Boost logo

Geometry :

Subject: Re: [geometry] Union clipping not working
From: Barend Gehrels (barend_at_[hidden])
Date: 2013-10-23 11:50:24


Hi,

Hunk wrote On 22-10-2013 11:40:
> Hello
>
> I have two areas which you can see on the follow picture
>
> <http://boost-geometry.203548.n3.nabble.com/file/n4025672/union_.png>
>
> As Points
>
> Blue:
> 2.5 , 4 / 2.5 , 1 / 2 , 1 / 2 , 4 / 0,4 / 0,0 / 7,0 / 7,5 / 2,5 / 2 , 4
> red:
> 2, 5 / 0 , 5 / 0 , 4 / 2, 4
>
> i expect as solution the outside area
> 0,0 7,0 7,4 0 ,4
> and the obstacle inside
>
> but the output polygon vector has only the size 1
>
> 0,4 / 0,0 / 7,0 /7,5 /0,5
>
> but i dont understand why ...
>
> is the problem the touch point(2,4) on polygon blue?

Nope, the problem is somewhere in your code. I don't see your code so I
cannot see what it is, but probably your polygon-definitions (CCW/CCW,
Open/Closed) do not correspond to the input you specify. You can always
call "correct".

This code works for me:
     boost::geometry::read_wkt("POLYGON((2.5 4 , 2.5 1 , 2 1 , 2 4
, 0 4 , 0 0 , 7 0 , 7 5 , 2 5 , 2 4, 2.5 4))", green);
     boost::geometry::read_wkt("POLYGON((2 5 , 0 5 , 0 4 , 2 4))",
blue);

     boost::geometry::correct(green);
     boost::geometry::correct(blue);

and delivers:

The orange line is the union. Colors are different because I adapted a
standard doumentation sample.
http://www.boost.org/doc/libs/1_54_0/libs/geometry/doc/html/geometry/reference/algorithms/union_.html

Another option is (remembering your previous mail about REGISTER_RING)
that you consider a ring as a polygon. That is not the case. The ring is
a simple geometry without any holes. You can output a union to a ring,
but any hole is than (by design) discarded. A ring cannot have holes, by
definition.

Regards, Barend



bifiaebh.png

Geometry list run by mateusz at loskot.net