org.locationtech.jts.geom.Polygon.getExteriorRing()方法的使用及代码示例

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

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

Polygon.getExteriorRing介绍

暂无

代码示例

代码示例来源:origin: graphhopper/graphhopper

for (Polygon shell : shells) {
  List<LinearRing> shellHoles = ((List<LinearRing>) shell.getUserData());
  punched.add(geometryFactory.createPolygon((LinearRing) (shell.getExteriorRing()),
      shellHoles.toArray(new LinearRing[shellHoles.size()])));

代码示例来源:origin: graphhopper/graphhopper

throw new IllegalStateException("no maximum polygon was found?");
} else {
  polygonShells.add(maxPolygon.getExteriorRing().getCoordinates());

代码示例来源:origin: geotools/geotools

public static Geometry exteriorRing(Geometry arg0) {
  if (!(arg0 instanceof Polygon)) return null;
  Polygon _this = (Polygon) arg0;
  return _this.getExteriorRing();
}

代码示例来源:origin: prestodb/presto

shellPart[currentPart] = true;
currentPart++;
currentPoint += polygon.getExteriorRing().getNumPoints();

代码示例来源:origin: geotools/geotools

private static Geometry smoothLineString(
    GeometryFactory factory, GeometrySmoother smoother, Geometry geom, double fit) {
  if (geom instanceof LinearRing) {
    // Treat as a Polygon
    Polygon poly = factory.createPolygon((LinearRing) geom, null);
    Polygon smoothed = smoother.smooth(poly, fit);
    return smoothed.getExteriorRing();
  } else {
    return smoother.smooth((LineString) geom, fit);
  }
}

代码示例来源:origin: geotools/geotools

@DescribeProcess(
  title = "Exterior Ring",
  description = "Returns the exterior ring of a polygonal geometry."
)
@DescribeResult(description = "Exterior ring of geometry")
public static Geometry exteriorRing(
    @DescribeParameter(name = "geom", description = "Input geometry") Polygon polygon) {
  return polygon.getExteriorRing();
}

代码示例来源:origin: geotools/geotools

List toList(Polygon poly) {
  ArrayList list = new ArrayList();
  list.add(
      new CoordinateSequenceEncoder(
          poly.getExteriorRing().getCoordinateSequence(), scale));
  for (int i = 0; i < poly.getNumInteriorRing(); i++) {
    list.add(
        new CoordinateSequenceEncoder(
            poly.getInteriorRingN(i).getCoordinateSequence(), scale));
  }
  return list;
}

代码示例来源:origin: locationtech/spatial4j

protected void write(JsonGenerator gen, Polygon p) throws IOException {
 gen.writeStartArray();
 write(gen, p.getExteriorRing().getCoordinateSequence());
 for (int i = 0; i < p.getNumInteriorRing(); i++) {
  write(gen, p.getInteriorRingN(i).getCoordinateSequence());
 }
 gen.writeEndArray();
}

代码示例来源:origin: geotools/geotools

private static int getCurvilinearElementsCount(Polygon poly) {
  int sum = getCurvilinearElementsCount(poly.getExteriorRing());
  for (int i = 0; i < poly.getNumInteriorRing(); i++) {
    sum += getCurvilinearElementsCount(poly.getInteriorRingN(i));
  }
  return sum;
}

代码示例来源:origin: geotools/geotools

private LinearRing makeSampleLinearRing(final GeometryFactory geomFac) {
  try {
    Polygon polyg = (Polygon) buildShiftedGeometry(makeSamplePolygon(geomFac), 0, 100);
    return (LinearRing) polyg.getExteriorRing();
  } catch (TopologyException te) {
    fail("Error creating sample polygon for testing " + te);
  }
  return null;
}

代码示例来源:origin: locationtech/spatial4j

protected void write(Encoder output, Polygon p) throws IOException {
 output.write(PolyshapeWriter.KEY_POLYGON);
 write(output, p.getExteriorRing().getCoordinateSequence());
 for (int i = 0; i < p.getNumInteriorRing(); i++) {
  output.startRing();
  write(output, p.getInteriorRingN(i).getCoordinateSequence());
 }
}

代码示例来源:origin: geotools/geotools

@Test
public void testToGeoemtry() {
  DefaultGeographicCRS crs = DefaultGeographicCRS.WGS84;
  // straight up
  Polygon polygon = JTS.toGeometry(new Envelope(-10, 10, -10, 10));
  assertEquals(5, polygon.getExteriorRing().getCoordinateSequence().size());
  // bounding box
  polygon = JTS.toGeometry((BoundingBox) new ReferencedEnvelope(-10, 10, -10, 10, crs));
  assertEquals(5, polygon.getExteriorRing().getCoordinateSequence().size());
}

代码示例来源:origin: geotools/geotools

private void writePolygon(Polygon poly, OutStream os) throws IOException {
  writeByteOrder(os);
  writeGeometryType(DB2WKBConstants.wkbPolygon2D, os);
  writeInt(poly.getNumInteriorRing() + 1, os);
  writeCoordinateSequence(poly.getExteriorRing().getCoordinateSequence(), true, os);
  for (int i = 0; i < poly.getNumInteriorRing(); i++) {
    writeCoordinateSequence(poly.getInteriorRingN(i).getCoordinateSequence(), true, os);
  }
}

代码示例来源:origin: geotools/geotools

public void testMultiSurface() throws Exception {
    GMLConfiguration gml = new GMLConfiguration(true);
    Parser p = new Parser(gml);
    Object multiSurface = p.parse(getClass().getResourceAsStream("multisurface.xml"));
    assertTrue(multiSurface instanceof MultiPolygon);
    MultiPolygon mp = (MultiPolygon) multiSurface;
    assertEquals(1, mp.getNumGeometries());
    Polygon poly = (Polygon) mp.getGeometryN(0);
    assertTrue(poly.getExteriorRing() instanceof CompoundRing);
  }
}

