给定纬度/经度坐标,计算10公里区域的最小和最大经度/纬度值 [英] Given a lat/lng coordinate, calculate the min and max lat/lng values for a 10 km area

查看:237
本文介绍了给定纬度/经度坐标,计算10公里区域的最小和最大经度/纬度值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

可以说我有一个经纬度坐标,我想把它放在10公里宽的正方形中心,然后得到最小纬度经度/最大纬度经度/纬度。



有没有简单的方法可以做到这一点已经存在?

解决方案

如果不需要确切地说,这很容易:

在纬度上,1公里是0.009度(从仪表的原始定义开始)。由于您的广场距离中心5公里,因此您只需从中心点加减0.045度即可。

经度方面,它稍微复杂一点:Divide上面的值与纬度的余弦值。



在代码中:

  lat_min = lat_center  -  0.045; 
lat_max = lat_center + 0.045;
long_min = long_center - (0.045 / Math.cos(lat_center * Math.PI / 180);
long_max = long_center +(0.045 / Math.cos(lat_center * Math.PI / 180);

Math.PI / 180 从度数到弧度)。



注意:不适用于两极。


Lets say I have a lat lng coordinate and I want to place that at the center of a square that is 10km wide and then get the minimum lat/lng and maximum lat/lng.

Is there an easy way to do this that already exists?

解决方案

If it doesn't need to be exact, it is pretty easy:

For the latitude, 1 km is 0.009 degrees (follows from the original definition of meter). Since your square is 5 km around the center, you just need to add and subtract 0.045 degrees from the center point.

For the longitude, it is slightly more complicated: Divide the above value with the cosine of the latitude.

In code:

lat_min = lat_center - 0.045;
lat_max = lat_center + 0.045;
long_min = long_center - (0.045 / Math.cos(lat_center*Math.PI/180);
long_max = long_center + (0.045 / Math.cos(lat_center*Math.PI/180);

(Math.PI/180 is needed to convert from degrees to radians).

Beware: Does not work around the poles.

这篇关于给定纬度/经度坐标,计算10公里区域的最小和最大经度/纬度值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