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

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

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

GeometryFactory.createLinearRing介绍

[英]Creates a LinearRing using the given CoordinateSequence. A null or empty array creates an empty LinearRing. The points must form a closed and simple linestring.
[中]使用给定的坐标序列创建线性阵列。null或空数组将创建空的LinearRing。这些点必须形成闭合的简单线串。

代码示例

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

verify(holes.isEmpty(), "shell is null but holes found");
shell = GEOMETRY_FACTORY.createLinearRing(coordinates);
holes.add(GEOMETRY_FACTORY.createLinearRing(coordinates));

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

LinearRing ring = geometryFactory.createLinearRing(polyPoints
    .toArray(new Coordinate[polyPoints.size()]));
rings.add(ring);

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

/** {@inheritDoc} */
public Geometry toGeometry() {
  Coordinate[] ring = new Coordinate[7];
  System.arraycopy(vertices, 0, ring, 0, 6);
  ring[6] = vertices[0];
  return geomFactory.createPolygon(geomFactory.createLinearRing(ring), null);
}

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

/**
 * Creates a ring from the specified (<var>x</var>,<var>y</var>) coordinates. The coordinates
 * are stored in a flat array.
 */
public LinearRing ring(int[] xy) {
  Coordinate[] coords = new Coordinate[xy.length / 2];
  for (int i = 0; i < xy.length; i += 2) {
    coords[i / 2] = new Coordinate(xy[i], xy[i + 1]);
  }
  return gf.createLinearRing(coords);
}

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

@Override
public LinearRing linearize() {
  CoordinateSequence cs = delegate.getLinearizedCoordinateSequence(delegate.tolerance);
  return getFactory().createLinearRing(cs);
}

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

@Override
public LinearRing linearize() {
  CoordinateSequence cs = delegate.getLinearizedCoordinateSequence(delegate.tolerance);
  return getFactory().createLinearRing(cs);
}

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

/**
   * Creates a ring from the specified (<var>x</var>,<var>y</var>) coordinates. The coordinates
   * are stored in a flat array.
   */
  public LinearRing ring(int[] xy) {
    Coordinate[] coords = new Coordinate[xy.length / 2];

    for (int i = 0; i < xy.length; i += 2) {
      coords[i / 2] = new Coordinate(xy[i], xy[i + 1]);
    }

    return gf.createLinearRing(coords);
  }
}

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

public static LinearRing ring(int[] xy) {
  Coordinate[] coords = new Coordinate[xy.length / 2];
  for (int i = 0; i < xy.length; i += 2) {
    coords[i / 2] = new Coordinate(xy[i], xy[i + 1]);
  }
  return GF.createLinearRing(coords);
}

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

@Test
public void testCoordinateDimensionPolygonEmpty() {
  Geometry geom = gf.createPolygon(gf.createLinearRing((Coordinate[]) null), null);
  // empty geometries using CoordinateArraySequence always report 3
  assertEquals(3, CoordinateSequences.coordinateDimension(geom));
}

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

@Test
public void testCoordinateDimensionPolygonLite2D() {
  Geometry geom =
      liteGF.createPolygon(
          liteGF.createLinearRing(
              liteCSF.create(new double[] {1, 1, 2, 1, 2, 2, 1, 2, 1, 1}, 2)),
          null);
  assertEquals(2, CoordinateSequences.coordinateDimension(geom));
}

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

@Test
public void testCoordinateDimensionPolygonEmptyLite2D() {
  Geometry geom =
      liteGF.createPolygon(
          liteGF.createLinearRing(liteCSF.create(new double[0], 2)), null);
  assertEquals(2, CoordinateSequences.coordinateDimension(geom));
}

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

public void testCreateSchemaAndInsertPolyTriangle() 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, 0, 99}, 3));
  Polygon poly = gf.createPolygon(shell, null);
  checkCreateSchemaAndInsert(poly);
}

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

@Test
public void toEnvelope() {
  Coordinate[] coords = getPolyCoords();
  GeometryFactory gf = new GeometryFactory();
  Geometry geom = gf.createPolygon(gf.createLinearRing(coords), null);
  ReferencedEnvelope refEnv = JTS.toEnvelope(geom);
  assertTrue(geom.getEnvelopeInternal().equals(refEnv));
}

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

public void testIntersectsRingFilter() throws Exception {
  FilterFactory2 ff = CommonFactoryFinder.getFilterFactory2(null);
  // should match only "r1"
  GeometryFactory gf = new GeometryFactory();
  PackedCoordinateSequenceFactory sf = new PackedCoordinateSequenceFactory();
  LineString ls = gf.createLinearRing(sf.create(new double[] {2, 1, 2, 3, 0, 3, 2, 1}, 2));
  Intersects is = ff.intersects(ff.property(aname("geom")), ff.literal(ls));
  FeatureCollection features = dataStore.getFeatureSource(tname("road")).getFeatures(is);
  checkSingleResult(features, "r1");
}

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

@Test
public void smoothLinearRing() {
  Coordinate[] coords = getPolyCoords();
  LineString line = factory.createLinearRing(coords);
  Geometry smoothed = JTS.smooth(line, 0);
  assertTrue(smoothed instanceof LinearRing);
  CoordList list = new CoordList(smoothed.getCoordinates());
  assertTrue(list.containsAll(coords));
  Envelope lineEnv = line.getEnvelopeInternal();
  Envelope smoothEnv = smoothed.getEnvelopeInternal();
  assertTrue(smoothEnv.covers(lineEnv));
}

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

public void testDisjointFilter() 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[] {4, -1, 4, 5, 6, 5, 6, -1, 4, -1}, 2));
  Polygon polygon = gf.createPolygon(shell, null);
  Disjoint dj = ff.disjoint(ff.property(aname("geom")), ff.literal(polygon));
  FeatureCollection features = dataStore.getFeatureSource(tname("road")).getFeatures(dj);
  checkSingleResult(features, "r2");
}

代码示例来源: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");
}

相关文章