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


Java EdgeExplorer类代码示例

本文整理汇总了Java中com.graphhopper.util.EdgeExplorer的典型用法代码示例。如果您正苦于以下问题:Java EdgeExplorer类的具体用法?Java EdgeExplorer怎么用?Java EdgeExplorer使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: print

import com.graphhopper.util.EdgeExplorer; //导入依赖的package包/类
public void print()
{
	int edgesCount = 0;

	EdgeExplorer explorer = createExplorer();

	for (IntObjectCursor<?> node : _node2edgesMap) {
		EdgeIterator iter = explorer.setBaseNode(node.key);

		if (iter != null)
		{
			while (iter.next())
			{
				edgesCount++;
			}
		}
	}

	logger.info("SubGraph: nodes - " + _node2edgesMap.size() + "; edges - " + edgesCount);
}
 
开发者ID:GIScience,项目名称:openrouteservice,代码行数:21,代码来源:SubGraph.java

示例2: printOverview

import com.graphhopper.util.EdgeExplorer; //导入依赖的package包/类
private void printOverview(GraphHopperStorage graph, LocationIndex locationIndex,
                           final double lat, final double lon, final double length) {
    final NodeAccess na = graph.getNodeAccess();
    int node = locationIndex.findClosest(lat, lon, EdgeFilter.ALL_EDGES).getClosestNode();
    final EdgeExplorer explorer = graph.createEdgeExplorer();
    new BreadthFirstSearch() {

        double currDist = 0;

        @Override
        protected boolean goFurther(int nodeId) {
            double currLat = na.getLat(nodeId);
            double currLon = na.getLon(nodeId);
            currDist = Helper.DIST_PLANE.calcDist(currLat, currLon, lat, lon);
            return currDist < length;
        }

        @Override
        protected boolean checkAdjacent(EdgeIteratorState edge) {
            System.out.println(edge.getBaseNode() + "->" + edge.getAdjNode() + " ("
                    + Math.round(edge.getDistance()) + "): " + edge.getName() + "\t\t , distTo:"
                    + currDist);
            return true;
        }
    }.start(explorer, node);
}
 
开发者ID:graphhopper,项目名称:map-matching,代码行数:27,代码来源:MapMatchingTest.java

示例3: searchAllForward

import com.graphhopper.util.EdgeExplorer; //导入依赖的package包/类
private void searchAllForward(QueryResult[] snapToResults, final QueryGraph queryGraph, final ShortestPathTree[] forwardTrees,
		final TIntObjectHashMap<List<FromIndexEdge>> visitedByNodeId, CHProcessingApi continueCB) {

	if (outputText) {
		System.out.println("Running forward searches");
	}

	EdgeExplorer outEdgeExplorer = createForwardsEdgeExplorer(queryGraph);
	for (int fromIndex = 0; fromIndex < snapToResults.length; fromIndex++) {

		// check for user quitting
		if (continueCB != null && continueCB.isCancelled()) {
			return;
		}

		final int finalFromIndx = fromIndex;
		if (snapToResults[fromIndex].isValid()) {
			forwardTrees[fromIndex] = search(snapToResults[fromIndex].getClosestNode(), outEdgeExplorer, false);
			forwardTrees[fromIndex].forEachEntry(new TIntObjectProcedure<EdgeEntry>() {

				@Override
				public boolean execute(int nodeId, EdgeEntry edge) {
					List<FromIndexEdge> visited = visitedByNodeId.get(nodeId);
					if (visited == null) {
						visited = new ArrayList<>(1);
						visitedByNodeId.put(nodeId, visited);
					}
					visited.add(new FromIndexEdge(finalFromIndx, edge));
					return true;
				}
			});
		}
	}
}
 
开发者ID:PGWelch,项目名称:com.opendoorlogistics,代码行数:35,代码来源:CHMatrixGeneration.java

示例4: fillEdgesUpward

