org.locationtech.jts.triangulate.quadedge.QuadEdgeSubdivision类的使用及代码示例

x33g5p2x  于2022-01-28 转载在 其他  
字(9.7k)|赞(0)|评价(0)|浏览(53)

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

QuadEdgeSubdivision介绍

[英]A class that contains the QuadEdges representing a planar subdivision that models a triangulation. The subdivision is constructed using the quadedge algebra defined in the class QuadEdge. All metric calculations are done in the Vertex class. In addition to a triangulation, subdivisions support extraction of Voronoi diagrams. This is easily accomplished, since the Voronoi diagram is the dual of the Delaunay triangulation.

Subdivisions can be provided with a tolerance value. Inserted vertices which are closer than this value to vertices already in the subdivision will be ignored. Using a suitable tolerance value can prevent robustness failures from happening during Delaunay triangulation.

Subdivisions maintain a frame triangle around the client-created edges. The frame is used to provide a bounded "container" for all edges within a TIN. Normally the frame edges, frame connecting edges, and frame triangles are not included in client processing.
[中]包含四边形边的类,四边形边表示为三角剖分建模的平面细分。细分使用quadedge类中定义的quadedge代数构造。所有度量计算都在Vertex类中完成。除了三角剖分,细分还支持Voronoi图的提取。这很容易实现,因为Voronoi图是Delaunay三角剖分的对偶。
可以为细分提供公差值。如果插入的顶点与细分中已存在的顶点之间的距离小于此值,则将忽略这些顶点。使用合适的公差值可以防止在Delaunay三角剖分期间发生鲁棒性故障。
细分在客户机创建的边周围保持一个框架三角形。框架用于为锡罐内的所有边缘提供一个有边界的“容器”。通常,框架边、框架连接边和框架三角形不包括在客户端处理中。

代码示例

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

