7

I have a database of polygon points as latitude, longitude pairs and I need to test if a given lat,lng point is inside any of the polygons.

There are several algorithms around including these but they don't work if the polygon straddles the antemeridian (off the coast of New Zealand, where longitude flips from +180 degrees East to -180 degrees West).

One solution I see is to detect if the polygon straddles the antemeridian and if so split it into two polygons, one on each side, then check each of them.

4

4 回答 4

2

The other (simpler) option, IMO, is to just test for that special case, and if it exists, apply a transform to your query point and the polygon. For example, if it spans the anti-meridian, just translate everything by a specific longitude amount to make it not span the meridian, and do your standard test.

于 2009-07-24T00:59:35.823 回答
1
于 2009-07-24T01:33:56.767 回答
1

您不能通过添加 360 使所有经度坐标“移动”到 GW 子午线的正侧吗?例如:坐标是-178度然后变成+182度,-1度变成359度,1度变成361等等......

我不知道这将如何影响两极,但它可能适用于任何不接触两极的东西。

于 2012-10-01T09:46:26.687 回答
0

感谢您的建议。最后,我正在测试的多边形是一个矩形,因此如果它跨越前经线(它具有不同符号的经度),则将其切成两个多边形,每边一个,并查询与其中任何一个相交的对象。

于 2009-08-08T05:07:09.550 回答