id,summary,reporter,owner,description,type,status,milestone,component,version,severity,resolution,keywords,cc 9768,difference of multi-polygon and box returns multi-polygon with redundant points,Volker Schöch ,Barend Gehrels,"boost::geometry::difference should not add redundant points to a polygon. In the following example I subtract an empty box from a polygon, and the result ends up representing the empty box even though obviously it should not. My polygon type is '''oriented counter-clockwise''' and '''not closed''', my point type is based on '''int'''. This is the data used as input to difference: {{{ _TPolygon const polygon = _TPolygon( ""MULTIPOLYGON(((249 509,5103 509,5103 3566,249 3566)))"" ) - _TRect( ""POLYGON((1220 1019,1220 1019,1220 1019,1220 1019,1220 1019))"" ); }}} This is the resulting multi-polygon, with the additional/redundant empty box: {{{ MULTIPOLYGON(((249 509,5103 509,5103 3566,249 3566),(1220 1019,1220 1019,1220 1019))) }}} This is my code that wraps boost::geometry to implement the operator used above: {{{ template template _TPolygon< T > _TPolygon< T >::operator-(Geometry geometry) const { _TPolygon< T > polygonOut; boost::geometry::difference(*this, geometry, polygonOut); // the following line fixes the problem but should not be necessary //boost::geometry::unique( polygonOut ); return polygonOut; } }}} These are the traits as defined to use _TRect<...> as a boost::geometry box: {{{ namespace boost { namespace geometry { namespace traits { template struct tag< _TRect > { typedef box_tag type; }; template struct point_type< _TRect > { typedef _TPoint type; }; template struct indexed_access< _TRect, min_corner, Dimension > { typedef typename geometry::coordinate_type< _TPoint >::type coordinate_type; static inline coordinate_type get(_TRect const& rect) { return geometry::get( rect.TopLeft() ); } static inline void set(_TRect& rect, coordinate_type const& value) { geometry::set( rect.TopLeft(), value ); } }; template struct indexed_access< _TRect, max_corner, Dimension > { typedef typename geometry::coordinate_type< _TPoint >::type coordinate_type; static inline coordinate_type get(_TRect const& rect) { return geometry::get( rect.BottomRight() ); } static inline void set(_TRect& rect, coordinate_type const& value) { geometry::set( rect.BottomRight(), value ); } }; } } } // namespace boost::geometry::traits }}} ",Bugs,closed,To Be Determined,geometry,Boost 1.56.0,Problem,duplicate,"difference, multi-polygon, polygon, box, unique",