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/export.h>
00022 #include <geos/geom/Coordinate.h>
00023
00024
00025 namespace geos {
00026 namespace geom {
00027 class CoordinateSequence;
00028 class Geometry;
00029 class Polygon;
00030 }
00031 }
00032
00033 namespace geos {
00034 namespace algorithm {
00035
00050 class GEOS_DLL CentroidArea {
00051
00052 public:
00053
00054 CentroidArea()
00055 :
00056 basePt(0.0, 0.0),
00057 areasum2(0)
00058 {}
00059
00060 ~CentroidArea() {}
00061
00068 void add(const geom::Geometry *geom);
00069
00076 void add(const geom::CoordinateSequence *ring);
00077
00078 geom::Coordinate* getCentroid() const;
00079
00081 bool getCentroid(geom::Coordinate& ret) const;
00082
00083 private:
00084
00086 geom::Coordinate basePt;
00087
00088
00089 geom::Coordinate triangleCent3;
00090
00092 double areasum2;
00093
00095 geom::Coordinate cg3;
00096
00097 void setBasePoint(const geom::Coordinate &newbasePt);
00098
00099 void add(const geom::Polygon *poly);
00100
00101 void addShell(const geom::CoordinateSequence *pts);
00102
00103 void addHole(const geom::CoordinateSequence *pts);
00104
00105 void addTriangle(const geom::Coordinate &p0, const geom::Coordinate &p1,
00106 const geom::Coordinate &p2,bool isPositiveArea);
00107
00108 static void centroid3(const geom::Coordinate &p1, const geom::Coordinate &p2,
00109 const geom::Coordinate &p3, geom::Coordinate &c);
00110
00111 static double area2(const geom::Coordinate &p1, const geom::Coordinate &p2,
00112 const geom::Coordinate &p3);
00113
00114 };
00115
00116 }
00117 }
00118
00119
00120 #endif // GEOS_ALGORITHM_CENTROIDAREA_H
00121
00122
00123
00124
00125
00126
00127
00128