Subject: [ggl] 'area' and 'within' implementations for spherical earth?
From: Barend Gehrels (barend)
Date: 2011-07-13 01:20:39
> Ahh, I missed that. Yes within appears to work fine.
Good to hear.
> However, I am having a confusing result using 'area' with
> spherical_equatorial. Porting roughly the polygon_example to use
> spherical_equatorial, I find adding an inner_ring to a polygon
> *increases* the area of the original polygon by the area of the inner
> ring. Please see attached.
> Is this a bug? Or do I misunderstand the "interior ring" concept?
Hmm, I'm afraid you find a bug indeed. If you take serious data, it will
probably not occur.
The central idea of Boost.Geometry are that polygons do have the correct
orientation. They should be clockwise, inner rings should be counter
clockwise. This rule is general, unless you specify that polygons have
counterclockwise order (then inner rings should be clockwise).
If you specify it wrong, you would get a negative area.
This all in the general case. But for spherical it is a little more
complicated: they have to take the dateline into account. Apparently the
detection of that is not perfect, therefore your first area was
positive. Probably the same for the inner area.
If you call bg::correct(boxRegion), it should be OK. If you use polygons
not entering negative coordinates like this, it is also OK though I
admit that this is the bug, so I will look at that in more detail soon.
OK, finally, what I really find strange is, that if I change
spherical_equatorial<bg::degree> to cartesian, it (correctly) complains
about the forgotten namespace in assign_points and within. That is
really surprising - I don't change the headerfiles, so the original file
should NOT have compiled... But it did, in MSVC, in GCC and in clang.
This is a mystery to me. I scanned for using and found only a few local
calls to using. So I don't know why it compiles.
Geometry list run by mateusz at loskot.net