Geo-algorithm for finding the coordinates of a point from a known location by distance and carrier

I would like to use the Google maps static API to display a map with a path overlay indicating the border.

AFAICT static API does not support polygons, so I intend to get around this by drawing the border using paths.

To do this, I need to define points in order to draw lines (paths) between them; so I need an algorithm that returns the geographic location (i.e. WGS84 coordinates) of a given bearing and the distance from a known point.

Can anyone point me to such an algorithm. Preferably in C #, but other languages ​​are acceptable?

+3
source share
5 answers

Found it (here: http://williams.best.vwh.net/avform.htm#LL ):

The point {lat, lon} is the distance d at a radius tc from point 1 if:

lat=asin(sin(lat1)*cos(d)+cos(lat1)*sin(d)*cos(tc)) IF (cos(lat)=0) lon=lon1 // endpoint a pole ELSE lon=mod(lon1-asin(sin(tc)*sin(d)/cos(lat))+pi,2*pi)-pi ENDIF 

Will the radial be in radians or degrees?

Edit:

radian = degrees * PI / 180

0
source

I implemented and tested it in C # using Degrees as input / output instead of radians:

  static readonly double FullCircleDegrees = 360d; static readonly double HalfCircleDegrees = FullCircleDegrees / 2d; static readonly double DegreesToRadians = Math.PI / HalfCircleDegrees; static readonly double RadiansToDegrees = 1 / DegreesToRadians; public LatLng GetPointGivenRadialAndDistance(LatLng center, double radius, double azimuth) { var lat1 = center.Lat * DegreesToRadians; var lng1 = center.Lng * DegreesToRadians; var lat = Math.Asin( (Math.Sin(lat1) * Math.Cos(radius)) + Math.Cos(lat1) * Math.Sin(radius) * Math.Cos(azimuth * DegreesToRadians)); var lng = 0d; if (Math.Cos(lat) == 0) { lng = lng1; } else { lng = ((lng1 + Math.PI - Math.Asin(Math.Sin(azimuth * DegreesToRadians) * Math.Sin(radius) / Math.Cos(lat1))) % (2 * Math.PI)) - Math.PI; } return new LatLng(lat * RadiansToDegrees, lng * RadiansToDegrees); } 
+2
source

You can draw a polygon in a KML file and then display KML on Google maps.

Here's KML on Google maps (from Google KML Samples) check out the Google Campus - Polygons section in the content.

+1
source

In (I think) every language that I know is radian. Please note: I think your sample code gives you coordinates based on a sphere, not on WGS84. Here's the Java code to convert between coordinate systems .

+1
source

Take a look at the Gavaghan Geodesy C # Library, this should be what you are looking for. And it's free.

+1
source

All Articles