Opened 8 years ago

Closed 8 years ago

Last modified 8 years ago

#10713 closed Bugs (fixed)

Boost Geometry dissolve

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

Description

Dear Boost Geometry Contributors

I was testing out the new 1.57 beta therefore also downloaded the latest \geometry\extensions\algorithms\dissolve.hpp file.

Testing that I stumbled upon a strange thing which I thought would be interesting for you.

Using the below example:

using namespace boost::geometry; using namespace boost::geometry::model; using namespace boost::geometry::model::d2;

int _tmain(int argc, _TCHAR* argv[]) {

polygon<point_xy<float>> Poly; read_wkt("POLYGON((-0.7189743518829346 4.1308121681213379, 0.0831791982054710 4.1034231185913086, 0.1004156470298767 4.1107301712036133, 0.1044322624802589 4.1026973724365234, 0.0831791982054710 4.1034231185913086, -0.7711903452873230 3.7412264347076416, -0.7189743518829346 4.1308121681213379))", Poly);

multi_polygon<polygon<point_xy<float>>> Dissolved; boost::geometry::dissolve(Poly, Dissolved); return 0;

}

I find that dissolve gives me 2 polygons back with 5 outline points in each. However the input polygon is like two triangles touching each other so I was expecting an output of two polygons with each 4 points.

I then looked at the dissolve.hpp and wondered if it could be because of the no_rescale_policy() specified in the dissolve function. Modified the function to use the rescale policy found in other of your geometry functions:

inline void dissolve(Geometry const& geometry, Collection& output_collection) {

concept::check<Geometry const>();

typedef typename boost::range_value<Collection>::type geometry_out;

concept::check<geometry_out>();

typedef typename geometry::point_type<Geometry>::type point_type; typedef typename geometry::rescale_policy_type<point_type>::type rescale_policy_type;

rescale_policy_type robust_policy = geometry::get_rescale_policy<rescale_policy_type>(geometry);

dispatch::dissolve <

typename tag<Geometry>::type, typename tag<geometry_out>::type, Geometry, geometry_out

::apply(geometry, robust_policy, std::back_inserter(output_collection));

}

Doing so made the dissolve function return two polygons with each 4 points.

I then ran a lot of different other tests and none of those failed for me.

I therefore wonder if there is a reason for the no_rescale_policy() or if it is better to use the “robust_policy”

Best regards and thanks a lot for this great library

Johan Doré

Change History (3)

comment:1 by Barend Gehrels, 8 years ago

Status: newassigned

comment:2 by Barend Gehrels, 8 years ago

Resolution: fixed
Status: assignedclosed

The no_rescale_policy was added in the dissolve-extension during the development of robustness/rescaling, it was indeed the intention to replace it with proper rescaling.

Done, thanks for your suggestion and your compliments.

comment:3 by anonymous, 8 years ago

Hi Again,

Thanks a lot for the fix.

Maybe it is me but I thought that the changes should also be applied to the Dissolve function?

Something like:

template <

typename Geometry, typename Collection

inline void dissolve(Geometry const& geometry, Collection& output_collection) {

concept::check<Geometry const>(); typedef typename boost::range_value<Collection>::type geometry_out;

concept::check<geometry_out>();

typedef typename geometry::point_type<Geometry>::type point_type; typedef typename geometry::rescale_policy_type<point_type>::type rescale_policy_type;

rescale_policy_type robust_policy = geometry::get_rescale_policy<rescale_policy_type>(geometry);

dispatch::dissolve <

typename tag<Geometry>::type, typename tag<geometry_out>::type, Geometry, geometry_out

::apply(geometry, robust_policy, std::back_inserter(output_collection));

}

Best regards

Johan

Note: See TracTickets for help on using tickets.