public GraphHopperGtfs(PtFlagEncoder flagEncoder, TranslationMap translationMap, GraphHopperStorage graphHopperStorage, LocationIndex locationIndex, GtfsStorage gtfsStorage, RealtimeFeed realtimeFeed) { this.flagEncoder = flagEncoder; this.accessEgressWeighting = new FastestWeighting(graphHopperStorage.getEncodingManager().getEncoder("foot")); this.translationMap = translationMap; this.graphHopperStorage = graphHopperStorage; this.locationIndex = locationIndex; this.gtfsStorage = gtfsStorage; this.realtimeFeed = realtimeFeed; this.tripFromLabel = new TripFromLabel(this.gtfsStorage, this.realtimeFeed); }
private void interpolateBridgesAndOrTunnels() { if (ghStorage.getEncodingManager().supports("generic")) { final FlagEncoder genericFlagEncoder = ghStorage.getEncodingManager() .getEncoder("generic"); if (!(genericFlagEncoder instanceof DataFlagEncoder)) { throw new IllegalStateException("'generic' flag encoder for elevation interpolation of " + "bridges and tunnels is enabled but does not have the expected type " + DataFlagEncoder.class.getName() + "."); } final DataFlagEncoder dataFlagEncoder = (DataFlagEncoder) genericFlagEncoder; StopWatch sw = new StopWatch().start(); new TunnelElevationInterpolator(ghStorage, dataFlagEncoder).execute(); float tunnel = sw.stop().getSeconds(); sw = new StopWatch().start(); new BridgeElevationInterpolator(ghStorage, dataFlagEncoder).execute(); logger.info("Bridge interpolation " + (int) sw.stop().getSeconds() + "s, " + "tunnel interpolation " + (int) tunnel + "s"); } }
public static LocationIndex createOrLoadIndex(GHDirectory directory, GraphHopperStorage graphHopperStorage) { final EdgeFilter filter = DefaultEdgeFilter.allEdges(graphHopperStorage.getEncodingManager().getEncoder("foot")); Graph walkNetwork = GraphSupport.filteredView(graphHopperStorage, filter); LocationIndex locationIndex = new LocationIndexTree(walkNetwork, directory); if (!locationIndex.loadExisting()) { locationIndex.prepareIndex(); } return locationIndex; }
public OSMReader(GraphHopperStorage ghStorage) { this.ghStorage = ghStorage; this.graph = ghStorage; this.nodeAccess = graph.getNodeAccess(); this.encodingManager = ghStorage.getEncodingManager(); osmNodeIdToInternalNodeMap = new GHLongIntBTree(200); osmNodeIdToNodeFlagsMap = new GHLongLongHashMap(200, .5f); osmWayIdToRouteWeightMap = new GHLongLongHashMap(200, .5f); pillarInfo = new PillarInfo(nodeAccess.is3D(), ghStorage.getDirectory()); }
/** * Create a new storage from the specified one without copying the data. */ public static GraphHopperStorage newStorage(GraphHopperStorage store) { Directory outdir = guessDirectory(store); boolean is3D = store.getNodeAccess().is3D(); return new GraphHopperStorage(store.getCHWeightings(), outdir, store.getEncodingManager(), is3D, store.getExtension()). create(store.getNodes()); }
final EdgeFilter filter = DefaultEdgeFilter.allEdges(graphHopperStorage.getEncodingManager().getEncoder("foot")); QueryResult queryResult = locationIndex.findClosest(source.lat, source.lon, filter); queryGraph.lookup(Collections.singletonList(queryResult));
private QueryResult findClosest(GHPoint point, int indexForErrorMessage) { final EdgeFilter filter = DefaultEdgeFilter.allEdges(graphHopperStorage.getEncodingManager().getEncoder("foot")); QueryResult source = locationIndex.findClosest(point.lat, point.lon, filter); if (!source.isValid()) { throw new PointNotFoundException("Cannot find point: " + point, indexForErrorMessage); } if (flagEncoder.getEdgeType(source.getClosestEdge().getFlags()) != GtfsStorage.EdgeType.HIGHWAY) { throw new RuntimeException(flagEncoder.getEdgeType(source.getClosestEdge().getFlags()).name()); } return source; }
@GET public Info getInfo() { final Info info = new Info(); // use bbox always without elevation (for backward compatibility) info.bbox = new BBox(storage.getBounds().minLon, storage.getBounds().maxLon, storage.getBounds().minLat, storage.getBounds().maxLat); info.supported_vehicles = storage.getEncodingManager().toString().split(","); for (String v : info.supported_vehicles) { Info.PerVehicle perVehicleJson = new Info.PerVehicle(); perVehicleJson.elevation = hasElevation; info.features.put(v, perVehicleJson); } info.import_date = storage.getProperties().get("datareader.import.date"); info.data_date = storage.getProperties().get("datareader.data.date"); info.prepare_ch_date = storage.getProperties().get("prepare.ch.date"); info.prepare_date = storage.getProperties().get("prepare.ch.date"); return info; } }
void connectStopsToStreetNetwork() { FlagEncoder footEncoder = ((GraphHopperStorage) graph).getEncodingManager().getEncoder("foot"); final EdgeFilter filter = DefaultEdgeFilter.allEdges(footEncoder); for (Stop stop : feed.stops.values()) { if (stop.location_type == 0) { // Only stops. Not interested in parent stations for now. QueryResult locationQueryResult = walkNetworkIndex.findClosest(stop.stop_lat, stop.stop_lon, filter); int streetNode; if (!locationQueryResult.isValid()) { streetNode = i++; nodeAccess.setNode(streetNode, stop.stop_lat, stop.stop_lon); EdgeIteratorState edge = graph.edge(streetNode, streetNode); edge.setFlags(encoder.setAccess(edge.getFlags(), true, false)); edge.setFlags(footEncoder.setAccess(edge.getFlags(), true, false)); edge.setFlags(footEncoder.setSpeed(edge.getFlags(), 5.0)); } else { streetNode = locationQueryResult.getClosestNode(); } gtfsStorage.getStationNodes().put(stop.stop_id, streetNode); } } }
public ShapeFileReader(GraphHopperStorage ghStorage) { this.graphStorage = ghStorage; this.graph = ghStorage; this.nodeAccess = graph.getNodeAccess(); this.encodingManager = ghStorage.getEncodingManager(); }
private void interpolateBridgesAndOrTunnels() { if (ghStorage.getEncodingManager().supports("generic")) { final FlagEncoder genericFlagEncoder = ghStorage.getEncodingManager() .getEncoder("generic"); if (!(genericFlagEncoder instanceof DataFlagEncoder)) { throw new IllegalStateException("'generic' flag encoder for elevation interpolation of " + "bridges and tunnels is enabled but does not have the expected type " + DataFlagEncoder.class.getName() + "."); } final DataFlagEncoder dataFlagEncoder = (DataFlagEncoder) genericFlagEncoder; StopWatch sw = new StopWatch().start(); new TunnelElevationInterpolator(ghStorage, dataFlagEncoder).execute(); float tunnel = sw.stop().getSeconds(); sw = new StopWatch().start(); new BridgeElevationInterpolator(ghStorage, dataFlagEncoder).execute(); logger.info("Bridge interpolation " + (int) sw.stop().getSeconds() + "s, " + "tunnel interpolation " + (int) tunnel + "s"); } }
private void interpolateBridgesAndOrTunnels() { if (ghStorage.getEncodingManager().supports("generic")) { final FlagEncoder genericFlagEncoder = ghStorage.getEncodingManager() .getEncoder("generic"); if (!(genericFlagEncoder instanceof DataFlagEncoder)) { throw new IllegalStateException("'generic' flag encoder for elevation interpolation of " + "bridges and tunnels is enabled but does not have the expected type " + DataFlagEncoder.class.getName() + "."); } final DataFlagEncoder dataFlagEncoder = (DataFlagEncoder) genericFlagEncoder; StopWatch sw = new StopWatch().start(); new TunnelElevationInterpolator(ghStorage, dataFlagEncoder).execute(); float tunnel = sw.stop().getSeconds(); sw = new StopWatch().start(); new BridgeElevationInterpolator(ghStorage, dataFlagEncoder).execute(); logger.info("Bridge interpolation " + (int) sw.stop().getSeconds() + "s, " + "tunnel interpolation " + (int) tunnel + "s"); } }
/** * Create a new storage from the specified one without copying the data. */ public static GraphHopperStorage newStorage( GraphHopperStorage store ) { Directory outdir = guessDirectory(store); boolean is3D = store.getNodeAccess().is3D(); return new GraphHopperStorage(store.getCHWeightings(), outdir, store.getEncodingManager(), is3D, store.getExtension()). create(store.getNodes()); }
/** * Create a new storage from the specified one without copying the data. */ public static GraphHopperStorage newStorage(GraphHopperStorage store) { Directory outdir = guessDirectory(store); boolean is3D = store.getNodeAccess().is3D(); return new GraphHopperStorage(store.getCHWeightings(), outdir, store.getEncodingManager(), is3D, store.getExtension()). create(store.getNodes()); }
/** * Create a new storage from the specified one without copying the data. */ public static GraphHopperStorage newStorage(GraphHopperStorage store) { Directory outdir = guessDirectory(store); boolean is3D = store.getNodeAccess().is3D(); return new GraphHopperStorage(store.getCHWeightings(), outdir, store.getEncodingManager(), is3D, store.getExtension()). create(store.getNodes()); }