使用 C# 将半径添加到经度和纬度
我需要生成最小和最大纬度和经度值的边界框,以便我可以返回给定半径内的地址。
我下面有两个 func<> 来返回我需要+/-到经纬度坐标以建立边界框的范围。然而,我不认为数学是 100%
我正在使用半正弦公式来生成距离计算,这似乎工作得很准确。我也研究了文森蒂距离公式,但对于我的需求来说这是多余的。
我的问题是,我希望我的搜索结果与半正矢一样准确,因为 I +/- 经纬度坐标的范围考虑了椭球曲率或地球。
好的,这是我的 func<>...请注意我不是数学教授: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)
)
);
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 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)
)
);
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
看看 zipcodeworld
Take a look at zipcodeworld