<div dir="ltr">Hi Peter,<div>Thank you very much. I will try this.</div><div>At the moment I am trying to have a running example with dirty implementation (for one vehicle added by hand to the query graph). Just want to have a better feeling of how things migh be. </div><div><br></div><div>Regards,</div><div>Wesam</div></div><div class="gmail_extra"><br><div class="gmail_quote">On 29 July 2015 at 08:09, Peter <span dir="ltr"><<a href="mailto:graphhopper@gmx.de" target="_blank">graphhopper@gmx.de</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
  
    
  
  <div bgcolor="#FFFFFF" text="#000000">
    <div>Hi Wesam,<br>
      <br>
      To inject car points additional to the user query you'll need a
      custom getPaths method in GraphHopper (via subclassing). E.g. see
      here how custom weighting is done, similarly I would propose to
      try with customer QueryGraph:<br>
<a href="https://github.com/graphhopper/graphhopper/blob/master/docs/core/weighting.md" target="_blank">https://github.com/graphhopper/graphhopper/blob/master/docs/core/weighting.md</a><br>
      <br>
      If something is missing for this to work in the GraphHopper class
      please let us know.<span class=""><br>
      <br>
      <br style="font-size:14px">
      <span style="font-size:14px">> Problems with this approach: </span><br style="font-size:14px">
      <span style="font-size:14px">> 1) everything is done at query
        time (number of vehicles GHPoints is usually large) </span><br>
      <br></span>
      in which range is it? 1K, 10K 100K?<br>
      Still I would try with the QueryGraph first and only if speed is
      degraded try a more complex solution.<span class=""><br>
      <br>
      <br style="font-size:14px">
      <span style="font-size:14px">> 2) Cannot differentiate between
        vehicles’ nodes and the nodes representing the user given
        GHPoints in the QueryGraph. </span><br>
      <br></span>
      Either handle that in your custom GraphHopper class or see my
      proposed methods in QueryGraph for the mapping.<span class=""><br>
      <br>
      <br style="font-size:14px">
      <span style="font-size:14px">> 3) The vehicles QueryResults
        will be considered as intermediate nodes for the routing
        algorithm. </span><br style="font-size:14px">
      <br></span>
      Yes, you need a custom setup but query only the points you need
      not with all:<br>
      qGraph = new QueryGraph(graph);<br>
      qGraph.lookup(allCarAndUserPoints);<br>
      <br>
      loop over user points only {<br>
         path = createAlgo(qGraph, ..).createPath(userPoint1,userPoint2)<br>
      }<br>
      <br>
      Kind Regards,<br>
      Peter<span class=""><br>
      <br>
      On 28.07.2015 09:53, wesam Herbawi wrote:<br>
    </span></div>
    <blockquote type="cite">
      <div dir="ltr">
        <p class="MsoNormal"><span class=""><span style="font-size:14px">The short
            answer is that you need to avoid the higher level API
            getPaths: </span><br style="font-size:14px">
          <a href="https://github.com/graphhopper/graphhopper/blob/master/docs/core/low-level-api.md" style="font-size:14px" target="_blank">https://github.com/graphhopper/graphhopper/blob/master/docs/core/low-level-api.md</a><span style="font-size:14px"> </span><br style="font-size:14px">
          <br style="font-size:14px">
          <span style="font-size:14px">and instead create your storage
            and algorithms on your own. </span><br style="font-size:14px">
          <br style="font-size:14px">
          <span style="font-size:14px">OR subclass the GraphHopper class
            to know which are car points and which ones are user defined
            query points. </span><br style="font-size:14px">
          <br style="font-size:14px">
          <span style="font-size:14px">Also to better identify locations
            in QueryGraph we could introduce a mapping to find out the
            virtual nodes e.g. via </span><br style="font-size:14px">
          <span style="font-size:14px">int /*virtualNode*/
            QueryGraph.getNodeId(int lookupIndex) </span><br style="font-size:14px">
          <span style="font-size:14px">int /*lookupIndex*/
            QueryGraph.getLookupIndex(int virtualNode) </span><br style="font-size:14px">
          <br style="font-size:14px">
          </span><span class=""><span style="font-size:14px">Kind Regards, </span><br style="font-size:14px">
          <span style="font-size:14px">Peter </span><br style="font-size:14px">
          <br style="font-size:14px">
          <span style="font-size:14px">Am 27.7.15 12:54 schrieb Wesam
            Herbawi: </span><br style="font-size:14px">
          <span style="font-size:14px">-------------------- </span><br style="font-size:14px">
          <span style="font-size:14px">Hi peter </span><br style="font-size:14px">
          <span style="font-size:14px">Very sorry for this prolonged
            email. It is just the brainstorming phase where I am trying
            to figure out how can the easiest way for the implementation
            look like. </span><br style="font-size:14px">
          <br style="font-size:14px">
          <span style="font-size:14px">Here is a summary of my
            understanding of the existing code and the way that I might
            follow for the implementation of my use case. I have also
            highlited some problems that one might face. Your opinion is
            highly appreciated. </span><br style="font-size:14px">
          <br style="font-size:14px">
          <span style="font-size:14px">in method protected
            List<Path> getPaths( GHRequest request, GHResponse rsp
            ) </span><br style="font-size:14px">
          <span style="font-size:14px">The request contains, among other
            things, a list of GHPoints representing the sources and
            destinations coordinates as given by the end user. For each
            of these GHPoints, a QueryResult object is obtained
            representing the snapping of the given GHPoints to the base
            graph nodes (base graph is the original street graph). This
            results in a list of QueryResult objects. Using the base
            graph and the list of QueryResult objects, a QueryGraph is
            created by adding virtual nodes and edges to the base graph.
            The routing algorithm is then fed with the QueryGraph to
            find the shortest path for each two consecutive points in
            the list of QueryResult objects (when the number of
            QueryResult objects>2 then this probably represents way
            nodes). </span><br style="font-size:14px">
          <br style="font-size:14px">
          <span style="font-size:14px">The implementation that came to
            my mind is just to handle the carsharing vehicles as list of
            GHPoints (exactly as the coordinates given by the end user
            when asking for a shortest path). Then use these carsharing
            vehicles GHPoints + the user given GHPoints for source and
            destination to create the QueryGraph </span><br style="font-size:14px">
          <span style="font-size:14px">QueryGraph queryGraph = new
            QueryGraph(routingGraph); </span><br style="font-size:14px">
          <span style="font-size:14px">queryGraph.lookup(qResults); </span><br style="font-size:14px">
          <br style="font-size:14px">
          <span style="font-size:14px">where qResults contains both the
            vehicles QueryResults + the user given GHPoints
            QueryResults. </span><br style="font-size:14px">
          <br style="font-size:14px">
          <span style="font-size:14px">Problems with this approach: </span><br style="font-size:14px">
          <span style="font-size:14px">1) everything is done at query
            time (number of vehicles GHPoints is usually large) </span><br style="font-size:14px">
          <span style="font-size:14px">2) Cannot differentiate between
            vehicles’ nodes and the nodes representing the user given
            GHPoints in the QueryGraph. </span><br style="font-size:14px">
          <span style="font-size:14px">3) The vehicles QueryResults will
            be considered as intermediate nodes for the routing
            algorithm. </span><br style="font-size:14px">
          <br style="font-size:14px">
          <span style="font-size:14px">To avoid problem number 3, I can
            maintain two QueryResult lists one for the vehicles
            QueryResults and one for those representing the user given
            GHPoints. However this requires playing in class
            GraphHopper.java which is a central one. Still I cannot tell
            which node in the QueryGraph is a vehicle node and which one
            is a node representing the user given coordinates. </span><br style="font-size:14px">
          <br style="font-size:14px">
          <span style="font-size:14px">Any hints, suggestions? </span><br>
        </span></p>
      </div>
      <br>
      <fieldset></fieldset>
      <br><span class="">
      <pre>_______________________________________________
GraphHopper mailing list
<a href="mailto:GraphHopper@openstreetmap.org" target="_blank">GraphHopper@openstreetmap.org</a>
<a href="https://lists.openstreetmap.org/listinfo/graphhopper" target="_blank">https://lists.openstreetmap.org/listinfo/graphhopper</a>
</pre>
    </span></blockquote>
    <br>
  </div>

<br>_______________________________________________<br>
GraphHopper mailing list<br>
<a href="mailto:GraphHopper@openstreetmap.org">GraphHopper@openstreetmap.org</a><br>
<a href="https://lists.openstreetmap.org/listinfo/graphhopper" rel="noreferrer" target="_blank">https://lists.openstreetmap.org/listinfo/graphhopper</a><br>
<br></blockquote></div><br></div>