本文整理了Java中com.vividsolutions.jts.geom.Polygon.getCentroid()
方法的一些代码示例,展示了Polygon.getCentroid()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Polygon.getCentroid()
方法的具体详情如下:
包路径:com.vividsolutions.jts.geom.Polygon
类名称:Polygon
方法名:getCentroid
暂无
代码示例来源:origin: opentripplanner/OpenTripPlanner
point = (Point) geom;
} else if (geom instanceof Polygon) {
point = ((Polygon) geom).getCentroid();
} else if (geom instanceof MultiPolygon) {
point = ((MultiPolygon) geom).getCentroid();
代码示例来源:origin: org.geotools/gt-render
public Point getCentroid() {
return polygon.getCentroid();
}
代码示例来源:origin: kiselev-dv/gazetteer
.getJSONArray(GeoJsonWriter.COORDINATES);
Point centroid = GeoJsonWriter.getPolygonGeometry(coords).getCentroid();
代码示例来源:origin: osmlab/atlas
/**
* This will return the centroid of a given polygon. It can handle complex polygons including
* multiple polygons. This will not necessarily return a location that is contained within the
* original polygon. For example if you have two concentric circles forming a donut shape, one
* smaller one contained within the bigger one. The centroid of that polygon will be at the
* center technically outside of the polygon. This is a very different concept to a
* representative point.
*
* @return a Location object that is the centroid of the polygon
*/
public Location center()
{
final Point point = JTS_POLYGON_CONVERTER.convert(this).getCentroid();
return new JtsLocationConverter().backwardConvert(point.getCoordinate());
}
代码示例来源:origin: kiselev-dv/gazetteer
private static void stripe(Polygon p, List<Polygon> result) {
Polygon bbox = (Polygon) p.getEnvelope();
Point centroid = bbox.getCentroid();
double snapX = fileNameKeyGenerator.roundX(centroid);
double minX = p.getEnvelopeInternal().getMinX();
double maxX = p.getEnvelopeInternal().getMaxX();
if(snapX > minX && snapX < maxX) {
List<Polygon> splitPolygon = GeometryUtils.splitPolygon(p,
factory.createLineString(new Coordinate[]{new Coordinate(snapX, 89.0), new Coordinate(snapX, -89.0)}));
for(Polygon cp : splitPolygon) {
stripe(cp, result);
}
}
else {
result.add(p);
}
}
代码示例来源:origin: jhpoelen/eol-globi-data
static protected LatLng calculateCentroidOfBBox(double left, double top, double right, double bottom) {
LatLng latLng;
if (left == right && top == bottom) {
latLng = new LatLng(top, left);
} else {
Coordinate[] points = {GeoUtil.getCoordinate(top, left), GeoUtil.getCoordinate(top, right),
GeoUtil.getCoordinate(bottom, right), GeoUtil.getCoordinate(bottom, left), GeoUtil.getCoordinate(top, left)};
GeometryFactory geometryFactory = new GeometryFactory();
Polygon polygon = geometryFactory.createPolygon(points);
Point centroid = polygon.getCentroid();
latLng = new LatLng(centroid.getCoordinate().y, centroid.getCoordinate().x);
}
return latLng;
}
代码示例来源:origin: org.geotools/gt2-render
centroid = geom.getCentroid(); // this where you would do the
代码示例来源:origin: org.geotools/gt-render
centroid = geom.getCentroid();
} catch (Exception e) {
代码示例来源:origin: org.geoserver.extension/wps-core
.getCentroid().getCoordinate();
Point p = gf.createPoint(centre);
b.add(p);
内容来源于网络,如有侵权,请联系作者删除!