Add radius to Longitude and Latitude with C#
I need to generate a bounding box of min and max latitude and longitude values so I can return addresses within a given radius.
I have two func<>'s below to return the range I need to +/- to the lon lat coordinates to establish the bounding box. However I don't think the math is 100%
I am using the Haversine formula to generate my distance calculations and that seems to be working accurately. I investigated the Vincenty formula for distance as well but for my needs that was overkill.
My problem is that I would like my search results to be as accurate as Haversine in that the range I +/- to the lon lat coordinates takes开发者_StackOverflow into account the ellipsoidal curvature or the earth.
Ok, here are my func<>'s...please note I am not a Math professor :o)
static Func<double, int, double> GetLatitudeRange = (latitude, distance) => (180.0 / Math.PI) * (distance / EARTH_RADIUS_IN_KM);
static Func<double, double, int, double> GetLongitudeRange = (longitude, latitude, distance) =>
(
Math.Asin(
Math.Sin(distance / EARTH_RADIUS_IN_KM) / Math.Cos(latitude)
)
);
Take a look at zipcodeworld
精彩评论