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) |
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 void |
createCHPreparations()
Deprecated.
use getCHFactoryDecorator().createPreparations() instead. Will be removed in 0.8.
|
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)
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() |
int |
getCHPrepareThreads()
Deprecated.
Use getCHFactoryDecorator().getCHPrepareThreads() instead. Will be removed in
0.8.
|
List<String> |
getCHWeightings()
Deprecated.
Use getCHFactoryDecorator().getWeightingsAsStrings() instead. Will be removed in
0.8.
|
String |
getDataReaderFile() |
ElevationProvider |
getElevationProvider() |
EncodingManager |
getEncodingManager() |
String |
getGraphHopperLocation() |
GraphHopperStorage |
getGraphHopperStorage()
The underlying graph used in algorithms.
|
LocationIndex |
getLocationIndex()
The location index created from the graph.
|
int |
getMaxVisitedNodes() |
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.
|
protected GraphHopper |
loadGraph(GraphHopperStorage g)
For testing only
|
void |
postProcessing()
Does the preparation and creates the location index
|
protected void |
prepare() |
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 setEnabled() instead. Will be removed in 0.8.
|
GraphHopper |
setCHEnabled(boolean enable)
Enables or disables contraction hierarchies (CH).
|
GraphHopper |
setCHPrepareThreads(int prepareThreads)
Deprecated.
Use getCHFactoryDecorator().setCHPrepareThreads() instead. Will be removed in
0.8.
|
GraphHopper |
setCHWeighting(String weightingName)
Deprecated.
This method is used as a deprecated wrapper to not break the JavaApi. This will
be removed in 0.7. Please use
setCHWeightings(List) or
setCHWeightings(String...) |
GraphHopper |
setCHWeightings(List<String> weightingList)
Deprecated.
Use getCHFactoryDecorator().setWeightingsAsStrings() instead. Will be removed in
0.8.
|
GraphHopper |
setCHWeightings(String... weightingNames)
Deprecated.
Use getCHFactoryDecorator().setWeightingsAsStrings() instead. Will be removed in
0.8.
|
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) |
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 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()
@Deprecated public GraphHopper setCHWeighting(String weightingName)
setCHWeightings(List)
or
setCHWeightings(String...)
setCHWeightings(List)
public GraphHopper setCHWeightings(String... weightingNames)
setCHWeightings(List)
public List<String> getCHWeightings()
public GraphHopper setCHWeightings(List<String> weightingList)
weightingList
- A list containing multiple weightings like: "fastest", "shortest" or
your own weight-calculation type.public int getCHPrepareThreads()
public GraphHopper setCHPrepareThreads(int prepareThreads)
public GraphHopper setCHEnable(boolean enable)
public 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 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()
protected void createCHPreparations()
public void postProcessing()
public Weighting createWeighting(HintsMap hintsMap, FlagEncoder encoder)
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 vehicleHintsMap
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)
protected LocationIndex createLocationIndex(Directory dir)
protected void initLocationIndex()
protected void prepare()
protected void cleanUp()
protected void flush()
public void close()
public void clean()
protected void ensureNotLoaded()
protected void ensureWriteAccess()
Copyright © 2012–2016. All rights reserved.