Search in sources :

Example 6 with Vertex

use of org.locationtech.jts.triangulate.quadedge.Vertex in project graphhopper by graphhopper.

the class QuadEdgeSubdivisionTest method createQuadEdgeSubdivisionFromTriangleList2.

@Test
public void createQuadEdgeSubdivisionFromTriangleList2() {
    Triangulation triangulation = new Triangulation();
    triangulation.getVertices().put(0, new Vertex(0.0, -1.0, 0.0));
    triangulation.getVertices().put(1, new Vertex(0.0, 0.0, 0.0));
    triangulation.getVertices().put(2, new Vertex(1.0, -1.0, 1.0));
    triangulation.getVertices().put(3, new Vertex(1.0, 1.0, 0.0));
    triangulation.getVertices().put(4, new Vertex(2.0, 0.0, 0.0));
    triangulation.getVertices().put(5, new Vertex(1.0, -3.0, 0.0));
    triangulation.makeTriangle(0, 3, 1);
    triangulation.makeTriangle(1, 2, 5);
    triangulation.makeTriangle(2, 4, 5);
    triangulation.makeTriangle(3, 4, 2);
    triangulation.makeTriangle(1, 3, 2);
    ReadableTriangulation readableTriangulation = ReadableTriangulation.wrap(triangulation);
    ReadableQuadEdge e1 = readableTriangulation.getEdge(1, 3);
    ReadableQuadEdge e2 = readableTriangulation.getEdge(3, 2);
    ReadableQuadEdge e3 = readableTriangulation.getEdge(2, 1);
    ReadableQuadEdge e4 = readableTriangulation.getEdge(4, 2);
    ReadableQuadEdge e41 = readableTriangulation.getEdge(3, 4);
    ReadableQuadEdge e5 = readableTriangulation.getEdge(5, 1);
    ReadableQuadEdge e6 = readableTriangulation.getEdge(2, 5);
    ReadableQuadEdge e7 = readableTriangulation.getEdge(4, 5);
    ReadableQuadEdge e0 = readableTriangulation.getEdge(1, 0);
    ReadableQuadEdge e00 = readableTriangulation.getEdge(3, 0);
    assertTriangle(e1, e2, e3);
    assertTriangle(e4, e2.sym(), e41);
    assertTriangle(e5, e3.sym(), e6);
    assertTriangle(e6.sym(), e4.sym(), e7);
    assertVertex(e1, e3.sym(), e5.sym(), e0);
    assertVertex(e5, e6.sym(), e7.sym());
    assertVertex(e7, e4, e41.sym());
    assertVertex(e41, e2, e1.sym(), e00);
    assertVertex(e3, e2.sym(), e4.sym(), e6);
    ReadableTriangulation triangulation1 = ReadableTriangulation.wrap(triangulation);
    ContourBuilder contourBuilder = new ContourBuilder(triangulation1);
    Geometry geometry = contourBuilder.computeIsoline(0.5, triangulation1.getEdges());
    assertEquals("MULTIPOLYGON (((0.5 -0.5, 1 -2, 1.5 -0.5, 1 0, 0.5 -0.5)))", geometry.toString());
}
Also used : Geometry(org.locationtech.jts.geom.Geometry) Vertex(org.locationtech.jts.triangulate.quadedge.Vertex) Test(org.junit.jupiter.api.Test)

Aggregations

Vertex (org.locationtech.jts.triangulate.quadedge.Vertex)6 Test (org.junit.jupiter.api.Test)4 Geometry (org.locationtech.jts.geom.Geometry)4 QuadEdgeSubdivision (org.locationtech.jts.triangulate.quadedge.QuadEdgeSubdivision)4 NodeAccess (com.graphhopper.storage.NodeAccess)2 EdgeIteratorState (com.graphhopper.util.EdgeIteratorState)2 Envelope (org.locationtech.jts.geom.Envelope)2 ConformingDelaunayTriangulator (org.locationtech.jts.triangulate.ConformingDelaunayTriangulator)2 ConstraintVertex (org.locationtech.jts.triangulate.ConstraintVertex)2 QuadEdge (org.locationtech.jts.triangulate.quadedge.QuadEdge)2 Stop (com.conveyal.gtfs.model.Stop)1 ContourBuilder (com.graphhopper.isochrone.algorithm.ContourBuilder)1 ReadableTriangulation (com.graphhopper.isochrone.algorithm.ReadableTriangulation)1 DefaultSnapFilter (com.graphhopper.routing.util.DefaultSnapFilter)1 FlagEncoder (com.graphhopper.routing.util.FlagEncoder)1 FastestWeighting (com.graphhopper.routing.weighting.FastestWeighting)1 Weighting (com.graphhopper.routing.weighting.Weighting)1 JsonFeature (com.graphhopper.util.JsonFeature)1 PointList (com.graphhopper.util.PointList)1 Instant (java.time.Instant)1