public class GraphHopper extends Object implements GraphHopperAPI
GraphHopperAPI
Constructor and Description |
---|
GraphHopper() |
GraphHopper(JsonFeatureCollection landmarkSplittingFeatureCollection) |
Modifier and Type | Method and Description |
---|---|
protected File |
_getOSMFile()
Currently we use this for a few tests where the dataReaderFile is loaded from the classpath
|
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) |
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() |
CHPreparationHandler |
getCHPreparationHandler() |
ElevationProvider |
getElevationProvider() |
EncodedValueFactory |
getEncodedValueFactory() |
EncodingManager |
getEncodingManager() |
boolean |
getFullyLoaded() |
String |
getGraphHopperLocation() |
GraphHopperStorage |
getGraphHopperStorage()
The underlying graph used in algorithms.
|
LMPreparationHandler |
getLMPreparationHandler() |
LocationIndex |
getLocationIndex()
The location index created from the graph.
|
String |
getOSMFile() |
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.
|
GraphHopper |
importOrLoad()
Imports provided data from disc and creates graph.
|
protected void |
importOSM() |
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 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 |
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) |
protected void |
setLocationIndex(LocationIndex locationIndex) |
GraphHopper |
setLongEdgeSamplingDistance(double longEdgeSamplingDistance)
Sets the distance distance between elevation samples on long edges
|
GraphHopper |
setMinNetworkSize(int minNetworkSize) |
GraphHopper |
setOSMFile(String osmFile)
This file can be an osm xml (.osm), a compressed xml (.osm.zip or .osm.gz) or a protobuf file
(.pbf).
|
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 shall be supported by this GraphHopper instance.
|
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.
|
public GraphHopper()
public GraphHopper(JsonFeatureCollection landmarkSplittingFeatureCollection)
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 setPreciseIndexResolution(int precision)
public GraphHopper setMinNetworkSize(int minNetworkSize)
public GraphHopper setStoreOnFlush(boolean storeOnFlush)
storeOnFlush
- true by defaultpublic 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 getOSMFile()
public GraphHopper setOSMFile(String osmFile)
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 void importOSM()
protected File _getOSMFile()
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 boolean getFullyLoaded()
public RouterConfig getRouterConfig()
Copyright © 2012–2021. All rights reserved.