GEOS
3.9.1dev
|
Computes the centroid of a Geometry of any dimension. More...
#include <Centroid.h>
Public Member Functions | |
Centroid (const geom::Geometry &geom) | |
Creates a new instance for computing the centroid of a geometry. More... | |
bool | getCentroid (geom::Coordinate ¢) const |
Gets the computed centroid. More... | |
Static Public Member Functions | |
static bool | getCentroid (const geom::Geometry &geom, geom::Coordinate ¢) |
Computes the centroid point of a geometry. More... | |
Private Member Functions | |
void | add (const geom::Geometry &geom) |
void | setAreaBasePoint (const geom::Coordinate &basePt) |
void | add (const geom::Polygon &poly) |
void | addShell (const geom::CoordinateSequence &pts) |
void | addHole (const geom::CoordinateSequence &pts) |
void | addTriangle (const geom::Coordinate &p0, const geom::Coordinate &p1, const geom::Coordinate &p2, bool isPositiveArea) |
void | addLineSegments (const geom::CoordinateSequence &pts) |
void | addPoint (const geom::Coordinate &pt) |
Static Private Member Functions | |
static void | centroid3 (const geom::Coordinate &p1, const geom::Coordinate &p2, const geom::Coordinate &p3, geom::Coordinate &c) |
static double | area2 (const geom::Coordinate &p1, const geom::Coordinate &p2, const geom::Coordinate &p3) |
Private Attributes | |
std::unique_ptr< geom::Coordinate > | areaBasePt |
geom::Coordinate | triangleCent3 |
geom::Coordinate | cg3 |
geom::Coordinate | lineCentSum |
geom::Coordinate | ptCentSum |
double | areasum2 |
double | totalLength |
int | ptCount |
Computes the centroid of a Geometry of any dimension.
If the geometry is nomimally of higher dimension, but contains only components having a lower effective dimension (i.e. zero length or area), the centroid will be computed appropriately.
If the input geometries are empty, a null
Coordinate is returned.
Definition at line 61 of file Centroid.h.
|
inline |
Creates a new instance for computing the centroid of a geometry.
Definition at line 79 of file Centroid.h.
|
private |
Adds a Geometry to the centroid total.
geom | the geometry to add |
|
private |
|
private |
|
private |
Adds the line segments defined by an array of coordinates to the linear centroid accumulators.
pts | an array of Coordinates |
|
private |
Adds a point to the point centroid accumulator.
pt | a Coordinate |
|
private |
|
private |
|
staticprivate |
Returns twice the signed area of the triangle p1-p2-p3. The area is positive if the triangle is oriented CCW, and negative if CW.
|
staticprivate |
Computes three times the centroid of the triangle p1-p2-p3. The factor of 3 is left in to permit division to be avoided until later.
|
static |
Computes the centroid point of a geometry.
geom | the geometry to use |
cent | will be set to the centroid point, if any |
true
if a centroid could be computed, false
otherwise (empty geom) bool geos::algorithm::Centroid::getCentroid | ( | geom::Coordinate & | cent | ) | const |
Gets the computed centroid.
cent | will be set to the centroid point, if any |
true
if a centroid could be computed, false
otherwise (empty geom)
|
private |
|
private |
Definition at line 100 of file Centroid.h.
|
private |
Definition at line 105 of file Centroid.h.
|
private |
Definition at line 102 of file Centroid.h.
|
private |
Definition at line 103 of file Centroid.h.
|
private |
Definition at line 104 of file Centroid.h.
|
private |
Definition at line 107 of file Centroid.h.
|
private |
Definition at line 106 of file Centroid.h.
|
private |
Definition at line 101 of file Centroid.h.