本文整理汇总了Java中com.graphhopper.GraphHopper类的典型用法代码示例。如果您正苦于以下问题:Java GraphHopper类的具体用法?Java GraphHopper怎么用?Java GraphHopper使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
GraphHopper类属于com.graphhopper包,在下文中一共展示了GraphHopper类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: init
import com.graphhopper.GraphHopper; //导入依赖的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.GraphHopper; //导入依赖的package包/类
public void init(GraphHopper gh)
{
if (_graphBuilders != null && _graphBuilders.size() > 0)
{
for(GraphBuilder builder : _graphBuilders)
{
try
{
builder.init(gh);
}
catch(Exception ex)
{
LOGGER.warning(ex.getMessage());
}
}
}
}
示例3: init
import com.graphhopper.GraphHopper; //导入依赖的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;
}
示例4: get
import com.graphhopper.GraphHopper; //导入依赖的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;
}
示例5: loadGraphStorage
import com.graphhopper.GraphHopper; //导入依赖的package包/类
/**
* load graph from storage: Use and ready to search the map
*/
private void loadGraphStorage() {
new AsyncTask<Void, Void, Path>() {
String error = "";
protected Path doInBackground(Void... v) {
try {
GraphHopper tmpHopp = new GraphHopper().forMobile();
tmpHopp.load(new File(mapsFolder, currentArea).getAbsolutePath());
hopper = tmpHopp;
} catch (Exception e) {
error = "error: " + e.getMessage();
}
return null;
}
protected void onPostExecute(Path o) {
if (error != "") {
logToast("An error happened while creating graph:" + error);
} else {
}
Variable.getVariable().setPrepareInProgress(false);
}
}.execute();
}
示例6: createHopper
import com.graphhopper.GraphHopper; //导入依赖的package包/类
public static GraphHopper createHopper(boolean memoryMapped, String graphFolder) {
GraphHopper ret = null;
ret = new GraphHopper().forDesktop();
// initialise the encoders ourselves as we can use multiple
// encoders for same vehicle type corresponding to different
// times of day (i.e. rush hours)
ret.setEncodingManager(createEncodingManager(graphFolder));
// don't need to write so disable the lock file (allows us to run out of program files)
ret.setAllowWrites(false);
if (memoryMapped) {
ret.setMemoryMapped();
}
ret.setGraphHopperLocation(graphFolder);
ret.importOrLoad();
return ret;
}
示例7: identifyFlagEncoder
import com.graphhopper.GraphHopper; //导入依赖的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;
}
示例8: CHMatrixGeneration
import com.graphhopper.GraphHopper; //导入依赖的package包/类
/**
*
* @param graphFolder
* @param memoryMapped
* @param hopper
* @param ownsHopper
* Whether this class owns the graphhopper graph (and wrapper object) and should dispose of it later.
* @param namedFlagEncoder
*/
private CHMatrixGeneration( GraphHopper hopper, boolean ownsHopper, String namedFlagEncoder) {
this.hopper = hopper;
this.ownsHopper = ownsHopper;
encodingManager = hopper.getEncodingManager();
flagEncoder = identifyFlagEncoder(hopper, namedFlagEncoder);
edgeFilter = new DefaultEdgeFilter(flagEncoder);
WeightingMap weightingMap = new WeightingMap("fastest");
// Weighting weighting = hopper.createWeighting(weightingMap, flagEncoder);
// prepareWeighting = new PreparationWeighting(weighting);
// get correct weighting for flag encoder
Weighting weighting = hopper.getWeightingForCH(weightingMap, flagEncoder);
prepareWeighting = new PreparationWeighting(weighting);
// save reference to the correct CH graph
chGraph = hopper.getGraphHopperStorage().getGraph(CHGraph.class,weighting);
// and create a level edge filter to ensure we (a) accept virtual (snap-to) edges and (b) don't descend into the
// base graph
levelEdgeFilter = new LevelEdgeFilter(chGraph);
}
示例9: init
import com.graphhopper.GraphHopper; //导入依赖的package包/类
public GraphExtension init(GraphHopper graphhopper) throws Exception {
if (_storage != null)
throw new Exception("GraphStorageBuilder has been already initialized.");
if (_parameters != null)
{
String value = _parameters.get("restrictions");
if (!Helper.isEmpty(value))
_includeRestrictions = Boolean.parseBoolean(value);
}
_storage = new EmergencyVehicleAttributesGraphStorage(_includeRestrictions);
return _storage;
}
示例10: init
import com.graphhopper.GraphHopper; //导入依赖的package包/类
public GraphExtension init(GraphHopper graphhopper) throws Exception {
if (_storage != null)
throw new Exception("GraphStorageBuilder has been already initialized.");
_storage = new TrailDifficultyScaleGraphStorage();
return _storage;
}
示例11: init
import com.graphhopper.GraphHopper; //导入依赖的package包/类
public GraphExtension init(GraphHopper graphhopper) throws Exception
{
if (!graphhopper.getEncodingManager().supports("wheelchair"))
return null;
if (_storage != null)
throw new Exception("GraphStorageBuilder has been already initialized.");
_storage = new WheelchairAttributesGraphStorage();
return _storage;
}
示例12: init
import com.graphhopper.GraphHopper; //导入依赖的package包/类
public GraphExtension init(GraphHopper graphhopper) throws Exception {
if (_storage != null)
throw new Exception("GraphStorageBuilder has been already initialized.");
_storage = new WayCategoryGraphStorage();
return _storage;
}
示例13: init
import com.graphhopper.GraphHopper; //导入依赖的package包/类
public GraphExtension init(GraphHopper graphhopper) throws Exception {
if (_storage != null)
throw new Exception("GraphStorageBuilder has been already initialized.");
_storage = new WaySurfaceTypeGraphStorage();
return _storage;
}
示例14: init
import com.graphhopper.GraphHopper; //导入依赖的package包/类
public GraphExtension init(GraphHopper graphhopper) throws Exception {
if (_storage != null)
throw new Exception("GraphStorageBuilder has been already initialized.");
_storage = new TollwaysGraphStorage();
return _storage;
}
示例15: init
import com.graphhopper.GraphHopper; //导入依赖的package包/类
public GraphExtension init(GraphHopper graphhopper) throws Exception {
if (_storage != null)
throw new Exception("GraphStorageBuilder has been already initialized.");
if (_parameters != null)
{
String value = _parameters.get("restrictions");
if (!Helper.isEmpty(value))
_includeRestrictions = Boolean.parseBoolean(value);
}
_storage = new HeavyVehicleAttributesGraphStorage(_includeRestrictions);
return _storage;
}