00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef GEOS_ALGORITHM_CENTROIDAREA_H
00021 #define GEOS_ALGORITHM_CENTROIDAREA_H
00022
00023
00024 #include <geos/export.h>
00025 #include <geos/geom/Coordinate.h>
00026
00027
00028 namespace geos {
00029 namespace geom {
00030 class CoordinateSequence;
00031 class Geometry;
00032 class Polygon;
00033 }
00034 }
00035
00036 namespace geos {
00037 namespace algorithm {
00038
00060 class GEOS_DLL CentroidArea {
00061
00062 public:
00063
00064 CentroidArea()
00065 :
00066 basePt(0.0, 0.0),
00067 areasum2(0.0),
00068 totalLength(0.0)
00069 {}
00070
00071 ~CentroidArea() {}
00072
00079 void add(const geom::Geometry *geom);
00080
00087 void add(const geom::CoordinateSequence *ring);
00088
00089
00090 geom::Coordinate* getCentroid() const;
00091
00093 bool getCentroid(geom::Coordinate& ret) const;
00094
00095 private:
00096
00098 geom::Coordinate basePt;
00099
00100
00101 geom::Coordinate triangleCent3;
00102
00104 double areasum2;
00105
00107 geom::Coordinate cg3;
00108
00109
00110 geom::Coordinate centSum;
00111 double totalLength;
00112
00113 void setBasePoint(const geom::Coordinate &newbasePt);
00114
00115 void add(const geom::Polygon *poly);
00116
00117 void addShell(const geom::CoordinateSequence *pts);
00118
00119 void addHole(const geom::CoordinateSequence *pts);
00120
00121 void addTriangle(const geom::Coordinate &p0, const geom::Coordinate &p1,
00122 const geom::Coordinate &p2,bool isPositiveArea);
00123
00124 static void centroid3(const geom::Coordinate &p1, const geom::Coordinate &p2,
00125 const geom::Coordinate &p3, geom::Coordinate &c);
00126
00127 static double area2(const geom::Coordinate &p1, const geom::Coordinate &p2,
00128 const geom::Coordinate &p3);
00129
00139 void addLinearSegments(const geom::CoordinateSequence& pts);
00140
00141 };
00142
00143 }
00144 }
00145
00146
00147 #endif // GEOS_ALGORITHM_CENTROIDAREA_H