Opened 7 years ago

Closed 7 years ago

#11783 closed Bugs (wontfix)

distance between polygon

Reported by: brahim.boudamouz@… Owned by: Barend Gehrels
Milestone: To Be Determined Component: geometry
Version: Boost 1.59.0 Severity: Problem
Keywords: distance polygon Cc:

Description

Distance between polygon return 0 whereas it is not.

For example, the following two polygons poly and poly2:

typedef boost::geometry::model::d2::point_xy<double> point_type; typedef boost::geometry::model::polygon<point_type> polygon_type;

polygon_type poly, poly2;

boost::geometry::read_wkt("POLYGON((0.483707939991215 4.773920582819078, 0.5053006295162502 4.848900310429359, 0.5026276157353238 4.926851374195881, 0.47595271806952655 5.000142970012212, 0.42788885209344396 5.061604949484321, 0.36314153156370255 5.1052282121312595, 0.28804795065446004 5.12675006676153, 0.20995692111385858 5.124068426945231, 0.13651026810181627 5.097445647190528, 0.07489571249838214 5.049482920409928, 0.031143980177505432 4.984867693057649, 0.009538656296549554 4.909917885067861, 0.012196499626267798 4.831966193462844, 0.03885948446609647 4.758643661998902, 0.0869192454259704 4.697132255323741, 0.151671837534352 4.653459953523097, 0.22677805366317155 4.63190817924884, 0.30488425540802405 4.634590447230228, 0.37834282146581616 4.661244162857866, 0.43996148046825034 4.709256316654202))", poly);

boost::geometry::read_wkt("POLYGON((-1.0557992498764188 4.746036929415318,-1.0993658333477525 4.810856267060861, -1.1608453480495324 4.859088577533509, -1.234220477005859 4.886019279588865, -1.312310562575837 4.889015578303403, -1.3874737831476758 4.867782698965993, -1.452354304963582 4.8243932756221835, -1.5006016515805882 4.763086838460696, -1.5274921589195156 4.689857989799479, -1.530391741605481 4.61187218939475, -1.5090144880022829 4.5367652713717845, -1.465451447333285 4.471894995746168, -1.4039664811460055 4.423618461729835, -1.3305789878636327 4.3966671418069225, -1.2524743477794593 4.393681706260662, -1.177299942608499 4.414952781113644, -1.1124158788230383 4.458393143311671, -1.0641739853613563 4.519743805317727,-1.0372958425476984 4.5929932717763435, -1.0344108128292469 4.670968207668558))",poly2);

std::cout << "distance: " << boost::geometry::distance(poly, poly2) << std::endl;

Attachments (1)

dist_test.cpp (2.1 KB ) - added by anonymous 7 years ago.
stand alone c++ source code to test bug

Download all attachments as: .zip

Change History (4)

by anonymous, 7 years ago

Attachment: dist_test.cpp added

stand alone c++ source code to test bug

comment:1 by awulkiew, 7 years ago

Thanks for the report.

By default bg::model::polygon is clockwise and closed (the last point must be equal to the first one). On the other hand the polygons you defined in WKT are not. To fix it you may:

  1. Pass closed WKTs
  2. Call bg::correct() after reading the polygon from WKT
  3. Use open polygon type, e.g. bg::model::polygon<point_type, true, false>

Can you confirm that this is not a bug?

comment:2 by brahim.boudamouz@…, 7 years ago

In fact that is not a bug! A call of boost::geomery::correct(mypolygon) before computing distance solve the problem Thanks for your quick answer and problem handling Grateful for the time you spent

comment:3 by awulkiew, 7 years ago

Resolution: wontfix
Status: newclosed
Note: See TracTickets for help on using tickets.