本文整理汇总了Java中com.graphhopper.routing.util.EncodingManager类的典型用法代码示例。如果您正苦于以下问题:Java EncodingManager类的具体用法?Java EncodingManager怎么用?Java EncodingManager使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
EncodingManager类属于com.graphhopper.routing.util包,在下文中一共展示了EncodingManager类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: init
import com.graphhopper.routing.util.EncodingManager; //导入依赖的package包/类
/**
* Creates a new GraphHopper for the given map name.
* @param newMapName the name of the map to load
*/
public static void init(String newMapName){
if(newMapName.equals(mapName)) return;
mapName = newMapName;
hopper = new GraphHopper().forDesktop();
hopper.setOSMFile("osm" + File.separator + mapName + ".osm.pbf");
hopper.setCHEnabled(false); // CH does not work with shortest weighting (at the moment)
// where to store GH files?
hopper.setGraphHopperLocation("graphs" + File.separator + mapName);
hopper.setEncodingManager(new EncodingManager("car"));
// this may take a few minutes
hopper.importOrLoad();
}
示例2: init
import com.graphhopper.routing.util.EncodingManager; //导入依赖的package包/类
public GraphExtension init(GraphHopper graphhopper) throws Exception {
if (_storage != null)
throw new Exception("GraphStorageBuilder has been already initialized.");
// extract profiles from GraphHopper instance
EncodingManager encMgr = graphhopper.getEncodingManager();
List<FlagEncoder> encoders = encMgr.fetchEdgeEncoders();
int[] profileTypes = new int[encoders.size()];
int i = 0;
for (FlagEncoder enc : encoders)
{
profileTypes[i] = RoutingProfileType.getFromEncoderName(enc.toString());
i++;
}
_storage = new AccessRestrictionsGraphStorage(profileTypes);
return _storage;
}
示例3: createHopper
import com.graphhopper.routing.util.EncodingManager; //导入依赖的package包/类
/**
* Helper method to create a {@link HeatStressGraphHopper} instance using
* the specified files.
*
* @param osmFile
* a OSM XML or OSM PBF file (see {@link OSMFileReader})
* @param weatherDataFile
* a CSV file containing the data of the weather station (see
* {@link WeatherDataParser})
* @param waySegmentsFile
* a CSV file containing the weighted lines segments (see
* {@link WaySegmentParser})
* @return a {@code HeatStressGraphHopper} instance
* @throws IOException
* if an error occurs while reading one of the specified files
*/
public static HeatStressGraphHopper createHopper(File osmFile,
File weatherDataFile, File waySegmentsFile) throws IOException {
java.nio.file.Path ghLocation = Files
.createTempDirectory("graph_hopper");
OSMData osmData = new OSMFileReader().read(osmFile);
WeatherData weatherData = new WeatherDataParser()
.parse(weatherDataFile);
WaySegments waySegments = new WaySegmentParser().parse(waySegmentsFile);
HeatStressGraphHopper hopper = new HeatStressGraphHopper();
hopper.getCHFactoryDecorator().setEnabled(false);
hopper.setOSMFile(osmFile.getAbsolutePath());
hopper.setGraphHopperLocation(ghLocation.toString());
hopper.setEncodingManager(new EncodingManager(FlagEncoderFactory.FOOT));
hopper.setOsmData(osmData);
hopper.setWeatherData(weatherData);
hopper.setSegments(waySegments);
hopper.importOrLoad();
return hopper;
}
示例4: loadHeatStressGraphHopper
import com.graphhopper.routing.util.EncodingManager; //导入依赖的package包/类
protected void loadHeatStressGraphHopper() {
logger.info(
"GraphHopper Location is " + this.ghLocation.toAbsolutePath());
HeatStressGraphHopper hopper = new HeatStressGraphHopper();
hopper.getCHFactoryDecorator().setEnabled(false);
hopper.setOSMFile(osmFile.getAbsolutePath());
hopper.setGraphHopperLocation(this.ghLocation.toString());
hopper.setEncodingManager(new EncodingManager(FlagEncoderFactory.FOOT));
hopper.setOsmData(this.osmData);
hopper.setWeatherData(this.weatherData);
if (waySegments != null)
hopper.setSegments(this.waySegments);
hopper.importOrLoad();
logger.info("CHEnabled = " + hopper.isCHEnabled() + ", getNodes = "
+ hopper.getGraphHopperStorage().getNodes() + ", mainEdges = "
+ hopper.getGraphHopperStorage().getAllEdges().getMaxId());
this.hopper = hopper;
}
示例5: get
import com.graphhopper.routing.util.EncodingManager; //导入依赖的package包/类
/**
*
* @param osmFile path to the osmFile to use
* @param workingDir if multiple GH instances are used, then each should have a different workingDir
* @return graphhopper instance
*/
public static GraphHopper get(String osmFile, String workingDir) {
GraphHopper hopper;
// create one GraphHopper instance
Map<String, String> env = System.getenv();
if(Boolean.valueOf(env.get("LOW_MEMORY"))) {
LOGGER.info("Using Graphhopper for mobile due to LOW_MEMORY env.");
hopper = new GraphHopper().forMobile();
hopper.setCHPrepareThreads(1);
} else {
hopper = new GraphHopper().forServer();
}
hopper.setOSMFile(osmFile);
hopper.setGraphHopperLocation(workingDir);
hopper.setEncodingManager(new EncodingManager("car"));
hopper.importOrLoad();
return hopper;
}
示例6: GUILocalization
import com.graphhopper.routing.util.EncodingManager; //导入依赖的package包/类
public GUILocalization(String osmFile, String graphFolder) {
// create singleton
hopper.setOSMFile(osmFile);
hopper.setGraphHopperLocation(graphFolder);
hopper.setEncodingManager(new EncodingManager(encoder));
hopper.setCHEnable(false);
// hopper.clean();
hopper.importOrLoad();
graph = hopper.getGraphHopperStorage();
locationIndex = new LocationIndexMatch(graph,
(LocationIndexTree) hopper.getLocationIndex());
mapMatching = new MapMatching(graph, locationIndex, encoder);
// mapMatching.setMaxSearchMultiplier(50);
mapMatching.setForceRepair(true);
mapMatching.setSeparatedSearchDistance(-1);
}
示例7: MapWrapper
import com.graphhopper.routing.util.EncodingManager; //导入依赖的package包/类
public MapWrapper() {
// create singleton
// hopper.setOSMFile(osmFile);
hopper.setGraphHopperLocation("graphFolder");
hopper.setEncodingManager(new EncodingManager(encoder));
hopper.setCHEnable(false);
// hopper.clean();
hopper.importOrLoad();
graph = hopper.getGraphHopperStorage();
index = new LocationIndexMatch(graph,
(LocationIndexTree) hopper.getLocationIndex());
mapMatching = new MapMatching(graph, index, encoder);
mapMatching.setForceRepair(true);
mapMatching.setSeparatedSearchDistance(-1);
}
示例8: mapMatchingTest
import com.graphhopper.routing.util.EncodingManager; //导入依赖的package包/类
@Test
public void mapMatchingTest() {
GraphHopperStorage graph = hopper.getGraphHopperStorage();
LocationIndexMatch locationIndex = new LocationIndexMatch(graph,
(LocationIndexTree) hopper.getLocationIndex());
MapMatching mapMatching = new MapMatching(graph, locationIndex,
encoder.getEncoder(EncodingManager.CAR));
mapMatching.setSeparatedSearchDistance(30);
// printOverview(graph, hopper.getLocationIndex(), 51.358735, 12.360574,
// 500);
List<GPXEntry> inputGPXEntries = createRandomGPXEntries(new GHPoint(
51.358735, 12.360574), new GHPoint(51.358594, 12.360032));
MatchResult mr = mapMatching.doWork(inputGPXEntries);
}
示例9: identifyFlagEncoder
import com.graphhopper.routing.util.EncodingManager; //导入依赖的package包/类
public static FlagEncoder identifyFlagEncoder(GraphHopper graphHopper, String namedFlagEncoder){
EncodingManager encodingManager = graphHopper.getEncodingManager();
FlagEncoder flagEncoder=null;
if (namedFlagEncoder == null) {
// Pick the first supported encoder from a standard list, ordered by most commonly used first.
// This allows the user to build the graph for the speed profile they want and it just works...
FlagEncoder foundFlagEncoder = null;
for (String vehicleType : getPossibleVehicleTypes()) {
if (encodingManager.supports(vehicleType)) {
foundFlagEncoder = encodingManager.getEncoder(vehicleType);
break;
}
}
if (foundFlagEncoder == null) {
throw new RuntimeException("The road network graph does not support any of the standard vehicle types");
}
flagEncoder = foundFlagEncoder;
} else {
namedFlagEncoder = namedFlagEncoder.toLowerCase().trim();
flagEncoder = encodingManager.getEncoder(namedFlagEncoder);
if (flagEncoder == null) {
throw new RuntimeException("Vehicle type is unsuported in road network graph: " + namedFlagEncoder);
}
}
return flagEncoder;
}
示例10: init
import com.graphhopper.routing.util.EncodingManager; //导入依赖的package包/类
@Override
public void init(GraphHopper graphhopper) throws Exception {
// create local network taken from
// https://github.com/graphhopper/graphhopper/blob/0.5/core/src/test/java/com/graphhopper/GraphHopperTest.java#L746
footEncoder = new FootFlagEncoder();
encodingManager = new EncodingManager(footEncoder);
weightings = new ArrayList<Weighting>(1);
weightings.add(new FastestWeighting(footEncoder));
}
示例11: init
import com.graphhopper.routing.util.EncodingManager; //导入依赖的package包/类
public static void init(String newMapName, double cellSize, double proximity) {
if (newMapName.equals(mapName)) {
return;
}
MapHelper.cellSize = cellSize;
Location.setProximity(proximity);
mapName = newMapName;
locations = new HashMap<String, Location>();
hopper = new GraphHopper().forDesktop();
hopper.setOSMFile("osm" + File.separator + mapName + ".osm.pbf");
hopper.setGraphHopperLocation("graphs" + File.separator + mapName);
hopper.setEncodingManager(new EncodingManager(EncodingManager.CAR));
hopper.importOrLoad();
}
示例12: init
import com.graphhopper.routing.util.EncodingManager; //导入依赖的package包/类
private void init() {
File ghDirectory = new File(GHLOCATION);
//delete GH if it exists
if(ghDirectory.exists() && ghDirectory.isDirectory()){
try {
FileUtils.deleteDirectory(ghDirectory);
} catch (IOException e) {
e.printStackTrace();
}
}
// import OpenStreetMap data
hopper = new GraphHopperOSM();
hopper.setDataReaderFile(OSM);
hopper.setGraphHopperLocation(GHLOCATION);
encoder = new CarFlagEncoder();
hopper.setEncodingManager(new EncodingManager(encoder));
hopper.getCHFactoryDecorator().setEnabled(false);
hopper.importOrLoad();
//for map matching core version 8.2
opts = AlgorithmOptions.start()
.algorithm(Parameters.Algorithms.DIJKSTRA_BI).traversalMode(hopper.getTraversalMode())
.weighting(new FastestWeighting(encoder))
.maxVisitedNodes(10000)
.hints(new HintsMap().put("weighting", "fastest").put("vehicle", encoder.toString()))
.build();
}
示例13: createWeighting
import com.graphhopper.routing.util.EncodingManager; //导入依赖的package包/类
/**
* Creates a new weighting with the specified {@code weightingType} and the
* {@code time}. The created Weighting can be used to calculate the route
* weight.
*
* @param weightingType
* the {@link WeightingType}
* @param time
* the point in time
* @return a {@link Weighting} with the specified weighting and point in
* time
*/
public Weighting createWeighting(WeightingType weightingType,
LocalDateTime time) {
// create weighting map and add a the time
HintsMap hintsMap = new HintsMap(weightingType.toString());
hintsMap.setVehicle(this.encodingManager);
hintsMap.put("time", time.toString());
FlagEncoder flagEncoder = new EncodingManager(encodingManager)
.getEncoder(encodingManager);
return hopper.createWeighting(hintsMap, flagEncoder);
}
示例14: RoadsToGraphHopperGtfs
import com.graphhopper.routing.util.EncodingManager; //导入依赖的package包/类
public RoadsToGraphHopperGtfs(EncodingManager encodingManager,
TranslationMap translationMap,
GraphHopperStorage graphHopperStorage, LocationIndex locationIndex,
GtfsStorage gtfsStorage) {
this.encodingManager = encodingManager;
this.translationMap = translationMap;
this.graphHopperStorage = graphHopperStorage;
this.locationIndex = locationIndex;
this.gtfsStorage = gtfsStorage;
}
示例15: loadGraphHopper
import com.graphhopper.routing.util.EncodingManager; //导入依赖的package包/类
private void loadGraphHopper() {
// create one GraphHopper instance
Map<String, String> env = System.getenv();
if(Boolean.valueOf(env.get("LOW_MEMORY"))) {
LOGGER.info("Using Graphhopper for mobile due to LOW_MEMORY env.");
hopper = new GraphHopper().forMobile();
hopper.setCHPrepareThreads(1);
} else {
hopper = new GraphHopper().forServer();
}
hopper.setOSMFile(osmPath);
hopper.setGraphHopperLocation(ghCacheLocation);
hopper.setEncodingManager(new EncodingManager("car"));
hopper.importOrLoad();
}