From e8b5e64f2bd068fc313d8a2af83886c07da04f1d Mon Sep 17 00:00:00 2001 From: Adam Wulkiewicz Date: Thu, 27 Feb 2014 15:20:51 +0100 Subject: [PATCH] added empty test for get_turns(L,A) and some small changes like naming, comments. to_svg() (test debug helper tool) is now using turn_info defined in relate::turns, also traversal info output commented out. --- .../algorithms/detail/overlay/get_turns.hpp | 11 + .../algorithms/detail/relate/turns.hpp | 4 +- .../overlay/get_turns_linear_areal.cpp | 195 ++++++++++++++++++ .../overlay/get_turns_linear_linear.cpp | 139 +------------ test/algorithms/overlay/test_get_turns.hpp | 159 ++++++++++++++ test/to_svg.hpp | 37 ++-- 6 files changed, 387 insertions(+), 158 deletions(-) create mode 100644 test/algorithms/overlay/get_turns_linear_areal.cpp create mode 100644 test/algorithms/overlay/test_get_turns.hpp diff --git a/include/boost/geometry/algorithms/detail/overlay/get_turns.hpp b/include/boost/geometry/algorithms/detail/overlay/get_turns.hpp index 581ef7bc1..40f8e6f2c 100644 --- a/include/boost/geometry/algorithms/detail/overlay/get_turns.hpp +++ b/include/boost/geometry/algorithms/detail/overlay/get_turns.hpp @@ -766,6 +766,11 @@ struct get_turn_info_type {}; +//template +//struct get_turn_info_type +// : overlay::get_turn_info_linear_linear +//{}; + template ::type, typename Tag2 = typename tag::type, typename TagBase1 = typename tag_base::type, typename TagBase2 = typename tag_base::type> @@ -780,6 +785,12 @@ struct turn_operation_type +//struct turn_operation_type +//{ +// typedef overlay::turn_operation_linear type; +//}; + }} // namespace detail::get_turns #endif // DOXYGEN_NO_DETAIL diff --git a/include/boost/geometry/algorithms/detail/relate/turns.hpp b/include/boost/geometry/algorithms/detail/relate/turns.hpp index bc5249595..f74003ead 100644 --- a/include/boost/geometry/algorithms/detail/relate/turns.hpp +++ b/include/boost/geometry/algorithms/detail/relate/turns.hpp @@ -60,7 +60,7 @@ struct enriched_info // linear_enriched_info ? }; template -struct enriched_turn_operation : public overlay::turn_operation_linear +struct enriched_turn_operation_linear : public overlay::turn_operation_linear { enriched_info

