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

x33g5p2x  于2022-01-19 转载在 其他  
字(7.6k)|赞(0)|评价(0)|浏览(166)

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

GeometryFactory.createPolygon介绍

[英]Constructs a Polygon with the given exterior boundary.
[中]使用给定的外部边界构造一个Polygon

代码示例

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

return GEOMETRY_FACTORY.createMultiPolygon();
  return GEOMETRY_FACTORY.createPolygon();
      polygons.add(GEOMETRY_FACTORY.createPolygon(shell, holes.toArray(new LinearRing[0])));
      holes.clear();
polygons.add(GEOMETRY_FACTORY.createPolygon(shell, holes.toArray(new LinearRing[0])));

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

holes.add(ring);
  else
    shells.add(geometryFactory.createPolygon(ring));
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

properties.put("bucket", features.size());
feature.setProperties(properties);
feature.setGeometry(geometryFactory.createPolygon(polygonShell));
features.add(feature);

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

private static Geometry readEnvelope(SliceInput input)
{
  verify(input.available() > 0);
  double xMin = input.readDouble();
  double yMin = input.readDouble();
  double xMax = input.readDouble();
  double yMax = input.readDouble();
  Coordinate[] coordinates = new Coordinate[5];
  coordinates[0] = new Coordinate(xMin, yMin);
  coordinates[1] = new Coordinate(xMin, yMax);
  coordinates[2] = new Coordinate(xMax, yMax);
  coordinates[3] = new Coordinate(xMax, yMin);
  coordinates[4] = coordinates[0];
  return GEOMETRY_FACTORY.createPolygon(coordinates);
}

代码示例来源:origin: hibernate/hibernate-orm

/**
 * Converts the specified {@code Envelope} to a {@code Polygon} having the specified srid.
 *
 * @param env The envelope to convert
 * @param srid The srid for the polygon
 *
 * @return The Polygon
 */
public static Polygon toPolygon(Envelope env, int srid) {
  final Coordinate[] coords = new Coordinate[5];
  coords[0] = new Coordinate( env.getMinX(), env.getMinY() );
  coords[1] = new Coordinate( env.getMinX(), env.getMaxY() );
  coords[2] = new Coordinate( env.getMaxX(), env.getMaxY() );
  coords[3] = new Coordinate( env.getMaxX(), env.getMinY() );
  coords[4] = new Coordinate( env.getMinX(), env.getMinY() );
  final LinearRing shell = geomFactory.createLinearRing( coords );
  final Polygon pg = geomFactory.createPolygon( shell, null );
  pg.setSRID( srid );
  return pg;
}

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

/**
 * Convience constructor for GeometryFactory.createPolygon.
 *
 * <p>The provided xy ordinates are turned into a linear rings.
 *
 * @param xy Two dimensional ordiantes.
 * @return Polygon
 */
public Polygon polygon(int[] xy) {
  LinearRing shell = ring(xy);
  return gf.createPolygon(shell, null);
}

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

public Polygon createPolygon(LinearRing shell) {
  if (shell instanceof CurvedGeometry) {
    return new CurvePolygon(shell, (LinearRing[]) null, this, tolerance);
  } else {
    return delegate.createPolygon(shell);
  }
}

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

/**
 * Creates an empty 3D Polygon.
 *
 * @return an empty Polygon
 */
public Polygon polygonZ() {
  return geomFact.createPolygon(linearRingZ(), null);
}

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

/**
 * Creates a Polygon from a list of XY coordinates.
 *
 * @param ord a list of XY ordinates
 * @return a Polygon
 */
public Polygon polygon(double... ord) {
  return geomFact.createPolygon(linearRing(ord), null);
}

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

/**
 * Create a simple polygon (no holes).
 *
 * @param coords the coords of the polygon.
 * @return the {@link Polygon}.
 */
public static Polygon createSimplePolygon(Coordinate[] coords) {
  return GF.createPolygon(GF.createLinearRing(coords), null);
}

代码示例来源:origin: org.elasticsearch/elasticsearch

protected Polygon toPolygonS4J(GeometryFactory factory) {
  final LinearRing shell = linearRingS4J(factory, this.shell.coordinates);
  final LinearRing[] holes = new LinearRing[this.holes.size()];
  Iterator<LineStringBuilder> iterator = this.holes.iterator();
  for (int i = 0; iterator.hasNext(); i++) {
    holes[i] = linearRingS4J(factory, iterator.next().coordinates);
  }
  return factory.createPolygon(shell, holes);
}

