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

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

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

GeometryFactory.toLinearRingArray介绍

[英]Converts the List to an array.
[中]将List转换为数组。

代码示例

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

private LinearRing[] getHoles(int n, double originX, double originY, double width) 
{
  List holeList = new ArrayList();
  
  addHoles(n, originX, originY, width, holeList );
  
  return GeometryFactory.toLinearRingArray(holeList);
}

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

seqIndex++;
LinearRing[] holeArray = GeometryFactory.toLinearRingArray(holes);
polys.add(geometryFactory.createPolygon(shell, holeArray));

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

public Polygon getResult()
{
 GeometryFactory gf = poly.getFactory();
 Polygon shell = gf.createPolygon(poly.getExteriorRing());
 
 List holes = new ArrayList();
 for (int i = 0; i < poly.getNumInteriorRing(); i++) {
  LinearRing hole = poly.getInteriorRingN(i);
  if (! isRemoved.value(hole)) {
   holes.add(hole);
  }
 }
 // all holes valid, so return original
 if (holes.size() == poly.getNumInteriorRing())
  return poly;
 
 // return new polygon with covered holes only
 Polygon result = gf.createPolygon(poly.getExteriorRing(),
   GeometryFactory.toLinearRingArray(holes));
 return result;
}

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

private Polygon clean(Polygon poly)
{
 Coordinate[] shellCoords = removeDuplicatePoints(poly.getExteriorRing().getCoordinates());
 LinearRing shell = fact.createLinearRing(shellCoords);
 List holes = new ArrayList();
 for (int i = 0; i < poly.getNumInteriorRing(); i++) {
  Coordinate[] holeCoords = removeDuplicatePoints(poly.getInteriorRingN(i).getCoordinates());
  holes.add(fact.createLinearRing(holeCoords));
 }
 return fact.createPolygon(shell, GeometryFactory.toLinearRingArray(holes));
}

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

public Polygon getResult()
{
 GeometryFactory gf = poly.getFactory();
 Polygon shell = gf.createPolygon(poly.getExteriorRing());
 PreparedGeometry shellPrep = PreparedGeometryFactory.prepare(shell);
 
 List holes = new ArrayList();
 for (int i = 0; i < poly.getNumInteriorRing(); i++) {
  LinearRing hole = poly.getInteriorRingN(i);
  if (shellPrep.covers(hole)) {
   holes.add(hole);
  }
 }
 // all holes valid, so return original
 if (holes.size() == poly.getNumInteriorRing())
  return poly;
 
 // return new polygon with covered holes only
 Polygon result = gf.createPolygon(poly.getExteriorRing(),
   GeometryFactory.toLinearRingArray(holes));
 return result;
}

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

/**
 * Removes duplicated coordinates within a Polygon.
 *
 * @param polygon the input polygon
 * @param tolerance to delete the coordinates
 * @return
 * @throws java.sql.SQLException
 */
public static Polygon removeDuplicateCoordinates(Polygon polygon, double tolerance) throws SQLException {
  Coordinate[] shellCoords = CoordinateUtils.removeRepeatedCoordinates(polygon.getExteriorRing().getCoordinates(),tolerance,true);
  LinearRing shell = FACTORY.createLinearRing(shellCoords);
  ArrayList<LinearRing> holes = new ArrayList<LinearRing>();
  for (int i = 0; i < polygon.getNumInteriorRing(); i++) {
    Coordinate[] holeCoords = CoordinateUtils.removeRepeatedCoordinates(polygon.getInteriorRingN(i).getCoordinates(), tolerance, true);
    if (holeCoords.length < 4) {
      throw new SQLException("Not enough coordinates to build a new LinearRing.\n Please adjust the tolerance");
    }
    holes.add(FACTORY.createLinearRing(holeCoords));
  }
  return FACTORY.createPolygon(shell, GeometryFactory.toLinearRingArray(holes));
}

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

/**
 * Removes duplicated coordinates within a Polygon.
 *
 * @param poly
 * @return
 */
public static Polygon removeCoordinates(Polygon poly) {
  Coordinate[] shellCoords = CoordinateUtils.removeDuplicatedCoordinates(poly.getExteriorRing().getCoordinates(),true);
  LinearRing shell = FACTORY.createLinearRing(shellCoords);
  ArrayList<LinearRing> holes = new ArrayList<LinearRing>();
  for (int i = 0; i < poly.getNumInteriorRing(); i++) {
    Coordinate[] holeCoords = CoordinateUtils.removeDuplicatedCoordinates(poly.getInteriorRingN(i).getCoordinates(),true);
    holes.add(FACTORY.createLinearRing(holeCoords));
  }
  return FACTORY.createPolygon(shell, GeometryFactory.toLinearRingArray(holes));
}

相关文章