public class GraphHopper extends Object implements GraphHopperAPI
GraphHopperAPI
Constructor and Description |
---|
GraphHopper() |
Modifier and Type | Method and Description |
---|---|
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 LocationIndex |
createLocationIndex(Directory dir) |
protected DataReader |
createReader(GraphHopperStorage ghStorage) |
Weighting |
createWeighting(Profile profile,
PMap hints) |
Weighting |
createWeighting(Profile profile,
PMap hints,
boolean disableTurnCosts) |
protected WeightingFactory |
createWeightingFactory() |
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.
|
CHPreparationHandler |
getCHPreparationHandler() |
String |
getDataReaderFile() |
ElevationProvider |
getElevationProvider() |
EncodedValueFactory |
getEncodedValueFactory() |
EncodingManager |
getEncodingManager() |
String |
getGraphHopperLocation() |
GraphHopperStorage |
getGraphHopperStorage()
The underlying graph used in algorithms.
|
LMPreparationHandler |
getLMPreparationHandler() |
LocationIndex |
getLocationIndex()
The location index created from the graph.
|
PathDetailsBuilderFactory |
getPathDetailsBuilderFactory() |
Profile |
getProfile(String profileName)
Returns the profile for the given profile name, or null if it does not exist
|
List<Profile> |
getProfiles() |
RouterConfig |
getRouterConfig() |
TagParserFactory |
getTagParserFactory() |
TranslationMap |
getTranslationMap() |
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() |
void |
importAndClose()
Imports and processes data, storing it to disk when complete.
|
protected DataReader |
importData() |
GraphHopper |
importOrLoad()
Imports provided data from disc and creates graph.
|
protected void |
importPublicTransit() |
GraphHopper |
init(GraphHopperConfig ghConfig)
Reads the configuration from a
GraphHopperConfig object which can be manually filled, or more typically
is read from `config.yml`. |
protected DataReader |
initDataReader(DataReader reader) |
protected void |
initLocationIndex()
Initializes the location index after the import is done.
|
boolean |
isAllowWrites() |
boolean |
load(String graphHopperFolder)
Opens existing graph folder.
|
protected GraphHopper |
loadGraph(GraphHopperStorage g)
For testing only
|
protected void |
loadOrPrepareLM(boolean closeEarly)
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 |
postProcessing(boolean closeEarly)
Does the preparation and creates the location index
|
protected void |
prepareCH(boolean closeEarly) |
protected void |
registerCustomEncodedValues(EncodingManager.Builder emBuilder) |
GHResponse |
route(GHRequest request) |
GraphHopper |
setAllowWrites(boolean allowWrites)
Specifies if it is allowed for GraphHopper to write.
|
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 |
setElevationWayPointMaxDistance(double elevationWayPointMaxDistance)
Sets the max elevation discrepancy between way points and the simplified polyline in meters
|
GraphHopper |
setEncodedValueFactory(EncodedValueFactory factory) |
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) |
GraphHopper |
setLongEdgeSamplingDistance(double longEdgeSamplingDistance)
Sets the distance distance between elevation samples on long edges
|
GraphHopper |
setMemoryMapped()
Enable memory mapped configuration if not enough memory is available on the target platform.
|
GraphHopper |
setMinNetworkSize(int minNetworkSize) |
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 |
setProfiles(List<Profile> profiles) |
GraphHopper |
setProfiles(Profile... profiles)
Sets the routing profiles that can be used for CH/LM preparation.
|
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 |
setTagParserFactory(TagParserFactory factory) |
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 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)
public GraphHopper setInMemory()
public GraphHopper setStoreOnFlush(boolean storeOnFlush)
storeOnFlush
- true by defaultpublic GraphHopper setMemoryMapped()
public GraphHopper setProfiles(Profile... profiles)
Here is an example how to setup two CH profiles and one LM profile (via the Java API)
// make sure the encoding manager contains a "car" and a "bike" flag encoder
hopper.setProfiles(
new Profile("my_car").setVehicle("car").setWeighting("shortest"),
new Profile("your_bike").setVehicle("bike").setWeighting("fastest")
);
hopper.getCHPreparationHandler().setCHProfiles(
new CHProfile("my_car"),
new CHProfile("your_bike")
);
hopper.getLMPreparationHandler().setLMProfiles(
new LMProfile("your_bike")
);
See also https://github.com/graphhopper/graphhopper/pull/1922.
public GraphHopper setProfiles(List<Profile> profiles)
public Profile getProfile(String profileName)
public boolean hasElevation()
public GraphHopper setElevation(boolean includeElevation)
public GraphHopper setLongEdgeSamplingDistance(double longEdgeSamplingDistance)
public GraphHopper setElevationWayPointMaxDistance(double elevationWayPointMaxDistance)
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 EncodedValueFactory getEncodedValueFactory()
public GraphHopper setEncodedValueFactory(EncodedValueFactory factory)
public TagParserFactory getTagParserFactory()
public GraphHopper setTagParserFactory(TagParserFactory factory)
public GraphHopper init(GraphHopperConfig ghConfig)
GraphHopperConfig
object which can be manually filled, or more typically
is read from `config.yml`.public GraphHopper importOrLoad()
public void importAndClose()
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 final CHPreparationHandler getCHPreparationHandler()
public final LMPreparationHandler getLMPreparationHandler()
public final void postProcessing()
protected void postProcessing(boolean closeEarly)
closeEarly
- release resources as early as possibleprotected void registerCustomEncodedValues(EncodingManager.Builder emBuilder)
protected void importPublicTransit()
public final Weighting createWeighting(Profile profile, PMap hints, boolean disableTurnCosts)
protected WeightingFactory createWeightingFactory()
public GHResponse route(GHRequest request)
route
in interface GraphHopperAPI
protected LocationIndex createLocationIndex(Directory dir)
protected void initLocationIndex()
protected void prepareCH(boolean closeEarly)
protected void loadOrPrepareLM(boolean closeEarly)
protected void cleanUp()
protected void flush()
public void close()
public void clean()
protected void ensureNotLoaded()
protected void ensureWriteAccess()
public RouterConfig getRouterConfig()
Copyright © 2012–2021. All rights reserved.