import com.graphhopper.util.EdgeExplorer; //导入依赖的package包/类
private void fillEdgesUpward(MultiTreeSPEntry currEdge, PriorityQueue<MultiTreeSPEntry> prioQueue,
		IntObjectMap<MultiTreeSPEntry> shortestWeightMap, EdgeExplorer explorer) {
	EdgeIterator iter = explorer.setBaseNode(currEdge.adjNode);

	if (iter == null) // we reach one of the target nodes
		return;

	_upwardEdgeFilter.setBaseNode(currEdge.adjNode);

	while (iter.next()) {
		if (!_upwardEdgeFilter.accept(iter))
			continue;
		
		_upwardEdgeFilter.updateHighestNode(iter);
		
		_edgeWeight = _weighting.calcWeight(iter, false, 0);

		if (!Double.isInfinite(_edgeWeight)) {
			MultiTreeSPEntry ee = shortestWeightMap.get(iter.getAdjNode());

			if (ee == null) {
				ee = new MultiTreeSPEntry(iter.getAdjNode(), iter.getEdge(), _edgeWeight, true, currEdge, currEdge.getSize());

				shortestWeightMap.put(iter.getAdjNode(), ee);
				prioQueue.add(ee);
			} else {
				_addToQueue = false;
				
				for (int i = 0; i < _treeEntrySize; ++i) {
					_msptItem = currEdge.getItem(i);
					_entryWeight = _msptItem.weight;
					
					if (_entryWeight == 0.0)
						continue;

					_msptSubItem = ee.getItem(i);

					if (_msptItem.update == false) {
	//					upwardItersSkipped++;
						continue;
					}
					
					_tmpWeight = _edgeWeight + _entryWeight;

					if (_msptSubItem.weight > _tmpWeight || _msptSubItem.weight == 0.0) {
						_msptSubItem.weight = _tmpWeight;
						_msptSubItem.edge = iter.getEdge();
						_msptSubItem.parent = currEdge;
						_msptSubItem.update = true;
						
						_addToQueue = true;
	//					upwardIters++;

					} //else
	//					upwardItersTotal++;
				}

				if (_addToQueue) {
					ee.updateWeights();
					prioQueue.remove(ee);
					prioQueue.add(ee);
				}
			}
		}
	}
	
	currEdge.resetUpdate(false);
}
 
开发者ID:GIScience,项目名称:openrouteservice,代码行数:69,代码来源:RPHASTAlgorithm.java

示例5: fillEdgesDownward

import com.graphhopper.util.EdgeExplorer; //导入依赖的package包/类
private void fillEdgesDownward(MultiTreeSPEntry currEdge, PriorityQueue<MultiTreeSPEntry> prioQueue,
		IntObjectMap<MultiTreeSPEntry> shortestWeightMap, EdgeExplorer explorer) {

	EdgeIterator iter = explorer.setBaseNode(currEdge.adjNode);

	if (iter == null)
		return;

	while (iter.next()) {
		_edgeWeight = _weighting.calcWeight(iter, false, 0);

		if (!Double.isInfinite(_edgeWeight)) {
			MultiTreeSPEntry ee = shortestWeightMap.get(iter.getAdjNode());

			if (ee == null) {
				ee = new MultiTreeSPEntry(iter.getAdjNode(), iter.getEdge(), _edgeWeight, true, currEdge, currEdge.getSize());
				ee.visited = true;

				shortestWeightMap.put(iter.getAdjNode(), ee);
				prioQueue.add(ee);
			} else {
				_addToQueue = false;
				
				for (int i = 0; i < _treeEntrySize; ++i) {
					_msptItem = currEdge.getItem(i);
					_entryWeight = _msptItem.weight;
					
					if (_entryWeight == 0.0)
						continue;

					if (_msptItem.update == false) {
	//					downwardItersSkipped++;
						continue;
					}

					_tmpWeight = _edgeWeight + _entryWeight;

					MultiTreeSPEntryItem eeItem = ee.getItem(i);

					if (eeItem.weight > _tmpWeight || eeItem.weight == 0.0) {
						eeItem.weight = _tmpWeight;
						eeItem.edge = iter.getEdge();
						eeItem.parent = currEdge;
						eeItem.update = true;
						
						_addToQueue = true;
	//					downwardIters++;
					} //else
					//	downwardItersTotal++;
				}
				
				ee.updateWeights();
				
				if (ee.visited == false) {
					// // This is the case if the node has been assigned a
					// weight in
					// // the upwards pass (fillEdges). We need to use it in
					// the
					// // downwards pass to access lower level nodes, though
					// the
					// weight
					// // does not have to be reset necessarily //
					ee.visited = true;
					ee.resetUpdate(true);
					prioQueue.add(ee);
				} else if (_addToQueue) {
					ee.visited = true;
					prioQueue.remove(ee);
					prioQueue.add(ee);
				}
			}
		}
	}
	
	currEdge.resetUpdate(false);
}
 
