com.vividsolutions.jts.geom.GeometryFactory.createGeometryCollection()方法的使用及代码示例

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

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

GeometryFactory.createGeometryCollection介绍

[英]Creates a GeometryCollection using the given Geometries; a null or empty array will create an empty GeometryCollection.
[中]使用给定的几何图形创建GeometryCollection;空数组或空数组将创建空GeometryCollection。

代码示例

代码示例来源:origin: opentripplanner/OpenTripPlanner

public final Geometry getDebugGeometry() {
  return geometryFactory.createGeometryCollection(debugGeom.toArray(new Geometry[debugGeom
      .size()]));
}

代码示例来源:origin: opentripplanner/OpenTripPlanner

A.up = A.down = A.right = A.left = null;
debugGeometry = geomFactory.createGeometryCollection(debugGeom
    .toArray(new Geometry[debugGeom.size()]));
return geomFactory.createGeometryCollection(retval.toArray(new Geometry[retval.size()]));

代码示例来源:origin: opentripplanner/OpenTripPlanner

geomsArray[k++] = ls;
GeometryCollection gc = gf.createGeometryCollection(geomsArray);

代码示例来源:origin: opentripplanner/OpenTripPlanner

/**
 * Returns a {@link Geometry} that represents the concave hull of the input
 * geometry according to the threshold.
 * The returned geometry contains the minimal number of points needed to
 * represent the concave hull.
 *
 * @return if the concave hull contains 3 or more points, a {@link Polygon};
 * 2 points, a {@link LineString};
 * 1 point, a {@link Point};
 * 0 points, an empty {@link GeometryCollection}.
 */
public Geometry getConcaveHull() {
  if (this.geometries.getNumGeometries() == 0) {
    return this.geomFactory.createGeometryCollection(null);
  }
  if (this.geometries.getNumGeometries() == 1) {
    return this.geometries.getGeometryN(0);
  }
  if (this.geometries.getNumGeometries() == 2) {
    return this.geomFactory.createLineString(this.geometries.getCoordinates());
  }
  return concaveHull();
}

代码示例来源:origin: opentripplanner/OpenTripPlanner

.createGeometryCollection(retval.toArray(new Geometry[retval.size()]));

代码示例来源:origin: com.vividsolutions/jts

public Object parse(Handler arg, GeometryFactory gf) throws SAXException {
    // one child, either a coord
    // or a coordinate sequence
    
    if(arg.children.size()<1)
      throw new SAXException("Cannot create a multi-polygon without atleast one geometry");
    
    Geometry[] geoms = (Geometry[]) arg.children.toArray(new Geometry[arg.children.size()]);
    
    GeometryCollection gc = gf.createGeometryCollection(geoms);
            
    return gc;
  }
});

代码示例来源:origin: com.vividsolutions/jts

/**
 * Gets the boundary of this geometry.
 * Zero-dimensional geometries have no boundary by definition,
 * so an empty GeometryCollection is returned.
 *
 * @return an empty GeometryCollection
 * @see Geometry#getBoundary
 */
public Geometry getBoundary() {
 return getFactory().createGeometryCollection(null);
}

代码示例来源:origin: com.vividsolutions/jts

/**
 * Gets the boundary of this geometry.
 * Zero-dimensional geometries have no boundary by definition,
 * so an empty GeometryCollection is returned.
 *
 * @return an empty GeometryCollection
 * @see Geometry#getBoundary
 */
public Geometry getBoundary() {
 return getFactory().createGeometryCollection(null);
}

代码示例来源:origin: com.vividsolutions/jts

/**
 * Gets the geometry parsed by this handler.
 * This method should only be called AFTER the parser has completed execution
 * 
 * @return the parsed Geometry, or a GeometryCollection if more than one geometry was parsed
 * @throws IllegalStateException if called before the parse is complete
 */
