00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #ifndef GEOS_ALGORITHM_CENTROIDAREA_H
00018 #define GEOS_ALGORITHM_CENTROIDAREA_H
00019
00020
00021 #include <geos/geom/Coordinate.h>
00022
00023
00024 namespace geos {
00025 namespace geom {
00026 class CoordinateSequence;
00027 class Geometry;
00028 class Polygon;
00029 }
00030 }
00031
00032 namespace geos {
00033 namespace algorithm {
00034
00049 class CentroidArea {
00050
00051 public:
00052
00053 CentroidArea()
00054 :
00055 basePt(0.0, 0.0),
00056 areasum2(0)
00057 {}
00058
00059 ~CentroidArea() {}
00060
00067 void add(const geom::Geometry *geom);
00068
00075 void add(const geom::CoordinateSequence *ring);
00076
00077 geom::Coordinate* getCentroid() const;
00078
00080 bool getCentroid(geom::Coordinate& ret) const;
00081
00082 private:
00083
00085 geom::Coordinate basePt;
00086
00087
00088 geom::Coordinate triangleCent3;
00089
00091 double areasum2;
00092
00094 geom::Coordinate cg3;
00095
00096 void setBasePoint(const geom::Coordinate &newbasePt);
00097
00098 void add(const geom::Polygon *poly);
00099
00100 void addShell(const geom::CoordinateSequence *pts);
00101
00102 void addHole(const geom::CoordinateSequence *pts);
00103
00104 void addTriangle(const geom::Coordinate &p0, const geom::Coordinate &p1,
00105 const geom::Coordinate &p2,bool isPositiveArea);
00106
00107 static void centroid3(const geom::Coordinate &p1, const geom::Coordinate &p2,
00108 const geom::Coordinate &p3, geom::Coordinate &c);
00109
00110 static double area2(const geom::Coordinate &p1, const geom::Coordinate &p2,
00111 const geom::Coordinate &p3);
00112
00113 };
00114
00115 }
00116 }
00117
00118
00119 #endif // GEOS_ALGORITHM_CENTROIDAREA_H
00120
00121
00122
00123
00124
00125
00126
00127