latitude longitude - How to test if a point inside area with lat/lon and radius using Java? -
i've write method has following signature
public class position { double longitude; double latitude; } boolean isinsidethearea(position center, double radius, position point);
so if point
inside area
has center
center , radius
radius in miles, should return true
, false
otherwise.
use haversine formula compute distance between center
, point
. if distance greater radius
, return false
; otherwise return true
.
pseudocode:
def haversinedistance(a, b): # snip... return foo def isinsidethearea (center, radius, point): return haversinedistance(center, point) <= radius
Comments
Post a Comment