// MultiCurve: the average of the weighted line segments of all contained curves
// Ring: the average of the weighted line segments of the contained curves
if (this instanceof CurveImpl ||
this instanceof MultiCurveImpl ||
this instanceof RingImpl) {
CentroidLine cl = new CentroidLine(this.crs);
cl.add(this);
return cl.getCentroid();
} else
// SurfaceBoundary: the average of the weighted line segments of all curves of the exterior and interior rings
if (this instanceof SurfaceBoundaryImpl) {
CentroidLine cl = new CentroidLine(this.crs);
cl.add(((SurfaceBoundaryImpl)this).getExterior());
Iterator<Ring> interiors = ((SurfaceBoundaryImpl)this).getInteriors().iterator();
while (interiors.hasNext()) {
cl.add((GeometryImpl) interiors.next());
}
return cl.getCentroid();
} else
// Surface: the average of the surface (considers holes)
// MultiSurface: the average of all contained surfaces (considers holes)