当前位置: 首页>>代码示例>>Java>>正文


Java GraphHopper类代码示例

本文整理汇总了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();
}
 
开发者ID:agentcontest,项目名称:massim,代码行数:21,代码来源:GraphHopperManager.java

示例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());
			}
		}
	}
}
 
开发者ID:GIScience,项目名称:openrouteservice,代码行数:18,代码来源:GraphProcessContext.java

示例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;
}
 
开发者ID:GIScience,项目名称:openrouteservice,代码行数:20,代码来源:AccessRestrictionsGraphStorageBuilder.java

示例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;
}
 
开发者ID:fleetSim,项目名称:trucksimulation,代码行数:24,代码来源:GraphHopperBuilder.java

示例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();
}
 
开发者ID:junjunguo,项目名称:PocketMaps,代码行数:28,代码来源:MapHandler.java

示例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;
}
 
开发者ID:PGWelch,项目名称:com.opendoorlogistics,代码行数:23,代码来源:CHMatrixGeneration.java

示例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;
}
 
开发者ID:PGWelch,项目名称:com.opendoorlogistics,代码行数:27,代码来源:CHMatrixGeneration.java

示例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);
}
 
开发者ID:PGWelch,项目名称:com.opendoorlogistics,代码行数:32,代码来源:CHMatrixGeneration.java

示例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;
}
 
开发者ID:GIScience,项目名称:openrouteservice,代码行数:16,代码来源:EmergencyVehicleGraphStorageBuilder.java

示例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;
}
 
开发者ID:GIScience,项目名称:openrouteservice,代码行数:9,代码来源:TrailDifficultyScaleGraphStorageBuilder.java

示例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;
}
 
开发者ID:GIScience,项目名称:openrouteservice,代码行数:12,代码来源:WheelchairGraphStorageBuilder.java

示例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;
}
 
开发者ID:GIScience,项目名称:openrouteservice,代码行数:9,代码来源:WayCategoryGraphStorageBuilder.java

示例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;
}
 
开发者ID:GIScience,项目名称:openrouteservice,代码行数:8,代码来源:WaySurfaceTypeGraphStorageBuilder.java

示例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;
}
 
开发者ID:GIScience,项目名称:openrouteservice,代码行数:9,代码来源:TollwaysGraphStorageBuilder.java

示例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;
}
 
开发者ID:GIScience,项目名称:openrouteservice,代码行数:16,代码来源:HeavyVehicleGraphStorageBuilder.java


注:本文中的com.graphhopper.GraphHopper类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。