本文整理了Java中org.locationtech.jts.geom.Polygon.getCentroid()
方法的一些代码示例,展示了Polygon.getCentroid()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Polygon.getCentroid()
方法的具体详情如下:
包路径:org.locationtech.jts.geom.Polygon
类名称:Polygon
方法名:getCentroid
暂无
代码示例来源:origin: geotools/geotools
public Point getCentroid() {
return polygon.getCentroid();
}
代码示例来源:origin: mapsforge/mapsforge
} else {
Point center = polygon.getCentroid();
LatLong centroid = new LatLong(center.getY(), center.getX());
double disOld = centroid.sphericalDistance(new LatLong(adminArea.getKey().lat, adminArea.getKey().lon));
代码示例来源:origin: geotools/geotools
/**
* Finds a centroid for a polygon catching any exceptions resulting from generalization or other
* polygon irregularities.
*
* @param geom The polygon.
* @return The polygon centroid, or null if it can't be found.
*/
public static Point getPolygonCentroid(Polygon geom) {
Point centroid;
try {
centroid = geom.getCentroid();
} catch (Exception e) {
// generalized polygons causes problems - this
// tries to hide them.
try {
centroid = geom.getExteriorRing().getCentroid();
} catch (Exception ee) {
try {
centroid = geom.getFactory().createPoint(geom.getCoordinate());
} catch (Exception eee) {
return null; // we're hooped
}
}
}
return centroid;
}
代码示例来源:origin: Geomatys/geotoolkit
private static Point convertToPoint(final Polygon pt){
return pt.getCentroid();
}
代码示例来源:origin: mapsforge/mapsforge
Point center = polygon.getCentroid();
if (center == null) {
return;
代码示例来源:origin: geotools/geotools
public void testSampleForCentralPoint() throws Exception {
// create a "C" shape polygon that won't contain it's centroid
Polygon g =
(Polygon)
new WKTReader()
.read(
"POLYGON ((-112.534433451864 43.8706532611928,-112.499157652296 44.7878240499628,-99.6587666095152 44.7878240499628,-99.7242788087131 43.2155312692142,-111.085391877449 43.099601544023,-110.744593363875 36.1862602686501,-98.6760836215473 35.9436771582516,-98.7415958207452 33.5197257879307,-111.77852346112 33.9783111823157,-111.758573671673 34.6566040234952,-113.088767445077 34.7644575726901,-113.023255245879 43.8706532611928,-112.534433451864 43.8706532611928))");
Point p = g.getCentroid();
assertFalse(g.contains(p));
// test with few samples, we shouldn't hit the inside
assertNull(RendererUtilities.sampleForInternalPoint(g, p, null, null, -1, 2));
// up the samples, we should hit the inside now
assertNotNull(RendererUtilities.sampleForInternalPoint(g, p, null, null, -1, 10));
}
代码示例来源:origin: locationtech/geowave
return GeometryUtils.GEOMETRY_FACTORY.createPolygon(orderedCoords).getCentroid();
内容来源于网络,如有侵权,请联系作者删除!