[GraphHopper] Load a custom edge weight

Peter graphhopper at gmx.de
Wed Mar 4 12:08:09 UTC 2015


Hi Rossano,

> Note that the implemented custom weight doesn't use distance nor speed
as measure.

yes, there is algo.setWeightLimit (where you can e.g. use
weighting.getMinWeight(distance)) and we'll probably add or change this
to a more controllable feature like visited nodes very soon.


> getMinWeight when, for example, astarbi is used?

This is only important for A* implementations and used as a 'distance
guess' -> see the necessary heuristic used in every A* implementation
and BeelineWeightApproximator


> java.lang.IllegalStateException: Multiple encoders are active. cannot
return one:bike,foot

In the current master and RC1 you can specify multiple vehicles even if
CH is turned on (although still only the first vehicle is prepared).
Before you had to disable CH to use multiple vehicles.

Regards,
Peter

On 02.03.2015 22:44, Rossano Schifanella wrote:
> Peter,
>
> thanks for the hint, I used the location index to find the closest
> edge and it worked. I have a couple of additional questions:
>
> - After having implemented a custom weight, I'm wandering if it's
> possible to set a threshold in the length or travel time over which a
> tentative path is discarded (e.g., using astarbi)? Note that the
> implemented custom weight doesn't use distance nor speed as measure.
> - What is the meaning of the method getMinWeight when, for example,
> astarbi is used?
> - Is it possible to specify more than a value for the property
> graph.flagEncoders (e.g., BIKE, FOOT) ? When I tried I got this
> exception: java.lang.IllegalStateException: Multiple encoders are
> active. cannot return one:bike,foot
> What am I doing wrong?
>
> Thanks a lot!
> Regards,
> Rossano
>
>
>
> On 2/28/15 9:21 PM, Peter wrote:
>> Hi Rossano,
>>
>> while import you'll have to store the mapping from osm node to internal
>> node, then you can easily do what you proposed. A more generic solution
>> would be to use GPS locations instead of OSM nodes to specify the
>> weighting and then using the location index to lookup the closest edge.
>>
>> Then you have the edgeId to weight mapping which you could either put
>> into the edge directly, or just use a double array where the edgeId is
>> the index. Or use DataAcess which is a storable array for many purposed.
>>
>> Regards,
>> Peter
>>
>>
>> On 27.02.2015 23:08, Rossano Schifanella wrote:
>>> Hi there,
>>>
>>> suppose I have an external file with this format
>>>
>>> OSM_NODE_ID1    OSM_NODE_ID2    w1
>>>
>>> where OSM_NODE_ID1 and OSM_NODE_ID2 are two OSM node ids and w1 is a
>>> double that represents a custom weight. What I'd like to do is:
>>>
>>> 1) Find the edge gh_edge_id in the GraphHopper internal data structure
>>> that corresponds to the the edge OSM_NODE_ID1->OSM_NODE_ID2
>>>
>>> 2) Create a data structure that maps the relation
>>>
>>> gh_edge_id    w1
>>>
>>> in a way that at runtime in a custom Weighting class I can retrieve
>>> the value w1 when the corresponding edge is visited.
>>>
>>> Which is the best approach to tackle this problem?
>>>
>>> Thanks a lot for your support.
>>>
>>> Rossano




More information about the GraphHopper mailing list