NetTopologySuite
 All Classes Namespaces Functions Variables Enumerations Enumerator Properties Pages
NetTopologySuite.Algorithm.Centroid Class Reference

Computes the centroid of a IGeometry of any dimension. If the geometry is nominally of higher dimension, but has lower effective dimension (i.e. contains only components having zero length or area), the centroid will be computed as for the equivalent lower-dimension geometry. If the input geometry is empty, a null Coordinate is returned. More...

Public Member Functions

 Centroid (IGeometry geom)
 Creates a new instance for computing the centroid of a geometry More...
 
Coordinate GetCentroid ()
 Gets the computed centroid. More...
 

Static Public Member Functions

static Coordinate GetCentroid (IGeometry geom)
 Computes the centroid point of a geometry. More...
 

Detailed Description

Computes the centroid of a IGeometry of any dimension. If the geometry is nominally of higher dimension, but has lower effective dimension (i.e. contains only components having zero length or area), the centroid will be computed as for the equivalent lower-dimension geometry. If the input geometry is empty, a null Coordinate is returned.

Algorithm

  • Dimension 2 - the centroid ic computed as a weighted sum of the centroids of a decomposition of the area into (possibly overlapping) triangles. Holes and multipolygons are handled correctly. See http://www.faqs.org/faqs/graphics/algorithms-faq/ for further details of the basic approach.
  • Dimension 1 - Computes the average of the midpoints of all line segments weighted by the segment length. Zero-length lines are treated as points.
  • Dimension 0 - Compute the average coordinate over all points. Repeated points are all included in the average

If the input geometries are empty, a null Coordinate is returned.

<version>1.7</version>

Constructor & Destructor Documentation

NetTopologySuite.Algorithm.Centroid.Centroid ( IGeometry  geom)

Creates a new instance for computing the centroid of a geometry

Member Function Documentation

static Coordinate NetTopologySuite.Algorithm.Centroid.GetCentroid ( IGeometry  geom)
static

Computes the centroid point of a geometry.

Parameters
geomThe geometry to use
Returns
The centroid point, or null if the geometry is empty
Coordinate NetTopologySuite.Algorithm.Centroid.GetCentroid ( )

Gets the computed centroid.

Returns
The computed centroid, or null if the input is empty

The centroid is computed from the highest dimension components present in the input. I.e. areas dominate lineal geometry, which dominates points. Degenerate geometry are computed using their effective dimension (e.g. areas may degenerate to lines or points)


The documentation for this class was generated from the following file: