com.vividsolutions.jts.geom.Polygon.union()方法的使用及代码示例

x33g5p2x  于2022-01-26 转载在 其他  
字(2.6k)|赞(0)|评价(0)|浏览(132)

本文整理了Java中com.vividsolutions.jts.geom.Polygon.union()方法的一些代码示例,展示了Polygon.union()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Polygon.union()方法的具体详情如下:
包路径:com.vividsolutions.jts.geom.Polygon
类名称:Polygon
方法名:union

Polygon.union介绍

暂无

代码示例

代码示例来源:origin: opentripplanner/OpenTripPlanner

Polygon otherHole = it.next();
if (otherHole.relate(polygon, "F***1****")) {
  polygon = (Polygon) polygon.union(otherHole);
  it.remove();

代码示例来源:origin: opentripplanner/OpenTripPlanner

/**
 * Safely add a vertex to this area. This creates edges to all other vertices unless those edges would cross one of the original edges.
 */
public void addVertex(IntersectionVertex newVertex, Graph graph) {
  GeometryFactory geometryFactory = GeometryUtils.getGeometryFactory();
  if (edges.size() == 0) {
    throw new RuntimeException("Can't add a vertex to an empty area");
  }
  @SuppressWarnings("unchecked")
  HashSet<IntersectionVertex> verticesCopy = (HashSet<IntersectionVertex>) vertices.clone();
  VERTEX: for (IntersectionVertex v : verticesCopy) {
    LineString newGeometry = geometryFactory.createLineString(new Coordinate[] {
        newVertex.getCoordinate(), v.getCoordinate() });
    // ensure that new edge does not leave the bounds of the original area, or
    // fall into any holes
    if (!originalEdges.union(originalEdges.getBoundary()).contains(newGeometry)) {
      continue VERTEX;
    }
    // check to see if this splits multiple NamedAreas. This code is rather similar to
    // code in OSMGBI, but the data structures are different
    createSegments(newVertex, v, areas, graph);
  }
  vertices.add(newVertex);
}

代码示例来源:origin: org.geotools/gt-render

public Geometry union() {
  return polygon.union();
}

代码示例来源:origin: org.geotools/gt-render

public Geometry union(Geometry other) {
  return polygon.union(other);
}

代码示例来源:origin: stackoverflow.com

// build polygon p1
Polygon p1 = new GeometryFactory().createPolygon(new Coordinate[]{new Coordinate(0,0), new Coordinate(0,10), new Coordinate(10,10), new Coordinate(10,0), new Coordinate(0,0)});
// build polygon p2
Polygon p2 = new GeometryFactory().createPolygon(new Coordinate[]{new Coordinate(0,0), new Coordinate(0,30), new Coordinate(5,30), new Coordinate(5,0), new Coordinate(0,0)});
// calculate polygon3 as the union of p1 and p2
Polygon p3 = (Polygon) p1.union(p2);
// print simple WKT
System.out.println(p3.toText());

代码示例来源:origin: stackoverflow.com

// create polygons
Polygon p1 = new GeometryFactory().createPolygon(new Coordinate[]{new Coordinate(0, 0), new Coordinate(0,10), new Coordinate(10,10), new Coordinate(10,0), new Coordinate(0,0)});
Polygon p2 = new GeometryFactory().createPolygon(new Coordinate[]{new Coordinate(5,5), new Coordinate(15,5), new Coordinate(15,15), new Coordinate(5,15), new Coordinate(5,5)});
// calculate union
Geometry union = p1.union(p2);
// print as WKT
System.out.println(union.toText());

相关文章