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

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

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

Polygon.getNumPoints介绍

暂无

代码示例

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

@Override
  public int compare(Polygon o1, Polygon o2) {
    return o2.getNumPoints() - o1.getNumPoints();
  }
});

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

/**
 * Lossy conversion to a GraphHopper Polygon.
 */
public static Polygon create(org.locationtech.jts.geom.Polygon polygon) {
  double[] lats = new double[polygon.getNumPoints()];
  double[] lons = new double[polygon.getNumPoints()];
  for (int i = 0; i < polygon.getNumPoints(); i++) {
    lats[i] = polygon.getCoordinates()[i].y;
    lons[i] = polygon.getCoordinates()[i].x;
  }
  return new Polygon(lats, lons);
}

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

for (int j = 0; j < multiPolygon.getNumGeometries(); j++) {
  Polygon polygon = (Polygon) multiPolygon.getGeometryN(j);
  if (polygon.getNumPoints() > maxPoints) {
    maxPoints = polygon.getNumPoints();
    maxPolygon = polygon;

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

public int getNumPoints() {
  return polygon.getNumPoints();
}

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

for (int i = 0; i < numGeometries; i++) {
  Polygon polygon = (Polygon) geometry.getGeometryN(i);
  if (polygon.getNumPoints() > 0) {
    numParts += polygon.getNumInteriorRing() + 1;

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

public void testEncode2D() throws Exception {
  Polygon poly = GML3MockData.polygonLite2D();
  Document doc = encode(poly, GML.Polygon);
  checkDimension(doc, GML.Polygon.getLocalPart(), 2);
  checkPosListOrdinates(doc, 2 * poly.getNumPoints());
}

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

public void testEncode3D() throws Exception {
  Polygon poly = GML3MockData.polygonLite3D();
  Document doc = encode(poly, GML.Polygon);
  checkDimension(doc, GML.Polygon.getLocalPart(), 3);
  checkPosListOrdinates(doc, 3 * poly.getNumPoints());
}

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

private static void addElemInfo(
    List elemInfoList, MultiPolygon polys, final int STARTING_OFFSET, final int GTYPE) {
  Polygon poly;
  int offset = STARTING_OFFSET;
  int LEN = D(GTYPE) + L(GTYPE);
  for (int i = 0; i < polys.getNumGeometries(); i++) {
    poly = (Polygon) polys.getGeometryN(i);
    if (poly != null && !poly.isEmpty()) {
      addElemInfo(elemInfoList, poly, offset, GTYPE);
      if (isRectangle(poly)) {
        offset += (2 * LEN);
      } else {
        offset += (poly.getNumPoints() * LEN);
      }
    }
  }
}

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

PolygonNode(Polygon poly, GeometryContext context)
{
 super(poly, poly.getNumPoints(), null, context);
 this.poly = poly;
}

代码示例来源:origin: com.graphhopper/graphhopper-isochrone

@Override
  public int compare(Polygon o1, Polygon o2) {
    return o2.getNumPoints() - o1.getNumPoints();
  }
});

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

@Test
  public void testMakeValid() throws Exception {
    // An invalid polygon similar to this one
    //
    // *----*
    // |    |
    // *----*----*
    //      |    |
    //      *----*
    //
    // Will be split into 2 separate polygons through the makeValid method
    final int[] xPoints = {0, 5, 5, 5, 10, 10, 5, 0};
    final int[] yPoints = {0, 0, 5, 10, 10, 5, 5, 5};
    final int nPoints = xPoints.length;

    final Shape shape = new java.awt.Polygon(xPoints, yPoints, nPoints);
    final LinearRing geom = (LinearRing) JTS.toGeometry(shape);
    final GeometryFactory factory = new GeometryFactory();
    final org.locationtech.jts.geom.Polygon polygon = factory.createPolygon(geom);
    assertFalse(polygon.isValid());

    final List<org.locationtech.jts.geom.Polygon> validPols = JTS.makeValid(polygon, false);

    assertEquals(2, validPols.size());
    org.locationtech.jts.geom.Polygon polygon1 = validPols.get(0);
    org.locationtech.jts.geom.Polygon polygon2 = validPols.get(1);
    assertEquals(5, polygon1.getNumPoints());
    assertEquals(5, polygon2.getNumPoints());
  }
}

代码示例来源:origin: com.graphhopper/graphhopper-api

/**
 * Lossy conversion to a GraphHopper Polygon.
 */
public static Polygon create(org.locationtech.jts.geom.Polygon polygon) {
  double[] lats = new double[polygon.getNumPoints()];
  double[] lons = new double[polygon.getNumPoints()];
  for (int i = 0; i < polygon.getNumPoints(); i++) {
    lats[i] = polygon.getCoordinates()[i].y;
    lons[i] = polygon.getCoordinates()[i].x;
  }
  return new Polygon(lats, lons);
}

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

static void encode(Element e, Polygon g, PrintHandler output)
    throws OperationNotSupportedException, IOException {
  if ((g == null) || (g.getNumPoints() == 0)) {
    throw new IOException("Bad Polygon Data");

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

public Coordinate[] getCoordinates() {
 if (isEmpty()) {
  return new Coordinate[]{};
 }
 Coordinate[] coordinates = new Coordinate[getNumPoints()];
 int k = -1;
 Coordinate[] shellCoordinates = shell.getCoordinates();
 for (int x = 0; x < shellCoordinates.length; x++) {
  k++;
  coordinates[k] = shellCoordinates[x];
 }
 for (int i = 0; i < holes.length; i++) {
  Coordinate[] childCoordinates = holes[i].getCoordinates();
  for (int j = 0; j < childCoordinates.length; j++) {
   k++;
   coordinates[k] = childCoordinates[j];
  }
 }
 return coordinates;
}

代码示例来源:origin: com.graphhopper/graphhopper-isochrone

for (int j = 0; j < multiPolygon.getNumGeometries(); j++) {
  Polygon polygon = (Polygon) multiPolygon.getGeometryN(j);
  if (polygon.getNumPoints() > maxPoints) {
    maxPoints = polygon.getNumPoints();
    maxPolygon = polygon;

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

public Polygon simplify(Polygon p) {
    //best case is you're going to remove one point, don't bother with the work.
    //more likely to mess it up!
    if (p.getNumPoints() <= 5)
        return p;
    Envelope bbox = p.getEnvelopeInternal();
    //its smaller than a pixel - replace with a polygon representing its bbox
    if ((bbox.getWidth() <= distance) && (bbox.getWidth() <= distance)) {
        return createBBoxPolygon(bbox);
    }
    DouglasPeuckerSimplifier tss = new DouglasPeuckerSimplifier(p);
    tss.setDistanceTolerance(distance);
    tss.setEnsureValid(false);
    Geometry newGeom = tss.getResultGeometry();
    if (newGeom.isEmpty())
        return createBBoxPolygon(bbox);
    // ... sometime the DP simplifier returns linear rings instead of Polygon
    if (newGeom instanceof LinearRing)
        return geometryFactory.createPolygon((LinearRing)newGeom);
    return (Polygon) newGeom;
}

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

public void testPolygonGetCoordinates() throws Exception {
 Polygon p = (Polygon) reader.read(
    "POLYGON ( (0 0, 100 0, 100 100, 0 100, 0 0), "
   + "          (20 20, 20 80, 80 80, 80 20, 20 20)) ");
 Coordinate[] coordinates = p.getCoordinates();
 assertEquals(10, p.getNumPoints());
 assertEquals(10, coordinates.length);
 assertEquals(new Coordinate(0, 0), coordinates[0]);
 assertEquals(new Coordinate(20, 20), coordinates[9]);
}

代码示例来源:origin: io.prestosql/presto-geospatial-toolkit

for (int i = 0; i < numGeometries; i++) {
  Polygon polygon = (Polygon) geometry.getGeometryN(i);
  if (polygon.getNumPoints() > 0) {
    numParts += polygon.getNumInteriorRing() + 1;

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

for (int i = 0; i < numGeometries; i++) {
  Polygon polygon = (Polygon) geometry.getGeometryN(i);
  if (polygon.getNumPoints() > 0) {
    numParts += polygon.getNumInteriorRing() + 1;

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

assertEquals(0, (geometryFactory.createLinearRing((CoordinateSequence)null)).getNumPoints());
assertEquals(0, (geometryFactory.createLineString((Coordinate[])null)).getNumPoints());
assertEquals(0, (geometryFactory.createPolygon(null, null)).getNumPoints());
assertEquals(0, (geometryFactory.createMultiPolygon(null)).getNumPoints());
assertEquals(0, (geometryFactory.createMultiLineString(null)).getNumPoints());

相关文章