0
votes

I have a Locations with given lat/lon coordinates (from Google Maps).

Now I want to span a rectangle with a given distance (f.e. 150 meters) to all 4 sky directions (north, south, west, east) an calculate their coordinates as lat/lon.

How can I do this in C#?

2
If distance is not large (150 meters is less than 0.1 nautical mile) and if Location is not near the North/South Pole you may use Flat Earth model. - Dmitry Bychenko

2 Answers

1
votes

Please check this PDF file, I think it should be very help full find rectangle span. Most see slide no 11.

0
votes

That depends on how precise it needs to be. You can use a spherical model.

void pointAtDistace(double lat1, double lon1, double brng, ref double lat2, ref double lon2)
{
    lat2 = Math.Asin( Math.Sin(lat1)*Math.Cos(d/R) +  Math.Cos(lat1)*Math.Sin(d/R)*Math.Cos(brng) );
    lon2 = lon1 + Math.Atan2(Math.Sin(brng)*Math.Sin(d/R)*Math.Cos(lat1), Math.Cos(d/R)-Math.Sin(lat1)*Math.sin(lat2));
}

Coordinates needs to be in radians for this. But since the earth is no spherical ball, here is library that uses a way more precise library for those purposes:

http://www.gavaghan.org/blog/free-source-code/geodesy-library-vincentys-formula/