Boost logo

Geometry :

Subject: [ggl] Understanding get_turns for linestring/polygon overlay
From: Simonson, Lucanus J (lucanus.j.simonson)
Date: 2011-04-15 16:48:29


Barend Gehrels wrote:
> Hi John,
>
>> Maybe I am a total idiot, but I have the hardest time debugging my
>> own problems with Boost::Geometry. I was able to create the
>> envelope and extend it to a box with a buffer. I also was able to
>> create a linestring that I am sure extends beyond the extent of the
>> box. Now I am trying to get the turn points for the intersection of
>> the linestring and the box. Previously, I was able to do the
>> following with a linestring and a polygon_2d typedef
>> boost::geometry::detail::overlay::turn_info<point_2d> turn_info;
>> std::vector<turn_info> turns;
>> boost::geometry::detail::get_turns::no_interrupt_policy policy;
>> boost::geometry::get_turns<false, false,
>> boost::geometry::detail::overlay::assign_null_policy>(splitLine,
>> bufferBox, turns, policy);
>>
>> However, this fails with a box_2d. I'm assuming that the box_2d is
>> somehow not really a polygon_2d, but can't figure out how to make it
>> a polygon. I know I could probably iterate through all the points
>> of the box and add it to a polygon, but is there a better way?
>
> Yes, a box_2d is not really a polygon_2d but you can convert it to
> one. Which branch of Boost.Geometry are you using? If 0.9.0, you can
> use boost::geometry::convert to convert the box into a polygon.
>
> Indeed the get_turns fails in case of a linestring and a box, and a
> polygon succeeds. In a future version the box will be supported as
> well in this algorithm.
>
> Regards, Barend

I think we need to check for and throw an excpetion for inputs that violate preconditions, otherwise the users will be frequently reporting failed test cases that are invalid. Is that planned for the release?

Thanks,
Luke


Geometry list run by mateusz at loskot.net