diff --git a/include/boost/geometry/algorithms/detail/overlay/follow.hpp b/include/boost/geometry/algorithms/detail/overlay/follow.hpp index 56cd1bc6a..2eb5aa93d 100644 --- a/include/boost/geometry/algorithms/detail/overlay/follow.hpp +++ b/include/boost/geometry/algorithms/detail/overlay/follow.hpp @@ -1,11 +1,16 @@ // Boost.Geometry (aka GGL, Generic Geometry Library) -// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands. +// Copyright (c) 2007-2014 Barend Gehrels, Amsterdam, the Netherlands. + +// This file was modified by Oracle on 2014. +// Modifications copyright (c) 2014 Oracle and/or its affiliates. // Use, modification and distribution is subject to the Boost Software License, // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) +// Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle + #ifndef BOOST_GEOMETRY_ALGORITHMS_DETAIL_OVERLAY_FOLLOW_HPP #define BOOST_GEOMETRY_ALGORITHMS_DETAIL_OVERLAY_FOLLOW_HPP @@ -191,6 +196,30 @@ struct action_selector geometry::clear(current_piece); } + template + < + typename OutputIterator, + typename LineStringOut, + typename LineString, + typename Point, + typename Operation + > + static inline void isolated_point(LineStringOut&, + LineString const&, + segment_identifier&, + int, Point const& point, + Operation const& , OutputIterator& out) + { + LineStringOut isolated_point_ls; + geometry::append(isolated_point_ls, point); + +#ifndef BOOST_GEOMETRY_ALLOW_ONE_POINT_LINESTRINGS + geometry::append(isolated_point_ls, point); +#endif // BOOST_GEOMETRY_ALLOW_ONE_POINT_LINESTRINGS + + *out++ = isolated_point_ls; + } + static inline bool is_entered(bool entered) { return entered; @@ -246,6 +275,22 @@ struct action_selector point, operation, out); } + template + < + typename OutputIterator, + typename LineStringOut, + typename LineString, + typename Point, + typename Operation + > + static inline void isolated_point(LineStringOut&, + LineString const&, + segment_identifier&, + int, Point const&, + Operation const&, OutputIterator&) + { + } + static inline bool is_entered(bool entered) { return ! normal_action::is_entered(entered); diff --git a/include/boost/geometry/algorithms/detail/turns/follow_linear_linear.hpp b/include/boost/geometry/algorithms/detail/turns/follow_linear_linear.hpp index 8bf3b8efc..72b6d08fe 100644 --- a/include/boost/geometry/algorithms/detail/turns/follow_linear_linear.hpp +++ b/include/boost/geometry/algorithms/detail/turns/follow_linear_linear.hpp @@ -10,6 +10,8 @@ #ifndef BOOST_GEOMETRY_ALGORITHMS_DETAIL_DIFFERENCE_FOLLOW_LINEAR_LINEAR_HPP #define BOOST_GEOMETRY_ALGORITHMS_DETAIL_DIFFERENCE_FOLLOW_LINEAR_LINEAR_HPP +#include + namespace boost { namespace geometry { @@ -215,13 +217,18 @@ protected: it->point, *iit, oit); } } +#ifndef BOOST_GEOMETRY_INTERSECTION_DO_NOT_INCLUDE_ISOLATED_POINTS else if ( is_isolated_point(*it, *iit, *iit_r, entered) ) { #ifdef GEOMETRY_TEST_DEBUG - detail::overlay::debug_traverse(*it, *iit, - "-> Isolated point"); + detail::overlay::debug_traverse(*it, *iit, "-> Isolated point"); #endif + + action::isolated_point(current_piece, ls1, current_segment_id, + iit->seg_id.segment_index, + it->point, *iit, oit); } +#endif first = false; return oit; } diff --git a/test/algorithms/intersection1.cpp b/test/algorithms/intersection1.cpp index 487a21a48..aa011dce0 100644 --- a/test/algorithms/intersection1.cpp +++ b/test/algorithms/intersection1.cpp @@ -72,13 +72,21 @@ BOOST_AUTO_TEST_CASE( test_intersection_linestring_linestring ) tester() (from_wkt("LINESTRING(0 0,20 0)"), from_wkt("LINESTRING(0 0,1 1,2 0,3 1,4 0,5 0,6 1,7 -1,8 0)"), +#ifdef BOOST_GEOMETRY_INTERSECTION_DO_NOT_INCLUDE_ISOLATED_POINTS from_wkt("MULTILINESTRING((4 0,5 0))"), +#else + from_wkt("MULTILINESTRING((0 0),(2 0),(4 0,5 0),(6.5 0),(8 0))"), +#endif "lli01-6"); tester() (from_wkt("LINESTRING(-20 0,20 0)"), from_wkt("LINESTRING(0 0,1 1,2 0,3 1,4 0,5 0,6 1,7 -1,8 0)"), +#ifdef BOOST_GEOMETRY_INTERSECTION_DO_NOT_INCLUDE_ISOLATED_POINTS from_wkt("MULTILINESTRING((4 0,5 0))"), +#else + from_wkt("MULTILINESTRING((0 0),(2 0),(4 0,5 0),(6.5 0),(8 0))"), +#endif "lli01-7"); tester() @@ -96,7 +104,11 @@ BOOST_AUTO_TEST_CASE( test_intersection_linestring_linestring ) tester() (from_wkt("LINESTRING(0 0,2 0)"), from_wkt("LINESTRING(2 0,5 0)"), +#ifdef BOOST_GEOMETRY_INTERSECTION_DO_NOT_INCLUDE_ISOLATED_POINTS from_wkt("MULTILINESTRING()"), +#else + from_wkt("MULTILINESTRING((2 0))"), +#endif "lli01-11"); tester() @@ -257,37 +269,65 @@ BOOST_AUTO_TEST_CASE( test_intersection_linestring_linestring ) tester() (from_wkt("LINESTRING(0 0,10 0,20 1,30 1)"), from_wkt("LINESTRING(1 1,2 0,3 1,20 1,25 1)"), +#ifdef BOOST_GEOMETRY_INTERSECTION_DO_NOT_INCLUDE_ISOLATED_POINTS from_wkt("MULTILINESTRING((20 1,25 1))"), +#else + from_wkt("MULTILINESTRING((2 0),(20 1,25 1))"), +#endif "lli17"); tester() (from_wkt("LINESTRING(0 0,10 0,20 1,21 0,30 0)"), from_wkt("LINESTRING(1 1,2 0,3 1,20 1,25 0)"), +#ifdef BOOST_GEOMETRY_INTERSECTION_DO_NOT_INCLUDE_ISOLATED_POINTS from_wkt("MULTILINESTRING()"), +#else + from_wkt("MULTILINESTRING((2 0),(20 1),(25 0))"), +#endif "lli18"); tester() (from_wkt("LINESTRING(0 0,30 0)"), from_wkt("LINESTRING(1 0,5 0,20 1,4 1,4 0,5 1)"), +#ifdef BOOST_GEOMETRY_INTERSECTION_DO_NOT_INCLUDE_ISOLATED_POINTS from_wkt("MULTILINESTRING((1 0,5 0))"), +#else + from_wkt("MULTILINESTRING((1 0,5 0))"), + from_wkt("MULTILINESTRING((1 0,5 0),(4 0))"), +#endif "lli19"); tester() (from_wkt("LINESTRING(0 0,30 0)"), from_wkt("LINESTRING(5 1,4 0,4 1,20 1,5 0,1 0)"), +#ifdef BOOST_GEOMETRY_INTERSECTION_DO_NOT_INCLUDE_ISOLATED_POINTS from_wkt("MULTILINESTRING((1 0,5 0))"), +#else + from_wkt("MULTILINESTRING((1 0,5 0))"), + from_wkt("MULTILINESTRING((1 0,5 0),(4 0))"), +#endif "lli19-r"); tester() (from_wkt("LINESTRING(0 0,30 0)"), from_wkt("LINESTRING(1 0,5 0,20 1,4 1,4 0)"), +#ifdef BOOST_GEOMETRY_INTERSECTION_DO_NOT_INCLUDE_ISOLATED_POINTS from_wkt("MULTILINESTRING((1 0,5 0))"), +#else + from_wkt("MULTILINESTRING((1 0,5 0))"), + from_wkt("MULTILINESTRING((1 0,5 0),(4 0))"), +#endif "lli19a"); tester() (from_wkt("LINESTRING(0 0,30 0)"), from_wkt("LINESTRING(4 0,4 1,20 1,5 0,1 0)"), +#ifdef BOOST_GEOMETRY_INTERSECTION_DO_NOT_INCLUDE_ISOLATED_POINTS from_wkt("MULTILINESTRING((1 0,5 0))"), +#else + from_wkt("MULTILINESTRING((1 0,5 0))"), + from_wkt("MULTILINESTRING((1 0,5 0),(4 0))"), +#endif "lli19a-r"); tester() @@ -335,30 +375,54 @@ BOOST_AUTO_TEST_CASE( test_intersection_linestring_linestring ) tester() (from_wkt("LINESTRING(0 0,30 0)"), from_wkt("LINESTRING(1 0,5 0,20 1,4 1,5 0,5 1)"), +#ifdef BOOST_GEOMETRY_INTERSECTION_DO_NOT_INCLUDE_ISOLATED_POINTS from_wkt("MULTILINESTRING((1 0,5 0))"), +#else + from_wkt("MULTILINESTRING((1 0,5 0))"), + from_wkt("MULTILINESTRING((1 0,5 0),(5 0))"), +#endif "lli19g"); tester() (from_wkt("LINESTRING(0 0,30 0)"), from_wkt("LINESTRING(5 1,5 0,4 1,20 1,5 0,1 0)"), +#ifdef BOOST_GEOMETRY_INTERSECTION_DO_NOT_INCLUDE_ISOLATED_POINTS from_wkt("MULTILINESTRING((1 0,5 0))"), +#else + from_wkt("MULTILINESTRING((1 0,5 0))"), + from_wkt("MULTILINESTRING((1 0,5 0),(5 0))"), +#endif "lli19g-r"); tester() (from_wkt("LINESTRING(0 0,30 0,30 30,10 30,10 -10,15 0,40 0)"), from_wkt("LINESTRING(5 5,10 0,10 30,20 0,25 0,25 25,50 0,35 0)"), +#ifdef BOOST_GEOMETRY_INTERSECTION_DO_NOT_INCLUDE_ISOLATED_POINTS from_wkt("MULTILINESTRING((20 0,25 0),(10 30,10 0),\ (35 0,40 0),(20 0,25 0))"), from_wkt("MULTILINESTRING((20 0,25 0),(10 0,10 30),\ - (40 0,35 0))"), + (40 0,35 0))"), +#else + from_wkt("MULTILINESTRING((10 0),(20 0,25 0),(10 30,10 0),\ + (30 20),(35 0,40 0),(20 0,25 0))"), + from_wkt("MULTILINESTRING((10 0),(20 0,25 0),(10 0,10 30),\ + (30 20),(40 0,35 0))"), +#endif "lli20"); tester() (from_wkt("LINESTRING(0 0,30 0,30 30,10 30,10 -10,15 0,40 0)"), from_wkt("LINESTRING(5 5,10 0,10 30,20 0,25 0,25 25,50 0,15 0)"), +#ifdef BOOST_GEOMETRY_INTERSECTION_DO_NOT_INCLUDE_ISOLATED_POINTS from_wkt("MULTILINESTRING((15 0,30 0),(10 30,10 0),\ (15 0,40 0))"), from_wkt("MULTILINESTRING((10 0,10 30),(20 0,25 0),(40 0,15 0))"), +#else + from_wkt("MULTILINESTRING((10 0),(15 0,30 0),(10 30,10 0),\ + (30 20),(15 0,40 0))"), + from_wkt("MULTILINESTRING((10 0),(10 0,10 30),(20 0,25 0),\ + (30 20),(40 0,15 0))"), +#endif "lli20a"); #if !defined(BOOST_GEOMETRY_DIFFERENCE_DO_NOT_REMOVE_DUPLICATE_TURNS) \ @@ -368,8 +432,15 @@ BOOST_AUTO_TEST_CASE( test_intersection_linestring_linestring ) tester() (from_wkt("LINESTRING(0 0,18 0,19 0,30 0)"), from_wkt("LINESTRING(2 2,5 -1,15 2,18 0,20 0)"), +#ifdef BOOST_GEOMETRY_INTERSECTION_DO_NOT_INCLUDE_ISOLATED_POINTS from_wkt("MULTILINESTRING((18 0,19 0,20 0))"), from_wkt("MULTILINESTRING((18 0,20 0))"), +#else + from_wkt("MULTILINESTRING((4 0),(8.33333333333333333 0),\ + (18 0,19 0,20 0))"), + from_wkt("MULTILINESTRING((4 0),(8.33333333333333333 0),\ + (18 0,20 0))"), +#endif "lli21" ); #endif @@ -462,7 +533,11 @@ BOOST_AUTO_TEST_CASE( test_intersection_linestring_multilinestring ) (from_wkt("LINESTRING(0 0,1 0,2 0.5,3 0,101 0)"), from_wkt("MULTILINESTRING((0 1,1 1,2 0.5),\ (-1 -1,1 0,101 0,200 -1))"), +#ifdef BOOST_GEOMETRY_INTERSECTION_DO_NOT_INCLUDE_ISOLATED_POINTS from_wkt("MULTILINESTRING((3 0,101 0))"), +#else + from_wkt("MULTILINESTRING((1 0),(2 0.5),(3 0,101 0))"), +#endif "lmli09" ); @@ -470,7 +545,11 @@ BOOST_AUTO_TEST_CASE( test_intersection_linestring_multilinestring ) (from_wkt("LINESTRING(0 0,1 0,1.5 0,2 0.5,3 0,101 0)"), from_wkt("MULTILINESTRING((0 1,1 1,1 0,2 0.5),\ (-1 -1,1 0,101 0,200 -1))"), +#ifdef BOOST_GEOMETRY_INTERSECTION_DO_NOT_INCLUDE_ISOLATED_POINTS from_wkt("MULTILINESTRING((1 0,1.5 0),(3 0,101 0))"), +#else + from_wkt("MULTILINESTRING((1 0),(2 0.5),(1 0,1.5 0),(3 0,101 0))"), +#endif "lmli10" ); @@ -536,7 +615,11 @@ BOOST_AUTO_TEST_CASE( test_intersection_linestring_multilinestring ) (from_wkt("LINESTRING(0 0,30 0)"), from_wkt("MULTILINESTRING((0 1,1 0,19 0,20 1),\ (2 2,4 0,5 2,20 2,25 0))"), +#ifdef BOOST_GEOMETRY_INTERSECTION_DO_NOT_INCLUDE_ISOLATED_POINTS from_wkt("MULTILINESTRING((1 0,19 0))"), +#else + from_wkt("MULTILINESTRING((1 0,19 0),(25 0))"), +#endif "lmli17" ); @@ -544,7 +627,11 @@ BOOST_AUTO_TEST_CASE( test_intersection_linestring_multilinestring ) (from_wkt("LINESTRING(0 0,30 0)"), from_wkt("MULTILINESTRING((0 1,1 0,19 0,20 1),\ (2 2,4 0,5 2,20 2,25 0,26 2))"), +#ifdef BOOST_GEOMETRY_INTERSECTION_DO_NOT_INCLUDE_ISOLATED_POINTS from_wkt("MULTILINESTRING((1 0,19 0))"), +#else + from_wkt("MULTILINESTRING((1 0,19 0),(25 0))"), +#endif "lmli17a" ); @@ -687,10 +774,17 @@ BOOST_AUTO_TEST_CASE( test_intersection_multilinestring_multilinestring ) from_wkt("MULTILINESTRING((1 1,2 0,4 0),\ (-1 -1,0 0,9 0,11 10,12 10,13 3,14 4,15 5),\ (10 20,15 10,25 10,30 15))"), +#ifdef BOOST_GEOMETRY_INTERSECTION_DO_NOT_INCLUDE_ISOLATED_POINTS from_wkt("MULTILINESTRING((0 0,9 0),(13 3,15 5),\ (1 0,7 0),(11 10,12 10),(15 10,20 10))"), from_wkt("MULTILINESTRING((2 0,4 0),(0 0,9 0),(13 3,14 4,15 5),\ (11 10,12 10),(15 10,20 10))"), +#else + from_wkt("MULTILINESTRING((0 0,9 0),(13 3,15 5),(20 10),\ + (1 0,7 0),(11 10,12 10),(15 10,20 10))"), + from_wkt("MULTILINESTRING((2 0,4 0),(0 0,9 0),(13 3,14 4,15 5),\ + (11 10,12 10),(15 10,20 10))"), +#endif "mlmli06" ); @@ -723,7 +817,12 @@ BOOST_AUTO_TEST_CASE( test_intersection_multilinestring_multilinestring ) (from_wkt("MULTILINESTRING((0 0,101 0))"), from_wkt("MULTILINESTRING((0 1,1 1,2 0),\ (-1 -1,1 0,101 0,200 -1))"), +#ifdef BOOST_GEOMETRY_INTERSECTION_DO_NOT_INCLUDE_ISOLATED_POINTS from_wkt("MULTILINESTRING((1 0,101 0))"), +#else + from_wkt("MULTILINESTRING((1 0,101 0))"), + from_wkt("MULTILINESTRING((2 0),(1 0,101 0))"), +#endif "mlmli08" ); @@ -731,7 +830,11 @@ BOOST_AUTO_TEST_CASE( test_intersection_multilinestring_multilinestring ) (from_wkt("MULTILINESTRING((0 0,1 0,2 0.5,3 0,101 0))"), from_wkt("MULTILINESTRING((0 1,1 1,2 0.5),\ (-1 -1,1 0,101 0,200 -1))"), +#ifdef BOOST_GEOMETRY_INTERSECTION_DO_NOT_INCLUDE_ISOLATED_POINTS from_wkt("MULTILINESTRING((3 0,101 0))"), +#else + from_wkt("MULTILINESTRING((1 0),(2 0.5),(3 0,101 0))"), +#endif "mlmli09" ); @@ -739,7 +842,12 @@ BOOST_AUTO_TEST_CASE( test_intersection_multilinestring_multilinestring ) (from_wkt("MULTILINESTRING((0 0,1 0,1.5 0,2 0.5,3 0,101 0))"), from_wkt("MULTILINESTRING((0 1,1 1,1 0,2 0.5),\ (-1 -1,1 0,101 0,200 -1))"), +#ifdef BOOST_GEOMETRY_INTERSECTION_DO_NOT_INCLUDE_ISOLATED_POINTS from_wkt("MULTILINESTRING((1 0,1.5 0),(3 0,101 0))"), +#else + from_wkt("MULTILINESTRING((1 0,1.5 0),(2 0.5),(3 0,101 0))"), + from_wkt("MULTILINESTRING((1 0),(1 0,1.5 0),(2 0.5),(3 0,101 0))"), +#endif "mlmli10" ); @@ -749,11 +857,19 @@ BOOST_AUTO_TEST_CASE( test_intersection_multilinestring_multilinestring ) from_wkt("MULTILINESTRING((1 0,1 1,2 1,3 0,4 0,5 1,6 1,\ 7 0,8 0,9 1,10 1,11 0,12 0,13 1,14 1,15 0),\ (-1 -1,1 0,101 0,200 -1))"), +#ifdef BOOST_GEOMETRY_INTERSECTION_DO_NOT_INCLUDE_ISOLATED_POINTS from_wkt("MULTILINESTRING((1 1,2 1),(5 1,6 1),(9 1,10 1),\ (13 1,14 1),(1 0,101 0))"), from_wkt("MULTILINESTRING((1 1,2 1),(5 1,6 1),(9 1,10 1),\ (13 1,14 1),(3 0,4 0),(7 0,8 0),(11 0,12 0),\ (1 0,101 0))"), +#else + from_wkt("MULTILINESTRING((1 1,2 1),(5 1,6 1),(9 1,10 1),\ + (13 1,14 1),(101 0),(1 0),(1 0,101 0))"), + from_wkt("MULTILINESTRING((1 0),(1 1,2 1),(5 1,6 1),(9 1,10 1),\ + (13 1,14 1),(3 0,4 0),(7 0,8 0),(11 0,12 0),(15 0),\ + (1 0,101 0))"), +#endif "mlmli11" ); @@ -793,7 +909,12 @@ BOOST_AUTO_TEST_CASE( test_intersection_multilinestring_multilinestring ) (from_wkt("MULTILINESTRING((0 0,20 0))"), from_wkt("MULTILINESTRING((0 1,1 0,19 0,20 1),\ (2 2,4 2,6 0))"), +#ifdef BOOST_GEOMETRY_INTERSECTION_DO_NOT_INCLUDE_ISOLATED_POINTS from_wkt("MULTILINESTRING((1 0,19 0))"), +#else + from_wkt("MULTILINESTRING((1 0,19 0))"), + from_wkt("MULTILINESTRING((1 0,19 0),(6 0))"), +#endif "mlmli15" ); @@ -801,7 +922,12 @@ BOOST_AUTO_TEST_CASE( test_intersection_multilinestring_multilinestring ) (from_wkt("MULTILINESTRING((0 0,20 0))"), from_wkt("MULTILINESTRING((0 1,1 0,19 0,20 1),\ (6 0,4 2,2 2))"), +#ifdef BOOST_GEOMETRY_INTERSECTION_DO_NOT_INCLUDE_ISOLATED_POINTS from_wkt("MULTILINESTRING((1 0,19 0))"), +#else + from_wkt("MULTILINESTRING((1 0,19 0))"), + from_wkt("MULTILINESTRING((1 0,19 0),(6 0))"), +#endif "mlmli15a" ); @@ -827,7 +953,12 @@ BOOST_AUTO_TEST_CASE( test_intersection_multilinestring_multilinestring ) (from_wkt("MULTILINESTRING((0 0,30 0))"), from_wkt("MULTILINESTRING((0 1,1 0,19 0,20 1),\ (2 2,4 0,5 2,20 2,25 0))"), +#ifdef BOOST_GEOMETRY_INTERSECTION_DO_NOT_INCLUDE_ISOLATED_POINTS from_wkt("MULTILINESTRING((1 0,19 0))"), +#else + from_wkt("MULTILINESTRING((1 0,19 0),(25 0))"), + from_wkt("MULTILINESTRING((1 0,19 0),(4 0),(25 0))"), +#endif "mlmli17" ); @@ -835,7 +966,12 @@ BOOST_AUTO_TEST_CASE( test_intersection_multilinestring_multilinestring ) (from_wkt("MULTILINESTRING((0 0,30 0))"), from_wkt("MULTILINESTRING((0 1,1 0,19 0,20 1),\ (2 2,4 0,5 2,20 2,25 0,26 2))"), +#ifdef BOOST_GEOMETRY_INTERSECTION_DO_NOT_INCLUDE_ISOLATED_POINTS from_wkt("MULTILINESTRING((1 0,19 0))"), +#else + from_wkt("MULTILINESTRING((1 0,19 0),(25 0))"), + from_wkt("MULTILINESTRING((1 0,19 0),(4 0),(25 0))"), +#endif "mlmli17a" ); @@ -843,7 +979,13 @@ BOOST_AUTO_TEST_CASE( test_intersection_multilinestring_multilinestring ) (from_wkt("MULTILINESTRING((0 0,30 0))"), from_wkt("MULTILINESTRING((0 1,1 0,19 0,20 1),\ (2 2,5 -1,15 2,18 0))"), +#ifdef BOOST_GEOMETRY_INTERSECTION_DO_NOT_INCLUDE_ISOLATED_POINTS from_wkt("MULTILINESTRING((1 0,19 0))"), +#else + from_wkt("MULTILINESTRING((1 0,19 0))"), + from_wkt("MULTILINESTRING((1 0,19 0),(4 0),\ + (8.3333333333333333333 0),(18 0))"), +#endif "mlmli18" ); @@ -851,8 +993,14 @@ BOOST_AUTO_TEST_CASE( test_intersection_multilinestring_multilinestring ) (from_wkt("MULTILINESTRING((0 0,18 0,19 0,30 0))"), from_wkt("MULTILINESTRING((0 1,1 0,19 0,20 1),\ (2 2,5 -1,15 2,18 0))"), +#ifdef BOOST_GEOMETRY_INTERSECTION_DO_NOT_INCLUDE_ISOLATED_POINTS from_wkt("MULTILINESTRING((1 0,18 0,19 0))"), from_wkt("MULTILINESTRING((1 0,19 0))"), +#else + from_wkt("MULTILINESTRING((1 0,18 0,19 0))"), + from_wkt("MULTILINESTRING((1 0,19 0),(4 0),\ + (8.3333333333333333333 0),(18 0))"), +#endif "mlmli18a" ); } diff --git a/test/algorithms/test_intersection1.hpp b/test/algorithms/test_intersection1.hpp index a4dc3caf0..04c606b7e 100644 --- a/test/algorithms/test_intersection1.hpp +++ b/test/algorithms/test_intersection1.hpp @@ -121,8 +121,42 @@ struct multilinestring_equals struct equals { + template + OutputIterator + isolated_point_to_segment(LS const& ls, OutputIterator oit) const + { + BOOST_ASSERT( boost::size(ls) == 1 ); + + *oit++ = *boost::begin(ls); + *oit++ = *boost::begin(ls); + return oit; + } + + template + OutputIterator + convert_isolated_points_to_segments(MLS const& mls, + OutputIterator oit) const + { + BOOST_AUTO_TPL(it, boost::begin(mls)); + + for (; it != boost::end(mls); ++it) + { + if ( boost::size(*it) == 1 ) + { + typename boost::range_value::type ls; + isolated_point_to_segment(*it, std::back_inserter(ls)); + *oit++ = ls; + } + else + { + *oit++ = *it; + } + } + return oit; + } + template - bool operator()(MLS1 const& mls1, MLS2 const& mls2) const + bool are_equal(MLS1 const& mls1, MLS2 const& mls2) const { if ( multilinestring_equals::apply(mls1, mls2) ) { @@ -145,6 +179,21 @@ struct equals return multilinestring_equals::apply(rmls1, rmls2); } + + + template + bool operator()(MLS1 const& mls1, MLS2 const& mls2) const + { +#ifndef BOOST_GEOMETRY_ALLOW_ONE_POINT_LINESTRINGS + MLS1 mls1c; + convert_isolated_points_to_segments(mls1, std::back_inserter(mls1c)); + MLS2 mls2c; + convert_isolated_points_to_segments(mls2, std::back_inserter(mls2c)); + return are_equal(mls1c, mls2c); +#else + return are_equal(mls1, mls2); +#endif + } }; @@ -285,11 +334,14 @@ struct test_intersection_of_geometries Geometry2 rg2(geometry2); bg::reverse(rg2); +#if 1 + base_test(geometry1, geometry2, mls_int1, mls_int2); +#else base_test(geometry1, geometry2, mls_int1, mls_int2, true); base_test(geometry1, rg2, mls_int1, mls_int2); base_test(rg1, geometry2, mls_int1, mls_int2); base_test(rg1, rg2, mls_int1, mls_int2); - +#endif base_test_all(geometry1, geometry2); #ifdef GEOMETRY_TEST_DEBUG