OsmIdGraphStorageBuilder.java

  1. package org.heigit.ors.routing.graphhopper.extensions.storages.builders;

  2. import com.graphhopper.GraphHopper;
  3. import com.graphhopper.reader.ReaderWay;
  4. import com.graphhopper.storage.GraphExtension;
  5. import com.graphhopper.util.EdgeIteratorState;
  6. import org.heigit.ors.routing.graphhopper.extensions.storages.OsmIdGraphStorage;

  7. public class OsmIdGraphStorageBuilder extends AbstractGraphStorageBuilder {
  8.     private OsmIdGraphStorage osmIdGraphStorage;

  9.     public GraphExtension init(GraphHopper graphhopper) throws Exception {
  10.         if (osmIdGraphStorage != null)
  11.             throw new Exception("GraphStorageBuilder has been already initialized.");

  12.         osmIdGraphStorage = new OsmIdGraphStorage();

  13.         return osmIdGraphStorage;
  14.     }

  15.     public void processWay(ReaderWay way) {
  16.         // do nothing
  17.     }

  18.     /**
  19.      * Process the graph edge - In the OSMId graph storage this stores the osm id (the way id) against the edge
  20.      *
  21.      * @param way  The full way read from the parser
  22.      * @param edge The EdgeIteratorState representing the edge to be processed
  23.      */
  24.     public void processEdge(ReaderWay way, EdgeIteratorState edge) {
  25.         osmIdGraphStorage.setEdgeValue(edge.getEdge(), way.getId());
  26.     }

  27.     @Override
  28.     public String getName() {
  29.         return "OsmId";
  30.     }
  31. }