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

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

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

GeometryFactory.toPolygonArray介绍

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

代码示例

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

Polygon[] polygonArray = geometryFactory.toPolygonArray(geometries);
MultiPolygon multiPolygon = geometryFactory.createMultiPolygon(polygonArray);
multiPolygon.setUserData(getSRS());

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

@DescribeProcess(
  title = "Polygonize",
  description =
      "Creates a set of polygons from linestrings delineating them.  The linestrings must be correctly noded (i.e. touch only at endpoints)."
)
@DescribeResult(description = "The collection of created polygons")
public static Geometry polygonize(
    @DescribeParameter(name = "geom", description = "Linework to polygonize")
        Geometry geom) {
  @SuppressWarnings("rawtypes")
  List lines = LineStringExtracter.getLines(geom);
  Polygonizer polygonizer = new Polygonizer();
  polygonizer.add(lines);
  @SuppressWarnings("rawtypes")
  Collection polys = polygonizer.getPolygons();
  Polygon[] polyArray = GeometryFactory.toPolygonArray(polys);
  return geom.getFactory().createGeometryCollection(polyArray);
}

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

private MultiPolygon clean(MultiPolygon g)
{
 List polys = new ArrayList();
 for (int i = 0; i < g.getNumGeometries(); i++) {
  Polygon poly = (Polygon) g.getGeometryN(i);
  polys.add(clean(poly));
 }
 return fact.createMultiPolygon(GeometryFactory.toPolygonArray(polys));
}
private MultiLineString clean(MultiLineString g)

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

public Geometry createCollection(Geometry[] geometries) {
    return geometryFactory.createMultiPolygon(GeometryFactory.toPolygonArray(
        Arrays.asList(geometries)));
  }
};

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

/**
 * Removes duplicated coordinates within a MultiPolygon.
 *
 * @param g
 * @return
 */
public static MultiPolygon removeCoordinates(MultiPolygon g) {
  ArrayList<Polygon> polys = new ArrayList<Polygon>();
  for (int i = 0; i < g.getNumGeometries(); i++) {
    Polygon poly = (Polygon) g.getGeometryN(i);
    polys.add(removeCoordinates(poly));
  }
  return FACTORY.createMultiPolygon(GeometryFactory.toPolygonArray(polys));
}

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

/**
  * Computes a {@link Geometry} containing only {@link Polygonal} components.
  * Extracts the {@link Polygon}s from the input 
  * and returns them as an appropriate {@link Polygonal} geometry.
  * <p>
  * If the input is already <tt>Polygonal</tt>, it is returned unchanged.
  * <p>
  * A particular use case is to filter out non-polygonal components
  * returned from an overlay operation.  
  * 
  * @param g the geometry to filter
  * @return a Polygonal geometry
  */
 private static Geometry restrictToPolygons(Geometry g)
 {
  if (g instanceof Polygonal) {
   return g;
  }
  List polygons = PolygonExtracter.getPolygons(g);
  if (polygons.size() == 1) 
   return (Polygon) polygons.get(0);
  return g.getFactory().createMultiPolygon(GeometryFactory.toPolygonArray(polygons));
 }
}

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

/**
 * Removes duplicated coordinates within a MultiPolygon.
 *
 * @param multiPolygon
 * @param tolerance to delete the coordinates
 * @return
 * @throws java.sql.SQLException
 */
public static MultiPolygon removeDuplicateCoordinates(MultiPolygon multiPolygon, double tolerance) throws SQLException {
  ArrayList<Polygon> polys = new ArrayList<Polygon>();
  for (int i = 0; i < multiPolygon.getNumGeometries(); i++) {
    Polygon poly = (Polygon) multiPolygon.getGeometryN(i);
    polys.add(removeDuplicateCoordinates(poly, tolerance));
  }
  return FACTORY.createMultiPolygon(GeometryFactory.toPolygonArray(polys));
}

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

/**
   * Creates a GeometryCollection containing possible polygons formed 
   * from the constituent linework of a set of geometries.
   * 
   * @param geometry
   * @return 
   */
  public static Geometry polygonize(Geometry geometry) {
    if(geometry == null){
      return null;
    }
    Polygonizer polygonizer = new Polygonizer();
    polygonizer.add(geometry);
    Collection pols = polygonizer.getPolygons();
    if(pols.isEmpty()){
      return null;
    }
    return FACTORY.createMultiPolygon(GeometryFactory.toPolygonArray(pols));
  }
}

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

public static Geometry toMultiPolygon(Geometry g1, Geometry g2)
{
 Geometry geoms = FunctionsUtil.buildGeometry(g1, g2);
 List polys = PolygonExtracter.getPolygons(g1);
 PolygonExtracter.getPolygons(g2, polys);
 return FunctionsUtil.getFactoryOrDefault(g1, g2)
   .createMultiPolygon( GeometryFactory.toPolygonArray(polys));
}

代码示例来源:origin: ElectronicChartCentre/java-vector-tile

geometry = gf.createMultiPolygon(GeometryFactory.toPolygonArray(polygons));

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

if (isCollection) {
 if (geom0 instanceof Polygon) {
  return createMultiPolygon(toPolygonArray(geomList));

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

MultiLineString voronoiSegs = geometryFactory.createMultiLineString(lineStrings.toArray(new LineString[0]));
polygonizer.add(voronoiSegs);
return geometryFactory.createMultiPolygon(GeometryFactory.toPolygonArray(polygonizer.getPolygons()));

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

public static Geometry overlaySnapRounded(Geometry g1, Geometry g2, double precisionTol)
{
 PrecisionModel pm = new PrecisionModel(precisionTol);
 GeometryFactory geomFact = g1.getFactory();
 
 List lines = LinearComponentExtracter.getLines(g1);
 // add second input's linework, if any
 if (g2 != null)
  LinearComponentExtracter.getLines(g2, lines);
 List nodedLinework = new GeometryNoder(pm).node(lines);
 // union the noded linework to remove duplicates
 Geometry nodedDedupedLinework = geomFact.buildGeometry(nodedLinework).union();
 
 // polygonize the result
 Polygonizer polygonizer = new Polygonizer();
 polygonizer.add(nodedDedupedLinework);
 Collection polys = polygonizer.getPolygons();
 
 // convert to collection for return
 Polygon[] polyArray = GeometryFactory.toPolygonArray(polys);
 return geomFact.createGeometryCollection(polyArray);
}

相关文章