for (Vertex vertex : (Collection<Vertex>) tin.getVertices(true)) {
  if (tin.isFrameVertex(vertex)) {
    vertex.setZ(Double.MAX_VALUE);
  } else {
  for (Vertex vertex : (Collection<Vertex>) tin.getVertices(true)) {
    JsonFeature feature = new JsonFeature();
    feature.setGeometry(geometryFactory.createPoint(vertex.getCoordinate()));
    response.polygons.add(feature);
  for (QuadEdge edge : (Collection<QuadEdge>) tin.getPrimaryEdges(false)) {
    JsonFeature feature = new JsonFeature();
    feature.setGeometry(edge.toLineSegment().toGeometry(geometryFactory));

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

conformingDelaunayTriangulator.formInitialDelaunay();
QuadEdgeSubdivision tin = conformingDelaunayTriangulator.getSubdivision();
for (Vertex vertex : (Collection<Vertex>) tin.getVertices(true)) {
  if (tin.isFrameVertex(vertex)) {
    vertex.setZ(Double.MAX_VALUE);

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

if (triangulation.isFrameVertex(e.orig())) {
  cC = moveEpsilonTowards(e.dest().getCoordinate(), e.orig().getCoordinate());
} else if (triangulation.isFrameVertex(e.dest())) {
  cC = moveEpsilonTowards(e.orig().getCoordinate(), e.dest().getCoordinate());
} else {

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

QuadEdge e = subdiv.locate(v);
if (subdiv.isVertexOfEdge(e, v)) {
else if (subdiv.isOnEdge(e, v.getCoordinate())) {
  subdiv.delete(e.oNext());
QuadEdge base = subdiv.makeEdge(e.orig(), v);
QuadEdge.splice(base, e);
QuadEdge startEdge = base;
do {
  base = subdiv.connect(e, base.sym());
  e = base.oPrev();
} while (e.lNext() != startEdge);

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

@SuppressWarnings("unchecked") // JTS is not generified
private Collection<QuadEdge> getPrimaryEdges() {
  return (Collection<QuadEdge>) triangulation.getPrimaryEdges(true);
}

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

/**
 * Gets the coordinates for each triangle in the subdivision as an array.
 * 
 * @param includeFrame
 *          true if the frame triangles should be included
 * @return a list of Coordinate[4] representing each triangle
 */
public List getTriangleCoordinates(boolean includeFrame) {
  TriangleCoordinatesVisitor visitor = new TriangleCoordinatesVisitor();
  visitTriangles(visitor, includeFrame);
  return visitor.getTriangles();
}

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

/**
  * Gets a List of {@link Polygon}s for the Voronoi cells 
  * of this triangulation.
 * <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 List of Polygons
  */
public List getVoronoiCellPolygons(GeometryFactory geomFact)
{
  /*
   * Compute circumcentres of triangles as vertices for dual edges.
   * Precomputing the circumcentres is more efficient, 
   * and more importantly ensures that the computed centres
   * are consistent across the Voronoi cells.
   */ 
  visitTriangles(new TriangleCircumcentreVisitor(), true);
  
 List cells = new ArrayList();
 Collection edges = getVertexUniqueEdges(false);
 for (Iterator i = edges.iterator(); i.hasNext(); ) {
   QuadEdge qe = (QuadEdge) i.next();
  cells.add(getVoronoiCellPolygon(qe, geomFact));
 }
 return cells;
}

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

/**
 * Tests whether a QuadEdge is an edge on the border of the frame facets and
 * the internal facets. E.g. an edge which does not itself touch a frame
 * vertex, but which touches an edge which does.
 * 
 * @param e
 *          the edge to test
 * @return true if the edge is on the border of the frame
 */
public boolean isFrameBorderEdge(QuadEdge e) {
  // MD debugging
  QuadEdge[] leftTri = new QuadEdge[3];
  getTriangleEdges(e, leftTri);
  // System.out.println(new QuadEdgeTriangle(leftTri).toString());
  QuadEdge[] rightTri = new QuadEdge[3];
  getTriangleEdges(e.sym(), rightTri);
  // System.out.println(new QuadEdgeTriangle(rightTri).toString());
  // check other vertex of triangle to left of edge
  Vertex vLeftTriOther = e.lNext().dest();
  if (isFrameVertex(vLeftTriOther))
    return true;
  // check other vertex of triangle to right of edge
  Vertex vRightTriOther = e.sym().lNext().dest();
  if (isFrameVertex(vRightTriOther))
    return true;
  return false;
}

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

/**
 * Gets the faces of the computed triangulation as a {@link GeometryCollection} 
 * of {@link Polygon}.
 * 
 * @param geomFact the geometry factory to use to create the output
 * @return the faces of the triangulation
 */
public Geometry getTriangles(GeometryFactory geomFact)
{
  create();
  return subdiv.getTriangles(geomFact);
}

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

QuadEdge e = locate(v);
QuadEdge base = makeEdge(e.orig(), v);
QuadEdge.splice(base, e);
QuadEdge startEdge = base;
do {
  base = connect(e, base.sym());
  e = base.oPrev();
} while (e.lNext() != startEdge);

代码示例来源:origin: locationtech/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));
  }
  return geomFact.createGeometryCollection(tris);
}

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

/**
 * Gets the faces of the computed diagram as a {@link GeometryCollection} 
 * of {@link Polygon}s, clipped as specified.
 * <p>
 * The <tt>userData</tt> attribute of each face <tt>Polygon</tt> is set to 
 * the <tt>Coordinate</tt>  of the corresponding input site.
 * This allows using a <tt>Map</tt> to link faces to data associated with sites.
 * 
 * @param geomFact the geometry factory to use to create the output
 * @return a <tt>GeometryCollection</tt> containing the face <tt>Polygon</tt>s of the diagram
 */
public Geometry getDiagram(GeometryFactory geomFact)
{
  create();
  Geometry polys = subdiv.getVoronoiDiagram(geomFact);
  
  // clip polys to diagramEnv
  return clipGeometryCollection(polys, diagramEnv);
}

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

/**
 * Computes the Delaunay triangulation of the initial sites.
 */
public void formInitialDelaunay() {
  computeBoundingBox();
  subdiv = new QuadEdgeSubdivision(computeAreaEnv, tolerance);
  subdiv.setLocator(new LastFoundQuadEdgeLocator(subdiv));
  incDel = new IncrementalDelaunayTriangulator(subdiv);
  insertSites(initialVertices);
}

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

private void create()
{
  if (subdiv != null) return;
  
  Envelope siteEnv = envelope(siteCoords);
  List vertices = toVertices(siteCoords);
  subdiv = new QuadEdgeSubdivision(siteEnv, tolerance);
  IncrementalDelaunayTriangulator triangulator = new IncrementalDelaunayTriangulator(subdiv);
  triangulator.insertSites(vertices);
}

代码示例来源:origin: com.graphhopper/graphhopper-isochrone

conformingDelaunayTriangulator.formInitialDelaunay();
QuadEdgeSubdivision tin = conformingDelaunayTriangulator.getSubdivision();
for (Vertex vertex : (Collection<Vertex>) tin.getVertices(true)) {
  if (tin.isFrameVertex(vertex)) {
    vertex.setZ(Double.MAX_VALUE);

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

/**
 * Tests whether a QuadEdge is an edge incident on a frame triangle vertex.
 * 
 * @param e
 *          the edge to test
 * @return true if the edge is connected to the frame triangle
 */
public boolean isFrameEdge(QuadEdge e) {
  if (isFrameVertex(e.orig()) || isFrameVertex(e.dest()))
    return true;
  return false;
}

代码示例来源:origin: com.graphhopper/graphhopper-isochrone

@SuppressWarnings("unchecked") // JTS is not generified
private Collection<QuadEdge> getPrimaryEdges() {
  return (Collection<QuadEdge>) triangulation.getPrimaryEdges(true);
}

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

/**
 * Gets a list of the triangles in the subdivision,
 * specified as an array of the triangle {@link Vertex}es.
 * 
 * @param includeFrame
 *          true if the frame triangles should be included
 * @return a List of Vertex[3] arrays
 */
public List getTriangleVertices(boolean includeFrame) {
  TriangleVertexListVisitor visitor = new TriangleVertexListVisitor();
  visitTriangles(visitor, includeFrame);
  return visitor.getTriangleVertices();
}

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

/**
   * Gets the faces of the computed triangulation as a {@link GeometryCollection} 
   * of {@link Polygon}.
   * 
   * @param geomFact the geometry factory to use to create the output
   * @return the faces of the triangulation
   */
  public Geometry getTriangles(GeometryFactory geomFact)
  {
    create();
    return subdiv.getTriangles(geomFact);
  }
}

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

private static GeometryCollection getTriangles(GeometryFactory geomFact,
                          DelaunayTriangulationBuilder delaunayTriangulationBuilder) {
    QuadEdgeSubdivision subdiv = delaunayTriangulationBuilder.getSubdivision();
    List triPtsList = subdiv.getTriangleCoordinates(false);
    Polygon[] tris = new Polygon[triPtsList.size()];
    int i = 0;
    for (Object aTriPtsList : triPtsList) {
      Coordinate[] triPt = (Coordinate[]) aTriPtsList;
      tris[i++] = geomFact.createPolygon(geomFact.createLinearRing(triPt), null);
    }
    return geomFact.createMultiPolygon(tris);
  }
}

相关文章