android - Why SphericalUtil.computeDistanceBetween method does not return accurate result? -
hi working on computing distance nearest point of route. testing 2 routes (polylines). nearest point of routes relative origin point in same coordinate or spot sphericalutil.computedistancebetween method of google maps android library returns different results.
example according code:
for(route route : routes){ boolean islocationonedge = polyutil.islocationonedge(location, route.getlatlngcoordinates(), true, route_search_radius); boolean islocationonpath = polyutil.islocationonpath(location, route.getlatlngcoordinates(), true, route_search_radius); if(islocationonedge || islocationonpath){ //meaning route near @ , compute distance origin latlng nearestpoint = findnearestpoint(location, route.getlatlngcoordinates()); double distance = sphericalutil.computedistancebetween(location, nearestpoint); log.i(tag, "origin: "+location); log.i(tag, "nearest point: "+nearestpoint); log.i(tag, "distance: "+distance); route.setdistancefromorigin(distance); route.setnearestpointfromorigin(nearestpoint); nearroutes.add(route); } }
the result in log following:
origin: lat/lng: (7.0792276,125.6248482) nearest point: lat/lng: (7.079228237884086,125.6248559529709) distance: 0.8584555298849629 origin: lat/lng: (7.0792276,125.6248482) nearest point: lat/lng: (7.0792199725865546,125.62475406260717) distance: 10.422383454451605
as can see there wide margin of difference among 2 distances though have same nearest point. (please see emphasized comparison below)
route a
origin: lat/lng: (7.0792276,125.6248482)
nearest point: lat/lng: (7.079228237884086,125.6248559529709)
distance: 0.8584555298849629
route b
origin: lat/lng: (7.0792276,125.6248482)
nearest point: lat/lng: (7.0792199725865546,125.62475406260717)
distance: 10.422383454451605
to illustrate plotted polygons/routes , nearest points origin. highlighted , indicated distances base on result logged code in logcat. why distance (red line) nearest point of route a origin 0.8584555298849629 compared distance (green line) of route b 10.422383454451605? base on positions , coordinates of nearest points close each other therefore distance should not differ greatly.
this bit confusing me. did miss or there wrong code?
there no evidence sphericalutil
returning inaccurate information.
this map plots origin , 2 points mention:
you can see scale of map @ bottom of image. if many pixels 5 feet, 2 "nearest" points appear approximately 11 meters apart, program output says.
Comments
Post a Comment