本文整理匯總了Java中com.vividsolutions.jts.algorithm.CentroidArea類的典型用法代碼示例。如果您正苦於以下問題:Java CentroidArea類的具體用法?Java CentroidArea怎麽用?Java CentroidArea使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
CentroidArea類屬於com.vividsolutions.jts.algorithm包,在下文中一共展示了CentroidArea類的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: reportInternal
import com.vividsolutions.jts.algorithm.CentroidArea; //導入依賴的package包/類
@SuppressWarnings("unchecked")
public Object reportInternal (Argument args[], Context context)
throws ExtensionException, LogoException {
VectorFeature feature = getFeature(args[0]);
switch (feature.getShapeType()) {
case POINT:
CentroidPoint cp = new CentroidPoint();
cp.add(feature.getGeometry());
return new Vertex(cp.getCentroid());
case LINE:
CentroidLine cl = new CentroidLine();
cl.add(feature.getGeometry());
return new Vertex(cl.getCentroid());
case POLYGON:
CentroidArea ca = new CentroidArea();
ca.add(feature.getGeometry());
return new Vertex(ca.getCentroid());
default:
throw new ExtensionException("invalid shape type");
}
}
示例2: calculateMapCentroid
import com.vividsolutions.jts.algorithm.CentroidArea; //導入依賴的package包/類
private Coordinate calculateMapCentroid(List<Coordinate> coordinates) {
if (coordinates.size() == 1) {
return coordinates.get(0);
}
CentroidArea area = new CentroidArea();
area.add(coordinates.toArray(new Coordinate[coordinates.size()]));
return area.getCentroid();
}