问题描述
我们正在考虑在需要进行路线规划的项目中使用它.我们遇到的第一个问题是,我们有非常动态的变量来表示我们的体重值.这意味着我们不能使用收缩层次算法,因为每次这些变量之一更改时,我们都应该重新创建收缩"图,因此我们在考虑配置graphhopper以便不使用CH算法
We are thinking to use it in our project where we need to do a route planner.The first problem we had is that we have very dyanimc variables representing our weight values; this means that we can't use the Contraction Hierarchy algorithm becouse every time one of these variables changes we should re-create the "contracted" graph, so we were thinking to configure graphhopper in order to not use the CH algorithm
在这种情况下,是否可以修改Graphhopper代码以支持此动态边缘权重值?例如,假设我们有节点A和节点B以及边A–B;假设该边的值为3在我们的场景中,可能会有一个事件可以将边A–B的值从3更改为6或从3更改为2我们可以修改代码以支持此功能吗?这取决于DataAccess的实现吗?
In this scenario is it possible to modify graphhopper code to support this dynamic edges weight values?For example let's suppose that we have node A and node B and an edge A--B; let's suppose that this edge has a value 3In our scenario there can be an event that can modify the value of the edge A--B from 3 to 6 or from 3 to 2Can we modify the code in order to support this feature? Is this dependant to the DataAccess implementation?
推荐答案
要修改边缘的速度或距离,您需要获取EdgeIteratorState(例如,从坐标中获取),然后设置标记或距离.这是一个代码段:
To modify the speed or distance of an edge you need to get an EdgeIteratorState (e.g. from a coordinate) and then set the flags or distance. Here is a code snippet:
// find edge for lat,lon point
QueryResult qr = locationIndex.findClosest(lat, lon, EdgeFilter.ALL_EDGES);
if(!qr.isValid())
throw RuntimeException("Cannot find nearby location " + lat+","+lon);
EdgeIteratorState edge = qr.getClosestEdge();
// use existing flags to reuse access information
long existingFlags = edge.getFlags();
// set speed
edge.setFlags(carFlagEncoder.setSpeed(existingFlags, newSpeed));
// set distance
edge.setDistance(newDistance);
这篇关于GraphHopper是否支持动态边缘权重?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!