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