com.vividsolutions.jts.algorithm

Class CentroidArea


public class CentroidArea
extends java.lang.Object

Computes the centroid of an area geometry.

Algorithm

Based on the usual algorithm for calculating the centroid as a weighted sum of the centroids of a decomposition of the area into (possibly overlapping) triangles. The algorithm has been extended to handle holes and multi-polygons. See http://www.faqs.org/faqs/graphics/algorithms-faq/ for further details of the basic approach.
Version:
1.6

Constructor Summary

CentroidArea()

Method Summary

void
add(Coordinate[] ring)
Adds the area defined by an array of coordinates.
void
add(Geometry geom)
Adds the area defined by a Geometry to the centroid total.
Coordinate
getCentroid()

Constructor Details

CentroidArea

public CentroidArea()

Method Details

add

public void add(Coordinate[] ring)
Adds the area defined by an array of coordinates. The array must be a ring; i.e. end with the same coordinate as it starts with.
Parameters:
ring - an array of Coordinates

add

public void add(Geometry geom)
Adds the area defined by a Geometry to the centroid total. If the geometry has no area it does not contribute to the centroid.
Parameters:
geom - the geometry to add

getCentroid

public Coordinate getCentroid()