public class GraphHopper extends Object implements GraphHopperAPI
GraphHopperAPI
Constructor and Description |
---|
GraphHopper() |
Modifier and Type | Method and Description |
---|---|
GraphHopper |
addAlgorithmFactoryDecorator(RoutingAlgorithmFactoryDecorator algoFactoryDecorator) |
List<Path> |
calcPaths(GHRequest request,
GHResponse ghRsp)
This method calculates the alternative path list using the low level Path objects.
|
ChangeGraphResponse |
changeGraph(Collection<JsonFeature> collection)
This method applies the changes to the graph specified as feature collection.
|
void |
clean()
Removes the on-disc routing files.
|
protected void |
cleanUp()
Internal method to clean up the graph.
|
void |
close()
Releases all associated resources like memory or files.
|
protected ChangeGraphHelper |
createChangeGraphHelper(Graph graph,
LocationIndex locationIndex) |
protected LocationIndex |
createLocationIndex(Directory dir) |
protected DataReader |
createReader(GraphHopperStorage ghStorage) |
Weighting |
createTurnWeighting(Graph graph,
Weighting weighting,
TraversalMode tMode)
Potentially wraps the specified weighting into a TurnWeighting instance.
|
Weighting |
createWeighting(HintsMap hintsMap,
FlagEncoder encoder,
Graph graph)
Based on the hintsMap and the specified encoder a Weighting instance can be
created.
|
protected void |
ensureNotLoaded() |
protected void |
ensureWriteAccess() |
protected void |
flush() |
GraphHopper |
forDesktop()
Configures the underlying storage to be used on a Desktop computer or within another Java
application with enough RAM but no network latency.
|
GraphHopper |
forMobile()
Configures the underlying storage to be used on a less powerful machine like Android or
Raspberry Pi with only few MB of RAM.
|
GraphHopper |
forServer()
Configures the underlying storage and response to be used on a well equipped server.
|
RoutingAlgorithmFactory |
getAlgorithmFactory(HintsMap map) |
CHAlgoFactoryDecorator |
getCHFactoryDecorator() |
String |
getDataReaderFile() |
ElevationProvider |
getElevationProvider() |
EncodingManager |
getEncodingManager() |
FlagEncoderFactory |
getFlagEncoderFactory() |
String |
getGraphHopperLocation() |
GraphHopperStorage |
getGraphHopperStorage()
The underlying graph used in algorithms.
|
LMAlgoFactoryDecorator |
getLMFactoryDecorator() |
LocationIndex |
getLocationIndex()
The location index created from the graph.
|
int |
getMaxVisitedNodes() |
PathDetailsBuilderFactory |
getPathDetailsBuilderFactory() |
String |
getPreferredLanguage() |
TranslationMap |
getTranslationMap() |
TraversalMode |
getTraversalMode() |
protected double |
getWayPointMaxDistance()
Return maximum distance (in meter) to reduce points via douglas peucker while OSM import.
|
protected int |
getWorkerThreads()
Threads for data reading.
|
boolean |
hasElevation() |
protected DataReader |
importData() |
GraphHopper |
importOrLoad()
Imports provided data from disc and creates graph.
|
GraphHopper |
init(CmdArgs args)
Reads configuration from a CmdArgs object.
|
protected DataReader |
initDataReader(DataReader reader) |
protected void |
initLocationIndex()
Initializes the location index after the import is done.
|
boolean |
isAllowWrites() |
boolean |
isCHEnabled() |
boolean |
isEnableInstructions() |
boolean |
load(String graphHopperFolder)
Opens existing graph folder.
|
protected GraphHopper |
loadGraph(GraphHopperStorage g)
For testing only
|
protected void |
loadOrPrepareLM()
For landmarks it is required to always call this method: either it creates the landmark data or it loads it.
|
void |
postProcessing()
Does the preparation and creates the location index
|
protected void |
prepareCH() |
GHResponse |
route(GHRequest request)
Calculates the path from specified request visiting the specified locations.
|
GraphHopper |
setAllowWrites(boolean allowWrites)
Specifies if it is allowed for GraphHopper to write.
|
GraphHopper |
setCHEnable(boolean enable)
Deprecated.
use
setCHEnabled(boolean) instead |
GraphHopper |
setCHEnabled(boolean enable)
Enables or disables contraction hierarchies (CH).
|
GraphHopper |
setDataReaderFile(String dataReaderFileStr)
This file can be any file type supported by the DataReader.
|
GraphHopper |
setElevation(boolean includeElevation)
Enable storing and fetching elevation data.
|
GraphHopper |
setElevationProvider(ElevationProvider eleProvider) |
GraphHopper |
setEnableCalcPoints(boolean b)
This methods enables gps point calculation.
|
GraphHopper |
setEnableInstructions(boolean b)
This method specifies if the import should include way names to be able to return
instructions for a route.
|
GraphHopper |
setEncodingManager(EncodingManager em)
Specify which vehicles can be read by this GraphHopper instance.
|
GraphHopper |
setFlagEncoderFactory(FlagEncoderFactory factory) |
GraphHopper |
setGraphHopperLocation(String ghLocation)
Sets the graphhopper folder.
|
void |
setGraphHopperStorage(GraphHopperStorage ghStorage) |
GraphHopper |
setInMemory()
This method call results in an in-memory graph.
|
protected void |
setLocationIndex(LocationIndex locationIndex) |
void |
setMaxVisitedNodes(int maxVisitedNodes)
This methods stops the algorithm from searching further if the resulting path would go over
the specified node count, important if none-CH routing is used.
|
GraphHopper |
setMemoryMapped()
Enable memory mapped configuration if not enough memory is available on the target platform.
|
GraphHopper |
setMinNetworkSize(int minNetworkSize,
int minOneWayNetworkSize) |
void |
setNonChMaxWaypointDistance(int nonChMaxWaypointDistance) |
GraphHopper |
setPathDetailsBuilderFactory(PathDetailsBuilderFactory pathBuilderFactory) |
GraphHopper |
setPreciseIndexResolution(int precision)
Precise location resolution index means also more space (disc/RAM) could be consumed and
probably slower query times, which would be e.g.
|
GraphHopper |
setPreferredLanguage(String preferredLanguage)
This method specifies the preferred language for way names during import.
|
GraphHopper |
setSortGraph(boolean sortGraph)
Sorts the graph which requires more RAM while import.
|
GraphHopper |
setStoreOnFlush(boolean storeOnFlush)
Only valid option for in-memory graph and if you e.g.
|
GraphHopper |
setTraversalMode(TraversalMode traversalMode)
Sets the default traversal mode used for the algorithms and preparation.
|
GraphHopper |
setWayPointMaxDistance(double wayPointMaxDistance)
This parameter specifies how to reduce points via douglas peucker while OSM import.
|
protected GraphHopper loadGraph(GraphHopperStorage g)
public EncodingManager getEncodingManager()
public GraphHopper setEncodingManager(EncodingManager em)
public ElevationProvider getElevationProvider()
public GraphHopper setElevationProvider(ElevationProvider eleProvider)
protected int getWorkerThreads()
protected double getWayPointMaxDistance()
public GraphHopper setWayPointMaxDistance(double wayPointMaxDistance)
public TraversalMode getTraversalMode()
public GraphHopper setTraversalMode(TraversalMode traversalMode)
public GraphHopper setPathDetailsBuilderFactory(PathDetailsBuilderFactory pathBuilderFactory)
public PathDetailsBuilderFactory getPathDetailsBuilderFactory()
public GraphHopper forServer()
public GraphHopper forDesktop()
public GraphHopper forMobile()
public GraphHopper setPreciseIndexResolution(int precision)
public GraphHopper setMinNetworkSize(int minNetworkSize, int minOneWayNetworkSize)
public GraphHopper setInMemory()
public GraphHopper setStoreOnFlush(boolean storeOnFlush)
storeOnFlush
- true by defaultpublic GraphHopper setMemoryMapped()
public GraphHopper setCHEnable(boolean enable)
setCHEnabled(boolean)
insteadpublic final boolean isCHEnabled()
public GraphHopper setCHEnabled(boolean enable)
public int getMaxVisitedNodes()
public void setMaxVisitedNodes(int maxVisitedNodes)
public boolean hasElevation()
public GraphHopper setElevation(boolean includeElevation)
public boolean isEnableInstructions()
public GraphHopper setEnableInstructions(boolean b)
public String getPreferredLanguage()
public GraphHopper setPreferredLanguage(String preferredLanguage)
Language code as defined in ISO 639-1 or ISO 639-2.
public GraphHopper setEnableCalcPoints(boolean b)
public String getGraphHopperLocation()
public GraphHopper setGraphHopperLocation(String ghLocation)
public String getDataReaderFile()
public GraphHopper setDataReaderFile(String dataReaderFileStr)
public GraphHopperStorage getGraphHopperStorage()
IllegalStateException
- if graph is not instantiated.public void setGraphHopperStorage(GraphHopperStorage ghStorage)
public LocationIndex getLocationIndex()
IllegalStateException
- if index is not initializedprotected void setLocationIndex(LocationIndex locationIndex)
public GraphHopper setSortGraph(boolean sortGraph)
public boolean isAllowWrites()
public GraphHopper setAllowWrites(boolean allowWrites)
public TranslationMap getTranslationMap()
public GraphHopper setFlagEncoderFactory(FlagEncoderFactory factory)
public FlagEncoderFactory getFlagEncoderFactory()
public GraphHopper init(CmdArgs args)
public GraphHopper importOrLoad()
protected DataReader importData() throws IOException
IOException
protected DataReader createReader(GraphHopperStorage ghStorage)
protected DataReader initDataReader(DataReader reader)
public boolean load(String graphHopperFolder)
load
in interface GraphHopperAPI
graphHopperFolder
- is the folder containing graphhopper files. Can be a compressed file
too ala folder-content.ghz.public RoutingAlgorithmFactory getAlgorithmFactory(HintsMap map)
public GraphHopper addAlgorithmFactoryDecorator(RoutingAlgorithmFactoryDecorator algoFactoryDecorator)
public final CHAlgoFactoryDecorator getCHFactoryDecorator()
public final LMAlgoFactoryDecorator getLMFactoryDecorator()
public void postProcessing()
public Weighting createWeighting(HintsMap hintsMap, FlagEncoder encoder, Graph graph)
hintsMap
- all parameters influencing the weighting. E.g. parameters coming via
GHRequest.getHints or directly via "&api.xy=" from the URL of the web UIencoder
- the required vehiclegraph
- The Graph enables the Weighting for NodeAccess and moreHintsMap
public Weighting createTurnWeighting(Graph graph, Weighting weighting, TraversalMode tMode)
public GHResponse route(GHRequest request)
GraphHopperAPI
route
in interface GraphHopperAPI
public List<Path> calcPaths(GHRequest request, GHResponse ghRsp)
public ChangeGraphResponse changeGraph(Collection<JsonFeature> collection)
protected ChangeGraphHelper createChangeGraphHelper(Graph graph, LocationIndex locationIndex)
protected LocationIndex createLocationIndex(Directory dir)
protected void initLocationIndex()
protected void prepareCH()
protected void loadOrPrepareLM()
protected void cleanUp()
protected void flush()
public void close()
public void clean()
protected void ensureNotLoaded()
protected void ensureWriteAccess()
public void setNonChMaxWaypointDistance(int nonChMaxWaypointDistance)
Copyright © 2012–2018. All rights reserved.