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


Java GraphHopper.getEncodingManager方法代码示例

本文整理汇总了Java中com.graphhopper.GraphHopper.getEncodingManager方法的典型用法代码示例。如果您正苦于以下问题:Java GraphHopper.getEncodingManager方法的具体用法?Java GraphHopper.getEncodingManager怎么用?Java GraphHopper.getEncodingManager使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.graphhopper.GraphHopper的用法示例。


在下文中一共展示了GraphHopper.getEncodingManager方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: 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

示例2: 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

示例3: 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

示例4: createStorage

import com.graphhopper.GraphHopper; //导入方法依赖的package包/类
@Override
public GraphHopperStorage createStorage(GHDirectory dir, GraphHopper gh) {
	EncodingManager encodingManager = gh.getEncodingManager();
	GraphExtension geTurnCosts = null;
	ArrayList<GraphExtension> graphExtensions = new ArrayList<GraphExtension>();
	
	if (encodingManager.needsTurnCostsSupport())
	{
		Path path = Paths.get(dir.getLocation(), "turn_costs");
		File fileEdges  = Paths.get(dir.getLocation(), "edges").toFile();
		File fileTurnCosts = path.toFile();
		
		// First we need to check if turncosts are available. This check is required when we introduce a new feature, but an existing graph does not have it yet.
		if ((!hasGraph(gh) && !fileEdges.exists()) || (fileEdges.exists() && fileTurnCosts.exists()))
			geTurnCosts =  new TurnCostExtension();
	}

	if (_graphStorageBuilders != null && _graphStorageBuilders.size() > 0)
	{
		for(GraphStorageBuilder builder : _graphStorageBuilders)
		{
			try
			{
				GraphExtension ext = builder.init(gh);
				if (ext != null)
					graphExtensions.add(ext);
			}
			catch(Exception ex)
			{
				LOGGER.error(ex);
			}
		}
	}

	GraphExtension graphExtension = null;
	
	if (geTurnCosts == null && graphExtensions.size() == 0)
		graphExtension =  new GraphExtension.NoOpExtension();
	else if (geTurnCosts != null && graphExtensions.size() > 0)
	{
		ArrayList<GraphExtension> seq = new ArrayList<GraphExtension>();
		seq.add(geTurnCosts);
		seq.addAll(graphExtensions);
		
		graphExtension = getExtension(seq);
	} 
	else if (geTurnCosts != null)
	{
		graphExtension = geTurnCosts;
	}
	else if (graphExtensions.size() > 0)
	{
		graphExtension = getExtension(graphExtensions);
	}
	
    if (gh.getLMFactoryDecorator().isEnabled())
         	gh.initLMAlgoFactoryDecorator();

    if (gh.getCHFactoryDecorator().isEnabled()) 
           gh.initCHAlgoFactoryDecorator();
     
	if (gh.isCHEnabled())
           return new GraphHopperStorage(gh.getCHFactoryDecorator().getWeightings(), dir, encodingManager, gh.hasElevation(), graphExtension);
	else
		return new GraphHopperStorage(dir, encodingManager, gh.hasElevation(), graphExtension);
}
 
开发者ID:GIScience,项目名称:openrouteservice,代码行数:67,代码来源:ORSGraphStorageFactory.java

示例5: MapMatching

import com.graphhopper.GraphHopper; //导入方法依赖的package包/类
public MapMatching(GraphHopper hopper, AlgorithmOptions algoOptions) {
    // Convert heading penalty [s] into U-turn penalty [m]
    final double PENALTY_CONVERSION_VELOCITY = 5;  // [m/s]
    final double headingTimePenalty = algoOptions.getHints().getDouble(
            Parameters.Routing.HEADING_PENALTY, Parameters.Routing.DEFAULT_HEADING_PENALTY);
    uTurnDistancePenalty = headingTimePenalty * PENALTY_CONVERSION_VELOCITY;

    this.locationIndex = new LocationIndexMatch(hopper.getGraphHopperStorage(),
            (LocationIndexTree) hopper.getLocationIndex());

    // create hints from algoOptions, so we can create the algorithm factory        
    HintsMap hints = new HintsMap();
    for (Entry<String, String> entry : algoOptions.getHints().toMap().entrySet()) {
        hints.put(entry.getKey(), entry.getValue());
    }

    // default is non-CH
    if (!hints.has(Parameters.CH.DISABLE)) {
        hints.put(Parameters.CH.DISABLE, true);

        if (!hopper.getCHFactoryDecorator().isDisablingAllowed())
            throw new IllegalArgumentException("Cannot disable CH. Not allowed on server side");
    }

    // TODO ugly workaround, duplicate data: hints can have 'vehicle' but algoOptions.weighting too!?
    // Similar problem in GraphHopper class
    String vehicle = hints.getVehicle();
    if (vehicle.isEmpty()) {
        if (algoOptions.hasWeighting()) {
            vehicle = algoOptions.getWeighting().getFlagEncoder().toString();
        } else {
            vehicle = hopper.getEncodingManager().fetchEdgeEncoders().get(0).toString();
        }
        hints.setVehicle(vehicle);
    }

    if (!hopper.getEncodingManager().supports(vehicle)) {
        throw new IllegalArgumentException("Vehicle " + vehicle + " unsupported. "
                + "Supported are: " + hopper.getEncodingManager());
    }

    algoFactory = hopper.getAlgorithmFactory(hints);

    Weighting weighting;
    CHAlgoFactoryDecorator chFactoryDecorator = hopper.getCHFactoryDecorator();
    boolean forceFlexibleMode = hints.getBool(Parameters.CH.DISABLE, false);
    if (chFactoryDecorator.isEnabled() && !forceFlexibleMode) {
        if (!(algoFactory instanceof PrepareContractionHierarchies)) {
            throw new IllegalStateException("Although CH was enabled a non-CH algorithm "
                    + "factory was returned " + algoFactory);
        }

        weighting = ((PrepareContractionHierarchies) algoFactory).getWeighting();
        this.routingGraph = hopper.getGraphHopperStorage().getGraph(CHGraph.class, weighting);
    } else {
        weighting = algoOptions.hasWeighting()
                ? algoOptions.getWeighting()
                : new FastestWeighting(hopper.getEncodingManager().getEncoder(vehicle),
                algoOptions.getHints());
        this.routingGraph = hopper.getGraphHopperStorage();
    }

    this.graph = hopper.getGraphHopperStorage();
    this.algoOptions = AlgorithmOptions.start(algoOptions).weighting(weighting).build();
    this.nodeCount = routingGraph.getNodes();
}
 
开发者ID:graphhopper,项目名称:map-matching,代码行数:67,代码来源:MapMatching.java


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