예제 #1
0
 public EdgeMapping[] mapFromRgEdgeId(int rgEdgeId) {
   if (rgEdgeId < 0 || rgEdgeId >= rgEdgeIdToHhEdgeId[0].length) {
     return null;
   }
   return new EdgeMapping[] {
     new EdgeMapping(
         rgEdgeIdToHhEdgeId[0][rgEdgeId], rgEdgeId, reversed.get(rgEdgeIdToHhEdgeId[0][rgEdgeId])),
     new EdgeMapping(
         rgEdgeIdToHhEdgeId[0][rgEdgeId], rgEdgeId, reversed.get(rgEdgeIdToHhEdgeId[1][rgEdgeId])),
   };
 }
예제 #2
0
 public EdgeMapping mapFromHHEdgeId(int hhEdgeId) {
   if (hhEdgeId < 0
       || hhEdgeId >= hhEdgeIdToRgEdgeId.length
       || hhEdgeIdToRgEdgeId[hhEdgeId] == -1) {
     return null;
   }
   return new EdgeMapping(hhEdgeId, hhEdgeIdToRgEdgeId[hhEdgeId], reversed.get(hhEdgeId));
 }
예제 #3
0
  public static EdgeMapper importFromDb(Connection conn) throws SQLException {
    HHDbReader reader = new HHDbReader(conn);
    RgDAO rg = new RgDAO(conn);

    // mapping from hhEdgeId to rgEdgeId
    int[] hhEdgeIdToRgEdgeId = new int[reader.numEdges()];
    int[][] rgEdgeIdToHhEdgeId = new int[2][rg.getNumEdges()];
    for (int i = 0; i < rgEdgeIdToHhEdgeId[0].length; i++) {
      rgEdgeIdToHhEdgeId[0][i] = -1;
      rgEdgeIdToHhEdgeId[1][i] = -1;
    }

    BitArray reversed = new BitArray(reader.numEdges());
    int hhEdgeId = 0;
    for (Iterator<HHEdge> iter = reader.getEdges(); iter.hasNext(); ) {
      HHEdge e = iter.next();
      if (e.shortcut) {
        // edge is not in routing graph
        hhEdgeIdToRgEdgeId[hhEdgeId] = -1;
      } else {
        // edge is in routing graph, either forward or backward

        // hh -> rg
        int rgEdgeId = e.id / 2;
        hhEdgeIdToRgEdgeId[hhEdgeId] = e.id / 2;
        reversed.set(hhEdgeId, e.id % 2 == 1);

        // rg ->hh
        if (rgEdgeIdToHhEdgeId[0][rgEdgeId] == -1) {
          rgEdgeIdToHhEdgeId[0][rgEdgeId] = hhEdgeId;
        } else {
          rgEdgeIdToHhEdgeId[1][rgEdgeId] = hhEdgeId;
        }
      }
      hhEdgeId++;
    }

    return new EdgeMapper(hhEdgeIdToRgEdgeId, rgEdgeIdToHhEdgeId, reversed);
  }