本文整理汇总了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();
}