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 void |
createBaseGraphAndProperties() |
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(BaseGraph baseGraph,
EncodingManager encodingManager,
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() |
BaseGraph |
getBaseGraph()
The underlying graph used in algorithms.
|
Map<String,RoutingCHGraph> |
getCHGraphs() |
CHPreparationHandler |
getCHPreparationHandler() |
CountryRuleFactory |
getCountryRuleFactory() |
String |
getCustomAreasDirectory() |
ElevationProvider |
getElevationProvider() |
EncodedValueFactory |
getEncodedValueFactory() |
EncodingManager |
getEncodingManager() |
boolean |
getFullyLoaded() |
String |
getGraphHopperLocation() |
Map<String,LandmarkStorage> |
getLandmarks() |
LMPreparationHandler |
getLMPreparationHandler() |
LocationIndex |
getLocationIndex()
The location index created from the graph.
|
String |
getOSMFile() |
OSMParsers |
getOSMParsers() |
PathDetailsBuilderFactory |
getPathDetailsBuilderFactory() |
Profile |
getProfile(String profileName)
Returns the profile for the given profile name, or null if it does not exist
|
List<Profile> |
getProfiles() |
StorableProperties |
getProperties() |
OSMReaderConfig |
getReaderConfig() |
RouterConfig |
getRouterConfig() |
TagParserFactory |
getTagParserFactory() |
TranslationMap |
getTranslationMap() |
VehicleTagParserFactory |
getVehicleTagParserFactory() |
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.
|
void |
setBaseGraph(BaseGraph baseGraph) |
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 |
setEncodedValuesString(String encodedValuesString) |
GraphHopper |
setFlagEncodersString(String flagEncodersString) |
GraphHopper |
setGraphHopperLocation(String ghLocation)
Sets the graphhopper folder.
|
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) |
GraphHopper |
setUrbanDensityCalculation(double residentialAreaRadius,
double residentialAreaSensitivity,
double cityAreaRadius,
double cityAreaSensitivity,
int threads)
Configures the urban density classification.
|
GraphHopper |
setVehicleEncodedValuesFactory(VehicleEncodedValuesFactory factory) |
GraphHopper |
setVehicleTagParserFactory(VehicleTagParserFactory factory) |
protected void |
writeEncodingManagerToProperties() |
public GraphHopper setEncodedValuesString(String encodedValuesString)
public GraphHopper setFlagEncodersString(String flagEncodersString)
public EncodingManager getEncodingManager()
public OSMParsers getOSMParsers()
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 setUrbanDensityCalculation(double residentialAreaRadius, double residentialAreaSensitivity, double cityAreaRadius, double cityAreaSensitivity, int threads)
UrbanDensity
residentialAreaRadius
- in meters. The higher this value the longer the calculation will take and the bigger the area for
which the road density used to identify residential areas is calculated.residentialAreaSensitivity
- Use this to find a trade-off between too many roads being classified as residential (too high
values) and not enough roads being classified as residential (too small values)cityAreaRadius
- in meters. The higher this value the longer the calculation will take and the bigger the area for
which the road density used to identify city areas is calculated. Set this to zero
to skip the city classification.cityAreaSensitivity
- Use this to find a trade-off between too many roads being classified as city (too high values)
and not enough roads being classified as city (too small values)threads
- the number of threads used for the calculation. If this is zero the urban density
calculation is skipped entirelypublic 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 BaseGraph getBaseGraph()
IllegalStateException
- if graph is not instantiated.public void setBaseGraph(BaseGraph baseGraph)
public StorableProperties getProperties()
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 setVehicleEncodedValuesFactory(VehicleEncodedValuesFactory factory)
public EncodedValueFactory getEncodedValueFactory()
public GraphHopper setEncodedValueFactory(EncodedValueFactory factory)
public VehicleTagParserFactory getVehicleTagParserFactory()
public GraphHopper setVehicleTagParserFactory(VehicleTagParserFactory 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`.
Important note: Calling this method overwrites the configuration done in some of the setter methods of this class, so generally it is advised to either use this method to configure GraphHopper or the different setter methods, but not both. Unfortunately, this still does not cover all cases and sometimes you have to use both, but then you should make sure there are no conflicts. If you need both it might also help to call the init before calling the setters, because this way the init method won't apply defaults to configuration options you already chose using the setters.
public GraphHopper importOrLoad()
public void importAndClose()
protected void postImport()
protected void importOSM()
protected void createBaseGraphAndProperties()
protected void writeEncodingManagerToProperties()
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(BaseGraph baseGraph, EncodingManager encodingManager, 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.