本文整理了Java中com.vividsolutions.jts.geom.GeometryFactory.toGeometryArray()
方法的一些代码示例,展示了GeometryFactory.toGeometryArray()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。GeometryFactory.toGeometryArray()
方法的具体详情如下:
包路径:com.vividsolutions.jts.geom.GeometryFactory
类名称:GeometryFactory
方法名:toGeometryArray
[英]Converts the List
to an array.
[中]将List
转换为数组。
代码示例来源:origin: com.vividsolutions/jts
/**
* Gets the cells in the Voronoi diagram for this triangulation.
* The cells are returned as a {@link GeometryCollection} of {@link Polygon}s
* <p>
* The userData of each polygon is set to be the {@link Coordinate}
* of the cell site. This allows easily associating external
* data associated with the sites to the cells.
*
* @param geomFact a geometry factory
* @return a GeometryCollection of Polygons
*/
public Geometry getVoronoiDiagram(GeometryFactory geomFact)
{
List vorCells = getVoronoiCellPolygons(geomFact);
return geomFact.createGeometryCollection(GeometryFactory.toGeometryArray(vorCells));
}
代码示例来源:origin: com.vividsolutions/jts
public GeometryCollection map(GeometryCollection gc)
{
List mapped = new ArrayList();
for (int i = 0; i < gc.getNumGeometries(); i++) {
Geometry g = mapOp.map(gc.getGeometryN(i));
if (!g.isEmpty())
mapped.add(g);
}
return gc.getFactory().createGeometryCollection(
GeometryFactory.toGeometryArray(mapped));
}
}
代码示例来源:origin: com.vividsolutions/jts
protected Geometry transformGeometryCollection(GeometryCollection geom, Geometry parent) {
List transGeomList = new ArrayList();
for (int i = 0; i < geom.getNumGeometries(); i++) {
Geometry transformGeom = transform(geom.getGeometryN(i));
if (transformGeom == null) continue;
if (pruneEmptyGeometry && transformGeom.isEmpty()) continue;
transGeomList.add(transformGeom);
}
if (preserveGeometryCollectionType)
return factory.createGeometryCollection(GeometryFactory.toGeometryArray(transGeomList));
return factory.buildGeometry(transGeomList);
}
代码示例来源:origin: com.vividsolutions/jts
return createGeometryCollection(toGeometryArray(geomList));
代码示例来源:origin: com.vividsolutions/jts
private static Geometry clipGeometryCollection(Geometry geom, Envelope clipEnv)
{
Geometry clipPoly = geom.getFactory().toGeometry(clipEnv);
List clipped = new ArrayList();
for (int i = 0; i < geom.getNumGeometries(); i++) {
Geometry g = geom.getGeometryN(i);
Geometry result = null;
// don't clip unless necessary
if (clipEnv.contains(g.getEnvelopeInternal()))
result = g;
else if (clipEnv.intersects(g.getEnvelopeInternal())) {
result = clipPoly.intersection(g);
// keep vertex key info
result.setUserData(g.getUserData());
}
if (result != null && ! result.isEmpty()) {
clipped.add(result);
}
}
return geom.getFactory().createGeometryCollection(GeometryFactory.toGeometryArray(clipped));
}
}
代码示例来源:origin: us.ihmc/ihmc-jmonkey-engine-toolkit
private static GeometryCollection componentBuffers(Geometry g, double distance)
{
List<Geometry> bufs = new ArrayList<Geometry>();
for (Iterator it = new GeometryCollectionIterator(g); it.hasNext();)
{
Geometry comp = (Geometry) it.next();
if (comp instanceof GeometryCollection) continue;
bufs.add(comp.buffer(distance));
}
return GEOMETRY_FACTORY.createGeometryCollection(GeometryFactory.toGeometryArray(bufs));
}
代码示例来源:origin: us.ihmc/IHMCJMonkeyEngineToolkit
private static GeometryCollection componentBuffers(Geometry g, double distance)
{
List<Geometry> bufs = new ArrayList<Geometry>();
for (Iterator it = new GeometryCollectionIterator(g); it.hasNext();)
{
Geometry comp = (Geometry) it.next();
if (comp instanceof GeometryCollection) continue;
bufs.add(comp.buffer(distance));
}
return GEOMETRY_FACTORY.createGeometryCollection(GeometryFactory.toGeometryArray(bufs));
}
代码示例来源:origin: com.vividsolutions/jts-core
/**
* Gets the cells in the Voronoi diagram for this triangulation.
* The cells are returned as a {@link GeometryCollection} of {@link Polygon}s
* <p>
* The userData of each polygon is set to be the {@link Coordinate}
* of the cell site. This allows easily associating external
* data associated with the sites to the cells.
*
* @param geomFact a geometry factory
* @return a GeometryCollection of Polygons
*/
public Geometry getVoronoiDiagram(GeometryFactory geomFact)
{
List vorCells = getVoronoiCellPolygons(geomFact);
return geomFact.createGeometryCollection(GeometryFactory.toGeometryArray(vorCells));
}
代码示例来源:origin: org.orbisgis/orbisgis-core
/**
* Removes duplicated coordinates within a GeometryCollection
* @param g
* @return
*/
public static GeometryCollection removeDuplicateCoordinates(GeometryCollection g) {
ArrayList<Geometry> geoms = new ArrayList<Geometry>();
for (int i = 0; i < g.getNumGeometries(); i++) {
Geometry geom = g.getGeometryN(i);
geoms.add(removeDuplicateCoordinates(geom));
}
return FACTORY.createGeometryCollection(GeometryFactory.toGeometryArray(geoms));
}
代码示例来源:origin: com.vividsolutions/jts-core
/**
* Gets a geometry representing the polygons formed by the polygonization.
* If a valid polygonal geometry was extracted the result is a {@linkl Polygonal} geometry.
*
* @return a geometry containing the polygons
*/
public Geometry getGeometry()
{
if (geomFactory == null) geomFactory = new GeometryFactory();
polygonize();
if (extractOnlyPolygonal) {
return geomFactory.buildGeometry(polyList);
}
// result may not be valid Polygonal, so return as a GeometryCollection
return geomFactory.createGeometryCollection(GeometryFactory.toGeometryArray(polyList));
}
代码示例来源:origin: org.orbisgis/h2gis-functions
/**
* Removes duplicated coordinates within a GeometryCollection
*
* @param g
* @return
*/
public static GeometryCollection removeCoordinates(GeometryCollection g) {
ArrayList<Geometry> geoms = new ArrayList<Geometry>();
for (int i = 0; i < g.getNumGeometries(); i++) {
Geometry geom = g.getGeometryN(i);
geoms.add(removeCoordinates(geom));
}
return FACTORY.createGeometryCollection(GeometryFactory.toGeometryArray(geoms));
}
}
代码示例来源:origin: org.orbisgis/h2gis
/**
* Removes duplicated coordinates within a GeometryCollection
*
* @param g
* @return
*/
public static GeometryCollection removeCoordinates(GeometryCollection g) {
ArrayList<Geometry> geoms = new ArrayList<Geometry>();
for (int i = 0; i < g.getNumGeometries(); i++) {
Geometry geom = g.getGeometryN(i);
geoms.add(removeCoordinates(geom));
}
return FACTORY.createGeometryCollection(GeometryFactory.toGeometryArray(geoms));
}
}
代码示例来源:origin: org.orbisgis/h2gis
/**
* Removes duplicated coordinates within a GeometryCollection
*
* @param geometryCollection
* @param tolerance to delete the coordinates
* @return
* @throws java.sql.SQLException
*/
public static GeometryCollection removeDuplicateCoordinates(GeometryCollection geometryCollection, double tolerance) throws SQLException {
ArrayList<Geometry> geoms = new ArrayList<>();
for (int i = 0; i < geometryCollection.getNumGeometries(); i++) {
Geometry geom = geometryCollection.getGeometryN(i);
geoms.add(removeDuplicateCoordinates(geom, tolerance));
}
return FACTORY.createGeometryCollection(GeometryFactory.toGeometryArray(geoms));
}
}
代码示例来源:origin: org.orbisgis/h2gis-functions
/**
* Removes duplicated coordinates within a GeometryCollection
*
* @param geometryCollection
* @param tolerance to delete the coordinates
* @return
* @throws java.sql.SQLException
*/
public static GeometryCollection removeDuplicateCoordinates(GeometryCollection geometryCollection, double tolerance) throws SQLException {
ArrayList<Geometry> geoms = new ArrayList<>();
for (int i = 0; i < geometryCollection.getNumGeometries(); i++) {
Geometry geom = geometryCollection.getGeometryN(i);
geoms.add(removeDuplicateCoordinates(geom, tolerance));
}
return FACTORY.createGeometryCollection(GeometryFactory.toGeometryArray(geoms));
}
}
代码示例来源:origin: org.geotools/gt-coverage
/**
* Helper method for {@link #intersection(Geometry, Geometry) intersection(Geometry, Geometry)}
*/
private static GeometryCollection intersection(GeometryCollection gc1, GeometryCollection gc2) {
List<Geometry> ret = new ArrayList<Geometry>();
final int size=gc1.getNumGeometries();
for (int i = 0; i < size; i++) {
Geometry g1 = (Geometry)gc1.getGeometryN(i);
List<Geometry> partial = intersection(gc2, g1);
ret.addAll(partial);
}
return gc1.getFactory().createGeometryCollection(GeometryFactory.toGeometryArray(ret));
}
代码示例来源:origin: com.vividsolutions/jts-core
public GeometryCollection map(GeometryCollection gc)
{
List mapped = new ArrayList();
for (int i = 0; i < gc.getNumGeometries(); i++) {
Geometry g = mapOp.map(gc.getGeometryN(i));
if (!g.isEmpty())
mapped.add(g);
}
return gc.getFactory().createGeometryCollection(
GeometryFactory.toGeometryArray(mapped));
}
}
代码示例来源:origin: com.vividsolutions/jts-core
protected Geometry transformGeometryCollection(GeometryCollection geom, Geometry parent) {
List transGeomList = new ArrayList();
for (int i = 0; i < geom.getNumGeometries(); i++) {
Geometry transformGeom = transform(geom.getGeometryN(i));
if (transformGeom == null) continue;
if (pruneEmptyGeometry && transformGeom.isEmpty()) continue;
transGeomList.add(transformGeom);
}
if (preserveGeometryCollectionType)
return factory.createGeometryCollection(GeometryFactory.toGeometryArray(transGeomList));
return factory.buildGeometry(transGeomList);
}
代码示例来源:origin: org.geotools/gt-coverage
/**
* Return the intersection of two Geometries.
* <BR>This method relies completely on {@link Geometry#intersection(Geometry)}
* but also tries to unroll <TT>GeometryCollection</TT>s.
*
* @param g1
* @param g2
* @return true if the two geometries intersect.
*/
public static Geometry intersection(Geometry g1, Geometry g2) {
if(g1 instanceof GeometryCollection) {
if(g2 instanceof GeometryCollection) {
return intersection((GeometryCollection)g1, (GeometryCollection)g2);
} else {
List<Geometry> ret = intersection((GeometryCollection)g1, g2);
return g1.getFactory().createGeometryCollection(GeometryFactory.toGeometryArray(ret));
}
} else {
if(g2 instanceof GeometryCollection) {
List<Geometry> ret = intersection((GeometryCollection)g2, g1);
return g1.getFactory().createGeometryCollection(GeometryFactory.toGeometryArray(ret));
} else {
return g1.intersection(g2);
}
}
}
代码示例来源:origin: mapplus/spatial_statistics_for_geotools_udig
continue;
Geometry[] geometries = GeometryFactory.toGeometryArray(entry.getValue());
GeometryCollection geomCol = gf.createGeometryCollection(geometries);
Geometry circle = new MinimumBoundingCircle(geomCol).getCircle();
代码示例来源:origin: com.vividsolutions/jts-core
private static Geometry clipGeometryCollection(Geometry geom, Envelope clipEnv)
{
Geometry clipPoly = geom.getFactory().toGeometry(clipEnv);
List clipped = new ArrayList();
for (int i = 0; i < geom.getNumGeometries(); i++) {
Geometry g = geom.getGeometryN(i);
Geometry result = null;
// don't clip unless necessary
if (clipEnv.contains(g.getEnvelopeInternal()))
result = g;
else if (clipEnv.intersects(g.getEnvelopeInternal())) {
result = clipPoly.intersection(g);
// keep vertex key info
result.setUserData(g.getUserData());
}
if (result != null && ! result.isEmpty()) {
clipped.add(result);
}
}
return geom.getFactory().createGeometryCollection(GeometryFactory.toGeometryArray(clipped));
}
}
内容来源于网络,如有侵权,请联系作者删除!