[GraphHopper] Geoposition of an edge

Philipp Kraus philipp.kraus at tu-clausthal.de
Wed Apr 30 13:45:48 UTC 2014


Hi, 

I have create a short testing code:

        EdgeIteratorState l_state = CGraphHopper.getInstance().getEdgeIterator(l_position.intValue());
        PointList l_points = l_state.fetchWayGeometry(0);

        //double l_latitude  = l_points.getLatitude(0)  + l_position.intValue() * ( l_points.getLatitude(l_points.size()-1)  - l_points.getLatitude(0) );
        //double l_longitute = l_points.getLongitude(0) + l_position.intValue() * ( l_points.getLongitude(l_points.size()-1) - l_points.getLongitude(0) );

        return new GeoPosition(l_points.getLatitude(0), l_points.getLongitude(0));

and the first point in the point list is around 200-300 km from the edge which is stored in my route edge list. The first item in my route edges is:
[51.80351990955801, 10.348262786865234]
but the first item on fetchGeometry returns
[52.48197732452998, 7.9807603652945245]]

Dou you have an idea?

Phil



Am 29.04.2014 um 15:55 schrieb Peter K <peathal at yahoo.de>:

> Hey Phil,
> 
> 
>> I think it is „fetchWayGeometry“ ? The fetch option should result a point list and in which way can you get a tip to get the correct point position. I know the edge has got e.g. 20 cells and I need the geoposition of the 5th cell. I don’t understand the matching between the point list and cell number.
> 
> You'll have to implement your own custom logic :)
> 
> E.g. just pick the first and the last point of that pointlist and
> calculate latDistance and lonDistance. Then iterate in a loop
> 
> for(cell : cellsForThatEdge) {
>  cell.set(lat, lon)
>  lat+=latDistance
>  lon+=lonDisatnce
> }
> 
>> How can I get an EdgeIterator from an EdgeID, does exists anything like this.graph.getEdgeIterator(<EdgeID>)?
> 
> via graph.getEdgeProps(edgeId, Integer.MIN_VALUE)




More information about the GraphHopper mailing list