[GraphHopper] How to find all the roads leading around a point

Peter graphhopper at gmx.de
Mon Mar 9 10:24:01 UTC 2015


For 0.4 you'll need to follow a slightly changed query behaviour and
incooperate the QueryGraph. This is incorrectly shown in the docs
<https://github.com/graphhopper/graphhopper/blob/0.4/docs/core/low-level-api.md#calculate-path-with-locationindex>
(I'll fix)

queryGraph = new QueryGraph(hopper.getGraph());

if you use ShortestWeighting you can specify the limit as distance:
dijkstra.setWeightLimit(someDistance)

You can create a sub class for dijkstra to select all edges:
new Dijkstra(...) {
   updateBestPath(...) {
      data.add(bestEdgeEntry.edge);
  }
}

BTW:

> int edgeNo=    edgeIterator.getAdjNode();

This is a node, not an edge

Regards,
Peter

On 09.03.2015 09:08, Gp P wrote:
> Hi Peter ,
>
> >>you will need to use a graph exploration algorithm like Dijkstra
> with a shortest weighting and specify the weight limit to the distance
> you want
> How I will accomplish this for edgeiterator ?
>
>
> I think its possible to query using GHQuery but needs the exact points
> , which doest comply to my problem statement...how do I find all roads
> from a point on  the road with x meters away and exact point on each
> of edges /connecting road after x meters 
> GHRequest req = new GHRequest(latFrom, lonFrom, latTo, lonTo).
>     setWeighting("fastest").
>     setVehicle("car");
> GHResponse rsp = hopper.route(req);
>
> My Code 
>
> EdgeIteratorState edge = qr.getClosestEdge();
>         ShortestWeighting shortestWeighting=   new ShortestWeighting() ;
>         shortestWeighting.getMinWeight(distance)
>         Dijkstra dijkstra=    new
> Dijkstra(hopper.getGraph(),encodingManager.getSingle(),new
> ShortestWeighting());
>         EdgeIterator edgeIterator= edx.setBaseNode(edge.getBaseNode());
>      //   edgeIterator.
>
>         edgeIterator.setDistance(distance);
>         while (edgeIterator.next()){
>
>             int edgeNo=    edgeIterator.getAdjNode();
>         Path path= dijkstra.calcPath(edge.getBaseNode(), edgeNo)  ;
>             data.add(edgeNo)  ;
>             
>             _logger.info <http://logger.info>(" Adjacent Edge :
> "+path.getDistance());
>
>         }
> I hope its possible , I have tried many approaches they solve only one
> part of problem 
>
> Regards ,
> G
>
> On Fri, Mar 6, 2015 at 12:54 PM, Peter <graphhopper at gmx.de
> <mailto:graphhopper at gmx.de>> wrote:
>
>     On 06.03.2015 07:13, Gp P wrote:
>>     As you can see above , i trying get all edges with distance 
>
>     you will need to use a graph exploration algorithm like Dijkstra
>     with a shortest weighting and specify the weight limit to the
>     distance you want
>
>     > edgeIterator.setDistance(*distance*);
>
>     oh, that should throw an exception if called before 'next' as this
>     sets the distance for one specific edge not for the iterator
>
>     Peter
>
>
>     _______________________________________________
>     GraphHopper mailing list
>     GraphHopper at openstreetmap.org <mailto:GraphHopper at openstreetmap.org>
>     https://lists.openstreetmap.org/listinfo/graphhopper
>
>
>
>
> -- 
> B*e * the *Ch*ange
>
>
> _______________________________________________
> GraphHopper mailing list
> GraphHopper at openstreetmap.org
> https://lists.openstreetmap.org/listinfo/graphhopper

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openstreetmap.org/pipermail/graphhopper/attachments/20150309/32998ecd/attachment.html>


More information about the GraphHopper mailing list