查找给定位置(纬度,经度)是否在两个坐标的边界框内(route-me) [英] Finding if a given position (lat, lon) is within the BoundingBox of two coordinates (route-me)

查看:134
本文介绍了查找给定位置(纬度,经度)是否在两个坐标的边界框内(route-me)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Route-Me项目开发iPhone应用程序. 我正在使用一种名为"latitudeLongitudeBoundingBoxForScreen"的方法,该方法返回一组两个cooördinates.在屏幕的纬度/经度中定义东北角和西南角.这似乎工作正常.

I am working on an iPhone app using the Route-Me project. I am using a method called 'latitudeLongitudeBoundingBoxForScreen' which returns a set of two cooördinates. Defining the Northeast and Southwest corners in lat/lon of your screen. This seems to work fine.

我的问题是如何确定给定点(纬度/经度)是否在这两个坐标(东北,西南)的边界内?

My question is how can I determine whether a given point (lat/lon) is within the boundaries of these two coordinates (northeast,southwest)?

非常感谢您的帮助.

推荐答案

对于多边形中的常规点,

For general point in a polygon, the Point Inclusion Test seems to work assuming a trivial Equirectanglular projection (x = lon, y = lat).

由于您知道东北和西南角,因此可以计算西北和东南角.另外,请记住,边界多边形(框)必须遵循缠绕惯例(您不能在点包含测试"中抛出点).

Since you know the north-east and south-west, you can compute the north-west and south-east corners. Also, keep in mind that your bounding polygon (box) must following a winding convention (you just can't throw points at the Point Inclusion Test).

如果边界框越过180 lon线,这将中断.简单的解决方法是,越过180 lon线的框是将360添加到负经度.这不是有效的导航点,但可以使数学工作正常.

This will break if the bounding box goes across the 180 lon line. The simple fix is if the box that crosses 180 lon line is to add 360 to the negative longitude. This isn't a valid navigation point but it makes the math work.

这在两极都行不通.

这篇关于查找给定位置(纬度,经度)是否在两个坐标的边界框内(route-me)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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