[GraphHopper] Small patch for distance calculations in CH and translation to spanish

Francisco José Peñarrubia fjp at scolab.es
Fri Jul 19 10:05:36 UTC 2013


Hi Peter.

Sorry, I should explain it a bit more.

When I use this code:

GHResponse ph = calculateRoute(flag1, flag2, gh);
        System.out.println("Dist = " + ph.getDistance() + " Time: " +
(t2-t3));

ph.getDistance returns much more than the real distance. I create the graph
with real distances in meters:

EdgeIterator edgeIt = graph.edge(idNodo1, idNodo2, dist.doubleValue(),
true);
edgeIt.setName(name);

With this change, it seems the distance is ok.

Maybe I am doing something wrong, or not in the last revision of the
library.

Best regards.

Fran.



2013/7/19 Peter K <peathal at yahoo.de>

>  Hi Francisco,
>
> what problems do you have?
>
> Regards,
> Peter.
>
>  Hi Peter and all.
>
>  I have a little patch to solve some problems I have with distance
> calculations when using CH. I don't know if it happens only to me, but...
> just in case.
>
>  The change is simple, in Path4CH file:
> double dist = mainIter.getDistance(); // in repository =>
> calcDistance(mainIter);
>
>  when mainIter is NOT a shortcut, getDistance directly.
>
>  Hope it helps, and thank you very much for this excellent library!!.
>
>  Fran.
>
>
>  diff --git a/core/src/main/java/com/graphhopper/routing/ch/Path4CH.java
> b/core/src/main/java/com/graphhopper/routing/ch/Path4CH.java
> index fb4f440..50199f4 100644
> --- a/core/src/main/java/com/graphhopper/routing/ch/Path4CH.java
> +++ b/core/src/main/java/com/graphhopper/routing/ch/Path4CH.java
> @@ -60,7 +60,7 @@
>       {
>          if (!mainIter.isShortcut())
>          {
> -            double dist = calcDistance(mainIter);
> +            double dist = mainIter.getDistance();
> //calcDistance(mainIter);
>              distance += dist;
>              int flags = mainIter.getFlags();
>              time += calcTime(dist, flags);
> diff --git a/core/src/main/java/com/graphhopper/util/TranslationMap.java
> b/core/src/main/java/com/graphhopper/util/TranslationMap.java
> index f3c9dde..3ff3c12 100644
> --- a/core/src/main/java/com/graphhopper/util/TranslationMap.java
> +++ b/core/src/main/java/com/graphhopper/util/TranslationMap.java
> @@ -42,6 +42,19 @@
>          de.put("turn %s", "%s abbiegen");
>          de.put("turn %s onto %s", "%s abbiegen auf %s");
>
> +        TranslationHashMap es = new TranslationHashMap();
> +        translations.put("es", es);
> +        es.put("sharp left", "izquierda");
> +        es.put("sharp right", "derecha");
> +        es.put("left", "izquierda");
> +        es.put("right", "derecha");
> +        es.put("slight left", "un poco a la izquierda");
> +        es.put("slight right", "un poco a la derecha");
> +        es.put("continue", "continue");
> +        es.put("continue onto %s", "siga por %s");
> +        es.put("turn %s", "gire por %s");
> +        es.put("turn %s onto %s", "gire %s por %s");
> +
>          TranslationHashMap en = new TranslationHashMap()
>          {
>              @Override
>
>  --
> Francisco José Peñarrubia
>
> Software Colaborativo
> http://www.scolab.es
>
>
> _______________________________________________
> GraphHopper mailing listGraphHopper at openstreetmap.orghttp://lists.openstreetmap.org/listinfo/graphhopper
>
>
>
> _______________________________________________
> GraphHopper mailing list
> GraphHopper at openstreetmap.org
> http://lists.openstreetmap.org/listinfo/graphhopper
>
>


-- 
Francisco José Peñarrubia

Software Colaborativo
http://www.scolab.es
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openstreetmap.org/pipermail/graphhopper/attachments/20130719/9e7e5b6c/attachment.html>


More information about the GraphHopper mailing list