geometry icon indicating copy to clipboard operation
geometry copied to clipboard

I cannot get Dissolve to compile

Open JohanDore opened this issue 6 months ago • 11 comments

Hi All,

As always, I want to start by thanking you for your work on Boost Geometry. It's been incredibly helpful to us.

We still use Dissolve to fix erroneous polygons that are drawn manually or received from third parties. We encounter various errors, and Dissolve has been a great function for us over the years.

If there are any alternatives, I would be happy to learn how to avoid using Dissolve. But if not, please help get Dissolve to compile again? It worked in 1.85 but with 1.88 I've been trying for the past few hours without any progress, so I probably can't make it work in finite time

Thanks a lot.

Best regards,

Johan

JohanDore avatar Jun 22 '25 19:06 JohanDore

hi @JohanDore ,

Thanks for reporting this issue!

Last spring I have done a big improvement in handling all intersection/union/difference code. I had also dissolve in mind - it should be easier now - but did not yet get to that part yet.

But I will do now, I hope to be able to work on it this and next Month - and it would actually be great to finally have it in the normal branch as well.

Best regards, Barend

barendgehrels avatar Jun 22 '25 20:06 barendgehrels

Hi @barendgehrels,

Oh that is great to hear. Let me know if there is anything I can do to help

Best regards

Johan

JohanDore avatar Jun 23 '25 06:06 JohanDore

hi @JohanDore

First step is there #1411 . See comments there. It compiles again - but it works not yet for all cases. (It works for some cases though)

However, if you want to target 1.88 then most of the changes would do for you. What is not working yet is the adaptation to the new underlying Graph algorithm. Hope to continue that next week.

barendgehrels avatar Jun 25 '25 17:06 barendgehrels

Oh thanks a lot @barendgehrels. It's always a pleasure working with you:-) I can confirm that it compiles under 1.88, however quite a few of my dissolve unitest still fails, e.g:

polygon<DPointXY> Poly;
read_wkt("POLYGON((0 0, 0 4, 4 4, 4 0, 1 0, 1 3, 3 3, 3 0))", Poly);
correct(Poly);

DMultiPolygon Dissolved;
boost::geometry::dissolve(Poly, Dissolved);

BOOST_CHECK(is_valid(Dissolved));
BOOST_CHECK_EQUAL(Dissolved.size(), 1);
BOOST_CHECK_EQUAL(Dissolved[0].outer().size(), 5); 	//It should have 5 points
BOOST_CHECK_EQUAL(Dissolved[0].inners().size(), 0);
BOOST_CHECK_CLOSE(area(Dissolved), 16.0, 0.0001);

worked under 1.85.

So maybe I better await you next iterations

JohanDore avatar Jun 29 '25 18:06 JohanDore

Oh thanks a lot @barendgehrels. It's always a pleasure working with you:-)

šŸ˜Ž thanks! Likewise!

I can confirm that it compiles under 1.88

Good to hear.

however quite a few of my dissolve unitest still fails, e.g:

Yes it is not yet the same. And in 1.89 it will be different again, because of changes in the underlying algorithm. Thanks for your test, I will add it.

So maybe I better await you next iterations

Hope to improve things!

barendgehrels avatar Jul 05 '25 09:07 barendgehrels

Thanks for your test, I will add it.

I had it already, it's dissolve_mail_2017_10_26_b ;-)

barendgehrels avatar Jul 05 '25 10:07 barendgehrels

hi @JohanDore the next step is done. Actually there are 3 alternatives now:

  • the original, which works now reasonable (better than the version 2 weeks ago)
  • a version using buffer which works fine BUT:
    • it removes all interior rings
    • it can change the coordinates a bit
  • a version which was submitted in 2021 already - and discussed - but never made it into the library. This is now called dissolve_using_correct.

If you have the time, is it possible to judge what is the best option for you?

barendgehrels avatar Jul 19 '25 12:07 barendgehrels

Few more remarks:

  • TEST_DISSOLVE(dissolve_mail_2017_10_26_b, 16.0, 1, 0, 5); should be fixed now (the case you described above)
  • the alternative using buffer needs the develop version of Boost.Geometry, because it uses the convert which I extended (w.r.t. geometry types) for this reason

barendgehrels avatar Jul 19 '25 12:07 barendgehrels

Thank a lot @barendgehrels

I'll give it a try when I am back in afew days and let you know

JohanDore avatar Jul 19 '25 15:07 JohanDore

Hi Barend,

If I could hand out a Nobel Prize for contributions to Boost.Geometry, I’d be standing on stage in Stockholm on December 10th with your name on the envelope! 😊

All tests are now passing — even some of the older ones that were previously failing are now working.

Thanks so much to you and everyone contributing to Boost.Geometry.

Best regards,

Johan

JohanDore avatar Aug 02 '25 07:08 JohanDore

If I could hand out a Nobel Prize for contributions to Boost.Geometry, I’d be standing on stage in Stockholm on December 10th with your name on the envelope! 😊

All tests are now passing — even some of the older ones that were previously failing are now working.

Thanks Johan for your nice comment! But also for your report and helping me finding the root cause, I'm glad that we (most probably) still get it in 1.89 in time.

barendgehrels avatar Aug 04 '25 05:08 barendgehrels