Quick question about bg::difference

classic Classic list List threaded Threaded
11 messages Options
V D
Reply | Threaded
Open this post in threaded view
|

Quick question about bg::difference

V D
Hi,


I have a question about the difference algorithm.

template<typename Geometry1, typename Geometry2, typename Collection>
void difference(Geometry1 const & geometry1, Geometry2 const & geometry2, Collection & output_collection)


What happens in the case that the 2 geometries are disjoint? So far in my test cases it seems that in disjoint cases it will always return the second geometry, is this guaranteed ?

Thank you
-V


_______________________________________________
ggl mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/ggl
V D
Reply | Threaded
Open this post in threaded view
|

Re: Quick question about bg::difference

V D
In fact, I'm trying to avoid the bg::difference call but:

bg::disjoint(MultiPolygon, Polygon)
bg::intersects(MultiPolygon, Polygon)
bg::overlaps(MultiPolygon, Polygon)

doesn't seem to be supported for this combination

but bg::difference(MultiPolygon, Polygon) is.

:/

-V


On Oct 24, 2011, at 1:47 PM, V D wrote:

> Hi,
>
>
> I have a question about the difference algorithm.
>
> template<typename Geometry1, typename Geometry2, typename Collection>
> void difference(Geometry1 const & geometry1, Geometry2 const & geometry2, Collection & output_collection)
>
>
> What happens in the case that the 2 geometries are disjoint? So far in my test cases it seems that in disjoint cases it will always return the second geometry, is this guaranteed ?
>
> Thank you
> -V
>

_______________________________________________
ggl mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/ggl
Reply | Threaded
Open this post in threaded view
|

Re: Quick question about bg::difference

Barend
Hi,

On 24-10-2011 22:58, V D wrote:

> In fact, I'm trying to avoid the bg::difference call but:
>
> bg::disjoint(MultiPolygon, Polygon)
> bg::intersects(MultiPolygon, Polygon)
> bg::overlaps(MultiPolygon, Polygon)
>
> doesn't seem to be supported for this combination
>
> but bg::difference(MultiPolygon, Polygon) is.
>
> :/

That is right. Sorry, they are planned but for inclusing we concentrated on finishing the overlay functions, and the boolean relation ships are somewhat behind...

They'll come. But not in Boost 1.48 of which the beta date happens to be today.

Regards, Barend




_______________________________________________
ggl mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/ggl
Reply | Threaded
Open this post in threaded view
|

Re: Quick question about bg::difference

Barend
In reply to this post by V D
Hi,

On 24-10-2011 22:47, V D wrote:
Hi,


I have a question about the difference algorithm.

template<typename Geometry1, typename Geometry2, typename Collection>
void difference(Geometry1 const & geometry1, Geometry2 const & geometry2, Collection & output_collection)


What happens in the case that the 2 geometries are disjoint? So far in my test cases it seems that in disjoint cases it will always return the second geometry, is this guaranteed ?


Hmm, I would expect they would always return the first. That is what OGC specifies. Are you sure? I will look tomorrownight, and repair if necessary.

Regards, Barend



_______________________________________________
ggl mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/ggl
V D
Reply | Threaded
Open this post in threaded view
|

Re: Quick question about bg::difference

V D
Hum, after running more test cases here is what seems to happen:

bg::difference(MultiPolygon, Polygon) and bg::difference(Polygon, MultiPolygon) will return always return the polygon if they are disjoint.
bg::difference(Polygon, Polygon) will always return the 1st polygon if they are disjoint.

-v



On Oct 24, 2011, at 2:06 PM, Barend Gehrels wrote:

> Hi,
>
> On 24-10-2011 22:47, V D wrote:
>> Hi,
>>
>>
>> I have a question about the difference algorithm.
>>
>> template<typename Geometry1, typename Geometry2, typename Collection>
>> void difference(Geometry1 const & geometry1, Geometry2 const & geometry2, Collection & output_collection)
>>
>>
>> What happens in the case that the 2 geometries are disjoint? So far in my test cases it seems that in disjoint cases it will always return the second geometry, is this guaranteed ?
>>
>
> Hmm, I would expect they would always return the first. That is what OGC specifies. Are you sure? I will look tomorrownight, and repair if necessary.
>
> Regards, Barend
>
>
> _______________________________________________
> ggl mailing list
> [hidden email]
> http://lists.osgeo.org/mailman/listinfo/ggl

_______________________________________________
ggl mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/ggl
Reply | Threaded
Open this post in threaded view
|

Re: Quick question about bg::difference

Barend
Hi,

On 24-10-2011 23:37, V D wrote:
> Hum, after running more test cases here is what seems to happen:
>
> bg::difference(MultiPolygon, Polygon) and bg::difference(Polygon, MultiPolygon) will return always return the polygon if they are disjoint.
> bg::difference(Polygon, Polygon) will always return the 1st polygon if they are disjoint.
>

Thanks. Yes, I could reproduce it and you are right. We have to fix this.

If we support 8 geometry types, there are (theoretically) 64
possibilities for difference, and all other algorithms having two input
arguments. We therefore try to limit this by automatically reversing
arguments, so MultiPolygon/Polygon will be reversed to
Polygon/MultiPolygon. I never realized or thought about it (blame me)
that for difference this of course can never be done.

So will fix this a.s.a.p. Thanks for the report.

