本文整理了Java中com.vividsolutions.jts.geom.Polygon.difference()
方法的一些代码示例,展示了Polygon.difference()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Polygon.difference()
方法的具体详情如下:
包路径:com.vividsolutions.jts.geom.Polygon
类名称:Polygon
方法名:difference
暂无
代码示例来源:origin: org.geotools/gt-render
public Geometry difference(Geometry other) {
return polygon.difference(other);
}
代码示例来源:origin: org.orbisgis/orbisgis-core
/**
* Cuts a Polygon with a Polygon.
*
* @param polygon
* @param extrudePolygon
* @return
*/
public static List<Polygon> cutPolygonWithPolygon(Polygon polygon, Polygon extrudePolygon) {
Geometry geom = polygon.difference(extrudePolygon);
ArrayList<Polygon> polygons = new ArrayList<Polygon>();
for (int i = 0; i < geom.getNumGeometries(); i++) {
Polygon subGeom = (Polygon) geom.getGeometryN(i);
polygons.add(subGeom);
}
return polygons;
}
代码示例来源:origin: kiselev-dv/gazetteer
private static MultiPolygon substract(MultiPolygon outer, MultiPolygon inner) {
List<Polygon> polygons = new ArrayList<Polygon>();
if(inner != null && !inner.isEmpty()) {
for(int j = 0; j < outer.getNumGeometries(); j++) {
Polygon outerN = (Polygon) outer.getGeometryN(j);
for(int i = 0; i < inner.getNumGeometries(); i++) {
Polygon innerN = (Polygon) inner.getGeometryN(i);
if(outerN.intersects(innerN)) {
outerN = (Polygon) outerN.difference(innerN);
}
}
if(!outerN.isEmpty()) {
polygons.add(outerN);
}
}
}
Polygon[] ps = polygons.toArray(new Polygon[polygons.size()]);
MultiPolygon mp = geometryFactory.createMultiPolygon(ps);
if(mp.isValid()) {
return mp;
}
return null;
}
代码示例来源:origin: org.orbisgis/h2gis
Collection<Geometry> shadowParts = new ArrayList<Geometry>();
for (Polygon shadowPolygon : shadows) {
shadowParts.add(shadowPolygon.difference(polygon));
代码示例来源:origin: org.orbisgis/h2gis-functions
Collection<Geometry> shadowParts = new ArrayList<Geometry>();
for (Polygon shadowPolygon : shadows) {
shadowParts.add(shadowPolygon.difference(polygon));
代码示例来源:origin: kiselev-dv/gazetteer
Polygon difference = (Polygon) outer.difference(inner);
if (difference.isValid()) {
r = difference;
代码示例来源:origin: osmlab/atlas
mergedMembers = outerPolygon.difference(innerPolygon);
代码示例来源:origin: org.geomajas.extension/geomajas-extension-command
public void execute(SplitPolygonRequest request, SplitPolygonResponse response) throws Exception {
// convert to most accurate precision model
Polygon polygon = null;
try {
polygon = (Polygon) converter.toJts(request.getPolygon());
} catch (Exception e) {
// throw new GeomajasException();
}
GeometryFactory factory = new GeometryFactory(new PrecisionModel(), polygon.getFactory().getSRID());
Polygon p = (Polygon) factory.createGeometry(polygon);
LineString l = (LineString) factory.createGeometry(converter.toJts(request.getLineString()));
int precision = 11;
com.vividsolutions.jts.geom.Geometry buffered = factory.createGeometryCollection(null);
while (buffered.isEmpty()) {
buffered = l.buffer(Math.pow(10.0, -(precision--)));
}
com.vividsolutions.jts.geom.Geometry diff = p.difference(buffered);
if (diff instanceof Polygon) {
response.setPolygons(new Geometry[] {converter.toDto(diff)});
} else if (diff instanceof MultiPolygon) {
Geometry[] polygons = new Geometry[diff.getNumGeometries()];
for (int i = 0; i < diff.getNumGeometries(); i++) {
polygons[i] = converter.toDto(diff.getGeometryN(i));
// makePrecise(polygon.getPrecisionModel(), polygons[i]);
}
response.setPolygons(polygons);
}
}
内容来源于网络,如有侵权,请联系作者删除!