Boost logo

Geometry :

Subject: Re: [geometry] Result change in geometry::centroid between version 1.53 and 1.58
From: Adam Wulkiewicz (adam.wulkiewicz_at_[hidden])
Date: 2015-04-24 09:32:40


Hi Eric,

Eric.noirfalise wrote:
> Dear All,
>
> I'm having a result change issue in geometry::centroid between boost version
> 1.53 and 1.58 when I use input polygon composed of integer points and an output
> double point.
>
> Here is my code :
>
> #include <boost/geometry.hpp>
> #include <boost/geometry/geometries/point_xy.hpp>
> #include <boost/geometry/geometries/polygon.hpp>
>
>
> int main()
> {
> typedef boost::geometry::model::d2::point_xy<int> PointInt;
> typedef boost::geometry::model::d2::point_xy<double> PointDouble;
> typedef boost::geometry::model::polygon<PointInt> polygon_type;
>
> polygon_type poly;
> boost::geometry::read_wkt(
> "POLYGON((1 1, 2 1, 2 2, 1 2, 1 1))", poly);
>
> PointDouble p;
> typedef boost::geometry::strategy::centroid::bashein_detmer<PointDouble,
> PointInt, double> Strategy;
> boost::geometry::centroid(poly, p, Strategy());
>
> std::cout << "centroid: " << boost::geometry::dsv(p) << std::endl;
>
> return 0;
> }
>
> The result for boost 1.53 (which seems good for me) :
> centroid: (1.5, 1.5)
>
> And the result for boost 1.58 (which seems wrong for me) :
> centroid: (1, 1)
> I can also see new warnings during compilation with version 1.58.
>
> Could you confirm me that this is a bug ?

Yes, it's a bug.
Introduced in this PR https://github.com/boostorg/geometry/pull/155
This was released with Boost 1.57.

Could you please create a ticket?

Regards,
Adam


Geometry list run by mateusz at loskot.net