I had to spend about two hours to work out the solution by @nibot , I simply needed a method to create a boundary box given its center point and width/height (or radius) in kilometers:
I don't understand the solution mathematically/ geographically.
I tweaked the solution (by try and error) to get the four coordinates:
North:
private static Position FromKmToNPosition(Position p, double km)
{
double r_earth = 6378;
var pi = Math.PI;
var new_latitude = p.Lat + (km / r_earth) * (180 / pi);
return new Position(new_latitude, p.Long);
}
East:
private static Position FromKmToEPosition(Position p, double km)
{
double r_earth = 6378;
var pi = Math.PI;
var new_longitude = p.Long + (km / r_earth) * (180 / pi) / Math.Cos(p.Lat * pi / 180);
return new Position(p.Lat, new_longitude);
}
South:
private static Position FromKmToSPosition(Position p, double km)
{
double r_earth = 6378;
var pi = Math.PI;
var new_latitude = p.Lat - (km / r_earth) * (180 / pi);
return new Position(new_latitude, p.Long);
}
West:
private static Position FromKmToWPosition(Position p, double km)
{
double r_earth = 6378;
var pi = Math.PI;
var new_longitude = p.Long - (km / r_earth) * (180 / pi) / Math.Cos(p.Lat * pi / 180);
return new Position(p.Lat, new_longitude);
}