mirror of
https://github.com/boostorg/geometry.git
synced 2025-05-11 21:44:04 +00:00
intersection now includes isolated intersection points; exact behavior depends on the definition of related macros;
updated unit test to test for isolated intersection points as well;
This commit is contained in:
parent
0cd6e23494
commit
e11dcd9bbf
@ -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<overlay_intersection>
|
||||
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<overlay_difference>
|
||||
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);
|
||||
|
@ -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 <boost/geometry/algorithms/detail/overlay/follow.hpp>
|
||||
|
||||
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;
|
||||
}
|
||||
|
@ -72,13 +72,21 @@ BOOST_AUTO_TEST_CASE( test_intersection_linestring_linestring )
|
||||
tester()
|
||||
(from_wkt<L>("LINESTRING(0 0,20 0)"),
|
||||
from_wkt<L>("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<ML>("MULTILINESTRING((4 0,5 0))"),
|
||||
#else
|
||||
from_wkt<ML>("MULTILINESTRING((0 0),(2 0),(4 0,5 0),(6.5 0),(8 0))"),
|
||||
#endif
|
||||
"lli01-6");
|
||||
|
||||
tester()
|
||||
(from_wkt<L>("LINESTRING(-20 0,20 0)"),
|
||||
from_wkt<L>("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<ML>("MULTILINESTRING((4 0,5 0))"),
|
||||
#else
|
||||
from_wkt<ML>("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<L>("LINESTRING(0 0,2 0)"),
|
||||
from_wkt<L>("LINESTRING(2 0,5 0)"),
|
||||
#ifdef BOOST_GEOMETRY_INTERSECTION_DO_NOT_INCLUDE_ISOLATED_POINTS
|
||||
from_wkt<ML>("MULTILINESTRING()"),
|
||||
#else
|
||||
from_wkt<ML>("MULTILINESTRING((2 0))"),
|
||||
#endif
|
||||
"lli01-11");
|
||||
|
||||
tester()
|
||||
@ -257,37 +269,65 @@ BOOST_AUTO_TEST_CASE( test_intersection_linestring_linestring )
|
||||
tester()
|
||||
(from_wkt<L>("LINESTRING(0 0,10 0,20 1,30 1)"),
|
||||
from_wkt<L>("LINESTRING(1 1,2 0,3 1,20 1,25 1)"),
|
||||
#ifdef BOOST_GEOMETRY_INTERSECTION_DO_NOT_INCLUDE_ISOLATED_POINTS
|
||||
from_wkt<ML>("MULTILINESTRING((20 1,25 1))"),
|
||||
#else
|
||||
from_wkt<ML>("MULTILINESTRING((2 0),(20 1,25 1))"),
|
||||
#endif
|
||||
"lli17");
|
||||
|
||||
tester()
|
||||
(from_wkt<L>("LINESTRING(0 0,10 0,20 1,21 0,30 0)"),
|
||||
from_wkt<L>("LINESTRING(1 1,2 0,3 1,20 1,25 0)"),
|
||||
#ifdef BOOST_GEOMETRY_INTERSECTION_DO_NOT_INCLUDE_ISOLATED_POINTS
|
||||
from_wkt<ML>("MULTILINESTRING()"),
|
||||
#else
|
||||
from_wkt<ML>("MULTILINESTRING((2 0),(20 1),(25 0))"),
|
||||
#endif
|
||||
"lli18");
|
||||
|
||||
tester()
|
||||
(from_wkt<L>("LINESTRING(0 0,30 0)"),
|
||||
from_wkt<L>("LINESTRING(1 0,5 0,20 1,4 1,4 0,5 1)"),
|
||||
#ifdef BOOST_GEOMETRY_INTERSECTION_DO_NOT_INCLUDE_ISOLATED_POINTS
|
||||
from_wkt<ML>("MULTILINESTRING((1 0,5 0))"),
|
||||
#else
|
||||
from_wkt<ML>("MULTILINESTRING((1 0,5 0))"),
|
||||
from_wkt<ML>("MULTILINESTRING((1 0,5 0),(4 0))"),
|
||||
#endif
|
||||
"lli19");
|
||||
|
||||
tester()
|
||||
(from_wkt<L>("LINESTRING(0 0,30 0)"),
|
||||
from_wkt<L>("LINESTRING(5 1,4 0,4 1,20 1,5 0,1 0)"),
|
||||
#ifdef BOOST_GEOMETRY_INTERSECTION_DO_NOT_INCLUDE_ISOLATED_POINTS
|
||||
from_wkt<ML>("MULTILINESTRING((1 0,5 0))"),
|
||||
#else
|
||||
from_wkt<ML>("MULTILINESTRING((1 0,5 0))"),
|
||||
from_wkt<ML>("MULTILINESTRING((1 0,5 0),(4 0))"),
|
||||
#endif
|
||||
"lli19-r");
|
||||
|
||||
tester()
|
||||
(from_wkt<L>("LINESTRING(0 0,30 0)"),
|
||||
from_wkt<L>("LINESTRING(1 0,5 0,20 1,4 1,4 0)"),
|
||||
#ifdef BOOST_GEOMETRY_INTERSECTION_DO_NOT_INCLUDE_ISOLATED_POINTS
|
||||
from_wkt<ML>("MULTILINESTRING((1 0,5 0))"),
|
||||
#else
|
||||
from_wkt<ML>("MULTILINESTRING((1 0,5 0))"),
|
||||
from_wkt<ML>("MULTILINESTRING((1 0,5 0),(4 0))"),
|
||||
#endif
|
||||
"lli19a");
|
||||
|
||||
tester()
|
||||
(from_wkt<L>("LINESTRING(0 0,30 0)"),
|
||||
from_wkt<L>("LINESTRING(4 0,4 1,20 1,5 0,1 0)"),
|
||||
#ifdef BOOST_GEOMETRY_INTERSECTION_DO_NOT_INCLUDE_ISOLATED_POINTS
|
||||
from_wkt<ML>("MULTILINESTRING((1 0,5 0))"),
|
||||
#else
|
||||
from_wkt<ML>("MULTILINESTRING((1 0,5 0))"),
|
||||
from_wkt<ML>("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<L>("LINESTRING(0 0,30 0)"),
|
||||
from_wkt<L>("LINESTRING(1 0,5 0,20 1,4 1,5 0,5 1)"),
|
||||
#ifdef BOOST_GEOMETRY_INTERSECTION_DO_NOT_INCLUDE_ISOLATED_POINTS
|
||||
from_wkt<ML>("MULTILINESTRING((1 0,5 0))"),
|
||||
#else
|
||||
from_wkt<ML>("MULTILINESTRING((1 0,5 0))"),
|
||||
from_wkt<ML>("MULTILINESTRING((1 0,5 0),(5 0))"),
|
||||
#endif
|
||||
"lli19g");
|
||||
|
||||
tester()
|
||||
(from_wkt<L>("LINESTRING(0 0,30 0)"),
|
||||
from_wkt<L>("LINESTRING(5 1,5 0,4 1,20 1,5 0,1 0)"),
|
||||
#ifdef BOOST_GEOMETRY_INTERSECTION_DO_NOT_INCLUDE_ISOLATED_POINTS
|
||||
from_wkt<ML>("MULTILINESTRING((1 0,5 0))"),
|
||||
#else
|
||||
from_wkt<ML>("MULTILINESTRING((1 0,5 0))"),
|
||||
from_wkt<ML>("MULTILINESTRING((1 0,5 0),(5 0))"),
|
||||
#endif
|
||||
"lli19g-r");
|
||||
|
||||
tester()
|
||||
(from_wkt<L>("LINESTRING(0 0,30 0,30 30,10 30,10 -10,15 0,40 0)"),
|
||||
from_wkt<L>("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<ML>("MULTILINESTRING((20 0,25 0),(10 30,10 0),\
|
||||
(35 0,40 0),(20 0,25 0))"),
|
||||
from_wkt<ML>("MULTILINESTRING((20 0,25 0),(10 0,10 30),\
|
||||
(40 0,35 0))"),
|
||||
(40 0,35 0))"),
|
||||
#else
|
||||
from_wkt<ML>("MULTILINESTRING((10 0),(20 0,25 0),(10 30,10 0),\
|
||||
(30 20),(35 0,40 0),(20 0,25 0))"),
|
||||
from_wkt<ML>("MULTILINESTRING((10 0),(20 0,25 0),(10 0,10 30),\
|
||||
(30 20),(40 0,35 0))"),
|
||||
#endif
|
||||
"lli20");
|
||||
|
||||
tester()
|
||||
(from_wkt<L>("LINESTRING(0 0,30 0,30 30,10 30,10 -10,15 0,40 0)"),
|
||||
from_wkt<L>("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<ML>("MULTILINESTRING((15 0,30 0),(10 30,10 0),\
|
||||
(15 0,40 0))"),
|
||||
from_wkt<ML>("MULTILINESTRING((10 0,10 30),(20 0,25 0),(40 0,15 0))"),
|
||||
#else
|
||||
from_wkt<ML>("MULTILINESTRING((10 0),(15 0,30 0),(10 30,10 0),\
|
||||
(30 20),(15 0,40 0))"),
|
||||
from_wkt<ML>("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<L>("LINESTRING(0 0,18 0,19 0,30 0)"),
|
||||
from_wkt<L>("LINESTRING(2 2,5 -1,15 2,18 0,20 0)"),
|
||||
#ifdef BOOST_GEOMETRY_INTERSECTION_DO_NOT_INCLUDE_ISOLATED_POINTS
|
||||
from_wkt<ML>("MULTILINESTRING((18 0,19 0,20 0))"),
|
||||
from_wkt<ML>("MULTILINESTRING((18 0,20 0))"),
|
||||
#else
|
||||
from_wkt<ML>("MULTILINESTRING((4 0),(8.33333333333333333 0),\
|
||||
(18 0,19 0,20 0))"),
|
||||
from_wkt<ML>("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<L>("LINESTRING(0 0,1 0,2 0.5,3 0,101 0)"),
|
||||
from_wkt<ML>("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<ML>("MULTILINESTRING((3 0,101 0))"),
|
||||
#else
|
||||
from_wkt<ML>("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<L>("LINESTRING(0 0,1 0,1.5 0,2 0.5,3 0,101 0)"),
|
||||
from_wkt<ML>("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<ML>("MULTILINESTRING((1 0,1.5 0),(3 0,101 0))"),
|
||||
#else
|
||||
from_wkt<ML>("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<L>("LINESTRING(0 0,30 0)"),
|
||||
from_wkt<ML>("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<ML>("MULTILINESTRING((1 0,19 0))"),
|
||||
#else
|
||||
from_wkt<ML>("MULTILINESTRING((1 0,19 0),(25 0))"),
|
||||
#endif
|
||||
"lmli17"
|
||||
);
|
||||
|
||||
@ -544,7 +627,11 @@ BOOST_AUTO_TEST_CASE( test_intersection_linestring_multilinestring )
|
||||
(from_wkt<L>("LINESTRING(0 0,30 0)"),
|
||||
from_wkt<ML>("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<ML>("MULTILINESTRING((1 0,19 0))"),
|
||||
#else
|
||||
from_wkt<ML>("MULTILINESTRING((1 0,19 0),(25 0))"),
|
||||
#endif
|
||||
"lmli17a"
|
||||
);
|
||||
|
||||
@ -687,10 +774,17 @@ BOOST_AUTO_TEST_CASE( test_intersection_multilinestring_multilinestring )
|
||||
from_wkt<ML>("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<ML>("MULTILINESTRING((0 0,9 0),(13 3,15 5),\
|
||||
(1 0,7 0),(11 10,12 10),(15 10,20 10))"),
|
||||
from_wkt<ML>("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<ML>("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<ML>("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<ML>("MULTILINESTRING((0 0,101 0))"),
|
||||
from_wkt<ML>("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<ML>("MULTILINESTRING((1 0,101 0))"),
|
||||
#else
|
||||
from_wkt<ML>("MULTILINESTRING((1 0,101 0))"),
|
||||
from_wkt<ML>("MULTILINESTRING((2 0),(1 0,101 0))"),
|
||||
#endif
|
||||
"mlmli08"
|
||||
);
|
||||
|
||||
@ -731,7 +830,11 @@ BOOST_AUTO_TEST_CASE( test_intersection_multilinestring_multilinestring )
|
||||
(from_wkt<ML>("MULTILINESTRING((0 0,1 0,2 0.5,3 0,101 0))"),
|
||||
from_wkt<ML>("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<ML>("MULTILINESTRING((3 0,101 0))"),
|
||||
#else
|
||||
from_wkt<ML>("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<ML>("MULTILINESTRING((0 0,1 0,1.5 0,2 0.5,3 0,101 0))"),
|
||||
from_wkt<ML>("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<ML>("MULTILINESTRING((1 0,1.5 0),(3 0,101 0))"),
|
||||
#else
|
||||
from_wkt<ML>("MULTILINESTRING((1 0,1.5 0),(2 0.5),(3 0,101 0))"),
|
||||
from_wkt<ML>("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<ML>("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<ML>("MULTILINESTRING((1 1,2 1),(5 1,6 1),(9 1,10 1),\
|
||||
(13 1,14 1),(1 0,101 0))"),
|
||||
from_wkt<ML>("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<ML>("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<ML>("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<ML>("MULTILINESTRING((0 0,20 0))"),
|
||||
from_wkt<ML>("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<ML>("MULTILINESTRING((1 0,19 0))"),
|
||||
#else
|
||||
from_wkt<ML>("MULTILINESTRING((1 0,19 0))"),
|
||||
from_wkt<ML>("MULTILINESTRING((1 0,19 0),(6 0))"),
|
||||
#endif
|
||||
"mlmli15"
|
||||
);
|
||||
|
||||
@ -801,7 +922,12 @@ BOOST_AUTO_TEST_CASE( test_intersection_multilinestring_multilinestring )
|
||||
(from_wkt<ML>("MULTILINESTRING((0 0,20 0))"),
|
||||
from_wkt<ML>("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<ML>("MULTILINESTRING((1 0,19 0))"),
|
||||
#else
|
||||
from_wkt<ML>("MULTILINESTRING((1 0,19 0))"),
|
||||
from_wkt<ML>("MULTILINESTRING((1 0,19 0),(6 0))"),
|
||||
#endif
|
||||
"mlmli15a"
|
||||
);
|
||||
|
||||
@ -827,7 +953,12 @@ BOOST_AUTO_TEST_CASE( test_intersection_multilinestring_multilinestring )
|
||||
(from_wkt<ML>("MULTILINESTRING((0 0,30 0))"),
|
||||
from_wkt<ML>("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<ML>("MULTILINESTRING((1 0,19 0))"),
|
||||
#else
|
||||
from_wkt<ML>("MULTILINESTRING((1 0,19 0),(25 0))"),
|
||||
from_wkt<ML>("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<ML>("MULTILINESTRING((0 0,30 0))"),
|
||||
from_wkt<ML>("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<ML>("MULTILINESTRING((1 0,19 0))"),
|
||||
#else
|
||||
from_wkt<ML>("MULTILINESTRING((1 0,19 0),(25 0))"),
|
||||
from_wkt<ML>("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<ML>("MULTILINESTRING((0 0,30 0))"),
|
||||
from_wkt<ML>("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<ML>("MULTILINESTRING((1 0,19 0))"),
|
||||
#else
|
||||
from_wkt<ML>("MULTILINESTRING((1 0,19 0))"),
|
||||
from_wkt<ML>("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<ML>("MULTILINESTRING((0 0,18 0,19 0,30 0))"),
|
||||
from_wkt<ML>("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<ML>("MULTILINESTRING((1 0,18 0,19 0))"),
|
||||
from_wkt<ML>("MULTILINESTRING((1 0,19 0))"),
|
||||
#else
|
||||
from_wkt<ML>("MULTILINESTRING((1 0,18 0,19 0))"),
|
||||
from_wkt<ML>("MULTILINESTRING((1 0,19 0),(4 0),\
|
||||
(8.3333333333333333333 0),(18 0))"),
|
||||
#endif
|
||||
"mlmli18a"
|
||||
);
|
||||
}
|
||||
|
@ -121,8 +121,42 @@ struct multilinestring_equals
|
||||
|
||||
struct equals
|
||||
{
|
||||
template <typename LS, typename OutputIterator>
|
||||
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 <typename MLS, typename OutputIterator>
|
||||
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<MLS>::type ls;
|
||||
isolated_point_to_segment(*it, std::back_inserter(ls));
|
||||
*oit++ = ls;
|
||||
}
|
||||
else
|
||||
{
|
||||
*oit++ = *it;
|
||||
}
|
||||
}
|
||||
return oit;
|
||||
}
|
||||
|
||||
template <typename MLS1, typename MLS2>
|
||||
bool operator()(MLS1 const& mls1, MLS2 const& mls2) const
|
||||
bool are_equal(MLS1 const& mls1, MLS2 const& mls2) const
|
||||
{
|
||||
if ( multilinestring_equals<MLS1, MLS2>::apply(mls1, mls2) )
|
||||
{
|
||||
@ -145,6 +179,21 @@ struct equals
|
||||
|
||||
return multilinestring_equals<MLS1, MLS2>::apply(rmls1, rmls2);
|
||||
}
|
||||
|
||||
|
||||
template <typename MLS1, typename MLS2>
|
||||
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<Geometry2>(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
|
||||
|
Loading…
x
Reference in New Issue
Block a user