
Geometry : 
Subject: Re: [geometry] Ring intersection question
From: Menelaos Karavelas (menelaos.karavelas_at_[hidden])
Date: 20141106 16:47:06
Yet one more comment.
On 06/11/2014 11:44 ??, Menelaos Karavelas wrote:
> Hi again.
>
> On 06/11/2014 11:34 ??, Menelaos Karavelas wrote:
>> Hi Will.
>>
>> On 06/11/2014 11:26 ??, Will Lucas wrote:
>>> On Thu, Nov 6, 2014 at 3:07 PM, Menelaos Karavelas
>>> <menelaos.karavelas_at_[hidden] <mailto:menelaos.karavelas_at_[hidden]>>
>>> wrote:
>>>
>>> Dear Will,
>>>
>>> I tried your polygons and the intersection seems to work.
>>> Please checkout the attached program, and let us know if you get
>>> a similar output. The output that I get is:
>>> MULTIPOLYGON(((75 150,250 150,250 75,75 75,75 150)))
>>>
>>> Best,
>>>
>>>  m.
>>>
>>>
>>> On 06/11/2014 10:44 ??, Will Lucas wrote:
>>>> Hi all,
>>>>
>>>> I have a question regarding the intersection of ring concepts
>>>> using Boost.Geometry. I currently have two overlapping
>>>> rectangles defined by the following WKTs:
>>>>
>>>> POLYGON((75 75,75 175,275 175,275 75,75 75))
>>>> POLYGON((50 50,50 150,250 150,250 50,50 50))
>>>>
>>>> When I perform the intersection of these rectangles, I get the
>>>> intersection points:
>>>>
>>>> POLYGON((75 150,250 75))
>>>>
>>>> The intersection points do not allow me to compute the area
>>>> correctly after the intersection. Is there way to get a fully
>>>> valid ring/polygon out of intersection, so that the area will
>>>> be equal to the overlapping region?
>>>>
>>>> Thanks!
>>>> Will
>>>>
>>>>
>>>> _______________________________________________
>>>> Geometry mailing list
>>>> Geometry_at_[hidden] <mailto:Geometry_at_[hidden]>
>>>> http://lists.boost.org/mailman/listinfo.cgi/geometry
>>>
>>>
>>> _______________________________________________
>>> Geometry mailing list
>>> Geometry_at_[hidden] <mailto:Geometry_at_[hidden]>
>>> http://lists.boost.org/mailman/listinfo.cgi/geometry
>>>
>>>
>>> Menelaos,
>>>
>>> Thanks for the quick response! I have tested your code, and it
>>> correctly outputs
>>>
>>> MULTIPOLYGON(((75 150,250 150,250 75,75 75,75 150)))
>>>
>>> I had to comment out the is_valid calls as I'm running the Ubuntu
>>> package (boost 1.54.0), which doesn't contain that helper method.
>>>
>>
>> Sure, this was just a sanity test.
>>
>>> I'm guess the problem may be my remapping of the OpenCV datatypes.
>>> Here is what I currently am working with
>>> https://gist.github.com/wlucasDFT/0b8e1e07f34ee7e489c6
>>>
>>> Do I need to define a polygon wrapper for the custom Contour type I
>>> have?
>>
>> I think that the problem is that your intersection output type should
>> be a multipolygon rather than a ring/polygon. Please checkout the
>> relevant doc page:
>> http://www.boost.org/doc/libs/1_56_0/libs/geometry/doc/html/geometry/reference/algorithms/intersection.html
>>
>> Try replacing the intersection output type by a multipolygon, or a
>> vector/deque of polygons and see what the output is.
>>
>
> Please see the updated attached program. I added one more call to
> bg::intersection specifying a ring as the output (like you do), and I
> get the result you get. I am now convinced that the problem is what I
> describe above.
>
I think what is happening is that the BG code understands your ring as a
container of points (a multipoint/vector of points/etc), rather than a
multipolygon, in which case it is setup to output just the intersection
points.
 m.
> All the best,
>
>  m.
>
>>  m.
>>
>>>
>>>
>>> _______________________________________________
>>> Geometry mailing list
>>> Geometry_at_[hidden]
>>> http://lists.boost.org/mailman/listinfo.cgi/geometry
>>
>
Geometry list run by mateusz at loskot.net