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

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

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

Polygon.<init>介绍

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

代码示例

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

/**
 * Returns the polygon surrounding the specified rectangle. Code lifted from ArcGridDataSource
 * (temporary).
 */
public static Polygon getPolygon(final Rectangle2D rect, final int srid) {
  final PrecisionModel pm = new PrecisionModel();
  final GeometryFactory gf = new GeometryFactory(pm, srid);
  final Coordinate[] coord =
      new Coordinate[] {
        new Coordinate(rect.getMinX(), rect.getMinY()),
        new Coordinate(rect.getMaxX(), rect.getMinY()),
        new Coordinate(rect.getMaxX(), rect.getMaxY()),
        new Coordinate(rect.getMinX(), rect.getMaxY()),
        new Coordinate(rect.getMinX(), rect.getMinY())
      };
  final LinearRing ring = gf.createLinearRing(coord);
  return new Polygon(ring, null, gf);
}

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

/**
 * Convert the crop envelope into a polygon and the use the world-to-grid transform to get a ROI
 * for the source coverage.
 */
public static Polygon getPolygon(final GeneralEnvelope env, final GeometryFactory gf)
    throws IllegalStateException, MismatchedDimensionException {
  final Rectangle2D rect = env.toRectangle2D();
  final Coordinate[] coord =
      new Coordinate[] {
        new Coordinate(rect.getMinX(), rect.getMinY()),
        new Coordinate(rect.getMinX(), rect.getMaxY()),
        new Coordinate(rect.getMaxX(), rect.getMaxY()),
        new Coordinate(rect.getMaxX(), rect.getMinY()),
        new Coordinate(rect.getMinX(), rect.getMinY())
      };
  final LinearRing ring = gf.createLinearRing(coord);
  final Polygon modelSpaceROI = new Polygon(ring, null, gf);
  // check that we have the same thing here
  assert modelSpaceROI
      .getEnvelopeInternal()
      .equals(new ReferencedEnvelope(rect, env.getCoordinateReferenceSystem()));
  return modelSpaceROI;
}

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

private Polygon createPolygon(float... coords) {
  LinearRing shell = new LinearRing(new LiteCoordinateSequence(coords), geometryFactory);
  return new Polygon(shell, null, geometryFactory);
}

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

final Polygon bounds = new Polygon(ring, null, gf);

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

/**
 * Constructs a <code>Polygon</code> with the given exterior boundary and
 * interior boundaries.
 *
 * @param shell
 *            the outer boundary of the new <code>Polygon</code>, or
 *            <code>null</code> or an empty <code>LinearRing</code> if
 *            the empty geometry is to be created.
 * @param holes
 *            the inner boundaries of the new <code>Polygon</code>, or
 *            <code>null</code> or empty <code>LinearRing</code> s if
 *            the empty geometry is to be created.
 * @throws IllegalArgumentException if a ring is invalid
 */
public Polygon createPolygon(LinearRing shell, LinearRing[] holes) {
 return new Polygon(shell, holes, this);
}

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

new LinearRing(
        new LiteCoordinateSequence(0, 0, 0, h, w, h, w, 0, 0, 0), GEOMETRY_FACTORY);
Polygon polygon = new Polygon(shell, null, GEOMETRY_FACTORY);
SimpleFeatureType ft = DataUtilities.createType("test", "geom:Polygon:srid=4326");
SimpleFeatureBuilder fb = new SimpleFeatureBuilder(ft);

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

protected Polygon copyInternal() {
 LinearRing shellCopy = (LinearRing) shell.copy();
 LinearRing[] holeCopies = new LinearRing[this.holes.length];
 for (int i = 0; i < holes.length; i++) {
   holeCopies[i] = (LinearRing) holes[i].copy();
 }
 return new Polygon(shellCopy, holeCopies, factory);
}

代码示例来源:origin: orbisgis/h2gis

/**
   * Create a new polygon without hole.
   *
   * @param polygon
   * @return
   */
  public static Polygon removeHolesPolygon(Polygon polygon) {
    return new Polygon((LinearRing) polygon.getExteriorRing(), null, polygon.getFactory());
  }
}

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

}),
        GEOMETRY_FACTORY);
Polygon p2 = new Polygon(shell, new LinearRing[] {hole}, GEOMETRY_FACTORY);

相关文章