public Geometry getGeometry() {
  if (stack.size() == 1) {
    Handler h = (Handler) stack.peek();
    if (h.children.size() == 1)
      return (Geometry) h.children.get(0);
    return gf.createGeometryCollection(
        (Geometry[]) h.children.toArray(new Geometry[stack.size()]));
  }
  throw new IllegalStateException(
      "Parse did not complete as expected, there are " + stack.size()
          + " elements on the Stack");
}

代码示例来源:origin: com.vividsolutions/jts

public static void unionUsingBuffer(Geometry[] geom)
{
 GeometryFactory fact = geom[0].getFactory();
 Geometry geomColl = fact.createGeometryCollection(geom);
 Geometry union = geomColl.buffer(0.0);
 System.out.println(union);
}

代码示例来源:origin: com.vividsolutions/jts

/**
  * Computes the combination of the input geometries
  * to produce the most appropriate {@link Geometry} or {@link GeometryCollection}
  * 
  * @return a Geometry which is the combination of the inputs
  */
public Geometry combine()
{
  List elems = new ArrayList();
  for (Iterator i = inputGeoms.iterator(); i.hasNext(); ) {
    Geometry g = (Geometry) i.next();
    extractElements(g, elems);
  }
 
 if (elems.size() == 0) {
   if (geomFactory != null) {
  // return an empty GC
     return geomFactory.createGeometryCollection(null);
   }
   return null;
 }
 // return the "simplest possible" geometry
 return geomFactory.buildGeometry(elems);
}

代码示例来源:origin: com.vividsolutions/jts

private Geometry bufferUnion(Geometry g0, Geometry g1)
{
  GeometryFactory factory = g0.getFactory();
  Geometry gColl = factory.createGeometryCollection(new Geometry[] { g0, g1 } );
  Geometry unionAll = gColl.buffer(0.0);
 return unionAll;
}

代码示例来源:origin: com.vividsolutions/jts

private GeometryCollection readGeometryCollection() throws IOException, ParseException
{
 int numGeom = dis.readInt();
 Geometry[] geoms = new Geometry[numGeom];
 for (int i = 0; i < numGeom; i++) {
  geoms[i] = readGeometry();
 }
 return factory.createGeometryCollection(geoms);
}

代码示例来源:origin: com.vividsolutions/jts

private Geometry bufferUnion(Geometry g0, Geometry g1)
{
  GeometryFactory factory = g0.getFactory();
  Geometry gColl = factory.createGeometryCollection(new Geometry[] { g0, g1 } );
  Geometry unionAll = gColl.buffer(0.0);
 return unionAll;
}

代码示例来源:origin: com.vividsolutions/jts

/**
 * Gets the geometry for the triangles in a triangulated subdivision as a {@link GeometryCollection}
 * of triangular {@link Polygon}s.
 * 
 * @param geomFact the GeometryFactory to use
 * @return a GeometryCollection of triangular Polygons
 */
public Geometry getTriangles(GeometryFactory geomFact) {
  List triPtsList = getTriangleCoordinates(false);
  Polygon[] tris = new Polygon[triPtsList.size()];
  int i = 0;
  for (Iterator it = triPtsList.iterator(); it.hasNext();) {
    Coordinate[] triPt = (Coordinate[]) it.next();
    tris[i++] = geomFact
        .createPolygon(geomFact.createLinearRing(triPt), null);
  }
  return geomFact.createGeometryCollection(tris);
}

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

/**
  * Creates a {@link GeometryCollection} with
  * every component reversed.
  * The order of the components in the collection are not reversed.
  *
  * @return a {@link GeometryCollection} in the reverse order
  */
 public Geometry reverse()
 {
  int n = geometries.length;
  Geometry[] revGeoms = new Geometry[n];
  for (int i = 0; i < geometries.length; i++) {
   revGeoms[i] = geometries[i].reverse();
  }
  return getFactory().createGeometryCollection(revGeoms);
 }
}

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

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));
  }
}

相关文章