GEOS: CentroidArea.h Source File

GEOS 3.5.0

- Main Page
- Related Pages
- Namespaces
- Classes
- Files

- File List

CentroidArea.h
1 /**********************************************************************
2 *
3 * GEOS - Geometry Engine Open Source
4 * http://geos.osgeo.org
5 *
6 * Copyright (C) 2005-2006 Refractions Research Inc.
7 * Copyright (C) 2001-2002 Vivid Solutions Inc.
8 *
9 * This is free software; you can redistribute and/or modify it under
10 * the terms of the GNU Lesser General Public Licence as published
11 * by the Free Software Foundation.
12 * See the COPYING file for more information.
13 *
14 **********************************************************************
15 *
16 * Last port: algorithm/CentroidArea.java r612
17 *
18 **********************************************************************/
19
20 #ifndef GEOS_ALGORITHM_CENTROIDAREA_H
21 #define GEOS_ALGORITHM_CENTROIDAREA_H
22
23
24 #include <geos/export.h>
25 #include <geos/geom/Coordinate.h>
26
27 // Forward declarations
28 namespace geos {
29 namespace geom {
30 class CoordinateSequence;
31 class Geometry;
32 class Polygon;
33 }
34 }
35
36 namespace geos {
37 namespace algorithm { // geos::algorithm
38
60 class GEOS_DLL CentroidArea {
61
62 public:
63
64 CentroidArea()
65 :
66 basePt(0.0, 0.0),
67 areasum2(0.0),
68 totalLength(0.0)
69 {}
70
71 ~CentroidArea() {}
72
79 void add(const geom::Geometry *geom);
80
87 void add(const geom::CoordinateSequence *ring);
88
89 // TODO: deprecate
90 geom::Coordinate* getCentroid() const;
91
93 bool getCentroid(geom::Coordinate& ret) const;
94
95 private:
96
98 geom::Coordinate basePt;
99
100 // temporary variable to hold centroid of triangle
101 geom::Coordinate triangleCent3;
102
104 double areasum2;
105
107 geom::Coordinate cg3;
108
109 // data for linear centroid computation, if needed
110 geom::Coordinate centSum;
111 double totalLength;
112
113 void setBasePoint(const geom::Coordinate &newbasePt);
114
115 void add(const geom::Polygon *poly);
116
117 void addShell(const geom::CoordinateSequence *pts);
118
119 void addHole(const geom::CoordinateSequence *pts);
120
121 void addTriangle(const geom::Coordinate &p0, const geom::Coordinate &p1,
122 const geom::Coordinate &p2,bool isPositiveArea);
123
124 static void centroid3(const geom::Coordinate &p1, const geom::Coordinate &p2,
125 const geom::Coordinate &p3, geom::Coordinate &c);
126
127 static double area2(const geom::Coordinate &p1, const geom::Coordinate &p2,
128 const geom::Coordinate &p3);
129
139 void addLinearSegments(const geom::CoordinateSequence& pts);
140
141 };
142
143 } // namespace geos::algorithm
144 } // namespace geos
145
146
147 #endif // GEOS_ALGORITHM_CENTROIDAREA_H
geos::geom::Coordinate
Coordinate is the lightweight class used to store coordinates.
Definition: Coordinate.h:60
geos::geom::Geometry
Basic implementation of Geometry, constructed and destructed by GeometryFactory.
Definition: Geometry.h:167
geos::geom::Polygon
Represents a linear polygon, which may include holes.
Definition: Polygon.h:66
geos::algorithm::CentroidArea
Computes the centroid of an area geometry.
Definition: CentroidArea.h:60
geos
Basic namespace for all GEOS functionalities.
Definition: IndexedNestedRingTester.h:25
geos::geom::CoordinateSequence
The internal representation of a list of coordinates inside a Geometry.
Definition: CoordinateSequence.h:59