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

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

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

Polygon.getCoordinates介绍

暂无

代码示例

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

public Coordinate[] getCoordinates() {
  return polygon.getCoordinates();
}

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

Coordinate[] coords = polygon.getCoordinates();

代码示例来源:origin: Geomatys/geotoolkit

private static MultiPoint convertToMultiPoint(final Polygon pt){
  return GF.createMultiPoint(pt.getCoordinates());
}

代码示例来源:origin: Geomatys/geotoolkit

private static LineString convertToLineString(final Polygon pt){
  return GF.createLineString(pt.getCoordinates());
}

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

private static MultiLineString convertToMultiLineString(final Polygon pt){
  return convertToMultiLineString(GF.createLineString(pt.getCoordinates()));
}

代码示例来源:origin: uk.os.vt/vt

private static int[] getTilingSchemeBoundingBox(int z, Geometry geometry) {
 Geometry geometryEnvelope = geometry.getEnvelope();
 if (geometryEnvelope instanceof Polygon) {
  Polygon polygon = (Polygon) geometryEnvelope;
  Coordinate[] coordinates = polygon.getCoordinates();
  int minx = Integer.MAX_VALUE;
  int maxx = Integer.MIN_VALUE;
  int miny = Integer.MAX_VALUE;
  int maxy = Integer.MIN_VALUE;
  for (int i = 0; i < coordinates.length - 1; i++) {
   Coordinate coordinate = coordinates[i];
   int[] tilecoords = CoordinateConversion.toTileCoordinates(new double[]{
     coordinate.y, coordinate.x}, z);
   minx = Math.min(minx, tilecoords[1]);
   maxx = Math.max(maxx, tilecoords[1]);
   miny = Math.min(miny, tilecoords[2]);
   maxy = Math.max(maxy, tilecoords[2]);
  }
  return new int[]{minx, miny, maxx, maxy};
 } else if (geometryEnvelope instanceof Point) {
  // TODO design out
  Point point = (Point) geometryEnvelope;
  int[] tilecoords = CoordinateConversion.toTileCoordinates(new double[]{
    point.getCoordinate().y, point.getCoordinate().x}, z);
  return new int[]{tilecoords[1], tilecoords[2], tilecoords[1], tilecoords[2]};
 }
 throw new IllegalArgumentException("unsupported geometry type");
}

代码示例来源:origin: ngageoint/elasticgeo

final Polygon polygon = (Polygon) geometry;
final List<List<Double>> points = new ArrayList<>();
for (final Coordinate coordinate : polygon.getCoordinates()) {
  points.add(ImmutableList.of(coordinate.x, coordinate.y));

代码示例来源: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: org.geotools/gt-geobuf

Polygon polygon = (Polygon) geometry;
  builder.setType(Geobuf.Data.Geometry.Type.POLYGON);
  Coordinate[] coords = polygon.getCoordinates();
  addCoords(builder, coords);
} else if (geometry instanceof MultiPoint) {

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

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

相关文章