Opened 5 years ago

Last modified 4 years ago

#13519 new Bugs

Invalid result for boost::geometry::difference

Reported by: lehnert@… Owned by: Barend Gehrels
Milestone: To Be Determined Component: geometry
Version: Boost 1.66.0 Severity: Problem
Keywords: geometry difference Cc:

Description

Hello,

executing the following polygon difference operation produces an obviously incorrect result. From a relatively large face a small face is subtracted and the result is very small.

Code snippet:

using point_type = boost::geometry::model::d2::point_xy<double>; using polygon = boost::geometry::model::polygon<point_type>; using multi_polygon = boost::geometry::model::multi_polygon<polygon>;

polygon op1, op2; multi_polygon result;

boost::geometry::read_wkt("MULTIPOLYGON(((-1.54499301090586272 0.996130119403307535, -1.54499299947730218 0.99761525234323567, -1.54655249947779994 0.995186041738558957, -1.54499301090586272 0.996130119403307535)), ((-1.54655249947779994 0.995186041738558957, -1.54499301719928761 0.995312293499367451, -1.54499301635595665 0.995421883734666779, -1.54655249947779994 0.995186041738558957)), ((-1.5466074994591299 1.08624204173854011, -1.54631431516927331 1.08619819902499004, -1.54633399044383202 1.08621614521949872, -1.5466074994591299 1.08624204173854011)), ((-1.5466074994591299 1.08624204173854011, -1.54499299946018764 1.08107828103308101, -1.54499301135365474 1.08339600649103418, -1.5466074994591299 1.08624204173854011)), ((-1.53918049946492008 1.05799404173705991, -1.5466074994591299 1.08624204173854011, -1.54634340852929708 1.08622473535414787, -1.99999999954877006 1.5, -1.99999999954877006 0.5, -1.54499301954877 0.995006979999999985, -1.54499301770602582 0.995246443249784174, -1.54655249947779994 0.995186041738558957, -1.54499299947244828 1.02129648988327593, -1.5449929994644851 1.06013330832250108, -1.5466074994591299 1.08624204173854011, -1.54499299946029955 1.08053288029024164, -1.53891949946469997 1.05905604173701007, -1.53918049946492008 1.05799404173705991)))", op1);

boost::geometry::read_wkt("POLYGON((-1.53581949946317997 1.06649704173632998, -1.5466074994591299 1.08624204173854011, -1.53723249946403007 1.06231704173661989, -1.53581949946317997 1.06649704173632998))", op2);

boost::geometry::difference(op1, op2, result);

Change History (3)

comment:1 by Barend Gehrels, 4 years ago

The first polygon is reported as invalid. Therefore the operation does not give the correct result. It has a self-touching (or intersecting) point at the upper right of the right side.

Can you please make it valid and retest?

comment:2 by anonymous, 4 years ago

This polygon was itself created via several (~64)previous difference operations. So I cannot make it valid. I can of course add the complete sequence of difference operations if this helps.

comment:3 by Barend Gehrels, 4 years ago

Right, sorry for that. Did you use 1.66 ? (probably yes because that is indicated in the ticket). Validity is improved there. But anyway, it apparently can still create an invalid result.

I'll come back to this, after my action removing the rescaling, that can be of influence

Note: See TracTickets for help on using tickets.