将 MKCooperativeRegion 视为矩形是否会再次困扰我?
背景:我正在构建一系列大量使用地图的基于位置的应用程序。这些地图用从服务器获取的位置进行注释,我将需要数据的地图区域传递给该服务器(定义为纬度/经度和 latDelta/longDelta,很像 MKCooperativeRegion,但参考坐标的位置不同) 。我正在编写一堆在管理这些区域时使用的辅助方法/类。需要与 iOS 3.x 兼容(意味着 MKMapRect 已经过时)。
问题:我将 MKCooperativeRegions 视为矩形是否会导致失败?具体来说,我将它们的几何形状视为矩形的几何形状,假设它们具有与矩形基本相同的属性。我已经实现了几种镜像 CGRect 辅助方法的方法,例如 MKCooperativeRegionUnion/Inset/Outset 等,它们都通过了我的单元测试,但我开始质疑我的基本假设是否正确。事实上,我知道 MKCooperativeRegion 并不代表几何矩形,而是由两组相互垂直的平行平面界定的球面区域(如果有人能告诉我更好的术语,那就加分了)。
我还没有遇到任何异常情况,但由于许多应用程序都依赖于我对几何的理解,我宁愿现在就弄清楚我是否走错了路。事实上,我在学校处理 3D 径向几何的大部分课程都在睡觉,这一事实并没有让我对自己的直觉是否正确充满信心。
Background: I'm build a series of location-based apps that make heavy use of maps. These maps are annotated with locations fetched from a server, to which I pass regions of the map I need data for (defined as a lat/long and a latDelta/longDelta, much like MKCoordinateRegion, but with a different location of the reference coordinate). I'm writing a bunch of helper methods/classes to use when managing these regions. Compatibility with iOS 3.x is required (meaning MKMapRect is out).
Question: Am I setting myself up for failure by treating MKCoordinateRegions like rectangles? Specifically, I'm treating their geometry as if it was that of a rectangle, assuming they have basically the same properties as rectangles. I've implemented several methods that mirror CGRect's helper methods, such as MKCoordinateRegionUnion/Inset/Outset, etc, and they all pass my unit tests, but I'm starting to question if my underlying assumptions are correct. I know in fact that MKCoordinateRegion does not represent a geometric rectangle, but rather a region of a spherical surface bound by two sets of parallel planes, perpendicular to each other (bonus points if somebody can clue me in on a better term for that).
I'm not experiencing any anomalies yet, but since many apps will be reliant on my understanding of the geometry, I'd rather figure out now if I'm going down the wrong path. The fact that I slept through most of the classes in school dealing with 3d radial geometry doesn't give me much confidence that my intuition is correct.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果你考虑到赤道、本初子午线和日期变更线的边缘情况,我想你会没事的。
或者,您可以开发自己的 MKMapRect,如 rects。 Troy Brant 有一篇关于矩形如何形成的精彩博客文章:
http://troybrant.net/blog/2010/01/mkmapview-and-zoom-levels-a-visual-guide/
虽然博客文章主要是关于缩放级别的,但所有信息可以用来构建您自己的地图矩形库。
球面上由大圆围成的区域称为球多边形。所以我想你可以称它们为球形矩形。
If you are taking into account the equator, prime meridian and dateline edge cases, I think you will be ok.
Alternatively, you could develop your own MKMapRect like rects. Troy Brant has a great blog post about the how the rects are formed:
http://troybrant.net/blog/2010/01/mkmapview-and-zoom-levels-a-visual-guide/
While the blog post is mainly about zoom levels, all the information there can be used to build up your own map rect library.
As for areas bounded by great circles on the surface of a sphere, they are called spherical polygons. So I guess you could just call them spherical rectangles.