开发者ID:GIScience,项目名称:openrouteservice,代码行数:77,代码来源:RPHASTAlgorithm.java

示例6: createExplorer

import com.graphhopper.util.EdgeExplorer; //导入依赖的package包/类
public EdgeExplorer createExplorer()
{
	return new SubGraphEdgeExplorer(this);
}
 
开发者ID:GIScience,项目名称:openrouteservice,代码行数:5,代码来源:SubGraph.java

示例7: runAlgo

import com.graphhopper.util.EdgeExplorer; //导入依赖的package包/类
protected void runAlgo() {
    EdgeExplorer explorer = outEdgeExplorer;
    while (true) {
        _visitedNodes++;
        if (isMaxVisitedNodesExceeded() || finished())
            break;

        int startNode = _currEdge.adjNode;
        EdgeIterator iter = explorer.setBaseNode(startNode);
        while (iter.next()) {
            if (!accept(iter, _currEdge.edge))
                continue;

            int traversalId = traversalMode.createTraversalId(iter, false);
            double tmpWeight = weighting.calcWeight(iter, false, _currEdge.edge) + _currEdge.weight;
            if (Double.isInfinite(tmpWeight))
                continue;

            SPTEntry nEdge = _fromMap.get(traversalId);
            if (nEdge == null) {
                nEdge = new SPTEntry(iter.getEdge(), iter.getAdjNode(), tmpWeight);
                nEdge.parent = _currEdge;
                _fromMap.put(traversalId, nEdge);
                _fromHeap.add(nEdge);
            } else if (nEdge.weight > tmpWeight) {
                _fromHeap.remove(nEdge);
                nEdge.edge = iter.getEdge();
                nEdge.weight = tmpWeight;
                nEdge.parent = _currEdge;
                _fromHeap.add(nEdge);
            } else
                continue;
        }

        if (_fromHeap.isEmpty())
            break;

        _currEdge = _fromHeap.poll();
        if (_currEdge == null)
            throw new AssertionError("Empty edge cannot happen");
    }
}
 
开发者ID:GIScience,项目名称:openrouteservice,代码行数:43,代码来源:DijkstraOneToManyAlgorithm.java

示例8: createBackwardsEdgeExplorer

import com.graphhopper.util.EdgeExplorer; //导入依赖的package包/类
public EdgeExplorer createBackwardsEdgeExplorer(Graph graph) {
	return graph.createEdgeExplorer(new DefaultEdgeFilter(flagEncoder, true, false));
}
 
开发者ID:PGWelch,项目名称:com.opendoorlogistics,代码行数:4,代码来源:CHMatrixGeneration.java

示例9: createForwardsEdgeExplorer

import com.graphhopper.util.EdgeExplorer; //导入依赖的package包/类
public EdgeExplorer createForwardsEdgeExplorer(Graph graph) {
	return graph.createEdgeExplorer(new DefaultEdgeFilter(flagEncoder, false, true));
}
 
开发者ID:PGWelch,项目名称:com.opendoorlogistics,代码行数:4,代码来源:CHMatrixGeneration.java

示例10: search

import com.graphhopper.util.EdgeExplorer; //导入依赖的package包/类
public ShortestPathTree search(int startNode, EdgeExplorer edgeExplorer, boolean isBackwards) {
	return search(startNode, edgeExplorer, levelEdgeFilter, isBackwards);
}
 
开发者ID:PGWelch,项目名称:com.opendoorlogistics,代码行数:4,代码来源:CHMatrixGeneration.java


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