|
Geometry : |
Subject: [ggl] Difference / xor for multi polygons
From: Javier Gonzalez (xaviergonz)
Date: 2011-03-07 14:38:18
>
> Note that the last polygon is not valid. It has a "Self-intersection[-0.01
> -1960]" as reported by PostGIS, and also SQL Server Spatial reports it as
> invalid.
>
> Do you mean POLYGON ((-0.01 -1960, 80.01 -1960, 0 -1880, -0.01 -1960)),
> which looks visually the same and is valid?
>
> The first, invalid one gives indeed that polygon. Boost.Geometry does not
> check validity beforehand. Self-intersections might give unexpected results.
>
> Unioning with the valid one I suggested above gives me :
>
> POLYGON((-2 2,1842 2,1842 -2362,-2 -2362,-2 2),(0 -1880,80.01 -1960,0
> -1960,0 -2360,1840 -2360,1840 0,0 0,0 -1880))
>
> visually the same as the clipper result and giving the same area. So this
> case is not faulty, but as designed.
>
>
> Ah, I didn't know (and notice) that. Sorry for the wrong alarm then :) I'll
fix my code so it doesn't make that kind of polygons then.
Here's another one though:
Difference of:
POLYGON((560 -400, 600 -400, 600 -440, 560 -440, 560 -400)), POLYGON((480
-400, 520 -400, 520 -440, 480 -440, 480 -400)), POLYGON((600 -320, 640 -320,
640 -360, 600 -360, 600 -320)), POLYGON((520 -400, 560 -400, 560 -440, 520
-440, 520 -400))
(4 rectangular holes, 3 close to each other, one separate)
with
POLYGON((0 0, 2000 0, 2000 -2000, 0 -2000, 0 0), (560 -400, 560 -440, 600
-440, 600 -400, 560 -400), (480 -400, 480 -440, 520 -440, 520 -400, 480
-400), (600 -320, 600 -360, 640 -360, 640 -320, 600 -320), (520 -400, 520
-440, 560 -440, 560 -400, 520 -400))
(a big rectangle with those same 4 rectangles as holes)
gives
POLYGON((640 -320, 640 -360, 600 -360, 600 -320, 640 -320))
(only the separate rectangle)
(PS: I'm not sure how to write proper WTK for multi polygons, if somebody
tells me I can report them with the proper form)
the result should be:
POLYGON((520 -440, 520 -400, 560 -400, 560 -440, 520 -440)), POLYGON((480
-440, 480 -400, 520 -400, 520 -440, 480 -440)), POLYGON((560 -440, 560 -400,
600 -400, 600 -440, 560 -440)), POLYGON((600 -360, 600 -320, 640 -320, 640
-360, 600 -360))
(the very same 4 rectangles again)
Maybe the problem is is the side sharing of some rectangles and it is my
fault again? :S
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/ggl/attachments/20110307/7e13526e/attachment.html
Geometry list run by mateusz at loskot.net