Subject: Re: [geometry] Interesection points
From: Adam Wulkiewicz (adam.wulkiewicz_at_[hidden])
Date: 2013-08-13 16:24:40
Barend Gehrels wrote:
> On 13-8-2013 9:25, Hunk wrote:
>> i am trying to get one intersection point between line polygon or line
>> i tried
>> typedef model::d2::point_xy<double> point;
>> typedef model::ring< point > ring;
>> typedef model::polygon< point > polygon;
>> typedef model::linestring< point > linestring;
>> "POLYGON((0 0,1 0, 1 1,0 1))", green);
>> linestring ls;
>> boost::geometry::read_wkt("LINESTRING(0.5 -1,0.5 0.5)", ls);
>> std::vector<point> intersections;
>> boost::geometry::intersection(green, blue, intersections);
>> but it is not working. I only want the point which is on the border.
>> Anyone has an idea for that ?
>> thank you for help. I am really new on boost.
> It should work. See for example the function void test_point_output() in
> intersection.cpp in the test-code (libs/geometry/test/algorithms). But
> your program will never compile. Where is green/blue declared? What aree
> you doing with ls?
> What is not working? Not compiling?
And if you correct compilation errors this particular example works. But
you should have in mind that model::polygon clockwiseness and closure
may be defined. Some algorithms may not work if this isn't set
correctly, see 2nd and 3rd template parameters described here:
So you should probably change the polygon type:
model::polygon<point, false, false> green; // CCW, open
boost::geometry::read_wkt("POLYGON((0 0, 1 0, 1 1, 0 1))", green);
model::polygon<point> green; // CW, closed
boost::geometry::read_wkt("POLYGON((0 0, 0 1, 1 1, 1 0, 0 0))", green);
Geometry list run by mateusz at loskot.net