enriched; }; @@ -80,7 +80,7 @@ struct get_turns typedef overlay::turn_info < point1_type, - enriched_turn_operation + enriched_turn_operation_linear > turn_info; template diff --git a/test/algorithms/overlay/get_turns_linear_areal.cpp b/test/algorithms/overlay/get_turns_linear_areal.cpp new file mode 100644 index 000000000..dfd2e26ef --- /dev/null +++ b/test/algorithms/overlay/get_turns_linear_areal.cpp @@ -0,0 +1,195 @@ +// Boost.Geometry (aka GGL, Generic Geometry Library) +// Unit Test + +// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands. +// Copyright (c) 2008-2012 Bruno Lalande, Paris, France. +// Copyright (c) 2009-2012 Mateusz Loskot, London, UK. + +// This file was modified by Oracle on 2014. +// Modifications copyright (c) 2014 Oracle and/or its affiliates. + +// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library +// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands. + +// 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 Adam Wulkiewicz, on behalf of Oracle + +#include "test_get_turns.hpp" +#include + +//TEST +#include +//#include +//#include + +template +void test_all() +{ + typedef bg::model::point pt; + typedef bg::model::linestring ls; + typedef bg::model::polygon poly; + + to_svg("LINESTRING(15 5,24 5,13 -4,13 10,10 10,8 10,4 6,2 8,1 10)", + "POLYGON((0 0,5 5,0 10,20 10,20 0,0 0)(10 3,15 3,15 7,10 7,10 3))", + "ls_poly.svg"); + to_svg("POLYGON((0 0,5 5,0 10,20 10,20 0,0 0)(10 3,15 3,15 7,10 7,10 3))", + "LINESTRING(15 5,24 5,13 -4,13 10,10 10,8 10,4 6,2 8,1 10)", + "poly_ls.svg"); +} + +int test_main(int, char* []) +{ + test_all(); + test_all(); + +#if ! defined(_MSC_VER) + test_all(); +#endif + +#if defined(HAVE_TTMATH) + test_all(); +#endif + return 0; +} + +/* +to_svg("LINESTRING(0 0,2 0)", "LINESTRING(1 0,3 0)", "lsls0000.svg"); +to_svg("LINESTRING(1 0,3 0)", "LINESTRING(2 0,0 0)", "lsls0001.svg"); +to_svg("LINESTRING(0 0,2 0)", "LINESTRING(3 0,1 0)", "lsls0002.svg"); + +to_svg("LINESTRING(0 0,1 0)", "LINESTRING(1 0,2 0)", "lsls0003.svg"); +to_svg("LINESTRING(0 0,1 0)", "LINESTRING(2 0,1 0)", "lsls0004.svg"); +to_svg("LINESTRING(1 0,2 0)", "LINESTRING(1 0,0 0)", "lsls0005.svg"); + +to_svg("LINESTRING(0 0,2 0)", "LINESTRING(0 0,2 0)", "lsls0006.svg"); +to_svg("LINESTRING(0 0,2 0)", "LINESTRING(2 0,0 0)", "lsls0007.svg"); + +to_svg("LINESTRING(0 0,3 0)", "LINESTRING(1 0,2 0)", "lsls0008.svg"); +to_svg("LINESTRING(0 0,3 0)", "LINESTRING(2 0,1 0)", "lsls0009.svg"); + +to_svg("LINESTRING(0 0,1 0)", "LINESTRING(1 0,1 1)", "lsls00010.svg"); +to_svg("LINESTRING(0 0,1 0)", "LINESTRING(1 1,1 0)", "lsls00011.svg"); +to_svg("LINESTRING(0 0,1 0)", "LINESTRING(0 0,0 1)", "lsls00012.svg"); +to_svg("LINESTRING(0 0,1 0)", "LINESTRING(0 1,0 0)", "lsls00013.svg"); +to_svg("LINESTRING(0 0,2 0)", "LINESTRING(1 0,1 1)", "lsls00014.svg"); +to_svg("LINESTRING(0 0,2 0)", "LINESTRING(1 1,1 0)", "lsls00015.svg"); + +to_svg("LINESTRING(0 0,2 0)", "LINESTRING(1 0,3 1)", "lsls00016.svg"); + +to_svg("LINESTRING(0 0,2 0)", "LINESTRING(2 0,1 0)", "lsls00017.svg"); +to_svg("LINESTRING(0 0,2 0)", "LINESTRING(0 0,1 0)", "lsls00018.svg"); +to_svg("LINESTRING(0 0,2 0)", "LINESTRING(1 0,0 0)", "lsls00019.svg"); +to_svg("LINESTRING(0 0,2 0)", "LINESTRING(1 0,2 0)", "lsls00020.svg"); + +to_svg("LINESTRING(0 0,2 0)", "LINESTRING(0 0,2 0)", "lsls000.svg"); +to_svg("LINESTRING(0 0,2 0,2 0,3 0)", "LINESTRING(0 0,2 0)", "lsls001.svg"); +to_svg("LINESTRING(1 0,1 1)", "LINESTRING(0 0,1 0,2 0)", "lsls0020.svg"); +to_svg("LINESTRING(1 0,0 0)", "LINESTRING(0 0,1 0,2 0)", "lsls0021.svg"); +to_svg("LINESTRING(1 0,2 0)", "LINESTRING(0 0,1 0,2 0)", "lsls0022.svg"); +to_svg("LINESTRING(1 1,1 0)", "LINESTRING(0 0,1 0,2 0)", "lsls0023.svg"); +to_svg("LINESTRING(0 0,1 0)", "LINESTRING(0 0,1 0,2 0)", "lsls0024.svg"); +to_svg("LINESTRING(2 0,1 0)", "LINESTRING(0 0,1 0,2 0)", "lsls0025.svg"); +to_svg("LINESTRING(0 0,1 0,2 0)", "LINESTRING(1 0,1 1)", "lsls00200.svg"); +to_svg("LINESTRING(0 0,1 0,2 0)", "LINESTRING(1 0,0 0)", "lsls00211.svg"); +to_svg("LINESTRING(0 0,1 0,2 0)", "LINESTRING(1 0,2 0)", "lsls00222.svg"); +to_svg("LINESTRING(0 0,1 0,2 0)", "LINESTRING(1 1,1 0)", "lsls00233.svg"); +to_svg("LINESTRING(0 0,1 0,2 0)", "LINESTRING(0 0,1 0)", "lsls00244.svg"); +to_svg("LINESTRING(0 0,1 0,2 0)", "LINESTRING(2 0,1 0)", "lsls00255.svg"); + +to_svg("LINESTRING(0 0,2 0,4 0,6 0,8 0)", "LINESTRING(1 0,3 0,5 0,6 0,9 0)", "lsls01.svg"); +to_svg("LINESTRING(0 0,2 0,4 0,4 4)", "LINESTRING(1 0,3 0,4 0,4 2,4 5)", "lsls02.svg"); +to_svg("LINESTRING(0 0,2 0,4 0,4 4)", "LINESTRING(1 0,4 0,4 4)", "lsls031.svg"); +to_svg("LINESTRING(0 0,2 0,4 0,4 4)", "LINESTRING(4 0,2 0,0 0)", "lsls032.svg"); +to_svg("LINESTRING(0 0,2 0,4 0,4 4)", "LINESTRING(4 0,2 2,0 2)", "lsls0321.svg"); +to_svg("LINESTRING(0 0,2 0,4 0,4 4)", "LINESTRING(4 0,2 0)", "lsls033.svg"); +to_svg("LINESTRING(0 0,2 0,4 0,4 4)", "LINESTRING(4 0,4 4)", "lsls034.svg"); +to_svg("LINESTRING(0 0,2 0,4 0,4 4)", "LINESTRING(4 0,3 1)", "lsls035.svg"); +to_svg("LINESTRING(0 0,2 0,4 0,4 4)", "LINESTRING(4 0,4 -1)", "lsls036.svg"); +to_svg("LINESTRING(0 0,2 0,4 0,4 4)", "LINESTRING(1 0,4 0,4 3)", "lsls04.svg"); +to_svg("LINESTRING(1 0,2 0,4 0,6 0,8 0)", "LINESTRING(0 0,3 0,5 0,6 0,9 0)", "lsls05.svg"); + +to_svg("LINESTRING(0 0,10 0,10 10)", "LINESTRING(1 0,10 9)", "lsls061.svg"); +to_svg("LINESTRING(0 0,10 0,10 10)", "LINESTRING(1 0,10 -9)", "lsls062.svg"); +to_svg("LINESTRING(0 0,10 0,10 10)", "LINESTRING(1 0,-10 9)", "lsls063.svg"); +to_svg("LINESTRING(0 0,10 0,10 10)", "LINESTRING(1 0,-10 -9)", "lsls064.svg"); +to_svg("LINESTRING(0 0,1 0,10 9,10 10)", "LINESTRING(1 0,10 9)", "lsls065.svg"); +to_svg("LINESTRING(0 0,10 0,10 10)", "LINESTRING(1 0,9 9)", "lsls071.svg"); +to_svg("LINESTRING(0 0,10 0,10 10)", "LINESTRING(1 0,9 -9)", "lsls072.svg"); +to_svg("LINESTRING(0 0,10 0,10 10)", "LINESTRING(1 0,-9 9)", "lsls073.svg"); +to_svg("LINESTRING(0 0,10 0,10 10)", "LINESTRING(1 0,-9 -9)", "lsls074.svg"); +to_svg("LINESTRING(0 0,1 0,10 0,10 10)", "LINESTRING(1 0,9 9)", "lsls081.svg"); +to_svg("LINESTRING(0 0,1 0,10 0,10 10)", "LINESTRING(0 0,9 9)", "lsls082.svg"); +to_svg("LINESTRING(0 0,1 0)", "LINESTRING(1 0,9 9)", "lsls083.svg"); +to_svg("LINESTRING(0 0,1 0)", "LINESTRING(9 9,1 0)", "lsls084.svg"); +to_svg("LINESTRING(0 0,1 0)", "LINESTRING(1 0,2 0)", "lsls085.svg"); +to_svg("LINESTRING(0 0,1 0)", "LINESTRING(2 0,1 0)", "lsls086.svg"); +to_svg("LINESTRING(0 0,10 0,10 10)", "LINESTRING(1 1,10 5)", "lsls091.svg"); +to_svg("LINESTRING(0 0,10 0,10 5,10 10)", "LINESTRING(1 1,10 5)", "lsls092.svg"); +to_svg("LINESTRING(0 0,10 0,10 10)", "LINESTRING(19 1,10 5)", "lsls093.svg"); +to_svg("LINESTRING(0 0,10 0,10 5,10 10)", "LINESTRING(19 1,10 5)", "lsls094.svg"); + +to_svg("LINESTRING(5 3,1 1,3 3,2 2,0 0)", "LINESTRING(0 0,3 3,6 3)", "1F100F10T.svg"); + +to_svg("LINESTRING(0 0,2 0,4 0)", "LINESTRING(1 1,1 0,3 0,3 1)", "lsls_01.svg"); +to_svg("LINESTRING(0 0,2 0,4 0)", "LINESTRING(1 -1,1 0,3 0,3 -1)", "lsls_02.svg"); +to_svg("LINESTRING(0 0,2 0,4 0)", "LINESTRING(3 1,3 0,1 0,1 1)", "lsls_03.svg"); +to_svg("LINESTRING(0 0,2 0,4 0)", "LINESTRING(3 -1,3 0,1 0,1 -1)", "lsls_04.svg"); +to_svg("LINESTRING(0 0,2 0,3 0,4 0,6 0)", "LINESTRING(2 1,2 0,4 0,4 1)", "lsls_05.svg"); +to_svg("LINESTRING(0 0,2 0,3 0,4 0,6 0)", "LINESTRING(2 -1,2 0,4 0,4 -1)", "lsls_06.svg"); +to_svg("LINESTRING(0 0,2 0,3 0,4 0,6 0)", "LINESTRING(4 1,4 0,2 0,2 1)", "lsls_07.svg"); +to_svg("LINESTRING(0 0,2 0,3 0,4 0,6 0)", "LINESTRING(4 -1,4 0,2 0,2 -1)", "lsls_08.svg"); + +to_svg("LINESTRING(0 0,2 0,4 0)", "LINESTRING(1 1,1 0,2 0,3 0,3 1)", "lsls_11.svg"); +to_svg("LINESTRING(0 0,2 0,4 0)", "LINESTRING(1 -1,1 0,2 0,3 0,3 -1)", "lsls_12.svg"); +to_svg("LINESTRING(0 0,2 0,4 0)", "LINESTRING(3 1,3 0,2 0,1 0,1 1)", "lsls_13.svg"); +to_svg("LINESTRING(0 0,2 0,4 0)", "LINESTRING(3 -1,3 0,2 0,1 0,1 -1)", "lsls_14.svg"); +to_svg("LINESTRING(0 0,2 0,3 0,4 0,6 0)", "LINESTRING(2 1,2 0,3 0,4 0,4 1)", "lsls_15.svg"); +to_svg("LINESTRING(0 0,2 0,3 0,4 0,6 0)", "LINESTRING(2 -1,2 0,3 0,4 0,4 -1)", "lsls_16.svg"); +to_svg("LINESTRING(0 0,2 0,3 0,4 0,6 0)", "LINESTRING(4 1,4 0,3 0,2 0,2 1)", "lsls_17.svg"); +to_svg("LINESTRING(0 0,2 0,3 0,4 0,6 0)", "LINESTRING(4 -1,4 0,3 0,2 0,2 -1)", "lsls_18.svg"); + +to_svg("LINESTRING(0 5,5 5,10 5,10 10,5 10,5 5,5 0)", "LINESTRING(0 5,5 5,5 10,10 10,10 5,5 5,5 0)", "lsls11.svg"); +to_svg("LINESTRING(0 5,5 5,10 5,10 10,5 10,5 5,5 0)", "LINESTRING(5 0,5 5,10 5,10 10,5 10,5 5,0 5)", "lsls12.svg"); +to_svg("LINESTRING(5 0,5 5,5 10,10 10,10 5,5 5,0 5)", "LINESTRING(0 5,5 5,5 10,10 10,10 5,5 5,5 0)", "lsls13.svg"); +to_svg("LINESTRING(5 0,5 5,5 10,10 10,10 5,5 5,0 5)", "LINESTRING(5 0,5 5,10 5,10 10,5 10,5 5,0 5)", "lsls14.svg"); + +to_svg("LINESTRING(0 5,10 5,10 10,5 10,5 0)", "LINESTRING(0 5,5 5,5 10,10 10,10 5,5 5,5 0)", "lsls15.svg"); +to_svg("LINESTRING(0 5,10 5,10 10,5 10,5 0)", "LINESTRING(5 0,5 10,10 10,10 5,0 5)", "lsls16.svg"); +to_svg("LINESTRING(0 5,10 5)", "LINESTRING(5 0,5 10,10 10,10 5,0 5)", "lsls161.svg"); +to_svg("LINESTRING(0 5,8 5,10 5)", "LINESTRING(5 0,5 10,10 10,10 5,0 5)", "lsls162.svg"); +to_svg("LINESTRING(0 5,8 5)", "LINESTRING(5 0,5 10,10 10,10 5,0 5)", "lsls1631.svg"); +to_svg("LINESTRING(0 5,1 5,7 5,8 5)", "LINESTRING(5 0,5 10,10 10,10 5,0 5)", "lsls1632.svg"); +to_svg("LINESTRING(0 5,1 5,7 5,8 5)", "LINESTRING(5 10,10 10,10 5,0 5)", "lsls1633.svg"); +to_svg("LINESTRING(0 5,8 4)", "LINESTRING(5 0,5 10,10 10,10 5,0 5)", "lsls1641.svg"); +to_svg("LINESTRING(0 5,8 6)", "LINESTRING(5 0,5 10,10 10,10 5,0 5)", "lsls1642.svg"); +to_svg("LINESTRING(1 5,8 4)", "LINESTRING(5 0,5 10,10 10,10 5,0 5)", "lsls1643.svg"); +to_svg("LINESTRING(1 5,8 5)", "LINESTRING(5 0,5 10,10 10,10 5,0 5)", "lsls1644.svg"); +to_svg("LINESTRING(0 5,5 5,8 4)", "LINESTRING(5 0,5 10,10 10,10 5,0 5)", "lsls165.svg"); +to_svg("LINESTRING(0 5,5 5,8 5)", "LINESTRING(5 0,5 10,10 10,10 5,0 5)", "lsls166.svg"); +to_svg("LINESTRING(0 5,5 5,8 5)", "LINESTRING(0 10,10 0,5 0,5 10,10 10,10 5,0 5)", "lsls167.svg"); +to_svg("LINESTRING(0 5,5 5,8 5)", "LINESTRING(0 10,5 5,10 0,5 0,5 5,5 10,10 10,10 5,0 5)", "lsls168.svg"); + +to_svg("LINESTRING(0 0,0 10,10 10,10 0,0 0)", "LINESTRING(0 2,0 0,10 0,10 10,0 10,0 8,0 2)", "lsls1690.svg"); +to_svg("LINESTRING(0 0,10 0,10 10,0 10,0 0)", "LINESTRING(0 8,0 0,10 0,10 10,0 10,0 8)", "lsls1691.svg"); +to_svg("LINESTRING(0 0,10 0,10 10,0 10,0 0)", "LINESTRING(0 2,0 0,10 0,10 10,0 10,0 8)", "lsls1692.svg"); +to_svg("LINESTRING(0 0,0 10,10 10,10 0,0 0)", "LINESTRING(0 2,0 0,10 0,10 10,0 10,0 8)", "lsls1693.svg"); +to_svg("LINESTRING(0 2,0 0,10 0,10 10,0 10,0 8)", "LINESTRING(0 0,10 0,10 10,0 10,0 0)", "lsls1694.svg"); +to_svg("LINESTRING(0 2,0 0,10 0,10 10,0 10,0 8)", "LINESTRING(0 0,0 10,10 10,10 0,0 0)", "lsls1695.svg"); + +to_svg("LINESTRING(0 8,0 0,10 0,10 10,0 10,0 2)", "ls1.svg"); +to_svg("LINESTRING(8 8,0 0,10 0,10 10,0 10,8 2)", "ls2.svg"); + +typedef bg::model::multi_linestring mls; +to_svg("LINESTRING(0 5,10 5,10 10,5 10,5 0)", "MULTILINESTRING((5 0,5 7),(5 8,5 10,10 10,10 5,0 5))", "lsls17.svg"); +to_svg("LINESTRING(0 5,10 5,10 10,5 10,5 0)", "MULTILINESTRING((5 0,5 4,5 6,5 7),(5 8,5 10,10 10,10 5,0 5))", "lsls18.svg"); +to_svg("LINESTRING(0 5,10 5,10 10,5 10,5 0)", "MULTILINESTRING((5 0,5 8),(5 7,5 10,10 10,10 5,0 5))", "lsls19.svg"); +to_svg("MULTILINESTRING((5 0,5 7),(5 8,5 10,10 10,10 5,0 5))", "LINESTRING(0 5,10 5,10 10,5 10,5 0)", "lsls20.svg"); +to_svg("MULTILINESTRING((5 0,5 8),(5 7,5 10,10 10,10 5,0 5))", "LINESTRING(0 5,10 5,10 10,5 10,5 0)", "lsls21.svg"); + +to_svg("LINESTRING(0 5,5 5,10 5,10 10,5 10,5 5,5 0)", "LINESTRING(0 5,5 5,0 10,10 10,10 5,5 5,5 0)", "lsls100.svg"); + +to_svg("LINESTRING(5 0,5 5,5 0)", "LINESTRING(0 5,5 5,0 10,2 10,5 5,5 10,10 10,10 5,5 5,10 2,10 0,8 0,5 5,5 0)", "lsls101.svg"); +*/ diff --git a/test/algorithms/overlay/get_turns_linear_linear.cpp b/test/algorithms/overlay/get_turns_linear_linear.cpp index 2bd1f9c22..3190d5d84 100644 --- a/test/algorithms/overlay/get_turns_linear_linear.cpp +++ b/test/algorithms/overlay/get_turns_linear_linear.cpp @@ -17,146 +17,9 @@ // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle -#include -#include - -#include - -#include - -#include -#include - -#include - +#include "test_get_turns.hpp" #include -#include -#include - -struct equal_turn -{ - equal_turn(std::string const& s) : turn_ptr(&s) {} - - template - bool operator()(T const& t) const - { - BOOST_ASSERT(turn_ptr && turn_ptr->size() == 3); - return bg::method_char(t.method) == (*turn_ptr)[0] - && bg::operation_char(t.operations[0].operation) == (*turn_ptr)[1] - && bg::operation_char(t.operations[1].operation) == (*turn_ptr)[2]; - } - - const std::string * turn_ptr; -}; - -template -void check_geometry( - Geometry1 const& g1, - Geometry2 const& g2, - std::string const& wkt1, - std::string const& wkt2, - std::vector const& expected) -{ - typedef bg::detail::overlay::turn_info - < - typename bg::point_type::type, - typename bg::detail::get_turns::turn_operation_type::type - > turn_info; - typedef bg::detail::overlay::assign_null_policy assign_policy_t; - typedef bg::detail::get_turns::no_interrupt_policy interrupt_policy_t; - - std::vector turns; - interrupt_policy_t interrupt_policy; - - // Don't switch the geometries - typedef bg::detail::get_turns::get_turn_info_type turn_policy_t; - bg::dispatch::get_turns - < - typename bg::tag::type, typename bg::tag::type, - Geometry1, Geometry2, false, false, - turn_policy_t - >::apply(0, g1, 1, g2, bg::detail::no_rescale_policy(), turns, interrupt_policy); - - bool ok = expected.size() == turns.size(); - - BOOST_CHECK_MESSAGE(ok, - "get_turns: " << wkt1 << " and " << wkt2 - << " -> Expected turns #: " << expected.size() << " detected turns #: " << turns.size()); - - BOOST_FOREACH(std::string const& s, expected) - { - typename std::vector::iterator - it = std::find_if(turns.begin(), turns.end(), equal_turn(s)); - - if ( it != turns.end() ) - turns.erase(it); - else - { - BOOST_CHECK_MESSAGE(false, - "get_turns: " << wkt1 << " and " << wkt2 - << " -> Expected turn: " << s << " not found"); - } - } -} - -template -void test_geometry(std::string const& wkt1, std::string const& wkt2, - std::vector const& expected) -{ - Geometry1 geometry1; - Geometry2 geometry2; - bg::read_wkt(wkt1, geometry1); - bg::read_wkt(wkt2, geometry2); - check_geometry(geometry1, geometry2, wkt1, wkt2, expected); -} - -template -void test_geometry(std::string const& wkt1, std::string const& wkt2, - std::string const& ex0) -{ - std::vector expected; - expected.push_back(ex0); - test_geometry(wkt1, wkt2, expected); -} - -template -void test_geometry(std::string const& wkt1, std::string const& wkt2, - std::string const& ex0, std::string const& ex1) -{ - std::vector expected; - expected.push_back(ex0); - expected.push_back(ex1); - test_geometry(wkt1, wkt2, expected); -} - -template -void test_geometry(std::string const& wkt1, std::string const& wkt2, - std::string const& ex0, std::string const& ex1, std::string const& ex2) -{ - std::vector expected; - expected.push_back(ex0); - expected.push_back(ex1); - expected.push_back(ex2); - test_geometry(wkt1, wkt2, expected); -} - -struct expected_pusher -{ - expected_pusher & operator()(std::string const& ex) - { - vec.push_back(ex); - return *this; - } - std::vector vec; -}; - -expected_pusher expected(std::string const& ex) -{ - expected_pusher res; - return res(ex); -} - //TEST //#include //#include diff --git a/test/algorithms/overlay/test_get_turns.hpp b/test/algorithms/overlay/test_get_turns.hpp new file mode 100644 index 000000000..d22de2cfa --- /dev/null +++ b/test/algorithms/overlay/test_get_turns.hpp @@ -0,0 +1,159 @@ +// Boost.Geometry (aka GGL, Generic Geometry Library) + +// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands. +// Copyright (c) 2008-2012 Bruno Lalande, Paris, France. +// Copyright (c) 2009-2012 Mateusz Loskot, London, UK. + +// This file was modified by Oracle on 2014. +// Modifications copyright (c) 2014 Oracle and/or its affiliates. + +// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library +// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands. + +// 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 Adam Wulkiewicz, on behalf of Oracle + +#ifndef BOOST_GEOMETRY_TEST_ALGORITHMS_OVERLAY_TEST_GET_TURNS_HPP +#define BOOST_GEOMETRY_TEST_ALGORITHMS_OVERLAY_TEST_GET_TURNS_HPP + +#include +#include + +#include + +#include + +#include + +#include + +#include +#include + +struct equal_turn +{ + equal_turn(std::string const& s) : turn_ptr(&s) {} + + template + bool operator()(T const& t) const + { + BOOST_ASSERT(turn_ptr && turn_ptr->size() == 3); + return bg::method_char(t.method) == (*turn_ptr)[0] + && bg::operation_char(t.operations[0].operation) == (*turn_ptr)[1] + && bg::operation_char(t.operations[1].operation) == (*turn_ptr)[2]; + } + + const std::string * turn_ptr; +}; + +template +void check_geometry( + Geometry1 const& g1, + Geometry2 const& g2, + std::string const& wkt1, + std::string const& wkt2, + std::vector const& expected) +{ + typedef bg::detail::overlay::turn_info + < + typename bg::point_type::type, + typename bg::detail::get_turns::turn_operation_type::type + > turn_info; + typedef bg::detail::overlay::assign_null_policy assign_policy_t; + typedef bg::detail::get_turns::no_interrupt_policy interrupt_policy_t; + + std::vector turns; + interrupt_policy_t interrupt_policy; + + // Don't switch the geometries + typedef bg::detail::get_turns::get_turn_info_type turn_policy_t; + bg::dispatch::get_turns + < + typename bg::tag::type, typename bg::tag::type, + Geometry1, Geometry2, false, false, + turn_policy_t + >::apply(0, g1, 1, g2, bg::detail::no_rescale_policy(), turns, interrupt_policy); + + bool ok = expected.size() == turns.size(); + + BOOST_CHECK_MESSAGE(ok, + "get_turns: " << wkt1 << " and " << wkt2 + << " -> Expected turns #: " << expected.size() << " detected turns #: " << turns.size()); + + BOOST_FOREACH(std::string const& s, expected) + { + typename std::vector::iterator + it = std::find_if(turns.begin(), turns.end(), equal_turn(s)); + + if ( it != turns.end() ) + turns.erase(it); + else + { + BOOST_CHECK_MESSAGE(false, + "get_turns: " << wkt1 << " and " << wkt2 + << " -> Expected turn: " << s << " not found"); + } + } +} + +template +void test_geometry(std::string const& wkt1, std::string const& wkt2, + std::vector const& expected) +{ + Geometry1 geometry1; + Geometry2 geometry2; + bg::read_wkt(wkt1, geometry1); + bg::read_wkt(wkt2, geometry2); + check_geometry(geometry1, geometry2, wkt1, wkt2, expected); +} + +template +void test_geometry(std::string const& wkt1, std::string const& wkt2, + std::string const& ex0) +{ + std::vector expected; + expected.push_back(ex0); + test_geometry(wkt1, wkt2, expected); +} + +template +void test_geometry(std::string const& wkt1, std::string const& wkt2, + std::string const& ex0, std::string const& ex1) +{ + std::vector expected; + expected.push_back(ex0); + expected.push_back(ex1); + test_geometry(wkt1, wkt2, expected); +} + +template +void test_geometry(std::string const& wkt1, std::string const& wkt2, + std::string const& ex0, std::string const& ex1, std::string const& ex2) +{ + std::vector expected; + expected.push_back(ex0); + expected.push_back(ex1); + expected.push_back(ex2); + test_geometry(wkt1, wkt2, expected); +} + +struct expected_pusher +{ + expected_pusher & operator()(std::string const& ex) + { + vec.push_back(ex); + return *this; + } + std::vector vec; +}; + +expected_pusher expected(std::string const& ex) +{ + expected_pusher res; + return res(ex); +} + +#endif // BOOST_GEOMETRY_TEST_ALGORITHMS_OVERLAY_TEST_GET_TURNS_HPP diff --git a/test/to_svg.hpp b/test/to_svg.hpp index 561e2f5d0..b6865b5b0 100644 --- a/test/to_svg.hpp +++ b/test/to_svg.hpp @@ -88,19 +88,19 @@ inline void turns_to_svg(Turns const& turns, Mapper & mapper, bool enrich = fals << ' ' << turn.operations[0].other_id.ring_index << ' ' << turn.operations[0].other_id.segment_index; - if ( enrich ) + /*if ( enrich ) { - out << ", "; - if (turn.operations[0].enriched.next_ip_index != -1) - { - out << "ip: " << turn.operations[0].enriched.next_ip_index; - } - else - { - out << "vx: " << turn.operations[0].enriched.travels_to_vertex_index - << " -> ip: " << turn.operations[0].enriched.travels_to_ip_index; - } + out << ", "; + if (turn.operations[0].enriched.next_ip_index != -1) + { + out << "ip: " << turn.operations[0].enriched.next_ip_index; } + else + { + out << "vx: " << turn.operations[0].enriched.travels_to_vertex_index + << " -> ip: " << turn.operations[0].enriched.travels_to_ip_index; + } + }*/ out << '\n'; @@ -111,10 +111,10 @@ inline void turns_to_svg(Turns const& turns, Mapper & mapper, bool enrich = fals << ' ' << turn.operations[1].seg_id.segment_index << ", "; out << "other: " << turn.operations[1].other_id.source_index << ' ' << turn.operations[1].other_id.multi_index - << ' ' << turn.operations[1].other_id.segment_index - << ' ' << turn.operations[1].other_id.ring_index; + << ' ' << turn.operations[1].other_id.ring_index + << ' ' << turn.operations[1].other_id.segment_index; - if ( enrich ) + /*if ( enrich ) { out << ", "; if (turn.operations[1].enriched.next_ip_index != -1) @@ -126,7 +126,7 @@ inline void turns_to_svg(Turns const& turns, Mapper & mapper, bool enrich = fals out << "vx: " << turn.operations[1].enriched.travels_to_vertex_index << " -> ip: " << turn.operations[1].enriched.travels_to_ip_index; } - } + }*/ //out << std::endl; @@ -253,7 +253,8 @@ inline void to_svg(G1 const& g1, G2 const& g2, std::string const& filename, bool // GET TURNS - typedef bg::detail::overlay::traversal_turn_info turn_info; + typedef typename bg::detail::relate::turns::get_turns::turn_info turn_info; + //typedef bg::detail::overlay::traversal_turn_info turn_info; //typedef bg::detail::overlay::calculate_distance_policy AssignPolicy; typedef to_svg_assign_policy AssignPolicy; @@ -291,7 +292,7 @@ inline void to_svg(G1 const& g1, G2 const& g2, std::string const& filename, bool std::sort(boost::begin(turns), boost::end(turns), less()); } - if ( enrich ) + /*if ( enrich ) { typedef typename bg::strategy::side::services::default_strategy < @@ -304,7 +305,7 @@ inline void to_svg(G1 const& g1, G2 const& g2, std::string const& filename, bool g1, g1, bg::detail::no_rescale_policy(), side_strategy_type()); - } + }*/ turns_to_svg(turns, mapper, enrich); }