public class GraphHopper extends Object
| Constructor and Description |
|---|
GraphHopper() |
| 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 Router |
doCreateRouter(GraphHopperStorage ghStorage,
LocationIndex locationIndex,
Map<String,Profile> profilesByName,
PathDetailsBuilderFactory pathBuilderFactory,
TranslationMap trMap,
RouterConfig routerConfig,
WeightingFactory weightingFactory,
Map<String,RoutingCHGraph> chGraphs,
Map<String,LandmarkStorage> landmarks) |
protected void |
ensureNotLoaded() |
protected void |
ensureWriteAccess() |
protected void |
flush() |
Map<String,RoutingCHGraph> |
getCHGraphs() |
CHPreparationHandler |
getCHPreparationHandler() |
CountryRuleFactory |
getCountryRuleFactory() |
String |
getCustomAreasDirectory() |
ElevationProvider |
getElevationProvider() |
EncodedValueFactory |
getEncodedValueFactory() |
EncodingManager |
getEncodingManager() |
EncodingManager.Builder |
getEncodingManagerBuilder() |
boolean |
getFullyLoaded() |
String |
getGraphHopperLocation() |
GraphHopperStorage |
getGraphHopperStorage()
The underlying graph used in algorithms.
|
Map<String,LandmarkStorage> |
getLandmarks() |
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() |
OSMReaderConfig |
getReaderConfig() |
RouterConfig |
getRouterConfig() |
TagParserFactory |
getTagParserFactory() |
TranslationMap |
getTranslationMap() |
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()
Load from existing graph folder.
|
protected void |
loadOrPrepareCH(boolean closeEarly) |
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.
|
protected void |
postImport() |
protected void |
postProcessing(boolean closeEarly)
Runs both after the import and when loading an existing Graph
|
protected Map<String,PrepareContractionHierarchies.Result> |
prepareCH(boolean closeEarly,
List<CHConfig> configsToPrepare) |
protected List<PrepareLandmarks> |
prepareLM(boolean closeEarly,
List<LMConfig> configsToPrepare) |
GHResponse |
route(GHRequest request) |
GraphHopper |
setAllowWrites(boolean allowWrites)
Specifies if it is allowed for GraphHopper to write.
|
GraphHopper |
setCountryRuleFactory(CountryRuleFactory countryRuleFactory)
Sets the factory used to create country rules.
|
GraphHopper |
setCustomAreasDirectory(String customAreasDirectory) |
GraphHopper |
setElevation(boolean includeElevation)
Enable storing and fetching elevation data.
|
GraphHopper |
setElevationProvider(ElevationProvider eleProvider) |
GraphHopper |
setEncodedValueFactory(EncodedValueFactory factory) |
GraphHopper |
setFlagEncoderFactory(FlagEncoderFactory factory) |
GraphHopper |
setGraphHopperLocation(String ghLocation)
Sets the graphhopper folder.
|
void |
setGraphHopperStorage(GraphHopperStorage ghStorage) |
protected void |
setLocationIndex(LocationIndex locationIndex) |
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) |
public EncodingManager.Builder getEncodingManagerBuilder()
public EncodingManager getEncodingManager()
public ElevationProvider getElevationProvider()
public GraphHopper setElevationProvider(ElevationProvider eleProvider)
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)
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 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 Map<String,RoutingCHGraph> getCHGraphs()
public Map<String,LandmarkStorage> getLandmarks()
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 setCustomAreasDirectory(String customAreasDirectory)
public String getCustomAreasDirectory()
public GraphHopper setCountryRuleFactory(CountryRuleFactory countryRuleFactory)
public CountryRuleFactory getCountryRuleFactory()
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 postImport()
protected void importOSM()
protected File _getOSMFile()
public boolean load()
public final CHPreparationHandler getCHPreparationHandler()
public final LMPreparationHandler getLMPreparationHandler()
protected void postProcessing(boolean closeEarly)
closeEarly - release resources as early as possibleprotected void importPublicTransit()
public final Weighting createWeighting(Profile profile, PMap hints, boolean disableTurnCosts)
protected WeightingFactory createWeightingFactory()
public GHResponse route(GHRequest request)
protected Router doCreateRouter(GraphHopperStorage ghStorage, LocationIndex locationIndex, Map<String,Profile> profilesByName, PathDetailsBuilderFactory pathBuilderFactory, TranslationMap trMap, RouterConfig routerConfig, WeightingFactory weightingFactory, Map<String,RoutingCHGraph> chGraphs, Map<String,LandmarkStorage> landmarks)
protected LocationIndex createLocationIndex(Directory dir)
protected void initLocationIndex()
protected void loadOrPrepareCH(boolean closeEarly)
protected Map<String,PrepareContractionHierarchies.Result> prepareCH(boolean closeEarly, List<CHConfig> configsToPrepare)
protected void loadOrPrepareLM(boolean closeEarly)
protected List<PrepareLandmarks> prepareLM(boolean closeEarly, List<LMConfig> configsToPrepare)
protected void cleanUp()
protected void flush()
public void close()
public void clean()
protected void ensureNotLoaded()
protected void ensureWriteAccess()
public boolean getFullyLoaded()
public RouterConfig getRouterConfig()
public OSMReaderConfig getReaderConfig()
Copyright © 2012–2022. All rights reserved.