Opened 8 years ago

Closed 8 years ago

#10823 closed Bugs (wontfix)

IsValid or dissolve problem?

Reported by: anonymous Owned by: Barend Gehrels
Milestone: To Be Determined Component: geometry
Version: Boost 1.57.0 Severity: Problem
Keywords: Cc: mkaravel

Description

Dear Boost Geometry contributors.

As always: Thanks for your great work. Your work is an incredible help every day.

I discovered a problem, which I guess you can help me with.

If you look at the below test case you will see a small polygon where two points touches each other and forms a "hole" in the polygon.

If I call is_valid with this polygon it tells me that the polygon is invalid.

If I then tries to dissolve it, the output is again not valid.

My question is therefore if it could be a problem with is_valid or dissolve. Alternatively what could I do to make it valid so that it can be used for calls to e.g sym_difference?

Thanks a lot

Johan

BOOST_AUTO_TEST_CASE(Boost_IsValidOrDissolve_Fails) {

polygon<point_xy<float>> Poly; read_wkt("POLYGON((0 3, 3 3, 3 1, 2 1, 2 2, 1 2, 1 1, 2 1, 2 0, 0 0, 0 3))", Poly);

BOOST_CHECK(!is_valid(Poly));

multi_polygon<polygon<point_xy<float>>> Polys; dissolve(Poly, Polys);

BOOST_CHECK(!is_valid(Polys));

}

Attachments (1)

ticket_10823.cpp (640 bytes ) - added by mkaravel 8 years ago.
File showing the validity of the correctly defined polygon

Download all attachments as: .zip

Change History (3)

comment:1 by mkaravel, 8 years ago

Cc: mkaravel added

by mkaravel, 8 years ago

Attachment: ticket_10823.cpp added

File showing the validity of the correctly defined polygon

comment:2 by mkaravel, 8 years ago

Resolution: wontfix
Status: newclosed

Hi Johan.

According to the OGC standard the outer and inner rings of a polygon must be simple rings (the standard uses the term LinearRing for these). As such, a ring of a polygon cannot touch itself.

This is what is implemented in Boost.Geometry (a bit relaxed though as we do allow for duplicate consecutive points). For your polygon to be valid, you need to define the inner ring separately; see the following WKT:

POLYGON((0 3,3 3,3 1,2 1,2 0,0 0,0 3),(2 1,2 2,1 2,1 1,2 1))

I have also attached a small program exhibiting what I am claiming above; if you re-define your polygon as per the WKT above, it is detected as valid.

Last edited 8 years ago by mkaravel (previous) (diff)
Note: See TracTickets for help on using tickets.