geolocation - Map Coordinates C# -


i have set of latitude longitude points. if wanted test if new point within x metres of of existing points possible? best if use way?

foreach(coordinate coord in coordinates) {      var distance =  geocoordinate.getdistance(lat,lon);      if(distance <= x)      {          addtoqualifyinglist(coord);      } } 

and compare new coordinate every point in set , check see within x metres?

here method calculate distance between 2 points (lat1, lon1 , lat2, lon2)

public enum distanceunit { miles, kilometers, nauticalmiles } public double getdistance( double lat1, double lon1 , double lat2 , double lon2, distanceunit unit) {     func<double, double> deg2rad = deg => (deg * math.pi / 180.0);     func<double, double> rad2deg = rad => (rad / math.pi * 180.0);     double theta = lon1 - lon2;     double dist = math.sin(deg2rad(lat1)) * math.sin(deg2rad(lat2)) + math.cos(deg2rad(lat1)) * math.cos(deg2rad(lat2)) * math.cos(deg2rad(theta));     dist = math.acos(dist);     dist = rad2deg(dist);     dist = dist * 60 * 1.1515;      if (unit == distanceunit.kilometers)     {         dist = dist * 1.609344;     }     else if (unit == distanceunit.nauticalmiles)     {         dist = dist * 0.8684;     }     return (dist); } 

to determine coordinates distance below 1 kilometer:

list<coordinate> result = coordinates.where(x => geocoordinate.getdistance(lat,lon, x.lan, x.lon, distanceunit.kilometers) < 1).tolist(); 

Comments

Popular posts from this blog

Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.12:test (default-test) on project.Error occurred in starting fork -

windows - Debug iNetMgr.exe unhandle exception System.Management.Automation.CmdletInvocationException -

unity3d - Fatal error- Monodevelop-Unity failed to start -