[GraphHopper] compyte Distance
Peter
graphhopper at gmx.de
Wed Jul 15 13:36:19 UTC 2015
Hi Fred,
see the Helper class with multiple possibilities, depending on how
precise or fast you want to have it:
DistanceCalcEarth (haversine base, most precise)
DistanceCalc3D (like DistanceCalcEarth but with elevation)
DistancePlaneProjection (less precise than DistanceCalcEarth but faster,
precise enough for small distances)
DistanceCalc2D (pythagoras based, not precise but probably fastest)
And then use the calcDist method
Regards,
Peter
On 15.07.2015 14:37, Lau wrote:
>
> *private**static*Double distance(Location one, Location two) {
>
> *int*R = 6371000;
>
> Double dLat = /toRad/(two.getLatitude() - one.getLatitude());
>
> Double dLon = /toRad/(two.getLongitude() -
> one.getLongitude());
>
> Double lat1 = /toRad/(one.getLatitude());
>
> Double lat2 = /toRad/(two.getLatitude());
>
> Double a = Math./sin/(dLat / 2) * Math./sin/(dLat / 2) +
> Math./sin/(dLon / 2)
>
> * Math./sin/(dLon / 2) * Math./cos/(lat1) *
> Math./cos/(lat2);
>
> Double c = 2 * Math./atan2/(Math./sqrt/(a), Math./sqrt/(1
> - a));
>
> Double d = R * c;
>
> *return*d;
>
> }
>
>
>
> *De:*Fred Laurent [mailto:fredlaurent31 at gmail.com]
> *Enviado el:* Wednesday, 15 July, 2015 7:15 AM
> *Para:* GraphHopper Java routing engine
> *Asunto:* [GraphHopper] compyte Distance
>
>
>
> Hello , is it possible in GH to compute the distance from my current
> Location (Curreent_lat,Current_lon)to a position B(B_lat,B_lon) using
> CalcDist for example ?
>
> thank you
>
>
>
> _______________________________________________
> 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/20150715/16180689/attachment.html>
More information about the GraphHopper
mailing list