代码示例来源:origin: hibernate/hibernate-orm

};
Polygon window = geometryFactory.createPolygon( coordinates );
Event event = entityManager.createQuery(
  "select e " +

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

public Polygon createPolygon(LinearRing shell, LinearRing[] holes) {
  if (shell instanceof CurvedGeometry || containsCurves(holes)) {
    return new CurvePolygon(shell, holes, this, tolerance);
  } else {
    return delegate.createPolygon(shell, holes);
  }
}

代码示例来源: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: locationtech/spatial4j

/** As if the ring is the outer ring of a polygon */
SpatialRelation relateEnclosedRing(LinearRing ring) {
 SpatialRelation rel = relateLineString(ring);
 if (rel == SpatialRelation.DISJOINT
     && ctx.getGeometryFactory().createPolygon(ring, null).contains(ctrGeom)) {
  // If it contains the circle center point, then the result is CONTAINS
  rel = SpatialRelation.CONTAINS;
 }
 return rel;
}

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

private Polygon readPolygon() throws IOException {
  int numRings = dis.readInt();
  LinearRing[] holes = null;
  if (numRings > 1) holes = new LinearRing[numRings - 1];
  LinearRing shell = readLinearRing();
  for (int i = 0; i < numRings - 1; i++) {
    holes[i] = readLinearRing();
  }
  return factory.createPolygon(shell, holes);
}

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

private void addFullAreaPolygon(List<Polygon> geometriesList) {
  Coordinate[] coordinateArray = new Coordinate[5];
  coordinateArray[0] = new Coordinate(imageProperties.minX - 1, imageProperties.minY - 1);
  coordinateArray[1] = new Coordinate(imageProperties.maxX, imageProperties.minY - 1);
  coordinateArray[2] = new Coordinate(imageProperties.maxX, imageProperties.maxY);
  coordinateArray[3] = new Coordinate(imageProperties.minX - 1, imageProperties.maxY);
  coordinateArray[4] = new Coordinate(imageProperties.minX - 1, imageProperties.minY - 1);
  LinearRing linearRing = GF.createLinearRing(coordinateArray);
  Polygon polygon = GF.createPolygon(linearRing, null);
  geometriesList.add(polygon);
}

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

public void testCreateSchemaAndInsertPolyRectangle() throws Exception {
  LiteCoordinateSequenceFactory csf = new LiteCoordinateSequenceFactory();
  GeometryFactory gf = new GeometryFactory(csf);
  LinearRing shell =
      gf.createLinearRing(
          csf.create(
              new double[] {0, 0, 99, 1, 0, 33, 1, 1, 66, 0, 1, 33, 0, 0, 99},
              3));
  Polygon poly = gf.createPolygon(shell, null);
  checkCreateSchemaAndInsert(poly);
}

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

public void testContainsFilter() throws Exception {
  FilterFactory2 ff = CommonFactoryFinder.getFilterFactory2(null);
  // should match only "r2"
  GeometryFactory gf = new GeometryFactory();
  PackedCoordinateSequenceFactory sf = new PackedCoordinateSequenceFactory();
  LinearRing shell =
      gf.createLinearRing(sf.create(new double[] {2, -1, 2, 5, 4, 5, 4, -1, 2, -1}, 2));
  Polygon polygon = gf.createPolygon(shell, null);
  Contains cs = ff.contains(ff.literal(polygon), ff.property(aname("geom")));
  FeatureCollection features = dataStore.getFeatureSource(tname("road")).getFeatures(cs);
  checkSingleResult(features, "r2");
}

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

@Test
public void smoothPolygon() {
  Coordinate[] coords = getPolyCoords();
  Polygon poly = factory.createPolygon(factory.createLinearRing(coords), null);
  Geometry smoothed = JTS.smooth(poly, 0);
  assertTrue(smoothed instanceof Polygon);
  CoordList list = new CoordList(smoothed.getCoordinates());
  assertTrue(list.containsAll(coords));
  Envelope polyEnv = poly.getEnvelopeInternal();
  Envelope smoothEnv = smoothed.getEnvelopeInternal();
  assertTrue(smoothEnv.covers(polyEnv));
}

相关文章