/**
   * Create an edge. If twoWay, create two edges (back and forth).
   *
   * @param vA
   * @param vB
   * @param length
   * @param back true if this is a reverse edge
   */
  private PlainStreetEdge edge(StreetVertex vA, StreetVertex vB, double length, boolean back) {
    String labelA = vA.getLabel();
    String labelB = vB.getLabel();
    String name = String.format("%s_%s", labelA, labelB);
    Coordinate[] coords = new Coordinate[2];
    coords[0] = vA.getCoordinate();
    coords[1] = vB.getCoordinate();
    LineString geom = GeometryUtils.getGeometryFactory().createLineString(coords);

    StreetTraversalPermission perm = StreetTraversalPermission.ALL;
    return new PlainStreetEdge(vA, vB, geom, name, length, perm, back);
  }
Ejemplo n.º 2
0
  private void makeEdges(StreetVertex v1, StreetVertex v2, String name) {
    LineString geometry =
        GeometryUtils.makeLineString(
            v1.getCoordinate().x, v1.getCoordinate().y, v2.getCoordinate().x, v2.getCoordinate().y);
    double length =
        SphericalDistanceLibrary.getInstance().distance(v1.getCoordinate(), v2.getCoordinate());
    new PlainStreetEdge(v1, v2, geometry, name, length, StreetTraversalPermission.ALL, false);

    geometry =
        GeometryUtils.makeLineString(
            v2.getCoordinate().x, v2.getCoordinate().y, v1.getCoordinate().x, v1.getCoordinate().y);
    new PlainStreetEdge(v2, v1, geometry, name, length, StreetTraversalPermission.ALL, true);
  }