Exemplo n.º 1
0
  public LineString createGeometry(Vertex a, Vertex b) {

    GeometryFactory factory = new GeometryFactory();
    Coordinate[] cs = new Coordinate[2];
    cs[0] = a.getCoordinate();
    cs[1] = b.getCoordinate();
    return factory.createLineString(cs);
  }
Exemplo n.º 2
0
  public void testNetworkLinker() {
    int numVerticesBefore = graph.getVertices().size();
    NetworkLinker nl = new NetworkLinker(graph);
    nl.createLinkage();
    int numVerticesAfter = graph.getVertices().size();
    assertEquals(4, numVerticesAfter - numVerticesBefore);
    Collection<Edge> outgoing = graph.getOutgoing(station1);
    assertTrue(outgoing.size() == 1);
    DirectEdge edge = (DirectEdge) outgoing.iterator().next();

    Vertex midpoint = edge.getToVertex();
    assertTrue(Math.abs(midpoint.getCoordinate().y - 40.01) < 0.00000001);

    outgoing = graph.getOutgoing(station2);
    assertTrue(outgoing.size() == 1);
    edge = (DirectEdge) outgoing.iterator().next();

    Vertex station2point = edge.getToVertex();
    assertTrue(Math.abs(station2point.getCoordinate().x - -74.002) < 0.00000001);
  }