代码示例来源:origin: geotools/geotools

private LineString circleArcInBounds(
    double x, double y, double radius, ReferencedEnvelope bounds) {
  Point center = gf.createPoint(new Coordinate(x, y));
  Polygon buffered = (Polygon) center.buffer(radius, 64);
  Polygon mask = JTS.toGeometry(bounds);
  Geometry intersection = buffered.getExteriorRing().intersection(mask);
  return (LineString) intersection;
}

代码示例来源:origin: geotools/geotools

@Test
public void testFullyOutsideCircle() throws Exception {
  Point p = (Point) wkt.read("POINT(5 5)");
  LineString ls = ((Polygon) p.buffer(10)).getExteriorRing();
  Geometry clipped = clipper.clip(ls, false);
  assertNull(clipped);
  showResult("Circle around", ls, clipped);
}

代码示例来源:origin: geotools/geotools

@Test
public void testCrossingCircle() throws Exception {
  Point p = (Point) wkt.read("POINT(5 5)");
  LineString ls = ((Polygon) p.buffer(6)).getExteriorRing();
  MultiLineString clipped = (MultiLineString) clipper.clip(ls, false);
  assertEquals(4, clipped.getNumGeometries());
  showResult("Circle around", ls, clipped);
}

代码示例来源:origin: geotools/geotools

public void testPolygon3D() throws Exception {
  GML3MockData.polygon3D(document, document, true);
  Polygon polygon = (Polygon) parse();
  assertNotNull(polygon);
  LineString exterior = polygon.getExteriorRing();
  assertTrue(new Coordinate(1d, 2d, 10d).equals3D(exterior.getCoordinateN(0)));
  LineString interior = polygon.getInteriorRingN(0);
  assertTrue(new Coordinate(1d, 2d, 10d).equals3D(interior.getCoordinateN(0)));
}

代码示例来源:origin: geotools/geotools

public void testPolygonPosList3D() throws Exception {
  GML3MockData.polygonWithPosList3D(document, document, true);
  Polygon polygon = (Polygon) parse();
  assertNotNull(polygon);
  LineString exterior = polygon.getExteriorRing();
  assertTrue(new Coordinate(1d, 2d, 10d).equals3D(exterior.getCoordinateN(0)));
  LineString interior = polygon.getInteriorRingN(0);
  assertTrue(new Coordinate(1d, 2d, 10d).equals3D(interior.getCoordinateN(0)));
}

代码示例来源:origin: geotools/geotools

public void test3D() throws Exception {
  GML3MockData.multiPolygon3D(document, document);
  MultiPolygon multiPolygon = (MultiPolygon) parse();
  assertNotNull(multiPolygon);
  assertEquals(2, multiPolygon.getNumGeometries());
  Polygon polygon = (Polygon) multiPolygon.getGeometryN(0);
  LineString exterior = polygon.getExteriorRing();
  assertTrue(new Coordinate(1d, 2d, 10d).equals3D(exterior.getCoordinateN(0)));
  LineString interior = polygon.getInteriorRingN(0);
  assertTrue(new Coordinate(1d, 2d, 10d).equals3D(interior.getCoordinateN(0)));
}

相关文章