Regards, Barend


_______________________________________________
ggl mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/ggl
V D
Reply | Threaded
Open this post in threaded view
|

Re: Quick question about bg::difference

V D
Hi Barend,

Just a follow-up on this issue. 

Let's consider the case where MP and P are not disjoint.
bg::difference(MP, P) will lose any polygon in MP that is disjoint with P.


Example with images: 

Say the MP is the 2 squares below and P is the blue-ish rectangle.




The output should be something similar to:


But the actual output will be:



I will provide WKT and code when I have a few minutes ;)
-v

On Oct 25, 2011, at 10:41 AM, Barend Gehrels wrote:

Hi,

On 24-10-2011 23:37, V D wrote:
Hum, after running more test cases here is what seems to happen:

bg::difference(MultiPolygon, Polygon) and bg::difference(Polygon, MultiPolygon) will return always return the polygon if they are disjoint.
bg::difference(Polygon, Polygon) will always return the 1st polygon if they are disjoint.


Thanks. Yes, I could reproduce it and you are right. We have to fix this.

If we support 8 geometry types, there are (theoretically) 64 possibilities for difference, and all other algorithms having two input arguments. We therefore try to limit this by automatically reversing arguments, so MultiPolygon/Polygon will be reversed to Polygon/MultiPolygon. I never realized or thought about it (blame me) that for difference this of course can never be done.

So will fix this a.s.a.p. Thanks for the report.

Regards, Barend


_______________________________________________
ggl mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/ggl


_______________________________________________
ggl mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/ggl
Reply | Threaded
Open this post in threaded view
|

Re: Quick question about bg::difference

Barend
Hi,

>
> I will provide WKT and code when I have a few minutes ;)

No problem, I have it now. Currently fixing it.

Mailing soon again,
Barend

_______________________________________________
ggl mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/ggl
Reply | Threaded
Open this post in threaded view
|

Re: Quick question about bg::difference

Barend
In reply to this post by V D
Hi,

I believe that the difference problem you reported is fixed now. I'm avoiding now the reversal of arguments (both in difference and in sym_difference, which calls difference). It initially caused failing of one (of many) unit tests, but it appeared that that test was wrong. So thanks again for the report.

I added unit tests for your cases.

I just also tested your additional case below and it is now going OK as well, fixed by the earlier fix.

I added also a unit test for this case. See the image below.


On 25-10-2011 20:10, V D wrote:
Hi Barend,

Just a follow-up on this issue. 

Let's consider the case where MP and P are not disjoint.
bg::difference(MP, P) will lose any polygon in MP that is disjoint with P.


Example with images: 

Say the MP is the 2 squares below and P is the blue-ish rectangle.




The output should be something similar to:


But the actual output will be:





Images of P-Q and Q-P (I had this already so used other colors, purple is the output)


BTW all these kind of images are created by the SVG extension which we think of moving to non-extension.

Regards, Barend



_______________________________________________
ggl mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/ggl
V D
Reply | Threaded
Open this post in threaded view
|

Re: Quick question about bg::difference

V D
Hi Barend,

This is great! Thank you very much.
Any idea if there is an upcoming stable snapshot of the trunk ?

-v


On Oct 25, 2011, at 1:18 PM, Barend Gehrels wrote:

> Hi,
>
> I believe that the difference problem you reported is fixed now. I'm avoiding now the reversal of arguments (both in difference and in sym_difference, which calls difference). It initially caused failing of one (of many) unit tests, but it appeared that that test was wrong. So thanks again for the report.
>
> I added unit tests for your cases.
>
> I just also tested your additional case below and it is now going OK as well, fixed by the earlier fix.
>
> I added also a unit test for this case. See the image below.
>
>
> On 25-10-2011 20:10, V D wrote:
>>
>> Hi Barend,
>>
>> Just a follow-up on this issue.
>>
>> Let's consider the case where MP and P are not disjoint.
>> bg::difference(MP, P) will lose any polygon in MP that is disjoint with P.
>>
>>
>> Example with images:
>>
>> Say the MP is the 2 squares below and P is the blue-ish rectangle.
>>
>> <Mail Attachment.png>
>>
>>
>>
>> The output should be something similar to:
>>
>> <Mail Attachment.png>
>>
>> But the actual output will be:
>>
>> <Mail Attachment.png>
>>
>>
>
>
> Images of P-Q and Q-P (I had this already so used other colors, purple is the output)
> <bebdfbja.png>
>
> BTW all these kind of images are created by the SVG extension which we think of moving to non-extension.
>
> Regards, Barend
>
>
> _______________________________________________
> ggl mailing list
> [hidden email]
> http://lists.osgeo.org/mailman/listinfo/ggl

_______________________________________________
ggl mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/ggl
Reply | Threaded
Open this post in threaded view
|

Re: Quick question about bg::difference

Barend
On 25-10-2011 22:31, V D wrote:
> Hi Barend,
>
> This is great! Thank you very much.
> Any idea if there is an upcoming stable snapshot of the trunk ?
>
> -v

You're welcome.
The Trunk is usually as stable as possible, if we make any change we run
all unit tests, and they're run by Boost automatically as well...

The real snapshots are quarterly by the new version of Boost.

Having said that, there are some coming changes o.a. in folder structure
so maybe we could create a tagged version before.

Barend


_______________________________________________
ggl mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/ggl