From 1e3041e7489bea9d181cb39d0037d317f446753f Mon Sep 17 00:00:00 2001 From: Menelaos Karavelas Date: Thu, 8 May 2014 01:28:09 +0300 Subject: [PATCH 01/66] [overlay][P/P, L/L] replace BOOST_AUTO_TPL by the exact type --- .../detail/overlay/linear_linear.hpp | 6 +++--- .../detail/overlay/pointlike_pointlike.hpp | 21 +++++++++++-------- 2 files changed, 15 insertions(+), 12 deletions(-) diff --git a/include/boost/geometry/algorithms/detail/overlay/linear_linear.hpp b/include/boost/geometry/algorithms/detail/overlay/linear_linear.hpp index db9e91fb6..74b9e0134 100644 --- a/include/boost/geometry/algorithms/detail/overlay/linear_linear.hpp +++ b/include/boost/geometry/algorithms/detail/overlay/linear_linear.hpp @@ -14,7 +14,6 @@ #include #include -#include #include #include @@ -85,8 +84,9 @@ struct linear_linear_no_intersections static inline OutputIterator apply(MultiLineString const& multilinestring, OutputIterator oit) { - BOOST_AUTO_TPL(it, boost::begin(multilinestring)); - for (; it != boost::end(multilinestring); ++it) + for (typename boost::range_iterator::type + it = boost::begin(multilinestring); + it != boost::end(multilinestring); ++it) { LineStringOut ls_out; geometry::convert(*it, ls_out); diff --git a/include/boost/geometry/algorithms/detail/overlay/pointlike_pointlike.hpp b/include/boost/geometry/algorithms/detail/overlay/pointlike_pointlike.hpp index 8a63e78aa..321a512bf 100644 --- a/include/boost/geometry/algorithms/detail/overlay/pointlike_pointlike.hpp +++ b/include/boost/geometry/algorithms/detail/overlay/pointlike_pointlike.hpp @@ -16,7 +16,6 @@ #include #include -#include #include #include @@ -72,8 +71,9 @@ struct copy_points static inline void apply(MultiPointIn const& multi_point_in, OutputIterator& oit) { - BOOST_AUTO_TPL(it, boost::begin(multi_point_in)); - for (; it != boost::end(multi_point_in); ++it) + for (typename boost::range_iterator::type + it = boost::begin(multi_point_in); + it != boost::end(multi_point_in); ++it) { PointOut point_out; geometry::convert(*it, point_out); @@ -185,8 +185,9 @@ struct multipoint_point_point { BOOST_ASSERT( OverlayType == overlay_difference ); - BOOST_AUTO_TPL(it, boost::begin(multipoint)); - for (; it != boost::end(multipoint); ++it) + for (typename boost::range_iterator::type + it = boost::begin(multipoint); + it != boost::end(multipoint); ++it) { action_selector_pl_pl < @@ -220,8 +221,9 @@ struct point_multipoint_point { typedef action_selector_pl_pl action; - BOOST_AUTO_TPL(it, boost::begin(multipoint)); - for (; it != boost::end(multipoint); ++it) + for (typename boost::range_iterator::type + it = boost::begin(multipoint); + it != boost::end(multipoint); ++it) { if ( detail::equals::equals_point_point(*it, point) ) { @@ -268,8 +270,9 @@ struct multipoint_multipoint_point std::sort(points2.begin(), points2.end(), detail::relate::less()); - BOOST_AUTO_TPL(it1, boost::begin(multipoint1)); - for (; it1 != boost::end(multipoint1); ++it1) + for (typename boost::range_iterator::type + it1 = boost::begin(multipoint1); + it1 != boost::end(multipoint1); ++it1) { bool found = std::binary_search(points2.begin(), points2.end(), *it1, detail::relate::less()); From 302c25280dc140cd6bd90dde54abeafd2fe0ca82 Mon Sep 17 00:00:00 2001 From: Menelaos Karavelas Date: Thu, 8 May 2014 13:45:10 +0300 Subject: [PATCH 02/66] [distance] add unit tests for all geometry combinations --- test/algorithms/distance_all.cpp | 20 + test/algorithms/distance_areal_areal.cpp | 266 ++++++ test/algorithms/distance_linear_areal.cpp | 774 ++++++++++++++++++ test/algorithms/distance_linear_linear.cpp | 268 ++++++ test/algorithms/distance_pointlike_areal.cpp | 547 +++++++++++++ test/algorithms/distance_pointlike_linear.cpp | 250 ++++++ .../distance_pointlike_pointlike.cpp | 138 ++++ 7 files changed, 2263 insertions(+) create mode 100644 test/algorithms/distance_all.cpp create mode 100644 test/algorithms/distance_areal_areal.cpp create mode 100644 test/algorithms/distance_linear_areal.cpp create mode 100644 test/algorithms/distance_linear_linear.cpp create mode 100644 test/algorithms/distance_pointlike_areal.cpp create mode 100644 test/algorithms/distance_pointlike_linear.cpp create mode 100644 test/algorithms/distance_pointlike_pointlike.cpp diff --git a/test/algorithms/distance_all.cpp b/test/algorithms/distance_all.cpp new file mode 100644 index 000000000..74a46fffb --- /dev/null +++ b/test/algorithms/distance_all.cpp @@ -0,0 +1,20 @@ +// Boost.Geometry (aka GGL, Generic Geometry Library) +// Unit Test + +// Copyright (c) 2014, Oracle and/or its affiliates. + +// Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle + +// Licensed under the Boost Software License version 1.0. +// http://www.boost.org/users/license.html + +#ifndef BOOST_TEST_MODULE +#define BOOST_TEST_MODULE test_distance_all +#endif + +#include "distance_pointlike_pointlike.cpp" +#include "distance_pointlike_linear.cpp" +#include "distance_pointlike_areal.cpp" +#include "distance_linear_linear.cpp" +#include "distance_linear_areal.cpp" +#include "distance_areal_areal.cpp" diff --git a/test/algorithms/distance_areal_areal.cpp b/test/algorithms/distance_areal_areal.cpp new file mode 100644 index 000000000..10e261513 --- /dev/null +++ b/test/algorithms/distance_areal_areal.cpp @@ -0,0 +1,266 @@ +// Boost.Geometry (aka GGL, Generic Geometry Library) +// Unit Test + +// Copyright (c) 2014, Oracle and/or its affiliates. + +// Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle + +// Licensed under the Boost Software License version 1.0. +// http://www.boost.org/users/license.html + +#include + +#ifndef BOOST_TEST_MODULE +#define BOOST_TEST_MODULE test_distance_areal_areal +#endif + +#include + +#include "test_distance_common.hpp" + + +typedef bg::model::point point_type; +typedef bg::model::polygon polygon_type; +typedef bg::model::multi_polygon multi_polygon_type; +typedef bg::model::box box_type; + +namespace services = bg::strategy::distance::services; +typedef bg::default_distance_result::type return_type; + +typedef bg::strategy::distance::projected_point<> point_segment_strategy; +typedef bg::strategy::distance::pythagoras_box_box<> box_box_strategy; + +//=========================================================================== + +template +void test_distance_polygon_polygon(Strategy const& strategy) +{ +#ifdef GEOMETRY_TEST_DEBUG + std::cout << std::endl; + std::cout << "polygon/polygon distance tests" << std::endl; +#endif + test_distance_of_geometries tester; + + tester("polygon((-10 -10,10 -10,10 10,-10 10,-10 -10))", + "polygon((-5 20,5 20,5 25,-5 25,-5 20))", + 10, 100, strategy); + + tester("polygon((-10 -10,10 -10,10 10,-10 10,-10 -10))", + "polygon((-5 20,-5 5,5 5,5 20,-5 20))", + 0, 0, strategy); + + tester("polygon((-10 -10,10 -10,10 10,-10 10,-10 -10))", + "polygon((-5 20,-5 -20,5 -20,5 20,-5 20))", + 0, 0, strategy); + + tester("polygon((-10 -10,10 -10,10 10,-10 10,-10 -10),\ + (-5 -5,-5 5,5 5,5 -5,-5 -5))", + "polygon((-1 -1,0 0,-1 0,-1 -1))", + 4, 16, strategy); +} + +//=========================================================================== + +template +void test_distance_polygon_multipolygon(Strategy const& strategy) +{ +#ifdef GEOMETRY_TEST_DEBUG + std::cout << std::endl; + std::cout << "polygon/multipolygon distance tests" << std::endl; +#endif + test_distance_of_geometries tester; + + tester("polygon((12 0,14 0,19 0,19.9 -1,12 0))", + "multipolygon(((-10 -10,10 -10,10 10,-10 10,-10 -10)),\ + ((20 -1,21 2,30 -10,20 -1)))", + 0.1, 0.01, strategy, true); + + tester("polygon((19 0,19.9 -1,12 0,20.5 0.5,19 0))", + "multipolygon(((-10 -10,10 -10,10 10,-10 10,-10 -10)),\ + ((20 -1,21 2,30 -10,20 -1)))", + 0, 0, strategy, true); +} + +//=========================================================================== + +template +void test_distance_multipolygon_multipolygon(Strategy const& strategy) +{ +#ifdef GEOMETRY_TEST_DEBUG + std::cout << std::endl; + std::cout << "multipolygon/multipolygon distance tests" << std::endl; +#endif + test_distance_of_geometries tester; + + tester("multipolygon(((12 0,14 0,14 1,12 0)),((18 0,19 0,19.9 -1,18 0)))", + "multipolygon(((-10 -10,10 -10,10 10,-10 10,-10 -10)),\ + ((20 -1,21 2,30 -10,20 -1)))", + 0.1, 0.01, strategy); + + tester("multipolygon(((18 0,19 0,19.9 -1,18 0)),((12 0,14 0,20.5 0.5,12 0)))", + "multipolygon(((-10 -10,10 -10,10 10,-10 10,-10 -10)),\ + ((20 -1,21 2,30 -10,20 -1)))", + 0, 0, strategy); +} + +//=========================================================================== + +template +void test_distance_box_box(Strategy const& strategy) +{ +#ifdef GEOMETRY_TEST_DEBUG + std::cout << std::endl; + std::cout << "box/box distance tests" << std::endl; +#endif + test_distance_of_geometries tester; + + tester(make_box2d(5, 5, 10, 10), + make_box2d(0, 0, 1, 1), + sqrt(32.0), 32, strategy); + + tester(make_box2d(3, 8, 13, 18), + make_box2d(0, 0, 5, 5), + 3, 9, strategy); + + tester(make_box2d(5, 5, 10, 10), + make_box2d(0, 0, 5, 5), + 0, 0, strategy); + + tester(make_box2d(5, 5, 10, 10), + make_box2d(0, 0, 6, 6), + 0, 0, strategy); + + tester(make_box2d(3, 5, 13, 15), + make_box2d(0, 0, 5, 5), + 0, 0, strategy); +} + +//=========================================================================== + +template +void test_distance_polygon_box(Strategy const& strategy) +{ +#ifdef GEOMETRY_TEST_DEBUG + std::cout << std::endl; + std::cout << "polygon/box distance tests" << std::endl; +#endif + test_distance_of_geometries tester; + + tester("polygon((10 10,10 5,5 5,5 10,10 10))", + make_box2d(0, 0, 1, 1), + sqrt(32.0), 32, strategy); + + tester("polygon((10 10,10 5,5 5,5 10,10 10))", + make_box2d(0, 0, 5, 5), + 0, 0, strategy); + + tester("polygon((10 10,10 5,5 5,5 10,10 10))", + make_box2d(0, 0, 6, 6), + 0, 0, strategy); + + tester("polygon((10 10,15 5,10 0,5 5,10 10))", + make_box2d(5, 0, 7.5, 2.5), + 0, 0, strategy); + + tester("polygon((10 10,15 5,10 0,5 5,10 10))", + make_box2d(5, 0, 6, 1), + sqrt(4.5), 4.5, strategy); +} + +//=========================================================================== + +template +void test_distance_multipolygon_box(Strategy const& strategy) +{ +#ifdef GEOMETRY_TEST_DEBUG + std::cout << std::endl; + std::cout << "multipolygon/box distance tests" << std::endl; +#endif + test_distance_of_geometries tester; + + tester("multipolygon(((-10 -10,-10 -9,-9 -9,-9 -10,-10 -10)),\ + ((2 2,2 3,3 3,3 2,2 2)))", + make_box2d(0, 0, 1, 1), + sqrt(2.0), 2, strategy); + + tester("multipolygon(((-10 -10,-10 -9,-9 -9,-9 -10,-10 -10)),\ + ((2 2,2 3,3 3,3 2,2 2)))", + make_box2d(0, 0, 2, 2), + 0, 0, strategy); + + tester("multipolygon(((-10 -10,-10 -9,-9 -9,-9 -10,-10 -10)),\ + ((2 2,2 3,3 3,3 2,2 2)))", + make_box2d(0, 0, 2.5, 2), + 0, 0, strategy); +} + +//=========================================================================== + +template +void test_more_empty_input_areal_areal(Strategy const& strategy) +{ +#ifdef GEOMETRY_TEST_DEBUG + std::cout << std::endl; + std::cout << "testing on empty inputs... " << std::flush; +#endif + bg::model::polygon polygon_empty; + bg::model::multi_polygon > multipolygon_empty; + + bg::model::polygon polygon = + from_wkt >("polygon((0 0,1 0,0 1))"); + + // 1st geometry is empty + test_empty_input(polygon_empty, polygon, strategy); + test_empty_input(multipolygon_empty, polygon, strategy); + + // 2nd geometry is empty + test_empty_input(polygon, polygon_empty, strategy); + test_empty_input(polygon, multipolygon_empty, strategy); + + // both geometries are empty + test_empty_input(polygon_empty, polygon_empty, strategy); + test_empty_input(polygon_empty, multipolygon_empty, strategy); + test_empty_input(multipolygon_empty, polygon_empty, strategy); + test_empty_input(multipolygon_empty, multipolygon_empty, strategy); + +#ifdef GEOMETRY_TEST_DEBUG + std::cout << "done!" << std::endl; +#endif +} + +//=========================================================================== + +BOOST_AUTO_TEST_CASE( test_all_polygon_polygon ) +{ + test_distance_polygon_polygon(point_segment_strategy()); +} + +BOOST_AUTO_TEST_CASE( test_all_polygon_multipolygon ) +{ + test_distance_polygon_multipolygon(point_segment_strategy()); +} + +BOOST_AUTO_TEST_CASE( test_all_multipolygon_multipolygon ) +{ + test_distance_multipolygon_multipolygon(point_segment_strategy()); +} + +BOOST_AUTO_TEST_CASE( test_all_box_box ) +{ + test_distance_box_box(box_box_strategy()); +} + +BOOST_AUTO_TEST_CASE( test_all_polygon_box ) +{ + test_distance_polygon_box(point_segment_strategy()); +} + +BOOST_AUTO_TEST_CASE( test_all_multipolygon_box ) +{ + test_distance_multipolygon_box(point_segment_strategy()); +} + +BOOST_AUTO_TEST_CASE( test_all_empty_input_areal_areal ) +{ + test_more_empty_input_areal_areal(point_segment_strategy()); +} diff --git a/test/algorithms/distance_linear_areal.cpp b/test/algorithms/distance_linear_areal.cpp new file mode 100644 index 000000000..c5d4d1409 --- /dev/null +++ b/test/algorithms/distance_linear_areal.cpp @@ -0,0 +1,774 @@ +// Boost.Geometry (aka GGL, Generic Geometry Library) +// Unit Test + +// Copyright (c) 2014, Oracle and/or its affiliates. + +// Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle + +// Licensed under the Boost Software License version 1.0. +// http://www.boost.org/users/license.html + +#include + +#ifndef BOOST_TEST_MODULE +#define BOOST_TEST_MODULE test_distance_linear_areal +#endif + +#include + +#include "test_distance_common.hpp" + + +typedef bg::model::point point_type; +typedef bg::model::point int_point_type; +typedef bg::model::segment segment_type; +typedef bg::model::segment int_segment_type; +typedef bg::model::linestring linestring_type; +typedef bg::model::multi_linestring multi_linestring_type; +typedef bg::model::polygon polygon_type; +typedef bg::model::multi_polygon multi_polygon_type; +typedef bg::model::box box_type; +typedef bg::model::box int_box_type; + +namespace services = bg::strategy::distance::services; +typedef bg::default_distance_result::type return_type; + +typedef bg::strategy::distance::pythagoras<> point_point_strategy; +typedef bg::strategy::distance::projected_point<> point_segment_strategy; + +//=========================================================================== + +template +void test_distance_segment_polygon(Strategy const& strategy) +{ +#ifdef GEOMETRY_TEST_DEBUG + std::cout << std::endl; + std::cout << "segment/polygon distance tests" << std::endl; +#endif + test_distance_of_geometries tester; + + tester(make_segment(-1, 20, 1, 20), + "polygon((-10 -10,10 -10,10 10,-10 10,-10 -10))", + 10, 100, strategy); + + tester(make_segment(1, 20, 2, 40), + "polygon((-10 -10,10 -10,10 10,-10 10,-10 -10))", + 10, 100, strategy); + + tester(make_segment(-1, 20, -1, 5), + "polygon((-10 -10,10 -10,10 10,-10 10,-10 -10))", + 0, 0, strategy); + + tester(make_segment(-1, 20, -1, -20), + "polygon((-10 -10,10 -10,10 10,-10 10,-10 -10))", + 0, 0, strategy); +} + +//=========================================================================== + +template +void test_distance_linestring_polygon(Strategy const& strategy) +{ +#ifdef GEOMETRY_TEST_DEBUG + std::cout << std::endl; + std::cout << "linestring/polygon distance tests" << std::endl; +#endif + test_distance_of_geometries tester; + + tester("linestring(-1 20,1 20,1 30)", + "polygon((-10 -10,10 -10,10 10,-10 10,-10 -10))", + 10, 100, strategy, true); + + tester("linestring(-1 20,1 20,1 5)", + "polygon((-10 -10,10 -10,10 10,-10 10,-10 -10))", + 0, 0, strategy, true); + + tester("linestring(-1 20,1 20,1 -20)", + "polygon((-10 -10,10 -10,10 10,-10 10,-10 -10))", + 0, 0, strategy, true); +} + +//=========================================================================== + +template +void test_distance_multilinestring_polygon(Strategy const& strategy) +{ +#ifdef GEOMETRY_TEST_DEBUG + std::cout << std::endl; + std::cout << "multilinestring/polygon distance tests" << std::endl; +#endif + test_distance_of_geometries tester; + + tester("multilinestring((-100 -100,-90 -90),(-1 20,1 20,1 30))", + "polygon((-10 -10,10 -10,10 10,-10 10,-10 -10))", + 10, 100, strategy, true); + + tester("multilinestring((-1 20,1 20,1 30),(-1 20,1 20,1 5))", + "polygon((-10 -10,10 -10,10 10,-10 10,-10 -10))", + 0, 0, strategy, true); + + tester("multilinestring((-1 20,1 20,1 30),(-1 20,1 20,1 -20))", + "polygon((-10 -10,10 -10,10 10,-10 10,-10 -10))", + 0, 0, strategy, true); +} + +//=========================================================================== + +template +void test_distance_segment_multipolygon(Strategy const& strategy) +{ +#ifdef GEOMETRY_TEST_DEBUG + std::cout << std::endl; + std::cout << "segment/multipolygon distance tests" << std::endl; +#endif + test_distance_of_geometries tester; + + tester(make_segment(-1, 20, 1, 20), + "multipolygon(((-10 -10,10 -10,10 10,-10 10,-10 -10)),\ + ((0 22,-1 30, 2 40,0 22)))", + 2, 4, strategy); + + tester(make_segment(12, 0, 14, 0), + "multipolygon(((-10 -10,10 -10,10 10,-10 10,-10 -10)),\ + ((20 -1,21 2,30 -10,20 -1)))", + 2, 4, strategy); + + tester(make_segment(12, 0, 20.5, 0.5), + "multipolygon(((-10 -10,10 -10,10 10,-10 10,-10 -10)),\ + ((20 -1,21 2,30 -10,20 -1)))", + 0, 0, strategy); + + tester(make_segment(12, 0, 50, 0), + "multipolygon(((-10 -10,10 -10,10 10,-10 10,-10 -10)),\ + ((20 -1,21 2,30 -10,20 -1)))", + 0, 0, strategy); +} + +//=========================================================================== + +template +void test_distance_linestring_multipolygon(Strategy const& strategy) +{ +#ifdef GEOMETRY_TEST_DEBUG + std::cout << std::endl; + std::cout << "linestring/multipolygon distance tests" << std::endl; +#endif + test_distance_of_geometries tester; + + tester("linestring(-1 20,1 20)", + "multipolygon(((-10 -10,10 -10,10 10,-10 10,-10 -10)),\ + ((0 22,-1 30, 2 40,0 22)))", + 2, 4, strategy, true); + + tester("linestring(12 0,14 0)", + "multipolygon(((-10 -10,10 -10,10 10,-10 10,-10 -10)),\ + ((20 -1,21 2,30 -10,20 -1)))", + 2, 4, strategy, true); + + tester("linestring(12 0,20.5 0.5)", + "multipolygon(((-10 -10,10 -10,10 10,-10 10,-10 -10)),\ + ((20 -1,21 2,30 -10,20 -1)))", + 0, 0, strategy, true); + + tester("linestring(12 0,50 0)", + "multipolygon(((-10 -10,10 -10,10 10,-10 10,-10 -10)),\ + ((20 -1,21 2,30 -10,20 -1)))", + 0, 0, strategy, true); +} + +//=========================================================================== + +template +void test_distance_multilinestring_multipolygon(Strategy const& strategy) +{ +#ifdef GEOMETRY_TEST_DEBUG + std::cout << std::endl; + std::cout << "multilinestring/multipolygon distance tests" << std::endl; +#endif + test_distance_of_geometries + < + multi_linestring_type, multi_polygon_type + > tester; + + tester("multilinestring((12 0,14 0),(19 0,19.9 -1))", + "multipolygon(((-10 -10,10 -10,10 10,-10 10,-10 -10)),\ + ((20 -1,21 2,30 -10)))", + 0.1, 0.01, strategy, true); + + tester("multilinestring((19 0,19.9 -1),(12 0,20.5 0.5))", + "multipolygon(((-10 -10,10 -10,10 10,-10 10,-10 -10)),\ + ((20 -1,21 2,30 -10,20 -1)))", + 0, 0, strategy, true); +} + +//=========================================================================== + +template +void test_distance_segment_box(Strategy const& strategy) +{ +#ifdef GEOMETRY_TEST_DEBUG + std::cout << std::endl; + std::cout << "2D segment/box distance tests" << std::endl; +#endif + typedef int_box_type B; + typedef segment_type S; + typedef int_segment_type IS; + + test_distance_of_geometries tester; + test_distance_of_geometries itester; + + // segments that intersect the box + tester(make_box2d(0, 0, 1, 1), + make_segment(-1, 0.5, 0.5, 0.75), + 0, 0, strategy); + tester(make_box2d(0, 0, 1, 1), + make_segment(-1, 0.5, 1.5, 0.75), + 0, 0, strategy); + tester(make_box2d(0, 0, 1, 1), + make_segment(0.5, -1, 0.5, 2), + 0, 0, strategy); + tester(make_box2d(0, 0, 1, 1), + make_segment(1, 1, 1.5, 0.75), + 0, 0, strategy); + tester(make_box2d(0, 0, 1, 1), + make_segment(2, 0, 0, 2), + 0, 0, strategy); + + // segment that has closest point on box boundary + tester(make_box2d(0, 0, 1, 1), + make_segment(4, 0.5, 5, 0.75), + 3, 9, strategy); + + // segment that has closest point on box corner + tester(make_box2d(0, 0, 1, 1), + make_segment(4, 0, 0, 4), + sqrt(2), 2, strategy); + itester(make_box2d(0, 0, 1, 1), + make_segment(-4, 0, 0, -4), + sqrt(8), 8, strategy); + itester(make_box2d(0, 0, 1, 1), + make_segment(-8, 4, 4, -8), + sqrt(8), 8, strategy); + tester(make_box2d(0, 0, 1, 1), + make_segment(-4, 0, 0, 4), + 1.5 * sqrt(2), 4.5, strategy); + tester(make_box2d(0, 0, 1, 1), + make_segment(-4, 0, 1, 5), + 1.5 * sqrt(2), 4.5, strategy); + itester(make_box2d(0, 0, 1, 1), + make_segment(0, -2, 3, 1), + 0.5 * sqrt(2), 0.5, strategy); + itester(make_box2d(0, 0, 1, 1), + make_segment(0, -2, 2, 2), + 0, 0, strategy); + + // horizontal segments + itester(make_box2d(0, 0, 1, 1), + make_segment(-2, -1, -1, -1), + sqrt(2), 2, strategy); + itester(make_box2d(0, 0, 1, 1), + make_segment(-1, -1, 0, -1), + 1, 1, strategy); + tester(make_box2d(0, 0, 1, 1), + make_segment(-0.5, -1, 0.5, -1), + 1, 1, strategy); + tester(make_box2d(0, 0, 1, 1), + make_segment(0.5, -1, 0.75, -1), + 1, 1, strategy); + tester(make_box2d(0, 0, 1, 1), + make_segment(0.5, -1, 1.25, -1), + 1, 1, strategy); + tester(make_box2d(0, 0, 1, 1), + make_segment(1, -1, 2, -1), + 1, 1, strategy); + tester(make_box2d(0, 0, 1, 1), + make_segment(2, -1, 3, -1), + sqrt(2), 2, strategy); + tester(make_box2d(0, 0, 1, 1), + make_segment(-2, -1, 2, -1), + 1, 1, strategy); + + tester(make_box2d(0, 0, 1, 1), + make_segment(-2, 0, -1, 0), + 1, 1, strategy); + tester(make_box2d(0, 0, 1, 1), + make_segment(-1, 0, 0, 0), + 0, 0, strategy); + tester(make_box2d(0, 0, 1, 1), + make_segment(-0.5, 0, 0.5, 0), + 0, 0, strategy); + tester(make_box2d(0, 0, 1, 1), + make_segment(0.5, 0, 0.75, 0), + 0, 0, strategy); + tester(make_box2d(0, 0, 1, 1), + make_segment(0.5, 0, 1.25, 0), + 0, 0, strategy); + tester(make_box2d(0, 0, 1, 1), + make_segment(1, 0, 2, 0), + 0, 0, strategy); + tester(make_box2d(0, 0, 1, 1), + make_segment(2, 0, 3, 0), + 1, 1, strategy); + tester(make_box2d(0, 0, 1, 1), + make_segment(-2, 0, 2, 0), + 0, 0, strategy); + + tester(make_box2d(0, 0, 1, 1), + make_segment(-2, 0.5, -1, 0.5), + 1, 1, strategy); + tester(make_box2d(0, 0, 1, 1), + make_segment(-1, 0.5, 0, 0.5), + 0, 0, strategy); + tester(make_box2d(0, 0, 1, 1), + make_segment(-0.5, 0.5, 0.5, 0.5), + 0, 0, strategy); + tester(make_box2d(0, 0, 1, 1), + make_segment(0.5, 0.5, 0.75, 0.5), + 0, 0, strategy); + tester(make_box2d(0, 0, 1, 1), + make_segment(0.5, 0.5, 1.25, 0.5), + 0, 0, strategy); + tester(make_box2d(0, 0, 1, 1), + make_segment(1, 0.5, 2, 0.5), + 0, 0, strategy); + tester(make_box2d(0, 0, 1, 1), + make_segment(2, 0.5, 3, 0.5), + 1, 1, strategy); + tester(make_box2d(0, 0, 1, 1), + make_segment(-2, 0.5, 2, 0.5), + 0, 0, strategy); + + tester(make_box2d(0, 0, 1, 1), + make_segment(-2, 1, -1, 1), + 1, 1, strategy); + tester(make_box2d(0, 0, 1, 1), + make_segment(-1, 1, 0, 1), + 0, 0, strategy); + tester(make_box2d(0, 0, 1, 1), + make_segment(-0.5, 1, 0.5, 1), + 0, 0, strategy); + tester(make_box2d(0, 0, 1, 1), + make_segment(0.5, 1, 0.75, 1), + 0, 0, strategy); + tester(make_box2d(0, 0, 1, 1), + make_segment(0.5, 1, 1.25, 1), + 0, 0, strategy); + tester(make_box2d(0, 0, 1, 1), + make_segment(1, 1, 2, 1), + 0, 0, strategy); + tester(make_box2d(0, 0, 1, 1), + make_segment(2, 1, 3, 1), + 1, 1, strategy); + tester(make_box2d(0, 0, 1, 1), + make_segment(-2, 1, 2, 1), + 0, 0, strategy); + + tester(make_box2d(0, 0, 1, 1), + make_segment(-2, 3, -1, 3), + sqrt(5), 5, strategy); + itester(make_box2d(0, 0, 1, 1), + make_segment(-1, 3, 0, 3), + 2, 4, strategy); + tester(make_box2d(0, 0, 1, 1), + make_segment(-0.5, 3, 0.5, 3), + 2, 4, strategy); + tester(make_box2d(0, 0, 1, 1), + make_segment(0.5, 3, 0.75, 3), + 2, 4, strategy); + tester(make_box2d(0, 0, 1, 1), + make_segment(0.5, 3, 1.25, 3), + 2, 4, strategy); + tester(make_box2d(0, 0, 1, 1), + make_segment(1, 3, 2, 3), + 2, 4, strategy); + tester(make_box2d(0, 0, 1, 1), + make_segment(2, 3, 3, 3), + sqrt(5), 5, strategy); + tester(make_box2d(0, 0, 1, 1), + make_segment(-2, 3, 2, 3), + 2, 4, strategy); + + // vertical segments + tester(make_box2d(0, 0, 1, 1), + make_segment(-1, -2, -1, -1), + sqrt(2), 2, strategy); + tester(make_box2d(0, 0, 1, 1), + make_segment(-1, -1, -1, 0), + 1, 1, strategy); + tester(make_box2d(0, 0, 1, 1), + make_segment(-1, -0.5, -1, 0.5), + 1, 1, strategy); + tester(make_box2d(0, 0, 1, 1), + make_segment(-1, 0.5, -1, 0.75), + 1, 1, strategy); + tester(make_box2d(0, 0, 1, 1), + make_segment(-1, 0.5, -1, 1.25), + 1, 1, strategy); + tester(make_box2d(0, 0, 1, 1), + make_segment(-1, 1, -1, 2), + 1, 1, strategy); + tester(make_box2d(0, 0, 1, 1), + make_segment(-1, 2, -1, 3), + sqrt(2), 2, strategy); + tester(make_box2d(0, 0, 1, 1), + make_segment(-1, -2, -1, 2), + 1, 1, strategy); + + tester(make_box2d(0, 0, 1, 1), + make_segment(0, -2, 0, -1), + 1, 1, strategy); + tester(make_box2d(0, 0, 1, 1), + make_segment(0, -1, 0, 0), + 0, 0, strategy); + tester(make_box2d(0, 0, 1, 1), + make_segment(0, -0.5, 0, 0.5), + 0, 0, strategy); + tester(make_box2d(0, 0, 1, 1), + make_segment(0, 0.5, 0, 0.75), + 0, 0, strategy); + tester(make_box2d(0, 0, 1, 1), + make_segment(0, 0.5, 0, 1.25), + 0, 0, strategy); + tester(make_box2d(0, 0, 1, 1), + make_segment(0, 1, 0, 2), + 0, 0, strategy); + tester(make_box2d(0, 0, 1, 1), + make_segment(0, 2, 0, 3), + 1, 1, strategy); + tester(make_box2d(0, 0, 1, 1), + make_segment(0, -2, 0, 2), + 0, 0, strategy); + + tester(make_box2d(0, 0, 1, 1), + make_segment(0.5, -2, 0.5, -1), + 1, 1, strategy); + tester(make_box2d(0, 0, 1, 1), + make_segment(0.5, -1, 0.5, 0), + 0, 0, strategy); + tester(make_box2d(0, 0, 1, 1), + make_segment(0.5, -0.5, 0.5, 0.5), + 0, 0, strategy); + tester(make_box2d(0, 0, 1, 1), + make_segment(0.5, 0.5, 0.5, 0.75), + 0, 0, strategy); + tester(make_box2d(0, 0, 1, 1), + make_segment(0.5, 0.5, 0.5, 1.25), + 0, 0, strategy); + tester(make_box2d(0, 0, 1, 1), + make_segment(0.5, 1, 0.5, 2), + 0, 0, strategy); + tester(make_box2d(0, 0, 1, 1), + make_segment(0.5, 2, 0.5, 3), + 1, 1, strategy); + tester(make_box2d(0, 0, 1, 1), + make_segment(0.5, -2, 0.5, 2), + 0, 0, strategy); + + tester(make_box2d(0, 0, 1, 1), + make_segment(1, -2, 1, -1), + 1, 1, strategy); + tester(make_box2d(0, 0, 1, 1), + make_segment(1, -1, 1, 0), + 0, 0, strategy); + tester(make_box2d(0, 0, 1, 1), + make_segment(1, -0.5, 1, 0.5), + 0, 0, strategy); + tester(make_box2d(0, 0, 1, 1), + make_segment(1, 0.5, 1, 0.75), + 0, 0, strategy); + tester(make_box2d(0, 0, 1, 1), + make_segment(1, 0.5, 1, 1.25), + 0, 0, strategy); + tester(make_box2d(0, 0, 1, 1), + make_segment(1, 1, 1, 2), + 0, 0, strategy); + tester(make_box2d(0, 0, 1, 1), + make_segment(1, 2, 1, 3), + 1, 1, strategy); + tester(make_box2d(0, 0, 1, 1), + make_segment(1, -2, 1, 2), + 0, 0, strategy); + + tester(make_box2d(0, 0, 1, 1), + make_segment(3, -2, 3, -1), + sqrt(5), 5, strategy); + tester(make_box2d(0, 0, 1, 1), + make_segment(3, -1, 3, 0), + 2, 4, strategy); + tester(make_box2d(0, 0, 1, 1), + make_segment(3, -0.5, 3, 0.5), + 2, 4, strategy); + tester(make_box2d(0, 0, 1, 1), + make_segment(3, 0.5, 3, 0.75), + 2, 4, strategy); + tester(make_box2d(0, 0, 1, 1), + make_segment(3, 0.5, 3, 1.25), + 2, 4, strategy); + tester(make_box2d(0, 0, 1, 1), + make_segment(3, 1, 3, 2), + 2, 4, strategy); + tester(make_box2d(0, 0, 1, 1), + make_segment(3, 2, 3, 3), + sqrt(5), 5, strategy); + tester(make_box2d(0, 0, 1, 1), + make_segment(3, -2, 3, 2), + 2, 4, strategy); + + // positive slope + itester(make_box2d(0, 0, 1, 1), + make_segment(-2, -2, -1, -1), + sqrt(2), 2, strategy); + tester(make_box2d(0, 0, 1, 1), + make_segment(-2, -2, 0, -0.5), + 0.5, 0.25, strategy); + tester(make_box2d(0, 0, 1, 1), + make_segment(-2, -2, 0.5, -0.5), + 0.5, 0.25, strategy); + tester(make_box2d(0, 0, 1, 1), + make_segment(-2, -2, 1, -0.5), + 0.5, 0.25, strategy); + tester(make_box2d(0, 0, 1, 1), + make_segment(-2, -2, 2, 0), + sqrt(0.2), 0.2, strategy); + tester(make_box2d(0, 0, 1, 1), + make_segment(-2, -2, 4, 1), + sqrt(0.2), 0.2, strategy); + tester(make_box2d(0, 0, 1, 1), + make_segment(-2, -2, -1.5, 0), + 1.5, 2.25, strategy); + tester(make_box2d(0, 0, 1, 1), + make_segment(-2, -2, -1.5, 0.5), + 1.5, 2.25, strategy); + tester(make_box2d(0, 0, 1, 1), + make_segment(-2, -2, -1.5, 1), + 1.5, 2.25, strategy); + tester(make_box2d(0, 0, 1, 1), + make_segment(-2, -2, 0, 2), + sqrt(0.2), 0.2, strategy); + tester(make_box2d(0, 0, 1, 1), + make_segment(-2, -2, 1, 4), + sqrt(0.2), 0.2, strategy); + tester(make_box2d(0, 0, 1, 1), + make_segment(-2, -2, 4, 2), + 0, 0, strategy); + tester(make_box2d(0, 0, 1, 1), + make_segment(-2, -2, 2, 4), + 0, 0, strategy); + tester(make_box2d(0, 0, 1, 1), + make_segment(-2, -2, 4, 3), + 0, 0, strategy); + tester(make_box2d(0, 0, 1, 1), + make_segment(-2, -2, 3, 4), + 0, 0, strategy); + tester(make_box2d(0, 0, 1, 1), + make_segment(-2, -2, 3, 3), + 0, 0, strategy); + + // negative slope + tester(make_box2d(0, 0, 1, 1), + make_segment(-2, -2, -1, -3), + sqrt(8), 8, strategy); + tester(make_box2d(0, 0, 1, 1), + make_segment(-3, -1, 0, -4), + sqrt(8), 8, strategy); + tester(make_box2d(0, 0, 1, 1), + make_segment(-2, 0.75, -1.5, 0.5), + 1.5, 2.25, strategy); + tester(make_box2d(0, 0, 1, 1), + make_segment(-2, 1.5, -1.5, 0.5), + 1.5, 2.25, strategy); + tester(make_box2d(0, 0, 1, 1), + make_segment(0.5, 2, 0.75, 1.5), + 0.5, 0.25, strategy); + tester(make_box2d(0, 0, 1, 1), + make_segment(-1, 2, 0.75, 1.5), + 0.5, 0.25, strategy); + tester(make_box2d(0, 0, 1, 1), + make_segment(0, 2, 2, 0), + 0, 0, strategy); + tester(make_box2d(0, 0, 1, 1), + make_segment(0, 3, 3, 0), + sqrt(0.5), 0.5, strategy); + tester(make_box2d(0, 0, 1, 1), + make_segment(-1, 4, 4, -1), + sqrt(0.5), 0.5, strategy); + tester(make_box2d(0, 0, 1, 1), + make_segment(-1, 4, 0, 3), + 2, 4, strategy); + tester(make_box2d(0, 0, 1, 1), + make_segment(-2, 5, -1, 4), + sqrt(10), 10, strategy); + tester(make_box2d(0, 0, 1, 1), + make_segment(3, -1, 4, -4), + sqrt(5), 5, strategy); + tester(make_box2d(0, 0, 1, 1), + make_segment(1, 2, 2, 1), + sqrt(0.5), 0.5, strategy); + tester(make_box2d(0, 0, 1, 1), + make_segment(0.5, -2, 2, -3), + 2, 4, strategy); + tester(make_box2d(0, 0, 1, 1), + make_segment(-1, -2, 0, -3), + sqrt(5), 5, strategy); + tester(make_box2d(0, 0, 1, 1), + make_segment(-1, -2, 0.5, -3.5), + sqrt(5), 5, strategy); + tester(make_box2d(0, 0, 1, 1), + make_segment(-1, -2, 0.5, -3.5), + sqrt(5), 5, strategy); + tester(make_box2d(0, 0, 1, 1), + make_segment(0.5, 3, 2.5, 2), + sqrt(2.45), 2.45, strategy); + tester(make_box2d(0, 0, 1, 1), + make_segment(0.5, 1.5, 1.5, -1.5), + 0, 0, strategy); +} + +//=========================================================================== + +template +void test_distance_linestring_box(Strategy const& strategy) +{ +#ifdef GEOMETRY_TEST_DEBUG + std::cout << std::endl; + std::cout << "linestring/box distance tests" << std::endl; +#endif + test_distance_of_geometries tester; + + // linestrings that intersect the box + tester("linestring(-1 0.5,0.5 0.75)", + make_box2d(0, 0, 1, 1), + 0, 0, strategy); + tester("linestring(-1 0.5,1.5 0.75)", + make_box2d(0, 0, 1, 1), + 0, 0, strategy); + + // linestring that has closest point on box boundary + tester("linestring(4 0.5,5 0.75)", + make_box2d(0, 0, 1, 1), + 3, 9, strategy); + + // linestring that has closest point on box corner + tester("linestring(4 0,0 4)", + make_box2d(0, 0, 1, 1), + sqrt(2), 2, strategy); +} + +//=========================================================================== + +template +void test_distance_multilinestring_box(Strategy const& strategy) +{ +#ifdef GEOMETRY_TEST_DEBUG + std::cout << std::endl; + std::cout << "multilinestring/box distance tests" << std::endl; +#endif + test_distance_of_geometries tester; + + // multilinestring that intersects the box + tester("multilinestring((-1 0.5,0.5 0.75),(4 0.5,5 0.75))", + make_box2d(0, 0, 1, 1), + 0, 0, strategy); + + // multilinestring that has closest point on box boundary + tester("multilinestring((4 0.5,5 0.75))", + make_box2d(0, 0, 1, 1), + 3, 9, strategy); + + // multilinestring that has closest point on box corner + tester("multilinestring((5 0,0 5),(4 0,0 4))", + make_box2d(0, 0, 1, 1), + sqrt(2), 2, strategy); +} + +//=========================================================================== + +template +void test_more_empty_input_linear_areal(Strategy const& strategy) +{ +#ifdef GEOMETRY_TEST_DEBUG + std::cout << std::endl; + std::cout << "testing on empty inputs... " << std::flush; +#endif + bg::model::linestring line_empty; + bg::model::polygon polygon_empty; + bg::model::multi_linestring > multiline_empty; + bg::model::multi_polygon > multipolygon_empty; + + bg::model::linestring line = + from_wkt >("linestring(0 0,1 1)"); + + bg::model::polygon polygon = + from_wkt >("polygon((0 0,1 0,0 1))"); + + // 1st geometry is empty + test_empty_input(line_empty, polygon, strategy); + test_empty_input(multiline_empty, polygon, strategy); + + // 2nd geometry is empty + test_empty_input(line, polygon_empty, strategy); + test_empty_input(line, multipolygon_empty, strategy); + + // both geometries are empty + test_empty_input(line_empty, polygon_empty, strategy); + test_empty_input(line_empty, multipolygon_empty, strategy); + test_empty_input(multiline_empty, polygon_empty, strategy); + test_empty_input(multiline_empty, multipolygon_empty, strategy); + +#ifdef GEOMETRY_TEST_DEBUG + std::cout << "done!" << std::endl; +#endif +} + +//=========================================================================== + +BOOST_AUTO_TEST_CASE( test_all_segment_polygon ) +{ + test_distance_segment_polygon(point_segment_strategy()); +} + +BOOST_AUTO_TEST_CASE( test_all_linestring_polygon ) +{ + test_distance_linestring_polygon(point_segment_strategy()); +} + +BOOST_AUTO_TEST_CASE( test_all_multilinestring_polygon ) +{ + test_distance_multilinestring_polygon(point_segment_strategy()); +} + +BOOST_AUTO_TEST_CASE( test_all_segment_multipolygon ) +{ + test_distance_segment_multipolygon(point_segment_strategy()); +} + +BOOST_AUTO_TEST_CASE( test_all_linestring_multipolygon ) +{ + test_distance_linestring_multipolygon(point_segment_strategy()); +} + +BOOST_AUTO_TEST_CASE( test_all_multilinestring_multipolygon ) +{ + test_distance_multilinestring_multipolygon(point_segment_strategy()); +} + +BOOST_AUTO_TEST_CASE( test_all_segment_box ) +{ + test_distance_segment_box(point_point_strategy()); + test_distance_segment_box(point_segment_strategy()); +} + +BOOST_AUTO_TEST_CASE( test_all_linestring_box ) +{ + test_distance_linestring_box(point_segment_strategy()); +} + +BOOST_AUTO_TEST_CASE( test_all_multilinestring_box ) +{ + test_distance_multilinestring_box(point_segment_strategy()); +} + +BOOST_AUTO_TEST_CASE( test_all_empty_input_linear_areal ) +{ + test_more_empty_input_linear_areal(point_segment_strategy()); +} diff --git a/test/algorithms/distance_linear_linear.cpp b/test/algorithms/distance_linear_linear.cpp new file mode 100644 index 000000000..17ac8874f --- /dev/null +++ b/test/algorithms/distance_linear_linear.cpp @@ -0,0 +1,268 @@ +// Boost.Geometry (aka GGL, Generic Geometry Library) +// Unit Test + +// Copyright (c) 2014, Oracle and/or its affiliates. + +// Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle + +// Licensed under the Boost Software License version 1.0. +// http://www.boost.org/users/license.html + +#include + +#ifndef BOOST_TEST_MODULE +#define BOOST_TEST_MODULE test_distance_linear_linear +#endif + +#include + +#include "test_distance_common.hpp" + + +typedef bg::model::point point_type; +typedef bg::model::segment segment_type; +typedef bg::model::linestring linestring_type; +typedef bg::model::multi_linestring multi_linestring_type; + +namespace services = bg::strategy::distance::services; +typedef bg::default_distance_result::type return_type; + +typedef bg::strategy::distance::projected_point<> point_segment_strategy; + +//=========================================================================== + +#ifdef BOOST_GEOMETRY_SUPPORT_SEGMENT_SEGMENT_DISTANCE +template +void test_distance_segment_segment(Strategy const& strategy) +{ +#ifdef GEOMETRY_TEST_DEBUG + std::cout << std::endl; + std::cout << "segment/segment distance tests" << std::endl; +#endif + test_distance_of_geometries tester; + + tester(make_segment(0, 0, 10, 0), + make_segment(4, 2, 4, 0.5), + return_type(0.5), return_type(0.25), strategy); + + tester(make_segment(0, 0, 10, 0), + make_segment(4, 2, 4, -0.5), + return_type(0), return_type(0), strategy); + + tester(make_segment(0, 0, 10, 0), + make_segment(4, 2, 0, 0), + return_type(0), return_type(0), strategy); + + tester(make_segment(0, 0, 10, 0), + make_segment(-2, 3, 1, 2), + return_type(2), return_type(4), strategy); +} +#endif // BOOST_GEOMETRY_SUPPORT_SEGMENT_SEGMENT_DISTANCE + +//=========================================================================== + +template +void test_distance_segment_linestring(Strategy const& strategy) +{ +#ifdef GEOMETRY_TEST_DEBUG + std::cout << std::endl; + std::cout << "segment/linestring distance tests" << std::endl; +#endif + test_distance_of_geometries tester; + + tester(make_segment(-1, -1, -2, -2), + "linestring(2 1,1 2,4 0)", + sqrt(12.5), 12.5, strategy); + + tester(make_segment(1, 1, 2, 2), + "linestring(2 1,1 2,4 0)", + 0, 0, strategy); +} + +//=========================================================================== + +template +void test_distance_linestring_linestring(Strategy const& strategy) +{ +#ifdef GEOMETRY_TEST_DEBUG + std::cout << std::endl; + std::cout << "linestring/linestring distance tests" << std::endl; +#endif + test_distance_of_geometries tester; + + // It is not obvious that linestrings with only one point are valid + tester("linestring(1 1)", "linestring(2 1)", 1, 1, strategy); + + tester("linestring(1 1,3 1)", "linestring(2 1)", 0, 0, strategy); + + tester("linestring(1 1)", "linestring(0 0,-2 0,2 -2,2 0)", + sqrt(2.0), 2, strategy); + + tester("linestring(1 1,1 1)", "linestring(2 1,2 1)", 1, 1, strategy); + + tester("linestring(1 1,1 1,1 1)", "linestring(2 1,2 1,2 1,2 1)", + 1, 1, strategy); + + tester("linestring(1 1,3 1)", "linestring(2 1,2 1)", 0, 0, strategy); + + tester("linestring(1 1,1 1)", "linestring(0 0,-2 0,2 -2,2 0)", + sqrt(2.0), 2, strategy); + + tester("linestring(1 1,3 1)", "linestring(2 1, 4 1)", 0, 0, strategy); + + tester("linestring(1 1,2 2,3 3)", "linestring(2 1,1 2,4 0)", + 0, 0, strategy); + + tester("linestring(1 1,2 2,3 3)", "linestring(1 0,2 -1,4 0)", + 1, 1, strategy); + + tester("linestring(1 1,2 2,3 3)", "linestring(1 -10,2 0,2.1 -10,4 0)", + sqrt(2.0), 2, strategy); + + tester("linestring(1 1,2 2,3 3)", "linestring(1 -10,2 1.9,2.1 -10,4 0)", + sqrt(0.005), 0.005, strategy); + + tester("linestring(1 1,1 2)", "linestring(0 0,-2 0,2 -2,2 0)", + sqrt(2.0), 2, strategy); +} + +//=========================================================================== + +template +void test_distance_segment_multilinestring(Strategy const& strategy) +{ +#ifdef GEOMETRY_TEST_DEBUG + std::cout << std::endl; + std::cout << "segment/multilinestring distance tests" << std::endl; +#endif + test_distance_of_geometries tester; + + tester(make_segment(-1, -1, -2, -2), + "multilinestring((2 1,1 2),(4 0,4 10))", + sqrt(12.5), 12.5, strategy); + + tester(make_segment(1, 1, 2, 2), + "multilinestring((2 1,1 2),(4 0,4 10))", + 0, 0, strategy); +} + +//=========================================================================== + +template +void test_distance_linestring_multilinestring(Strategy const& strategy) +{ +#ifdef GEOMETRY_TEST_DEBUG + std::cout << std::endl; + std::cout << "linestring/multilinestring distance tests" << std::endl; +#endif + + test_distance_of_geometries tester; + + tester("linestring(1 1,2 2,3 3)", + "multilinestring((2 1,1 2,4 0),(1 -10,2 1.9,2.1 -10,4 0))", + 0, 0, strategy, true); + + tester("linestring(1 1,2 2,3 3)", + "multilinestring((1 -10,2 0,2.1 -10,4 0),(1 -10,2 1.9,2.1 -10,4 0))", + sqrt(0.005), 0.005, strategy, true); +} + +//=========================================================================== + +template +void test_distance_multilinestring_multilinestring(Strategy const& strategy) +{ +#ifdef GEOMETRY_TEST_DEBUG + std::cout << std::endl; + std::cout << "multilinestring/multilinestring distance tests" << std::endl; +#endif + + test_distance_of_geometries + < + multi_linestring_type, multi_linestring_type + > tester; + + tester("multilinestring((0 0,0 1,1 1),(10 0,11 1,12 2))", + "multilinestring((0.5 0.5,0.75 0.75),(11 0,11 7))", + 0, 0, strategy); + + tester("multilinestring((0 0,0 1,1 1),(10 0,11 1,12 2))", + "multilinestring((0.5 0.5,0.75 0.75),(11 0,11 0.9))", + sqrt(0.005), 0.005, strategy); + + tester("multilinestring((0 0,0 1,1 1),(10 0,11 1,12 2))", + "multilinestring((0.5 0.5,0.75 0.75),(11.1 0,11.1 0.9))", + sqrt(0.02), 0.02, strategy); +} + +//=========================================================================== + +template +void test_more_empty_input_linear_linear(Strategy const& strategy) +{ +#ifdef GEOMETRY_TEST_DEBUG + std::cout << std::endl; + std::cout << "testing on empty inputs... " << std::flush; +#endif + bg::model::linestring line_empty; + bg::model::multi_linestring > multiline_empty; + + bg::model::linestring line = + from_wkt >("linestring(0 0,1 1)"); + + // 1st geometry is empty + test_empty_input(line_empty, line, strategy); + test_empty_input(multiline_empty, line, strategy); + + // 2nd geometry is empty + test_empty_input(line, line_empty, strategy); + test_empty_input(line, multiline_empty, strategy); + + // both geometries are empty + test_empty_input(line_empty, line_empty, strategy); + test_empty_input(line_empty, multiline_empty, strategy); + test_empty_input(multiline_empty, multiline_empty, strategy); + +#ifdef GEOMETRY_TEST_DEBUG + std::cout << "done!" << std::endl; +#endif +} + +//=========================================================================== + +#ifdef BOOST_GEOMETRY_SUPPORT_SEGMENT_SEGMENT_DISTANCE +BOOST_AUTO_TEST_CASE( test_all_segment_segment ) +{ + test_distance_segment_segment(point_segment_strategy()); +} +#endif // BOOST_GEOMETRY_SUPPORT_SEGMENT_SEGMENT_DISTANCE + +BOOST_AUTO_TEST_CASE( test_all_segment_linestring ) +{ + test_distance_segment_linestring(point_segment_strategy()); +} + +BOOST_AUTO_TEST_CASE( test_all_linestring_linestring ) +{ + test_distance_linestring_linestring(point_segment_strategy()); +} + +BOOST_AUTO_TEST_CASE( test_all_segment_multilinestring ) +{ + test_distance_segment_multilinestring(point_segment_strategy()); +} + +BOOST_AUTO_TEST_CASE( test_all_linestring_multilinestring ) +{ + test_distance_linestring_multilinestring(point_segment_strategy()); +} + +BOOST_AUTO_TEST_CASE( test_all_multilinestring_multilinestring ) +{ + test_distance_multilinestring_multilinestring(point_segment_strategy()); +} + +BOOST_AUTO_TEST_CASE( test_all_empty_input_linear_linear ) +{ + test_more_empty_input_linear_linear(point_segment_strategy()); +} diff --git a/test/algorithms/distance_pointlike_areal.cpp b/test/algorithms/distance_pointlike_areal.cpp new file mode 100644 index 000000000..78e42a4f9 --- /dev/null +++ b/test/algorithms/distance_pointlike_areal.cpp @@ -0,0 +1,547 @@ +// Boost.Geometry (aka GGL, Generic Geometry Library) +// Unit Test + +// Copyright (c) 2014, Oracle and/or its affiliates. + +// Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle + +// Licensed under the Boost Software License version 1.0. +// http://www.boost.org/users/license.html + +#include + +#ifndef BOOST_TEST_MODULE +#define BOOST_TEST_MODULE test_distance_pointlike_areal +#endif + +#include + +#include "test_distance_common.hpp" + + +typedef bg::model::point point_type; +typedef bg::model::multi_point multi_point_type; +typedef bg::model::point point_type_3d; +typedef bg::model::multi_point multi_point_type_3d; +typedef bg::model::polygon polygon_type; +typedef bg::model::multi_polygon multi_polygon_type; +typedef bg::model::box box_type; +typedef bg::model::box box_type_3d; + +namespace services = bg::strategy::distance::services; +typedef bg::default_distance_result::type return_type; + +typedef bg::strategy::distance::pythagoras<> point_point_strategy; +typedef bg::strategy::distance::projected_point<> point_segment_strategy; +typedef bg::strategy::distance::pythagoras_point_box<> point_box_strategy; + +//=========================================================================== + +template +void test_distance_point_polygon(Strategy const& strategy) +{ +#ifdef GEOMETRY_TEST_DEBUG + std::cout << std::endl; + std::cout << "point/polygon distance tests" << std::endl; +#endif + test_distance_of_geometries tester; + + tester("point(0 -20)", + "polygon((-10 -10,10 -10,10 10,-10 10,-10 -10))", + 10, 100, strategy); + + tester("point(12 0)", + "polygon((-10 -10,10 -10,10 10,-10 10,-10 -10))", + 2, 4, strategy); + + tester("point(0 0)", + "polygon((-10 -10,10 -10,10 10,-10 10,-10 -10))", + 0, 0, strategy); + + tester("point(0 0)", + "polygon((-10 -10,10 -10,10 10,-10 10,-10 -10),\ + (-5 -5,-5 5,5 5,5 -5,-5 -5))", + 5, 25, strategy); +} + +//=========================================================================== + +template +void test_distance_point_multipolygon(Strategy const& strategy) +{ +#ifdef GEOMETRY_TEST_DEBUG + std::cout << std::endl; + std::cout << "point/multipolygon distance tests" << std::endl; +#endif + test_distance_of_geometries tester; + + tester("point(0 -20)", + "multipolygon(((-10 -10,10 -10,10 10,-10 10,-10 -10)),\ + ((0 22,-1 30,2 40,0 22)))", + 10, 100, strategy); + + tester("point(12 0)", + "multipolygon(((-10 -10,10 -10,10 10,-10 10,-10 -10)),\ + ((20 -1,21 2,30 -10,20 -1)))", + 2, 4, strategy); + + tester("point(0 0)", + "multipolygon(((-10 -10,10 -10,10 10,-10 10,-10 -10)),\ + ((20 -1,21 2,30 -10,20 -1)))", + 0, 0, strategy); + + tester("point(0 0)", + "multipolygon(((-10 -10,10 -10,10 10,-10 10,-10 -10),\ + (-5 -5,-5 5,5 5,5 -5,-5 -5)),\ + ((100 0,101 0,101 1,100 1,100 0)))", + 5, 25, strategy); +} + +//=========================================================================== + +template +void test_distance_multipoint_polygon(Strategy const& strategy) +{ +#ifdef GEOMETRY_TEST_DEBUG + std::cout << std::endl; + std::cout << "multipoint/polygon distance tests" << std::endl; +#endif + test_distance_of_geometries tester; + + tester("multipoint(0 -20,0 -15)", + "polygon((-10 -10,10 -10,10 10,-10 10,-10 -10))", + 5, 25, strategy); + + tester("multipoint(16 0,12 0)", + "polygon((-10 -10,10 -10,10 10,-10 10,-10 -10))", + 2, 4, strategy); + + tester("multipoint(0 0,5 5,4 4)", + "polygon((-10 -10,10 -10,10 10,-10 10,-10 -10))", + 0, 0, strategy); + + tester("multipoint(0 0,2 0)", + "polygon((-10 -10,10 -10,10 10,-10 10,-10 -10),\ + (-5 -5,-5 5,5 5,5 -5,-5 -5))", + 3, 9, strategy); +} + +//=========================================================================== + +template +void test_distance_multipoint_multipolygon(Strategy const& strategy) +{ +#ifdef GEOMETRY_TEST_DEBUG + std::cout << std::endl; + std::cout << "multipoint/multipolygon distance tests" << std::endl; +#endif + test_distance_of_geometries tester; + + tester("multipoint(0 -20,0 -15)", + "multipolygon(((-10 -10,10 -10,10 10,-10 10,-10 -10)),\ + ((0 22,-1 30,2 40,0 22)))", + 5, 25, strategy); + + tester("multipoint(16 0,12 0)", + "multipolygon(((-10 -10,10 -10,10 10,-10 10,-10 -10)),\ + ((20 -1,21 2,30 -10,20 -1)))", + 2, 4, strategy); + + tester("multipoint(0 0,4 4,5 5)", + "multipolygon(((-10 -10,10 -10,10 10,-10 10,-10 -10)),\ + ((20 -1,21 2,30 -10,20 -1)))", + 0, 0, strategy); + + tester("multipoint(0 0,2 0)", + "multipolygon(((-10 -10,10 -10,10 10,-10 10,-10 -10),\ + (-5 -5,-5 5,5 5,5 -5,-5 -5)),\ + ((100 0,101 0,101 1,100 1,100 0)))", + 3, 9, strategy); +} + +//=========================================================================== + +template +void test_distance_point_box_2d(Strategy const& strategy) +{ +#ifdef GEOMETRY_TEST_DEBUG + std::cout << std::endl; + std::cout << "2D point/box distance tests" << std::endl; +#endif + test_distance_of_geometries tester; + + // point inside box + tester(make_box2d(-1, -1, 1, 1), + "point(0 0)", 0, 0, strategy); + + // points on box corners + tester(make_box2d(-1, -1, 1, 1), + "point(-1 -1)", 0, 0, strategy); + tester(make_box2d(-1, -1, 1, 1), + "point(-1 1)", 0, 0, strategy); + tester(make_box2d(-1, -1, 1, 1), + "point(1 -1)", 0, 0, strategy); + tester(make_box2d(-1, -1, 1, 1), + "point(1 1)", 0, 0, strategy); + + // points on box boundary edges + tester(make_box2d(-1, -1, 1, 1), + "point(0 -1)", 0, 0, strategy); + tester(make_box2d(-1, -1, 1, 1), + "point(-1 0)", 0, 0, strategy); + tester(make_box2d(-1, -1, 1, 1), + "point(1 0)", 0, 0, strategy); + tester(make_box2d(-1, -1, 1, 1), + "point(0 1)", 0, 0, strategy); + + // points outside box + tester(make_box2d(-1, -1, 1, 1), + "point(0 4)", 3, 9, strategy); + tester(make_box2d(-1, -1, 1, 1), + "point(0.5 4)", 3, 9, strategy); + tester(make_box2d(-1, -1, 1, 1), + "point(-0.5 5)", 4, 16, strategy); + tester(make_box2d(-1, -1, 1, 1), + "point(3 0.25)", 2, 4, strategy); + tester(make_box2d(-1, -1, 1, 1), + "point(-3 -0.25)", 2, 4, strategy); + tester(make_box2d(-1, -1, 1, 1), + "point(3 5)", sqrt(20), 20, strategy); + tester(make_box2d(-1, -1, 1, 1), + "point(-5 -4)", 5, 25, strategy); + tester(make_box2d(-1, -1, 1, 1), + "point(2 -2)", sqrt(2), 2, strategy); + tester(make_box2d(-1, -1, 1, 1), + "point(-3 4)", sqrt(13), 13, strategy); +} + +//=========================================================================== + +template +void test_distance_point_box_different_point_types(Strategy const& strategy) +{ +#ifdef GEOMETRY_TEST_DEBUG + std::cout << std::endl; + std::cout << "2D point/box distance tests with different points" + << std::endl; +#endif + typedef point_type double_point; + typedef box_type double_box; + typedef bg::model::point int_point; + typedef bg::model::box int_box; + + test_distance_of_geometries() + ("point(0 0)", + make_box2d(1, 1, 2, 2), + sqrt(2), 2, strategy); + + test_distance_of_geometries() + ("point(0.5 0)", + make_box2d(1, -1, 2, 1), + 0.5, 0.25, strategy); + + test_distance_of_geometries() + ("point(1.5 0)", + make_box2d(1, -1, 2, 1), + 0, 0, strategy); + + test_distance_of_geometries() + ("point(1.5 0)", + make_box2d(1, -1, 2, 1), + 0, 0, strategy); + + test_distance_of_geometries() + ("point(1 0)", + make_box2d(0.5, -1, 1.5, 1), + 0, 0, strategy); + + test_distance_of_geometries() + ("point(0 0)", + make_box2d(0.5, -1, 1.5, 1), + 0.5, 0.25, strategy); +} + +//=========================================================================== + +template +void test_distance_point_box_3d(Strategy const& strategy) +{ +#ifdef GEOMETRY_TEST_DEBUG + std::cout << std::endl; + std::cout << "3D point/box distance tests" << std::endl; +#endif + test_distance_of_geometries tester; + + // point inside box + tester(make_box3d(-1, -1, -1, 1, 1, 1), + "point(0 0 0)", 0, 0, strategy); + + // points on box corners + tester(make_box3d(-1, -1, -1, 1, 1, 1), + "point(-1 -1 -1)", 0, 0, strategy); + tester(make_box3d(-1, -1, -1, 1, 1, 1), + "point(-1 -1 1)", 0, 0, strategy); + tester(make_box3d(-1, -1, -1, 1, 1, 1), + "point(-1 1 -1)", 0, 0, strategy); + tester(make_box3d(-1, -1, -1, 1, 1, 1), + "point(-1 1 1)", 0, 0, strategy); + tester(make_box3d(-1, -1, -1, 1, 1, 1), + "point(1 -1 -1)", 0, 0, strategy); + tester(make_box3d(-1, -1, -1, 1, 1, 1), + "point(1 -1 1)", 0, 0, strategy); + tester(make_box3d(-1, -1, -1, 1, 1, 1), + "point(1 1 -1)", 0, 0, strategy); + tester(make_box3d(-1, -1, -1, 1, 1, 1), + "point(1 1 1)", 0, 0, strategy); + + // points on box boundary edges + tester(make_box3d(-1, -1, -1, 1, 1, 1), + "point(0 -1 -1)", 0, 0, strategy); + tester(make_box3d(-1, -1, -1, 1, 1, 1), + "point(0 -1 1)", 0, 0, strategy); + tester(make_box3d(-1, -1, -1, 1, 1, 1), + "point(0 1 -1)", 0, 0, strategy); + tester(make_box3d(-1, -1, -1, 1, 1, 1), + "point(0 1 1)", 0, 0, strategy); + + tester(make_box3d(-1, -1, -1, 1, 1, 1), + "point(-1 0 -1)", 0, 0, strategy); + tester(make_box3d(-1, -1, -1, 1, 1, 1), + "point(-1 0 1)", 0, 0, strategy); + tester(make_box3d(-1, -1, -1, 1, 1, 1), + "point(1 0 -1)", 0, 0, strategy); + tester(make_box3d(-1, -1, -1, 1, 1, 1), + "point(1 0 1)", 0, 0, strategy); + + tester(make_box3d(-1, -1, -1, 1, 1, 1), + "point(-1 -1 0)", 0, 0, strategy); + tester(make_box3d(-1, -1, -1, 1, 1, 1), + "point(-1 1 0)", 0, 0, strategy); + tester(make_box3d(-1, -1, -1, 1, 1, 1), + "point(1 -1 0)", 0, 0, strategy); + tester(make_box3d(-1, -1, -1, 1, 1, 1), + "point(1 1 0)", 0, 0, strategy); + + // point on box faces + tester(make_box3d(-1, -1, -1, 1, 1, 1), + "point(0 0 -1)", 0, 0, strategy); + tester(make_box3d(-1, -1, -1, 1, 1, 1), + "point(0 0 1)", 0, 0, strategy); + tester(make_box3d(-1, -1, -1, 1, 1, 1), + "point(0 -1 0)", 0, 0, strategy); + tester(make_box3d(-1, -1, -1, 1, 1, 1), + "point(0 1 0)", 0, 0, strategy); + tester(make_box3d(-1, -1, -1, 1, 1, 1), + "point(-1 0 0)", 0, 0, strategy); + tester(make_box3d(-1, -1, -1, 1, 1, 1), + "point(1 0 0)", 0, 0, strategy); + + // points outside box -- closer to box corners + tester(make_box3d(-1, -1, -1, 1, 1, 1), + "point(-2 -3 -4)", sqrt(14), 14, strategy); + tester(make_box3d(-1, -1, -1, 1, 1, 1), + "point(-2 -3 3)", 3, 9, strategy); + tester(make_box3d(-1, -1, -1, 1, 1, 1), + "point(-2 5 -2)", sqrt(18), 18, strategy); + tester(make_box3d(-1, -1, -1, 1, 1, 1), + "point(-2 5 3)", sqrt(21), 21, strategy); + tester(make_box3d(-1, -1, -1, 1, 1, 1), + "point(4 -6 -3)", sqrt(38), 38, strategy); + tester(make_box3d(-1, -1, -1, 1, 1, 1), + "point(4 -6 4)", sqrt(43), 43, strategy); + tester(make_box3d(-1, -1, -1, 1, 1, 1), + "point(4 7 -2)", sqrt(46), 46, strategy); + tester(make_box3d(-1, -1, -1, 1, 1, 1), + "point(4 7 8)", sqrt(94), 94, strategy); + + + // points closer to box facets + tester(make_box3d(-1, -1, -1, 1, 1, 1), + "point(0 0 10)", 9, 81, strategy); + tester(make_box3d(-1, -1, -1, 1, 1, 1), + "point(0 0 -5)", 4, 16, strategy); + tester(make_box3d(-1, -1, -1, 1, 1, 1), + "point(0 7 0)", 6, 36, strategy); + tester(make_box3d(-1, -1, -1, 1, 1, 1), + "point(0 -6 0)", 5, 25, strategy); + tester(make_box3d(-1, -1, -1, 1, 1, 1), + "point(4 0 0)", 3, 9, strategy); + tester(make_box3d(-1, -1, -1, 1, 1, 1), + "point(-3 0 0)", 2, 4, strategy); + + // points closer to box edges + tester(make_box3d(-1, -1, -1, 1, 1, 1), + "point(0 -4 -5)", 5, 25, strategy); + tester(make_box3d(-1, -1, -1, 1, 1, 1), + "point(0 -3 6)", sqrt(29), 29, strategy); + tester(make_box3d(-1, -1, -1, 1, 1, 1), + "point(0 2 -7)", sqrt(37), 37, strategy); + tester(make_box3d(-1, -1, -1, 1, 1, 1), + "point(0 8 7)", sqrt(85), 85, strategy); + + tester(make_box3d(-1, -1, -1, 1, 1, 1), + "point(-4 0 -4)", sqrt(18), 18, strategy); + tester(make_box3d(-1, -1, -1, 1, 1, 1), + "point(-3 0 5)", sqrt(20), 20, strategy); + tester(make_box3d(-1, -1, -1, 1, 1, 1), + "point(2 0 -6)", sqrt(26), 26, strategy); + tester(make_box3d(-1, -1, -1, 1, 1, 1), + "point(8 0 6)", sqrt(74), 74, strategy); + + tester(make_box3d(-1, -1, -1, 1, 1, 1), + "point(-5 -5 0)", sqrt(32), 32, strategy); + tester(make_box3d(-1, -1, -1, 1, 1, 1), + "point(-4 6 0)", sqrt(34), 34, strategy); + tester(make_box3d(-1, -1, -1, 1, 1, 1), + "point(3 -7 0)", sqrt(40), 40, strategy); + tester(make_box3d(-1, -1, -1, 1, 1, 1), + "point(9 7 0)", 10, 100, strategy); +} + +//=========================================================================== + +template +void test_distance_multipoint_box_2d(Strategy const& strategy) +{ +#ifdef GEOMETRY_TEST_DEBUG + std::cout << std::endl; + std::cout << "2D multipoint/box distance tests" << std::endl; +#endif + test_distance_of_geometries tester; + + // at least one point inside the box + tester(make_box2d(0, 0, 10, 10), + "multipoint(0 0,-1 -1,20 20)", 0, 0, strategy); + + tester(make_box2d(0, 0, 10, 10), + "multipoint(1 1,-1 -1,20 20)", 0, 0, strategy); + + tester(make_box2d(0, 0, 10, 10), + "multipoint(1 1,2 2,3 3)", 0, 0, strategy); + + // all points outside the box + tester(make_box2d(0, 0, 10, 10), + "multipoint(-1 -1,20 20)", sqrt(2), 2, strategy); + + tester(make_box2d(0, 0, 10, 10), + "multipoint(5 13, 50 50)", 3, 9, strategy); +} + +//=========================================================================== + +template +void test_distance_multipoint_box_3d(Strategy const& strategy) +{ +#ifdef GEOMETRY_TEST_DEBUG + std::cout << std::endl; + std::cout << "3D multipoint/box distance tests" << std::endl; +#endif + test_distance_of_geometries tester; + + // at least one point inside the box + tester(make_box3d(0, 0, 0, 10, 10, 10), + "multipoint(0 0 0,-1 -1 -1,20 20 20)", 0, 0, strategy); + + tester(make_box3d(0, 0, 0, 10, 10, 10), + "multipoint(1 1 1,-1 -1 -1,20 20 20)", 0, 0, strategy); + + tester(make_box3d(0, 0, 0, 10, 10, 10), + "multipoint(1 1 1,2 2 2,3 3 3)", 0, 0, strategy); + + // all points outside the box + tester(make_box3d(0, 0, 0, 10, 10, 10), + "multipoint(-1 -1 -1,20 20 20)", sqrt(3), 3, strategy); + + tester(make_box3d(0, 0, 0, 10, 10, 10), + "multipoint(5 5 13,50 50 50)", 3, 9, strategy); +} + +//=========================================================================== + +template +void test_more_empty_input_pointlike_areal(Strategy const& strategy) +{ +#ifdef GEOMETRY_TEST_DEBUG + std::cout << std::endl; + std::cout << "testing on empty inputs... " << std::flush; +#endif + bg::model::multi_point multipoint_empty; + bg::model::polygon polygon_empty; + bg::model::multi_polygon > multipolygon_empty; + + Point point = from_wkt("point(0 0)"); + bg::model::polygon polygon = + from_wkt >("polygon((0 0,1 0,0 1))"); + + // 1st geometry is empty + test_empty_input(multipoint_empty, polygon, strategy); + + // 2nd geometry is empty + test_empty_input(point, polygon_empty, strategy); + test_empty_input(point, multipolygon_empty, strategy); + + // both geometries are empty + test_empty_input(multipoint_empty, polygon_empty, strategy); + test_empty_input(multipoint_empty, multipolygon_empty, strategy); + +#ifdef GEOMETRY_TEST_DEBUG + std::cout << "done!" << std::endl; +#endif +} + +//=========================================================================== + +BOOST_AUTO_TEST_CASE( test_all_point_polygon ) +{ + test_distance_point_polygon(point_point_strategy()); // back-compatibility + test_distance_point_polygon(point_segment_strategy()); +} + +BOOST_AUTO_TEST_CASE( test_all_point_multipolygon ) +{ + test_distance_point_multipolygon(point_point_strategy()); // back-compatibility + test_distance_point_multipolygon(point_segment_strategy()); +} + +BOOST_AUTO_TEST_CASE( test_all_multipoint_polygon ) +{ + test_distance_multipoint_polygon(point_point_strategy()); // back-compatibility + test_distance_multipoint_polygon(point_segment_strategy()); +} + +BOOST_AUTO_TEST_CASE( test_all_multipoint_multipolygon ) +{ + test_distance_multipoint_multipolygon(point_point_strategy()); // back-compatibility + test_distance_multipoint_multipolygon(point_segment_strategy()); +} + +BOOST_AUTO_TEST_CASE( test_all_point_box_2d ) +{ + point_box_strategy pb_strategy; + + test_distance_point_box_2d(pb_strategy); + test_distance_point_box_different_point_types(pb_strategy); +} + +BOOST_AUTO_TEST_CASE( test_all_point_box_3d ) +{ + test_distance_point_box_3d(point_box_strategy()); +} + +BOOST_AUTO_TEST_CASE( test_all_multipoint_box_2d ) +{ + test_distance_multipoint_box_2d(point_box_strategy()); +} + +BOOST_AUTO_TEST_CASE( test_all_multipoint_box_3d ) +{ + test_distance_multipoint_box_3d(point_box_strategy()); +} + +BOOST_AUTO_TEST_CASE( test_all_empty_input_pointlike_areal ) +{ + test_more_empty_input_pointlike_areal + < + point_type + >(point_segment_strategy()); +} diff --git a/test/algorithms/distance_pointlike_linear.cpp b/test/algorithms/distance_pointlike_linear.cpp new file mode 100644 index 000000000..9fe7f84c7 --- /dev/null +++ b/test/algorithms/distance_pointlike_linear.cpp @@ -0,0 +1,250 @@ +// Boost.Geometry (aka GGL, Generic Geometry Library) +// Unit Test + +// Copyright (c) 2014, Oracle and/or its affiliates. + +// Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle + +// Licensed under the Boost Software License version 1.0. +// http://www.boost.org/users/license.html + +#include + +#ifndef BOOST_TEST_MODULE +#define BOOST_TEST_MODULE test_distance_pointlike_linear +#endif + +#include + +#include "test_distance_common.hpp" + + +typedef bg::model::point point_type; +typedef bg::model::multi_point multi_point_type; +typedef bg::model::segment segment_type; +typedef bg::model::linestring linestring_type; +typedef bg::model::multi_linestring multi_linestring_type; + +namespace services = bg::strategy::distance::services; +typedef bg::default_distance_result::type return_type; + +typedef bg::strategy::distance::pythagoras<> point_point_strategy; +typedef bg::strategy::distance::projected_point<> point_segment_strategy; + + +//=========================================================================== + + +template +void test_distance_point_segment(Strategy const& strategy) +{ +#ifdef GEOMETRY_TEST_DEBUG + std::cout << std::endl; + std::cout << "point/segment distance tests" << std::endl; +#endif + test_distance_of_geometries tester; + + tester("point(0 0)", "segment(2 0,3 0)", 2, 4, strategy); + tester("point(2.5 3)", "segment(2 0,3 0)", 3, 9, strategy); + tester("point(2 0)", "segment(2 0,3 0)", 0, 0, strategy); + tester("point(3 0)", "segment(2 0,3 0)", 0, 0, strategy); + tester("point(2.5 0)", "segment(2 0,3 0)", 0, 0, strategy); +} + +//=========================================================================== + +template +void test_distance_point_linestring(Strategy const& strategy) +{ +#ifdef GEOMETRY_TEST_DEBUG + std::cout << std::endl; + std::cout << "point/linestring distance tests" << std::endl; +#endif + test_distance_of_geometries tester; + + tester("point(0 0)", "linestring(2 0)", 2, 4, strategy); + tester("point(0 0)", "linestring(2 0,3 0)", 2, 4, strategy); + tester("point(2.5 3)", "linestring(2 0,3 0)", 3, 9, strategy); + tester("point(2 0)", "linestring(2 0,3 0)", 0, 0, strategy); + tester("point(3 0)", "linestring(2 0,3 0)", 0, 0, strategy); + tester("point(2.5 0)", "linestring(2 0,3 0)", 0, 0, strategy); +} + +//=========================================================================== + +template +void test_distance_point_multilinestring(Strategy const& strategy) +{ +#ifdef GEOMETRY_TEST_DEBUG + std::cout << std::endl; + std::cout << "point/multilinestring distance tests" << std::endl; +#endif + test_distance_of_geometries tester; + + tester("point(0 0)", "multilinestring((-5 0,-3 0),(2 0,3 0))", + 2, 4, strategy); + tester("point(2.5 3)", "multilinestring((-5 0,-3 0),(2 0,3 0))", + 3, 9, strategy); + tester("point(2 0)", "multilinestring((-5 0,-3 0),(2 0,3 0))", + 0, 0, strategy); + tester("point(3 0)", "multilinestring((-5 0,-3 0),(2 0,3 0))", + 0, 0, strategy); + tester("point(2.5 0)", "multilinestring((-5 0,-3 0),(2 0,3 0))", + 0, 0, strategy); +} + +//=========================================================================== + +template +void test_distance_linestring_multipoint(Strategy const& strategy) +{ +#ifdef GEOMETRY_TEST_DEBUG + std::cout << std::endl; + std::cout << "linestring/multipoint distance tests" << std::endl; +#endif + test_distance_of_geometries tester; + + tester("linestring(2 0,0 2,100 100)", + "multipoint(0 0,1 0,0 1,1 1)", + 0, 0, strategy); + tester("linestring(4 0,0 4,100 100)", + "multipoint(0 0,1 0,0 1,1 1)", + sqrt(2.0), 2, strategy); + tester("linestring(1 1,2 2,100 100)", + "multipoint(0 0,1 0,0 1,1 1)", + 0, 0, strategy); + tester("linestring(3 3,4 4,100 100)", + "multipoint(0 0,1 0,0 1,1 1)", + sqrt(8.0), 8, strategy); +} + +//=========================================================================== + +template +void test_distance_multipoint_multilinestring(Strategy const& strategy) +{ +#ifdef GEOMETRY_TEST_DEBUG + std::cout << std::endl; + std::cout << "multipoint/multilinestring distance tests" << std::endl; +#endif + test_distance_of_geometries tester; + + tester("multipoint(0 0,1 0,0 1,1 1)", + "multilinestring((2 0,0 2),(2 2,3 3))", + 0, 0, strategy); + tester("multipoint(0 0,1 0,0 1,1 1)", + "multilinestring((3 0,0 3),(4 4,5 5))", + 0.5 * sqrt(2.0), 0.5, strategy); + tester("multipoint(0 0,1 0,0 1,1 1)", + "multilinestring((4 4,5 5),(1 1,2 2))", + 0, 0, strategy); + tester("multipoint(0 0,1 0,0 1,1 1)", + "multilinestring((3 3,4 4),(4 4,5 5))", + sqrt(8.0), 8, strategy); +} + +//=========================================================================== + +template +void test_distance_multipoint_segment(Strategy const& strategy) +{ +#ifdef GEOMETRY_TEST_DEBUG + std::cout << std::endl; + std::cout << "multipoint/segment distance tests" << std::endl; +#endif + test_distance_of_geometries tester; + + tester("multipoint(0 0,1 0,0 1,1 1)", + make_segment(2, 0, 0, 2), + 0, 0, strategy); + tester("multipoint(0 0,1 0,0 1,1 1)", + make_segment(4, 0, 0, 4), + sqrt(2.0), 2, strategy); + tester("multipoint(0 0,1 0,0 1,1 1)", + make_segment(1, 1, 2, 2), + 0, 0, strategy); + tester("multipoint(0 0,1 0,0 1,1 1)", + make_segment(3, 3, 4, 4), + sqrt(8.0), 8, strategy); +} + +//=========================================================================== + +template +void test_more_empty_input_pointlike_linear(Strategy const& strategy) +{ +#ifdef GEOMETRY_TEST_DEBUG + std::cout << std::endl; + std::cout << "testing on empty inputs... " << std::flush; +#endif + bg::model::linestring line_empty; + bg::model::multi_point multipoint_empty; + bg::model::multi_linestring > multiline_empty; + + Point point = from_wkt("point(0 0)"); + bg::model::linestring line = + from_wkt >("linestring(0 0,1 1)"); + + // 1st geometry is empty + test_empty_input(multipoint_empty, line, strategy); + + // 2nd geometry is empty + test_empty_input(point, line_empty, strategy); + test_empty_input(point, multiline_empty, strategy); + + // both geometries are empty + test_empty_input(multipoint_empty, line_empty, strategy); + test_empty_input(multipoint_empty, multiline_empty, strategy); + +#ifdef GEOMETRY_TEST_DEBUG + std::cout << "done!" << std::endl; +#endif +} + + +//=========================================================================== +//=========================================================================== +//=========================================================================== + +BOOST_AUTO_TEST_CASE( test_all_point_segment ) +{ + test_distance_point_segment(point_point_strategy()); // back-compatibility + test_distance_point_segment(point_segment_strategy()); +} + +BOOST_AUTO_TEST_CASE( test_all_point_linestring ) +{ + test_distance_point_linestring(point_point_strategy()); // back-compatibility + test_distance_point_linestring(point_segment_strategy()); +} + +BOOST_AUTO_TEST_CASE( test_all_point_multilinestring ) +{ + test_distance_point_multilinestring(point_point_strategy()); // back-compatibility + test_distance_point_multilinestring(point_segment_strategy()); +} + +BOOST_AUTO_TEST_CASE( test_all_linestring_multipoint ) +{ + test_distance_linestring_multipoint(point_point_strategy()); // back-compatibility + test_distance_linestring_multipoint(point_segment_strategy()); +} + +BOOST_AUTO_TEST_CASE( test_all_multipoint_multilinestring ) +{ + test_distance_multipoint_multilinestring(point_point_strategy()); // back-compatibility + test_distance_multipoint_multilinestring(point_segment_strategy()); +} + +BOOST_AUTO_TEST_CASE( test_all_multipoint_segment ) +{ + test_distance_multipoint_segment(point_segment_strategy()); +} + +BOOST_AUTO_TEST_CASE( test_all_empty_input_pointlike_linear ) +{ + test_more_empty_input_pointlike_linear + < + point_type + >(point_segment_strategy()); +} diff --git a/test/algorithms/distance_pointlike_pointlike.cpp b/test/algorithms/distance_pointlike_pointlike.cpp new file mode 100644 index 000000000..149a2dc3e --- /dev/null +++ b/test/algorithms/distance_pointlike_pointlike.cpp @@ -0,0 +1,138 @@ +// Boost.Geometry (aka GGL, Generic Geometry Library) +// Unit Test + +// Copyright (c) 2014, Oracle and/or its affiliates. + +// Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle + +// Licensed under the Boost Software License version 1.0. +// http://www.boost.org/users/license.html + +#include + +#ifndef BOOST_TEST_MODULE +#define BOOST_TEST_MODULE test_distance_pointlike_pointlike +#endif + +#include + +#include "test_distance_common.hpp" + + +typedef bg::model::point point_type; +typedef bg::model::multi_point multi_point_type; + +namespace services = bg::strategy::distance::services; +typedef bg::default_distance_result::type return_type; + +typedef bg::strategy::distance::pythagoras<> point_point_strategy; + +//=========================================================================== + +template +void test_distance_point_point(Strategy const& strategy) +{ +#ifdef GEOMETRY_TEST_DEBUG + std::cout << std::endl; + std::cout << "point/point distance tests" << std::endl; +#endif + test_distance_of_geometries tester; + + tester("point(1 1)", "point(0 0)", + sqrt(2.0), 2, strategy); + tester("point(1 1)", "point(1 1)", + 0, 0, strategy); +} + +//=========================================================================== + +template +void test_distance_point_multipoint(Strategy const& strategy) +{ +#ifdef GEOMETRY_TEST_DEBUG + std::cout << std::endl; + std::cout << "point/multipoint distance tests" << std::endl; +#endif + test_distance_of_geometries tester; + + tester("point(1 1)", + "multipoint(1 1,2 1,2 2,1 2)", + 0, 0, strategy); + tester("point(1 1)", + "multipoint(2 2,2 3,3 2,3 3)", + sqrt(2.0), 2, strategy); + tester("point(3 0)", + "multipoint(2 2,2 4,4 2,4 4)", + sqrt(5.0), 5, strategy); +} + +//=========================================================================== + +template +void test_distance_multipoint_multipoint(Strategy const& strategy) +{ +#ifdef GEOMETRY_TEST_DEBUG + std::cout << std::endl; + std::cout << "multipoint/multipoint distance tests" << std::endl; +#endif + test_distance_of_geometries tester; + + tester("multipoint(0 0,1 0,0 1,1 1)", + "multipoint(1 1,2 1,2 2,1 2)", + 0, 0, strategy); + tester("multipoint(0 0,1 0,0 1,1 1)", + "multipoint(2 2,2 3,3 2,3 3)", + sqrt(2.0), 2, strategy); +} + +//=========================================================================== + +template +void test_more_empty_input_pointlike_pointlike(Strategy const& strategy) +{ +#ifdef GEOMETRY_TEST_DEBUG + std::cout << std::endl; + std::cout << "testing on empty inputs... " << std::flush; +#endif + bg::model::multi_point multipoint_empty; + + Point point = from_wkt("point(0 0)"); + + // 1st geometry is empty + test_empty_input(multipoint_empty, point, strategy); + + // 2nd geometry is empty + test_empty_input(point, multipoint_empty, strategy); + + // both geometries are empty + test_empty_input(multipoint_empty, multipoint_empty, strategy); + +#ifdef GEOMETRY_TEST_DEBUG + std::cout << "done!" << std::endl; +#endif +} + +//=========================================================================== + +BOOST_AUTO_TEST_CASE( test_all_point_point ) +{ + test_distance_point_point(point_point_strategy()); +} + +BOOST_AUTO_TEST_CASE( test_all_point_multipoint ) +{ + test_distance_point_multipoint(point_point_strategy()); +} + +BOOST_AUTO_TEST_CASE( test_all_multipoint_multipoint ) +{ + test_distance_multipoint_multipoint(point_point_strategy()); +} + +BOOST_AUTO_TEST_CASE( test_all_empty_input_pointlike_pointlike ) +{ + test_more_empty_input_pointlike_pointlike + < + point_type + >(point_point_strategy()); +} From 319f9a7b83c25b56afc8cbec6fc794828e1a9a7c Mon Sep 17 00:00:00 2001 From: Menelaos Karavelas Date: Thu, 8 May 2014 13:46:31 +0300 Subject: [PATCH 03/66] [test][algorithms] add new unit tests for distance in Jamfile --- test/algorithms/Jamfile.v2 | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/test/algorithms/Jamfile.v2 b/test/algorithms/Jamfile.v2 index 52c497af2..de35ec60e 100644 --- a/test/algorithms/Jamfile.v2 +++ b/test/algorithms/Jamfile.v2 @@ -31,6 +31,12 @@ test-suite boost-geometry-algorithms [ run difference_pl_pl.cpp ] [ run disjoint.cpp ] [ run distance.cpp : : : msvc:/bigobj ] + [ run distance_areal_areal.cpp ] + [ run distance_linear_areal.cpp ] + [ run distance_linear_linear.cpp ] + [ run distance_pointlike_areal.cpp ] + [ run distance_pointlike_linear.cpp ] + [ run distance_pointlike_pointlike.cpp ] [ run envelope.cpp ] [ run equals.cpp ] [ run expand.cpp ] From affc4340c24df06e6777f59c3bd592d414bb5604 Mon Sep 17 00:00:00 2001 From: Menelaos Karavelas Date: Thu, 8 May 2014 13:49:24 +0300 Subject: [PATCH 04/66] [strategies][distance] add cartesian strategy for point-box and box-box distance computation --- .../cartesian/distance_pythagoras_box_box.hpp | 338 ++++++++++++++++++ .../distance_pythagoras_point_box.hpp | 333 +++++++++++++++++ 2 files changed, 671 insertions(+) create mode 100644 include/boost/geometry/strategies/cartesian/distance_pythagoras_box_box.hpp create mode 100644 include/boost/geometry/strategies/cartesian/distance_pythagoras_point_box.hpp diff --git a/include/boost/geometry/strategies/cartesian/distance_pythagoras_box_box.hpp b/include/boost/geometry/strategies/cartesian/distance_pythagoras_box_box.hpp new file mode 100644 index 000000000..d4c94b5c0 --- /dev/null +++ b/include/boost/geometry/strategies/cartesian/distance_pythagoras_box_box.hpp @@ -0,0 +1,338 @@ +// Boost.Geometry (aka GGL, Generic Geometry Library) + +// Copyright (c) 2008-2014 Bruno Lalande, Paris, France. +// Copyright (c) 2008-2014 Barend Gehrels, Amsterdam, the Netherlands. +// Copyright (c) 2009-2014 Mateusz Loskot, London, UK. + +// This file was modified by Oracle on 2014. +// Modifications copyright (c) 2014, Oracle and/or its affiliates. + +// Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle + +// 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) + +#ifndef BOOST_GEOMETRY_STRATEGIES_CARTESIAN_DISTANCE_PYTHAGORAS_BOX_BOX_HPP +#define BOOST_GEOMETRY_STRATEGIES_CARTESIAN_DISTANCE_PYTHAGORAS_BOX_BOX_HPP + + +#include + +#include + +#include + + + + +namespace boost { namespace geometry +{ + +namespace strategy { namespace distance +{ + +#ifndef DOXYGEN_NO_DETAIL +namespace detail +{ + +template +struct compute_pythagoras_box_box +{ + template + static inline void apply(Box1 const& box1, Box2 const& box2, T& result) + { + T const b1_min_coord = + boost::numeric_cast(geometry::get(box1)); + T const b1_max_coord = + boost::numeric_cast(geometry::get(box1)); + + T const b2_min_coord = + boost::numeric_cast(geometry::get(box2)); + T const b2_max_coord = + boost::numeric_cast(geometry::get(box2)); + + if ( b1_max_coord < b2_min_coord ) + { + T diff = b2_min_coord - b1_max_coord; + result += diff * diff; + } + if ( b1_min_coord > b2_max_coord ) + { + T diff = b1_min_coord - b2_max_coord; + result += diff * diff; + } + + compute_pythagoras_box_box::apply(box1, box2, result); + } +}; + +template <> +struct compute_pythagoras_box_box<0> +{ + template + static inline void apply(Box1 const&, Box2 const&, T&) + { + } +}; + +} +#endif // DOXYGEN_NO_DETAIL + + +namespace comparable +{ + +/*! +\brief Strategy to calculate comparable distance between two boxes +\ingroup strategies +\tparam Box1 \tparam_first_box +\tparam Box2 \tparam_second_box +\tparam CalculationType \tparam_calculation +*/ +template +class pythagoras_box_box +{ +public : + + template + struct calculation_type + { + typedef typename util::calculation_type::geometric::binary + < + Box1, + Box2, + CalculationType + >::type type; + }; + + template + static inline typename calculation_type::type + apply(Box1 const& box1, Box2 const& box2) + { + BOOST_CONCEPT_ASSERT + ( (concept::ConstPoint::type>) ); + BOOST_CONCEPT_ASSERT + ( (concept::ConstPoint::type>) ); + + // Calculate distance using Pythagoras + // (Leave comment above for Doxygen) + + assert_dimension_equal(); + + typename calculation_type::type result(0); + + detail::compute_pythagoras_box_box + < + dimension::value + >::apply(box1, box2, result); + + return result; + } +}; + +} // namespace comparable + + +/*! +\brief Strategy to calculate the distance between two points or boxes +\ingroup strategies +\tparam CalculationType \tparam_calculation + +\qbk{ +[heading Notes] +[note Can be used for boxes with two\, three or more dimensions] +[heading See also] +[link geometry.reference.algorithms.distance.distance_3_with_strategy distance (with strategy)] +} + +*/ +template +< + typename CalculationType = void +> +class pythagoras_box_box +{ +public : + + template + struct calculation_type + : util::calculation_type::geometric::binary + < + Box1, + Box2, + CalculationType, + double, + double // promote integer to double + > + {}; + + /*! + \brief applies the distance calculation using pythagoras_box_box + \return the calculated distance (including taking the square root) + \param box1 first box + \param box2 second box + */ + template + static inline typename calculation_type::type + apply(Box1 const& box1, Box2 const& box2) + { + // Don't add std:: for ttmath + // The cast is necessary for MSVC which considers sqrt __int64 as an ambiguous call + return sqrt + ( + boost::numeric_cast::type> + ( + comparable::pythagoras_box_box + < + CalculationType + >::apply(box1, box2) + ) + ); + } +}; + + +#ifndef DOXYGEN_NO_STRATEGY_SPECIALIZATIONS +namespace services +{ + +template +struct tag > +{ + typedef strategy_tag_distance_box_box type; +}; + + +template +struct return_type, Box1, Box2> + : pythagoras_box_box::template calculation_type +{}; + + +template +struct comparable_type > +{ + typedef comparable::pythagoras_box_box type; +}; + + +template +struct get_comparable > +{ + typedef comparable::pythagoras_box_box comparable_type; +public : + static inline comparable_type + apply(pythagoras_box_box const& ) + { + return comparable_type(); + } +}; + + +template +struct result_from_distance, Box1, Box2> +{ +private: + typedef typename return_type + < + pythagoras_box_box, Box1, Box2 + >::type return_type; +public: + template + static inline return_type + apply(pythagoras_box_box const& , T const& value) + { + return return_type(value); + } +}; + + +// Specializations for comparable::pythagoras_box_box +template +struct tag > +{ + typedef strategy_tag_distance_box_box type; +}; + + +template +struct return_type, Box1, Box2> + : comparable::pythagoras_box_box + < + CalculationType + >::template calculation_type +{}; + + + + +template +struct comparable_type > +{ + typedef comparable::pythagoras_box_box type; +}; + + +template +struct get_comparable > +{ + typedef comparable::pythagoras_box_box comparable_type; +public : + static inline comparable_type apply(comparable_type const& ) + { + return comparable_type(); + } +}; + + +template +struct result_from_distance + < + comparable::pythagoras_box_box, Box1, Box2 + > +{ +private : + typedef typename return_type + < + comparable::pythagoras_box_box, Box1, Box2 + >::type return_type; +public : + template + static inline return_type + apply(comparable::pythagoras_box_box const&, + T const& value) + { + return_type const v = value; + return v * v; + } +}; + + +template +struct default_strategy + < + box_tag, Box1, Box2, cartesian_tag, cartesian_tag, void, box_tag + > +{ + typedef pythagoras_box_box<> type; +}; + + +} // namespace services +#endif // DOXYGEN_NO_STRATEGY_SPECIALIZATIONS + + +}} // namespace strategy::distance + + +}} // namespace boost::geometry + + +#endif // BOOST_GEOMETRY_STRATEGIES_CARTESIAN_DISTANCE_PYTHAGORAS_BOX_BOX_HPP diff --git a/include/boost/geometry/strategies/cartesian/distance_pythagoras_point_box.hpp b/include/boost/geometry/strategies/cartesian/distance_pythagoras_point_box.hpp new file mode 100644 index 000000000..304250167 --- /dev/null +++ b/include/boost/geometry/strategies/cartesian/distance_pythagoras_point_box.hpp @@ -0,0 +1,333 @@ +// Boost.Geometry (aka GGL, Generic Geometry Library) + +// Copyright (c) 2008-2014 Bruno Lalande, Paris, France. +// Copyright (c) 2008-2014 Barend Gehrels, Amsterdam, the Netherlands. +// Copyright (c) 2009-2014 Mateusz Loskot, London, UK. + +// This file was modified by Oracle on 2014. +// Modifications copyright (c) 2014, Oracle and/or its affiliates. + +// Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle + +// 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) + +#ifndef BOOST_GEOMETRY_STRATEGIES_CARTESIAN_DISTANCE_PYTHAGORAS_POINT_BOX_HPP +#define BOOST_GEOMETRY_STRATEGIES_CARTESIAN_DISTANCE_PYTHAGORAS_POINT_BOX_HPP + + +#include + +#include + +#include + + + +namespace boost { namespace geometry +{ + +namespace strategy { namespace distance +{ + +#ifndef DOXYGEN_NO_DETAIL +namespace detail +{ + +template +struct compute_pythagoras_point_box +{ + template + static inline void apply(Point const& point, Box const& box, T& result) + { + T const p_coord = boost::numeric_cast(geometry::get(point)); + T const b_min_coord = + boost::numeric_cast(geometry::get(box)); + T const b_max_coord = + boost::numeric_cast(geometry::get(box)); + + if ( p_coord < b_min_coord ) + { + T diff = b_min_coord - p_coord; + result += diff * diff; + } + if ( p_coord > b_max_coord ) + { + T diff = p_coord - b_max_coord; + result += diff * diff; + } + + compute_pythagoras_point_box::apply(point, box, result); + } +}; + +template <> +struct compute_pythagoras_point_box<0> +{ + template + static inline void apply(Point const&, Box const&, T&) + { + } +}; + + +} // namespace detail +#endif // DOXYGEN_NO_DETAIL + + +namespace comparable +{ + +/*! +\brief Strategy to calculate comparable distance between two points +\ingroup strategies +\tparam Point \tparam_first_point +\tparam Box \tparam_second_box +\tparam CalculationType \tparam_calculation +*/ +template +class pythagoras_point_box +{ +public : + + template + struct calculation_type + { + typedef typename util::calculation_type::geometric::binary + < + Point, Box, CalculationType + >::type type; + }; + + template + static inline typename calculation_type::type + apply(Point const& point, Box const& box) + { + BOOST_CONCEPT_ASSERT( (concept::ConstPoint) ); + BOOST_CONCEPT_ASSERT + ( (concept::ConstPoint::type>) ); + + // Calculate distance using Pythagoras + // (Leave comment above for Doxygen) + + assert_dimension_equal(); + + typename calculation_type::type result(0); + + detail::compute_pythagoras_point_box + < + dimension::value + >::apply(point, box, result); + + return result; + } +}; + +} // namespace comparable + + +/*! +\brief Strategy to calculate the distance between two points or boxes +\ingroup strategies +\tparam CalculationType \tparam_calculation + +\qbk{ +[heading Notes] +[note Can be used for points and boxes with two\, three or more dimensions] +[heading See also] +[link geometry.reference.algorithms.distance.distance_3_with_strategy distance (with strategy)] +} + +*/ +template +< + typename CalculationType = void +> +class pythagoras_point_box +{ +public : + + template + struct calculation_type + : util::calculation_type::geometric::binary + < + Point, + Box, + CalculationType, + double, + double // promote integer to double + > + {}; + + /*! + \brief applies the distance calculation using pythagoras + \return the calculated distance (including taking the square root) + \param point point + \param box box + */ + template + static inline typename calculation_type::type + apply(Point const& point, Box const& box) + { + // Don't add std:: for ttmath + // The cast is necessary for MSVC which considers sqrt __int64 as an ambiguous call + return sqrt + ( + boost::numeric_cast::type> + ( + comparable::pythagoras_point_box + < + CalculationType + >::apply(point, box) + ) + ); + } +}; + + +#ifndef DOXYGEN_NO_STRATEGY_SPECIALIZATIONS +namespace services +{ + +template +struct tag > +{ + typedef strategy_tag_distance_point_box type; +}; + + +template +struct return_type, Point, Box> + : pythagoras_point_box + < + CalculationType + >::template calculation_type +{}; + + +template +struct comparable_type > +{ + typedef comparable::pythagoras_point_box type; +}; + + +template +struct get_comparable > +{ + typedef comparable::pythagoras_point_box comparable_type; +public : + static inline comparable_type + apply(pythagoras_point_box const& ) + { + return comparable_type(); + } +}; + + +template +struct result_from_distance, Point, Box> +{ +private : + typedef typename return_type + < + pythagoras_point_box, Point, Box + >::type return_type; +public : + template + static inline return_type + apply(pythagoras_point_box const& , T const& value) + { + return return_type(value); + } +}; + + +// Specializations for comparable::pythagoras_point_box +template +struct tag > +{ + typedef strategy_tag_distance_point_box type; +}; + + +template +struct return_type + < + comparable::pythagoras_point_box, Point, Box + > : comparable::pythagoras_point_box + < + CalculationType + >::template calculation_type +{}; + + + + +template +struct comparable_type > +{ + typedef comparable::pythagoras_point_box type; +}; + + +template +struct get_comparable > +{ + typedef comparable::pythagoras_point_box comparable_type; +public : + static inline comparable_type apply(comparable_type const& ) + { + return comparable_type(); + } +}; + + +template +struct result_from_distance + < + comparable::pythagoras_point_box, Point, Box + > +{ +private : + typedef typename return_type + < + comparable::pythagoras_point_box, Point, Box + >::type return_type; +public : + template + static inline return_type + apply(comparable::pythagoras_point_box const& , + T const& value) + { + return_type const v = value; + return v * v; + } +}; + + +template +struct default_strategy +{ + typedef pythagoras_point_box<> type; +}; + + +} // namespace services +#endif // DOXYGEN_NO_STRATEGY_SPECIALIZATIONS + + +}} // namespace strategy::distance + + +}} // namespace boost::geometry + + +#endif // BOOST_GEOMETRY_STRATEGIES_CARTESIAN_DISTANCE_PYTHAGORAS_POINT_BOX_HPP From ebc8d5cf63c5b6605fe4c7759f0328e3ab8e6eb7 Mon Sep 17 00:00:00 2001 From: Menelaos Karavelas Date: Thu, 8 May 2014 14:43:10 +0300 Subject: [PATCH 05/66] [distance] add distance(box, box) detail implementation --- .../algorithms/detail/distance/box_to_box.hpp | 58 +++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 include/boost/geometry/algorithms/detail/distance/box_to_box.hpp diff --git a/include/boost/geometry/algorithms/detail/distance/box_to_box.hpp b/include/boost/geometry/algorithms/detail/distance/box_to_box.hpp new file mode 100644 index 000000000..98b3be0f7 --- /dev/null +++ b/include/boost/geometry/algorithms/detail/distance/box_to_box.hpp @@ -0,0 +1,58 @@ +// Boost.Geometry (aka GGL, Generic Geometry Library) + +// Copyright (c) 2014, Oracle and/or its affiliates. + +// Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle + +// Licensed under the Boost Software License version 1.0. +// http://www.boost.org/users/license.html + +#ifndef BOOST_GEOMETRY_ALGORITHMS_DETAIL_DISTANCE_BOX_TO_BOX_HPP +#define BOOST_GEOMETRY_ALGORITHMS_DETAIL_DISTANCE_BOX_TO_BOX_HPP + +#include +#include +#include + +#include +#include + +#include + + +namespace boost { namespace geometry +{ + +#ifndef DOXYGEN_NO_DISPATCH +namespace dispatch +{ + + +template +struct distance + < + Box1, Box2, Strategy, box_tag, box_tag, + strategy_tag_distance_box_box, false + > +{ + static inline typename strategy::distance::services::return_type + < + Strategy, + typename point_type::type, + typename point_type::type + >::type + apply(Box1 const& box1, Box2 const& box2, Strategy const& strategy) + { + return strategy.apply(box1, box2); + } +}; + + +} // namespace dispatch +#endif // DOXYGEN_NO_DISPATCH + + +}} // namespace boost::geometry + + +#endif // BOOST_GEOMETRY_ALGORITHMS_DETAIL_DISTANCE_BOX_TO_BOX_HPP From f9825be6bff428aab3d2f460592448b2766ef52f Mon Sep 17 00:00:00 2001 From: Menelaos Karavelas Date: Thu, 8 May 2014 14:43:38 +0300 Subject: [PATCH 06/66] [distance] add implementation of distance(point, geometry); most of the origina code was in algorithms/distance.hpp; the point-box combination was added; point_to_range takes only one strategy now; all intermediate distance computations done with comaprable distances (conversion happens at the end); --- .../detail/distance/point_to_geometry.hpp | 405 ++++++++++++++++++ 1 file changed, 405 insertions(+) create mode 100644 include/boost/geometry/algorithms/detail/distance/point_to_geometry.hpp diff --git a/include/boost/geometry/algorithms/detail/distance/point_to_geometry.hpp b/include/boost/geometry/algorithms/detail/distance/point_to_geometry.hpp new file mode 100644 index 000000000..21b4703ea --- /dev/null +++ b/include/boost/geometry/algorithms/detail/distance/point_to_geometry.hpp @@ -0,0 +1,405 @@ +// Boost.Geometry (aka GGL, Generic Geometry Library) + +// Copyright (c) 2007-2014 Barend Gehrels, Amsterdam, the Netherlands. +// Copyright (c) 2008-2014 Bruno Lalande, Paris, France. +// Copyright (c) 2009-2014 Mateusz Loskot, London, UK. +// Copyright (c) 2013-2014 Adam Wulkiewicz, Lodz, Poland. + +// This file was modified by Oracle on 2014. +// Modifications copyright (c) 2014, Oracle and/or its affiliates. + +// Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle + +// 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) + +#ifndef BOOST_GEOMETRY_ALGORITHMS_DETAIL_DISTANCE_POINT_TO_GEOMETRY_HPP +#define BOOST_GEOMETRY_ALGORITHMS_DETAIL_DISTANCE_POINT_TO_GEOMETRY_HPP + +#include + +#include + +#include +#include +#include +#include +#include +#include + +#include + +#include +#include +#include +#include + +#include + +#include +#include +#include + +#include + +#include + + +namespace boost { namespace geometry +{ + +#ifndef DOXYGEN_NO_DETAIL +namespace detail { namespace distance +{ + + +// To avoid spurious namespaces here: +using strategy::distance::services::return_type; + + +template +struct point_to_point +{ + static inline typename return_type::type + apply(P1 const& p1, P2 const& p2, Strategy const& strategy) + { + boost::ignore_unused_variable_warning(strategy); + return strategy.apply(p1, p2); + } +}; + + +template +< + typename Point, + typename Range, + closure_selector Closure, + typename Strategy +> +struct point_to_range +{ + typedef typename return_type + < + Strategy, Point, typename point_type::type + >::type return_type; + + typedef typename strategy::distance::services::comparable_type + < + Strategy + >::type comparable_strategy; + + static inline return_type apply(Point const& point, Range const& range, + Strategy const& strategy) + { + comparable_strategy c_strategy = + strategy::distance::services::get_comparable + < + Strategy + >::apply(strategy); + + return_type const zero = return_type(0); + + if (boost::size(range) == 0) + { + return zero; + } + + typedef typename closeable_view::type view_type; + + view_type view(range); + + // line of one point: return point distance + typedef typename boost::range_iterator::type iterator_type; + iterator_type it = boost::begin(view); + iterator_type prev = it++; + if (it == boost::end(view)) + { + return strategy::distance::services::comparable_to_regular + < + comparable_strategy, Strategy, Point, Range + >::apply( c_strategy.apply(point, + *boost::begin(view), + *boost::begin(view)) ); + } + + // start with first segment distance + return_type d = c_strategy.apply(point, *prev, *it); + + // check if other segments are closer + for (++prev, ++it; it != boost::end(view); ++prev, ++it) + { + return_type const ds = c_strategy.apply(point, *prev, *it); + if (geometry::math::equals(ds, zero)) + { + return ds; + } + else if (ds < d) + { + d = ds; + } + } + + return strategy::distance::services::comparable_to_regular + < + comparable_strategy, Strategy, Point, Range + >::apply(d); + } +}; + + +template +< + typename Point, + typename Ring, + closure_selector Closure, + typename Strategy +> +struct point_to_ring +{ + typedef std::pair + < + typename return_type + < + Strategy, Point, typename point_type::type + >::type, + bool + > distance_containment; + + static inline distance_containment apply(Point const& point, + Ring const& ring, + Strategy const& strategy) + { + return distance_containment + ( + point_to_range + < + Point, + Ring, + Closure, + Strategy + >::apply(point, ring, strategy), + geometry::within(point, ring) + ); + } +}; + + + +template +< + typename Point, + typename Polygon, + closure_selector Closure, + typename Strategy +> +struct point_to_polygon +{ + typedef typename return_type + < + Strategy, Point, typename point_type::type + >::type return_type; + typedef std::pair distance_containment; + + typedef typename strategy::distance::services::comparable_type + < + Strategy + >::type comparable_strategy; + + static inline distance_containment apply(Point const& point, + Polygon const& polygon, + Strategy const& strategy) + { + comparable_strategy c_strategy = + strategy::distance::services::get_comparable + < + Strategy + >::apply(strategy); + + // Check distance to all rings + typedef point_to_ring + < + Point, + typename ring_type::type, + Closure, + comparable_strategy + > per_ring; + + distance_containment dc = per_ring::apply(point, + exterior_ring(polygon), + c_strategy); + + typename interior_return_type::type rings + = interior_rings(polygon); + for (typename boost::range_iterator + < + typename interior_type::type const + >::type it = boost::begin(rings); + it != boost::end(rings); ++it) + { + distance_containment dcr = per_ring::apply(point, *it, c_strategy); + if (dcr.first < dc.first) + { + dc.first = dcr.first; + } + // If it was inside, and also inside inner ring, + // turn off the inside-flag, it is outside the polygon + if (dc.second && dcr.second) + { + dc.second = false; + } + } + + return_type rd = strategy::distance::services::comparable_to_regular + < + comparable_strategy, Strategy, Point, Polygon + >::apply(dc.first); + + return std::make_pair(rd, dc.second); + } +}; + + +}} // namespace detail::distance +#endif // DOXYGEN_NO_DETAIL + + + + +#ifndef DOXYGEN_NO_DISPATCH +namespace dispatch +{ + + +// Point-point +template +struct distance + < + P1, P2, Strategy, + point_tag, point_tag, strategy_tag_distance_point_point, + false + > + : detail::distance::point_to_point +{}; + + +// Point-line version 2, where point-segment strategy is specified +template +struct distance +< + Point, Linestring, Strategy, + point_tag, linestring_tag, strategy_tag_distance_point_segment, + false +> : detail::distance::point_to_range +{}; + + +// Point-ring , where point-segment strategy is specified +template +struct distance +< + Point, Ring, Strategy, + point_tag, ring_tag, strategy_tag_distance_point_segment, + false +> +{ + typedef typename return_type::type>::type return_type; + + static inline return_type apply(Point const& point, + Ring const& ring, + Strategy const& strategy) + { + std::pair + dc = detail::distance::point_to_ring + < + Point, Ring, + geometry::closure::value, + Strategy + >::apply(point, ring, strategy); + + return dc.second ? return_type(0) : dc.first; + } +}; + + +// Point-polygon , where point-segment strategy is specified +template +struct distance +< + Point, Polygon, Strategy, point_tag, polygon_tag, + strategy_tag_distance_point_segment, false +> +{ + typedef typename return_type::type>::type return_type; + + static inline return_type apply(Point const& point, + Polygon const& polygon, + Strategy const& strategy) + { + std::pair + dc = detail::distance::point_to_polygon + < + Point, Polygon, + geometry::closure::value, + Strategy + >::apply(point, polygon, strategy); + + return dc.second ? return_type(0) : dc.first; + } +}; + + +// Point-segment version 2, with point-segment strategy +template +struct distance +< + Point, Segment, Strategy, + point_tag, segment_tag, strategy_tag_distance_point_segment, + false +> +{ + static inline typename return_type::type>::type + apply(Point const& point, + Segment const& segment, + Strategy const& strategy) + { + + typename point_type::type p[2]; + geometry::detail::assign_point_from_index<0>(segment, p[0]); + geometry::detail::assign_point_from_index<1>(segment, p[1]); + return strategy.apply(point, p[0], p[1]); + } +}; + + + +template +struct distance + < + Point, Box, Strategy, point_tag, box_tag, + strategy_tag_distance_point_box, false + > +{ + static inline typename strategy::distance::services::return_type + < + Strategy, Point, typename point_type::type + >::type + apply(Point const& point, Box const& box, Strategy const& strategy) + { + return strategy.apply(point, box); + } +}; + + + +} // namespace dispatch +#endif // DOXYGEN_NO_DISPATCH + + +}} // namespace boost::geometry + + +#endif // BOOST_GEOMETRY_ALGORITHMS_DETAIL_DISTANCE_POINT_TO_GEOMETRY_HPP From 17d3f0e78ea1cbd66bb79aed37013e8b3f55f986 Mon Sep 17 00:00:00 2001 From: Menelaos Karavelas Date: Thu, 8 May 2014 14:47:19 +0300 Subject: [PATCH 07/66] [strategies][distance] add class to convert a distance result from comparable to regular distance result if needed; add implementation of this for cartesian coordinates (applies sqrt); --- .../distance_comparable_to_regular.hpp | 106 ++++++++++++++++++ .../distance_comparable_to_regular.hpp | 53 +++++++++ 2 files changed, 159 insertions(+) create mode 100644 include/boost/geometry/strategies/cartesian/distance_comparable_to_regular.hpp create mode 100644 include/boost/geometry/strategies/distance_comparable_to_regular.hpp diff --git a/include/boost/geometry/strategies/cartesian/distance_comparable_to_regular.hpp b/include/boost/geometry/strategies/cartesian/distance_comparable_to_regular.hpp new file mode 100644 index 000000000..2d13b7a75 --- /dev/null +++ b/include/boost/geometry/strategies/cartesian/distance_comparable_to_regular.hpp @@ -0,0 +1,106 @@ +// Boost.Geometry (aka GGL, Generic Geometry Library) + +// Copyright (c) 2014, Oracle and/or its affiliates. + +// Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle + +// Licensed under the Boost Software License version 1.0. +// http://www.boost.org/users/license.html + +#ifndef BOOST_GEOMETRY_STRATEGIES_CARTESIAN_DISTANCE_COMPARABLE_TO_REGULAR_HPP +#define BOOST_GEOMETRY_STRATEGIES_CARTESIAN_DISTANCE_COMPARABLE_TO_REGULAR_HPP + + +#include +#include +#include + +namespace boost { namespace geometry +{ + +namespace strategy { namespace distance +{ + + + +#ifndef DOXYGEN_NO_STRATEGY_SPECIALIZATIONS +namespace services +{ + + +template +< + typename ComparableStrategy, + typename Strategy, + typename Geometry1, + typename Geometry2 +> +struct comparable_to_regular + < + ComparableStrategy, Strategy, + Geometry1, Geometry2, + cartesian_tag, cartesian_tag + > +{ + typedef typename return_type + < + Strategy, + typename point_type::type, + typename point_type::type + >::type calculation_type; + + typedef typename return_type + < + ComparableStrategy, + typename point_type::type, + typename point_type::type + >::type comparable_calculation_type; + + static inline calculation_type apply(comparable_calculation_type const& cd) + { + return sqrt( boost::numeric_cast(cd) ); + } +}; + + + +template +struct comparable_to_regular + < + ComparableStrategy, + ComparableStrategy, + Geometry1, + Geometry2, + cartesian_tag, + cartesian_tag + > +{ + typedef typename return_type + < + ComparableStrategy, + typename point_type::type, + typename point_type::type + >::type comparable_calculation_type; + + static inline comparable_calculation_type + apply(comparable_calculation_type const& cd) + { + return cd; + } +}; + + + + + + + +} // namespace services +#endif // DOXYGEN_NO_STRATEGY_SPECIALIZATIONS + + +}} // namespace strategy::distance + +}} // namespace boost::geometry + +#endif // BOOST_GEOMETRY_STRATEGIES_CARTESIAN_DISTANCE_COMPARABLE_TO_REGULAR_HPP diff --git a/include/boost/geometry/strategies/distance_comparable_to_regular.hpp b/include/boost/geometry/strategies/distance_comparable_to_regular.hpp new file mode 100644 index 000000000..88f51eb15 --- /dev/null +++ b/include/boost/geometry/strategies/distance_comparable_to_regular.hpp @@ -0,0 +1,53 @@ +// Boost.Geometry (aka GGL, Generic Geometry Library) + +// Copyright (c) 2014, Oracle and/or its affiliates. + +// Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle + +// Licensed under the Boost Software License version 1.0. +// http://www.boost.org/users/license.html + +#ifndef BOOST_GEOMETRY_STRATEGIES_DISTANCE_COMPARABLE_TO_REGULAR_HPP +#define BOOST_GEOMETRY_STRATEGIES_DISTANCE_COMPARABLE_TO_REGULAR_HPP + +#include +#include +#include + + +namespace boost { namespace geometry +{ + +namespace strategy { namespace distance +{ + + + +#ifndef DOXYGEN_NO_STRATEGY_SPECIALIZATIONS +namespace services +{ + + +template +< + typename ComparableStrategy, + typename Strategy, + typename Geometry1, + typename Geometry2, + typename CsTag1 = typename cs_tag::type, + typename CsTag2 = typename cs_tag::type +> +struct comparable_to_regular + : geometry::not_implemented +{}; + + +} // namespace services +#endif // DOXYGEN_NO_STRATEGY_SPECIALIZATIONS + + +}} // namespace strategy::distance + +}} // namespace boost::geometry + +#endif // BOOST_GEOMETRY_STRATEGIES_DISTANCE_COMPARABLE_TO_REGULAR_HPP From ad2fbc9e5b15f4a5e75fffe036e44c77039a3b84 Mon Sep 17 00:00:00 2001 From: Menelaos Karavelas Date: Thu, 8 May 2014 14:49:01 +0300 Subject: [PATCH 08/66] [distance] add helper classes for choosing default strategies --- .../detail/distance/default_strategies.hpp | 131 ++++++++++++++++++ 1 file changed, 131 insertions(+) create mode 100644 include/boost/geometry/algorithms/detail/distance/default_strategies.hpp diff --git a/include/boost/geometry/algorithms/detail/distance/default_strategies.hpp b/include/boost/geometry/algorithms/detail/distance/default_strategies.hpp new file mode 100644 index 000000000..70e8521ea --- /dev/null +++ b/include/boost/geometry/algorithms/detail/distance/default_strategies.hpp @@ -0,0 +1,131 @@ +// Boost.Geometry (aka GGL, Generic Geometry Library) + +// Copyright (c) 2007-2014 Barend Gehrels, Amsterdam, the Netherlands. +// Copyright (c) 2008-2014 Bruno Lalande, Paris, France. +// Copyright (c) 2009-2014 Mateusz Loskot, London, UK. +// Copyright (c) 2013-2014 Adam Wulkiewicz, Lodz, Poland. + +// This file was modified by Oracle on 2014. +// Modifications copyright (c) 2014, Oracle and/or its affiliates. + +// Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle + +// 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) + +#ifndef BOOST_GEOMETRY_ALGORITHMS_DETAIL_DISTANCE_DEFAULT_STRATEGIES_HPP +#define BOOST_GEOMETRY_ALGORITHMS_DETAIL_DISTANCE_DEFAULT_STRATEGIES_HPP + +#include +#include +#include +#include +#include + +#include + +#include +#include + +namespace boost { namespace geometry +{ + +#ifndef DOXYGEN_NO_DETAIL +namespace detail { namespace distance +{ + + + +// Helper metafunction for default strategy retrieval +template +< + typename Geometry1, + typename Geometry2, + typename Tag1 = typename tag_cast + < + typename tag::type, pointlike_tag + >::type, + typename Tag2 = typename tag_cast + < + typename tag::type, pointlike_tag + >::type +> +struct default_strategy + : strategy::distance::services::default_strategy + < + segment_tag, + typename point_type::type, + typename point_type::type + > +{}; + + +template +struct default_strategy + : strategy::distance::services::default_strategy + < + point_tag, + typename point_type::type, + typename point_type::type + > +{}; + + +template +struct default_strategy + : strategy::distance::services::default_strategy + < + point_tag, + typename point_type::type, + typename point_type::type, + cartesian_tag, + cartesian_tag, + void, + box_tag + > +{}; + + +template +struct default_strategy + : strategy::distance::services::default_strategy + < + box_tag, + typename point_type::type, + typename point_type::type, + cartesian_tag, + cartesian_tag, + void, + box_tag + > +{}; + + + +// Helper metafunction for default point-segment strategy retrieval +template +struct default_ps_strategy + : strategy::distance::services::default_strategy + < + segment_tag, + typename point_type::type, + typename point_type::type, + typename cs_tag::type>::type, + typename cs_tag::type>::type, + Strategy + > +{}; + + + +}} // namespace detail::distance +#endif // DOXYGEN_NO_DETAIL + +}} // namespace boost::geometry + + +#endif // BOOST_GEOMETRY_ALGORITHMS_DETAIL_DISTANCE_DEFAULT_STRATEGIES_HPP From 6bac8b43a15f7eaa14b407d56aa017990112922b Mon Sep 17 00:00:00 2001 From: Menelaos Karavelas Date: Thu, 8 May 2014 14:49:27 +0300 Subject: [PATCH 09/66] [distance] add distance code for single-to-multi geometry combinations and dispatch specializations; some of the code in this file originated from multi/algorithms/distance.hpp --- .../detail/distance/single_to_multi.hpp | 480 ++++++++++++++++++ 1 file changed, 480 insertions(+) create mode 100644 include/boost/geometry/algorithms/detail/distance/single_to_multi.hpp diff --git a/include/boost/geometry/algorithms/detail/distance/single_to_multi.hpp b/include/boost/geometry/algorithms/detail/distance/single_to_multi.hpp new file mode 100644 index 000000000..6b43144ac --- /dev/null +++ b/include/boost/geometry/algorithms/detail/distance/single_to_multi.hpp @@ -0,0 +1,480 @@ +// Boost.Geometry (aka GGL, Generic Geometry Library) + +// Copyright (c) 2007-2014 Barend Gehrels, Amsterdam, the Netherlands. +// Copyright (c) 2008-2014 Bruno Lalande, Paris, France. +// Copyright (c) 2009-2014 Mateusz Loskot, London, UK. + +// This file was modified by Oracle on 2014. +// Modifications copyright (c) 2014, Oracle and/or its affiliates. + +// Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle + +// 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) + +#ifndef BOOST_GEOMETRY_ALGORITHMS_DETAIL_DISTANCE_SINGLE_TO_MULTI_HPP +#define BOOST_GEOMETRY_ALGORITHMS_DETAIL_DISTANCE_SINGLE_TO_MULTI_HPP + +#include +#include + +#include +#include +#include + +#include +#include + +#include +#include +#include + +#include + +#include +#include + +#include + +#include + +// includes needed from multi.hpp -- start +#include +#include +#include +#include + +#include +#include +#include + +#include +// includes needed from multi.hpp -- end + +#include + + +namespace boost { namespace geometry +{ + +#ifndef DOXYGEN_NO_DETAIL +namespace detail { namespace distance +{ + + +template +struct distance_single_to_multi_generic +{ + typedef typename strategy::distance::services::comparable_type + < + Strategy + >::type comparable_strategy; + + typedef typename strategy::distance::services::return_type + < + Strategy, + typename point_type::type, + typename point_type::type + >::type return_type; + + static inline return_type apply(Geometry const& geometry, + MultiGeometry const& multi, + Strategy const& strategy) + { + return_type min_cdist = return_type(); + bool first = true; + + comparable_strategy cstrategy = + strategy::distance::services::get_comparable + < + Strategy + >::apply(strategy); + + for (typename range_iterator::type it = boost::begin(multi); + it != boost::end(multi); + ++it, first = false) + { + return_type cdist = dispatch::distance + < + Geometry, + typename range_value::type, + comparable_strategy + >::apply(geometry, *it, cstrategy); + + if (first || cdist < min_cdist) + { + min_cdist = cdist; + } + if ( geometry::math::equals(min_cdist, 0) ) + { + break; + } + } + + return strategy::distance::services::comparable_to_regular + < + comparable_strategy, Strategy, Geometry, MultiGeometry + >::apply(min_cdist); + } +}; + + + +template +struct distance_multi_to_single_generic +{ + typedef typename strategy::distance::services::return_type + < + Strategy, + typename point_type::type, + typename point_type::type + >::type return_type; + + static inline return_type apply(MultiGeometry const& multi, + Geometry const& geometry, + Strategy const& strategy) + { + return distance_single_to_multi_generic + < + Geometry, MultiGeometry, Strategy + >::apply(geometry, multi, strategy); + } +}; + + + + +}} // namespace detail::distance +#endif // DOXYGEN_NO_DETAIL + + + +#ifndef DOXYGEN_NO_DISPATCH +namespace dispatch +{ + + +namespace splitted_dispatch +{ + + +template +< + typename Geometry, + typename MultiGeometry, + typename Strategy, + typename GeometryTag, + typename MultiGeometryTag, + typename StrategyTag +> +struct distance_single_to_multi + : not_implemented +{}; + + + +template +struct distance_single_to_multi + < + Point, MultiPoint, Strategy, + point_tag, multi_point_tag, + strategy_tag_distance_point_point + > : detail::distance::distance_single_to_multi_generic + < + Point, MultiPoint, Strategy + > +{}; + + + +template +struct distance_single_to_multi + < + Point, MultiLinestring, Strategy, + point_tag, multi_linestring_tag, + strategy_tag_distance_point_segment + > : detail::distance::distance_single_to_multi_generic + < + Point, MultiLinestring, Strategy + > +{}; + + + +template +struct distance_single_to_multi + < + Point, MultiPolygon, Strategy, + point_tag, multi_polygon_tag, + strategy_tag_distance_point_segment + > : detail::distance::distance_single_to_multi_generic + < + Point, MultiPolygon, Strategy + > +{}; + + + +template +struct distance_single_to_multi + < + Linestring, MultiLinestring, Strategy, + linestring_tag, multi_linestring_tag, + strategy_tag_distance_point_segment + > : detail::distance::geometry_to_geometry_rtree + < + Linestring, MultiLinestring, Strategy + > +{}; + + + +template +struct distance_single_to_multi + < + Linestring, MultiPolygon, Strategy, + linestring_tag, multi_polygon_tag, + strategy_tag_distance_point_segment + > : detail::distance::geometry_to_geometry_rtree + < + Linestring, MultiPolygon, Strategy + > +{}; + + + +template +struct distance_single_to_multi + < + Polygon, MultiPoint, Strategy, + polygon_tag, multi_point_tag, + strategy_tag_distance_point_segment + > : detail::distance::distance_single_to_multi_generic + < + Polygon, MultiPoint, Strategy + > +{}; + + + +template +struct distance_single_to_multi + < + Polygon, MultiLinestring, Strategy, + polygon_tag, multi_linestring_tag, + strategy_tag_distance_point_segment + > : detail::distance::geometry_to_geometry_rtree + < + Polygon, MultiLinestring, Strategy + > +{}; + + + +template +struct distance_single_to_multi + < + Polygon, MultiPolygon, Strategy, + polygon_tag, multi_polygon_tag, + strategy_tag_distance_point_segment + > : detail::distance::geometry_to_geometry_rtree + < + Polygon, MultiPolygon, Strategy + > +{}; + + + +template +struct distance_single_to_multi + < + MultiLinestring, Ring, Strategy, + multi_linestring_tag, ring_tag, + strategy_tag_distance_point_segment + > : detail::distance::geometry_to_geometry_rtree + < + MultiLinestring, Ring, Strategy + > +{}; + + +template +struct distance_single_to_multi + < + MultiPolygon, Ring, Strategy, + multi_polygon_tag, ring_tag, + strategy_tag_distance_point_segment + > : detail::distance::geometry_to_geometry_rtree + < + MultiPolygon, Ring, Strategy + > +{}; + + + +template +< + typename MultiGeometry, + typename Geometry, + typename Strategy, + typename MultiGeometryTag, + typename GeometryTag, + typename StrategyTag +> +struct distance_multi_to_single + : not_implemented +{}; + + + +template +< + typename MultiPoint, + typename Segment, + typename Strategy +> +struct distance_multi_to_single + < + MultiPoint, Segment, Strategy, + multi_point_tag, segment_tag, + strategy_tag_distance_point_segment + > : detail::distance::distance_multi_to_single_generic + < + MultiPoint, Segment, Strategy + > +{}; + + + +template +< + typename MultiPoint, + typename Box, + typename Strategy +> +struct distance_multi_to_single + < + MultiPoint, Box, Strategy, + multi_point_tag, box_tag, + strategy_tag_distance_point_box + > : detail::distance::distance_multi_to_single_generic + < + MultiPoint, Box, Strategy + > +{}; + + +template +struct distance_multi_to_single + < + MultiLinestring, Segment, Strategy, + multi_linestring_tag, segment_tag, + strategy_tag_distance_point_segment + > : detail::distance::distance_multi_to_single_generic + < + MultiLinestring, Segment, Strategy + > +{}; + + + +template +struct distance_multi_to_single + < + MultiLinestring, Box, Strategy, + multi_linestring_tag, box_tag, + strategy_tag_distance_point_segment + > : detail::distance::distance_multi_to_single_generic + < + MultiLinestring, Box, Strategy + > +{}; + + + +template +struct distance_multi_to_single + < + MultiPolygon, Segment, Strategy, + multi_polygon_tag, segment_tag, + strategy_tag_distance_point_segment + > : detail::distance::distance_multi_to_single_generic + < + MultiPolygon, Segment, Strategy + > +{}; + + + +template +struct distance_multi_to_single + < + MultiPolygon, Box, Strategy, + multi_polygon_tag, box_tag, + strategy_tag_distance_point_segment + > : detail::distance::distance_multi_to_single_generic + < + MultiPolygon, Box, Strategy + > +{}; + + +} // namespace splitted_dispatch + + +template +< + typename Geometry, + typename MultiGeometry, + typename Strategy, + typename GeometryTag, + typename StrategyTag +> +struct distance + < + Geometry, MultiGeometry, Strategy, GeometryTag, multi_tag, + StrategyTag, false + > : splitted_dispatch::distance_single_to_multi + < + Geometry, MultiGeometry, Strategy, + GeometryTag, typename tag::type, + StrategyTag + > +{}; + + + +template +< + typename MultiGeometry, + typename Geometry, + typename Strategy, + typename GeometryTag, + typename StrategyTag +> +struct distance + < + MultiGeometry, Geometry, Strategy, multi_tag, GeometryTag, + StrategyTag, false + > : splitted_dispatch::distance_multi_to_single + < + MultiGeometry, Geometry, Strategy, + typename tag::type, GeometryTag, + StrategyTag + > +{}; + + + +} // namespace dispatch +#endif // DOXYGEN_NO_DISPATCH + + +}} // namespace boost::geometry + + +#endif // BOOST_GEOMETRY_ALGORITHMS_DETAIL_DISTANCE_SINGLE_TO_MULTI_HPP From 22142c9040c91fc77b2847542978bd24df271c74 Mon Sep 17 00:00:00 2001 From: Menelaos Karavelas Date: Thu, 8 May 2014 14:52:13 +0300 Subject: [PATCH 10/66] [distance] add distance code for multi-to-multi geometry combinations and dispatch specializations; some of the code in this file originated from multi/algorithms/distance.hpp --- .../detail/distance/multi_to_multi.hpp | 248 ++++++++++++++++++ 1 file changed, 248 insertions(+) create mode 100644 include/boost/geometry/algorithms/detail/distance/multi_to_multi.hpp diff --git a/include/boost/geometry/algorithms/detail/distance/multi_to_multi.hpp b/include/boost/geometry/algorithms/detail/distance/multi_to_multi.hpp new file mode 100644 index 000000000..0be5b8641 --- /dev/null +++ b/include/boost/geometry/algorithms/detail/distance/multi_to_multi.hpp @@ -0,0 +1,248 @@ +// Boost.Geometry (aka GGL, Generic Geometry Library) + +// Copyright (c) 2007-2014 Barend Gehrels, Amsterdam, the Netherlands. +// Copyright (c) 2008-2014 Bruno Lalande, Paris, France. +// Copyright (c) 2009-2014 Mateusz Loskot, London, UK. + +// This file was modified by Oracle on 2014. +// Modifications copyright (c) 2014, Oracle and/or its affiliates. + +// Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle + +// 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) + +#ifndef BOOST_GEOMETRY_ALGORITHMS_DETAIL_DISTANCE_MULTI_TO_MULTI_HPP +#define BOOST_GEOMETRY_ALGORITHMS_DETAIL_DISTANCE_MULTI_TO_MULTI_HPP + +#include + +#include +#include +#include +#include + +#include +#include +#include + +#include + +#include + +#include + +#include +#include + + +namespace boost { namespace geometry +{ + +#ifndef DOXYGEN_NO_DETAIL +namespace detail { namespace distance +{ + + + +template +struct distance_multi_to_multi_generic +{ + typedef typename strategy::distance::services::comparable_type + < + Strategy + >::type comparable_strategy; + + typedef typename strategy::distance::services::return_type + < + Strategy, + typename point_type::type, + typename point_type::type + >::type return_type; + + static inline return_type apply(Multi1 const& multi1, + Multi2 const& multi2, Strategy const& strategy) + { + return_type min_cdist = return_type(); + bool first = true; + + comparable_strategy cstrategy = + strategy::distance::services::get_comparable + < + Strategy + >::apply(strategy); + + for(typename range_iterator::type it = boost::begin(multi1); + it != boost::end(multi1); + ++it, first = false) + { + return_type cdist = + dispatch::splitted_dispatch::distance_single_to_multi + < + typename range_value::type, + Multi2, + comparable_strategy, + typename tag::type>::type, + typename tag::type, + typename strategy::distance::services::tag + < + comparable_strategy + >::type + >::apply(*it, multi2, cstrategy); + if (first || cdist < min_cdist) + { + min_cdist = cdist; + } + if ( geometry::math::equals(min_cdist, 0) ) + { + break; + } + } + + return strategy::distance::services::comparable_to_regular + < + comparable_strategy, + Strategy, + Multi1, + Multi2 + >::apply(min_cdist); + } +}; + + +}} // namespace detail::distance +#endif // DOXYGEN_NO_DETAIL + + + +#ifndef DOXYGEN_NO_DISPATCH +namespace dispatch +{ + + +namespace splitted_dispatch +{ + + +template +< + typename MultiGeometry1, + typename MultiGeometry2, + typename Strategy, + typename Tag1, + typename Tag2, + typename StrategyTag +> +struct distance_multi_to_multi + : not_implemented +{}; + + + +template +< + typename MultiPoint, + typename MultiPolygon, + typename Strategy +> +struct distance_multi_to_multi + < + MultiPoint, MultiPolygon, Strategy, + multi_point_tag, multi_polygon_tag, + strategy_tag_distance_point_segment + > : detail::distance::distance_multi_to_multi_generic + < + MultiPoint, MultiPolygon, Strategy + > +{}; + + + +template +< + typename MultiLinestring1, + typename MultiLinestring2, + typename Strategy +> +struct distance_multi_to_multi + < + MultiLinestring1, MultiLinestring2, Strategy, + multi_linestring_tag, multi_linestring_tag, + strategy_tag_distance_point_segment + > : detail::distance::geometry_to_geometry_rtree + < + MultiLinestring1, MultiLinestring2, Strategy + > +{}; + + +template +< + typename MultiLinestring, + typename MultiPolygon, + typename Strategy +> +struct distance_multi_to_multi + < + MultiLinestring, MultiPolygon, Strategy, + multi_linestring_tag, multi_polygon_tag, + strategy_tag_distance_point_segment + > : detail::distance::geometry_to_geometry_rtree + < + MultiLinestring, MultiPolygon, Strategy + > +{}; + + +template +struct distance_multi_to_multi + < + MultiPolygon1, MultiPolygon2, Strategy, + multi_polygon_tag, multi_polygon_tag, + strategy_tag_distance_point_segment + > : detail::distance::geometry_to_geometry_rtree + < + MultiPolygon1, MultiPolygon2, Strategy + > +{}; + + +} // namespace splitted_dispatch + + + + +template +< + typename MultiGeometry1, + typename MultiGeometry2, + typename Strategy, + typename StrategyTag +> +struct distance + < + MultiGeometry1, MultiGeometry2, Strategy, multi_tag, multi_tag, + StrategyTag, false + > : splitted_dispatch::distance_multi_to_multi + < + MultiGeometry1, MultiGeometry2, Strategy, + typename geometry::tag::type, + typename geometry::tag::type, + StrategyTag + > +{}; + + + +} // namespace dispatch +#endif // DOXYGEN_NO_DISPATCH + + +}} // namespace boost::geometry + + +#endif // BOOST_GEOMETRY_ALGORITHMS_DETAIL_DISTANCE_MULTI_TO_MULTI_HPP From 5d04ac7c9239071a7a611293b320b1ab259dea31 Mon Sep 17 00:00:00 2001 From: Menelaos Karavelas Date: Thu, 8 May 2014 14:52:51 +0300 Subject: [PATCH 11/66] [distance] segment-to-segment distance computation --- .../detail/distance/segment_to_segment.hpp | 122 ++++++++++++++++++ 1 file changed, 122 insertions(+) create mode 100644 include/boost/geometry/algorithms/detail/distance/segment_to_segment.hpp diff --git a/include/boost/geometry/algorithms/detail/distance/segment_to_segment.hpp b/include/boost/geometry/algorithms/detail/distance/segment_to_segment.hpp new file mode 100644 index 000000000..ab7d11f57 --- /dev/null +++ b/include/boost/geometry/algorithms/detail/distance/segment_to_segment.hpp @@ -0,0 +1,122 @@ +// Boost.Geometry (aka GGL, Generic Geometry Library) + +// Copyright (c) 2014, Oracle and/or its affiliates. + +// Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle + +// Licensed under the Boost Software License version 1.0. +// http://www.boost.org/users/license.html + +#ifndef BOOST_GEOMETRY_ALGORITHMS_DETAIL_DISTANCE_SEGMENT_TO_SEGMENT_HPP +#define BOOST_GEOMETRY_ALGORITHMS_DETAIL_DISTANCE_SEGMENT_TO_SEGMENT_HPP + +#include + +#include +#include + +#include +#include +#include + +#include +#include + +#include + + +namespace boost { namespace geometry +{ + + +#ifndef DOXYGEN_NO_DETAIL +namespace detail { namespace distance +{ + + + +// compute segment-segment distance +template +struct segment_to_segment +{ + typedef typename strategy::distance::services::return_type + < + Strategy, + typename point_type::type, + typename point_type::type + >::type return_type; + + typedef typename strategy::distance::services::comparable_type + < + Strategy + >::type comparable_strategy; + + static inline return_type + apply(Segment1 const& segment1, Segment2 const& segment2, + Strategy const& strategy) + { + if ( geometry::intersects(segment1, segment2) ) + { + return 0; + } + + typename point_type::type p[2]; + detail::assign_point_from_index<0>(segment1, p[0]); + detail::assign_point_from_index<1>(segment1, p[1]); + + typename point_type::type q[2]; + detail::assign_point_from_index<0>(segment2, q[0]); + detail::assign_point_from_index<1>(segment2, q[1]); + + comparable_strategy cstrategy = + strategy::distance::services::get_comparable + < + Strategy + >::apply(strategy); + + return_type d[4]; + d[0] = cstrategy.apply(q[0], p[0], p[1]); + d[1] = cstrategy.apply(q[1], p[0], p[1]); + d[2] = cstrategy.apply(p[0], q[0], q[1]); + d[3] = cstrategy.apply(p[1], q[0], q[1]); + + return strategy::distance::services::comparable_to_regular + < + comparable_strategy, Strategy, Segment1, Segment2 + >::apply( *std::min_element(d, d + 4) ); + } +}; + + + + +}} // namespace detail::distance +#endif // DOXYGEN_NO_DETAIL + + +#ifndef DOXYGEN_NO_DISPATCH +namespace dispatch +{ + + + +// segment-segment +template +struct distance + < + Segment1, Segment2, Strategy, segment_tag, segment_tag, + strategy_tag_distance_point_segment, false + > + : detail::distance::segment_to_segment +{}; + + + +} // namespace dispatch +#endif // DOXYGEN_NO_DISPATCH + + +}} // namespace boost::geometry + + +#endif // BOOST_GEOMETRY_ALGORITHMS_DETAIL_DISTANCE_SEGMENT_TO_SEGMENT_HPP From 26dfb26d69f90b466aee076c4616a4f3f248e383 Mon Sep 17 00:00:00 2001 From: Menelaos Karavelas Date: Thu, 8 May 2014 14:53:21 +0300 Subject: [PATCH 12/66] [distance] add implementation for distance computation between a range and a segment or a box --- .../distance/range_to_segment_or_box.hpp | 336 ++++++++++++++++++ 1 file changed, 336 insertions(+) create mode 100644 include/boost/geometry/algorithms/detail/distance/range_to_segment_or_box.hpp diff --git a/include/boost/geometry/algorithms/detail/distance/range_to_segment_or_box.hpp b/include/boost/geometry/algorithms/detail/distance/range_to_segment_or_box.hpp new file mode 100644 index 000000000..b73c5a840 --- /dev/null +++ b/include/boost/geometry/algorithms/detail/distance/range_to_segment_or_box.hpp @@ -0,0 +1,336 @@ +// Boost.Geometry (aka GGL, Generic Geometry Library) + +// Copyright (c) 2014, Oracle and/or its affiliates. + +// Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle + +// Licensed under the Boost Software License version 1.0. +// http://www.boost.org/users/license.html + +#ifndef BOOST_GEOMETRY_ALGORITHMS_DETAIL_DISTANCE_RANGE_TO_SEGMENT_OR_BOX_HPP +#define BOOST_GEOMETRY_ALGORITHMS_DETAIL_DISTANCE_RANGE_TO_SEGMENT_OR_BOX_HPP + +#include + +#include + +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +#include +#include +#include +#include +#include + +#include + +#include + + +namespace boost { namespace geometry +{ + +#ifndef DOXYGEN_NO_DETAIL +namespace detail { namespace distance +{ + + + +template +< + typename Range, + typename SegmentOrBox, + typename Strategy +> +class range_to_segment_or_box +{ +private: + typedef typename point_type::type segment_or_box_point; + typedef typename point_type::type range_point; + +public: + typedef typename strategy::distance::services::return_type + < + Strategy, range_point, segment_or_box_point + >::type return_type; + +private: + typedef typename strategy::distance::services::comparable_type + < + Strategy + >::type comparable_strategy; + + typedef typename strategy::distance::services::tag + < + comparable_strategy + >::type comparable_strategy_tag; + + typedef dispatch::distance + < + segment_or_box_point, Range, comparable_strategy, + point_tag, typename tag::type, + comparable_strategy_tag, false + > point_to_range; + + // compute distance of a point to a segment or a box + template + < + typename Point, + typename SegOrBoxPoints, + typename ComparableStrategy, + typename Tag + > + struct distance_point_to_segment_or_box + {}; + + template + < + typename Point, + typename SegmentPoints, + typename ComparableStrategy + > + struct distance_point_to_segment_or_box + < + Point, SegmentPoints, ComparableStrategy, segment_tag + > + { + static inline return_type apply(Point const& point, + SegmentPoints const& segment_points, + ComparableStrategy const& strategy) + { + return strategy.apply(point, segment_points[0], segment_points[1]); + } + }; + + template + < + typename Point, + typename BoxPoints, + typename ComparableStrategy + > + struct distance_point_to_segment_or_box + < + Point, BoxPoints, ComparableStrategy, box_tag + > + { + static inline return_type apply(Point const& point, + BoxPoints const& box_points, + ComparableStrategy const& strategy) + { + return_type cd_min = + strategy.apply(point, box_points[0], box_points[3]); + + for (unsigned int i = 0; i < 2; ++i) + { + return_type cd = + strategy.apply(point, box_points[i], box_points[i+1]); + + if ( cd < cd_min ) + { + cd_min = cd; + } + } + + return cd_min; + } + }; + + + // assign the points of a segment or a box to a range + template + < + typename SegOrBox, + typename PointRange, + typename Tag = typename tag::type + > + struct assign_segment_or_box_points + {}; + + + template + struct assign_segment_or_box_points + { + static inline void apply(Segment const& segment, PointRange& range) + { + detail::assign_point_from_index<0>(segment, range[0]); + detail::assign_point_from_index<1>(segment, range[1]); + } + }; + + template + struct assign_segment_or_box_points + { + static inline void apply(Box const& box, PointRange& range) + { + detail::assign_box_corners_oriented(box, range); + } + }; + + +public: + static inline return_type + apply(Range const& range, SegmentOrBox const& segment_or_box, + Strategy const& strategy, bool check_intersection = true) + { + if ( check_intersection && geometry::intersects(range, segment_or_box) ) + { + return 0; + } + + comparable_strategy cstrategy = + strategy::distance::services::get_comparable + < + Strategy + >::apply(strategy); + + + // get all points of the segment or the box + std::vector + segment_or_box_points(geometry::num_points(segment_or_box)); + + assign_segment_or_box_points + < + + SegmentOrBox, + std::vector + >::apply(segment_or_box, segment_or_box_points); + + // consider all distances from each endpoint of the segment or box + // to the range + typename std::vector::const_iterator it + = segment_or_box_points.begin(); + return_type cd_min = point_to_range::apply(*it, range, cstrategy); + + for (++it; it != segment_or_box_points.end(); ++it) + { + return_type cd = point_to_range::apply(*it, range, cstrategy); + if ( cd < cd_min ) + { + cd_min = cd; + } + } + + // consider all distances of the points in the range to the + // segment or box + typedef typename range_iterator::type iterator_type; + for (iterator_type it = boost::begin(range); it != boost::end(range); ++it) + { + return_type cd = distance_point_to_segment_or_box + < + typename point_type::type, + std::vector, + comparable_strategy, + typename tag::type + >::apply(*it, segment_or_box_points, cstrategy); + + if ( cd < cd_min ) + { + cd_min = cd; + } + } + + return strategy::distance::services::comparable_to_regular + < + comparable_strategy, Strategy, + range_point, segment_or_box_point + >::apply(cd_min); + } + + static inline return_type + apply(SegmentOrBox const& segment_or_box, Range const& range, + Strategy const& strategy, bool check_intersection = true) + { + return apply(range, segment_or_box, strategy, check_intersection); + } +}; + + +}} // namespace detail::distance +#endif // DOXYGEN_NO_DETAIL + + + +#ifndef DOXYGEN_NO_DISPATCH +namespace dispatch +{ + + + +template +struct distance + < + Linestring, Segment, Strategy, linestring_tag, segment_tag, + strategy_tag_distance_point_segment, false + > + : detail::distance::range_to_segment_or_box + < + Linestring, Segment, Strategy + > +{}; + + + + +template +struct distance + < + Segment, Ring, Strategy, segment_tag, ring_tag, + strategy_tag_distance_point_segment, false + > + : detail::distance::range_to_segment_or_box + < + Ring, Segment, Strategy + > +{}; + + + + +template +struct distance + < + Linestring, Box, Strategy, linestring_tag, box_tag, + strategy_tag_distance_point_segment, false + > + : detail::distance::range_to_segment_or_box + < + Linestring, Box, Strategy + > +{}; + + + + +template +struct distance + < + Ring, Box, Strategy, ring_tag, box_tag, + strategy_tag_distance_point_segment, false + > + : detail::distance::range_to_segment_or_box + < + Ring, Box, Strategy + > +{}; + + + + +} // namespace dispatch +#endif // DOXYGEN_NO_DISPATCH + + + +}} // namespace boost::geometry + + +#endif // BOOST_GEOMETRY_ALGORITHMS_DETAIL_DISTANCE_RANGE_TO_SEGMENT_OR_BOX_HPP From 3051652a5b6cb5cf901e5afff6fd03f539e6e1c3 Mon Sep 17 00:00:00 2001 From: Menelaos Karavelas Date: Thu, 8 May 2014 14:57:11 +0300 Subject: [PATCH 13/66] [distance] add implementation for distance computation between a polygon and a segment or a box --- .../distance/polygon_to_segment_or_box.hpp | 152 ++++++++++++++++++ 1 file changed, 152 insertions(+) create mode 100644 include/boost/geometry/algorithms/detail/distance/polygon_to_segment_or_box.hpp diff --git a/include/boost/geometry/algorithms/detail/distance/polygon_to_segment_or_box.hpp b/include/boost/geometry/algorithms/detail/distance/polygon_to_segment_or_box.hpp new file mode 100644 index 000000000..14bc3af14 --- /dev/null +++ b/include/boost/geometry/algorithms/detail/distance/polygon_to_segment_or_box.hpp @@ -0,0 +1,152 @@ +// Boost.Geometry (aka GGL, Generic Geometry Library) + +// Copyright (c) 2014, Oracle and/or its affiliates. + +// Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle + +// Licensed under the Boost Software License version 1.0. +// http://www.boost.org/users/license.html + +#ifndef BOOST_GEOMETRY_ALGORITHMS_DETAIL_DISTANCE_POLYGON_TO_SEGMENT_OR_BOX_HPP +#define BOOST_GEOMETRY_ALGORITHMS_DETAIL_DISTANCE_POLYGON_TO_SEGMENT_OR_BOX_HPP + +#include + +#include +#include +#include +#include + +#include +#include +#include +#include + +#include +#include +#include + +#include + +#include + +#include +#include + + +namespace boost { namespace geometry +{ + +#ifndef DOXYGEN_NO_DETAIL +namespace detail { namespace distance +{ + + +template +struct polygon_to_segment_or_box +{ + typedef typename return_type + < + Strategy, + typename point_type::type, + typename point_type::type + >::type return_type; + + typedef typename strategy::distance::services::comparable_type + < + Strategy + >::type comparable_strategy; + + static inline return_type apply(Polygon const& polygon, + SegmentOrBox const& segment_or_box, + Strategy const& strategy) + { + typedef typename geometry::ring_type::type e_ring; + typedef typename geometry::interior_type::type i_rings; + typedef typename range_value::type i_ring; + + if ( geometry::intersects(polygon, segment_or_box) ) + { + return 0; + } + + e_ring const& ext_ring = geometry::exterior_ring(polygon); + i_rings const& int_rings = geometry::interior_rings(polygon); + + comparable_strategy cstrategy = + strategy::distance::services::get_comparable + < + Strategy + >::apply(strategy); + + + return_type cd_min = range_to_segment_or_box + < + e_ring, SegmentOrBox, comparable_strategy + >::apply(ext_ring, segment_or_box, cstrategy, false); + + typedef typename boost::range_iterator::type iterator_type; + for (iterator_type it = boost::begin(int_rings); + it != boost::end(int_rings); ++it) + { + return_type cd = range_to_segment_or_box + < + i_ring, SegmentOrBox, comparable_strategy + >::apply(*it, segment_or_box, cstrategy, false); + + if ( cd < cd_min ) + { + cd_min = cd; + } + } + + return strategy::distance::services::comparable_to_regular + < + comparable_strategy, + Strategy, + Polygon, + SegmentOrBox + >::apply(cd_min); + } +}; + + +}} // namespace detail::distance +#endif // DOXYGEN_NO_DETAIL + + + +#ifndef DOXYGEN_NO_DETAIL +namespace dispatch +{ + + +template +struct distance + < + Polygon, Segment, Strategy, polygon_tag, segment_tag, + strategy_tag_distance_point_segment, false + > + : detail::distance::polygon_to_segment_or_box +{}; + + + +template +struct distance + < + Polygon, Box, Strategy, polygon_tag, box_tag, + strategy_tag_distance_point_segment, false + > + : detail::distance::polygon_to_segment_or_box +{}; + + + +} // namespace dispatch +#endif // DOXYGEN_NO_DETAIL + +}} // namespace boost::geometry + + +#endif // BOOST_GEOMETRY_ALGORITHMS_DETAIL_DISTANCE_POLYGON_TO_SEGMENT_OR_BOX_HPP From e1e227c022dce42fd41edad55aed1e25c6c807d4 Mon Sep 17 00:00:00 2001 From: Menelaos Karavelas Date: Thu, 8 May 2014 14:57:44 +0300 Subject: [PATCH 14/66] [distance] segment-box distance computation --- .../detail/distance/segment_to_box.hpp | 588 ++++++++++++++++++ 1 file changed, 588 insertions(+) create mode 100644 include/boost/geometry/algorithms/detail/distance/segment_to_box.hpp diff --git a/include/boost/geometry/algorithms/detail/distance/segment_to_box.hpp b/include/boost/geometry/algorithms/detail/distance/segment_to_box.hpp new file mode 100644 index 000000000..0ddf18ada --- /dev/null +++ b/include/boost/geometry/algorithms/detail/distance/segment_to_box.hpp @@ -0,0 +1,588 @@ +// Boost.Geometry (aka GGL, Generic Geometry Library) + +// Copyright (c) 2014, Oracle and/or its affiliates. + +// Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle + +// Licensed under the Boost Software License version 1.0. +// http://www.boost.org/users/license.html + +#ifndef BOOST_GEOMETRY_ALGORITHMS_DETAIL_DISTANCE_SEGMENT_TO_BOX_HPP +#define BOOST_GEOMETRY_ALGORITHMS_DETAIL_DISTANCE_SEGMENT_TO_BOX_HPP + +#include +#include + +#include +#include +#include +#include + +#include +#include + +#include +#include +#include + +#include + +#include +#include +#include + +#include + +#include + + + +namespace boost { namespace geometry +{ + + +#ifndef DOXYGEN_NO_DETAIL +namespace detail { namespace distance +{ + + +template +< + typename ReturnType, + typename SegmentPoint, + typename BoxPoint, + typename PPStrategy, + typename PSStrategy +> +class segment_to_box_2D +{ +private: + template + struct cast_to_result + { + template + static inline Result apply(T const& t) + { + return boost::numeric_cast(t); + } + }; + + static inline ReturnType + non_negative_slope_segment(SegmentPoint const& p0, + SegmentPoint const& p1, + BoxPoint const& top_left, + BoxPoint const& top_right, + BoxPoint const& bottom_left, + BoxPoint const& bottom_right, + PPStrategy const& pp_strategy, + PSStrategy const& ps_strategy) + { + typedef cast_to_result cast; + + // assert that the segment has non-negative slope + BOOST_ASSERT( (math::equals(geometry::get<0>(p0), + geometry::get<0>(p1)) + && geometry::get<1>(p0) < geometry::get<1>(p1)) + || + (geometry::get<0>(p0) < geometry::get<0>(p1) + && geometry::get<1>(p0) <= geometry::get<1>(p1)) + ); + + // p0 lies to the right of the box + if ( geometry::get<0>(p0) >= geometry::get<0>(top_right) ) + { + if ( geometry::get<1>(p0) >= geometry::get<1>(top_right) ) + { + // closest box point is the top-right corner + return cast::apply(pp_strategy.apply(p0, top_right)); + } + else if ( geometry::get<1>(p0) >= geometry::get<1>(bottom_right) ) + { + // distance is realized between p0 and right-most + // segment of box + ReturnType diff = cast::apply(geometry::get<0>(p0)) + - cast::apply(geometry::get<0>(bottom_right)); + return diff * diff; + } + else + { + // distance is realized between the bottom-right + // corner of the box and the segment + return cast::apply(ps_strategy.apply(bottom_right, p0, p1)); + } + } + + // p1 lies to the left of the box + if ( geometry::get<0>(p1) <= geometry::get<1>(bottom_left) ) + { + if ( geometry::get<1>(p1) <= geometry::get<1>(bottom_left) ) + { + // closest box point is the bottom-left corner + return cast::apply(pp_strategy.apply(p1, bottom_left)); + } + else if ( geometry::get<1>(p1) <= geometry::get<1>(top_left) ) + { + // distance is realized between p1 and left-most + // segment of box + ReturnType diff = cast::apply(geometry::get<0>(p1)) + - cast::apply(geometry::get<0>(bottom_left)); + return diff * diff; + } + else + { + // distance is realized between the top-left + // corner of the box and the segment + return cast::apply(ps_strategy.apply(top_left, p0, p1)); + } + } + + // the segment lies below the box + if ( geometry::get<1>(p1) < geometry::get<1>(bottom_left) ) + { + // p1 is below the lower segment of the box + // (and inside its band) + if ( geometry::get<0>(p1) <= geometry::get<0>(bottom_right) ) + { + ReturnType diff = cast::apply(geometry::get<1>(bottom_right)) + - cast::apply(geometry::get<1>(p1)); + return diff * diff; + } + + // p1 is to the right of the box, but p0 is below the box + // in this case the distance is realized between the + // bottom-right corner of the box and the segment + return cast::apply(ps_strategy.apply(bottom_right, p0, p1)); + } + + // the segment lies above the box + if ( geometry::get<1>(p0) > geometry::get<1>(top_left) ) + { + // p0 is above the upper segment of the box + // (and inside its band) + if ( geometry::get<0>(p0) >= geometry::get<0>(top_left) ) + { + ReturnType diff = cast::apply(geometry::get<1>(p0)) + - cast::apply(geometry::get<1>(top_left)); + return diff * diff; + } + + // p0 is to the left of the box, but p1 is above the box + // in this case the distance is realized between the + // top-left corner of the box and the segment + return cast::apply(ps_strategy.apply(top_left, p0, p1)); + } + + ReturnType diff0 = cast::apply(geometry::get<0>(p1)) + - cast::apply(geometry::get<0>(p0)); + ReturnType t_min0 = cast::apply(geometry::get<0>(bottom_left)) + - cast::apply(geometry::get<0>(p0)); + ReturnType t_max0 = cast::apply(geometry::get<0>(top_right)) + - cast::apply(geometry::get<0>(p0)); + + ReturnType diff1 = cast::apply(geometry::get<1>(p1)) + - cast::apply(geometry::get<1>(p0)); + ReturnType t_min1 = cast::apply(geometry::get<1>(bottom_left)) + - cast::apply(geometry::get<1>(p0)); + ReturnType t_max1 = cast::apply(geometry::get<1>(top_right)) + - cast::apply(geometry::get<1>(p0)); + + // t_min0 > t_max1 + if ( t_min0 * diff1 > t_max1 * diff0 ) + { + return cast::apply(ps_strategy.apply(top_left, p0, p1)); + } + + // t_min1 > t_max0 + if ( t_min1 * diff0 > t_max0 * diff1 ) + { + return cast::apply(ps_strategy.apply(bottom_right, p0, p1)); + } + + // in all other cases the box and segment intersect, so return 0 + return ReturnType(0); + } + + + static inline ReturnType + negative_slope_segment(SegmentPoint const& p0, + SegmentPoint const& p1, + BoxPoint const& top_left, + BoxPoint const& top_right, + BoxPoint const& bottom_left, + BoxPoint const& bottom_right, + PPStrategy const& pp_strategy, + PSStrategy const& ps_strategy) + { + typedef cast_to_result cast; + + // assert that the segment has negative slope + BOOST_ASSERT + ( geometry::get<0>(p0) < geometry::get<0>(p1) + && geometry::get<1>(p0) > geometry::get<1>(p1) ); + + // p0 lies to the right of the box + if ( geometry::get<0>(p0) >= geometry::get<0>(top_right) ) + { + if ( geometry::get<1>(p0) <= geometry::get<1>(bottom_right) ) + { + // closest box point is the bottom-right corner + return cast::apply(pp_strategy.apply(p0, bottom_right)); + } + else if ( geometry::get<1>(p0) <= geometry::get<1>(top_right) ) + { + // distance is realized between p0 and right-most + // segment of box + ReturnType diff = cast::apply(geometry::get<0>(p0)) + - cast::apply(geometry::get<0>(bottom_right)); + return diff * diff; + } + else + { + // distance is realized between the top-right + // corner of the box and the segment + return cast::apply(ps_strategy.apply(top_right, p0, p1)); + } + } + + // p1 lies to the left of the box + if ( geometry::get<0>(p1) <= geometry::get<1>(bottom_left) ) + { + if ( geometry::get<1>(p1) >= geometry::get<1>(top_left) ) + { + // closest box point is the top-left corner + return cast::apply(pp_strategy.apply(p1, top_left)); + } + else if ( geometry::get<1>(p1) >= geometry::get<1>(bottom_left) ) + { + // distance is realized between p1 and left-most + // segment of box + ReturnType diff = cast::apply(geometry::get<0>(p1)) + - cast::apply(geometry::get<0>(bottom_left)); + return diff * diff; + } + else + { + // distance is realized between the bottom-left + // corner of the box and the segment + return cast::apply(ps_strategy.apply(bottom_left, p0, p1)); + } + } + + // the segment lies below the box + if ( geometry::get<1>(p0) < geometry::get<1>(bottom_left) ) + { + // p0 is below the lower segment of the box + // (and inside its band) + if ( geometry::get<0>(p0) >= geometry::get<0>(bottom_left) ) + { + ReturnType diff = cast::apply(geometry::get<1>(bottom_left)) + - cast::apply(geometry::get<1>(p0)); + return diff * diff; + } + + // p0 is to the left of the box, but p1 is below the box + // in this case the distance is realized between the + // bottom-left corner of the box and the segment + return cast::apply(ps_strategy.apply(bottom_left, p0, p1)); + } + + // the segment lies above the box + if ( geometry::get<1>(p1) > geometry::get<1>(top_right) ) + { + // p1 is above the upper segment of the box + // (and inside its band) + if ( geometry::get<0>(p1) <= geometry::get<0>(top_right) ) + { + ReturnType diff = cast::apply(geometry::get<1>(p1)) + - cast::apply(geometry::get<1>(top_right)); + return diff * diff; + } + + // p1 is to the right of the box, but p0 is above the box + // in this case the distance is realized between the + // top-right corner of the box and the segment + return cast::apply(ps_strategy.apply(top_right, p0, p1)); + } + + ReturnType diff0 = cast::apply(geometry::get<0>(p1)) + - cast::apply(geometry::get<0>(p0)); + ReturnType t_min0 = cast::apply(geometry::get<0>(bottom_left)) + - cast::apply(geometry::get<0>(p0)); + ReturnType t_max0 = cast::apply(geometry::get<0>(top_right)) + - cast::apply(geometry::get<0>(p0)); + + ReturnType diff1 = cast::apply(geometry::get<1>(p0)) + - cast::apply(geometry::get<1>(p1)); + ReturnType t_min1 = cast::apply(geometry::get<1>(p0)) + - cast::apply(geometry::get<1>(top_right)); + ReturnType t_max1 = cast::apply(geometry::get<1>(p0)) + - cast::apply(geometry::get<1>(bottom_left)); + + // t_max0 < t_max1 + if ( t_max0 * diff1 < t_max1 * diff0 ) + { + return cast::apply(ps_strategy.apply(top_right, p0, p1)); + } + + // t_min0 > t_min1 + if ( t_min0 * diff1 > t_min1 * diff0 ) + { + return cast::apply(ps_strategy.apply(bottom_left, p0, p1)); + } + + // in all other cases the box and segment intersect, so return 0 + return ReturnType(0); + } + +public: + static inline ReturnType apply(SegmentPoint const& p0, + SegmentPoint const& p1, + BoxPoint const& top_left, + BoxPoint const& top_right, + BoxPoint const& bottom_left, + BoxPoint const& bottom_right, + PPStrategy const& pp_strategy, + PSStrategy const& ps_strategy) + { + BOOST_ASSERT( geometry::less()(p0, p1) ); + + if ( geometry::get<0>(p0) < geometry::get<0>(p1) + && geometry::get<1>(p0) > geometry::get<1>(p1) ) + { + return negative_slope_segment(p0, p1, + top_left, top_right, + bottom_left, bottom_right, + pp_strategy, + ps_strategy); + } + + return non_negative_slope_segment(p0, p1, + top_left, top_right, + bottom_left, bottom_right, + pp_strategy, + ps_strategy); + } +}; + + +//========================================================================= +//========================================================================= +//========================================================================= + +template +< + typename Segment, + typename Box, + typename std::size_t Dimension, + typename PPStrategy, + typename PSStrategy +> +class segment_to_box + : not_implemented +{}; + + +template +< + typename Segment, + typename Box, + typename PPStrategy, + typename PSStrategy +> +class segment_to_box +{ +private: + typedef typename point_type::type segment_point; + typedef typename point_type::type box_point; + + typedef typename strategy::distance::services::comparable_type + < + PPStrategy + >::type pp_comparable_strategy; + + typedef typename strategy::distance::services::comparable_type + < + PSStrategy + >::type ps_comparable_strategy; + +public: + typedef typename strategy::distance::services::return_type + < + PSStrategy, segment_point, box_point + >::type return_type; + + static inline return_type apply(Segment const& segment, + Box const& box, + PPStrategy const& pp_strategy, + PSStrategy const& ps_strategy) + { + segment_point p[2]; + detail::assign_point_from_index<0>(segment, p[0]); + detail::assign_point_from_index<1>(segment, p[1]); + + if ( geometry::equals(p[0], p[1]) ) + { + typedef typename detail::distance::default_strategy + < + segment_point, Box + >::type default_point_box_strategy_type; + + return dispatch::distance + < + segment_point, + Box, + default_point_box_strategy_type + >::apply(p[0], box, default_point_box_strategy_type()); + } + + box_point top_left, top_right, bottom_left, bottom_right; + detail::assign_box_corners(box, bottom_left, bottom_right, + top_left, top_right); + + pp_comparable_strategy c_pp_strategy = + strategy::distance::services::get_comparable + < + PPStrategy + >::apply(pp_strategy); + + ps_comparable_strategy c_ps_strategy = + strategy::distance::services::get_comparable + < + PSStrategy + >::apply(ps_strategy); + + return_type d; + + if ( geometry::less()(p[0], p[1]) ) + { + d = segment_to_box_2D + < + return_type, + segment_point, + box_point, + pp_comparable_strategy, + ps_comparable_strategy + >::apply(p[0], p[1], + top_left, top_right, bottom_left, bottom_right, + c_pp_strategy, + c_ps_strategy); + } + else + { + d = segment_to_box_2D + < + return_type, + segment_point, + box_point, + pp_comparable_strategy, + ps_comparable_strategy + >::apply(p[1], p[0], + top_left, top_right, bottom_left, bottom_right, + c_pp_strategy, + c_ps_strategy); + } + + return strategy::distance::services::comparable_to_regular + < + ps_comparable_strategy, PSStrategy, Segment, Box + >::apply( d ); + } +}; + + +}} // namespace detail::distance +#endif // DOXYGEN_NO_DETAIL + + +#ifndef DOXYGEN_NO_DISPATCH +namespace dispatch +{ + + +template +struct distance + < + Segment, Box, Strategy, segment_tag, box_tag, + strategy_tag_distance_point_point, false + > +{ + typedef typename strategy::distance::services::return_type + < + Strategy, + typename point_type::type, + typename point_type::type + >::type return_type; + + + static inline return_type apply(Segment const& segment, + Box const& box, + Strategy const& strategy) + { + assert_dimension_equal(); + + typedef typename detail::distance::default_ps_strategy + < + typename point_type::type, + typename point_type::type, + Strategy + >::type ps_strategy_type; + + return detail::distance::segment_to_box + < + Segment, + Box, + dimension::value, + Strategy, + ps_strategy_type + >::apply(segment, box, strategy, ps_strategy_type()); + } +}; + + +template +struct distance + < + Segment, Box, Strategy, segment_tag, box_tag, + strategy_tag_distance_point_segment, false + > +{ + typedef typename strategy::distance::services::return_type + < + Strategy, + typename point_type::type, + typename point_type::type + >::type return_type; + + + static inline return_type apply(Segment const& segment, + Box const& box, + Strategy const& strategy) + { + assert_dimension_equal(); + + typedef typename strategy::distance::services::strategy_point_point + < + Strategy + >::type pp_strategy_type; + + return detail::distance::segment_to_box + < + Segment, + Box, + dimension::value, + pp_strategy_type, + Strategy + >::apply(segment, box, pp_strategy_type(), strategy); + } +}; + + + +} // namespace dispatch +#endif // DOXYGEN_NO_DISPATCH + + +}} // namespace boost::geometry + + +#endif // BOOST_GEOMETRY_ALGORITHMS_DETAIL_DISTANCE_SEGMENT_TO_BOX_HPP From 8553124d37d56dbb4b77d039b0be1cbecd1c47d8 Mon Sep 17 00:00:00 2001 From: Menelaos Karavelas Date: Thu, 8 May 2014 14:58:05 +0300 Subject: [PATCH 15/66] [distance] base cose for distance computations using the R-Tree --- .../distance/geometry_to_geometry_rtree.hpp | 338 ++++++++++++++++++ 1 file changed, 338 insertions(+) create mode 100644 include/boost/geometry/algorithms/detail/distance/geometry_to_geometry_rtree.hpp diff --git a/include/boost/geometry/algorithms/detail/distance/geometry_to_geometry_rtree.hpp b/include/boost/geometry/algorithms/detail/distance/geometry_to_geometry_rtree.hpp new file mode 100644 index 000000000..84030d77c --- /dev/null +++ b/include/boost/geometry/algorithms/detail/distance/geometry_to_geometry_rtree.hpp @@ -0,0 +1,338 @@ +// Boost.Geometry (aka GGL, Generic Geometry Library) + +// Copyright (c) 2014, Oracle and/or its affiliates. + +// Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle + +// Licensed under the Boost Software License version 1.0. +// http://www.boost.org/users/license.html + +#ifndef BOOST_GEOMETRY_ALGORITHMS_DETAIL_DISTANCE_GEOMETRY_TO_GEOMETRY_RTREE_HPP +#define BOOST_GEOMETRY_ALGORITHMS_DETAIL_DISTANCE_GEOMETRY_TO_GEOMETRY_RTREE_HPP + +#include +#include +#include + +#include +#include + +#include +#include +#include + +#include +#include + +#include +#include + +#include +#include +#include + +#include + +#include + + +namespace boost { namespace geometry +{ + + +#ifndef DOXYGEN_NO_DETAIL +namespace detail { namespace distance +{ + + + +template +< + typename RTreePoint, + typename Geometry, + typename Strategy +> +class point_range_to_geometry_rtree +{ +public: + typedef typename strategy::distance::services::comparable_type + < + Strategy + >::type comparable_strategy; + + typedef typename strategy::distance::services::return_type + < + Strategy, + RTreePoint, + typename point_type::type + >::type return_type; + +private: + typedef index::rtree > r_tree; + + // functor to evaluate minimum comparable distance + struct minimum_cdistance_evaluator + { + r_tree const& m_r_tree; + comparable_strategy const& m_cstrategy; + bool m_first; + return_type m_min_cd; + + minimum_cdistance_evaluator(r_tree const& r_tree, + comparable_strategy const& cstrategy) + : m_r_tree(r_tree), m_cstrategy(cstrategy), + m_first(true), m_min_cd() + {} + + template + inline void operator()(QueryGeometry const& query_geometry) + { + typename r_tree::value_type t_v; + std::size_t n = + m_r_tree.query(index::nearest(query_geometry, 1), &t_v); + + BOOST_ASSERT( n > 0 ); + + return_type cd = dispatch::distance + < + typename r_tree::value_type, + QueryGeometry, + comparable_strategy + >::apply(t_v, query_geometry, m_cstrategy); + + if ( m_first || cd < m_min_cd ) + { + m_first = false; + m_min_cd = cd; + } + } + }; + + + + // class to choose between for_each_point and for_each_segment + template ::type> + struct for_each_selector + { + typedef dispatch::for_each_segment type; + }; + + template + struct for_each_selector + { + typedef dispatch::for_each_point type; + }; + +public: + template + static inline return_type apply(PointIterator points_first, + PointIterator points_beyond, + Geometry const& geometry, + Strategy const& strategy) + { + BOOST_ASSERT( points_first != points_beyond ); + + if ( geometry::has_one_element(points_first, points_beyond) ) + { + return dispatch::distance + < + typename std::iterator_traits::value_type, + Geometry, + Strategy + >::apply(*points_first, geometry, strategy); + } + + // create -- packing algorithm + r_tree rt(points_first, points_beyond); + + minimum_cdistance_evaluator + functor(rt, + strategy::distance::services::get_comparable + < + Strategy + >::apply(strategy)); + + for_each_selector::type::apply(geometry, functor); + + return strategy::distance::services::comparable_to_regular + < + comparable_strategy, Strategy, RTreePoint, Geometry + >::apply(functor.m_min_cd); + } +}; + + + +template +< + typename Geometry1, + typename Geometry2, + typename Strategy +> +struct geometry_to_geometry_rtree +{ + // the following works with linear geometries seen as ranges of points + // + // we compute the r-tree for the points of one range and then, + // compute nearest points for the segments of the other, + // ... and ... + // vice versa. + + typedef typename strategy::distance::services::return_type + < + Strategy, + typename point_type::type, + typename point_type::type + >::type return_type; + + static inline return_type apply(Geometry1 const& geometry1, + Geometry2 const& geometry2, + Strategy const& strategy, + bool check_intersection = true) + { + point_iterator first1 = points_begin(geometry1); + point_iterator beyond1 = points_end(geometry1); + point_iterator first2 = points_begin(geometry2); + point_iterator beyond2 = points_end(geometry2); + + if ( geometry::has_one_element(first1, beyond1) ) + { + return dispatch::distance + < + typename point_type::type, + Geometry2, + Strategy + >::apply(*first1, geometry2, strategy); + } + + if ( geometry::has_one_element(first2, beyond2) ) + { + return dispatch::distance + < + typename point_type::type, + Geometry1, + Strategy + >::apply(*first2, geometry1, strategy); + } + + if ( check_intersection && geometry::intersects(geometry1, geometry2) ) + { + return return_type(0); + } + + return_type cdist1 = point_range_to_geometry_rtree + < + typename point_type::type, + Geometry2, + Strategy + >::apply(first1, beyond1, geometry2, strategy); + + return_type cdist2 = point_range_to_geometry_rtree + < + typename point_type::type, + Geometry1, + Strategy + >::apply(first2, beyond2, geometry1, strategy); + + return (std::min)(cdist1, cdist2); + } +}; + + + + +}} // namespace detail::distance +#endif // DOXYGEN_NO_DETAIL + + + + +#ifndef DOXYGEN_NO_DISPATCH +namespace dispatch +{ + + +template +struct distance + < + Linestring1, Linestring2, Strategy, + linestring_tag, linestring_tag, + strategy_tag_distance_point_segment, false + > + : detail::distance::geometry_to_geometry_rtree + < + Linestring1, Linestring2, Strategy + > +{}; + + + +template +struct distance + < + Linestring, Polygon, Strategy, + linestring_tag, polygon_tag, + strategy_tag_distance_point_segment, false + > + : detail::distance::geometry_to_geometry_rtree + < + Linestring, Polygon, Strategy + > +{}; + + + +template +struct distance + < + Linestring, Ring, Strategy, + linestring_tag, ring_tag, + strategy_tag_distance_point_segment, false + > + : detail::distance::geometry_to_geometry_rtree + < + Linestring, Ring, Strategy + > +{}; + + + +template +struct distance + < + Polygon1, Polygon2, Strategy, + polygon_tag, polygon_tag, + strategy_tag_distance_point_segment, false + > + : detail::distance::geometry_to_geometry_rtree + < + Polygon1, Polygon2, Strategy + > +{}; + + + +template +struct distance + < + Polygon, Ring, Strategy, + polygon_tag, ring_tag, + strategy_tag_distance_point_segment, false + > + : detail::distance::geometry_to_geometry_rtree + < + Polygon, Ring, Strategy + > +{}; + + + + +} // namespace dispatch +#endif // DOXYGEN_NO_DISPATCH + + + +}} // namespace boost::geometry + +#endif // BOOST_GEOMETRY_ALGORITHMS_DETAIL_DISTANCE_GEOMETRY_TO_GEOMETRY_RTREE_HPP From ab6588f9b2b935a08deabd0eabcc7ec93bdc507a Mon Sep 17 00:00:00 2001 From: Menelaos Karavelas Date: Thu, 8 May 2014 15:00:07 +0300 Subject: [PATCH 16/66] [distance] implementation for distance(multi-point,range) --- .../detail/distance/multipoint_to_range.hpp | 182 ++++++++++++++++++ 1 file changed, 182 insertions(+) create mode 100644 include/boost/geometry/algorithms/detail/distance/multipoint_to_range.hpp diff --git a/include/boost/geometry/algorithms/detail/distance/multipoint_to_range.hpp b/include/boost/geometry/algorithms/detail/distance/multipoint_to_range.hpp new file mode 100644 index 000000000..5a800175c --- /dev/null +++ b/include/boost/geometry/algorithms/detail/distance/multipoint_to_range.hpp @@ -0,0 +1,182 @@ +// Boost.Geometry (aka GGL, Generic Geometry Library) + +// Copyright (c) 2014, Oracle and/or its affiliates. + +// Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle + +// Licensed under the Boost Software License version 1.0. +// http://www.boost.org/users/license.html + +#ifndef BOOST_GEOMETRY_ALGORITHMS_DETAIL_DISTANCE_MULTIPOINT_TO_RANGE_HPP +#define BOOST_GEOMETRY_ALGORITHMS_DETAIL_DISTANCE_MULTIPOINT_TO_RANGE_HPP + +#include + +#include +#include +#include + +#include + +#include +#include +#include + +#include + + +namespace boost { namespace geometry +{ + +#ifndef DOXYGEN_NO_DETAIL +namespace detail { namespace distance +{ + +template +struct multipoint_to_multipoint +{ + typedef typename strategy::distance::services::return_type + < + Strategy, + typename point_type::type, + typename point_type::type + >::type return_type; + + static inline return_type apply(MultiPoint1 const& multipoint1, + MultiPoint2 const& multipoint2, + Strategy const& strategy) + { + if ( boost::size(multipoint1) > boost::size(multipoint2) ) + + { + return multipoint_to_multipoint + < + MultiPoint2, MultiPoint1, Strategy + >::apply(multipoint2, multipoint1, strategy); + } + + return point_range_to_geometry_rtree + < + typename point_type::type, + MultiPoint2, + Strategy + >::apply(points_begin(multipoint1), points_end(multipoint1), + multipoint2, strategy); + } +}; + + +}} // namespace detail::distance +#endif // DOXYGEN_NO_DETAIL + + + +#ifndef DOXYGEN_NO_DISPATCH +namespace dispatch +{ + + +namespace splitted_dispatch +{ + +// specializations of distance_single_to_multi for various geometry combinations + +template +struct distance_single_to_multi + < + Linestring, MultiPoint, Strategy, + linestring_tag, multi_point_tag, + strategy_tag_distance_point_segment + > +{ + typedef typename strategy::distance::services::return_type + < + Strategy, + typename point_type::type, + typename point_type::type + >::type return_type; + + static inline return_type apply(Linestring const& linestring, + MultiPoint const& multipoint, + Strategy const& strategy) + { + return detail::distance::point_range_to_geometry_rtree + < + typename point_type::type, + Linestring, + Strategy + >::apply(geometry::points_begin(multipoint), + geometry::points_end(multipoint), + linestring, strategy); + + } +}; + + + + +// specializations of distance_multi_to_multi for various geometry combinations + + +template +struct distance_multi_to_multi + < + MultiPoint1, MultiPoint2, Strategy, + multi_point_tag, multi_point_tag, + strategy_tag_distance_point_point + > : detail::distance::multipoint_to_multipoint + < + MultiPoint1, MultiPoint2, Strategy + > +{}; + + + +template +< + typename MultiPoint, + typename MultiLinestring, + typename Strategy +> +struct distance_multi_to_multi + < + MultiPoint, MultiLinestring, Strategy, + multi_point_tag, multi_linestring_tag, + strategy_tag_distance_point_segment + > +{ + typedef typename strategy::distance::services::return_type + < + Strategy, + typename point_type::type, + typename point_type::type + >::type return_type; + + static inline return_type apply(MultiPoint const& multipoint, + MultiLinestring const& multilinestring, + Strategy const& strategy) + { + return detail::distance::point_range_to_geometry_rtree + < + typename point_type::type, + MultiLinestring, + Strategy + >::apply(geometry::points_begin(multipoint), + geometry::points_end(multipoint), + multilinestring, strategy); + + } +}; + +} // namespace splitted_dispatch + + +} // namespace dispatch +#endif // DOXYGEN_NO_DISPATCH + + + +}} // namespace boost::geometry + + +#endif // BOOST_GEOMETRY_MULTI_ALGORITHMS_DISTANCE_ALTERNATE_HPP From e783d7ca2e0de038b664795cc82ddac6fc51facd Mon Sep 17 00:00:00 2001 From: Menelaos Karavelas Date: Thu, 8 May 2014 15:01:03 +0300 Subject: [PATCH 17/66] [distance] dispatches for various geometry combinations with the point-point strategy; the point-point strategy is not the natural distance strategy for these geometry pairs; the dispatches have been added for backward compatibility; --- .../distance/backward_compatibility.hpp | 346 ++++++++++++++++++ 1 file changed, 346 insertions(+) create mode 100644 include/boost/geometry/algorithms/detail/distance/backward_compatibility.hpp diff --git a/include/boost/geometry/algorithms/detail/distance/backward_compatibility.hpp b/include/boost/geometry/algorithms/detail/distance/backward_compatibility.hpp new file mode 100644 index 000000000..603963cbf --- /dev/null +++ b/include/boost/geometry/algorithms/detail/distance/backward_compatibility.hpp @@ -0,0 +1,346 @@ +// Boost.Geometry (aka GGL, Generic Geometry Library) + +// Copyright (c) 2007-2014 Barend Gehrels, Amsterdam, the Netherlands. +// Copyright (c) 2008-2014 Bruno Lalande, Paris, France. +// Copyright (c) 2009-2014 Mateusz Loskot, London, UK. +// Copyright (c) 2013-2014 Adam Wulkiewicz, Lodz, Poland. + +// This file was modified by Oracle on 2014. +// Modifications copyright (c) 2014, Oracle and/or its affiliates. + +// Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle + +// 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) + +#ifndef BOOST_GEOMETRY_ALGORITHMS_DETAIL_DISTANCE_BACKWARD_COMPATIBILITY_HPP +#define BOOST_GEOMETRY_ALGORITHMS_DETAIL_DISTANCE_BACKWARD_COMPATIBILITY_HPP + +#include + +#include +#include +#include +#include + +#include +#include + +#include + +#include + +#include +#include +#include +#include + + +namespace boost { namespace geometry +{ + + +#ifndef DOXYGEN_NO_DETAIL +namespace detail { namespace distance +{ + + +template +struct point_to_segment +{ + static inline typename strategy::distance::services::return_type + < + Strategy, + Point, + typename point_type::type + >::type + apply(Point const& point, Segment const& segment, Strategy const& ) + { + typename detail::distance::default_ps_strategy + < + Point, + typename point_type::type, + Strategy + >::type segment_strategy; + + typename point_type::type p[2]; + geometry::detail::assign_point_from_index<0>(segment, p[0]); + geometry::detail::assign_point_from_index<1>(segment, p[1]); + return segment_strategy.apply(point, p[0], p[1]); + } +}; + + +}} // namespace detail::distance +#endif // DOXYGEN_NO_DETAIL + + + + +#ifndef DOXYGEN_NO_DISPATCH +namespace dispatch +{ + + +// Point-segment version 1, with point-point strategy +template +struct distance +< + Point, Segment, Strategy, + point_tag, segment_tag, strategy_tag_distance_point_point, + false +> : detail::distance::point_to_segment +{}; + + +// Point-line version 1, where point-point strategy is specified +template +struct distance +< + Point, Linestring, Strategy, + point_tag, linestring_tag, strategy_tag_distance_point_point, + false +> +{ + + static inline typename return_type::type>::type + apply(Point const& point, + Linestring const& linestring, + Strategy const& strategy) + { + typedef typename detail::distance::default_ps_strategy + < + Point, + typename point_type::type, + Strategy + >::type ps_strategy_type; + + return detail::distance::point_to_range + < + Point, Linestring, closed, ps_strategy_type + >::apply(point, linestring, ps_strategy_type()); + } +}; + + +// Point-ring , where point-point strategy is specified +template +struct distance +< + Point, Ring, Strategy, + point_tag, ring_tag, strategy_tag_distance_point_point, + false +> +{ + typedef typename strategy::distance::services::return_type + < + Strategy, Point, typename point_type::type + >::type return_type; + + static inline return_type apply(Point const& point, + Ring const& ring, + Strategy const& strategy) + { + typedef typename detail::distance::default_ps_strategy + < + Point, + typename point_type::type, + Strategy + >::type ps_strategy_type; + + std::pair + dc = detail::distance::point_to_ring + < + Point, Ring, + geometry::closure::value, + ps_strategy_type + >::apply(point, ring, ps_strategy_type()); + + return dc.second ? return_type(0) : dc.first; + } +}; + + +// Point-polygon , where point-point strategy is specified +template +struct distance +< + Point, Polygon, Strategy, + point_tag, polygon_tag, strategy_tag_distance_point_point, + false +> +{ + typedef typename strategy::distance::services::return_type + < + Strategy, Point, typename point_type::type + >::type return_type; + + static inline return_type apply(Point const& point, + Polygon const& polygon, + Strategy const& strategy) + { + typedef typename detail::distance::default_ps_strategy + < + Point, + typename point_type::type, + Strategy + >::type ps_strategy_type; + + std::pair + dc = detail::distance::point_to_polygon + < + Point, Polygon, + geometry::closure::value, + ps_strategy_type + >::apply(point, polygon, ps_strategy_type()); + + return dc.second ? return_type(0) : dc.first; + } +}; + + + + +namespace splitted_dispatch +{ + + +template +< + typename Point, + typename MultiGeometry, + typename MultiGeometryTag, + typename Strategy +> +struct distance_single_to_multi + < + Point, MultiGeometry, Strategy, + point_tag, MultiGeometryTag, + strategy_tag_distance_point_point + > +{ + typedef typename strategy::distance::services::return_type + < + Strategy, Point, typename point_type::type + >::type return_type; + + static inline return_type apply(Point const& point, + MultiGeometry const& multigeometry, + Strategy const&) + { + typedef typename detail::distance::default_ps_strategy + < + Point, + typename point_type::type, + Strategy + >::type ps_strategy_type; + + return distance_single_to_multi + < + Point, MultiGeometry, ps_strategy_type, + point_tag, MultiGeometryTag, + strategy_tag_distance_point_segment + >::apply(point, multigeometry, ps_strategy_type()); + } +}; + + +template +< + typename Geometry, + typename MultiPoint, + typename GeometryTag, + typename Strategy +> +struct distance_single_to_multi + < + Geometry, MultiPoint, Strategy, + GeometryTag, multi_point_tag, + strategy_tag_distance_point_point + > +{ + typedef typename strategy::distance::services::return_type + < + Strategy, + typename point_type::type, + typename point_type::type + >::type return_type; + + static inline return_type apply(Geometry const& geometry, + MultiPoint const& multipoint, + Strategy const&) + { + typedef typename detail::distance::default_ps_strategy + < + typename point_type::type, + typename point_type::type, + Strategy + >::type ps_strategy_type; + + return distance_single_to_multi + < + Geometry, MultiPoint, ps_strategy_type, + GeometryTag, multi_point_tag, + strategy_tag_distance_point_segment + >::apply(geometry, multipoint, ps_strategy_type()); + } +}; + + +template +< + typename MultiPoint, + typename MultiGeometry, + typename MultiGeometryTag, + typename Strategy +> +struct distance_multi_to_multi + < + MultiPoint, MultiGeometry, Strategy, + multi_point_tag, MultiGeometryTag, + strategy_tag_distance_point_point + > +{ + typedef typename strategy::distance::services::return_type + < + Strategy, + typename point_type::type, + typename point_type::type + >::type return_type; + + static inline return_type apply(MultiPoint const& multipoint, + MultiGeometry const& multigeometry, + Strategy const&) + { + typedef typename detail::distance::default_ps_strategy + < + typename point_type::type, + typename point_type::type, + Strategy + >::type ps_strategy_type; + + return distance_multi_to_multi + < + MultiPoint, MultiGeometry, ps_strategy_type, + multi_point_tag, MultiGeometryTag, + strategy_tag_distance_point_segment + >::apply(multipoint, multigeometry, ps_strategy_type()); + } +}; + + +} // namespace splitted_dispatch + + +} // namespace dispatch +#endif // DOXYGEN_NO_DISPATCH + + +}} // namespace boost::geometry + + +#endif // BOOST_GEOMETRY_ALGORITHMS_DETAIL_DISTANCE_BACKWARD_COMPATIBILITY_HPP From 8a23c010617355fd7aca0b2951fe3ab2aa593de6 Mon Sep 17 00:00:00 2001 From: Menelaos Karavelas Date: Thu, 8 May 2014 15:02:49 +0300 Subject: [PATCH 18/66] [test][distance] add common code for distance unit tests --- test/algorithms/test_distance_common.hpp | 392 +++++++++++++++++++++++ 1 file changed, 392 insertions(+) create mode 100644 test/algorithms/test_distance_common.hpp diff --git a/test/algorithms/test_distance_common.hpp b/test/algorithms/test_distance_common.hpp new file mode 100644 index 000000000..d6c1d4f9d --- /dev/null +++ b/test/algorithms/test_distance_common.hpp @@ -0,0 +1,392 @@ +// Boost.Geometry (aka GGL, Generic Geometry Library) +// Unit Test + +// Copyright (c) 2014, Oracle and/or its affiliates. + +// Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle + +// Licensed under the Boost Software License version 1.0. +// http://www.boost.org/users/license.html + +#ifndef BOOST_GEOMETRY_TEST_DISTANCE_COMMON_HPP +#define BOOST_GEOMETRY_TEST_DISTANCE_COMMON_HPP + +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +#include +#include + +#include "from_wkt.hpp" + + + +#ifndef BOOST_GEOMETRY_TEST_DISTANCE_HPP + +namespace bg = ::boost::geometry; + +// function copied from BG's test_distance.hpp + +template +void test_empty_input(Geometry1 const& geometry1, Geometry2 const& geometry2) +{ + try + { + bg::distance(geometry1, geometry2); + } + catch(bg::empty_input_exception const& ) + { + return; + } + BOOST_CHECK_MESSAGE(false, "A empty_input_exception should have been thrown" ); +} +#endif // BOOST_GEOMETRY_TEST_DISTANCE_HPP + + + +//======================================================================== +//======================================================================== +//======================================================================== + + +// create geometries -- START +template +Segment make_segment(double x1, double y1, double x2, double y2) +{ + typename bg::point_type::type p(x1, y1), q(x2, y2); + return Segment(p, q); +} + + +template +Box make_box2d(double xmin, double ymin, double xmax, double ymax) +{ + typedef typename bg::point_type::type BoxPoint; + + return Box(BoxPoint(xmin, ymin), BoxPoint(xmax, ymax)); +} + +template +Box make_box3d(double xmin, double ymin, double zmin, + double xmax, double ymax, double zmax) +{ + typedef typename bg::point_type::type BoxPoint; + + return Box(BoxPoint(xmin, ymin, zmin), BoxPoint(xmax, ymax, zmax)); +} +// create geometries -- END + + +//======================================================================== +//======================================================================== +//======================================================================== + + +#ifdef GEOMETRY_TEST_DEBUG +// pretty print geometry -- START +template +struct pretty_print_geometry_dispatch +{ + template + static inline Stream& apply(Geometry const& geometry, Stream& os) + { + os << bg::wkt(geometry); + return os; + } +}; + +template +struct pretty_print_geometry_dispatch +{ + template + static inline Stream& apply(Geometry const& geometry, Stream& os) + { + os << "SEGMENT" << bg::dsv(geometry); + return os; + } +}; + +template +struct pretty_print_geometry_dispatch +{ + template + static inline Stream& apply(Geometry const& geometry, Stream& os) + { + os << "BOX" << bg::dsv(geometry); + return os; + } +}; + + +template +struct pretty_print_geometry +{ + template + static inline Stream& apply(Geometry const& geometry, Stream& os) + { + return pretty_print_geometry_dispatch + < + Geometry, typename bg::tag::type + >::apply(geometry, os); + } +}; +// pretty print geometry -- END +#endif // GEOMETRY_TEST_DEBUG + + + + +//======================================================================== + +template +< + typename Geometry1, typename Geometry2, + int id1 = bg::geometry_id::value, + int id2 = bg::geometry_id::value +> +struct test_distance_of_geometries + : public test_distance_of_geometries +{}; + + +template +struct test_distance_of_geometries +{ + template + void operator()(std::string const& wkt1, + std::string const& wkt2, + double expected_distance, + double expected_comparable_distance, + Strategy const& strategy, + bool test_reversed = false) const + { + Geometry1 geometry1 = from_wkt(wkt1); + Geometry2 geometry2 = from_wkt(wkt2); + + operator()(geometry1, geometry2, + expected_distance, expected_comparable_distance, + strategy, test_reversed); + } + + template + void operator()(Geometry1 const& geometry1, + std::string const& wkt2, + double expected_distance, + double expected_comparable_distance, + Strategy const& strategy, + bool test_reversed = false) const + { + Geometry2 geometry2 = from_wkt(wkt2); + + operator()(geometry1, geometry2, + expected_distance, expected_comparable_distance, + strategy, test_reversed); + } + + template + void operator()(std::string const& wkt1, + Geometry2 const& geometry2, + double expected_distance, + double expected_comparable_distance, + Strategy const& strategy, + bool test_reversed = false) const + { + Geometry1 geometry1 = from_wkt(wkt1); + + operator()(geometry1, geometry2, + expected_distance, expected_comparable_distance, + strategy, test_reversed); + } + + template + void operator()(Geometry1 const& geometry1, + Geometry2 const& geometry2, + double expected_distance, + double expected_comparable_distance, + Strategy const& strategy, + bool test_reversed = true) const + { + +#ifdef GEOMETRY_TEST_DEBUG + typedef pretty_print_geometry PPG1; + typedef pretty_print_geometry PPG2; + PPG1::apply(geometry1, std::cout); + std::cout << " - "; + PPG2::apply(geometry2, std::cout); + std::cout << std::endl; +#endif + + typename bg::default_distance_result::type dist_def + = bg::distance(geometry1, geometry2); + + BOOST_CHECK_CLOSE(dist_def, expected_distance, 0.0001); + + typename bg::default_distance_result::type dist + = bg::distance(geometry1, geometry2, strategy); + + BOOST_CHECK_CLOSE(dist, expected_distance, 0.0001); + +#ifdef GEOMETRY_TEST_DEBUG + typename bg::default_distance_result::type cdist_def + = bg::comparable_distance(geometry1, geometry2); + + BOOST_CHECK_CLOSE(cdist_def, expected_comparable_distance, 0.001); +#endif + + typename bg::default_distance_result::type cdist + = bg::comparable_distance(geometry1, geometry2, strategy); + + BOOST_CHECK_CLOSE(cdist, expected_comparable_distance, 0.001); + +#ifdef GEOMETRY_TEST_DEBUG + std::cout << "distance (default strategy) = " << dist_def << " ; " + << "distance (passed strategy) = " << dist << " ; " + << "comp. distance (default strategy) = " + << cdist_def << " ; " + << "comp. distance (passed strategy) = " + << cdist << std::endl; + + if ( !test_reversed ) + { + std::cout << std::endl; + } +#endif + + if ( test_reversed ) + { + dist_def = bg::distance(geometry2, geometry1); + + BOOST_CHECK_CLOSE(dist_def, expected_distance, 0.0001); + + dist = bg::distance(geometry2, geometry1, strategy); + + BOOST_CHECK_CLOSE(dist, expected_distance, 0.0001); + +#ifdef GEOMETRY_TEST_DEBUG + cdist_def = bg::comparable_distance(geometry2, geometry1); + + BOOST_CHECK_CLOSE(cdist_def, expected_comparable_distance, 0.001); +#endif + + cdist = bg::comparable_distance(geometry2, geometry1, strategy); + + BOOST_CHECK_CLOSE(cdist, expected_comparable_distance, 0.001); + +#ifdef GEOMETRY_TEST_DEBUG + std::cout << "distance[reversed args] (def. startegy) = " + << dist_def << " ; " + << "distance[reversed args] (passed startegy) = " + << dist << " ; " + << "comp. distance[reversed args] (def. strategy) = " + << cdist_def << " ; " + << "comp. distance[reversed args] (passed strategy) = " + << cdist << std::endl; + std::cout << std::endl; +#endif + } + } +}; + + +//======================================================================== +//======================================================================== + +template +struct test_distance_of_geometries +< + Geometry1, Geometry2, + 92 /* segment */, 3 /* polygon */ +> + : public test_distance_of_geometries +{ + typedef test_distance_of_geometries base; + + typedef typename bg::ring_type::type ring_type; + + template + void operator()(Segment const& segment, + std::string const& wkt, + double expected_distance, + double expected_comparable_distance, + Strategy const& strategy) const + { + Geometry2 geometry = from_wkt(wkt); + operator()(segment, + geometry, + expected_distance, + expected_comparable_distance, + strategy); + } + + + template + void operator()(Segment const& segment, + Geometry2 const& geometry, + double expected_distance, + double expected_comparable_distance, + Strategy const& strategy) const + { + base::operator()(segment, geometry, expected_distance, + expected_comparable_distance, strategy); + if ( bg::num_interior_rings(geometry) == 0 ) { +#ifdef GEOMETRY_TEST_DEBUG + std::cout << "... testing also exterior ring ..." << std::endl; +#endif +#if 0 + // cannot run it now; needs within(point,linestring) + test_distance_of_segment_and_geometry() + (segment, + bg::exterior_ring(geometry), + expected_distance, + expected_comparable_distance, + strategy); +#endif + } + } +}; + + +//======================================================================== + + +template +void test_empty_input(Geometry1 const& geometry1, + Geometry2 const& geometry2, + Strategy const& strategy) +{ + try + { + bg::distance(geometry1, geometry2, strategy); + } + catch(bg::empty_input_exception const& ) + { + return; + } + BOOST_CHECK_MESSAGE(false, "A empty_input_exception should have been thrown" ); + + try + { + bg::distance(geometry2, geometry1, strategy); + } + catch(bg::empty_input_exception const& ) + { + return; + } + BOOST_CHECK_MESSAGE(false, "A empty_input_exception should have been thrown" ); +} + +#endif // BOOST_GEOMETRY_TEST_DISTANCE_COMMON_HPP From ddc5ddf0ffb8ed967a8dac842f086d79e7ca2376 Mon Sep 17 00:00:00 2001 From: Menelaos Karavelas Date: Thu, 8 May 2014 15:04:23 +0300 Subject: [PATCH 19/66] [comparable distance] add free function for comparable distance that takes a strategy --- .../algorithms/comparable_distance.hpp | 64 +++++++++++++++---- 1 file changed, 51 insertions(+), 13 deletions(-) diff --git a/include/boost/geometry/algorithms/comparable_distance.hpp b/include/boost/geometry/algorithms/comparable_distance.hpp index 4f0563a8a..9bce0390b 100644 --- a/include/boost/geometry/algorithms/comparable_distance.hpp +++ b/include/boost/geometry/algorithms/comparable_distance.hpp @@ -1,8 +1,13 @@ // 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. +// Copyright (c) 2007-2014 Barend Gehrels, Amsterdam, the Netherlands. +// Copyright (c) 2008-2014 Bruno Lalande, Paris, France. +// Copyright (c) 2009-2014 Mateusz Loskot, London, UK. + +// This file was modified by Oracle on 2014. +// Modifications copyright (c) 2014, Oracle and/or its affiliates. + +// Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle // Parts of Boost.Geometry are redesigned from Geodan's Geographic Library // (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands. @@ -15,13 +20,45 @@ #define BOOST_GEOMETRY_ALGORITHMS_COMPARABLE_DISTANCE_HPP +#include + +#include + #include +#include namespace boost { namespace geometry { +// MK::need to add qbk documentation +template +inline typename strategy::distance::services::return_type + < + typename strategy::distance::services::comparable_type + < + Strategy + >::type, + typename point_type::type, + typename point_type::type + >::type +comparable_distance(Geometry1 const& geometry1, Geometry2 const& geometry2, + Strategy const& strategy) +{ + concept::check(); + concept::check(); + + return distance(geometry1, geometry2, + strategy::distance::services::get_comparable + < + Strategy + >::apply(strategy) + ); +} + + + /*! \brief \brief_calc2{comparable distance measurement} \ingroup distance @@ -45,10 +82,7 @@ inline typename default_distance_result::type comparable_d concept::check(); concept::check(); - typedef typename point_type::type point1_type; - typedef typename point_type::type point2_type; - - // Define a point-point-distance-strategy + // Define a default-distance-strategy // for either the normal case, either the reversed case typedef typename strategy::distance::services::comparable_type @@ -57,14 +91,18 @@ inline typename default_distance_result::type comparable_d < geometry::reverse_dispatch ::type::value, - typename strategy::distance::services::default_strategy - ::type, - typename strategy::distance::services::default_strategy - ::type + typename detail::distance::default_strategy + < + Geometry2, Geometry1 + >::type, + typename detail::distance::default_strategy + < + Geometry1, Geometry2 + >::type >::type - >::type strategy_type; + >::type default_comparable_strategy_type; - return distance(geometry1, geometry2, strategy_type()); + return distance(geometry1, geometry2, default_comparable_strategy_type()); } From cfc4e7a3c9069a2b30f92c9066b7e771f5e50d84 Mon Sep 17 00:00:00 2001 From: Menelaos Karavelas Date: Thu, 8 May 2014 15:06:19 +0300 Subject: [PATCH 20/66] [multi][distance] move multi/algorithms distance code under algorithms/ keep the file as a placeholder and include algorithms/distance.hpp --- .../geometry/multi/algorithms/distance.hpp | 161 ++---------------- 1 file changed, 10 insertions(+), 151 deletions(-) diff --git a/include/boost/geometry/multi/algorithms/distance.hpp b/include/boost/geometry/multi/algorithms/distance.hpp index 92352d5fe..4946b6f3e 100644 --- a/include/boost/geometry/multi/algorithms/distance.hpp +++ b/include/boost/geometry/multi/algorithms/distance.hpp @@ -1,8 +1,13 @@ // 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. +// Copyright (c) 2007-2014 Barend Gehrels, Amsterdam, the Netherlands. +// Copyright (c) 2008-2014 Bruno Lalande, Paris, France. +// Copyright (c) 2009-2014 Mateusz Loskot, London, UK. + +// This file was modified by Oracle on 2014. +// Modifications copyright (c) 2014, Oracle and/or its affiliates. + +// Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle // Parts of Boost.Geometry are redesigned from Geodan's Geographic Library // (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands. @@ -14,155 +19,9 @@ #ifndef BOOST_GEOMETRY_MULTI_ALGORITHMS_DISTANCE_HPP #define BOOST_GEOMETRY_MULTI_ALGORITHMS_DISTANCE_HPP - -#include -#include - -#include -#include -#include -#include +// this file is intentionally empty (with the exception of the #include below) +// it is used for backward compatinility and may be removed in the future #include -#include -#include - - -namespace boost { namespace geometry -{ - -#ifndef DOXYGEN_NO_DETAIL -namespace detail { namespace distance -{ - - -template -struct distance_single_to_multi - : private dispatch::distance - < - Geometry, - typename range_value::type, - Strategy - > -{ - typedef typename strategy::distance::services::return_type - < - Strategy, - typename point_type::type, - typename point_type::type - >::type return_type; - - static inline return_type apply(Geometry const& geometry, - MultiGeometry const& multi, - Strategy const& strategy) - { - return_type mindist = return_type(); - bool first = true; - - for(typename range_iterator::type it = boost::begin(multi); - it != boost::end(multi); - ++it, first = false) - { - return_type dist = dispatch::distance - < - Geometry, - typename range_value::type, - Strategy - >::apply(geometry, *it, strategy); - - if (first || dist < mindist) - { - mindist = dist; - } - } - - return mindist; - } -}; - -template -struct distance_multi_to_multi - : private distance_single_to_multi - < - typename range_value::type, - Multi2, - Strategy - > -{ - typedef typename strategy::distance::services::return_type - < - Strategy, - typename point_type::type, - typename point_type::type - >::type return_type; - - static inline return_type apply(Multi1 const& multi1, - Multi2 const& multi2, Strategy const& strategy) - { - return_type mindist = return_type(); - bool first = true; - - for(typename range_iterator::type it = boost::begin(multi1); - it != boost::end(multi1); - ++it, first = false) - { - return_type dist = distance_single_to_multi - < - typename range_value::type, - Multi2, - Strategy - >::apply(*it, multi2, strategy); - if (first || dist < mindist) - { - mindist = dist; - } - } - - return mindist; - } -}; - - -}} // namespace detail::distance -#endif - - -#ifndef DOXYGEN_NO_DISPATCH -namespace dispatch -{ - -template -< - typename G1, - typename G2, - typename Strategy, - typename SingleGeometryTag -> -struct distance -< - G1, G2, Strategy, - SingleGeometryTag, multi_tag, strategy_tag_distance_point_point, - false -> - : detail::distance::distance_single_to_multi -{}; - -template -struct distance -< - G1, G2, Strategy, - multi_tag, multi_tag, strategy_tag_distance_point_point, - false -> - : detail::distance::distance_multi_to_multi -{}; - -} // namespace dispatch -#endif - - - -}} // namespace boost::geometry - #endif // BOOST_GEOMETRY_MULTI_ALGORITHMS_DISTANCE_HPP From 0600a3419feb66bde7f5fefaaed3874a11bf0908 Mon Sep 17 00:00:00 2001 From: Menelaos Karavelas Date: Thu, 8 May 2014 15:08:09 +0300 Subject: [PATCH 21/66] [strategies][distance] add tags for point-box and box-box strategies --- include/boost/geometry/strategies/tags.hpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/include/boost/geometry/strategies/tags.hpp b/include/boost/geometry/strategies/tags.hpp index 39f2f2303..7589c2107 100644 --- a/include/boost/geometry/strategies/tags.hpp +++ b/include/boost/geometry/strategies/tags.hpp @@ -34,6 +34,8 @@ namespace strategy struct strategy_tag_distance_point_point {}; struct strategy_tag_distance_point_segment {}; +struct strategy_tag_distance_point_box {}; +struct strategy_tag_distance_box_box {}; }} // namespace boost::geometry From 55f63b77dfefcd631748d3f01e5574bb8f58d90c Mon Sep 17 00:00:00 2001 From: Menelaos Karavelas Date: Thu, 8 May 2014 15:10:24 +0300 Subject: [PATCH 22/66] [distance] update distance.hpp: primary dispatch is under algorithms/dispatch/, details are under algorithms/detail/distance/ --- .../boost/geometry/algorithms/distance.hpp | 458 ++---------------- 1 file changed, 47 insertions(+), 411 deletions(-) diff --git a/include/boost/geometry/algorithms/distance.hpp b/include/boost/geometry/algorithms/distance.hpp index 953be2361..8f5ececdf 100644 --- a/include/boost/geometry/algorithms/distance.hpp +++ b/include/boost/geometry/algorithms/distance.hpp @@ -20,266 +20,49 @@ #ifndef BOOST_GEOMETRY_ALGORITHMS_DISTANCE_HPP #define BOOST_GEOMETRY_ALGORITHMS_DISTANCE_HPP - #include #include #include #include +#include + #include #include +#include #include #include #include #include -#include #include #include #include -#include -#include +#include -#include -#include +#include + +#include +#include +#include +#include + +#include + +#include namespace boost { namespace geometry { -#ifndef DOXYGEN_NO_DETAIL -namespace detail { namespace distance -{ - -// To avoid spurious namespaces here: -using strategy::distance::services::return_type; - -template -struct point_to_point -{ - static inline typename return_type::type - apply(P1 const& p1, P2 const& p2, Strategy const& strategy) - { - boost::ignore_unused_variable_warning(strategy); - return strategy.apply(p1, p2); - } -}; - - -template -struct point_to_segment -{ - static inline typename return_type::type>::type - apply(Point const& point, Segment const& segment, Strategy const& ) - { - typename strategy::distance::services::default_strategy - < - segment_tag, - Point, - typename point_type::type, - typename cs_tag::type, - typename cs_tag::type>::type, - Strategy - >::type segment_strategy; - - typename point_type::type p[2]; - geometry::detail::assign_point_from_index<0>(segment, p[0]); - geometry::detail::assign_point_from_index<1>(segment, p[1]); - return segment_strategy.apply(point, p[0], p[1]); - } -}; - - -template -< - typename Point, - typename Range, - closure_selector Closure, - typename PPStrategy, - typename PSStrategy -> -struct point_to_range -{ - typedef typename return_type::type>::type return_type; - - static inline return_type apply(Point const& point, Range const& range, - PPStrategy const& pp_strategy, PSStrategy const& ps_strategy) - { - return_type const zero = return_type(0); - - if (boost::size(range) == 0) - { - return zero; - } - - typedef typename closeable_view::type view_type; - - view_type view(range); - - // line of one point: return point distance - typedef typename boost::range_iterator::type iterator_type; - iterator_type it = boost::begin(view); - iterator_type prev = it++; - if (it == boost::end(view)) - { - return pp_strategy.apply(point, *boost::begin(view)); - } - - // Create comparable (more efficient) strategy - typedef typename strategy::distance::services::comparable_type::type eps_strategy_type; - eps_strategy_type eps_strategy = strategy::distance::services::get_comparable::apply(ps_strategy); - - // start with first segment distance - return_type d = eps_strategy.apply(point, *prev, *it); - return_type rd = ps_strategy.apply(point, *prev, *it); - - // check if other segments are closer - for (++prev, ++it; it != boost::end(view); ++prev, ++it) - { - return_type const ds = eps_strategy.apply(point, *prev, *it); - if (geometry::math::equals(ds, zero)) - { - return ds; - } - else if (ds < d) - { - d = ds; - rd = ps_strategy.apply(point, *prev, *it); - } - } - - return rd; - } -}; - - -template -< - typename Point, - typename Ring, - closure_selector Closure, - typename PPStrategy, - typename PSStrategy -> -struct point_to_ring -{ - typedef std::pair - < - typename return_type::type>::type, bool - > distance_containment; - - static inline distance_containment apply(Point const& point, - Ring const& ring, - PPStrategy const& pp_strategy, PSStrategy const& ps_strategy) - { - return distance_containment - ( - point_to_range - < - Point, - Ring, - Closure, - PPStrategy, - PSStrategy - >::apply(point, ring, pp_strategy, ps_strategy), - geometry::within(point, ring) - ); - } -}; - - - -template -< - typename Point, - typename Polygon, - closure_selector Closure, - typename PPStrategy, - typename PSStrategy -> -struct point_to_polygon -{ - typedef typename return_type::type>::type return_type; - typedef std::pair distance_containment; - - static inline distance_containment apply(Point const& point, - Polygon const& polygon, - PPStrategy const& pp_strategy, PSStrategy const& ps_strategy) - { - // Check distance to all rings - typedef point_to_ring - < - Point, - typename ring_type::type, - Closure, - PPStrategy, - PSStrategy - > per_ring; - - distance_containment dc = per_ring::apply(point, - exterior_ring(polygon), pp_strategy, ps_strategy); - - typename interior_return_type::type rings - = interior_rings(polygon); - for (BOOST_AUTO_TPL(it, boost::begin(rings)); it != boost::end(rings); ++it) - { - distance_containment dcr = per_ring::apply(point, - *it, pp_strategy, ps_strategy); - if (dcr.first < dc.first) - { - dc.first = dcr.first; - } - // If it was inside, and also inside inner ring, - // turn off the inside-flag, it is outside the polygon - if (dc.second && dcr.second) - { - dc.second = false; - } - } - return dc; - } -}; - - -// Helper metafunction for default strategy retrieval -template -struct default_strategy - : strategy::distance::services::default_strategy - < - point_tag, - typename point_type::type, - typename point_type::type - > -{}; - - -}} // namespace detail::distance -#endif // DOXYGEN_NO_DETAIL - #ifndef DOXYGEN_NO_DISPATCH namespace dispatch { -using strategy::distance::services::return_type; - - -template -< - typename Geometry1, typename Geometry2, - typename Strategy = typename detail::distance::default_strategy::type, - typename Tag1 = typename tag_cast::type, multi_tag>::type, - typename Tag2 = typename tag_cast::type, multi_tag>::type, - typename StrategyTag = typename strategy::distance::services::tag::type, - bool Reverse = reverse_dispatch::type::value -> -struct distance: not_implemented -{}; - - // If reversal is needed, perform it template < @@ -316,184 +99,6 @@ struct distance }; -// Point-point -template -struct distance - < - P1, P2, Strategy, - point_tag, point_tag, strategy_tag_distance_point_point, - false - > - : detail::distance::point_to_point -{}; - - -// Point-line version 1, where point-point strategy is specified -template -struct distance -< - Point, Linestring, Strategy, - point_tag, linestring_tag, strategy_tag_distance_point_point, - false -> -{ - - static inline typename return_type::type>::type - apply(Point const& point, - Linestring const& linestring, - Strategy const& strategy) - { - typedef typename strategy::distance::services::default_strategy - < - segment_tag, - Point, - typename point_type::type, - typename cs_tag::type, - typename cs_tag::type>::type, - Strategy - >::type ps_strategy_type; - - return detail::distance::point_to_range - < - Point, Linestring, closed, Strategy, ps_strategy_type - >::apply(point, linestring, strategy, ps_strategy_type()); - } -}; - - -// Point-line version 2, where point-segment strategy is specified -template -struct distance -< - Point, Linestring, Strategy, - point_tag, linestring_tag, strategy_tag_distance_point_segment, - false -> -{ - static inline typename return_type::type>::type - apply(Point const& point, - Linestring const& linestring, - Strategy const& strategy) - { - typedef typename strategy::distance::services::strategy_point_point::type pp_strategy_type; - return detail::distance::point_to_range - < - Point, Linestring, closed, pp_strategy_type, Strategy - >::apply(point, linestring, pp_strategy_type(), strategy); - } -}; - -// Point-ring , where point-segment strategy is specified -template -struct distance -< - Point, Ring, Strategy, - point_tag, ring_tag, strategy_tag_distance_point_point, - false -> -{ - typedef typename return_type::type>::type return_type; - - static inline return_type apply(Point const& point, - Ring const& ring, - Strategy const& strategy) - { - typedef typename strategy::distance::services::default_strategy - < - segment_tag, - Point, - typename point_type::type, - typename cs_tag::type, - typename cs_tag::type>::type, - Strategy - >::type ps_strategy_type; - - std::pair - dc = detail::distance::point_to_ring - < - Point, Ring, - geometry::closure::value, - Strategy, ps_strategy_type - >::apply(point, ring, strategy, ps_strategy_type()); - - return dc.second ? return_type(0) : dc.first; - } -}; - - -// Point-polygon , where point-segment strategy is specified -template -struct distance -< - Point, Polygon, Strategy, - point_tag, polygon_tag, strategy_tag_distance_point_point, - false -> -{ - typedef typename return_type::type>::type return_type; - - static inline return_type apply(Point const& point, - Polygon const& polygon, - Strategy const& strategy) - { - typedef typename strategy::distance::services::default_strategy - < - segment_tag, - Point, - typename point_type::type, - typename cs_tag::type, - typename cs_tag::type>::type, - Strategy - >::type ps_strategy_type; - - std::pair - dc = detail::distance::point_to_polygon - < - Point, Polygon, - geometry::closure::value, - Strategy, ps_strategy_type - >::apply(point, polygon, strategy, ps_strategy_type()); - - return dc.second ? return_type(0) : dc.first; - } -}; - - - -// Point-segment version 1, with point-point strategy -template -struct distance -< - Point, Segment, Strategy, - point_tag, segment_tag, strategy_tag_distance_point_point, - false -> : detail::distance::point_to_segment -{}; - -// Point-segment version 2, with point-segment strategy -template -struct distance -< - Point, Segment, Strategy, - point_tag, segment_tag, strategy_tag_distance_point_segment, - false -> -{ - static inline typename return_type::type>::type - apply(Point const& point, - Segment const& segment, - Strategy const& strategy) - { - - typename point_type::type p[2]; - geometry::detail::assign_point_from_index<0>(segment, p[0]); - geometry::detail::assign_point_from_index<1>(segment, p[1]); - return strategy.apply(point, p[0], p[1]); - } -}; - - - } // namespace dispatch #endif // DOXYGEN_NO_DISPATCH @@ -578,10 +183,41 @@ inline typename default_distance_result::type distance( concept::check(); concept::check(); - return distance(geometry1, geometry2, - typename detail::distance::default_strategy::type()); + typedef typename boost::mpl::if_c + < + geometry::reverse_dispatch::type::value, + typename detail::distance::default_strategy + < + Geometry2, Geometry1 + >::type, + typename detail::distance::default_strategy + < + Geometry1, Geometry2 + >::type + >::type default_strategy_type; + + + return distance(geometry1, geometry2, default_strategy_type()); } }} // namespace boost::geometry + +// the implementation details +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#ifdef BOOST_GEOMETRY_SUPPORT_SEGMENT_SEGMENT_DISTANCE +#include +#endif // BOOST_GEOMETRY_SUPPORT_SEGMENT_SEGMENT_DISTANCE + +#include + #endif // BOOST_GEOMETRY_ALGORITHMS_DISTANCE_HPP From 3c64533d7db906896901f2fdfcb408437aca4d7d Mon Sep 17 00:00:00 2001 From: Menelaos Karavelas Date: Thu, 8 May 2014 15:11:54 +0300 Subject: [PATCH 23/66] [distance] add primary dispatch definition under algorithms/dispatch --- .../geometry/algorithms/dispatch/distance.hpp | 65 +++++++++++++++++++ 1 file changed, 65 insertions(+) create mode 100644 include/boost/geometry/algorithms/dispatch/distance.hpp diff --git a/include/boost/geometry/algorithms/dispatch/distance.hpp b/include/boost/geometry/algorithms/dispatch/distance.hpp new file mode 100644 index 000000000..58fd59340 --- /dev/null +++ b/include/boost/geometry/algorithms/dispatch/distance.hpp @@ -0,0 +1,65 @@ +// Boost.Geometry (aka GGL, Generic Geometry Library) + +// Copyright (c) 2007-2014 Barend Gehrels, Amsterdam, the Netherlands. +// Copyright (c) 2008-2014 Bruno Lalande, Paris, France. +// Copyright (c) 2009-2014 Mateusz Loskot, London, UK. +// Copyright (c) 2013-2014 Adam Wulkiewicz, Lodz, Poland. + +// This file was modified by Oracle on 2014. +// Modifications copyright (c) 2014, Oracle and/or its affiliates. + +// Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle + +// 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) + +#ifndef BOOST_GEOMETRY_ALGORITHMS_DISPATCH_DISTANCE_HPP +#define BOOST_GEOMETRY_ALGORITHMS_DISPATCH_DISTANCE_HPP + + +#include +#include +#include +#include + + +namespace boost { namespace geometry +{ + + +#ifndef DOXYGEN_NO_DISPATCH +namespace dispatch +{ + + +using strategy::distance::services::return_type; + + +template +< + typename Geometry1, typename Geometry2, + typename Strategy = typename detail::distance::default_strategy::type, + typename Tag1 = typename tag_cast::type, multi_tag>::type, + typename Tag2 = typename tag_cast::type, multi_tag>::type, + typename StrategyTag = typename strategy::distance::services::tag::type, + bool Reverse = reverse_dispatch::type::value +> +struct distance: not_implemented +{}; + + + + + +} // namespace dispatch +#endif // DOXYGEN_NO_DISPATCH + + +}} // namespace boost::geometry + + +#endif // BOOST_GEOMETRY_ALGORITHMS_DISPATCH_DISTANCE_HPP From b1eaf94bfe0d6c519efad75c727541650a315a32 Mon Sep 17 00:00:00 2001 From: Menelaos Karavelas Date: Thu, 8 May 2014 15:12:59 +0300 Subject: [PATCH 24/66] [strategies][distance] add a template parameter to default distance strategy corresponding to the second geometry of the distance strategy --- include/boost/geometry/strategies/distance.hpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/include/boost/geometry/strategies/distance.hpp b/include/boost/geometry/strategies/distance.hpp index 4179f8250..d4df78aca 100644 --- a/include/boost/geometry/strategies/distance.hpp +++ b/include/boost/geometry/strategies/distance.hpp @@ -85,7 +85,8 @@ template typename Point2 = Point1, typename CsTag1 = typename cs_tag::type, typename CsTag2 = typename cs_tag::type, - typename UnderlyingStrategy = void + typename UnderlyingStrategy = void, + typename GeometryTag2 = GeometryTag > struct default_strategy { From 752de3060a98b8b389f9a08e538bde68d9a1744a Mon Sep 17 00:00:00 2001 From: Menelaos Karavelas Date: Thu, 8 May 2014 15:15:16 +0300 Subject: [PATCH 25/66] [iterators] add free function has_one_element, that tests whether an iterator range has a unique element (has size 1) --- .../geometry/iterators/has_one_element.hpp | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 include/boost/geometry/iterators/has_one_element.hpp diff --git a/include/boost/geometry/iterators/has_one_element.hpp b/include/boost/geometry/iterators/has_one_element.hpp new file mode 100644 index 000000000..2f9acefc1 --- /dev/null +++ b/include/boost/geometry/iterators/has_one_element.hpp @@ -0,0 +1,29 @@ +// Boost.Geometry (aka GGL, Generic Geometry Library) + +// Copyright (c) 2014, Oracle and/or its affiliates. + +// Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle + +// Licensed under the Boost Software License version 1.0. +// http://www.boost.org/users/license.html + +#ifndef BOOST_GEOMETRY_ITERATORS_HAS_ONE_ELEMENT_HPP +#define BOOST_GEOMETRY_ITERATORS_HAS_ONE_ELEMENT_HPP + + +namespace boost { namespace geometry +{ + + +// free function to test if an iterator range has a single element +template +inline bool has_one_element(Iterator first, Iterator beyond) +{ + return first != beyond && ++first == beyond; +} + + +}} // namespace boost::geometry + + +#endif // BOOST_GEOMETRY_ITERATORS_HAS_ONE_ELEMENT_HPP From d289118bd97c732882514ac474273c7c40ff06c2 Mon Sep 17 00:00:00 2001 From: Menelaos Karavelas Date: Thu, 8 May 2014 15:26:57 +0300 Subject: [PATCH 26/66] [strategies] add the point-box and box-box pythagoras strategies in strategies/strategies.hpp --- include/boost/geometry/strategies/strategies.hpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/include/boost/geometry/strategies/strategies.hpp b/include/boost/geometry/strategies/strategies.hpp index 491c1d858..972078d20 100644 --- a/include/boost/geometry/strategies/strategies.hpp +++ b/include/boost/geometry/strategies/strategies.hpp @@ -37,11 +37,14 @@ #include #include #include +#include +#include #include #include #include #include #include +#include #include #include From 9ea4b6bf6cbfe8cac3c3f706e777999c5913c728 Mon Sep 17 00:00:00 2001 From: Adam Wulkiewicz Date: Thu, 8 May 2014 14:42:45 +0200 Subject: [PATCH 27/66] [index] Add the support for std::pair<> and boost/std::tuple<> registered as Indexable --- include/boost/geometry/index/equal_to.hpp | 72 +++++++++++++++------- include/boost/geometry/index/indexable.hpp | 69 ++++++++++++++------- 2 files changed, 97 insertions(+), 44 deletions(-) diff --git a/include/boost/geometry/index/equal_to.hpp b/include/boost/geometry/index/equal_to.hpp index 8ce5074c3..37e10cb6f 100644 --- a/include/boost/geometry/index/equal_to.hpp +++ b/include/boost/geometry/index/equal_to.hpp @@ -1,6 +1,6 @@ // Boost.Geometry Index // -// Copyright (c) 2011-2013 Adam Wulkiewicz, Lodz, Poland. +// Copyright (c) 2011-2014 Adam Wulkiewicz, Lodz, Poland. // // Use, modification and distribution is subject to the Boost Software License, // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at @@ -10,15 +10,14 @@ #define BOOST_GEOMETRY_INDEX_EQUAL_TO_HPP #include +#include -namespace boost { namespace geometry { namespace index { - -namespace detail { +namespace boost { namespace geometry { namespace index { namespace detail { template struct equals { - static bool apply(Geometry const& g1, Geometry const& g2) + inline static bool apply(Geometry const& g1, Geometry const& g2) { return geometry::equals(g1, g2); } @@ -27,7 +26,7 @@ struct equals template struct equals { - static bool apply(T const& v1, T const& v2) + inline static bool apply(T const& v1, T const& v2) { return v1 == v2; } @@ -57,8 +56,6 @@ struct tuple_equals } }; -} // namespace detail - /*! \brief The function object comparing Values. @@ -67,8 +64,9 @@ The default version handles Values which are Indexables. This template is also specialized for std::pair and boost::tuple<...>. \tparam Value The type of objects which are compared by this function object. +\tparam IsIndexable If true, Values are compared using boost::geometry::equals() functions. */ -template +template ::value> struct equal_to { /*! \brief The type of result returned by function object. */ @@ -81,7 +79,7 @@ struct equal_to \param r Second value. \return true if values are equal. */ - bool operator()(Value const& l, Value const& r) const + inline bool operator()(Value const& l, Value const& r) const { return detail::equals::type>::apply(l ,r); } @@ -97,7 +95,7 @@ It compares pairs' first values, then second values. \tparam T2 The second type. */ template -struct equal_to< std::pair > +struct equal_to, false> { /*! \brief The type of result returned by function object. */ typedef bool result_type; @@ -109,7 +107,7 @@ struct equal_to< std::pair > \param r Second value. \return true if values are equal. */ - bool operator()(std::pair const& l, std::pair const& r) const + inline bool operator()(std::pair const& l, std::pair const& r) const { typedef detail::equals::type> equals1; typedef detail::equals::type> equals2; @@ -126,7 +124,7 @@ It compares all members of the tuple from the first one to the last one. */ template -struct equal_to< boost::tuple > +struct equal_to, false> { typedef boost::tuple value_type; @@ -140,7 +138,7 @@ struct equal_to< boost::tuple > \param r Second value. \return true if values are equal. */ - bool operator()(value_type const& l, value_type const& r) const + inline bool operator()(value_type const& l, value_type const& r) const { return detail::tuple_equals< value_type, 0, boost::tuples::length::value @@ -148,15 +146,13 @@ struct equal_to< boost::tuple > } }; -}}} // namespace boost::geometry::index +}}}} // namespace boost::geometry::index::detail #if !defined(BOOST_NO_CXX11_HDR_TUPLE) && !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) #include -namespace boost { namespace geometry { namespace index { - -namespace detail { +namespace boost { namespace geometry { namespace index { namespace detail { template struct std_tuple_equals @@ -182,8 +178,6 @@ struct std_tuple_equals } }; -} // namespace detail - /*! \brief The function object comparing Values. @@ -192,7 +186,7 @@ It's defined if the compiler supports tuples and variadic templates. It compares all members of the tuple from the first one to the last one. */ template -struct equal_to< std::tuple > +struct equal_to, false> { typedef std::tuple value_type; @@ -214,8 +208,42 @@ struct equal_to< std::tuple > } }; -}}} // namespace boost::geometry::index +}}}} // namespace boost::geometry::index::detail #endif // !defined(BOOST_NO_CXX11_HDR_TUPLE) && !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) +namespace boost { namespace geometry { namespace index { + +/*! +\brief The function object comparing Values. + +The default version handles Values which are Indexables, std::pair, boost::tuple<...> +and std::tuple<...> if STD tuples and variadic templates are supported. +All members are compared from left to right, Geometries using boost::geometry::equals() function, +other types using operator==. + +\tparam Value The type of objects which are compared by this function object. +*/ +template +struct equal_to + : detail::equal_to +{ + /*! \brief The type of result returned by function object. */ + typedef typename detail::equal_to::result_type result_type; + + /*! + \brief Compare Values. + + \param l First value. + \param r Second value. + \return true if Values are equal. + */ + inline bool operator()(Value const& l, Value const& r) const + { + return detail::equal_to::operator()(l ,r); + } +}; + +}}} // namespace boost::geometry::index + #endif // BOOST_GEOMETRY_INDEX_EQUAL_TO_HPP diff --git a/include/boost/geometry/index/indexable.hpp b/include/boost/geometry/index/indexable.hpp index 9533fcf9e..7476602f8 100644 --- a/include/boost/geometry/index/indexable.hpp +++ b/include/boost/geometry/index/indexable.hpp @@ -1,6 +1,6 @@ // Boost.Geometry Index // -// Copyright (c) 2011-2013 Adam Wulkiewicz, Lodz, Poland. +// Copyright (c) 2011-2014 Adam Wulkiewicz, Lodz, Poland. // // Use, modification and distribution is subject to the Boost Software License, // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at @@ -11,9 +11,7 @@ #include -namespace boost { namespace geometry { namespace index { - -namespace detail { +namespace boost { namespace geometry { namespace index { namespace detail { template struct is_indexable_impl { static const bool value = false; }; @@ -31,24 +29,19 @@ struct is_indexable is_indexable_impl::type>::value; }; -} // namespace detail - /*! \brief The function object extracting Indexable from Value. It translates Value object to Indexable object. The default version handles Values which are Indexables. -This template is also specialized for std::pair and boost::tuple. +This template is also specialized for std::pair, boost::tuple +and std::tuple. \tparam Value The Value type which may be translated directly to the Indexable. +\tparam IsIndexable If true, the const reference to Value is returned. */ -template +template ::value> struct indexable { - BOOST_MPL_ASSERT_MSG( - (detail::is_indexable::value), - NOT_VALID_INDEXABLE_TYPE, - (Value) - ); /*! \brief The type of result returned by function object. */ typedef Value const& result_type; @@ -58,7 +51,7 @@ struct indexable \param v The value. \return The indexable. */ - result_type operator()(Value const& v) const + inline result_type operator()(Value const& v) const { return v; } @@ -73,7 +66,7 @@ This specialization translates from std::pair. \tparam T2 The second type. */ template -struct indexable< std::pair > +struct indexable, false> { BOOST_MPL_ASSERT_MSG( (detail::is_indexable::value), @@ -90,7 +83,7 @@ struct indexable< std::pair > \param v The value. \return The indexable. */ - result_type operator()(std::pair const& v) const + inline result_type operator()(std::pair const& v) const { return v.first; } @@ -105,7 +98,7 @@ This specialization translates from boost::tuple. */ template -struct indexable< boost::tuple > +struct indexable, false> { typedef boost::tuple value_type; @@ -124,19 +117,19 @@ struct indexable< boost::tuple > \param v The value. \return The indexable. */ - result_type operator()(value_type const& v) const + inline result_type operator()(value_type const& v) const { return boost::get<0>(v); } }; -}}} // namespace boost::geometry::index +}}}} // namespace boost::geometry::index::detail #if !defined(BOOST_NO_CXX11_HDR_TUPLE) && !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) #include -namespace boost { namespace geometry { namespace index { +namespace boost { namespace geometry { namespace index { namespace detail { /*! \brief The function object extracting Indexable from Value. @@ -147,7 +140,7 @@ It's defined if the compiler supports tuples and variadic templates. \tparam Indexable The Indexable type. */ template -struct indexable< std::tuple > +struct indexable, false> { typedef std::tuple value_type; @@ -172,8 +165,40 @@ struct indexable< std::tuple > } }; -}}} // namespace boost::geometry::index +}}}} // namespace boost::geometry::index::detail #endif // !defined(BOOST_NO_CXX11_HDR_TUPLE) && !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) +namespace boost { namespace geometry { namespace index { + +/*! +\brief The function object extracting Indexable from Value. + +It translates Value object to Indexable object. By default, it can handle Values which are Indexables, +std::pair, boost::tuple and std::tuple if STD tuples +and variadic templates are supported. + +\tparam Value The Value type which may be translated directly to the Indexable. +*/ +template +struct indexable + : detail::indexable +{ + /*! \brief The type of result returned by function object. It should be const Indexable reference. */ + typedef typename detail::indexable::result_type result_type; + + /*! + \brief Return indexable extracted from the value. + + \param v The value. + \return The indexable. + */ + inline result_type operator()(Value const& v) const + { + return detail::indexable::operator()(v); + } +}; + +}}} // namespace boost::geometry::index + #endif // BOOST_GEOMETRY_INDEX_INDEXABLE_HPP From 203aa991aef5e756291eba96298b601b435208f7 Mon Sep 17 00:00:00 2001 From: Menelaos Karavelas Date: Thu, 8 May 2014 15:46:25 +0300 Subject: [PATCH 28/66] [index] replace #include by the necessary includes --- include/boost/geometry/index/rtree.hpp | 39 +++++++++++++++++++++++++- 1 file changed, 38 insertions(+), 1 deletion(-) diff --git a/include/boost/geometry/index/rtree.hpp b/include/boost/geometry/index/rtree.hpp index 6decfe70f..40d6918ca 100644 --- a/include/boost/geometry/index/rtree.hpp +++ b/include/boost/geometry/index/rtree.hpp @@ -17,7 +17,44 @@ #include #include -#include +//#include +// START +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +//#include +//#include +//#include +//#include +//#include +// END #include From 8a7a14bc5330f0dcf9823b4b1ea6fbe53a27ead9 Mon Sep 17 00:00:00 2001 From: Menelaos Karavelas Date: Thu, 8 May 2014 15:52:53 +0300 Subject: [PATCH 29/66] [index] replace call to comparable_distance_near by bg::comparable_distance --- include/boost/geometry/index/detail/distance_predicates.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/boost/geometry/index/detail/distance_predicates.hpp b/include/boost/geometry/index/detail/distance_predicates.hpp index c5c2c4c51..a8980cc41 100644 --- a/include/boost/geometry/index/detail/distance_predicates.hpp +++ b/include/boost/geometry/index/detail/distance_predicates.hpp @@ -112,7 +112,7 @@ struct calculate_distance< nearest, Indexable, Tag > static inline bool apply(nearest const& p, Indexable const& i, result_type & result) { - result = index::detail::comparable_distance_near(relation::value(p.point_or_relation), i); + result = geometry::comparable_distance(relation::value(p.point_or_relation), i); return true; } }; From 23f8b97fac13134e78fee3fe82de0f3db100b7fc Mon Sep 17 00:00:00 2001 From: Menelaos Karavelas Date: Thu, 8 May 2014 15:59:15 +0300 Subject: [PATCH 30/66] [index] include comparable_distance algorithm --- include/boost/geometry/index/rtree.hpp | 1 + 1 file changed, 1 insertion(+) diff --git a/include/boost/geometry/index/rtree.hpp b/include/boost/geometry/index/rtree.hpp index 40d6918ca..9e61a3979 100644 --- a/include/boost/geometry/index/rtree.hpp +++ b/include/boost/geometry/index/rtree.hpp @@ -21,6 +21,7 @@ // START #include +#include #include #include #include From 1a2ef5c2bcc21f96ded548b52c5fe1133bdab1cb Mon Sep 17 00:00:00 2001 From: Menelaos Karavelas Date: Thu, 8 May 2014 16:39:09 +0300 Subject: [PATCH 31/66] [disjoint] add specializations for linestring/multilinestring, multilinestring/multilinestring; fixed specialization for polygon/multilinestring --- .../boost/geometry/algorithms/disjoint.hpp | 28 +++++++++++++++---- 1 file changed, 23 insertions(+), 5 deletions(-) diff --git a/include/boost/geometry/algorithms/disjoint.hpp b/include/boost/geometry/algorithms/disjoint.hpp index ac9de681d..7ee61c602 100644 --- a/include/boost/geometry/algorithms/disjoint.hpp +++ b/include/boost/geometry/algorithms/disjoint.hpp @@ -37,6 +37,7 @@ #include #include #include +#include #include #include @@ -433,13 +434,25 @@ struct disjoint {}; -// move the following specializations to multi/algorithms/disjoint.hpp? - -template -struct disjoint - : public detail::disjoint::disjoint_linear_areal +template +struct disjoint + : public detail::disjoint::disjoint_linear {}; +template +struct disjoint +{ + static inline bool apply(Polygon const& polygon, + MultiLinestring const& multilinestring) + { + return detail::disjoint::disjoint_linear_areal + < + MultiLinestring, + Polygon + >::apply(multilinestring, polygon); + } +}; + template struct disjoint : public detail::disjoint::disjoint_linear_areal @@ -455,6 +468,11 @@ struct disjoint {}; +template +struct disjoint + : public detail::disjoint::disjoint_linear +{}; + template struct disjoint : public detail::disjoint::disjoint_point_linear From 3d25114c8e3f7b0744d1ccb5250287ed43dd840b Mon Sep 17 00:00:00 2001 From: Menelaos Karavelas Date: Thu, 8 May 2014 22:33:56 +0300 Subject: [PATCH 32/66] [distance] remove inclusion of default_distance_result (not used) --- .../geometry/algorithms/detail/distance/point_to_geometry.hpp | 1 - .../algorithms/detail/distance/polygon_to_segment_or_box.hpp | 1 - 2 files changed, 2 deletions(-) diff --git a/include/boost/geometry/algorithms/detail/distance/point_to_geometry.hpp b/include/boost/geometry/algorithms/detail/distance/point_to_geometry.hpp index 21b4703ea..bac63e830 100644 --- a/include/boost/geometry/algorithms/detail/distance/point_to_geometry.hpp +++ b/include/boost/geometry/algorithms/detail/distance/point_to_geometry.hpp @@ -35,7 +35,6 @@ #include #include -#include #include #include diff --git a/include/boost/geometry/algorithms/detail/distance/polygon_to_segment_or_box.hpp b/include/boost/geometry/algorithms/detail/distance/polygon_to_segment_or_box.hpp index 14bc3af14..351e7278e 100644 --- a/include/boost/geometry/algorithms/detail/distance/polygon_to_segment_or_box.hpp +++ b/include/boost/geometry/algorithms/detail/distance/polygon_to_segment_or_box.hpp @@ -17,7 +17,6 @@ #include #include -#include #include #include #include From f4a687d79aee62ebe7e1df79e968c231432d5864 Mon Sep 17 00:00:00 2001 From: Barend Gehrels Date: Thu, 8 May 2014 22:06:21 +0200 Subject: [PATCH 33/66] [doc] Fixed double inclusion of Menelaos --- doc/geometry.qbk | 1 - 1 file changed, 1 deletion(-) diff --git a/doc/geometry.qbk b/doc/geometry.qbk index cfe3b6deb..7ff1d6512 100644 --- a/doc/geometry.qbk +++ b/doc/geometry.qbk @@ -113,7 +113,6 @@ Boost.Geometry contains contributions by: * Federico Fern\u00E1ndez (preliminary version of R-tree spatial index) * Karsten Ahnert (patch for cross-track distance) * Mats Taraldsvik (documentation: adapting a legacy model) -* Menelaos Karavelas (on behalf of Oracle: distance, set operations, etc.) [include imports.qbk] From e729f37bbee0fc7b3036f8a8129faee05a9fb16c Mon Sep 17 00:00:00 2001 From: Menelaos Karavelas Date: Thu, 8 May 2014 23:47:22 +0300 Subject: [PATCH 34/66] [distance] perform reverse-dispatch for default strategy --- .../detail/distance/default_strategies.hpp | 26 ++++++-- .../default_comparable_distance_result.hpp | 59 +++++++++++++++++++ 2 files changed, 80 insertions(+), 5 deletions(-) create mode 100644 include/boost/geometry/strategies/default_comparable_distance_result.hpp diff --git a/include/boost/geometry/algorithms/detail/distance/default_strategies.hpp b/include/boost/geometry/algorithms/detail/distance/default_strategies.hpp index 70e8521ea..131265c0e 100644 --- a/include/boost/geometry/algorithms/detail/distance/default_strategies.hpp +++ b/include/boost/geometry/algorithms/detail/distance/default_strategies.hpp @@ -25,6 +25,7 @@ #include #include #include +#include #include @@ -52,7 +53,8 @@ template typename Tag2 = typename tag_cast < typename tag::type, pointlike_tag - >::type + >::type, + bool Reverse = geometry::reverse_dispatch::type::value > struct default_strategy : strategy::distance::services::default_strategy @@ -63,10 +65,24 @@ struct default_strategy > {}; +template +< + typename Geometry1, + typename Geometry2, + typename Tag1, + typename Tag2 +> +struct default_strategy + : default_strategy +{}; + template -struct default_strategy - : strategy::distance::services::default_strategy +struct default_strategy + < + Pointlike1, Pointlike2, + pointlike_tag, pointlike_tag, false + > : strategy::distance::services::default_strategy < point_tag, typename point_type::type, @@ -76,7 +92,7 @@ struct default_strategy template -struct default_strategy +struct default_strategy : strategy::distance::services::default_strategy < point_tag, @@ -91,7 +107,7 @@ struct default_strategy template -struct default_strategy +struct default_strategy : strategy::distance::services::default_strategy < box_tag, diff --git a/include/boost/geometry/strategies/default_comparable_distance_result.hpp b/include/boost/geometry/strategies/default_comparable_distance_result.hpp new file mode 100644 index 000000000..bbaf3656b --- /dev/null +++ b/include/boost/geometry/strategies/default_comparable_distance_result.hpp @@ -0,0 +1,59 @@ +// Boost.Geometry (aka GGL, Generic Geometry Library) + +// Copyright (c) 2007-2014 Barend Gehrels, Amsterdam, the Netherlands. +// Copyright (c) 2008-2014 Bruno Lalande, Paris, France. +// Copyright (c) 2009-2014 Mateusz Loskot, London, UK. + +// This file was modified by Oracle on 2014. +// Modifications copyright (c) 2014, Oracle and/or its affiliates. + +// Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle + +// 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) + +#ifndef BOOST_GEOMETRY_STRATEGIES_DEFAULT_COMPARABLE_DISTANCE_RESULT_HPP +#define BOOST_GEOMETRY_STRATEGIES_DEFAULT_COMPARABLE_DISTANCE_RESULT_HPP + +#include +#include +#include + + +#include + +namespace boost { namespace geometry +{ + +/*! +\brief Meta-function defining return type of comparable_distance function +\ingroup distance +\note The strategy defines the return-type (so this situation is different + from length, where distance is sqr/sqrt, but length always squared) + */ +template +struct default_comparable_distance_result +{ + typedef typename strategy::distance::services::return_type + < + typename strategy::distance::services::comparable_type + < + typename detail::distance::default_strategy + < + Geometry1, Geometry2 + >::type + >::type, + typename point_type::type, + typename point_type::type + >::type type; +}; + + +}} // namespace boost::geometry + + +#endif // BOOST_GEOMETRY_STRATEGIES_DEFAULT_COMPARABLE_DISTANCE_RESULT_HPP From cd775883263c56e8302c20d1ae4fc280aa535d85 Mon Sep 17 00:00:00 2001 From: Menelaos Karavelas Date: Thu, 8 May 2014 23:48:38 +0300 Subject: [PATCH 35/66] [strategies] implement default_comparable_distance_result class --- .../geometry/strategies/default_comparable_distance_result.hpp | 1 - 1 file changed, 1 deletion(-) diff --git a/include/boost/geometry/strategies/default_comparable_distance_result.hpp b/include/boost/geometry/strategies/default_comparable_distance_result.hpp index bbaf3656b..601bdbd6a 100644 --- a/include/boost/geometry/strategies/default_comparable_distance_result.hpp +++ b/include/boost/geometry/strategies/default_comparable_distance_result.hpp @@ -23,7 +23,6 @@ #include #include - #include namespace boost { namespace geometry From 4598228ea0dee4e7cfc1a66883e4ae52612a621e Mon Sep 17 00:00:00 2001 From: Menelaos Karavelas Date: Thu, 8 May 2014 23:50:28 +0300 Subject: [PATCH 36/66] [distance] re-implement the default strategy type in free function distance(g1, g2); remove inclusion of unused headers; --- include/boost/geometry/algorithms/distance.hpp | 16 ++-------------- 1 file changed, 2 insertions(+), 14 deletions(-) diff --git a/include/boost/geometry/algorithms/distance.hpp b/include/boost/geometry/algorithms/distance.hpp index 8f5ececdf..929a9370d 100644 --- a/include/boost/geometry/algorithms/distance.hpp +++ b/include/boost/geometry/algorithms/distance.hpp @@ -21,16 +21,13 @@ #define BOOST_GEOMETRY_ALGORITHMS_DISTANCE_HPP #include -#include #include -#include #include #include #include #include -#include #include #include @@ -183,19 +180,10 @@ inline typename default_distance_result::type distance( concept::check(); concept::check(); - typedef typename boost::mpl::if_c + typedef typename detail::distance::default_strategy < - geometry::reverse_dispatch::type::value, - typename detail::distance::default_strategy - < - Geometry2, Geometry1 - >::type, - typename detail::distance::default_strategy - < - Geometry1, Geometry2 - >::type + Geometry1, Geometry2 >::type default_strategy_type; - return distance(geometry1, geometry2, default_strategy_type()); } From 73858fc359731302b115414e8e5050c4cdb0ebf9 Mon Sep 17 00:00:00 2001 From: Menelaos Karavelas Date: Thu, 8 May 2014 23:56:55 +0300 Subject: [PATCH 37/66] [comparable distance] simplify the definition of the default comparable strategy using the class detail::distance::default_strategy --- .../algorithms/comparable_distance.hpp | 21 ++++--------------- 1 file changed, 4 insertions(+), 17 deletions(-) diff --git a/include/boost/geometry/algorithms/comparable_distance.hpp b/include/boost/geometry/algorithms/comparable_distance.hpp index 9bce0390b..fb0a12509 100644 --- a/include/boost/geometry/algorithms/comparable_distance.hpp +++ b/include/boost/geometry/algorithms/comparable_distance.hpp @@ -20,10 +20,6 @@ #define BOOST_GEOMETRY_ALGORITHMS_COMPARABLE_DISTANCE_HPP -#include - -#include - #include #include @@ -76,8 +72,8 @@ comparable_distance(Geometry1 const& geometry1, Geometry2 const& geometry2, \qbk{[include reference/algorithms/comparable_distance.qbk]} */ template -inline typename default_distance_result::type comparable_distance( - Geometry1 const& geometry1, Geometry2 const& geometry2) +inline typename default_distance_result::type +comparable_distance(Geometry1 const& geometry1, Geometry2 const& geometry2) { concept::check(); concept::check(); @@ -87,18 +83,9 @@ inline typename default_distance_result::type comparable_d typedef typename strategy::distance::services::comparable_type < - typename boost::mpl::if_c + typename detail::distance::default_strategy < - geometry::reverse_dispatch - ::type::value, - typename detail::distance::default_strategy - < - Geometry2, Geometry1 - >::type, - typename detail::distance::default_strategy - < - Geometry1, Geometry2 - >::type + Geometry1, Geometry2 >::type >::type default_comparable_strategy_type; From 47c1cfe9b66646ef6e502e9a37f9b73763fb6cee Mon Sep 17 00:00:00 2001 From: Menelaos Karavelas Date: Thu, 8 May 2014 23:59:11 +0300 Subject: [PATCH 38/66] [strategies][distance] re-implement the dfeault distance result using the default strategy from detail::distance::default_strategy --- .../strategies/default_distance_result.hpp | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/include/boost/geometry/strategies/default_distance_result.hpp b/include/boost/geometry/strategies/default_distance_result.hpp index 74ce495d3..92b629f6f 100644 --- a/include/boost/geometry/strategies/default_distance_result.hpp +++ b/include/boost/geometry/strategies/default_distance_result.hpp @@ -1,8 +1,13 @@ // 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. +// Copyright (c) 2007-2014 Barend Gehrels, Amsterdam, the Netherlands. +// Copyright (c) 2008-2014 Bruno Lalande, Paris, France. +// Copyright (c) 2009-2014 Mateusz Loskot, London, UK. + +// This file was modified by Oracle on 2014. +// Modifications copyright (c) 2014, Oracle and/or its affiliates. + +// Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle // Parts of Boost.Geometry are redesigned from Geodan's Geographic Library // (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands. @@ -19,6 +24,7 @@ #include #include +#include namespace boost { namespace geometry { @@ -34,11 +40,9 @@ struct default_distance_result { typedef typename strategy::distance::services::return_type < - typename strategy::distance::services::default_strategy + typename detail::distance::default_strategy < - point_tag, - typename point_type::type, - typename point_type::type + Geometry1, Geometry2 >::type, typename point_type::type, typename point_type::type From 226dcc4e6c962e3d723284ca4c0c0d73a3cfe0f8 Mon Sep 17 00:00:00 2001 From: Menelaos Karavelas Date: Fri, 9 May 2014 00:02:17 +0300 Subject: [PATCH 39/66] [comparable distance] fix comments so that they make sense wrt to the code they refer to --- include/boost/geometry/algorithms/comparable_distance.hpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/include/boost/geometry/algorithms/comparable_distance.hpp b/include/boost/geometry/algorithms/comparable_distance.hpp index fb0a12509..cc1ae9244 100644 --- a/include/boost/geometry/algorithms/comparable_distance.hpp +++ b/include/boost/geometry/algorithms/comparable_distance.hpp @@ -78,9 +78,7 @@ comparable_distance(Geometry1 const& geometry1, Geometry2 const& geometry2) concept::check(); concept::check(); - // Define a default-distance-strategy - // for either the normal case, either the reversed case - + // Define the default-distance-strategy typedef typename strategy::distance::services::comparable_type < typename detail::distance::default_strategy From a7d02e03914983eae18e120f2cbe9ef98b782197 Mon Sep 17 00:00:00 2001 From: Menelaos Karavelas Date: Fri, 9 May 2014 00:20:24 +0300 Subject: [PATCH 40/66] [distance][test] enable segment-segment distance computations --- include/boost/geometry/algorithms/distance.hpp | 3 --- test/algorithms/distance_linear_linear.cpp | 4 ---- 2 files changed, 7 deletions(-) diff --git a/include/boost/geometry/algorithms/distance.hpp b/include/boost/geometry/algorithms/distance.hpp index 929a9370d..36ff3a695 100644 --- a/include/boost/geometry/algorithms/distance.hpp +++ b/include/boost/geometry/algorithms/distance.hpp @@ -201,10 +201,7 @@ inline typename default_distance_result::type distance( #include #include #include - -#ifdef BOOST_GEOMETRY_SUPPORT_SEGMENT_SEGMENT_DISTANCE #include -#endif // BOOST_GEOMETRY_SUPPORT_SEGMENT_SEGMENT_DISTANCE #include diff --git a/test/algorithms/distance_linear_linear.cpp b/test/algorithms/distance_linear_linear.cpp index 17ac8874f..578a458c5 100644 --- a/test/algorithms/distance_linear_linear.cpp +++ b/test/algorithms/distance_linear_linear.cpp @@ -31,7 +31,6 @@ typedef bg::strategy::distance::projected_point<> point_segment_strategy; //=========================================================================== -#ifdef BOOST_GEOMETRY_SUPPORT_SEGMENT_SEGMENT_DISTANCE template void test_distance_segment_segment(Strategy const& strategy) { @@ -57,7 +56,6 @@ void test_distance_segment_segment(Strategy const& strategy) make_segment(-2, 3, 1, 2), return_type(2), return_type(4), strategy); } -#endif // BOOST_GEOMETRY_SUPPORT_SEGMENT_SEGMENT_DISTANCE //=========================================================================== @@ -230,12 +228,10 @@ void test_more_empty_input_linear_linear(Strategy const& strategy) //=========================================================================== -#ifdef BOOST_GEOMETRY_SUPPORT_SEGMENT_SEGMENT_DISTANCE BOOST_AUTO_TEST_CASE( test_all_segment_segment ) { test_distance_segment_segment(point_segment_strategy()); } -#endif // BOOST_GEOMETRY_SUPPORT_SEGMENT_SEGMENT_DISTANCE BOOST_AUTO_TEST_CASE( test_all_segment_linestring ) { From 5777fd5b8d49552cced5c99e0cda2af3ec6a13b4 Mon Sep 17 00:00:00 2001 From: Menelaos Karavelas Date: Fri, 9 May 2014 09:33:32 +0300 Subject: [PATCH 41/66] [overlay] the specialization of intersection_insert for linestring/box computes the intersection, but pretends as if it works for difference as well; quick fix: further specialize this specialization of intersection insert so that it works only for overlay_intersection; problem and quick fix related to boost trac ticket #10019; --- .../geometry/algorithms/detail/overlay/intersection_insert.hpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/include/boost/geometry/algorithms/detail/overlay/intersection_insert.hpp b/include/boost/geometry/algorithms/detail/overlay/intersection_insert.hpp index 173639e9a..a13a62745 100644 --- a/include/boost/geometry/algorithms/detail/overlay/intersection_insert.hpp +++ b/include/boost/geometry/algorithms/detail/overlay/intersection_insert.hpp @@ -393,14 +393,13 @@ template < typename Linestring, typename Box, typename GeometryOut, - overlay_type OverlayType, bool Reverse1, bool Reverse2, bool ReverseOut > struct intersection_insert < Linestring, Box, GeometryOut, - OverlayType, + overlay_intersection, Reverse1, Reverse2, ReverseOut, linestring_tag, box_tag, linestring_tag, false, true, false From 5c5d42341ccf689877f22b844e938b1f9e44ad71 Mon Sep 17 00:00:00 2001 From: Menelaos Karavelas Date: Fri, 9 May 2014 22:25:45 +0300 Subject: [PATCH 42/66] [test][distance] move unit test code from test/multi/algorithms/multi_distance.cpp to test/algorithms/distance.cpp; delete test/multi/algorithms/multi_distance.cpp; --- test/algorithms/distance.cpp | 143 ++++++++++++++++++- test/multi/algorithms/Jamfile.v2 | 7 +- test/multi/algorithms/multi_distance.cpp | 171 ----------------------- 3 files changed, 143 insertions(+), 178 deletions(-) delete mode 100644 test/multi/algorithms/multi_distance.cpp diff --git a/test/algorithms/distance.cpp b/test/algorithms/distance.cpp index 597df4f07..5a2c31aa0 100644 --- a/test/algorithms/distance.cpp +++ b/test/algorithms/distance.cpp @@ -1,9 +1,9 @@ // 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. +// Copyright (c) 2007-2014 Barend Gehrels, Amsterdam, the Netherlands. +// Copyright (c) 2008-2014 Bruno Lalande, Paris, France. +// Copyright (c) 2009-2014 Mateusz Loskot, London, UK. // Parts of Boost.Geometry are redesigned from Geodan's Geographic Library // (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands. @@ -13,6 +13,7 @@ // http://www.boost.org/LICENSE_1_0.txt) +#include #include #include @@ -29,6 +30,13 @@ #include #include +// includes for multi-geometries +#include +#include +#include +#include + + BOOST_GEOMETRY_REGISTER_C_ARRAY_CS(cs::cartesian) BOOST_GEOMETRY_REGISTER_BOOST_TUPLE_CS(cs::cartesian) @@ -196,6 +204,105 @@ void test_distance_array_as_linestring() } +// code moved from the distance unit test in multi/algorithms -- start +template +void test_distance(std::string const& wkt1, std::string const& wkt2, double expected) +{ + Geometry1 g1; + Geometry2 g2; + bg::read_wkt(wkt1, g1); + bg::read_wkt(wkt2, g2); + typename bg::default_distance_result::type d = bg::distance(g1, g2); + + BOOST_CHECK_CLOSE(d, expected, 0.0001); +} + +template +void test_distance(Strategy const& strategy, std::string const& wkt1, + std::string const& wkt2, double expected) +{ + Geometry1 g1; + Geometry2 g2; + bg::read_wkt(wkt1, g1); + bg::read_wkt(wkt2, g2); + typename bg::default_distance_result::type d = bg::distance(g1, g2, strategy); + + BOOST_CHECK_CLOSE(d, expected, 0.0001); +} + + +template +void test_2d() +{ + typedef bg::model::multi_point

mp; + typedef bg::model::multi_linestring > ml; + test_distance("POINT(0 0)", "POINT(1 1)", sqrt(2.0)); + test_distance("POINT(0 0)", "MULTIPOINT((1 1),(1 0),(0 2))", 1.0); + test_distance("MULTIPOINT((1 1),(1 0),(0 2))", "POINT(0 0)", 1.0); + test_distance("MULTIPOINT((1 1),(1 0),(0 2))", "MULTIPOINT((2 2),(2 3))", sqrt(2.0)); + test_distance("POINT(0 0)", "MULTILINESTRING((1 1,2 2),(1 0,2 0),(0 2,0 3))", 1.0); + test_distance("MULTILINESTRING((1 1,2 2),(1 0,2 0),(0 2,0 3))", "POINT(0 0)", 1.0); + test_distance("MULTILINESTRING((1 1,2 2),(1 0,2 0),(0 2,0 3))", "MULTIPOINT((0 0),(1 1))", 0.0); + + // Test with a strategy + bg::strategy::distance::pythagoras<> pyth; + test_distance(pyth, "POINT(0 0)", "POINT(1 1)", sqrt(2.0)); + test_distance(pyth, "POINT(0 0)", "MULTIPOINT((1 1),(1 0),(0 2))", 1.0); + test_distance(pyth, "MULTIPOINT((1 1),(1 0),(0 2))", "POINT(0 0)", 1.0); +} + + +template +void test_3d() +{ + typedef bg::model::multi_point

mp; + test_distance("POINT(0 0 0)", "POINT(1 1 1)", sqrt(3.0)); + test_distance("POINT(0 0 0)", "MULTIPOINT((1 1 1),(1 0 0),(0 1 2))", 1.0); + test_distance("MULTIPOINT((1 1 1),(1 0 0),(0 0 2))", "MULTIPOINT((2 2 2),(2 3 4))", sqrt(3.0)); +} + + +template +void test_mixed() +{ + typedef bg::model::multi_point mp1; + typedef bg::model::multi_point mp2; + + test_distance("POINT(0 0)", "POINT(1 1)", sqrt(2.0)); + + test_distance("POINT(0 0)", "MULTIPOINT((1 1),(1 0),(0 2))", 1.0); + test_distance("POINT(0 0)", "MULTIPOINT((1 1),(1 0),(0 2))", 1.0); + test_distance("POINT(0 0)", "MULTIPOINT((1 1),(1 0),(0 2))", 1.0); + test_distance("POINT(0 0)", "MULTIPOINT((1 1),(1 0),(0 2))", 1.0); + + // Test automatic reversal + test_distance("MULTIPOINT((1 1),(1 0),(0 2))", "POINT(0 0)", 1.0); + test_distance("MULTIPOINT((1 1),(1 0),(0 2))", "POINT(0 0)", 1.0); + test_distance("MULTIPOINT((1 1),(1 0),(0 2))", "POINT(0 0)", 1.0); + test_distance("MULTIPOINT((1 1),(1 0),(0 2))", "POINT(0 0)", 1.0); + + // Test multi-multi using different point types for each + test_distance("MULTIPOINT((1 1),(1 0),(0 2))", "MULTIPOINT((2 2),(2 3))", sqrt(2.0)); + + // Test with a strategy + using namespace bg::strategy::distance; + + test_distance(pythagoras<>(), "POINT(0 0)", "POINT(1 1)", sqrt(2.0)); + + test_distance(pythagoras<>(), "POINT(0 0)", "MULTIPOINT((1 1),(1 0),(0 2))", 1.0); + test_distance(pythagoras<>(), "POINT(0 0)", "MULTIPOINT((1 1),(1 0),(0 2))", 1.0); + test_distance(pythagoras<>(), "POINT(0 0)", "MULTIPOINT((1 1),(1 0),(0 2))", 1.0); + test_distance(pythagoras<>(), "POINT(0 0)", "MULTIPOINT((1 1),(1 0),(0 2))", 1.0); + + // Most interesting: reversal AND a strategy (note that the stategy must be reversed automatically + test_distance(pythagoras<>(), "MULTIPOINT((1 1),(1 0),(0 2))", "POINT(0 0)", 1.0); + test_distance(pythagoras<>(), "MULTIPOINT((1 1),(1 0),(0 2))", "POINT(0 0)", 1.0); + test_distance(pythagoras<>(), "MULTIPOINT((1 1),(1 0),(0 2))", "POINT(0 0)", 1.0); + test_distance(pythagoras<>(), "MULTIPOINT((1 1),(1 0),(0 2))", "POINT(0 0)", 1.0); +} +// code moved from the distance unit test in multi/algorithms -- end + + template @@ -264,10 +371,22 @@ void test_empty_input() bg::model::linestring

line_empty; bg::model::polygon

poly_empty; bg::model::ring

ring_empty; + bg::model::multi_point

mp_empty; + bg::model::multi_linestring > ml_empty; test_empty_input(p, line_empty); test_empty_input(p, poly_empty); test_empty_input(p, ring_empty); + + test_empty_input(p, mp_empty); + test_empty_input(p, ml_empty); + test_empty_input(mp_empty, mp_empty); + + // Test behaviour if one of the inputs is empty + bg::model::multi_point

mp; + mp.push_back(p); + test_empty_input(mp_empty, mp); + test_empty_input(mp, mp_empty); } void test_large_integers() @@ -335,5 +454,23 @@ int test_main(int, char* []) test_empty_input >(); + // below are the test cases moved here from the distance unit test + // in test/multi/algorithms + test_2d >(); + test_2d >(); + test_2d >(); + + test_3d >(); + test_3d >(); + + test_mixed, bg::model::d2::point_xy >(); + +#ifdef HAVE_TTMATH + test_2d >(); + test_mixed, bg::model::d2::point_xy >(); +#endif + + test_empty_input >(); + return 0; } diff --git a/test/multi/algorithms/Jamfile.v2 b/test/multi/algorithms/Jamfile.v2 index 5708300cb..ef1d6b2c8 100644 --- a/test/multi/algorithms/Jamfile.v2 +++ b/test/multi/algorithms/Jamfile.v2 @@ -1,8 +1,8 @@ # 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. +# Copyright (c) 2007-2014 Barend Gehrels, Amsterdam, the Netherlands. +# Copyright (c) 2008-2014 Bruno Lalande, Paris, France. +# Copyright (c) 2009-2014 Mateusz Loskot, London, UK. # # Use, modification and distribution is subject to the Boost Software License, # Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at @@ -19,7 +19,6 @@ test-suite boost-geometry-multi-algorithms [ run multi_difference.cpp : : : BOOST_GEOMETRY_TEST_ONLY_ONE_TYPE msvc:/bigobj ] [ run multi_difference_spike.cpp : : : BOOST_GEOMETRY_TEST_ONLY_ONE_TYPE msvc:/bigobj ] [ run multi_disjoint.cpp ] - [ run multi_distance.cpp ] [ run multi_envelope.cpp ] [ run multi_equals.cpp ] [ run multi_for_each.cpp ] diff --git a/test/multi/algorithms/multi_distance.cpp b/test/multi/algorithms/multi_distance.cpp deleted file mode 100644 index 0c932474a..000000000 --- a/test/multi/algorithms/multi_distance.cpp +++ /dev/null @@ -1,171 +0,0 @@ -// Boost.Geometry (aka GGL, Generic Geometry Library) -// -// Copyright (c) 2007-2012 Barend Gehrels, 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) - -#include - - -#include - -#include - -#include -#include - -#include - - -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include - -BOOST_GEOMETRY_REGISTER_C_ARRAY_CS(cs::cartesian) -BOOST_GEOMETRY_REGISTER_BOOST_TUPLE_CS(cs::cartesian) - - -template -void test_distance(std::string const& wkt1, std::string const& wkt2, double expected) -{ - Geometry1 g1; - Geometry2 g2; - bg::read_wkt(wkt1, g1); - bg::read_wkt(wkt2, g2); - typename bg::default_distance_result::type d = bg::distance(g1, g2); - - BOOST_CHECK_CLOSE(d, expected, 0.0001); -} - -template -void test_distance(Strategy const& strategy, std::string const& wkt1, - std::string const& wkt2, double expected) -{ - Geometry1 g1; - Geometry2 g2; - bg::read_wkt(wkt1, g1); - bg::read_wkt(wkt2, g2); - typename bg::default_distance_result::type d = bg::distance(g1, g2, strategy); - - BOOST_CHECK_CLOSE(d, expected, 0.0001); -} - - -template -void test_2d() -{ - typedef bg::model::multi_point

mp; - typedef bg::model::multi_linestring > ml; - test_distance("POINT(0 0)", "POINT(1 1)", sqrt(2.0)); - test_distance("POINT(0 0)", "MULTIPOINT((1 1),(1 0),(0 2))", 1.0); - test_distance("MULTIPOINT((1 1),(1 0),(0 2))", "POINT(0 0)", 1.0); - test_distance("MULTIPOINT((1 1),(1 0),(0 2))", "MULTIPOINT((2 2),(2 3))", sqrt(2.0)); - test_distance("POINT(0 0)", "MULTILINESTRING((1 1,2 2),(1 0,2 0),(0 2,0 3))", 1.0); - test_distance("MULTILINESTRING((1 1,2 2),(1 0,2 0),(0 2,0 3))", "POINT(0 0)", 1.0); - test_distance("MULTILINESTRING((1 1,2 2),(1 0,2 0),(0 2,0 3))", "MULTIPOINT((0 0),(1 1))", 0.0); - - // Test with a strategy - bg::strategy::distance::pythagoras<> pyth; - test_distance(pyth, "POINT(0 0)", "POINT(1 1)", sqrt(2.0)); - test_distance(pyth, "POINT(0 0)", "MULTIPOINT((1 1),(1 0),(0 2))", 1.0); - test_distance(pyth, "MULTIPOINT((1 1),(1 0),(0 2))", "POINT(0 0)", 1.0); -} - - -template -void test_3d() -{ - typedef bg::model::multi_point

mp; - test_distance("POINT(0 0 0)", "POINT(1 1 1)", sqrt(3.0)); - test_distance("POINT(0 0 0)", "MULTIPOINT((1 1 1),(1 0 0),(0 1 2))", 1.0); - test_distance("MULTIPOINT((1 1 1),(1 0 0),(0 0 2))", "MULTIPOINT((2 2 2),(2 3 4))", sqrt(3.0)); -} - - -template -void test_mixed() -{ - typedef bg::model::multi_point mp1; - typedef bg::model::multi_point mp2; - - test_distance("POINT(0 0)", "POINT(1 1)", sqrt(2.0)); - - test_distance("POINT(0 0)", "MULTIPOINT((1 1),(1 0),(0 2))", 1.0); - test_distance("POINT(0 0)", "MULTIPOINT((1 1),(1 0),(0 2))", 1.0); - test_distance("POINT(0 0)", "MULTIPOINT((1 1),(1 0),(0 2))", 1.0); - test_distance("POINT(0 0)", "MULTIPOINT((1 1),(1 0),(0 2))", 1.0); - - // Test automatic reversal - test_distance("MULTIPOINT((1 1),(1 0),(0 2))", "POINT(0 0)", 1.0); - test_distance("MULTIPOINT((1 1),(1 0),(0 2))", "POINT(0 0)", 1.0); - test_distance("MULTIPOINT((1 1),(1 0),(0 2))", "POINT(0 0)", 1.0); - test_distance("MULTIPOINT((1 1),(1 0),(0 2))", "POINT(0 0)", 1.0); - - // Test multi-multi using different point types for each - test_distance("MULTIPOINT((1 1),(1 0),(0 2))", "MULTIPOINT((2 2),(2 3))", sqrt(2.0)); - - // Test with a strategy - using namespace bg::strategy::distance; - - test_distance(pythagoras<>(), "POINT(0 0)", "POINT(1 1)", sqrt(2.0)); - - test_distance(pythagoras<>(), "POINT(0 0)", "MULTIPOINT((1 1),(1 0),(0 2))", 1.0); - test_distance(pythagoras<>(), "POINT(0 0)", "MULTIPOINT((1 1),(1 0),(0 2))", 1.0); - test_distance(pythagoras<>(), "POINT(0 0)", "MULTIPOINT((1 1),(1 0),(0 2))", 1.0); - test_distance(pythagoras<>(), "POINT(0 0)", "MULTIPOINT((1 1),(1 0),(0 2))", 1.0); - - // Most interesting: reversal AND a strategy (note that the stategy must be reversed automatically - test_distance(pythagoras<>(), "MULTIPOINT((1 1),(1 0),(0 2))", "POINT(0 0)", 1.0); - test_distance(pythagoras<>(), "MULTIPOINT((1 1),(1 0),(0 2))", "POINT(0 0)", 1.0); - test_distance(pythagoras<>(), "MULTIPOINT((1 1),(1 0),(0 2))", "POINT(0 0)", 1.0); - test_distance(pythagoras<>(), "MULTIPOINT((1 1),(1 0),(0 2))", "POINT(0 0)", 1.0); -} - -template -void test_empty_input() -{ - P p; - bg::model::multi_point

mp_empty; - bg::model::multi_linestring > ml_empty; - - test_empty_input(p, mp_empty); - test_empty_input(p, ml_empty); - test_empty_input(mp_empty, mp_empty); - - // Test behaviour if one of the inputs is empty - bg::model::multi_point

mp; - mp.push_back(p); - test_empty_input(mp_empty, mp); - test_empty_input(mp, mp_empty); -} - - -int test_main( int , char* [] ) -{ - test_2d >(); - test_2d >(); - test_2d >(); - - test_3d >(); - test_3d >(); - - test_mixed, bg::model::d2::point_xy >(); - -#ifdef HAVE_TTMATH - test_2d >(); - test_mixed, bg::model::d2::point_xy >(); -#endif - - test_empty_input >(); - - return 0; -} From 54ff519466c4b641cd3a59e100f1ff6e20264091 Mon Sep 17 00:00:00 2001 From: Menelaos Karavelas Date: Fri, 9 May 2014 23:02:39 +0300 Subject: [PATCH 43/66] [stategies][distance] remove strategy::distance::services::strategy_point_point from distance strategies and distance strategy concept --- .../strategies/cartesian/distance_projected_point.hpp | 5 ----- .../geometry/strategies/concepts/distance_concept.hpp | 9 +-------- include/boost/geometry/strategies/distance.hpp | 2 -- .../strategies/spherical/distance_cross_track.hpp | 10 ---------- 4 files changed, 1 insertion(+), 25 deletions(-) diff --git a/include/boost/geometry/strategies/cartesian/distance_projected_point.hpp b/include/boost/geometry/strategies/cartesian/distance_projected_point.hpp index 95b13d792..cd86b523f 100644 --- a/include/boost/geometry/strategies/cartesian/distance_projected_point.hpp +++ b/include/boost/geometry/strategies/cartesian/distance_projected_point.hpp @@ -174,11 +174,6 @@ struct return_type, P, PS> : projected_point::template calculation_type {}; -template -struct strategy_point_point > -{ - typedef Strategy type; -}; template diff --git a/include/boost/geometry/strategies/concepts/distance_concept.hpp b/include/boost/geometry/strategies/concepts/distance_concept.hpp index 5d8cfb690..3d4505bb1 100644 --- a/include/boost/geometry/strategies/concepts/distance_concept.hpp +++ b/include/boost/geometry/strategies/concepts/distance_concept.hpp @@ -135,16 +135,9 @@ private : ApplyMethod, 1 >::type sptype; - // 1) must define meta-function return_type + // must define meta-function return_type typedef typename strategy::distance::services::return_type::type rtype; - // 2) must define underlying point-distance-strategy - typedef typename strategy::distance::services::strategy_point_point::type stype; - BOOST_CONCEPT_ASSERT - ( - (concept::PointDistanceStrategy) - ); - Strategy *str = 0; ptype *p = 0; diff --git a/include/boost/geometry/strategies/distance.hpp b/include/boost/geometry/strategies/distance.hpp index d4df78aca..2071e86cc 100644 --- a/include/boost/geometry/strategies/distance.hpp +++ b/include/boost/geometry/strategies/distance.hpp @@ -61,8 +61,6 @@ template struct result_from_distance {}; -// For point-segment only: -template struct strategy_point_point {}; // Default strategy diff --git a/include/boost/geometry/strategies/spherical/distance_cross_track.hpp b/include/boost/geometry/strategies/spherical/distance_cross_track.hpp index 4185a9479..3180fcf5f 100644 --- a/include/boost/geometry/strategies/spherical/distance_cross_track.hpp +++ b/include/boost/geometry/strategies/spherical/distance_cross_track.hpp @@ -250,16 +250,6 @@ public : }; -template -< - typename CalculationType, - typename Strategy -> -struct strategy_point_point > -{ - typedef Strategy type; -}; - /* From d6b3abcfc10b1777f5e8c4281c238bfb161748ee Mon Sep 17 00:00:00 2001 From: Menelaos Karavelas Date: Fri, 9 May 2014 23:05:20 +0300 Subject: [PATCH 44/66] [distance] re-write segment-box distance code without strategy::distance::services::strategy_point_point; fix bug in segment-box comparable distance when the segment degenerates to a point; --- .../detail/distance/segment_to_box.hpp | 72 +++++++------------ 1 file changed, 25 insertions(+), 47 deletions(-) diff --git a/include/boost/geometry/algorithms/detail/distance/segment_to_box.hpp b/include/boost/geometry/algorithms/detail/distance/segment_to_box.hpp index 0ddf18ada..7f7f6da6a 100644 --- a/include/boost/geometry/algorithms/detail/distance/segment_to_box.hpp +++ b/include/boost/geometry/algorithms/detail/distance/segment_to_box.hpp @@ -12,6 +12,8 @@ #include #include +#include +#include #include #include @@ -422,17 +424,32 @@ public: if ( geometry::equals(p[0], p[1]) ) { - typedef typename detail::distance::default_strategy + typedef typename boost::mpl::if_ < - segment_point, Box - >::type default_point_box_strategy_type; + boost::is_same + < + ps_comparable_strategy, + PSStrategy + >, + typename strategy::distance::services::comparable_type + < + typename detail::distance::default_strategy + < + segment_point, Box + >::type + >::type, + typename detail::distance::default_strategy + < + segment_point, Box + >::type + >::type point_box_strategy_type; return dispatch::distance < segment_point, Box, - default_point_box_strategy_type - >::apply(p[0], box, default_point_box_strategy_type()); + point_box_strategy_type + >::apply(p[0], box, point_box_strategy_type()); } box_point top_left, top_right, bottom_left, bottom_right; @@ -499,46 +516,6 @@ namespace dispatch { -template -struct distance - < - Segment, Box, Strategy, segment_tag, box_tag, - strategy_tag_distance_point_point, false - > -{ - typedef typename strategy::distance::services::return_type - < - Strategy, - typename point_type::type, - typename point_type::type - >::type return_type; - - - static inline return_type apply(Segment const& segment, - Box const& box, - Strategy const& strategy) - { - assert_dimension_equal(); - - typedef typename detail::distance::default_ps_strategy - < - typename point_type::type, - typename point_type::type, - Strategy - >::type ps_strategy_type; - - return detail::distance::segment_to_box - < - Segment, - Box, - dimension::value, - Strategy, - ps_strategy_type - >::apply(segment, box, strategy, ps_strategy_type()); - } -}; - - template struct distance < @@ -560,9 +537,10 @@ struct distance { assert_dimension_equal(); - typedef typename strategy::distance::services::strategy_point_point + typedef typename detail::distance::default_strategy < - Strategy + typename point_type::type, + typename point_type::type >::type pp_strategy_type; return detail::distance::segment_to_box From aba739439bf5e76cf9d9dfb5a297b255aabfd982 Mon Sep 17 00:00:00 2001 From: Menelaos Karavelas Date: Fri, 9 May 2014 23:07:00 +0300 Subject: [PATCH 45/66] [test][distance L/A] add test case for segment-box distance, where the segment degenerates to a point --- test/algorithms/distance_linear_areal.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/test/algorithms/distance_linear_areal.cpp b/test/algorithms/distance_linear_areal.cpp index c5d4d1409..8d1fe9884 100644 --- a/test/algorithms/distance_linear_areal.cpp +++ b/test/algorithms/distance_linear_areal.cpp @@ -622,6 +622,11 @@ void test_distance_segment_box(Strategy const& strategy) tester(make_box2d(0, 0, 1, 1), make_segment(0.5, 1.5, 1.5, -1.5), 0, 0, strategy); + + // test degenerate segment + tester(make_box2d(0, 0, 2, 2), + make_segment(4, 1, 4, 1), + 2, 4, strategy); } //=========================================================================== @@ -754,7 +759,6 @@ BOOST_AUTO_TEST_CASE( test_all_multilinestring_multipolygon ) BOOST_AUTO_TEST_CASE( test_all_segment_box ) { - test_distance_segment_box(point_point_strategy()); test_distance_segment_box(point_segment_strategy()); } From f565154090106bfb7bd04899b4760e899f50ec80 Mon Sep 17 00:00:00 2001 From: Menelaos Karavelas Date: Sat, 10 May 2014 15:14:19 +0300 Subject: [PATCH 46/66] [test][strategies] add unit test to test the return type of the default distance result and the default comparable distance result --- test/strategies/Jamfile.v2 | 12 +- test/strategies/distance_default_result.cpp | 270 ++++++++++++++++++++ 2 files changed, 279 insertions(+), 3 deletions(-) create mode 100644 test/strategies/distance_default_result.cpp diff --git a/test/strategies/Jamfile.v2 b/test/strategies/Jamfile.v2 index 9475f6a5d..e994e46f0 100644 --- a/test/strategies/Jamfile.v2 +++ b/test/strategies/Jamfile.v2 @@ -1,8 +1,13 @@ # 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. +# Copyright (c) 2007-2014 Barend Gehrels, Amsterdam, the Netherlands. +# Copyright (c) 2008-2014 Bruno Lalande, Paris, France. +# Copyright (c) 2009-2014 Mateusz Loskot, London, UK. +# +# This file was modified by Oracle on 2014. +# Modifications copyright (c) 2014, Oracle and/or its affiliates. +# +# Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle # # Use, modification and distribution is subject to the Boost Software License, # Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at @@ -11,6 +16,7 @@ test-suite boost-geometry-strategies : [ run cross_track.cpp ] + [ run distance_default_result.cpp ] [ run haversine.cpp ] [ run projected_point.cpp ] [ run pythagoras.cpp ] diff --git a/test/strategies/distance_default_result.cpp b/test/strategies/distance_default_result.cpp new file mode 100644 index 000000000..40315d207 --- /dev/null +++ b/test/strategies/distance_default_result.cpp @@ -0,0 +1,270 @@ +// Boost.Geometry (aka GGL, Generic Geometry Library) +// Unit Test + +// Copyright (c) 2014, Oracle and/or its affiliates. + +// Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle + +// Licensed under the Boost Software License version 1.0. +// http://www.boost.org/users/license.html + +#ifndef BOOST_TEST_MODULE +#define BOOST_TEST_MODULE test_distance_default_result +#endif + +#include +#include + +#include + +#include +#include +#include + +#include + +#include +#include +#include + +#include +#include +#include + +#if defined(HAVE_TTMATH) +#include +#endif + +namespace bg = ::boost::geometry; + + +template +struct assert_equal_types +{ + assert_equal_types() + { + static const bool are_same = + boost::is_same::type::value; + + BOOST_MPL_ASSERT_MSG((are_same), + WRONG_DEFAULT_DISTANCE_RESULT, + (types)); + } +}; + +//========================================================================= + +template +< + typename Geometry1, + typename Geometry2, + typename ExpectedResult, + typename ExpectedComparableResult +> +inline void test_distance_result() +{ + typedef typename bg::default_distance_result + < + Geometry1, Geometry2 + >::type result12; + + typedef typename bg::default_distance_result + < + Geometry2, Geometry1 + >::type result21; + + typedef typename bg::default_comparable_distance_result + < + Geometry1, Geometry2 + >::type comparable_result12; + + typedef typename bg::default_comparable_distance_result + < + Geometry2, Geometry1 + >::type comparable_result21; + + assert_equal_types(); + assert_equal_types(); + assert_equal_types(); + assert_equal_types(); +} + +//========================================================================= + +template +< + typename CoordinateType1, + typename CoordinateType2, + std::size_t Dimension, + typename CoordinateSystem, + typename ExpectedResult, + typename ExpectedComparableResult = ExpectedResult +> +struct test_distance_result_segment +{ + test_distance_result_segment() + { + typedef typename bg::model::point + < + CoordinateType1, Dimension, CoordinateSystem + > point1; + + typedef typename bg::model::point + < + CoordinateType2, Dimension, CoordinateSystem + > point2; + + typedef typename bg::model::segment segment1; + typedef typename bg::model::segment segment2; + + test_distance_result + < + point1, point2, ExpectedResult, ExpectedComparableResult + >(); + + test_distance_result + < + point1, segment2, ExpectedResult, ExpectedComparableResult + >(); + + test_distance_result + < + point2, segment1, ExpectedResult, ExpectedComparableResult + >(); + } +}; + +//========================================================================= + +template +< + typename CoordinateType1, + typename CoordinateType2, + std::size_t Dimension, + typename ExpectedResult, + typename ExpectedComparableResult = ExpectedResult +> +struct test_distance_result_box +{ + test_distance_result_box() + { + typedef typename bg::model::point + < + CoordinateType1, Dimension, bg::cs::cartesian + > point1; + + typedef typename bg::model::point + < + CoordinateType2, Dimension, bg::cs::cartesian + > point2; + + typedef typename bg::model::box box1; + typedef typename bg::model::box box2; + + test_distance_result + < + point1, box2, ExpectedResult, ExpectedComparableResult + >(); + + test_distance_result + < + point2, box1, ExpectedResult, ExpectedComparableResult + >(); + + test_distance_result + < + box1, box2, ExpectedResult, ExpectedComparableResult + >(); + } +}; + +//========================================================================= + +template +inline void test_segment_all() +{ +#if defined(HAVE_TTMATH) + typedef ttmath_big tt; + typedef bg::util::detail::default_integral::type default_integral; +#endif + typedef typename boost::mpl::if_ + < + typename boost::is_same::type, + double, + float + >::type float_return_type; + + test_distance_result_segment(); + test_distance_result_segment(); + test_distance_result_segment(); + test_distance_result_segment(); + + test_distance_result_segment(); + test_distance_result_segment(); + + test_distance_result_segment(); + test_distance_result_segment(); + test_distance_result_segment(); + test_distance_result_segment(); + test_distance_result_segment(); + +#if defined(HAVE_TTMATH) + test_distance_result_segment(); + test_distance_result_segment(); + + test_distance_result_segment(); + test_distance_result_segment(); + test_distance_result_segment(); +#endif +} + +//========================================================================= + +template +inline void test_box_all() +{ +#if defined(HAVE_TTMATH) + typedef ttmath_big tt; +#endif + typedef bg::util::detail::default_integral::type default_integral; + + test_distance_result_box(); + test_distance_result_box(); + test_distance_result_box(); + test_distance_result_box(); + + test_distance_result_box(); + test_distance_result_box(); + + test_distance_result_box(); + test_distance_result_box(); + test_distance_result_box(); + test_distance_result_box(); + test_distance_result_box(); + +#if defined(HAVE_TTMATH) + test_distance_result_box(); + test_distance_result_box(); + + test_distance_result_box(); + test_distance_result_box(); + test_distance_result_box(); +#endif +} + +//========================================================================= + +BOOST_AUTO_TEST_CASE( test_point_point_or_point_segment ) +{ + test_segment_all<2, bg::cs::cartesian>(); + test_segment_all<3, bg::cs::cartesian>(); + test_segment_all<4, bg::cs::cartesian>(); + test_segment_all<2, bg::cs::spherical_equatorial >(); +} + +BOOST_AUTO_TEST_CASE( test_point_box_or_box ) +{ + test_box_all<2>(); + test_box_all<3>(); + test_box_all<4>(); +} From 15c711cf53cc4a5adb87aad415695d2fd470597e Mon Sep 17 00:00:00 2001 From: Menelaos Karavelas Date: Sun, 11 May 2014 23:16:17 +0300 Subject: [PATCH 47/66] [distance] polish code; make clear when the result of comparable or regular strategy is used; re-write geometry_to_geometry_rtree class so that is uses comparable distances for internal computations; --- .../distance/geometry_to_geometry_rtree.hpp | 72 +++++++++++++------ 1 file changed, 52 insertions(+), 20 deletions(-) diff --git a/include/boost/geometry/algorithms/detail/distance/geometry_to_geometry_rtree.hpp b/include/boost/geometry/algorithms/detail/distance/geometry_to_geometry_rtree.hpp index 84030d77c..faa1f20a8 100644 --- a/include/boost/geometry/algorithms/detail/distance/geometry_to_geometry_rtree.hpp +++ b/include/boost/geometry/algorithms/detail/distance/geometry_to_geometry_rtree.hpp @@ -54,7 +54,7 @@ template > class point_range_to_geometry_rtree { -public: +private: typedef typename strategy::distance::services::comparable_type < Strategy @@ -62,26 +62,27 @@ public: typedef typename strategy::distance::services::return_type < - Strategy, + comparable_strategy, RTreePoint, typename point_type::type - >::type return_type; + >::type comparable_return_type; -private: typedef index::rtree > r_tree; // functor to evaluate minimum comparable distance - struct minimum_cdistance_evaluator + struct minimum_comparable_distance_evaluator { r_tree const& m_r_tree; comparable_strategy const& m_cstrategy; bool m_first; - return_type m_min_cd; + comparable_return_type m_min_cd; - minimum_cdistance_evaluator(r_tree const& r_tree, - comparable_strategy const& cstrategy) - : m_r_tree(r_tree), m_cstrategy(cstrategy), - m_first(true), m_min_cd() + minimum_comparable_distance_evaluator + (r_tree const& r_tree, comparable_strategy const& cstrategy) + : m_r_tree(r_tree) + , m_cstrategy(cstrategy) + , m_first(true) + , m_min_cd() {} template @@ -93,7 +94,7 @@ private: BOOST_ASSERT( n > 0 ); - return_type cd = dispatch::distance + comparable_return_type cd = dispatch::distance < typename r_tree::value_type, QueryGeometry, @@ -124,6 +125,13 @@ private: }; public: + typedef typename strategy::distance::services::return_type + < + Strategy, + RTreePoint, + typename point_type::type + >::type return_type; + template static inline return_type apply(PointIterator points_first, PointIterator points_beyond, @@ -145,7 +153,7 @@ public: // create -- packing algorithm r_tree rt(points_first, points_beyond); - minimum_cdistance_evaluator + minimum_comparable_distance_evaluator functor(rt, strategy::distance::services::get_comparable < @@ -169,7 +177,7 @@ template typename Geometry2, typename Strategy > -struct geometry_to_geometry_rtree +class geometry_to_geometry_rtree { // the following works with linear geometries seen as ranges of points // @@ -178,6 +186,20 @@ struct geometry_to_geometry_rtree // ... and ... // vice versa. +private: + typedef typename strategy::distance::services::comparable_type + < + Strategy + >::type comparable_strategy; + + typedef typename strategy::distance::services::return_type + < + comparable_strategy, + typename point_type::type, + typename point_type::type + >::type comparable_return_type; + +public: typedef typename strategy::distance::services::return_type < Strategy, @@ -220,21 +242,31 @@ struct geometry_to_geometry_rtree return return_type(0); } - return_type cdist1 = point_range_to_geometry_rtree + comparable_strategy cstrategy = + strategy::distance::services::get_comparable + < + Strategy + >::apply(strategy); + + comparable_return_type cdist1 = point_range_to_geometry_rtree < typename point_type::type, Geometry2, - Strategy - >::apply(first1, beyond1, geometry2, strategy); + comparable_strategy + >::apply(first1, beyond1, geometry2, cstrategy); - return_type cdist2 = point_range_to_geometry_rtree + comparable_return_type cdist2 = point_range_to_geometry_rtree < typename point_type::type, Geometry1, - Strategy - >::apply(first2, beyond2, geometry1, strategy); + comparable_strategy + >::apply(first2, beyond2, geometry1, cstrategy); - return (std::min)(cdist1, cdist2); + + return strategy::distance::services::comparable_to_regular + < + comparable_strategy, Strategy, Geometry1, Geometry2 + >::apply( (std::min)(cdist1, cdist2) ); } }; From cea8dd1b0dbf81eb08d98fdddbcc9b42b13e0190 Mon Sep 17 00:00:00 2001 From: Menelaos Karavelas Date: Sun, 11 May 2014 23:21:22 +0300 Subject: [PATCH 48/66] [distance] polish code; make clear when the result of comparable or regular strategy is used; --- .../detail/distance/multi_to_multi.hpp | 25 +++-- .../detail/distance/point_to_geometry.hpp | 99 ++++++++++++------- .../distance/polygon_to_segment_or_box.hpp | 27 +++-- .../distance/range_to_segment_or_box.hpp | 64 ++++++------ .../detail/distance/segment_to_box.hpp | 12 ++- .../detail/distance/segment_to_segment.hpp | 23 +++-- .../detail/distance/single_to_multi.hpp | 25 +++-- 7 files changed, 174 insertions(+), 101 deletions(-) diff --git a/include/boost/geometry/algorithms/detail/distance/multi_to_multi.hpp b/include/boost/geometry/algorithms/detail/distance/multi_to_multi.hpp index 0be5b8641..1e6e3c77f 100644 --- a/include/boost/geometry/algorithms/detail/distance/multi_to_multi.hpp +++ b/include/boost/geometry/algorithms/detail/distance/multi_to_multi.hpp @@ -50,24 +50,33 @@ namespace detail { namespace distance template -struct distance_multi_to_multi_generic +class distance_multi_to_multi_generic { +private: typedef typename strategy::distance::services::comparable_type < Strategy >::type comparable_strategy; typedef typename strategy::distance::services::return_type - < - Strategy, - typename point_type::type, - typename point_type::type - >::type return_type; + < + comparable_strategy, + typename point_type::type, + typename point_type::type + >::type comparable_return_type; + +public: + typedef typename strategy::distance::services::return_type + < + Strategy, + typename point_type::type, + typename point_type::type + >::type return_type; static inline return_type apply(Multi1 const& multi1, Multi2 const& multi2, Strategy const& strategy) { - return_type min_cdist = return_type(); + comparable_return_type min_cdist = comparable_return_type(); bool first = true; comparable_strategy cstrategy = @@ -80,7 +89,7 @@ struct distance_multi_to_multi_generic it != boost::end(multi1); ++it, first = false) { - return_type cdist = + comparable_return_type cdist = dispatch::splitted_dispatch::distance_single_to_multi < typename range_value::type, diff --git a/include/boost/geometry/algorithms/detail/distance/point_to_geometry.hpp b/include/boost/geometry/algorithms/detail/distance/point_to_geometry.hpp index bac63e830..4d6a598ad 100644 --- a/include/boost/geometry/algorithms/detail/distance/point_to_geometry.hpp +++ b/include/boost/geometry/algorithms/detail/distance/point_to_geometry.hpp @@ -56,14 +56,11 @@ namespace detail { namespace distance { -// To avoid spurious namespaces here: -using strategy::distance::services::return_type; - - template struct point_to_point { - static inline typename return_type::type + static inline + typename strategy::distance::services::return_type::type apply(P1 const& p1, P2 const& p2, Strategy const& strategy) { boost::ignore_unused_variable_warning(strategy); @@ -79,18 +76,25 @@ template closure_selector Closure, typename Strategy > -struct point_to_range +class point_to_range { - typedef typename return_type - < - Strategy, Point, typename point_type::type - >::type return_type; - +private: typedef typename strategy::distance::services::comparable_type < Strategy >::type comparable_strategy; + typedef typename strategy::distance::services::return_type + < + comparable_strategy, Point, typename point_type::type + >::type comparable_return_type; + +public: + typedef typename strategy::distance::services::return_type + < + Strategy, Point, typename point_type::type + >::type return_type; + static inline return_type apply(Point const& point, Range const& range, Strategy const& strategy) { @@ -100,7 +104,7 @@ struct point_to_range Strategy >::apply(strategy); - return_type const zero = return_type(0); + comparable_return_type const zero = comparable_return_type(0); if (boost::size(range) == 0) { @@ -126,26 +130,29 @@ struct point_to_range } // start with first segment distance - return_type d = c_strategy.apply(point, *prev, *it); + comparable_return_type cd = c_strategy.apply(point, *prev, *it); // check if other segments are closer for (++prev, ++it; it != boost::end(view); ++prev, ++it) { - return_type const ds = c_strategy.apply(point, *prev, *it); - if (geometry::math::equals(ds, zero)) + comparable_return_type cds = c_strategy.apply(point, *prev, *it); + if (geometry::math::equals(cds, zero)) { - return ds; + return strategy::distance::services::comparable_to_regular + < + comparable_strategy, Strategy, Point, Range + >::apply(zero); } - else if (ds < d) + else if (cds < cd) { - d = ds; + cd = cds; } } return strategy::distance::services::comparable_to_regular < comparable_strategy, Strategy, Point, Range - >::apply(d); + >::apply(cd); } }; @@ -161,7 +168,7 @@ struct point_to_ring { typedef std::pair < - typename return_type + typename strategy::distance::services::return_type < Strategy, Point, typename point_type::type >::type, @@ -195,19 +202,31 @@ template closure_selector Closure, typename Strategy > -struct point_to_polygon +class point_to_polygon { - typedef typename return_type - < - Strategy, Point, typename point_type::type - >::type return_type; - typedef std::pair distance_containment; - +private: typedef typename strategy::distance::services::comparable_type < Strategy >::type comparable_strategy; + typedef typename strategy::distance::services::return_type + < + comparable_strategy, Point, typename point_type::type + >::type comparable_return_type; + + typedef std::pair + < + comparable_return_type, bool + > comparable_distance_containment; + +public: + typedef typename strategy::distance::services::return_type + < + Strategy, Point, typename point_type::type + >::type return_type; + typedef std::pair distance_containment; + static inline distance_containment apply(Point const& point, Polygon const& polygon, Strategy const& strategy) @@ -227,9 +246,8 @@ struct point_to_polygon comparable_strategy > per_ring; - distance_containment dc = per_ring::apply(point, - exterior_ring(polygon), - c_strategy); + comparable_distance_containment dc = + per_ring::apply(point, exterior_ring(polygon), c_strategy); typename interior_return_type::type rings = interior_rings(polygon); @@ -239,7 +257,8 @@ struct point_to_polygon >::type it = boost::begin(rings); it != boost::end(rings); ++it) { - distance_containment dcr = per_ring::apply(point, *it, c_strategy); + comparable_distance_containment dcr = + per_ring::apply(point, *it, c_strategy); if (dcr.first < dc.first) { dc.first = dcr.first; @@ -305,11 +324,14 @@ struct distance false > { - typedef typename return_type::type>::type return_type; + typedef typename strategy::distance::services::return_type + < + Strategy, Point, typename point_type::type + >::type return_type; static inline return_type apply(Point const& point, - Ring const& ring, - Strategy const& strategy) + Ring const& ring, + Strategy const& strategy) { std::pair dc = detail::distance::point_to_ring @@ -332,11 +354,14 @@ struct distance strategy_tag_distance_point_segment, false > { - typedef typename return_type::type>::type return_type; + typedef typename strategy::distance::services::return_type + < + Strategy, Point, typename point_type::type + >::type return_type; static inline return_type apply(Point const& point, - Polygon const& polygon, - Strategy const& strategy) + Polygon const& polygon, + Strategy const& strategy) { std::pair dc = detail::distance::point_to_polygon diff --git a/include/boost/geometry/algorithms/detail/distance/polygon_to_segment_or_box.hpp b/include/boost/geometry/algorithms/detail/distance/polygon_to_segment_or_box.hpp index 351e7278e..631cb25d3 100644 --- a/include/boost/geometry/algorithms/detail/distance/polygon_to_segment_or_box.hpp +++ b/include/boost/geometry/algorithms/detail/distance/polygon_to_segment_or_box.hpp @@ -42,20 +42,29 @@ namespace detail { namespace distance template -struct polygon_to_segment_or_box +class polygon_to_segment_or_box { - typedef typename return_type +private: + typedef typename strategy::distance::services::comparable_type + < + Strategy + >::type comparable_strategy; + + typedef typename strategy::distance::services::return_type + < + comparable_strategy, + typename point_type::type, + typename point_type::type + >::type comparable_return_type; + +public: + typedef typename strategy::distance::services::return_type < Strategy, typename point_type::type, typename point_type::type >::type return_type; - typedef typename strategy::distance::services::comparable_type - < - Strategy - >::type comparable_strategy; - static inline return_type apply(Polygon const& polygon, SegmentOrBox const& segment_or_box, Strategy const& strategy) @@ -79,7 +88,7 @@ struct polygon_to_segment_or_box >::apply(strategy); - return_type cd_min = range_to_segment_or_box + comparable_return_type cd_min = range_to_segment_or_box < e_ring, SegmentOrBox, comparable_strategy >::apply(ext_ring, segment_or_box, cstrategy, false); @@ -88,7 +97,7 @@ struct polygon_to_segment_or_box for (iterator_type it = boost::begin(int_rings); it != boost::end(int_rings); ++it) { - return_type cd = range_to_segment_or_box + comparable_return_type cd = range_to_segment_or_box < i_ring, SegmentOrBox, comparable_strategy >::apply(*it, segment_or_box, cstrategy, false); diff --git a/include/boost/geometry/algorithms/detail/distance/range_to_segment_or_box.hpp b/include/boost/geometry/algorithms/detail/distance/range_to_segment_or_box.hpp index b73c5a840..db2bcf68f 100644 --- a/include/boost/geometry/algorithms/detail/distance/range_to_segment_or_box.hpp +++ b/include/boost/geometry/algorithms/detail/distance/range_to_segment_or_box.hpp @@ -57,18 +57,16 @@ private: typedef typename point_type::type segment_or_box_point; typedef typename point_type::type range_point; -public: - typedef typename strategy::distance::services::return_type - < - Strategy, range_point, segment_or_box_point - >::type return_type; - -private: typedef typename strategy::distance::services::comparable_type < Strategy >::type comparable_strategy; + typedef typename strategy::distance::services::return_type + < + comparable_strategy, range_point, segment_or_box_point + >::type comparable_return_type; + typedef typename strategy::distance::services::tag < comparable_strategy @@ -79,7 +77,7 @@ private: segment_or_box_point, Range, comparable_strategy, point_tag, typename tag::type, comparable_strategy_tag, false - > point_to_range; + > comparable_point_to_range; // compute distance of a point to a segment or a box template @@ -89,7 +87,7 @@ private: typename ComparableStrategy, typename Tag > - struct distance_point_to_segment_or_box + struct comparable_distance_point_to_segment_or_box {}; template @@ -98,14 +96,15 @@ private: typename SegmentPoints, typename ComparableStrategy > - struct distance_point_to_segment_or_box + struct comparable_distance_point_to_segment_or_box < Point, SegmentPoints, ComparableStrategy, segment_tag > { - static inline return_type apply(Point const& point, - SegmentPoints const& segment_points, - ComparableStrategy const& strategy) + static inline + comparable_return_type apply(Point const& point, + SegmentPoints const& segment_points, + ComparableStrategy const& strategy) { return strategy.apply(point, segment_points[0], segment_points[1]); } @@ -117,21 +116,22 @@ private: typename BoxPoints, typename ComparableStrategy > - struct distance_point_to_segment_or_box + struct comparable_distance_point_to_segment_or_box < Point, BoxPoints, ComparableStrategy, box_tag > { - static inline return_type apply(Point const& point, - BoxPoints const& box_points, - ComparableStrategy const& strategy) + static inline + comparable_return_type apply(Point const& point, + BoxPoints const& box_points, + ComparableStrategy const& strategy) { - return_type cd_min = + comparable_return_type cd_min = strategy.apply(point, box_points[0], box_points[3]); for (unsigned int i = 0; i < 2; ++i) { - return_type cd = + comparable_return_type cd = strategy.apply(point, box_points[i], box_points[i+1]); if ( cd < cd_min ) @@ -177,6 +177,11 @@ private: public: + typedef typename strategy::distance::services::return_type + < + Strategy, range_point, segment_or_box_point + >::type return_type; + static inline return_type apply(Range const& range, SegmentOrBox const& segment_or_box, Strategy const& strategy, bool check_intersection = true) @@ -208,11 +213,13 @@ public: // to the range typename std::vector::const_iterator it = segment_or_box_points.begin(); - return_type cd_min = point_to_range::apply(*it, range, cstrategy); + comparable_return_type cd_min = + comparable_point_to_range::apply(*it, range, cstrategy); for (++it; it != segment_or_box_points.end(); ++it) { - return_type cd = point_to_range::apply(*it, range, cstrategy); + comparable_return_type cd = + comparable_point_to_range::apply(*it, range, cstrategy); if ( cd < cd_min ) { cd_min = cd; @@ -224,13 +231,14 @@ public: typedef typename range_iterator::type iterator_type; for (iterator_type it = boost::begin(range); it != boost::end(range); ++it) { - return_type cd = distance_point_to_segment_or_box - < - typename point_type::type, - std::vector, - comparable_strategy, - typename tag::type - >::apply(*it, segment_or_box_points, cstrategy); + comparable_return_type cd = + comparable_distance_point_to_segment_or_box + < + typename point_type::type, + std::vector, + comparable_strategy, + typename tag::type + >::apply(*it, segment_or_box_points, cstrategy); if ( cd < cd_min ) { diff --git a/include/boost/geometry/algorithms/detail/distance/segment_to_box.hpp b/include/boost/geometry/algorithms/detail/distance/segment_to_box.hpp index 7f7f6da6a..3efa7673a 100644 --- a/include/boost/geometry/algorithms/detail/distance/segment_to_box.hpp +++ b/include/boost/geometry/algorithms/detail/distance/segment_to_box.hpp @@ -407,6 +407,10 @@ private: PSStrategy >::type ps_comparable_strategy; + typedef typename strategy::distance::services::return_type + < + ps_comparable_strategy, segment_point, box_point + >::type comparable_return_type; public: typedef typename strategy::distance::services::return_type < @@ -468,11 +472,11 @@ public: PSStrategy >::apply(ps_strategy); - return_type d; + comparable_return_type cd; if ( geometry::less()(p[0], p[1]) ) { - d = segment_to_box_2D + cd = segment_to_box_2D < return_type, segment_point, @@ -486,7 +490,7 @@ public: } else { - d = segment_to_box_2D + cd = segment_to_box_2D < return_type, segment_point, @@ -502,7 +506,7 @@ public: return strategy::distance::services::comparable_to_regular < ps_comparable_strategy, PSStrategy, Segment, Box - >::apply( d ); + >::apply( cd ); } }; diff --git a/include/boost/geometry/algorithms/detail/distance/segment_to_segment.hpp b/include/boost/geometry/algorithms/detail/distance/segment_to_segment.hpp index ab7d11f57..1ae22153c 100644 --- a/include/boost/geometry/algorithms/detail/distance/segment_to_segment.hpp +++ b/include/boost/geometry/algorithms/detail/distance/segment_to_segment.hpp @@ -37,8 +37,22 @@ namespace detail { namespace distance // compute segment-segment distance template -struct segment_to_segment +class segment_to_segment { +private: + typedef typename strategy::distance::services::comparable_type + < + Strategy + >::type comparable_strategy; + + typedef typename strategy::distance::services::return_type + < + comparable_strategy, + typename point_type::type, + typename point_type::type + >::type comparable_return_type; + +public: typedef typename strategy::distance::services::return_type < Strategy, @@ -46,11 +60,6 @@ struct segment_to_segment typename point_type::type >::type return_type; - typedef typename strategy::distance::services::comparable_type - < - Strategy - >::type comparable_strategy; - static inline return_type apply(Segment1 const& segment1, Segment2 const& segment2, Strategy const& strategy) @@ -74,7 +83,7 @@ struct segment_to_segment Strategy >::apply(strategy); - return_type d[4]; + comparable_return_type d[4]; d[0] = cstrategy.apply(q[0], p[0], p[1]); d[1] = cstrategy.apply(q[1], p[0], p[1]); d[2] = cstrategy.apply(p[0], q[0], q[1]); diff --git a/include/boost/geometry/algorithms/detail/distance/single_to_multi.hpp b/include/boost/geometry/algorithms/detail/distance/single_to_multi.hpp index 6b43144ac..f0c18476d 100644 --- a/include/boost/geometry/algorithms/detail/distance/single_to_multi.hpp +++ b/include/boost/geometry/algorithms/detail/distance/single_to_multi.hpp @@ -67,25 +67,34 @@ namespace detail { namespace distance template -struct distance_single_to_multi_generic +class distance_single_to_multi_generic { +private: typedef typename strategy::distance::services::comparable_type < Strategy >::type comparable_strategy; typedef typename strategy::distance::services::return_type - < - Strategy, - typename point_type::type, - typename point_type::type - >::type return_type; + < + comparable_strategy, + typename point_type::type, + typename point_type::type + >::type comparable_return_type; + +public: + typedef typename strategy::distance::services::return_type + < + Strategy, + typename point_type::type, + typename point_type::type + >::type return_type; static inline return_type apply(Geometry const& geometry, MultiGeometry const& multi, Strategy const& strategy) { - return_type min_cdist = return_type(); + comparable_return_type min_cdist = comparable_return_type(); bool first = true; comparable_strategy cstrategy = @@ -98,7 +107,7 @@ struct distance_single_to_multi_generic it != boost::end(multi); ++it, first = false) { - return_type cdist = dispatch::distance + comparable_return_type cdist = dispatch::distance < Geometry, typename range_value::type, From 5132d2a9cffb0c539ecc416965d8ee54e30e9211 Mon Sep 17 00:00:00 2001 From: Barend Gehrels Date: Mon, 12 May 2014 22:31:09 +0200 Subject: [PATCH 49/66] [doc] Added variant to implementation-status matrix --- doc/reference/status/area_status.qbk | 1 + doc/reference/status/centroid_status.qbk | 1 + doc/reference/status/clear_status.qbk | 1 + doc/reference/status/correct_status.qbk | 1 + doc/reference/status/covered_by_status.qbk | 21 ++++++------ doc/reference/status/crosses_status.qbk | 21 ++++++------ doc/reference/status/disjoint_status.qbk | 21 ++++++------ doc/reference/status/distance_status.qbk | 21 ++++++------ doc/reference/status/envelope_status.qbk | 1 + doc/reference/status/equals_status.qbk | 21 ++++++------ doc/reference/status/intersects_status.qbk | 21 ++++++------ doc/reference/status/length_status.qbk | 1 + doc/reference/status/num_points_status.qbk | 1 + doc/reference/status/overlaps_status.qbk | 21 ++++++------ doc/reference/status/perimeter_status.qbk | 1 + doc/reference/status/within_status.qbk | 21 ++++++------ .../implementation_status.cpp | 34 ++++++++++++++++--- 17 files changed, 126 insertions(+), 84 deletions(-) diff --git a/doc/reference/status/area_status.qbk b/doc/reference/status/area_status.qbk index e4d8d3023..edff68193 100644 --- a/doc/reference/status/area_status.qbk +++ b/doc/reference/status/area_status.qbk @@ -10,4 +10,5 @@ [[MultiPoint][ [$img/ok.png] ]] [[MultiLinestring][ [$img/ok.png] ]] [[MultiPolygon][ [$img/ok.png] ]] +[[Variant][ [$img/ok.png] ]] ] diff --git a/doc/reference/status/centroid_status.qbk b/doc/reference/status/centroid_status.qbk index e4d8d3023..edff68193 100644 --- a/doc/reference/status/centroid_status.qbk +++ b/doc/reference/status/centroid_status.qbk @@ -10,4 +10,5 @@ [[MultiPoint][ [$img/ok.png] ]] [[MultiLinestring][ [$img/ok.png] ]] [[MultiPolygon][ [$img/ok.png] ]] +[[Variant][ [$img/ok.png] ]] ] diff --git a/doc/reference/status/clear_status.qbk b/doc/reference/status/clear_status.qbk index e4d8d3023..edff68193 100644 --- a/doc/reference/status/clear_status.qbk +++ b/doc/reference/status/clear_status.qbk @@ -10,4 +10,5 @@ [[MultiPoint][ [$img/ok.png] ]] [[MultiLinestring][ [$img/ok.png] ]] [[MultiPolygon][ [$img/ok.png] ]] +[[Variant][ [$img/ok.png] ]] ] diff --git a/doc/reference/status/correct_status.qbk b/doc/reference/status/correct_status.qbk index e4d8d3023..edff68193 100644 --- a/doc/reference/status/correct_status.qbk +++ b/doc/reference/status/correct_status.qbk @@ -10,4 +10,5 @@ [[MultiPoint][ [$img/ok.png] ]] [[MultiLinestring][ [$img/ok.png] ]] [[MultiPolygon][ [$img/ok.png] ]] +[[Variant][ [$img/ok.png] ]] ] diff --git a/doc/reference/status/covered_by_status.qbk b/doc/reference/status/covered_by_status.qbk index 122666d12..cc550988b 100644 --- a/doc/reference/status/covered_by_status.qbk +++ b/doc/reference/status/covered_by_status.qbk @@ -1,13 +1,14 @@ [heading Supported geometries] [table -[[ ][Point][Segment][Box][Linestring][Ring][Polygon][MultiPoint][MultiLinestring][MultiPolygon]] -[[Point][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ]] -[[Segment][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ]] -[[Box][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ]] -[[Linestring][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/nyi.png] ]] -[[Ring][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/ok.png] ]] -[[Polygon][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/ok.png] ]] -[[MultiPoint][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ]] -[[MultiLinestring][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/nyi.png] ]] -[[MultiPolygon][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/ok.png] ]] +[[ ][Point][Segment][Box][Linestring][Ring][Polygon][MultiPoint][MultiLinestring][MultiPolygon][Variant]] +[[Point][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ]] +[[Segment][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ]] +[[Box][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ]] +[[Linestring][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ]] +[[Ring][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ]] +[[Polygon][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ]] +[[MultiPoint][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ]] +[[MultiLinestring][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ]] +[[MultiPolygon][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ]] +[[Variant][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ]] ] diff --git a/doc/reference/status/crosses_status.qbk b/doc/reference/status/crosses_status.qbk index 512f4bb78..6b1fe8758 100644 --- a/doc/reference/status/crosses_status.qbk +++ b/doc/reference/status/crosses_status.qbk @@ -1,13 +1,14 @@ [heading Supported geometries] [table -[[ ][Point][Segment][Box][Linestring][Ring][Polygon][MultiPoint][MultiLinestring][MultiPolygon]] -[[Point][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/ok.png] ]] -[[Segment][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ]] -[[Box][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ]] -[[Linestring][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/nyi.png] ]] -[[Ring][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/nyi.png] ]] -[[Polygon][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/nyi.png] ]] -[[MultiPoint][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ]] -[[MultiLinestring][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/nyi.png] ]] -[[MultiPolygon][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/nyi.png] ]] +[[ ][Point][Segment][Box][Linestring][Ring][Polygon][MultiPoint][MultiLinestring][MultiPolygon][Variant]] +[[Point][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ]] +[[Segment][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ]] +[[Box][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ]] +[[Linestring][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ]] +[[Ring][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ]] +[[Polygon][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ]] +[[MultiPoint][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ]] +[[MultiLinestring][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ]] +[[MultiPolygon][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ]] +[[Variant][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ]] ] diff --git a/doc/reference/status/disjoint_status.qbk b/doc/reference/status/disjoint_status.qbk index f6562c3a3..0760a55f8 100644 --- a/doc/reference/status/disjoint_status.qbk +++ b/doc/reference/status/disjoint_status.qbk @@ -1,13 +1,14 @@ [heading Supported geometries] [table -[[ ][Point][Segment][Box][Linestring][Ring][Polygon][MultiPoint][MultiLinestring][MultiPolygon]] -[[Point][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/ok.png] ]] -[[Segment][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ]] -[[Box][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/ok.png] ]] -[[Linestring][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/ok.png] ]] -[[Ring][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/ok.png] ]] -[[Polygon][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/ok.png] ]] -[[MultiPoint][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ]] -[[MultiLinestring][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/ok.png] ]] -[[MultiPolygon][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/ok.png] ]] +[[ ][Point][Segment][Box][Linestring][Ring][Polygon][MultiPoint][MultiLinestring][MultiPolygon][Variant]] +[[Point][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ]] +[[Segment][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/ok.png] ]] +[[Box][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/ok.png] ]] +[[Linestring][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/ok.png] ]] +[[Ring][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ]] +[[Polygon][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/ok.png] ]] +[[MultiPoint][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ]] +[[MultiLinestring][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/nyi.png] ]] +[[MultiPolygon][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ]] +[[Variant][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/ok.png] ]] ] diff --git a/doc/reference/status/distance_status.qbk b/doc/reference/status/distance_status.qbk index 5dbdeba7f..9209452b6 100644 --- a/doc/reference/status/distance_status.qbk +++ b/doc/reference/status/distance_status.qbk @@ -1,13 +1,14 @@ [heading Supported geometries] [table -[[ ][Point][Segment][Box][Linestring][Ring][Polygon][MultiPoint][MultiLinestring][MultiPolygon]] -[[Point][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ]] -[[Segment][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ]] -[[Box][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ]] -[[Linestring][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ]] -[[Ring][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ]] -[[Polygon][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ]] -[[MultiPoint][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ]] -[[MultiLinestring][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ]] -[[MultiPolygon][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ]] +[[ ][Point][Segment][Box][Linestring][Ring][Polygon][MultiPoint][MultiLinestring][MultiPolygon][Variant]] +[[Point][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ]] +[[Segment][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ]] +[[Box][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ]] +[[Linestring][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ]] +[[Ring][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ]] +[[Polygon][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ]] +[[MultiPoint][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ]] +[[MultiLinestring][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ]] +[[MultiPolygon][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ]] +[[Variant][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ]] ] diff --git a/doc/reference/status/envelope_status.qbk b/doc/reference/status/envelope_status.qbk index e4d8d3023..edff68193 100644 --- a/doc/reference/status/envelope_status.qbk +++ b/doc/reference/status/envelope_status.qbk @@ -10,4 +10,5 @@ [[MultiPoint][ [$img/ok.png] ]] [[MultiLinestring][ [$img/ok.png] ]] [[MultiPolygon][ [$img/ok.png] ]] +[[Variant][ [$img/ok.png] ]] ] diff --git a/doc/reference/status/equals_status.qbk b/doc/reference/status/equals_status.qbk index 9abd11cbc..2628e4483 100644 --- a/doc/reference/status/equals_status.qbk +++ b/doc/reference/status/equals_status.qbk @@ -1,13 +1,14 @@ [heading Supported geometries] [table -[[ ][Point][Segment][Box][Linestring][Ring][Polygon][MultiPoint][MultiLinestring][MultiPolygon]] -[[Point][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ]] -[[Segment][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ]] -[[Box][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ]] -[[Linestring][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/nyi.png] ]] -[[Ring][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ]] -[[Polygon][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/ok.png] ]] -[[MultiPoint][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ]] -[[MultiLinestring][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/nyi.png] ]] -[[MultiPolygon][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/ok.png] ]] +[[ ][Point][Segment][Box][Linestring][Ring][Polygon][MultiPoint][MultiLinestring][MultiPolygon][Variant]] +[[Point][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ]] +[[Segment][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ]] +[[Box][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/ok.png] ]] +[[Linestring][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ]] +[[Ring][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/ok.png] ]] +[[Polygon][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/ok.png] ]] +[[MultiPoint][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ]] +[[MultiLinestring][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ]] +[[MultiPolygon][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/ok.png] ]] +[[Variant][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/ok.png] ]] ] diff --git a/doc/reference/status/intersects_status.qbk b/doc/reference/status/intersects_status.qbk index f6562c3a3..0760a55f8 100644 --- a/doc/reference/status/intersects_status.qbk +++ b/doc/reference/status/intersects_status.qbk @@ -1,13 +1,14 @@ [heading Supported geometries] [table -[[ ][Point][Segment][Box][Linestring][Ring][Polygon][MultiPoint][MultiLinestring][MultiPolygon]] -[[Point][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/ok.png] ]] -[[Segment][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ]] -[[Box][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/ok.png] ]] -[[Linestring][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/ok.png] ]] -[[Ring][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/ok.png] ]] -[[Polygon][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/ok.png] ]] -[[MultiPoint][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ]] -[[MultiLinestring][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/ok.png] ]] -[[MultiPolygon][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/ok.png] ]] +[[ ][Point][Segment][Box][Linestring][Ring][Polygon][MultiPoint][MultiLinestring][MultiPolygon][Variant]] +[[Point][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ]] +[[Segment][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/ok.png] ]] +[[Box][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/ok.png] ]] +[[Linestring][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/ok.png] ]] +[[Ring][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ]] +[[Polygon][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/ok.png] ]] +[[MultiPoint][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ]] +[[MultiLinestring][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/nyi.png] ]] +[[MultiPolygon][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ]] +[[Variant][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/ok.png] ]] ] diff --git a/doc/reference/status/length_status.qbk b/doc/reference/status/length_status.qbk index e4d8d3023..edff68193 100644 --- a/doc/reference/status/length_status.qbk +++ b/doc/reference/status/length_status.qbk @@ -10,4 +10,5 @@ [[MultiPoint][ [$img/ok.png] ]] [[MultiLinestring][ [$img/ok.png] ]] [[MultiPolygon][ [$img/ok.png] ]] +[[Variant][ [$img/ok.png] ]] ] diff --git a/doc/reference/status/num_points_status.qbk b/doc/reference/status/num_points_status.qbk index e4d8d3023..edff68193 100644 --- a/doc/reference/status/num_points_status.qbk +++ b/doc/reference/status/num_points_status.qbk @@ -10,4 +10,5 @@ [[MultiPoint][ [$img/ok.png] ]] [[MultiLinestring][ [$img/ok.png] ]] [[MultiPolygon][ [$img/ok.png] ]] +[[Variant][ [$img/ok.png] ]] ] diff --git a/doc/reference/status/overlaps_status.qbk b/doc/reference/status/overlaps_status.qbk index bcb8a672e..8d26c4daf 100644 --- a/doc/reference/status/overlaps_status.qbk +++ b/doc/reference/status/overlaps_status.qbk @@ -1,13 +1,14 @@ [heading Supported geometries] [table -[[ ][Point][Segment][Box][Linestring][Ring][Polygon][MultiPoint][MultiLinestring][MultiPolygon]] -[[Point][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ]] -[[Segment][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ]] -[[Box][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ]] -[[Linestring][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/nyi.png] ]] -[[Ring][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/ok.png] ]] -[[Polygon][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/ok.png] ]] -[[MultiPoint][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ]] -[[MultiLinestring][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/nyi.png] ]] -[[MultiPolygon][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/ok.png] ]] +[[ ][Point][Segment][Box][Linestring][Ring][Polygon][MultiPoint][MultiLinestring][MultiPolygon][Variant]] +[[Point][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ]] +[[Segment][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ]] +[[Box][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ]] +[[Linestring][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ]] +[[Ring][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/ok.png] ]] +[[Polygon][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/ok.png] ]] +[[MultiPoint][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ]] +[[MultiLinestring][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ]] +[[MultiPolygon][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/ok.png] ]] +[[Variant][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ]] ] diff --git a/doc/reference/status/perimeter_status.qbk b/doc/reference/status/perimeter_status.qbk index e4d8d3023..edff68193 100644 --- a/doc/reference/status/perimeter_status.qbk +++ b/doc/reference/status/perimeter_status.qbk @@ -10,4 +10,5 @@ [[MultiPoint][ [$img/ok.png] ]] [[MultiLinestring][ [$img/ok.png] ]] [[MultiPolygon][ [$img/ok.png] ]] +[[Variant][ [$img/ok.png] ]] ] diff --git a/doc/reference/status/within_status.qbk b/doc/reference/status/within_status.qbk index 122666d12..cc550988b 100644 --- a/doc/reference/status/within_status.qbk +++ b/doc/reference/status/within_status.qbk @@ -1,13 +1,14 @@ [heading Supported geometries] [table -[[ ][Point][Segment][Box][Linestring][Ring][Polygon][MultiPoint][MultiLinestring][MultiPolygon]] -[[Point][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ]] -[[Segment][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ]] -[[Box][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ]] -[[Linestring][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/nyi.png] ]] -[[Ring][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/ok.png] ]] -[[Polygon][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/ok.png] ]] -[[MultiPoint][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ]] -[[MultiLinestring][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/nyi.png] ]] -[[MultiPolygon][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/ok.png] ]] +[[ ][Point][Segment][Box][Linestring][Ring][Polygon][MultiPoint][MultiLinestring][MultiPolygon][Variant]] +[[Point][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ]] +[[Segment][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ]] +[[Box][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ]] +[[Linestring][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ]] +[[Ring][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ]] +[[Polygon][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ]] +[[MultiPoint][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ]] +[[MultiLinestring][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ]] +[[MultiPolygon][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ]] +[[Variant][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ]] ] diff --git a/doc/src/docutils/tools/implementation_status/implementation_status.cpp b/doc/src/docutils/tools/implementation_status/implementation_status.cpp index 392002d6f..1a3e1e18e 100644 --- a/doc/src/docutils/tools/implementation_status/implementation_status.cpp +++ b/doc/src/docutils/tools/implementation_status/implementation_status.cpp @@ -30,7 +30,8 @@ static const int polygon = 5; static const int multi_point = 6; static const int multi_linestring = 7; static const int multi_polygon = 8; -static const int geometry_count = 9; +static const int variant = 9; +static const int geometry_count = 10; struct compile_bjam { @@ -149,6 +150,7 @@ inline std::string typedef_string(int type, bool clockwise, bool open) out << "bg::model::ring"; break; + case variant : case polygon : out << "bg::model::polygon"; @@ -174,6 +176,7 @@ inline std::string wkt_string(int type) case segment : return "LINESTRING(1 1,2 2)"; case box : return "POLYGON((1 1,2 2))"; case polygon : + case variant : case ring : return "POLYGON((0 0,0 1,1 1,0 0))"; case multi_point : return "MULTIPOINT((1 1),(2 2))"; @@ -196,6 +199,7 @@ inline std::string geometry_string(int type) case multi_point : return "MultiPoint"; case multi_linestring : return "MultiLinestring"; case multi_polygon : return "MultiPolygon"; + case variant : return "Variant"; } return ""; } @@ -235,15 +239,37 @@ int report_library(CompilePolicy& compile_policy, { std::ofstream out("tmp/t.cpp"); + std::string name = "geometry"; + + if (type == variant) + { + name = "source"; + } + + out << "#include " << std::endl; + + if (type == variant) + { + out << "#include " << std::endl; + } + out - << "#include " << std::endl << "template " << std::endl << "inline void test()" << std::endl << "{" << std::endl << " namespace bg = boost::geometry;" << std::endl - << " " << typedef_string(type, clockwise, open) << " geometry;" << std::endl - << " bg::read_wkt(\"" << wkt_string(type) << "\", geometry);" << std::endl; + << " " << typedef_string(type, clockwise, open) << " " << name << ";" << std::endl + << " bg::read_wkt(\"" << wkt_string(type) << "\", " << name << ");" << std::endl; + if (type == variant) + { + out + << " typedef " << typedef_string(polygon, clockwise, open) << " type1;" << std::endl + << " typedef " << typedef_string(box, clockwise, open) << " type2;" << std::endl + << " boost::variant geometry;" << std::endl + << " geometry = source;" + << std::endl; + } if (algo.arity > 1) { From b8eaf21fb5a52bfaabe50e3fd45c47f3def6edfe Mon Sep 17 00:00:00 2001 From: Menelaos Karavelas Date: Tue, 13 May 2014 10:53:25 +0300 Subject: [PATCH 50/66] [comparable distance] make comparable_distance(g1, g2) return default_comparable_distance_result --- include/boost/geometry/algorithms/comparable_distance.hpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/include/boost/geometry/algorithms/comparable_distance.hpp b/include/boost/geometry/algorithms/comparable_distance.hpp index cc1ae9244..55b827bd3 100644 --- a/include/boost/geometry/algorithms/comparable_distance.hpp +++ b/include/boost/geometry/algorithms/comparable_distance.hpp @@ -19,6 +19,7 @@ #ifndef BOOST_GEOMETRY_ALGORITHMS_COMPARABLE_DISTANCE_HPP #define BOOST_GEOMETRY_ALGORITHMS_COMPARABLE_DISTANCE_HPP +#include #include #include @@ -72,7 +73,7 @@ comparable_distance(Geometry1 const& geometry1, Geometry2 const& geometry2, \qbk{[include reference/algorithms/comparable_distance.qbk]} */ template -inline typename default_distance_result::type +inline typename default_comparable_distance_result::type comparable_distance(Geometry1 const& geometry1, Geometry2 const& geometry2) { concept::check(); From 9d9f1241be3886e9f727a2f9a5b6703cbd879f26 Mon Sep 17 00:00:00 2001 From: Menelaos Karavelas Date: Tue, 13 May 2014 10:54:35 +0300 Subject: [PATCH 51/66] [test][distance] add test case for distance between boxes with integer coordinates --- test/algorithms/distance_areal_areal.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/test/algorithms/distance_areal_areal.cpp b/test/algorithms/distance_areal_areal.cpp index 10e261513..8e9a35fce 100644 --- a/test/algorithms/distance_areal_areal.cpp +++ b/test/algorithms/distance_areal_areal.cpp @@ -19,9 +19,11 @@ #include "test_distance_common.hpp" +typedef bg::model::point int_point_type; typedef bg::model::point point_type; typedef bg::model::polygon polygon_type; typedef bg::model::multi_polygon multi_polygon_type; +typedef bg::model::box int_box_type; typedef bg::model::box box_type; namespace services = bg::strategy::distance::services; @@ -112,8 +114,13 @@ void test_distance_box_box(Strategy const& strategy) std::cout << std::endl; std::cout << "box/box distance tests" << std::endl; #endif + test_distance_of_geometries int_tester; test_distance_of_geometries tester; + int_tester(make_box2d(5, 5, 10, 10), + make_box2d(0, 0, 1, 1), + sqrt(32.0), 32, strategy); + tester(make_box2d(5, 5, 10, 10), make_box2d(0, 0, 1, 1), sqrt(32.0), 32, strategy); From cfef0b8d68a98b306b1f2f1155f057ad43bf8781 Mon Sep 17 00:00:00 2001 From: Menelaos Karavelas Date: Tue, 13 May 2014 10:55:36 +0300 Subject: [PATCH 52/66] [test] extract string_from_type class in geometry_test_common.hpp in a separate file --- test/geometry_test_common.hpp | 47 +------------------- test/string_from_type.hpp | 82 +++++++++++++++++++++++++++++++++++ 2 files changed, 83 insertions(+), 46 deletions(-) create mode 100644 test/string_from_type.hpp diff --git a/test/geometry_test_common.hpp b/test/geometry_test_common.hpp index fdaec1e57..37b8d053d 100644 --- a/test/geometry_test_common.hpp +++ b/test/geometry_test_common.hpp @@ -34,6 +34,7 @@ #include +#include // Include some always-included-for-testing files #if ! defined(BOOST_GEOMETRY_NO_BOOST_TEST) @@ -83,52 +84,6 @@ namespace bg = boost::geometry; -template -struct string_from_type {}; - -template <> struct string_from_type -{ static std::string name() { return "v"; } }; - -template <> struct string_from_type -{ static std::string name() { return "f"; } }; - -template <> struct string_from_type -{ static std::string name() { return "d"; } }; - -template <> struct string_from_type -{ static std::string name() { return "e"; } }; - -template <> struct string_from_type -{ static std::string name() { return "s"; } }; - -template <> struct string_from_type -{ static std::string name() { return "i"; } }; - -template <> struct string_from_type -{ static std::string name() { return "l"; } }; - -#if defined(HAVE_TTMATH) - template <> struct string_from_type - { static std::string name() { return "t"; } }; -#endif - -#if defined(BOOST_RATIONAL_HPP) -template struct string_from_type > -{ static std::string name() { return "r"; } }; -#endif - - -#if defined(HAVE_GMP) - template <> struct string_from_type - { static std::string name() { return "g"; } }; -#endif - -#if defined(HAVE_CLN) - template <> struct string_from_type - { static std::string name() { return "c"; } }; -#endif - - template inline T1 if_typed_tt(T1 value_tt, T2 value) { diff --git a/test/string_from_type.hpp b/test/string_from_type.hpp new file mode 100644 index 000000000..b564c2359 --- /dev/null +++ b/test/string_from_type.hpp @@ -0,0 +1,82 @@ +// 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. + +// 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) + +#ifndef GEOMETRY_TEST_STRING_FROM_TYPE_HPP +#define GEOMETRY_TEST_STRING_FROM_TYPE_HPP + + +#if defined(HAVE_TTMATH) +# include +#endif + +#if defined(HAVE_CLN) || defined(HAVE_GMP) +# include +#endif + + +#if defined(HAVE_GMP) +# include +#endif +#if defined(HAVE_CLN) +# include +#endif + + + +template +struct string_from_type {}; + +template <> struct string_from_type +{ static std::string name() { return "v"; } }; + +template <> struct string_from_type +{ static std::string name() { return "f"; } }; + +template <> struct string_from_type +{ static std::string name() { return "d"; } }; + +template <> struct string_from_type +{ static std::string name() { return "e"; } }; + +template <> struct string_from_type +{ static std::string name() { return "s"; } }; + +template <> struct string_from_type +{ static std::string name() { return "i"; } }; + +template <> struct string_from_type +{ static std::string name() { return "l"; } }; + +#if defined(HAVE_TTMATH) + template <> struct string_from_type + { static std::string name() { return "t"; } }; +#endif + +#if defined(BOOST_RATIONAL_HPP) +template struct string_from_type > +{ static std::string name() { return "r"; } }; +#endif + + +#if defined(HAVE_GMP) +template <> struct string_from_type +{ static std::string name() { return "g"; } }; +#endif + +#if defined(HAVE_CLN) +template <> struct string_from_type +{ static std::string name() { return "c"; } }; +#endif + + +#endif // GEOMETRY_TEST_STRING_FROM_TYPE_HPP From cfb445773e770283d1c2bab4f8e38c434b17bc90 Mon Sep 17 00:00:00 2001 From: Menelaos Karavelas Date: Tue, 13 May 2014 11:01:45 +0300 Subject: [PATCH 53/66] [test][distance] make clear the distinction between distance result and comparable distance result (use correct types and checks) --- test/algorithms/test_distance_common.hpp | 276 +++++++++++++++++------ 1 file changed, 202 insertions(+), 74 deletions(-) diff --git a/test/algorithms/test_distance_common.hpp b/test/algorithms/test_distance_common.hpp index d6c1d4f9d..f4ba097fa 100644 --- a/test/algorithms/test_distance_common.hpp +++ b/test/algorithms/test_distance_common.hpp @@ -14,7 +14,10 @@ #include #include -#include +#include +#include +#include + #include #include #include @@ -31,8 +34,12 @@ #include #include +#include +#include + #include "from_wkt.hpp" +#include #ifndef BOOST_GEOMETRY_TEST_DISTANCE_HPP @@ -150,6 +157,28 @@ struct pretty_print_geometry +//======================================================================== + + +template +struct check_equal +{ + static inline void apply(T const& value1, T const& value2) + { + BOOST_CHECK( value1 == value2 ); + } +}; + +template <> +struct check_equal +{ + static inline void apply(double value1, double value2) + { + BOOST_CHECK_CLOSE( value1, value2, 0.0001 ); + } +}; + + //======================================================================== template @@ -166,61 +195,80 @@ struct test_distance_of_geometries template struct test_distance_of_geometries { - template + template + < + typename DistanceType, + typename ComparableDistanceType, + typename Strategy + > void operator()(std::string const& wkt1, std::string const& wkt2, - double expected_distance, - double expected_comparable_distance, - Strategy const& strategy, - bool test_reversed = false) const - { - Geometry1 geometry1 = from_wkt(wkt1); - Geometry2 geometry2 = from_wkt(wkt2); - - operator()(geometry1, geometry2, - expected_distance, expected_comparable_distance, - strategy, test_reversed); - } - - template - void operator()(Geometry1 const& geometry1, - std::string const& wkt2, - double expected_distance, - double expected_comparable_distance, - Strategy const& strategy, - bool test_reversed = false) const - { - Geometry2 geometry2 = from_wkt(wkt2); - - operator()(geometry1, geometry2, - expected_distance, expected_comparable_distance, - strategy, test_reversed); - } - - template - void operator()(std::string const& wkt1, - Geometry2 const& geometry2, - double expected_distance, - double expected_comparable_distance, - Strategy const& strategy, - bool test_reversed = false) const - { - Geometry1 geometry1 = from_wkt(wkt1); - - operator()(geometry1, geometry2, - expected_distance, expected_comparable_distance, - strategy, test_reversed); - } - - template - void operator()(Geometry1 const& geometry1, - Geometry2 const& geometry2, - double expected_distance, - double expected_comparable_distance, + DistanceType const& expected_distance, + ComparableDistanceType const& expected_comparable_distance, Strategy const& strategy, bool test_reversed = true) const { + Geometry1 geometry1 = from_wkt(wkt1); + Geometry2 geometry2 = from_wkt(wkt2); + operator()(geometry1, geometry2, + expected_distance, expected_comparable_distance, + strategy, test_reversed); + } + + template + < + typename DistanceType, + typename ComparableDistanceType, + typename Strategy + > + void operator()(Geometry1 const& geometry1, + std::string const& wkt2, + DistanceType const& expected_distance, + ComparableDistanceType const& expected_comparable_distance, + Strategy const& strategy, + bool test_reversed = true) const + { + Geometry2 geometry2 = from_wkt(wkt2); + + operator()(geometry1, geometry2, + expected_distance, expected_comparable_distance, + strategy, test_reversed); + } + + template + < + typename DistanceType, + typename ComparableDistanceType, + typename Strategy + > + void operator()(std::string const& wkt1, + Geometry2 const& geometry2, + DistanceType const& expected_distance, + ComparableDistanceType const& expected_comparable_distance, + Strategy const& strategy, + bool test_reversed = true) const + { + Geometry1 geometry1 = from_wkt(wkt1); + + operator()(geometry1, geometry2, + expected_distance, expected_comparable_distance, + strategy, test_reversed); + } + + template + < + typename DistanceType, + typename ComparableDistanceType, + typename Strategy + > + void operator()(Geometry1 const& geometry1, + Geometry2 const& geometry2, + DistanceType const& expected_distance, + ComparableDistanceType const& expected_comparable_distance, + Strategy const& strategy, + bool test_reversed = true) const + { #ifdef GEOMETRY_TEST_DEBUG typedef pretty_print_geometry PPG1; typedef pretty_print_geometry PPG2; @@ -229,30 +277,94 @@ struct test_distance_of_geometries PPG2::apply(geometry2, std::cout); std::cout << std::endl; #endif + typedef typename bg::default_distance_result + < + Geometry1, Geometry2 + >::type default_distance_result; - typename bg::default_distance_result::type dist_def - = bg::distance(geometry1, geometry2); + typedef typename bg::strategy::distance::services::return_type + < + Strategy, Geometry1, Geometry2 + >::type distance_result_from_strategy; - BOOST_CHECK_CLOSE(dist_def, expected_distance, 0.0001); + static const bool same_regular = boost::is_same + < + default_distance_result, + distance_result_from_strategy + >::type::value; - typename bg::default_distance_result::type dist - = bg::distance(geometry1, geometry2, strategy); + BOOST_CHECK( same_regular ); + - BOOST_CHECK_CLOSE(dist, expected_distance, 0.0001); - -#ifdef GEOMETRY_TEST_DEBUG - typename bg::default_distance_result::type cdist_def - = bg::comparable_distance(geometry1, geometry2); - - BOOST_CHECK_CLOSE(cdist_def, expected_comparable_distance, 0.001); -#endif - - typename bg::default_distance_result::type cdist - = bg::comparable_distance(geometry1, geometry2, strategy); - - BOOST_CHECK_CLOSE(cdist, expected_comparable_distance, 0.001); + typedef typename bg::default_comparable_distance_result + < + Geometry1, Geometry2 + >::type default_comparable_distance_result; + + typedef typename bg::strategy::distance::services::return_type + < + typename bg::strategy::distance::services::comparable_type + < + Strategy + >::type, + Geometry1, + Geometry2 + >::type comparable_distance_result_from_strategy; + + static const bool same_comparable = boost::is_same + < + default_comparable_distance_result, + comparable_distance_result_from_strategy + >::type::value; + + BOOST_CHECK( same_comparable ); + + + // check distance with default strategy + default_distance_result dist_def = bg::distance(geometry1, geometry2); + + check_equal + < + default_distance_result + >::apply(dist_def, expected_distance); + + + // check distance with passed strategy + distance_result_from_strategy dist = + bg::distance(geometry1, geometry2, strategy); + + check_equal + < + default_distance_result + >::apply(dist, expected_distance); + + + // check comparable distance with default strategy + default_comparable_distance_result cdist_def = + bg::comparable_distance(geometry1, geometry2); + + check_equal + < + default_comparable_distance_result + >::apply(cdist_def, expected_comparable_distance); + + + // check comparable distance with passed strategy + comparable_distance_result_from_strategy cdist = + bg::comparable_distance(geometry1, geometry2, strategy); + + check_equal + < + default_comparable_distance_result + >::apply(cdist, expected_comparable_distance); #ifdef GEOMETRY_TEST_DEBUG + std::cout << string_from_type::type>::name() + << string_from_type::type>::name() + << " -> " + << string_from_type::name() + << string_from_type::name() + << std::endl; std::cout << "distance (default strategy) = " << dist_def << " ; " << "distance (passed strategy) = " << dist << " ; " << "comp. distance (default strategy) = " @@ -268,23 +380,39 @@ struct test_distance_of_geometries if ( test_reversed ) { + // check distance with default strategy dist_def = bg::distance(geometry2, geometry1); - BOOST_CHECK_CLOSE(dist_def, expected_distance, 0.0001); + check_equal + < + default_distance_result + >::apply(dist_def, expected_distance); + + // check distance with given strategy dist = bg::distance(geometry2, geometry1, strategy); - BOOST_CHECK_CLOSE(dist, expected_distance, 0.0001); + check_equal + < + default_distance_result + >::apply(dist, expected_distance); -#ifdef GEOMETRY_TEST_DEBUG + + // check comparable distance with default strategy cdist_def = bg::comparable_distance(geometry2, geometry1); - BOOST_CHECK_CLOSE(cdist_def, expected_comparable_distance, 0.001); -#endif + check_equal + < + default_comparable_distance_result + >::apply(cdist_def, expected_comparable_distance); + // check comparable distance with given strategy cdist = bg::comparable_distance(geometry2, geometry1, strategy); - BOOST_CHECK_CLOSE(cdist, expected_comparable_distance, 0.001); + check_equal + < + default_comparable_distance_result + >::apply(cdist, expected_comparable_distance); #ifdef GEOMETRY_TEST_DEBUG std::cout << "distance[reversed args] (def. startegy) = " From ef5d49a3fa59aec17aff6ae62552862f993fe9f7 Mon Sep 17 00:00:00 2001 From: Menelaos Karavelas Date: Tue, 13 May 2014 11:57:09 +0300 Subject: [PATCH 54/66] [test][distance] replace operator() by static apply method in tester of distance of two geometries; activate test for the segment-ring combination --- test/algorithms/distance_areal_areal.cpp | 170 +-- test/algorithms/distance_linear_areal.cpp | 985 +++++++++--------- test/algorithms/distance_linear_linear.cpp | 148 +-- test/algorithms/distance_pointlike_areal.cpp | 536 +++++----- test/algorithms/distance_pointlike_linear.cpp | 140 +-- .../distance_pointlike_pointlike.cpp | 49 +- test/algorithms/test_distance_common.hpp | 140 +-- 7 files changed, 1133 insertions(+), 1035 deletions(-) diff --git a/test/algorithms/distance_areal_areal.cpp b/test/algorithms/distance_areal_areal.cpp index 8e9a35fce..e46e8c54c 100644 --- a/test/algorithms/distance_areal_areal.cpp +++ b/test/algorithms/distance_areal_areal.cpp @@ -41,24 +41,24 @@ void test_distance_polygon_polygon(Strategy const& strategy) std::cout << std::endl; std::cout << "polygon/polygon distance tests" << std::endl; #endif - test_distance_of_geometries tester; + typedef test_distance_of_geometries tester; - tester("polygon((-10 -10,10 -10,10 10,-10 10,-10 -10))", - "polygon((-5 20,5 20,5 25,-5 25,-5 20))", - 10, 100, strategy); + tester::apply("polygon((-10 -10,10 -10,10 10,-10 10,-10 -10))", + "polygon((-5 20,5 20,5 25,-5 25,-5 20))", + 10, 100, strategy); - tester("polygon((-10 -10,10 -10,10 10,-10 10,-10 -10))", - "polygon((-5 20,-5 5,5 5,5 20,-5 20))", - 0, 0, strategy); + tester::apply("polygon((-10 -10,10 -10,10 10,-10 10,-10 -10))", + "polygon((-5 20,-5 5,5 5,5 20,-5 20))", + 0, 0, strategy); - tester("polygon((-10 -10,10 -10,10 10,-10 10,-10 -10))", - "polygon((-5 20,-5 -20,5 -20,5 20,-5 20))", - 0, 0, strategy); + tester::apply("polygon((-10 -10,10 -10,10 10,-10 10,-10 -10))", + "polygon((-5 20,-5 -20,5 -20,5 20,-5 20))", + 0, 0, strategy); - tester("polygon((-10 -10,10 -10,10 10,-10 10,-10 -10),\ - (-5 -5,-5 5,5 5,5 -5,-5 -5))", - "polygon((-1 -1,0 0,-1 0,-1 -1))", - 4, 16, strategy); + tester::apply("polygon((-10 -10,10 -10,10 10,-10 10,-10 -10),\ + (-5 -5,-5 5,5 5,5 -5,-5 -5))", + "polygon((-1 -1,0 0,-1 0,-1 -1))", + 4, 16, strategy); } //=========================================================================== @@ -70,17 +70,20 @@ void test_distance_polygon_multipolygon(Strategy const& strategy) std::cout << std::endl; std::cout << "polygon/multipolygon distance tests" << std::endl; #endif - test_distance_of_geometries tester; + typedef test_distance_of_geometries + < + polygon_type, multi_polygon_type + > tester; - tester("polygon((12 0,14 0,19 0,19.9 -1,12 0))", - "multipolygon(((-10 -10,10 -10,10 10,-10 10,-10 -10)),\ - ((20 -1,21 2,30 -10,20 -1)))", - 0.1, 0.01, strategy, true); + tester::apply("polygon((12 0,14 0,19 0,19.9 -1,12 0))", + "multipolygon(((-10 -10,10 -10,10 10,-10 10,-10 -10)),\ + ((20 -1,21 2,30 -10,20 -1)))", + 0.1, 0.01, strategy, true); - tester("polygon((19 0,19.9 -1,12 0,20.5 0.5,19 0))", - "multipolygon(((-10 -10,10 -10,10 10,-10 10,-10 -10)),\ - ((20 -1,21 2,30 -10,20 -1)))", - 0, 0, strategy, true); + tester::apply("polygon((19 0,19.9 -1,12 0,20.5 0.5,19 0))", + "multipolygon(((-10 -10,10 -10,10 10,-10 10,-10 -10)),\ + ((20 -1,21 2,30 -10,20 -1)))", + 0, 0, strategy, true); } //=========================================================================== @@ -92,17 +95,22 @@ void test_distance_multipolygon_multipolygon(Strategy const& strategy) std::cout << std::endl; std::cout << "multipolygon/multipolygon distance tests" << std::endl; #endif - test_distance_of_geometries tester; + typedef test_distance_of_geometries + < + multi_polygon_type, multi_polygon_type + > tester; - tester("multipolygon(((12 0,14 0,14 1,12 0)),((18 0,19 0,19.9 -1,18 0)))", - "multipolygon(((-10 -10,10 -10,10 10,-10 10,-10 -10)),\ - ((20 -1,21 2,30 -10,20 -1)))", - 0.1, 0.01, strategy); + tester::apply("multipolygon(((12 0,14 0,14 1,12 0)),\ + ((18 0,19 0,19.9 -1,18 0)))", + "multipolygon(((-10 -10,10 -10,10 10,-10 10,-10 -10)),\ + ((20 -1,21 2,30 -10,20 -1)))", + 0.1, 0.01, strategy); - tester("multipolygon(((18 0,19 0,19.9 -1,18 0)),((12 0,14 0,20.5 0.5,12 0)))", - "multipolygon(((-10 -10,10 -10,10 10,-10 10,-10 -10)),\ - ((20 -1,21 2,30 -10,20 -1)))", - 0, 0, strategy); + tester::apply("multipolygon(((18 0,19 0,19.9 -1,18 0)),\ + ((12 0,14 0,20.5 0.5,12 0)))", + "multipolygon(((-10 -10,10 -10,10 10,-10 10,-10 -10)),\ + ((20 -1,21 2,30 -10,20 -1)))", + 0, 0, strategy); } //=========================================================================== @@ -114,32 +122,32 @@ void test_distance_box_box(Strategy const& strategy) std::cout << std::endl; std::cout << "box/box distance tests" << std::endl; #endif - test_distance_of_geometries int_tester; - test_distance_of_geometries tester; + typedef test_distance_of_geometries int_tester; + typedef test_distance_of_geometries tester; - int_tester(make_box2d(5, 5, 10, 10), - make_box2d(0, 0, 1, 1), - sqrt(32.0), 32, strategy); + int_tester::apply(make_box2d(5, 5, 10, 10), + make_box2d(0, 0, 1, 1), + sqrt(32.0), 32, strategy); - tester(make_box2d(5, 5, 10, 10), - make_box2d(0, 0, 1, 1), - sqrt(32.0), 32, strategy); + tester::apply(make_box2d(5, 5, 10, 10), + make_box2d(0, 0, 1, 1), + sqrt(32.0), 32, strategy); - tester(make_box2d(3, 8, 13, 18), - make_box2d(0, 0, 5, 5), - 3, 9, strategy); + tester::apply(make_box2d(3, 8, 13, 18), + make_box2d(0, 0, 5, 5), + 3, 9, strategy); - tester(make_box2d(5, 5, 10, 10), - make_box2d(0, 0, 5, 5), - 0, 0, strategy); + tester::apply(make_box2d(5, 5, 10, 10), + make_box2d(0, 0, 5, 5), + 0, 0, strategy); - tester(make_box2d(5, 5, 10, 10), - make_box2d(0, 0, 6, 6), - 0, 0, strategy); + tester::apply(make_box2d(5, 5, 10, 10), + make_box2d(0, 0, 6, 6), + 0, 0, strategy); - tester(make_box2d(3, 5, 13, 15), - make_box2d(0, 0, 5, 5), - 0, 0, strategy); + tester::apply(make_box2d(3, 5, 13, 15), + make_box2d(0, 0, 5, 5), + 0, 0, strategy); } //=========================================================================== @@ -151,27 +159,27 @@ void test_distance_polygon_box(Strategy const& strategy) std::cout << std::endl; std::cout << "polygon/box distance tests" << std::endl; #endif - test_distance_of_geometries tester; + typedef test_distance_of_geometries tester; - tester("polygon((10 10,10 5,5 5,5 10,10 10))", - make_box2d(0, 0, 1, 1), - sqrt(32.0), 32, strategy); + tester::apply("polygon((10 10,10 5,5 5,5 10,10 10))", + make_box2d(0, 0, 1, 1), + sqrt(32.0), 32, strategy); - tester("polygon((10 10,10 5,5 5,5 10,10 10))", - make_box2d(0, 0, 5, 5), - 0, 0, strategy); + tester::apply("polygon((10 10,10 5,5 5,5 10,10 10))", + make_box2d(0, 0, 5, 5), + 0, 0, strategy); - tester("polygon((10 10,10 5,5 5,5 10,10 10))", - make_box2d(0, 0, 6, 6), - 0, 0, strategy); + tester::apply("polygon((10 10,10 5,5 5,5 10,10 10))", + make_box2d(0, 0, 6, 6), + 0, 0, strategy); - tester("polygon((10 10,15 5,10 0,5 5,10 10))", - make_box2d(5, 0, 7.5, 2.5), - 0, 0, strategy); + tester::apply("polygon((10 10,15 5,10 0,5 5,10 10))", + make_box2d(5, 0, 7.5, 2.5), + 0, 0, strategy); - tester("polygon((10 10,15 5,10 0,5 5,10 10))", - make_box2d(5, 0, 6, 1), - sqrt(4.5), 4.5, strategy); + tester::apply("polygon((10 10,15 5,10 0,5 5,10 10))", + make_box2d(5, 0, 6, 1), + sqrt(4.5), 4.5, strategy); } //=========================================================================== @@ -183,22 +191,22 @@ void test_distance_multipolygon_box(Strategy const& strategy) std::cout << std::endl; std::cout << "multipolygon/box distance tests" << std::endl; #endif - test_distance_of_geometries tester; + typedef test_distance_of_geometries tester; - tester("multipolygon(((-10 -10,-10 -9,-9 -9,-9 -10,-10 -10)),\ - ((2 2,2 3,3 3,3 2,2 2)))", - make_box2d(0, 0, 1, 1), - sqrt(2.0), 2, strategy); + tester::apply("multipolygon(((-10 -10,-10 -9,-9 -9,-9 -10,-10 -10)),\ + ((2 2,2 3,3 3,3 2,2 2)))", + make_box2d(0, 0, 1, 1), + sqrt(2.0), 2, strategy); - tester("multipolygon(((-10 -10,-10 -9,-9 -9,-9 -10,-10 -10)),\ - ((2 2,2 3,3 3,3 2,2 2)))", - make_box2d(0, 0, 2, 2), - 0, 0, strategy); + tester::apply("multipolygon(((-10 -10,-10 -9,-9 -9,-9 -10,-10 -10)),\ + ((2 2,2 3,3 3,3 2,2 2)))", + make_box2d(0, 0, 2, 2), + 0, 0, strategy); - tester("multipolygon(((-10 -10,-10 -9,-9 -9,-9 -10,-10 -10)),\ - ((2 2,2 3,3 3,3 2,2 2)))", - make_box2d(0, 0, 2.5, 2), - 0, 0, strategy); + tester::apply("multipolygon(((-10 -10,-10 -9,-9 -9,-9 -10,-10 -10)),\ + ((2 2,2 3,3 3,3 2,2 2)))", + make_box2d(0, 0, 2.5, 2), + 0, 0, strategy); } //=========================================================================== diff --git a/test/algorithms/distance_linear_areal.cpp b/test/algorithms/distance_linear_areal.cpp index 8d1fe9884..e00f3f288 100644 --- a/test/algorithms/distance_linear_areal.cpp +++ b/test/algorithms/distance_linear_areal.cpp @@ -45,23 +45,23 @@ void test_distance_segment_polygon(Strategy const& strategy) std::cout << std::endl; std::cout << "segment/polygon distance tests" << std::endl; #endif - test_distance_of_geometries tester; + typedef test_distance_of_geometries tester; - tester(make_segment(-1, 20, 1, 20), - "polygon((-10 -10,10 -10,10 10,-10 10,-10 -10))", - 10, 100, strategy); + tester::apply(make_segment(-1, 20, 1, 20), + "polygon((-10 -10,10 -10,10 10,-10 10,-10 -10))", + 10, 100, strategy); - tester(make_segment(1, 20, 2, 40), - "polygon((-10 -10,10 -10,10 10,-10 10,-10 -10))", - 10, 100, strategy); + tester::apply(make_segment(1, 20, 2, 40), + "polygon((-10 -10,10 -10,10 10,-10 10,-10 -10))", + 10, 100, strategy); - tester(make_segment(-1, 20, -1, 5), - "polygon((-10 -10,10 -10,10 10,-10 10,-10 -10))", - 0, 0, strategy); + tester::apply(make_segment(-1, 20, -1, 5), + "polygon((-10 -10,10 -10,10 10,-10 10,-10 -10))", + 0, 0, strategy); - tester(make_segment(-1, 20, -1, -20), - "polygon((-10 -10,10 -10,10 10,-10 10,-10 -10))", - 0, 0, strategy); + tester::apply(make_segment(-1, 20, -1, -20), + "polygon((-10 -10,10 -10,10 10,-10 10,-10 -10))", + 0, 0, strategy); } //=========================================================================== @@ -73,19 +73,19 @@ void test_distance_linestring_polygon(Strategy const& strategy) std::cout << std::endl; std::cout << "linestring/polygon distance tests" << std::endl; #endif - test_distance_of_geometries tester; + typedef test_distance_of_geometries tester; - tester("linestring(-1 20,1 20,1 30)", - "polygon((-10 -10,10 -10,10 10,-10 10,-10 -10))", - 10, 100, strategy, true); + tester::apply("linestring(-1 20,1 20,1 30)", + "polygon((-10 -10,10 -10,10 10,-10 10,-10 -10))", + 10, 100, strategy, true); - tester("linestring(-1 20,1 20,1 5)", - "polygon((-10 -10,10 -10,10 10,-10 10,-10 -10))", - 0, 0, strategy, true); + tester::apply("linestring(-1 20,1 20,1 5)", + "polygon((-10 -10,10 -10,10 10,-10 10,-10 -10))", + 0, 0, strategy, true); - tester("linestring(-1 20,1 20,1 -20)", - "polygon((-10 -10,10 -10,10 10,-10 10,-10 -10))", - 0, 0, strategy, true); + tester::apply("linestring(-1 20,1 20,1 -20)", + "polygon((-10 -10,10 -10,10 10,-10 10,-10 -10))", + 0, 0, strategy, true); } //=========================================================================== @@ -97,19 +97,22 @@ void test_distance_multilinestring_polygon(Strategy const& strategy) std::cout << std::endl; std::cout << "multilinestring/polygon distance tests" << std::endl; #endif - test_distance_of_geometries tester; + typedef test_distance_of_geometries + < + multi_linestring_type, polygon_type + > tester; - tester("multilinestring((-100 -100,-90 -90),(-1 20,1 20,1 30))", - "polygon((-10 -10,10 -10,10 10,-10 10,-10 -10))", - 10, 100, strategy, true); + tester::apply("multilinestring((-100 -100,-90 -90),(-1 20,1 20,1 30))", + "polygon((-10 -10,10 -10,10 10,-10 10,-10 -10))", + 10, 100, strategy, true); - tester("multilinestring((-1 20,1 20,1 30),(-1 20,1 20,1 5))", - "polygon((-10 -10,10 -10,10 10,-10 10,-10 -10))", - 0, 0, strategy, true); + tester::apply("multilinestring((-1 20,1 20,1 30),(-1 20,1 20,1 5))", + "polygon((-10 -10,10 -10,10 10,-10 10,-10 -10))", + 0, 0, strategy, true); - tester("multilinestring((-1 20,1 20,1 30),(-1 20,1 20,1 -20))", - "polygon((-10 -10,10 -10,10 10,-10 10,-10 -10))", - 0, 0, strategy, true); + tester::apply("multilinestring((-1 20,1 20,1 30),(-1 20,1 20,1 -20))", + "polygon((-10 -10,10 -10,10 10,-10 10,-10 -10))", + 0, 0, strategy, true); } //=========================================================================== @@ -121,27 +124,30 @@ void test_distance_segment_multipolygon(Strategy const& strategy) std::cout << std::endl; std::cout << "segment/multipolygon distance tests" << std::endl; #endif - test_distance_of_geometries tester; + typedef test_distance_of_geometries + < + segment_type, multi_polygon_type + > tester; - tester(make_segment(-1, 20, 1, 20), - "multipolygon(((-10 -10,10 -10,10 10,-10 10,-10 -10)),\ - ((0 22,-1 30, 2 40,0 22)))", - 2, 4, strategy); + tester::apply(make_segment(-1, 20, 1, 20), + "multipolygon(((-10 -10,10 -10,10 10,-10 10,-10 -10)),\ + ((0 22,-1 30, 2 40,0 22)))", + 2, 4, strategy); - tester(make_segment(12, 0, 14, 0), - "multipolygon(((-10 -10,10 -10,10 10,-10 10,-10 -10)),\ - ((20 -1,21 2,30 -10,20 -1)))", - 2, 4, strategy); + tester::apply(make_segment(12, 0, 14, 0), + "multipolygon(((-10 -10,10 -10,10 10,-10 10,-10 -10)),\ + ((20 -1,21 2,30 -10,20 -1)))", + 2, 4, strategy); - tester(make_segment(12, 0, 20.5, 0.5), - "multipolygon(((-10 -10,10 -10,10 10,-10 10,-10 -10)),\ - ((20 -1,21 2,30 -10,20 -1)))", - 0, 0, strategy); + tester::apply(make_segment(12, 0, 20.5, 0.5), + "multipolygon(((-10 -10,10 -10,10 10,-10 10,-10 -10)),\ + ((20 -1,21 2,30 -10,20 -1)))", + 0, 0, strategy); - tester(make_segment(12, 0, 50, 0), - "multipolygon(((-10 -10,10 -10,10 10,-10 10,-10 -10)),\ - ((20 -1,21 2,30 -10,20 -1)))", - 0, 0, strategy); + tester::apply(make_segment(12, 0, 50, 0), + "multipolygon(((-10 -10,10 -10,10 10,-10 10,-10 -10)),\ + ((20 -1,21 2,30 -10,20 -1)))", + 0, 0, strategy); } //=========================================================================== @@ -153,27 +159,30 @@ void test_distance_linestring_multipolygon(Strategy const& strategy) std::cout << std::endl; std::cout << "linestring/multipolygon distance tests" << std::endl; #endif - test_distance_of_geometries tester; + typedef test_distance_of_geometries + < + linestring_type, multi_polygon_type + > tester; - tester("linestring(-1 20,1 20)", - "multipolygon(((-10 -10,10 -10,10 10,-10 10,-10 -10)),\ - ((0 22,-1 30, 2 40,0 22)))", - 2, 4, strategy, true); + tester::apply("linestring(-1 20,1 20)", + "multipolygon(((-10 -10,10 -10,10 10,-10 10,-10 -10)),\ + ((0 22,-1 30, 2 40,0 22)))", + 2, 4, strategy, true); - tester("linestring(12 0,14 0)", - "multipolygon(((-10 -10,10 -10,10 10,-10 10,-10 -10)),\ - ((20 -1,21 2,30 -10,20 -1)))", - 2, 4, strategy, true); + tester::apply("linestring(12 0,14 0)", + "multipolygon(((-10 -10,10 -10,10 10,-10 10,-10 -10)),\ + ((20 -1,21 2,30 -10,20 -1)))", + 2, 4, strategy, true); - tester("linestring(12 0,20.5 0.5)", - "multipolygon(((-10 -10,10 -10,10 10,-10 10,-10 -10)),\ - ((20 -1,21 2,30 -10,20 -1)))", - 0, 0, strategy, true); + tester::apply("linestring(12 0,20.5 0.5)", + "multipolygon(((-10 -10,10 -10,10 10,-10 10,-10 -10)),\ + ((20 -1,21 2,30 -10,20 -1)))", + 0, 0, strategy, true); - tester("linestring(12 0,50 0)", - "multipolygon(((-10 -10,10 -10,10 10,-10 10,-10 -10)),\ - ((20 -1,21 2,30 -10,20 -1)))", - 0, 0, strategy, true); + tester::apply("linestring(12 0,50 0)", + "multipolygon(((-10 -10,10 -10,10 10,-10 10,-10 -10)),\ + ((20 -1,21 2,30 -10,20 -1)))", + 0, 0, strategy, true); } //=========================================================================== @@ -185,20 +194,20 @@ void test_distance_multilinestring_multipolygon(Strategy const& strategy) std::cout << std::endl; std::cout << "multilinestring/multipolygon distance tests" << std::endl; #endif - test_distance_of_geometries + typedef test_distance_of_geometries < multi_linestring_type, multi_polygon_type > tester; - tester("multilinestring((12 0,14 0),(19 0,19.9 -1))", - "multipolygon(((-10 -10,10 -10,10 10,-10 10,-10 -10)),\ - ((20 -1,21 2,30 -10)))", - 0.1, 0.01, strategy, true); + tester::apply("multilinestring((12 0,14 0),(19 0,19.9 -1))", + "multipolygon(((-10 -10,10 -10,10 10,-10 10,-10 -10)),\ + ((20 -1,21 2,30 -10)))", + 0.1, 0.01, strategy, true); - tester("multilinestring((19 0,19.9 -1),(12 0,20.5 0.5))", - "multipolygon(((-10 -10,10 -10,10 10,-10 10,-10 -10)),\ - ((20 -1,21 2,30 -10,20 -1)))", - 0, 0, strategy, true); + tester::apply("multilinestring((19 0,19.9 -1),(12 0,20.5 0.5))", + "multipolygon(((-10 -10,10 -10,10 10,-10 10,-10 -10)),\ + ((20 -1,21 2,30 -10,20 -1)))", + 0, 0, strategy, true); } //=========================================================================== @@ -214,419 +223,419 @@ void test_distance_segment_box(Strategy const& strategy) typedef segment_type S; typedef int_segment_type IS; - test_distance_of_geometries tester; - test_distance_of_geometries itester; + typedef test_distance_of_geometries tester; + typedef test_distance_of_geometries itester; // segments that intersect the box - tester(make_box2d(0, 0, 1, 1), - make_segment(-1, 0.5, 0.5, 0.75), - 0, 0, strategy); - tester(make_box2d(0, 0, 1, 1), - make_segment(-1, 0.5, 1.5, 0.75), - 0, 0, strategy); - tester(make_box2d(0, 0, 1, 1), - make_segment(0.5, -1, 0.5, 2), - 0, 0, strategy); - tester(make_box2d(0, 0, 1, 1), - make_segment(1, 1, 1.5, 0.75), - 0, 0, strategy); - tester(make_box2d(0, 0, 1, 1), - make_segment(2, 0, 0, 2), - 0, 0, strategy); + tester::apply(make_box2d(0, 0, 1, 1), + make_segment(-1, 0.5, 0.5, 0.75), + 0, 0, strategy); + tester::apply(make_box2d(0, 0, 1, 1), + make_segment(-1, 0.5, 1.5, 0.75), + 0, 0, strategy); + tester::apply(make_box2d(0, 0, 1, 1), + make_segment(0.5, -1, 0.5, 2), + 0, 0, strategy); + tester::apply(make_box2d(0, 0, 1, 1), + make_segment(1, 1, 1.5, 0.75), + 0, 0, strategy); + tester::apply(make_box2d(0, 0, 1, 1), + make_segment(2, 0, 0, 2), + 0, 0, strategy); // segment that has closest point on box boundary - tester(make_box2d(0, 0, 1, 1), - make_segment(4, 0.5, 5, 0.75), - 3, 9, strategy); + tester::apply(make_box2d(0, 0, 1, 1), + make_segment(4, 0.5, 5, 0.75), + 3, 9, strategy); // segment that has closest point on box corner - tester(make_box2d(0, 0, 1, 1), - make_segment(4, 0, 0, 4), - sqrt(2), 2, strategy); - itester(make_box2d(0, 0, 1, 1), - make_segment(-4, 0, 0, -4), - sqrt(8), 8, strategy); - itester(make_box2d(0, 0, 1, 1), - make_segment(-8, 4, 4, -8), - sqrt(8), 8, strategy); - tester(make_box2d(0, 0, 1, 1), - make_segment(-4, 0, 0, 4), - 1.5 * sqrt(2), 4.5, strategy); - tester(make_box2d(0, 0, 1, 1), - make_segment(-4, 0, 1, 5), - 1.5 * sqrt(2), 4.5, strategy); - itester(make_box2d(0, 0, 1, 1), - make_segment(0, -2, 3, 1), - 0.5 * sqrt(2), 0.5, strategy); - itester(make_box2d(0, 0, 1, 1), - make_segment(0, -2, 2, 2), - 0, 0, strategy); + tester::apply(make_box2d(0, 0, 1, 1), + make_segment(4, 0, 0, 4), + sqrt(2), 2, strategy); + itester::apply(make_box2d(0, 0, 1, 1), + make_segment(-4, 0, 0, -4), + sqrt(8), 8, strategy); + itester::apply(make_box2d(0, 0, 1, 1), + make_segment(-8, 4, 4, -8), + sqrt(8), 8, strategy); + tester::apply(make_box2d(0, 0, 1, 1), + make_segment(-4, 0, 0, 4), + 1.5 * sqrt(2), 4.5, strategy); + tester::apply(make_box2d(0, 0, 1, 1), + make_segment(-4, 0, 1, 5), + 1.5 * sqrt(2), 4.5, strategy); + itester::apply(make_box2d(0, 0, 1, 1), + make_segment(0, -2, 3, 1), + 0.5 * sqrt(2), 0.5, strategy); + itester::apply(make_box2d(0, 0, 1, 1), + make_segment(0, -2, 2, 2), + 0, 0, strategy); // horizontal segments - itester(make_box2d(0, 0, 1, 1), - make_segment(-2, -1, -1, -1), - sqrt(2), 2, strategy); - itester(make_box2d(0, 0, 1, 1), - make_segment(-1, -1, 0, -1), - 1, 1, strategy); - tester(make_box2d(0, 0, 1, 1), - make_segment(-0.5, -1, 0.5, -1), - 1, 1, strategy); - tester(make_box2d(0, 0, 1, 1), - make_segment(0.5, -1, 0.75, -1), - 1, 1, strategy); - tester(make_box2d(0, 0, 1, 1), - make_segment(0.5, -1, 1.25, -1), - 1, 1, strategy); - tester(make_box2d(0, 0, 1, 1), - make_segment(1, -1, 2, -1), - 1, 1, strategy); - tester(make_box2d(0, 0, 1, 1), - make_segment(2, -1, 3, -1), - sqrt(2), 2, strategy); - tester(make_box2d(0, 0, 1, 1), - make_segment(-2, -1, 2, -1), - 1, 1, strategy); + itester::apply(make_box2d(0, 0, 1, 1), + make_segment(-2, -1, -1, -1), + sqrt(2), 2, strategy); + itester::apply(make_box2d(0, 0, 1, 1), + make_segment(-1, -1, 0, -1), + 1, 1, strategy); + tester::apply(make_box2d(0, 0, 1, 1), + make_segment(-0.5, -1, 0.5, -1), + 1, 1, strategy); + tester::apply(make_box2d(0, 0, 1, 1), + make_segment(0.5, -1, 0.75, -1), + 1, 1, strategy); + tester::apply(make_box2d(0, 0, 1, 1), + make_segment(0.5, -1, 1.25, -1), + 1, 1, strategy); + tester::apply(make_box2d(0, 0, 1, 1), + make_segment(1, -1, 2, -1), + 1, 1, strategy); + tester::apply(make_box2d(0, 0, 1, 1), + make_segment(2, -1, 3, -1), + sqrt(2), 2, strategy); + tester::apply(make_box2d(0, 0, 1, 1), + make_segment(-2, -1, 2, -1), + 1, 1, strategy); - tester(make_box2d(0, 0, 1, 1), - make_segment(-2, 0, -1, 0), - 1, 1, strategy); - tester(make_box2d(0, 0, 1, 1), - make_segment(-1, 0, 0, 0), - 0, 0, strategy); - tester(make_box2d(0, 0, 1, 1), - make_segment(-0.5, 0, 0.5, 0), - 0, 0, strategy); - tester(make_box2d(0, 0, 1, 1), - make_segment(0.5, 0, 0.75, 0), - 0, 0, strategy); - tester(make_box2d(0, 0, 1, 1), - make_segment(0.5, 0, 1.25, 0), - 0, 0, strategy); - tester(make_box2d(0, 0, 1, 1), - make_segment(1, 0, 2, 0), - 0, 0, strategy); - tester(make_box2d(0, 0, 1, 1), - make_segment(2, 0, 3, 0), - 1, 1, strategy); - tester(make_box2d(0, 0, 1, 1), - make_segment(-2, 0, 2, 0), - 0, 0, strategy); + tester::apply(make_box2d(0, 0, 1, 1), + make_segment(-2, 0, -1, 0), + 1, 1, strategy); + tester::apply(make_box2d(0, 0, 1, 1), + make_segment(-1, 0, 0, 0), + 0, 0, strategy); + tester::apply(make_box2d(0, 0, 1, 1), + make_segment(-0.5, 0, 0.5, 0), + 0, 0, strategy); + tester::apply(make_box2d(0, 0, 1, 1), + make_segment(0.5, 0, 0.75, 0), + 0, 0, strategy); + tester::apply(make_box2d(0, 0, 1, 1), + make_segment(0.5, 0, 1.25, 0), + 0, 0, strategy); + tester::apply(make_box2d(0, 0, 1, 1), + make_segment(1, 0, 2, 0), + 0, 0, strategy); + tester::apply(make_box2d(0, 0, 1, 1), + make_segment(2, 0, 3, 0), + 1, 1, strategy); + tester::apply(make_box2d(0, 0, 1, 1), + make_segment(-2, 0, 2, 0), + 0, 0, strategy); - tester(make_box2d(0, 0, 1, 1), - make_segment(-2, 0.5, -1, 0.5), - 1, 1, strategy); - tester(make_box2d(0, 0, 1, 1), - make_segment(-1, 0.5, 0, 0.5), - 0, 0, strategy); - tester(make_box2d(0, 0, 1, 1), - make_segment(-0.5, 0.5, 0.5, 0.5), - 0, 0, strategy); - tester(make_box2d(0, 0, 1, 1), - make_segment(0.5, 0.5, 0.75, 0.5), - 0, 0, strategy); - tester(make_box2d(0, 0, 1, 1), - make_segment(0.5, 0.5, 1.25, 0.5), - 0, 0, strategy); - tester(make_box2d(0, 0, 1, 1), - make_segment(1, 0.5, 2, 0.5), - 0, 0, strategy); - tester(make_box2d(0, 0, 1, 1), - make_segment(2, 0.5, 3, 0.5), - 1, 1, strategy); - tester(make_box2d(0, 0, 1, 1), - make_segment(-2, 0.5, 2, 0.5), - 0, 0, strategy); + tester::apply(make_box2d(0, 0, 1, 1), + make_segment(-2, 0.5, -1, 0.5), + 1, 1, strategy); + tester::apply(make_box2d(0, 0, 1, 1), + make_segment(-1, 0.5, 0, 0.5), + 0, 0, strategy); + tester::apply(make_box2d(0, 0, 1, 1), + make_segment(-0.5, 0.5, 0.5, 0.5), + 0, 0, strategy); + tester::apply(make_box2d(0, 0, 1, 1), + make_segment(0.5, 0.5, 0.75, 0.5), + 0, 0, strategy); + tester::apply(make_box2d(0, 0, 1, 1), + make_segment(0.5, 0.5, 1.25, 0.5), + 0, 0, strategy); + tester::apply(make_box2d(0, 0, 1, 1), + make_segment(1, 0.5, 2, 0.5), + 0, 0, strategy); + tester::apply(make_box2d(0, 0, 1, 1), + make_segment(2, 0.5, 3, 0.5), + 1, 1, strategy); + tester::apply(make_box2d(0, 0, 1, 1), + make_segment(-2, 0.5, 2, 0.5), + 0, 0, strategy); - tester(make_box2d(0, 0, 1, 1), - make_segment(-2, 1, -1, 1), - 1, 1, strategy); - tester(make_box2d(0, 0, 1, 1), - make_segment(-1, 1, 0, 1), - 0, 0, strategy); - tester(make_box2d(0, 0, 1, 1), - make_segment(-0.5, 1, 0.5, 1), - 0, 0, strategy); - tester(make_box2d(0, 0, 1, 1), - make_segment(0.5, 1, 0.75, 1), - 0, 0, strategy); - tester(make_box2d(0, 0, 1, 1), - make_segment(0.5, 1, 1.25, 1), - 0, 0, strategy); - tester(make_box2d(0, 0, 1, 1), - make_segment(1, 1, 2, 1), - 0, 0, strategy); - tester(make_box2d(0, 0, 1, 1), - make_segment(2, 1, 3, 1), - 1, 1, strategy); - tester(make_box2d(0, 0, 1, 1), - make_segment(-2, 1, 2, 1), - 0, 0, strategy); + tester::apply(make_box2d(0, 0, 1, 1), + make_segment(-2, 1, -1, 1), + 1, 1, strategy); + tester::apply(make_box2d(0, 0, 1, 1), + make_segment(-1, 1, 0, 1), + 0, 0, strategy); + tester::apply(make_box2d(0, 0, 1, 1), + make_segment(-0.5, 1, 0.5, 1), + 0, 0, strategy); + tester::apply(make_box2d(0, 0, 1, 1), + make_segment(0.5, 1, 0.75, 1), + 0, 0, strategy); + tester::apply(make_box2d(0, 0, 1, 1), + make_segment(0.5, 1, 1.25, 1), + 0, 0, strategy); + tester::apply(make_box2d(0, 0, 1, 1), + make_segment(1, 1, 2, 1), + 0, 0, strategy); + tester::apply(make_box2d(0, 0, 1, 1), + make_segment(2, 1, 3, 1), + 1, 1, strategy); + tester::apply(make_box2d(0, 0, 1, 1), + make_segment(-2, 1, 2, 1), + 0, 0, strategy); - tester(make_box2d(0, 0, 1, 1), - make_segment(-2, 3, -1, 3), - sqrt(5), 5, strategy); - itester(make_box2d(0, 0, 1, 1), - make_segment(-1, 3, 0, 3), - 2, 4, strategy); - tester(make_box2d(0, 0, 1, 1), - make_segment(-0.5, 3, 0.5, 3), - 2, 4, strategy); - tester(make_box2d(0, 0, 1, 1), - make_segment(0.5, 3, 0.75, 3), - 2, 4, strategy); - tester(make_box2d(0, 0, 1, 1), - make_segment(0.5, 3, 1.25, 3), - 2, 4, strategy); - tester(make_box2d(0, 0, 1, 1), - make_segment(1, 3, 2, 3), - 2, 4, strategy); - tester(make_box2d(0, 0, 1, 1), - make_segment(2, 3, 3, 3), - sqrt(5), 5, strategy); - tester(make_box2d(0, 0, 1, 1), - make_segment(-2, 3, 2, 3), - 2, 4, strategy); + tester::apply(make_box2d(0, 0, 1, 1), + make_segment(-2, 3, -1, 3), + sqrt(5), 5, strategy); + itester::apply(make_box2d(0, 0, 1, 1), + make_segment(-1, 3, 0, 3), + 2, 4, strategy); + tester::apply(make_box2d(0, 0, 1, 1), + make_segment(-0.5, 3, 0.5, 3), + 2, 4, strategy); + tester::apply(make_box2d(0, 0, 1, 1), + make_segment(0.5, 3, 0.75, 3), + 2, 4, strategy); + tester::apply(make_box2d(0, 0, 1, 1), + make_segment(0.5, 3, 1.25, 3), + 2, 4, strategy); + tester::apply(make_box2d(0, 0, 1, 1), + make_segment(1, 3, 2, 3), + 2, 4, strategy); + tester::apply(make_box2d(0, 0, 1, 1), + make_segment(2, 3, 3, 3), + sqrt(5), 5, strategy); + tester::apply(make_box2d(0, 0, 1, 1), + make_segment(-2, 3, 2, 3), + 2, 4, strategy); // vertical segments - tester(make_box2d(0, 0, 1, 1), - make_segment(-1, -2, -1, -1), - sqrt(2), 2, strategy); - tester(make_box2d(0, 0, 1, 1), - make_segment(-1, -1, -1, 0), - 1, 1, strategy); - tester(make_box2d(0, 0, 1, 1), - make_segment(-1, -0.5, -1, 0.5), - 1, 1, strategy); - tester(make_box2d(0, 0, 1, 1), - make_segment(-1, 0.5, -1, 0.75), - 1, 1, strategy); - tester(make_box2d(0, 0, 1, 1), - make_segment(-1, 0.5, -1, 1.25), - 1, 1, strategy); - tester(make_box2d(0, 0, 1, 1), - make_segment(-1, 1, -1, 2), - 1, 1, strategy); - tester(make_box2d(0, 0, 1, 1), - make_segment(-1, 2, -1, 3), - sqrt(2), 2, strategy); - tester(make_box2d(0, 0, 1, 1), - make_segment(-1, -2, -1, 2), - 1, 1, strategy); + tester::apply(make_box2d(0, 0, 1, 1), + make_segment(-1, -2, -1, -1), + sqrt(2), 2, strategy); + tester::apply(make_box2d(0, 0, 1, 1), + make_segment(-1, -1, -1, 0), + 1, 1, strategy); + tester::apply(make_box2d(0, 0, 1, 1), + make_segment(-1, -0.5, -1, 0.5), + 1, 1, strategy); + tester::apply(make_box2d(0, 0, 1, 1), + make_segment(-1, 0.5, -1, 0.75), + 1, 1, strategy); + tester::apply(make_box2d(0, 0, 1, 1), + make_segment(-1, 0.5, -1, 1.25), + 1, 1, strategy); + tester::apply(make_box2d(0, 0, 1, 1), + make_segment(-1, 1, -1, 2), + 1, 1, strategy); + tester::apply(make_box2d(0, 0, 1, 1), + make_segment(-1, 2, -1, 3), + sqrt(2), 2, strategy); + tester::apply(make_box2d(0, 0, 1, 1), + make_segment(-1, -2, -1, 2), + 1, 1, strategy); - tester(make_box2d(0, 0, 1, 1), - make_segment(0, -2, 0, -1), - 1, 1, strategy); - tester(make_box2d(0, 0, 1, 1), - make_segment(0, -1, 0, 0), - 0, 0, strategy); - tester(make_box2d(0, 0, 1, 1), - make_segment(0, -0.5, 0, 0.5), - 0, 0, strategy); - tester(make_box2d(0, 0, 1, 1), - make_segment(0, 0.5, 0, 0.75), - 0, 0, strategy); - tester(make_box2d(0, 0, 1, 1), - make_segment(0, 0.5, 0, 1.25), - 0, 0, strategy); - tester(make_box2d(0, 0, 1, 1), - make_segment(0, 1, 0, 2), - 0, 0, strategy); - tester(make_box2d(0, 0, 1, 1), - make_segment(0, 2, 0, 3), - 1, 1, strategy); - tester(make_box2d(0, 0, 1, 1), - make_segment(0, -2, 0, 2), - 0, 0, strategy); + tester::apply(make_box2d(0, 0, 1, 1), + make_segment(0, -2, 0, -1), + 1, 1, strategy); + tester::apply(make_box2d(0, 0, 1, 1), + make_segment(0, -1, 0, 0), + 0, 0, strategy); + tester::apply(make_box2d(0, 0, 1, 1), + make_segment(0, -0.5, 0, 0.5), + 0, 0, strategy); + tester::apply(make_box2d(0, 0, 1, 1), + make_segment(0, 0.5, 0, 0.75), + 0, 0, strategy); + tester::apply(make_box2d(0, 0, 1, 1), + make_segment(0, 0.5, 0, 1.25), + 0, 0, strategy); + tester::apply(make_box2d(0, 0, 1, 1), + make_segment(0, 1, 0, 2), + 0, 0, strategy); + tester::apply(make_box2d(0, 0, 1, 1), + make_segment(0, 2, 0, 3), + 1, 1, strategy); + tester::apply(make_box2d(0, 0, 1, 1), + make_segment(0, -2, 0, 2), + 0, 0, strategy); - tester(make_box2d(0, 0, 1, 1), - make_segment(0.5, -2, 0.5, -1), - 1, 1, strategy); - tester(make_box2d(0, 0, 1, 1), - make_segment(0.5, -1, 0.5, 0), - 0, 0, strategy); - tester(make_box2d(0, 0, 1, 1), - make_segment(0.5, -0.5, 0.5, 0.5), - 0, 0, strategy); - tester(make_box2d(0, 0, 1, 1), - make_segment(0.5, 0.5, 0.5, 0.75), - 0, 0, strategy); - tester(make_box2d(0, 0, 1, 1), - make_segment(0.5, 0.5, 0.5, 1.25), - 0, 0, strategy); - tester(make_box2d(0, 0, 1, 1), - make_segment(0.5, 1, 0.5, 2), - 0, 0, strategy); - tester(make_box2d(0, 0, 1, 1), - make_segment(0.5, 2, 0.5, 3), - 1, 1, strategy); - tester(make_box2d(0, 0, 1, 1), - make_segment(0.5, -2, 0.5, 2), - 0, 0, strategy); + tester::apply(make_box2d(0, 0, 1, 1), + make_segment(0.5, -2, 0.5, -1), + 1, 1, strategy); + tester::apply(make_box2d(0, 0, 1, 1), + make_segment(0.5, -1, 0.5, 0), + 0, 0, strategy); + tester::apply(make_box2d(0, 0, 1, 1), + make_segment(0.5, -0.5, 0.5, 0.5), + 0, 0, strategy); + tester::apply(make_box2d(0, 0, 1, 1), + make_segment(0.5, 0.5, 0.5, 0.75), + 0, 0, strategy); + tester::apply(make_box2d(0, 0, 1, 1), + make_segment(0.5, 0.5, 0.5, 1.25), + 0, 0, strategy); + tester::apply(make_box2d(0, 0, 1, 1), + make_segment(0.5, 1, 0.5, 2), + 0, 0, strategy); + tester::apply(make_box2d(0, 0, 1, 1), + make_segment(0.5, 2, 0.5, 3), + 1, 1, strategy); + tester::apply(make_box2d(0, 0, 1, 1), + make_segment(0.5, -2, 0.5, 2), + 0, 0, strategy); - tester(make_box2d(0, 0, 1, 1), - make_segment(1, -2, 1, -1), - 1, 1, strategy); - tester(make_box2d(0, 0, 1, 1), - make_segment(1, -1, 1, 0), - 0, 0, strategy); - tester(make_box2d(0, 0, 1, 1), - make_segment(1, -0.5, 1, 0.5), - 0, 0, strategy); - tester(make_box2d(0, 0, 1, 1), - make_segment(1, 0.5, 1, 0.75), - 0, 0, strategy); - tester(make_box2d(0, 0, 1, 1), - make_segment(1, 0.5, 1, 1.25), - 0, 0, strategy); - tester(make_box2d(0, 0, 1, 1), - make_segment(1, 1, 1, 2), - 0, 0, strategy); - tester(make_box2d(0, 0, 1, 1), - make_segment(1, 2, 1, 3), - 1, 1, strategy); - tester(make_box2d(0, 0, 1, 1), - make_segment(1, -2, 1, 2), - 0, 0, strategy); + tester::apply(make_box2d(0, 0, 1, 1), + make_segment(1, -2, 1, -1), + 1, 1, strategy); + tester::apply(make_box2d(0, 0, 1, 1), + make_segment(1, -1, 1, 0), + 0, 0, strategy); + tester::apply(make_box2d(0, 0, 1, 1), + make_segment(1, -0.5, 1, 0.5), + 0, 0, strategy); + tester::apply(make_box2d(0, 0, 1, 1), + make_segment(1, 0.5, 1, 0.75), + 0, 0, strategy); + tester::apply(make_box2d(0, 0, 1, 1), + make_segment(1, 0.5, 1, 1.25), + 0, 0, strategy); + tester::apply(make_box2d(0, 0, 1, 1), + make_segment(1, 1, 1, 2), + 0, 0, strategy); + tester::apply(make_box2d(0, 0, 1, 1), + make_segment(1, 2, 1, 3), + 1, 1, strategy); + tester::apply(make_box2d(0, 0, 1, 1), + make_segment(1, -2, 1, 2), + 0, 0, strategy); - tester(make_box2d(0, 0, 1, 1), - make_segment(3, -2, 3, -1), - sqrt(5), 5, strategy); - tester(make_box2d(0, 0, 1, 1), - make_segment(3, -1, 3, 0), - 2, 4, strategy); - tester(make_box2d(0, 0, 1, 1), - make_segment(3, -0.5, 3, 0.5), - 2, 4, strategy); - tester(make_box2d(0, 0, 1, 1), - make_segment(3, 0.5, 3, 0.75), - 2, 4, strategy); - tester(make_box2d(0, 0, 1, 1), - make_segment(3, 0.5, 3, 1.25), - 2, 4, strategy); - tester(make_box2d(0, 0, 1, 1), - make_segment(3, 1, 3, 2), - 2, 4, strategy); - tester(make_box2d(0, 0, 1, 1), - make_segment(3, 2, 3, 3), - sqrt(5), 5, strategy); - tester(make_box2d(0, 0, 1, 1), - make_segment(3, -2, 3, 2), - 2, 4, strategy); + tester::apply(make_box2d(0, 0, 1, 1), + make_segment(3, -2, 3, -1), + sqrt(5), 5, strategy); + tester::apply(make_box2d(0, 0, 1, 1), + make_segment(3, -1, 3, 0), + 2, 4, strategy); + tester::apply(make_box2d(0, 0, 1, 1), + make_segment(3, -0.5, 3, 0.5), + 2, 4, strategy); + tester::apply(make_box2d(0, 0, 1, 1), + make_segment(3, 0.5, 3, 0.75), + 2, 4, strategy); + tester::apply(make_box2d(0, 0, 1, 1), + make_segment(3, 0.5, 3, 1.25), + 2, 4, strategy); + tester::apply(make_box2d(0, 0, 1, 1), + make_segment(3, 1, 3, 2), + 2, 4, strategy); + tester::apply(make_box2d(0, 0, 1, 1), + make_segment(3, 2, 3, 3), + sqrt(5), 5, strategy); + tester::apply(make_box2d(0, 0, 1, 1), + make_segment(3, -2, 3, 2), + 2, 4, strategy); // positive slope - itester(make_box2d(0, 0, 1, 1), - make_segment(-2, -2, -1, -1), - sqrt(2), 2, strategy); - tester(make_box2d(0, 0, 1, 1), - make_segment(-2, -2, 0, -0.5), - 0.5, 0.25, strategy); - tester(make_box2d(0, 0, 1, 1), - make_segment(-2, -2, 0.5, -0.5), - 0.5, 0.25, strategy); - tester(make_box2d(0, 0, 1, 1), - make_segment(-2, -2, 1, -0.5), - 0.5, 0.25, strategy); - tester(make_box2d(0, 0, 1, 1), - make_segment(-2, -2, 2, 0), - sqrt(0.2), 0.2, strategy); - tester(make_box2d(0, 0, 1, 1), - make_segment(-2, -2, 4, 1), - sqrt(0.2), 0.2, strategy); - tester(make_box2d(0, 0, 1, 1), - make_segment(-2, -2, -1.5, 0), - 1.5, 2.25, strategy); - tester(make_box2d(0, 0, 1, 1), - make_segment(-2, -2, -1.5, 0.5), - 1.5, 2.25, strategy); - tester(make_box2d(0, 0, 1, 1), - make_segment(-2, -2, -1.5, 1), - 1.5, 2.25, strategy); - tester(make_box2d(0, 0, 1, 1), - make_segment(-2, -2, 0, 2), - sqrt(0.2), 0.2, strategy); - tester(make_box2d(0, 0, 1, 1), - make_segment(-2, -2, 1, 4), - sqrt(0.2), 0.2, strategy); - tester(make_box2d(0, 0, 1, 1), - make_segment(-2, -2, 4, 2), - 0, 0, strategy); - tester(make_box2d(0, 0, 1, 1), - make_segment(-2, -2, 2, 4), - 0, 0, strategy); - tester(make_box2d(0, 0, 1, 1), - make_segment(-2, -2, 4, 3), - 0, 0, strategy); - tester(make_box2d(0, 0, 1, 1), - make_segment(-2, -2, 3, 4), - 0, 0, strategy); - tester(make_box2d(0, 0, 1, 1), - make_segment(-2, -2, 3, 3), - 0, 0, strategy); + itester::apply(make_box2d(0, 0, 1, 1), + make_segment(-2, -2, -1, -1), + sqrt(2), 2, strategy); + tester::apply(make_box2d(0, 0, 1, 1), + make_segment(-2, -2, 0, -0.5), + 0.5, 0.25, strategy); + tester::apply(make_box2d(0, 0, 1, 1), + make_segment(-2, -2, 0.5, -0.5), + 0.5, 0.25, strategy); + tester::apply(make_box2d(0, 0, 1, 1), + make_segment(-2, -2, 1, -0.5), + 0.5, 0.25, strategy); + tester::apply(make_box2d(0, 0, 1, 1), + make_segment(-2, -2, 2, 0), + sqrt(0.2), 0.2, strategy); + tester::apply(make_box2d(0, 0, 1, 1), + make_segment(-2, -2, 4, 1), + sqrt(0.2), 0.2, strategy); + tester::apply(make_box2d(0, 0, 1, 1), + make_segment(-2, -2, -1.5, 0), + 1.5, 2.25, strategy); + tester::apply(make_box2d(0, 0, 1, 1), + make_segment(-2, -2, -1.5, 0.5), + 1.5, 2.25, strategy); + tester::apply(make_box2d(0, 0, 1, 1), + make_segment(-2, -2, -1.5, 1), + 1.5, 2.25, strategy); + tester::apply(make_box2d(0, 0, 1, 1), + make_segment(-2, -2, 0, 2), + sqrt(0.2), 0.2, strategy); + tester::apply(make_box2d(0, 0, 1, 1), + make_segment(-2, -2, 1, 4), + sqrt(0.2), 0.2, strategy); + tester::apply(make_box2d(0, 0, 1, 1), + make_segment(-2, -2, 4, 2), + 0, 0, strategy); + tester::apply(make_box2d(0, 0, 1, 1), + make_segment(-2, -2, 2, 4), + 0, 0, strategy); + tester::apply(make_box2d(0, 0, 1, 1), + make_segment(-2, -2, 4, 3), + 0, 0, strategy); + tester::apply(make_box2d(0, 0, 1, 1), + make_segment(-2, -2, 3, 4), + 0, 0, strategy); + tester::apply(make_box2d(0, 0, 1, 1), + make_segment(-2, -2, 3, 3), + 0, 0, strategy); // negative slope - tester(make_box2d(0, 0, 1, 1), - make_segment(-2, -2, -1, -3), - sqrt(8), 8, strategy); - tester(make_box2d(0, 0, 1, 1), - make_segment(-3, -1, 0, -4), - sqrt(8), 8, strategy); - tester(make_box2d(0, 0, 1, 1), - make_segment(-2, 0.75, -1.5, 0.5), - 1.5, 2.25, strategy); - tester(make_box2d(0, 0, 1, 1), - make_segment(-2, 1.5, -1.5, 0.5), - 1.5, 2.25, strategy); - tester(make_box2d(0, 0, 1, 1), - make_segment(0.5, 2, 0.75, 1.5), - 0.5, 0.25, strategy); - tester(make_box2d(0, 0, 1, 1), - make_segment(-1, 2, 0.75, 1.5), - 0.5, 0.25, strategy); - tester(make_box2d(0, 0, 1, 1), - make_segment(0, 2, 2, 0), - 0, 0, strategy); - tester(make_box2d(0, 0, 1, 1), - make_segment(0, 3, 3, 0), - sqrt(0.5), 0.5, strategy); - tester(make_box2d(0, 0, 1, 1), - make_segment(-1, 4, 4, -1), - sqrt(0.5), 0.5, strategy); - tester(make_box2d(0, 0, 1, 1), - make_segment(-1, 4, 0, 3), - 2, 4, strategy); - tester(make_box2d(0, 0, 1, 1), - make_segment(-2, 5, -1, 4), - sqrt(10), 10, strategy); - tester(make_box2d(0, 0, 1, 1), - make_segment(3, -1, 4, -4), - sqrt(5), 5, strategy); - tester(make_box2d(0, 0, 1, 1), - make_segment(1, 2, 2, 1), - sqrt(0.5), 0.5, strategy); - tester(make_box2d(0, 0, 1, 1), - make_segment(0.5, -2, 2, -3), - 2, 4, strategy); - tester(make_box2d(0, 0, 1, 1), - make_segment(-1, -2, 0, -3), - sqrt(5), 5, strategy); - tester(make_box2d(0, 0, 1, 1), - make_segment(-1, -2, 0.5, -3.5), - sqrt(5), 5, strategy); - tester(make_box2d(0, 0, 1, 1), - make_segment(-1, -2, 0.5, -3.5), - sqrt(5), 5, strategy); - tester(make_box2d(0, 0, 1, 1), - make_segment(0.5, 3, 2.5, 2), - sqrt(2.45), 2.45, strategy); - tester(make_box2d(0, 0, 1, 1), - make_segment(0.5, 1.5, 1.5, -1.5), - 0, 0, strategy); + tester::apply(make_box2d(0, 0, 1, 1), + make_segment(-2, -2, -1, -3), + sqrt(8), 8, strategy); + tester::apply(make_box2d(0, 0, 1, 1), + make_segment(-3, -1, 0, -4), + sqrt(8), 8, strategy); + tester::apply(make_box2d(0, 0, 1, 1), + make_segment(-2, 0.75, -1.5, 0.5), + 1.5, 2.25, strategy); + tester::apply(make_box2d(0, 0, 1, 1), + make_segment(-2, 1.5, -1.5, 0.5), + 1.5, 2.25, strategy); + tester::apply(make_box2d(0, 0, 1, 1), + make_segment(0.5, 2, 0.75, 1.5), + 0.5, 0.25, strategy); + tester::apply(make_box2d(0, 0, 1, 1), + make_segment(-1, 2, 0.75, 1.5), + 0.5, 0.25, strategy); + tester::apply(make_box2d(0, 0, 1, 1), + make_segment(0, 2, 2, 0), + 0, 0, strategy); + tester::apply(make_box2d(0, 0, 1, 1), + make_segment(0, 3, 3, 0), + sqrt(0.5), 0.5, strategy); + tester::apply(make_box2d(0, 0, 1, 1), + make_segment(-1, 4, 4, -1), + sqrt(0.5), 0.5, strategy); + tester::apply(make_box2d(0, 0, 1, 1), + make_segment(-1, 4, 0, 3), + 2, 4, strategy); + tester::apply(make_box2d(0, 0, 1, 1), + make_segment(-2, 5, -1, 4), + sqrt(10), 10, strategy); + tester::apply(make_box2d(0, 0, 1, 1), + make_segment(3, -1, 4, -4), + sqrt(5), 5, strategy); + tester::apply(make_box2d(0, 0, 1, 1), + make_segment(1, 2, 2, 1), + sqrt(0.5), 0.5, strategy); + tester::apply(make_box2d(0, 0, 1, 1), + make_segment(0.5, -2, 2, -3), + 2, 4, strategy); + tester::apply(make_box2d(0, 0, 1, 1), + make_segment(-1, -2, 0, -3), + sqrt(5), 5, strategy); + tester::apply(make_box2d(0, 0, 1, 1), + make_segment(-1, -2, 0.5, -3.5), + sqrt(5), 5, strategy); + tester::apply(make_box2d(0, 0, 1, 1), + make_segment(-1, -2, 0.5, -3.5), + sqrt(5), 5, strategy); + tester::apply(make_box2d(0, 0, 1, 1), + make_segment(0.5, 3, 2.5, 2), + sqrt(2.45), 2.45, strategy); + tester::apply(make_box2d(0, 0, 1, 1), + make_segment(0.5, 1.5, 1.5, -1.5), + 0, 0, strategy); // test degenerate segment - tester(make_box2d(0, 0, 2, 2), - make_segment(4, 1, 4, 1), - 2, 4, strategy); + tester::apply(make_box2d(0, 0, 2, 2), + make_segment(4, 1, 4, 1), + 2, 4, strategy); } //=========================================================================== @@ -638,25 +647,25 @@ void test_distance_linestring_box(Strategy const& strategy) std::cout << std::endl; std::cout << "linestring/box distance tests" << std::endl; #endif - test_distance_of_geometries tester; + typedef test_distance_of_geometries tester; // linestrings that intersect the box - tester("linestring(-1 0.5,0.5 0.75)", - make_box2d(0, 0, 1, 1), - 0, 0, strategy); - tester("linestring(-1 0.5,1.5 0.75)", - make_box2d(0, 0, 1, 1), - 0, 0, strategy); + tester::apply("linestring(-1 0.5,0.5 0.75)", + make_box2d(0, 0, 1, 1), + 0, 0, strategy); + tester::apply("linestring(-1 0.5,1.5 0.75)", + make_box2d(0, 0, 1, 1), + 0, 0, strategy); // linestring that has closest point on box boundary - tester("linestring(4 0.5,5 0.75)", - make_box2d(0, 0, 1, 1), - 3, 9, strategy); + tester::apply("linestring(4 0.5,5 0.75)", + make_box2d(0, 0, 1, 1), + 3, 9, strategy); // linestring that has closest point on box corner - tester("linestring(4 0,0 4)", - make_box2d(0, 0, 1, 1), - sqrt(2), 2, strategy); + tester::apply("linestring(4 0,0 4)", + make_box2d(0, 0, 1, 1), + sqrt(2), 2, strategy); } //=========================================================================== @@ -668,22 +677,22 @@ void test_distance_multilinestring_box(Strategy const& strategy) std::cout << std::endl; std::cout << "multilinestring/box distance tests" << std::endl; #endif - test_distance_of_geometries tester; + typedef test_distance_of_geometries tester; // multilinestring that intersects the box - tester("multilinestring((-1 0.5,0.5 0.75),(4 0.5,5 0.75))", - make_box2d(0, 0, 1, 1), - 0, 0, strategy); + tester::apply("multilinestring((-1 0.5,0.5 0.75),(4 0.5,5 0.75))", + make_box2d(0, 0, 1, 1), + 0, 0, strategy); // multilinestring that has closest point on box boundary - tester("multilinestring((4 0.5,5 0.75))", - make_box2d(0, 0, 1, 1), - 3, 9, strategy); + tester::apply("multilinestring((4 0.5,5 0.75))", + make_box2d(0, 0, 1, 1), + 3, 9, strategy); // multilinestring that has closest point on box corner - tester("multilinestring((5 0,0 5),(4 0,0 4))", - make_box2d(0, 0, 1, 1), - sqrt(2), 2, strategy); + tester::apply("multilinestring((5 0,0 5),(4 0,0 4))", + make_box2d(0, 0, 1, 1), + sqrt(2), 2, strategy); } //=========================================================================== diff --git a/test/algorithms/distance_linear_linear.cpp b/test/algorithms/distance_linear_linear.cpp index 578a458c5..5faeca69a 100644 --- a/test/algorithms/distance_linear_linear.cpp +++ b/test/algorithms/distance_linear_linear.cpp @@ -38,23 +38,23 @@ void test_distance_segment_segment(Strategy const& strategy) std::cout << std::endl; std::cout << "segment/segment distance tests" << std::endl; #endif - test_distance_of_geometries tester; + typedef test_distance_of_geometries tester; - tester(make_segment(0, 0, 10, 0), - make_segment(4, 2, 4, 0.5), - return_type(0.5), return_type(0.25), strategy); + tester::apply(make_segment(0, 0, 10, 0), + make_segment(4, 2, 4, 0.5), + return_type(0.5), return_type(0.25), strategy); - tester(make_segment(0, 0, 10, 0), - make_segment(4, 2, 4, -0.5), - return_type(0), return_type(0), strategy); + tester::apply(make_segment(0, 0, 10, 0), + make_segment(4, 2, 4, -0.5), + return_type(0), return_type(0), strategy); - tester(make_segment(0, 0, 10, 0), - make_segment(4, 2, 0, 0), - return_type(0), return_type(0), strategy); + tester::apply(make_segment(0, 0, 10, 0), + make_segment(4, 2, 0, 0), + return_type(0), return_type(0), strategy); - tester(make_segment(0, 0, 10, 0), - make_segment(-2, 3, 1, 2), - return_type(2), return_type(4), strategy); + tester::apply(make_segment(0, 0, 10, 0), + make_segment(-2, 3, 1, 2), + return_type(2), return_type(4), strategy); } //=========================================================================== @@ -66,15 +66,15 @@ void test_distance_segment_linestring(Strategy const& strategy) std::cout << std::endl; std::cout << "segment/linestring distance tests" << std::endl; #endif - test_distance_of_geometries tester; + typedef test_distance_of_geometries tester; - tester(make_segment(-1, -1, -2, -2), - "linestring(2 1,1 2,4 0)", - sqrt(12.5), 12.5, strategy); + tester::apply(make_segment(-1, -1, -2, -2), + "linestring(2 1,1 2,4 0)", + sqrt(12.5), 12.5, strategy); - tester(make_segment(1, 1, 2, 2), - "linestring(2 1,1 2,4 0)", - 0, 0, strategy); + tester::apply(make_segment(1, 1, 2, 2), + "linestring(2 1,1 2,4 0)", + 0, 0, strategy); } //=========================================================================== @@ -86,42 +86,52 @@ void test_distance_linestring_linestring(Strategy const& strategy) std::cout << std::endl; std::cout << "linestring/linestring distance tests" << std::endl; #endif - test_distance_of_geometries tester; + typedef test_distance_of_geometries + < + linestring_type, linestring_type + > tester; // It is not obvious that linestrings with only one point are valid - tester("linestring(1 1)", "linestring(2 1)", 1, 1, strategy); + tester::apply("linestring(1 1)", "linestring(2 1)", + 1, 1, strategy); - tester("linestring(1 1,3 1)", "linestring(2 1)", 0, 0, strategy); + tester::apply("linestring(1 1,3 1)", "linestring(2 1)", + 0, 0, strategy); - tester("linestring(1 1)", "linestring(0 0,-2 0,2 -2,2 0)", - sqrt(2.0), 2, strategy); + tester::apply("linestring(1 1)", "linestring(0 0,-2 0,2 -2,2 0)", + sqrt(2.0), 2, strategy); - tester("linestring(1 1,1 1)", "linestring(2 1,2 1)", 1, 1, strategy); + tester::apply("linestring(1 1,1 1)", "linestring(2 1,2 1)", + 1, 1, strategy); - tester("linestring(1 1,1 1,1 1)", "linestring(2 1,2 1,2 1,2 1)", - 1, 1, strategy); + tester::apply("linestring(1 1,1 1,1 1)", "linestring(2 1,2 1,2 1,2 1)", + 1, 1, strategy); - tester("linestring(1 1,3 1)", "linestring(2 1,2 1)", 0, 0, strategy); + tester::apply("linestring(1 1,3 1)", "linestring(2 1,2 1)", + 0, 0, strategy); - tester("linestring(1 1,1 1)", "linestring(0 0,-2 0,2 -2,2 0)", - sqrt(2.0), 2, strategy); + tester::apply("linestring(1 1,1 1)", "linestring(0 0,-2 0,2 -2,2 0)", + sqrt(2.0), 2, strategy); - tester("linestring(1 1,3 1)", "linestring(2 1, 4 1)", 0, 0, strategy); + tester::apply("linestring(1 1,3 1)", "linestring(2 1, 4 1)", + 0, 0, strategy); - tester("linestring(1 1,2 2,3 3)", "linestring(2 1,1 2,4 0)", - 0, 0, strategy); + tester::apply("linestring(1 1,2 2,3 3)", "linestring(2 1,1 2,4 0)", + 0, 0, strategy); - tester("linestring(1 1,2 2,3 3)", "linestring(1 0,2 -1,4 0)", - 1, 1, strategy); + tester::apply("linestring(1 1,2 2,3 3)", "linestring(1 0,2 -1,4 0)", + 1, 1, strategy); - tester("linestring(1 1,2 2,3 3)", "linestring(1 -10,2 0,2.1 -10,4 0)", - sqrt(2.0), 2, strategy); + tester::apply("linestring(1 1,2 2,3 3)", + "linestring(1 -10,2 0,2.1 -10,4 0)", + sqrt(2.0), 2, strategy); - tester("linestring(1 1,2 2,3 3)", "linestring(1 -10,2 1.9,2.1 -10,4 0)", - sqrt(0.005), 0.005, strategy); + tester::apply("linestring(1 1,2 2,3 3)", + "linestring(1 -10,2 1.9,2.1 -10,4 0)", + sqrt(0.005), 0.005, strategy); - tester("linestring(1 1,1 2)", "linestring(0 0,-2 0,2 -2,2 0)", - sqrt(2.0), 2, strategy); + tester::apply("linestring(1 1,1 2)", "linestring(0 0,-2 0,2 -2,2 0)", + sqrt(2.0), 2, strategy); } //=========================================================================== @@ -133,15 +143,18 @@ void test_distance_segment_multilinestring(Strategy const& strategy) std::cout << std::endl; std::cout << "segment/multilinestring distance tests" << std::endl; #endif - test_distance_of_geometries tester; + typedef test_distance_of_geometries + < + segment_type, multi_linestring_type + > tester; - tester(make_segment(-1, -1, -2, -2), - "multilinestring((2 1,1 2),(4 0,4 10))", - sqrt(12.5), 12.5, strategy); + tester::apply(make_segment(-1, -1, -2, -2), + "multilinestring((2 1,1 2),(4 0,4 10))", + sqrt(12.5), 12.5, strategy); - tester(make_segment(1, 1, 2, 2), - "multilinestring((2 1,1 2),(4 0,4 10))", - 0, 0, strategy); + tester::apply(make_segment(1, 1, 2, 2), + "multilinestring((2 1,1 2),(4 0,4 10))", + 0, 0, strategy); } //=========================================================================== @@ -154,15 +167,18 @@ void test_distance_linestring_multilinestring(Strategy const& strategy) std::cout << "linestring/multilinestring distance tests" << std::endl; #endif - test_distance_of_geometries tester; + typedef test_distance_of_geometries + < + linestring_type, multi_linestring_type + > tester; - tester("linestring(1 1,2 2,3 3)", - "multilinestring((2 1,1 2,4 0),(1 -10,2 1.9,2.1 -10,4 0))", - 0, 0, strategy, true); + tester::apply("linestring(1 1,2 2,3 3)", + "multilinestring((2 1,1 2,4 0),(1 -10,2 1.9,2.1 -10,4 0))", + 0, 0, strategy, true); - tester("linestring(1 1,2 2,3 3)", - "multilinestring((1 -10,2 0,2.1 -10,4 0),(1 -10,2 1.9,2.1 -10,4 0))", - sqrt(0.005), 0.005, strategy, true); + tester::apply("linestring(1 1,2 2,3 3)", + "multilinestring((1 -10,2 0,2.1 -10,4 0),(1 -10,2 1.9,2.1 -10,4 0))", + sqrt(0.005), 0.005, strategy, true); } //=========================================================================== @@ -175,22 +191,22 @@ void test_distance_multilinestring_multilinestring(Strategy const& strategy) std::cout << "multilinestring/multilinestring distance tests" << std::endl; #endif - test_distance_of_geometries + typedef test_distance_of_geometries < multi_linestring_type, multi_linestring_type > tester; - tester("multilinestring((0 0,0 1,1 1),(10 0,11 1,12 2))", - "multilinestring((0.5 0.5,0.75 0.75),(11 0,11 7))", - 0, 0, strategy); + tester::apply("multilinestring((0 0,0 1,1 1),(10 0,11 1,12 2))", + "multilinestring((0.5 0.5,0.75 0.75),(11 0,11 7))", + 0, 0, strategy); - tester("multilinestring((0 0,0 1,1 1),(10 0,11 1,12 2))", - "multilinestring((0.5 0.5,0.75 0.75),(11 0,11 0.9))", - sqrt(0.005), 0.005, strategy); + tester::apply("multilinestring((0 0,0 1,1 1),(10 0,11 1,12 2))", + "multilinestring((0.5 0.5,0.75 0.75),(11 0,11 0.9))", + sqrt(0.005), 0.005, strategy); - tester("multilinestring((0 0,0 1,1 1),(10 0,11 1,12 2))", - "multilinestring((0.5 0.5,0.75 0.75),(11.1 0,11.1 0.9))", - sqrt(0.02), 0.02, strategy); + tester::apply("multilinestring((0 0,0 1,1 1),(10 0,11 1,12 2))", + "multilinestring((0.5 0.5,0.75 0.75),(11.1 0,11.1 0.9))", + sqrt(0.02), 0.02, strategy); } //=========================================================================== diff --git a/test/algorithms/distance_pointlike_areal.cpp b/test/algorithms/distance_pointlike_areal.cpp index 78e42a4f9..f8d68f30a 100644 --- a/test/algorithms/distance_pointlike_areal.cpp +++ b/test/algorithms/distance_pointlike_areal.cpp @@ -44,24 +44,24 @@ void test_distance_point_polygon(Strategy const& strategy) std::cout << std::endl; std::cout << "point/polygon distance tests" << std::endl; #endif - test_distance_of_geometries tester; + typedef test_distance_of_geometries tester; - tester("point(0 -20)", - "polygon((-10 -10,10 -10,10 10,-10 10,-10 -10))", - 10, 100, strategy); + tester::apply("point(0 -20)", + "polygon((-10 -10,10 -10,10 10,-10 10,-10 -10))", + 10, 100, strategy); - tester("point(12 0)", - "polygon((-10 -10,10 -10,10 10,-10 10,-10 -10))", - 2, 4, strategy); + tester::apply("point(12 0)", + "polygon((-10 -10,10 -10,10 10,-10 10,-10 -10))", + 2, 4, strategy); - tester("point(0 0)", - "polygon((-10 -10,10 -10,10 10,-10 10,-10 -10))", - 0, 0, strategy); + tester::apply("point(0 0)", + "polygon((-10 -10,10 -10,10 10,-10 10,-10 -10))", + 0, 0, strategy); - tester("point(0 0)", - "polygon((-10 -10,10 -10,10 10,-10 10,-10 -10),\ - (-5 -5,-5 5,5 5,5 -5,-5 -5))", - 5, 25, strategy); + tester::apply("point(0 0)", + "polygon((-10 -10,10 -10,10 10,-10 10,-10 -10),\ + (-5 -5,-5 5,5 5,5 -5,-5 -5))", + 5, 25, strategy); } //=========================================================================== @@ -73,28 +73,28 @@ void test_distance_point_multipolygon(Strategy const& strategy) std::cout << std::endl; std::cout << "point/multipolygon distance tests" << std::endl; #endif - test_distance_of_geometries tester; + typedef test_distance_of_geometries tester; - tester("point(0 -20)", - "multipolygon(((-10 -10,10 -10,10 10,-10 10,-10 -10)),\ - ((0 22,-1 30,2 40,0 22)))", - 10, 100, strategy); + tester::apply("point(0 -20)", + "multipolygon(((-10 -10,10 -10,10 10,-10 10,-10 -10)),\ + ((0 22,-1 30,2 40,0 22)))", + 10, 100, strategy); - tester("point(12 0)", - "multipolygon(((-10 -10,10 -10,10 10,-10 10,-10 -10)),\ - ((20 -1,21 2,30 -10,20 -1)))", - 2, 4, strategy); + tester::apply("point(12 0)", + "multipolygon(((-10 -10,10 -10,10 10,-10 10,-10 -10)),\ + ((20 -1,21 2,30 -10,20 -1)))", + 2, 4, strategy); - tester("point(0 0)", - "multipolygon(((-10 -10,10 -10,10 10,-10 10,-10 -10)),\ - ((20 -1,21 2,30 -10,20 -1)))", - 0, 0, strategy); + tester::apply("point(0 0)", + "multipolygon(((-10 -10,10 -10,10 10,-10 10,-10 -10)),\ + ((20 -1,21 2,30 -10,20 -1)))", + 0, 0, strategy); - tester("point(0 0)", - "multipolygon(((-10 -10,10 -10,10 10,-10 10,-10 -10),\ - (-5 -5,-5 5,5 5,5 -5,-5 -5)),\ - ((100 0,101 0,101 1,100 1,100 0)))", - 5, 25, strategy); + tester::apply("point(0 0)", + "multipolygon(((-10 -10,10 -10,10 10,-10 10,-10 -10),\ + (-5 -5,-5 5,5 5,5 -5,-5 -5)),\ + ((100 0,101 0,101 1,100 1,100 0)))", + 5, 25, strategy); } //=========================================================================== @@ -106,24 +106,24 @@ void test_distance_multipoint_polygon(Strategy const& strategy) std::cout << std::endl; std::cout << "multipoint/polygon distance tests" << std::endl; #endif - test_distance_of_geometries tester; + typedef test_distance_of_geometries tester; - tester("multipoint(0 -20,0 -15)", - "polygon((-10 -10,10 -10,10 10,-10 10,-10 -10))", - 5, 25, strategy); + tester::apply("multipoint(0 -20,0 -15)", + "polygon((-10 -10,10 -10,10 10,-10 10,-10 -10))", + 5, 25, strategy); - tester("multipoint(16 0,12 0)", - "polygon((-10 -10,10 -10,10 10,-10 10,-10 -10))", - 2, 4, strategy); + tester::apply("multipoint(16 0,12 0)", + "polygon((-10 -10,10 -10,10 10,-10 10,-10 -10))", + 2, 4, strategy); - tester("multipoint(0 0,5 5,4 4)", - "polygon((-10 -10,10 -10,10 10,-10 10,-10 -10))", - 0, 0, strategy); + tester::apply("multipoint(0 0,5 5,4 4)", + "polygon((-10 -10,10 -10,10 10,-10 10,-10 -10))", + 0, 0, strategy); - tester("multipoint(0 0,2 0)", - "polygon((-10 -10,10 -10,10 10,-10 10,-10 -10),\ - (-5 -5,-5 5,5 5,5 -5,-5 -5))", - 3, 9, strategy); + tester::apply("multipoint(0 0,2 0)", + "polygon((-10 -10,10 -10,10 10,-10 10,-10 -10),\ + (-5 -5,-5 5,5 5,5 -5,-5 -5))", + 3, 9, strategy); } //=========================================================================== @@ -135,28 +135,31 @@ void test_distance_multipoint_multipolygon(Strategy const& strategy) std::cout << std::endl; std::cout << "multipoint/multipolygon distance tests" << std::endl; #endif - test_distance_of_geometries tester; + typedef test_distance_of_geometries + < + multi_point_type, multi_polygon_type + > tester; - tester("multipoint(0 -20,0 -15)", - "multipolygon(((-10 -10,10 -10,10 10,-10 10,-10 -10)),\ - ((0 22,-1 30,2 40,0 22)))", - 5, 25, strategy); + tester::apply("multipoint(0 -20,0 -15)", + "multipolygon(((-10 -10,10 -10,10 10,-10 10,-10 -10)),\ + ((0 22,-1 30,2 40,0 22)))", + 5, 25, strategy); - tester("multipoint(16 0,12 0)", - "multipolygon(((-10 -10,10 -10,10 10,-10 10,-10 -10)),\ - ((20 -1,21 2,30 -10,20 -1)))", - 2, 4, strategy); + tester::apply("multipoint(16 0,12 0)", + "multipolygon(((-10 -10,10 -10,10 10,-10 10,-10 -10)),\ + ((20 -1,21 2,30 -10,20 -1)))", + 2, 4, strategy); - tester("multipoint(0 0,4 4,5 5)", - "multipolygon(((-10 -10,10 -10,10 10,-10 10,-10 -10)),\ - ((20 -1,21 2,30 -10,20 -1)))", - 0, 0, strategy); + tester::apply("multipoint(0 0,4 4,5 5)", + "multipolygon(((-10 -10,10 -10,10 10,-10 10,-10 -10)),\ + ((20 -1,21 2,30 -10,20 -1)))", + 0, 0, strategy); - tester("multipoint(0 0,2 0)", - "multipolygon(((-10 -10,10 -10,10 10,-10 10,-10 -10),\ - (-5 -5,-5 5,5 5,5 -5,-5 -5)),\ - ((100 0,101 0,101 1,100 1,100 0)))", - 3, 9, strategy); + tester::apply("multipoint(0 0,2 0)", + "multipolygon(((-10 -10,10 -10,10 10,-10 10,-10 -10),\ + (-5 -5,-5 5,5 5,5 -5,-5 -5)),\ + ((100 0,101 0,101 1,100 1,100 0)))", + 3, 9, strategy); } //=========================================================================== @@ -168,51 +171,51 @@ void test_distance_point_box_2d(Strategy const& strategy) std::cout << std::endl; std::cout << "2D point/box distance tests" << std::endl; #endif - test_distance_of_geometries tester; + typedef test_distance_of_geometries tester; // point inside box - tester(make_box2d(-1, -1, 1, 1), - "point(0 0)", 0, 0, strategy); + tester::apply(make_box2d(-1, -1, 1, 1), + "point(0 0)", 0, 0, strategy); // points on box corners - tester(make_box2d(-1, -1, 1, 1), - "point(-1 -1)", 0, 0, strategy); - tester(make_box2d(-1, -1, 1, 1), - "point(-1 1)", 0, 0, strategy); - tester(make_box2d(-1, -1, 1, 1), - "point(1 -1)", 0, 0, strategy); - tester(make_box2d(-1, -1, 1, 1), - "point(1 1)", 0, 0, strategy); + tester::apply(make_box2d(-1, -1, 1, 1), + "point(-1 -1)", 0, 0, strategy); + tester::apply(make_box2d(-1, -1, 1, 1), + "point(-1 1)", 0, 0, strategy); + tester::apply(make_box2d(-1, -1, 1, 1), + "point(1 -1)", 0, 0, strategy); + tester::apply(make_box2d(-1, -1, 1, 1), + "point(1 1)", 0, 0, strategy); // points on box boundary edges - tester(make_box2d(-1, -1, 1, 1), - "point(0 -1)", 0, 0, strategy); - tester(make_box2d(-1, -1, 1, 1), - "point(-1 0)", 0, 0, strategy); - tester(make_box2d(-1, -1, 1, 1), - "point(1 0)", 0, 0, strategy); - tester(make_box2d(-1, -1, 1, 1), - "point(0 1)", 0, 0, strategy); + tester::apply(make_box2d(-1, -1, 1, 1), + "point(0 -1)", 0, 0, strategy); + tester::apply(make_box2d(-1, -1, 1, 1), + "point(-1 0)", 0, 0, strategy); + tester::apply(make_box2d(-1, -1, 1, 1), + "point(1 0)", 0, 0, strategy); + tester::apply(make_box2d(-1, -1, 1, 1), + "point(0 1)", 0, 0, strategy); // points outside box - tester(make_box2d(-1, -1, 1, 1), - "point(0 4)", 3, 9, strategy); - tester(make_box2d(-1, -1, 1, 1), - "point(0.5 4)", 3, 9, strategy); - tester(make_box2d(-1, -1, 1, 1), - "point(-0.5 5)", 4, 16, strategy); - tester(make_box2d(-1, -1, 1, 1), - "point(3 0.25)", 2, 4, strategy); - tester(make_box2d(-1, -1, 1, 1), - "point(-3 -0.25)", 2, 4, strategy); - tester(make_box2d(-1, -1, 1, 1), - "point(3 5)", sqrt(20), 20, strategy); - tester(make_box2d(-1, -1, 1, 1), - "point(-5 -4)", 5, 25, strategy); - tester(make_box2d(-1, -1, 1, 1), - "point(2 -2)", sqrt(2), 2, strategy); - tester(make_box2d(-1, -1, 1, 1), - "point(-3 4)", sqrt(13), 13, strategy); + tester::apply(make_box2d(-1, -1, 1, 1), + "point(0 4)", 3, 9, strategy); + tester::apply(make_box2d(-1, -1, 1, 1), + "point(0.5 4)", 3, 9, strategy); + tester::apply(make_box2d(-1, -1, 1, 1), + "point(-0.5 5)", 4, 16, strategy); + tester::apply(make_box2d(-1, -1, 1, 1), + "point(3 0.25)", 2, 4, strategy); + tester::apply(make_box2d(-1, -1, 1, 1), + "point(-3 -0.25)", 2, 4, strategy); + tester::apply(make_box2d(-1, -1, 1, 1), + "point(3 5)", sqrt(20), 20, strategy); + tester::apply(make_box2d(-1, -1, 1, 1), + "point(-5 -4)", 5, 25, strategy); + tester::apply(make_box2d(-1, -1, 1, 1), + "point(2 -2)", sqrt(2), 2, strategy); + tester::apply(make_box2d(-1, -1, 1, 1), + "point(-3 4)", sqrt(13), 13, strategy); } //=========================================================================== @@ -230,35 +233,47 @@ void test_distance_point_box_different_point_types(Strategy const& strategy) typedef bg::model::point int_point; typedef bg::model::box int_box; - test_distance_of_geometries() - ("point(0 0)", - make_box2d(1, 1, 2, 2), - sqrt(2), 2, strategy); + test_distance_of_geometries + < + int_point, int_box + >::apply("point(0 0)", + make_box2d(1, 1, 2, 2), + sqrt(2), 2, strategy); - test_distance_of_geometries() - ("point(0.5 0)", - make_box2d(1, -1, 2, 1), - 0.5, 0.25, strategy); + test_distance_of_geometries + < + double_point, int_box + >::apply("point(0.5 0)", + make_box2d(1, -1, 2, 1), + 0.5, 0.25, strategy); - test_distance_of_geometries() - ("point(1.5 0)", - make_box2d(1, -1, 2, 1), - 0, 0, strategy); + test_distance_of_geometries + < + double_point, double_box + >::apply("point(1.5 0)", + make_box2d(1, -1, 2, 1), + 0, 0, strategy); - test_distance_of_geometries() - ("point(1.5 0)", - make_box2d(1, -1, 2, 1), - 0, 0, strategy); + test_distance_of_geometries + < + double_point, int_box + >::apply("point(1.5 0)", + make_box2d(1, -1, 2, 1), + 0, 0, strategy); - test_distance_of_geometries() - ("point(1 0)", - make_box2d(0.5, -1, 1.5, 1), - 0, 0, strategy); + test_distance_of_geometries + < + int_point, double_box + >::apply("point(1 0)", + make_box2d(0.5, -1, 1.5, 1), + 0, 0, strategy); - test_distance_of_geometries() - ("point(0 0)", - make_box2d(0.5, -1, 1.5, 1), - 0.5, 0.25, strategy); + test_distance_of_geometries + < + int_point, double_box + >::apply("point(0 0)", + make_box2d(0.5, -1, 1.5, 1), + 0.5, 0.25, strategy); } //=========================================================================== @@ -270,132 +285,132 @@ void test_distance_point_box_3d(Strategy const& strategy) std::cout << std::endl; std::cout << "3D point/box distance tests" << std::endl; #endif - test_distance_of_geometries tester; + typedef test_distance_of_geometries tester; // point inside box - tester(make_box3d(-1, -1, -1, 1, 1, 1), - "point(0 0 0)", 0, 0, strategy); + tester::apply(make_box3d(-1, -1, -1, 1, 1, 1), + "point(0 0 0)", 0, 0, strategy); // points on box corners - tester(make_box3d(-1, -1, -1, 1, 1, 1), - "point(-1 -1 -1)", 0, 0, strategy); - tester(make_box3d(-1, -1, -1, 1, 1, 1), - "point(-1 -1 1)", 0, 0, strategy); - tester(make_box3d(-1, -1, -1, 1, 1, 1), - "point(-1 1 -1)", 0, 0, strategy); - tester(make_box3d(-1, -1, -1, 1, 1, 1), - "point(-1 1 1)", 0, 0, strategy); - tester(make_box3d(-1, -1, -1, 1, 1, 1), - "point(1 -1 -1)", 0, 0, strategy); - tester(make_box3d(-1, -1, -1, 1, 1, 1), - "point(1 -1 1)", 0, 0, strategy); - tester(make_box3d(-1, -1, -1, 1, 1, 1), - "point(1 1 -1)", 0, 0, strategy); - tester(make_box3d(-1, -1, -1, 1, 1, 1), - "point(1 1 1)", 0, 0, strategy); + tester::apply(make_box3d(-1, -1, -1, 1, 1, 1), + "point(-1 -1 -1)", 0, 0, strategy); + tester::apply(make_box3d(-1, -1, -1, 1, 1, 1), + "point(-1 -1 1)", 0, 0, strategy); + tester::apply(make_box3d(-1, -1, -1, 1, 1, 1), + "point(-1 1 -1)", 0, 0, strategy); + tester::apply(make_box3d(-1, -1, -1, 1, 1, 1), + "point(-1 1 1)", 0, 0, strategy); + tester::apply(make_box3d(-1, -1, -1, 1, 1, 1), + "point(1 -1 -1)", 0, 0, strategy); + tester::apply(make_box3d(-1, -1, -1, 1, 1, 1), + "point(1 -1 1)", 0, 0, strategy); + tester::apply(make_box3d(-1, -1, -1, 1, 1, 1), + "point(1 1 -1)", 0, 0, strategy); + tester::apply(make_box3d(-1, -1, -1, 1, 1, 1), + "point(1 1 1)", 0, 0, strategy); // points on box boundary edges - tester(make_box3d(-1, -1, -1, 1, 1, 1), - "point(0 -1 -1)", 0, 0, strategy); - tester(make_box3d(-1, -1, -1, 1, 1, 1), - "point(0 -1 1)", 0, 0, strategy); - tester(make_box3d(-1, -1, -1, 1, 1, 1), - "point(0 1 -1)", 0, 0, strategy); - tester(make_box3d(-1, -1, -1, 1, 1, 1), - "point(0 1 1)", 0, 0, strategy); + tester::apply(make_box3d(-1, -1, -1, 1, 1, 1), + "point(0 -1 -1)", 0, 0, strategy); + tester::apply(make_box3d(-1, -1, -1, 1, 1, 1), + "point(0 -1 1)", 0, 0, strategy); + tester::apply(make_box3d(-1, -1, -1, 1, 1, 1), + "point(0 1 -1)", 0, 0, strategy); + tester::apply(make_box3d(-1, -1, -1, 1, 1, 1), + "point(0 1 1)", 0, 0, strategy); - tester(make_box3d(-1, -1, -1, 1, 1, 1), - "point(-1 0 -1)", 0, 0, strategy); - tester(make_box3d(-1, -1, -1, 1, 1, 1), - "point(-1 0 1)", 0, 0, strategy); - tester(make_box3d(-1, -1, -1, 1, 1, 1), - "point(1 0 -1)", 0, 0, strategy); - tester(make_box3d(-1, -1, -1, 1, 1, 1), - "point(1 0 1)", 0, 0, strategy); + tester::apply(make_box3d(-1, -1, -1, 1, 1, 1), + "point(-1 0 -1)", 0, 0, strategy); + tester::apply(make_box3d(-1, -1, -1, 1, 1, 1), + "point(-1 0 1)", 0, 0, strategy); + tester::apply(make_box3d(-1, -1, -1, 1, 1, 1), + "point(1 0 -1)", 0, 0, strategy); + tester::apply(make_box3d(-1, -1, -1, 1, 1, 1), + "point(1 0 1)", 0, 0, strategy); - tester(make_box3d(-1, -1, -1, 1, 1, 1), - "point(-1 -1 0)", 0, 0, strategy); - tester(make_box3d(-1, -1, -1, 1, 1, 1), - "point(-1 1 0)", 0, 0, strategy); - tester(make_box3d(-1, -1, -1, 1, 1, 1), - "point(1 -1 0)", 0, 0, strategy); - tester(make_box3d(-1, -1, -1, 1, 1, 1), - "point(1 1 0)", 0, 0, strategy); + tester::apply(make_box3d(-1, -1, -1, 1, 1, 1), + "point(-1 -1 0)", 0, 0, strategy); + tester::apply(make_box3d(-1, -1, -1, 1, 1, 1), + "point(-1 1 0)", 0, 0, strategy); + tester::apply(make_box3d(-1, -1, -1, 1, 1, 1), + "point(1 -1 0)", 0, 0, strategy); + tester::apply(make_box3d(-1, -1, -1, 1, 1, 1), + "point(1 1 0)", 0, 0, strategy); // point on box faces - tester(make_box3d(-1, -1, -1, 1, 1, 1), - "point(0 0 -1)", 0, 0, strategy); - tester(make_box3d(-1, -1, -1, 1, 1, 1), - "point(0 0 1)", 0, 0, strategy); - tester(make_box3d(-1, -1, -1, 1, 1, 1), - "point(0 -1 0)", 0, 0, strategy); - tester(make_box3d(-1, -1, -1, 1, 1, 1), - "point(0 1 0)", 0, 0, strategy); - tester(make_box3d(-1, -1, -1, 1, 1, 1), - "point(-1 0 0)", 0, 0, strategy); - tester(make_box3d(-1, -1, -1, 1, 1, 1), - "point(1 0 0)", 0, 0, strategy); + tester::apply(make_box3d(-1, -1, -1, 1, 1, 1), + "point(0 0 -1)", 0, 0, strategy); + tester::apply(make_box3d(-1, -1, -1, 1, 1, 1), + "point(0 0 1)", 0, 0, strategy); + tester::apply(make_box3d(-1, -1, -1, 1, 1, 1), + "point(0 -1 0)", 0, 0, strategy); + tester::apply(make_box3d(-1, -1, -1, 1, 1, 1), + "point(0 1 0)", 0, 0, strategy); + tester::apply(make_box3d(-1, -1, -1, 1, 1, 1), + "point(-1 0 0)", 0, 0, strategy); + tester::apply(make_box3d(-1, -1, -1, 1, 1, 1), + "point(1 0 0)", 0, 0, strategy); // points outside box -- closer to box corners - tester(make_box3d(-1, -1, -1, 1, 1, 1), - "point(-2 -3 -4)", sqrt(14), 14, strategy); - tester(make_box3d(-1, -1, -1, 1, 1, 1), - "point(-2 -3 3)", 3, 9, strategy); - tester(make_box3d(-1, -1, -1, 1, 1, 1), - "point(-2 5 -2)", sqrt(18), 18, strategy); - tester(make_box3d(-1, -1, -1, 1, 1, 1), - "point(-2 5 3)", sqrt(21), 21, strategy); - tester(make_box3d(-1, -1, -1, 1, 1, 1), - "point(4 -6 -3)", sqrt(38), 38, strategy); - tester(make_box3d(-1, -1, -1, 1, 1, 1), - "point(4 -6 4)", sqrt(43), 43, strategy); - tester(make_box3d(-1, -1, -1, 1, 1, 1), - "point(4 7 -2)", sqrt(46), 46, strategy); - tester(make_box3d(-1, -1, -1, 1, 1, 1), - "point(4 7 8)", sqrt(94), 94, strategy); + tester::apply(make_box3d(-1, -1, -1, 1, 1, 1), + "point(-2 -3 -4)", sqrt(14), 14, strategy); + tester::apply(make_box3d(-1, -1, -1, 1, 1, 1), + "point(-2 -3 3)", 3, 9, strategy); + tester::apply(make_box3d(-1, -1, -1, 1, 1, 1), + "point(-2 5 -2)", sqrt(18), 18, strategy); + tester::apply(make_box3d(-1, -1, -1, 1, 1, 1), + "point(-2 5 3)", sqrt(21), 21, strategy); + tester::apply(make_box3d(-1, -1, -1, 1, 1, 1), + "point(4 -6 -3)", sqrt(38), 38, strategy); + tester::apply(make_box3d(-1, -1, -1, 1, 1, 1), + "point(4 -6 4)", sqrt(43), 43, strategy); + tester::apply(make_box3d(-1, -1, -1, 1, 1, 1), + "point(4 7 -2)", sqrt(46), 46, strategy); + tester::apply(make_box3d(-1, -1, -1, 1, 1, 1), + "point(4 7 8)", sqrt(94), 94, strategy); // points closer to box facets - tester(make_box3d(-1, -1, -1, 1, 1, 1), - "point(0 0 10)", 9, 81, strategy); - tester(make_box3d(-1, -1, -1, 1, 1, 1), - "point(0 0 -5)", 4, 16, strategy); - tester(make_box3d(-1, -1, -1, 1, 1, 1), - "point(0 7 0)", 6, 36, strategy); - tester(make_box3d(-1, -1, -1, 1, 1, 1), - "point(0 -6 0)", 5, 25, strategy); - tester(make_box3d(-1, -1, -1, 1, 1, 1), - "point(4 0 0)", 3, 9, strategy); - tester(make_box3d(-1, -1, -1, 1, 1, 1), - "point(-3 0 0)", 2, 4, strategy); + tester::apply(make_box3d(-1, -1, -1, 1, 1, 1), + "point(0 0 10)", 9, 81, strategy); + tester::apply(make_box3d(-1, -1, -1, 1, 1, 1), + "point(0 0 -5)", 4, 16, strategy); + tester::apply(make_box3d(-1, -1, -1, 1, 1, 1), + "point(0 7 0)", 6, 36, strategy); + tester::apply(make_box3d(-1, -1, -1, 1, 1, 1), + "point(0 -6 0)", 5, 25, strategy); + tester::apply(make_box3d(-1, -1, -1, 1, 1, 1), + "point(4 0 0)", 3, 9, strategy); + tester::apply(make_box3d(-1, -1, -1, 1, 1, 1), + "point(-3 0 0)", 2, 4, strategy); // points closer to box edges - tester(make_box3d(-1, -1, -1, 1, 1, 1), - "point(0 -4 -5)", 5, 25, strategy); - tester(make_box3d(-1, -1, -1, 1, 1, 1), - "point(0 -3 6)", sqrt(29), 29, strategy); - tester(make_box3d(-1, -1, -1, 1, 1, 1), - "point(0 2 -7)", sqrt(37), 37, strategy); - tester(make_box3d(-1, -1, -1, 1, 1, 1), - "point(0 8 7)", sqrt(85), 85, strategy); + tester::apply(make_box3d(-1, -1, -1, 1, 1, 1), + "point(0 -4 -5)", 5, 25, strategy); + tester::apply(make_box3d(-1, -1, -1, 1, 1, 1), + "point(0 -3 6)", sqrt(29), 29, strategy); + tester::apply(make_box3d(-1, -1, -1, 1, 1, 1), + "point(0 2 -7)", sqrt(37), 37, strategy); + tester::apply(make_box3d(-1, -1, -1, 1, 1, 1), + "point(0 8 7)", sqrt(85), 85, strategy); - tester(make_box3d(-1, -1, -1, 1, 1, 1), - "point(-4 0 -4)", sqrt(18), 18, strategy); - tester(make_box3d(-1, -1, -1, 1, 1, 1), - "point(-3 0 5)", sqrt(20), 20, strategy); - tester(make_box3d(-1, -1, -1, 1, 1, 1), - "point(2 0 -6)", sqrt(26), 26, strategy); - tester(make_box3d(-1, -1, -1, 1, 1, 1), - "point(8 0 6)", sqrt(74), 74, strategy); + tester::apply(make_box3d(-1, -1, -1, 1, 1, 1), + "point(-4 0 -4)", sqrt(18), 18, strategy); + tester::apply(make_box3d(-1, -1, -1, 1, 1, 1), + "point(-3 0 5)", sqrt(20), 20, strategy); + tester::apply(make_box3d(-1, -1, -1, 1, 1, 1), + "point(2 0 -6)", sqrt(26), 26, strategy); + tester::apply(make_box3d(-1, -1, -1, 1, 1, 1), + "point(8 0 6)", sqrt(74), 74, strategy); - tester(make_box3d(-1, -1, -1, 1, 1, 1), - "point(-5 -5 0)", sqrt(32), 32, strategy); - tester(make_box3d(-1, -1, -1, 1, 1, 1), - "point(-4 6 0)", sqrt(34), 34, strategy); - tester(make_box3d(-1, -1, -1, 1, 1, 1), - "point(3 -7 0)", sqrt(40), 40, strategy); - tester(make_box3d(-1, -1, -1, 1, 1, 1), - "point(9 7 0)", 10, 100, strategy); + tester::apply(make_box3d(-1, -1, -1, 1, 1, 1), + "point(-5 -5 0)", sqrt(32), 32, strategy); + tester::apply(make_box3d(-1, -1, -1, 1, 1, 1), + "point(-4 6 0)", sqrt(34), 34, strategy); + tester::apply(make_box3d(-1, -1, -1, 1, 1, 1), + "point(3 -7 0)", sqrt(40), 40, strategy); + tester::apply(make_box3d(-1, -1, -1, 1, 1, 1), + "point(9 7 0)", 10, 100, strategy); } //=========================================================================== @@ -407,24 +422,29 @@ void test_distance_multipoint_box_2d(Strategy const& strategy) std::cout << std::endl; std::cout << "2D multipoint/box distance tests" << std::endl; #endif - test_distance_of_geometries tester; + typedef test_distance_of_geometries tester; // at least one point inside the box - tester(make_box2d(0, 0, 10, 10), - "multipoint(0 0,-1 -1,20 20)", 0, 0, strategy); + tester::apply(make_box2d(0, 0, 10, 10), + "multipoint(0 0,-1 -1,20 20)", + 0, 0, strategy); - tester(make_box2d(0, 0, 10, 10), - "multipoint(1 1,-1 -1,20 20)", 0, 0, strategy); + tester::apply(make_box2d(0, 0, 10, 10), + "multipoint(1 1,-1 -1,20 20)", + 0, 0, strategy); - tester(make_box2d(0, 0, 10, 10), - "multipoint(1 1,2 2,3 3)", 0, 0, strategy); + tester::apply(make_box2d(0, 0, 10, 10), + "multipoint(1 1,2 2,3 3)", + 0, 0, strategy); // all points outside the box - tester(make_box2d(0, 0, 10, 10), - "multipoint(-1 -1,20 20)", sqrt(2), 2, strategy); + tester::apply(make_box2d(0, 0, 10, 10), + "multipoint(-1 -1,20 20)", + sqrt(2), 2, strategy); - tester(make_box2d(0, 0, 10, 10), - "multipoint(5 13, 50 50)", 3, 9, strategy); + tester::apply(make_box2d(0, 0, 10, 10), + "multipoint(5 13, 50 50)", + 3, 9, strategy); } //=========================================================================== @@ -436,24 +456,32 @@ void test_distance_multipoint_box_3d(Strategy const& strategy) std::cout << std::endl; std::cout << "3D multipoint/box distance tests" << std::endl; #endif - test_distance_of_geometries tester; + typedef test_distance_of_geometries + < + box_type_3d, multi_point_type_3d + > tester; // at least one point inside the box - tester(make_box3d(0, 0, 0, 10, 10, 10), - "multipoint(0 0 0,-1 -1 -1,20 20 20)", 0, 0, strategy); + tester::apply(make_box3d(0, 0, 0, 10, 10, 10), + "multipoint(0 0 0,-1 -1 -1,20 20 20)", + 0, 0, strategy); - tester(make_box3d(0, 0, 0, 10, 10, 10), - "multipoint(1 1 1,-1 -1 -1,20 20 20)", 0, 0, strategy); + tester::apply(make_box3d(0, 0, 0, 10, 10, 10), + "multipoint(1 1 1,-1 -1 -1,20 20 20)", + 0, 0, strategy); - tester(make_box3d(0, 0, 0, 10, 10, 10), - "multipoint(1 1 1,2 2 2,3 3 3)", 0, 0, strategy); + tester::apply(make_box3d(0, 0, 0, 10, 10, 10), + "multipoint(1 1 1,2 2 2,3 3 3)", + 0, 0, strategy); // all points outside the box - tester(make_box3d(0, 0, 0, 10, 10, 10), - "multipoint(-1 -1 -1,20 20 20)", sqrt(3), 3, strategy); + tester::apply(make_box3d(0, 0, 0, 10, 10, 10), + "multipoint(-1 -1 -1,20 20 20)", + sqrt(3), 3, strategy); - tester(make_box3d(0, 0, 0, 10, 10, 10), - "multipoint(5 5 13,50 50 50)", 3, 9, strategy); + tester::apply(make_box3d(0, 0, 0, 10, 10, 10), + "multipoint(5 5 13,50 50 50)", + 3, 9, strategy); } //=========================================================================== diff --git a/test/algorithms/distance_pointlike_linear.cpp b/test/algorithms/distance_pointlike_linear.cpp index 9fe7f84c7..9a56f0460 100644 --- a/test/algorithms/distance_pointlike_linear.cpp +++ b/test/algorithms/distance_pointlike_linear.cpp @@ -42,13 +42,13 @@ void test_distance_point_segment(Strategy const& strategy) std::cout << std::endl; std::cout << "point/segment distance tests" << std::endl; #endif - test_distance_of_geometries tester; + typedef test_distance_of_geometries tester; - tester("point(0 0)", "segment(2 0,3 0)", 2, 4, strategy); - tester("point(2.5 3)", "segment(2 0,3 0)", 3, 9, strategy); - tester("point(2 0)", "segment(2 0,3 0)", 0, 0, strategy); - tester("point(3 0)", "segment(2 0,3 0)", 0, 0, strategy); - tester("point(2.5 0)", "segment(2 0,3 0)", 0, 0, strategy); + tester::apply("point(0 0)", "segment(2 0,3 0)", 2, 4, strategy); + tester::apply("point(2.5 3)", "segment(2 0,3 0)", 3, 9, strategy); + tester::apply("point(2 0)", "segment(2 0,3 0)", 0, 0, strategy); + tester::apply("point(3 0)", "segment(2 0,3 0)", 0, 0, strategy); + tester::apply("point(2.5 0)", "segment(2 0,3 0)", 0, 0, strategy); } //=========================================================================== @@ -60,14 +60,14 @@ void test_distance_point_linestring(Strategy const& strategy) std::cout << std::endl; std::cout << "point/linestring distance tests" << std::endl; #endif - test_distance_of_geometries tester; + typedef test_distance_of_geometries tester; - tester("point(0 0)", "linestring(2 0)", 2, 4, strategy); - tester("point(0 0)", "linestring(2 0,3 0)", 2, 4, strategy); - tester("point(2.5 3)", "linestring(2 0,3 0)", 3, 9, strategy); - tester("point(2 0)", "linestring(2 0,3 0)", 0, 0, strategy); - tester("point(3 0)", "linestring(2 0,3 0)", 0, 0, strategy); - tester("point(2.5 0)", "linestring(2 0,3 0)", 0, 0, strategy); + tester::apply("point(0 0)", "linestring(2 0)", 2, 4, strategy); + tester::apply("point(0 0)", "linestring(2 0,3 0)", 2, 4, strategy); + tester::apply("point(2.5 3)", "linestring(2 0,3 0)", 3, 9, strategy); + tester::apply("point(2 0)", "linestring(2 0,3 0)", 0, 0, strategy); + tester::apply("point(3 0)", "linestring(2 0,3 0)", 0, 0, strategy); + tester::apply("point(2.5 0)", "linestring(2 0,3 0)", 0, 0, strategy); } //=========================================================================== @@ -79,18 +79,26 @@ void test_distance_point_multilinestring(Strategy const& strategy) std::cout << std::endl; std::cout << "point/multilinestring distance tests" << std::endl; #endif - test_distance_of_geometries tester; + typedef test_distance_of_geometries + < + point_type, multi_linestring_type + > tester; - tester("point(0 0)", "multilinestring((-5 0,-3 0),(2 0,3 0))", - 2, 4, strategy); - tester("point(2.5 3)", "multilinestring((-5 0,-3 0),(2 0,3 0))", - 3, 9, strategy); - tester("point(2 0)", "multilinestring((-5 0,-3 0),(2 0,3 0))", - 0, 0, strategy); - tester("point(3 0)", "multilinestring((-5 0,-3 0),(2 0,3 0))", - 0, 0, strategy); - tester("point(2.5 0)", "multilinestring((-5 0,-3 0),(2 0,3 0))", - 0, 0, strategy); + tester::apply("point(0 0)", + "multilinestring((-5 0,-3 0),(2 0,3 0))", + 2, 4, strategy); + tester::apply("point(2.5 3)", + "multilinestring((-5 0,-3 0),(2 0,3 0))", + 3, 9, strategy); + tester::apply("point(2 0)", + "multilinestring((-5 0,-3 0),(2 0,3 0))", + 0, 0, strategy); + tester::apply("point(3 0)", + "multilinestring((-5 0,-3 0),(2 0,3 0))", + 0, 0, strategy); + tester::apply("point(2.5 0)", + "multilinestring((-5 0,-3 0),(2 0,3 0))", + 0, 0, strategy); } //=========================================================================== @@ -102,20 +110,23 @@ void test_distance_linestring_multipoint(Strategy const& strategy) std::cout << std::endl; std::cout << "linestring/multipoint distance tests" << std::endl; #endif - test_distance_of_geometries tester; + typedef test_distance_of_geometries + < + linestring_type, multi_point_type + > tester; - tester("linestring(2 0,0 2,100 100)", - "multipoint(0 0,1 0,0 1,1 1)", - 0, 0, strategy); - tester("linestring(4 0,0 4,100 100)", - "multipoint(0 0,1 0,0 1,1 1)", - sqrt(2.0), 2, strategy); - tester("linestring(1 1,2 2,100 100)", - "multipoint(0 0,1 0,0 1,1 1)", - 0, 0, strategy); - tester("linestring(3 3,4 4,100 100)", - "multipoint(0 0,1 0,0 1,1 1)", - sqrt(8.0), 8, strategy); + tester::apply("linestring(2 0,0 2,100 100)", + "multipoint(0 0,1 0,0 1,1 1)", + 0, 0, strategy); + tester::apply("linestring(4 0,0 4,100 100)", + "multipoint(0 0,1 0,0 1,1 1)", + sqrt(2.0), 2, strategy); + tester::apply("linestring(1 1,2 2,100 100)", + "multipoint(0 0,1 0,0 1,1 1)", + 0, 0, strategy); + tester::apply("linestring(3 3,4 4,100 100)", + "multipoint(0 0,1 0,0 1,1 1)", + sqrt(8.0), 8, strategy); } //=========================================================================== @@ -127,20 +138,23 @@ void test_distance_multipoint_multilinestring(Strategy const& strategy) std::cout << std::endl; std::cout << "multipoint/multilinestring distance tests" << std::endl; #endif - test_distance_of_geometries tester; + typedef test_distance_of_geometries + < + multi_point_type, multi_linestring_type + > tester; - tester("multipoint(0 0,1 0,0 1,1 1)", - "multilinestring((2 0,0 2),(2 2,3 3))", - 0, 0, strategy); - tester("multipoint(0 0,1 0,0 1,1 1)", - "multilinestring((3 0,0 3),(4 4,5 5))", - 0.5 * sqrt(2.0), 0.5, strategy); - tester("multipoint(0 0,1 0,0 1,1 1)", - "multilinestring((4 4,5 5),(1 1,2 2))", - 0, 0, strategy); - tester("multipoint(0 0,1 0,0 1,1 1)", - "multilinestring((3 3,4 4),(4 4,5 5))", - sqrt(8.0), 8, strategy); + tester::apply("multipoint(0 0,1 0,0 1,1 1)", + "multilinestring((2 0,0 2),(2 2,3 3))", + 0, 0, strategy); + tester::apply("multipoint(0 0,1 0,0 1,1 1)", + "multilinestring((3 0,0 3),(4 4,5 5))", + 0.5 * sqrt(2.0), 0.5, strategy); + tester::apply("multipoint(0 0,1 0,0 1,1 1)", + "multilinestring((4 4,5 5),(1 1,2 2))", + 0, 0, strategy); + tester::apply("multipoint(0 0,1 0,0 1,1 1)", + "multilinestring((3 3,4 4),(4 4,5 5))", + sqrt(8.0), 8, strategy); } //=========================================================================== @@ -152,20 +166,20 @@ void test_distance_multipoint_segment(Strategy const& strategy) std::cout << std::endl; std::cout << "multipoint/segment distance tests" << std::endl; #endif - test_distance_of_geometries tester; + typedef test_distance_of_geometries tester; - tester("multipoint(0 0,1 0,0 1,1 1)", - make_segment(2, 0, 0, 2), - 0, 0, strategy); - tester("multipoint(0 0,1 0,0 1,1 1)", - make_segment(4, 0, 0, 4), - sqrt(2.0), 2, strategy); - tester("multipoint(0 0,1 0,0 1,1 1)", - make_segment(1, 1, 2, 2), - 0, 0, strategy); - tester("multipoint(0 0,1 0,0 1,1 1)", - make_segment(3, 3, 4, 4), - sqrt(8.0), 8, strategy); + tester::apply("multipoint(0 0,1 0,0 1,1 1)", + make_segment(2, 0, 0, 2), + 0, 0, strategy); + tester::apply("multipoint(0 0,1 0,0 1,1 1)", + make_segment(4, 0, 0, 4), + sqrt(2.0), 2, strategy); + tester::apply("multipoint(0 0,1 0,0 1,1 1)", + make_segment(1, 1, 2, 2), + 0, 0, strategy); + tester::apply("multipoint(0 0,1 0,0 1,1 1)", + make_segment(3, 3, 4, 4), + sqrt(8.0), 8, strategy); } //=========================================================================== diff --git a/test/algorithms/distance_pointlike_pointlike.cpp b/test/algorithms/distance_pointlike_pointlike.cpp index 149a2dc3e..83116ed73 100644 --- a/test/algorithms/distance_pointlike_pointlike.cpp +++ b/test/algorithms/distance_pointlike_pointlike.cpp @@ -36,12 +36,14 @@ void test_distance_point_point(Strategy const& strategy) std::cout << std::endl; std::cout << "point/point distance tests" << std::endl; #endif - test_distance_of_geometries tester; + typedef test_distance_of_geometries tester; - tester("point(1 1)", "point(0 0)", - sqrt(2.0), 2, strategy); - tester("point(1 1)", "point(1 1)", - 0, 0, strategy); + tester::apply("point(1 1)", + "point(0 0)", + sqrt(2.0), 2, strategy); + tester::apply("point(1 1)", + "point(1 1)", + 0, 0, strategy); } //=========================================================================== @@ -53,17 +55,17 @@ void test_distance_point_multipoint(Strategy const& strategy) std::cout << std::endl; std::cout << "point/multipoint distance tests" << std::endl; #endif - test_distance_of_geometries tester; + typedef test_distance_of_geometries tester; - tester("point(1 1)", - "multipoint(1 1,2 1,2 2,1 2)", - 0, 0, strategy); - tester("point(1 1)", - "multipoint(2 2,2 3,3 2,3 3)", - sqrt(2.0), 2, strategy); - tester("point(3 0)", - "multipoint(2 2,2 4,4 2,4 4)", - sqrt(5.0), 5, strategy); + tester::apply("point(1 1)", + "multipoint(1 1,2 1,2 2,1 2)", + 0, 0, strategy); + tester::apply("point(1 1)", + "multipoint(2 2,2 3,3 2,3 3)", + sqrt(2.0), 2, strategy); + tester::apply("point(3 0)", + "multipoint(2 2,2 4,4 2,4 4)", + sqrt(5.0), 5, strategy); } //=========================================================================== @@ -75,14 +77,17 @@ void test_distance_multipoint_multipoint(Strategy const& strategy) std::cout << std::endl; std::cout << "multipoint/multipoint distance tests" << std::endl; #endif - test_distance_of_geometries tester; + typedef test_distance_of_geometries + < + multi_point_type, multi_point_type + > tester; - tester("multipoint(0 0,1 0,0 1,1 1)", - "multipoint(1 1,2 1,2 2,1 2)", - 0, 0, strategy); - tester("multipoint(0 0,1 0,0 1,1 1)", - "multipoint(2 2,2 3,3 2,3 3)", - sqrt(2.0), 2, strategy); + tester::apply("multipoint(0 0,1 0,0 1,1 1)", + "multipoint(1 1,2 1,2 2,1 2)", + 0, 0, strategy); + tester::apply("multipoint(0 0,1 0,0 1,1 1)", + "multipoint(2 2,2 3,3 2,3 3)", + sqrt(2.0), 2, strategy); } //=========================================================================== diff --git a/test/algorithms/test_distance_common.hpp b/test/algorithms/test_distance_common.hpp index f4ba097fa..826811cda 100644 --- a/test/algorithms/test_distance_common.hpp +++ b/test/algorithms/test_distance_common.hpp @@ -34,6 +34,7 @@ #include #include +#include #include #include @@ -201,19 +202,20 @@ struct test_distance_of_geometries typename ComparableDistanceType, typename Strategy > - void operator()(std::string const& wkt1, - std::string const& wkt2, - DistanceType const& expected_distance, - ComparableDistanceType const& expected_comparable_distance, - Strategy const& strategy, - bool test_reversed = true) const + static inline + void apply(std::string const& wkt1, + std::string const& wkt2, + DistanceType const& expected_distance, + ComparableDistanceType const& expected_comparable_distance, + Strategy const& strategy, + bool test_reversed = true) { Geometry1 geometry1 = from_wkt(wkt1); Geometry2 geometry2 = from_wkt(wkt2); - operator()(geometry1, geometry2, - expected_distance, expected_comparable_distance, - strategy, test_reversed); + apply(geometry1, geometry2, + expected_distance, expected_comparable_distance, + strategy, test_reversed); } template @@ -222,18 +224,19 @@ struct test_distance_of_geometries typename ComparableDistanceType, typename Strategy > - void operator()(Geometry1 const& geometry1, - std::string const& wkt2, - DistanceType const& expected_distance, - ComparableDistanceType const& expected_comparable_distance, - Strategy const& strategy, - bool test_reversed = true) const + static inline + void apply(Geometry1 const& geometry1, + std::string const& wkt2, + DistanceType const& expected_distance, + ComparableDistanceType const& expected_comparable_distance, + Strategy const& strategy, + bool test_reversed = true) { Geometry2 geometry2 = from_wkt(wkt2); - operator()(geometry1, geometry2, - expected_distance, expected_comparable_distance, - strategy, test_reversed); + apply(geometry1, geometry2, + expected_distance, expected_comparable_distance, + strategy, test_reversed); } template @@ -242,18 +245,19 @@ struct test_distance_of_geometries typename ComparableDistanceType, typename Strategy > - void operator()(std::string const& wkt1, - Geometry2 const& geometry2, - DistanceType const& expected_distance, - ComparableDistanceType const& expected_comparable_distance, - Strategy const& strategy, - bool test_reversed = true) const + static inline + void apply(std::string const& wkt1, + Geometry2 const& geometry2, + DistanceType const& expected_distance, + ComparableDistanceType const& expected_comparable_distance, + Strategy const& strategy, + bool test_reversed = true) { Geometry1 geometry1 = from_wkt(wkt1); - operator()(geometry1, geometry2, - expected_distance, expected_comparable_distance, - strategy, test_reversed); + apply(geometry1, geometry2, + expected_distance, expected_comparable_distance, + strategy, test_reversed); } template @@ -262,12 +266,13 @@ struct test_distance_of_geometries typename ComparableDistanceType, typename Strategy > - void operator()(Geometry1 const& geometry1, - Geometry2 const& geometry2, - DistanceType const& expected_distance, - ComparableDistanceType const& expected_comparable_distance, - Strategy const& strategy, - bool test_reversed = true) const + static inline + void apply(Geometry1 const& geometry1, + Geometry2 const& geometry2, + DistanceType const& expected_distance, + ComparableDistanceType const& expected_comparable_distance, + Strategy const& strategy, + bool test_reversed = true) { #ifdef GEOMETRY_TEST_DEBUG typedef pretty_print_geometry PPG1; @@ -445,44 +450,57 @@ struct test_distance_of_geometries typedef typename bg::ring_type::type ring_type; - template - void operator()(Segment const& segment, - std::string const& wkt, - double expected_distance, - double expected_comparable_distance, - Strategy const& strategy) const + template + < + typename Segment, + typename DistanceType, + typename ComparableDistanceType, + typename Strategy + > + static inline + void apply(Segment const& segment, + std::string const& wkt, + DistanceType const& expected_distance, + ComparableDistanceType const& expected_comparable_distance, + Strategy const& strategy) { Geometry2 geometry = from_wkt(wkt); - operator()(segment, - geometry, - expected_distance, - expected_comparable_distance, - strategy); + apply(segment, + geometry, + expected_distance, + expected_comparable_distance, + strategy); } - template - void operator()(Segment const& segment, - Geometry2 const& geometry, - double expected_distance, - double expected_comparable_distance, - Strategy const& strategy) const + template + < + typename Segment, + typename DistanceType, + typename ComparableDistanceType, + typename Strategy + > + static inline + void apply(Segment const& segment, + Geometry2 const& geometry, + DistanceType const& expected_distance, + ComparableDistanceType const& expected_comparable_distance, + Strategy const& strategy) { - base::operator()(segment, geometry, expected_distance, - expected_comparable_distance, strategy); + base::apply(segment, geometry, expected_distance, + expected_comparable_distance, strategy); if ( bg::num_interior_rings(geometry) == 0 ) { #ifdef GEOMETRY_TEST_DEBUG std::cout << "... testing also exterior ring ..." << std::endl; #endif -#if 0 - // cannot run it now; needs within(point,linestring) - test_distance_of_segment_and_geometry() - (segment, - bg::exterior_ring(geometry), - expected_distance, - expected_comparable_distance, - strategy); -#endif + test_distance_of_geometries + < + Segment, ring_type + >::apply(segment, + bg::exterior_ring(geometry), + expected_distance, + expected_comparable_distance, + strategy); } } }; From c9950313373024e4f9b76279df7a007f794e4ebf Mon Sep 17 00:00:00 2001 From: Barend Gehrels Date: Wed, 14 May 2014 13:22:48 +0200 Subject: [PATCH 55/66] [intersection] avoid circulare reference in index/intersection/distance --- .../detail/overlay/intersection_box_box.hpp | 84 +++++++++++++++++++ .../geometry/algorithms/intersection.hpp | 63 +------------- .../algorithms/intersection_content.hpp | 10 ++- .../geometry/strategies/intersection.hpp | 3 +- 4 files changed, 95 insertions(+), 65 deletions(-) create mode 100644 include/boost/geometry/algorithms/detail/overlay/intersection_box_box.hpp diff --git a/include/boost/geometry/algorithms/detail/overlay/intersection_box_box.hpp b/include/boost/geometry/algorithms/detail/overlay/intersection_box_box.hpp new file mode 100644 index 000000000..dd041b0d7 --- /dev/null +++ b/include/boost/geometry/algorithms/detail/overlay/intersection_box_box.hpp @@ -0,0 +1,84 @@ +// Boost.Geometry (aka GGL, Generic Geometry Library) + +// Copyright (c) 2007-2014 Barend Gehrels, 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) + +#ifndef BOOST_GEOMETRY_ALGORITHMS_DETAIL_OVERLAY_INTERSECTION_BOX_BOX_HPP +#define BOOST_GEOMETRY_ALGORITHMS_DETAIL_OVERLAY_INTERSECTION_BOX_BOX_HPP + + +#include +#include + + +namespace boost { namespace geometry +{ + +#ifndef DOXYGEN_NO_DETAIL +namespace detail { namespace intersection +{ + +template +struct intersection_box_box +{ + template + < + typename Box1, typename Box2, + typename RobustPolicy, + typename BoxOut, + typename Strategy + > + static inline bool apply(Box1 const& box1, + Box2 const& box2, + RobustPolicy const& robust_policy, + BoxOut& box_out, + Strategy const& strategy) + { + typedef typename coordinate_type::type ct; + + ct min1 = get(box1); + ct min2 = get(box2); + ct max1 = get(box1); + ct max2 = get(box2); + + if (max1 < min2 || max2 < min1) + { + return false; + } + // Set dimensions of output coordinate + set(box_out, min1 < min2 ? min2 : min1); + set(box_out, max1 > max2 ? max2 : max1); + + return intersection_box_box + ::apply(box1, box2, robust_policy, box_out, strategy); + } +}; + +template +struct intersection_box_box +{ + template + < + typename Box1, typename Box2, + typename RobustPolicy, + typename BoxOut, + typename Strategy + > + static inline bool apply(Box1 const&, Box2 const&, + RobustPolicy const&, BoxOut&, Strategy const&) + { + return true; + } +}; + + +}} // namespace detail::intersection +#endif // DOXYGEN_NO_DETAIL + +}} // namespace boost::geometry + + +#endif // BOOST_GEOMETRY_ALGORITHMS_DETAIL_OVERLAY_INTERSECTION_BOX_BOX_HPP diff --git a/include/boost/geometry/algorithms/intersection.hpp b/include/boost/geometry/algorithms/intersection.hpp index 500cacc9f..ca3bb0682 100644 --- a/include/boost/geometry/algorithms/intersection.hpp +++ b/include/boost/geometry/algorithms/intersection.hpp @@ -12,6 +12,7 @@ #include #include +#include #include #include @@ -19,68 +20,6 @@ namespace boost { namespace geometry { -#ifndef DOXYGEN_NO_DETAIL -namespace detail { namespace intersection -{ - -template -struct intersection_box_box -{ - template - < - typename Box1, typename Box2, - typename RobustPolicy, - typename BoxOut, - typename Strategy - > - static inline bool apply(Box1 const& box1, - Box2 const& box2, - RobustPolicy const& robust_policy, - BoxOut& box_out, - Strategy const& strategy) - { - typedef typename coordinate_type::type ct; - - ct min1 = get(box1); - ct min2 = get(box2); - ct max1 = get(box1); - ct max2 = get(box2); - - if (max1 < min2 || max2 < min1) - { - return false; - } - // Set dimensions of output coordinate - set(box_out, min1 < min2 ? min2 : min1); - set(box_out, max1 > max2 ? max2 : max1); - - return intersection_box_box - ::apply(box1, box2, robust_policy, box_out, strategy); - } -}; - -template -struct intersection_box_box -{ - template - < - typename Box1, typename Box2, - typename RobustPolicy, - typename BoxOut, - typename Strategy - > - static inline bool apply(Box1 const&, Box2 const&, - RobustPolicy const&, BoxOut&, Strategy const&) - { - return true; - } -}; - - -}} // namespace detail::intersection -#endif // DOXYGEN_NO_DETAIL - - #ifndef DOXYGEN_NO_DISPATCH namespace dispatch diff --git a/include/boost/geometry/index/detail/algorithms/intersection_content.hpp b/include/boost/geometry/index/detail/algorithms/intersection_content.hpp index 955d6eb65..ed615c402 100644 --- a/include/boost/geometry/index/detail/algorithms/intersection_content.hpp +++ b/include/boost/geometry/index/detail/algorithms/intersection_content.hpp @@ -11,7 +11,8 @@ #ifndef BOOST_GEOMETRY_INDEX_DETAIL_ALGORITHMS_INTERSECTION_CONTENT_HPP #define BOOST_GEOMETRY_INDEX_DETAIL_ALGORITHMS_INTERSECTION_CONTENT_HPP -#include +#include +#include #include namespace boost { namespace geometry { namespace index { namespace detail { @@ -25,7 +26,12 @@ inline typename default_content_result::type intersection_content(Box const if ( geometry::intersects(box1, box2) ) { Box box_intersection; - geometry::intersection(box1, box2, box_intersection); + + strategy_intersection_empty dummy; + geometry::detail::intersection::intersection_box_box + < + 0, geometry::dimension::value + >::apply(box1, box2, box_intersection, dummy); return detail::content(box_intersection); } return 0; diff --git a/include/boost/geometry/strategies/intersection.hpp b/include/boost/geometry/strategies/intersection.hpp index d97baf66d..ef1b676fd 100644 --- a/include/boost/geometry/strategies/intersection.hpp +++ b/include/boost/geometry/strategies/intersection.hpp @@ -82,7 +82,8 @@ public: typedef RobustPolicy rescale_policy_type; }; - +// Version for box_box intersection or other detail calls not needing a strategy +struct strategy_intersection_empty {}; }} // namespace boost::geometry From 07696d76fdeedd8ac091f6c9b8a0ff64a6920954 Mon Sep 17 00:00:00 2001 From: Barend Gehrels Date: Wed, 14 May 2014 13:46:22 +0200 Subject: [PATCH 56/66] [overlay] Added missing include / removed obsolete include, causing unit test troubles after distance merge --- .../geometry/algorithms/detail/overlay/get_relative_order.hpp | 2 -- include/boost/geometry/policies/robustness/rescale_policy.hpp | 1 + 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/include/boost/geometry/algorithms/detail/overlay/get_relative_order.hpp b/include/boost/geometry/algorithms/detail/overlay/get_relative_order.hpp index 50a14ea24..d71f4ad51 100644 --- a/include/boost/geometry/algorithms/detail/overlay/get_relative_order.hpp +++ b/include/boost/geometry/algorithms/detail/overlay/get_relative_order.hpp @@ -10,8 +10,6 @@ #define BOOST_GEOMETRY_ALGORITHMS_DETAIL_OVERLAY_GET_RELATIVE_ORDER_HPP -#include - #include diff --git a/include/boost/geometry/policies/robustness/rescale_policy.hpp b/include/boost/geometry/policies/robustness/rescale_policy.hpp index 570ba8bef..5b3b56697 100644 --- a/include/boost/geometry/policies/robustness/rescale_policy.hpp +++ b/include/boost/geometry/policies/robustness/rescale_policy.hpp @@ -16,6 +16,7 @@ #include +#include #include #include From 09365f00869a34acc762c158b52d6991667ef437 Mon Sep 17 00:00:00 2001 From: Barend Gehrels Date: Wed, 14 May 2014 13:46:52 +0200 Subject: [PATCH 57/66] [unit test] Added copyright info --- test/algorithms/from_wkt.hpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/test/algorithms/from_wkt.hpp b/test/algorithms/from_wkt.hpp index 13d646356..2e47f2e24 100644 --- a/test/algorithms/from_wkt.hpp +++ b/test/algorithms/from_wkt.hpp @@ -1,3 +1,15 @@ +// Boost.Geometry (aka GGL, Generic Geometry Library) +// Unit Tests + +// Copyright (c) 2007-2014 Barend Gehrels, Amsterdam, the Netherlands. +// Copyright (c) 2008-2014 Bruno Lalande, Paris, France. +// Copyright (c) 2009-2014 Mateusz Loskot, London, UK. +// Copyright (c) 2013-2014 Adam Wulkiewicz, Lodz, Poland. + +// 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) + #ifndef BOOST_GEOMETRY_TEST_FROM_WKT_HPP #define BOOST_GEOMETRY_TEST_FROM_WKT_HPP From afb301f6ed6b52f3968bfcc071128d39470b67ec Mon Sep 17 00:00:00 2001 From: Barend Gehrels Date: Wed, 14 May 2014 13:47:22 +0200 Subject: [PATCH 58/66] [unit test] Made from_wkt inline and avoid abbreviations --- test/algorithms/from_wkt.hpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/test/algorithms/from_wkt.hpp b/test/algorithms/from_wkt.hpp index 2e47f2e24..5390db868 100644 --- a/test/algorithms/from_wkt.hpp +++ b/test/algorithms/from_wkt.hpp @@ -16,11 +16,11 @@ #include template -Geometry from_wkt(std::string const& wkt) +inline Geometry from_wkt(std::string const& wkt) { - Geometry res; - boost::geometry::read_wkt(wkt, res); - return res; + Geometry result; + boost::geometry::read_wkt(wkt, result); + return result; } #endif // BOOST_GEOMETRY_TEST_FROM_WKT_HPP From a703cae46e887a49fd70f17cc3e942006a81e4fd Mon Sep 17 00:00:00 2001 From: Barend Gehrels Date: Wed, 14 May 2014 14:18:48 +0200 Subject: [PATCH 59/66] [num_points][test] Added test for num_points which was not yet there --- test/algorithms/Jamfile.v2 | 1 + test/algorithms/num_points.cpp | 65 ++++++++++++++++++++++++++++++++++ 2 files changed, 66 insertions(+) create mode 100644 test/algorithms/num_points.cpp diff --git a/test/algorithms/Jamfile.v2 b/test/algorithms/Jamfile.v2 index de35ec60e..63b7fe3c4 100644 --- a/test/algorithms/Jamfile.v2 +++ b/test/algorithms/Jamfile.v2 @@ -47,6 +47,7 @@ test-suite boost-geometry-algorithms [ run intersects.cpp : : : msvc:/bigobj ] [ run length.cpp ] [ run make.cpp ] + [ run num_points.cpp ] [ run overlaps.cpp ] [ run perimeter.cpp ] [ run point_on_surface.cpp ] diff --git a/test/algorithms/num_points.cpp b/test/algorithms/num_points.cpp new file mode 100644 index 000000000..3abeed449 --- /dev/null +++ b/test/algorithms/num_points.cpp @@ -0,0 +1,65 @@ +// Boost.Geometry (aka GGL, Generic Geometry Library) +// Unit Test + +// Copyright (c) 2007-2014 Barend Gehrels, Amsterdam, the Netherlands. +// Copyright (c) 2008-2014 Bruno Lalande, Paris, France. +// Copyright (c) 2009-2014 Mateusz Loskot, London, UK. +// Copyright (c) 2013-2014 Adam Wulkiewicz, Lodz, Poland. + +// 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) + +#ifndef BOOST_TEST_MODULE +#define BOOST_TEST_MODULE test_num_points +#endif + +#include +#include + +#include +#include +#include +#include + +#include +#include + +template +inline void test_num_points(std::string const& wkt, std::size_t expected) +{ + namespace bg = boost::geometry; + Geometry geometry; + boost::geometry::read_wkt(wkt, geometry); + std::size_t detected = bg::num_points(geometry); + BOOST_CHECK_EQUAL(expected, detected); + detected = bg::num_points(geometry, false); + BOOST_CHECK_EQUAL(expected, detected); + detected = bg::num_points(geometry, true); +} + +BOOST_AUTO_TEST_CASE( test_num_points_closed ) +{ + namespace bg = boost::geometry; + typedef bg::model::point point; + typedef bg::model::linestring linestring; + typedef bg::model::segment segment; + typedef bg::model::box box; + typedef bg::model::ring ring; + typedef bg::model::polygon polygon; + typedef bg::model::multi_point multi_point; + typedef bg::model::multi_linestring multi_linestring; + typedef bg::model::multi_polygon multi_polygon; + + test_num_points("POINT(0 0)", 1u); + test_num_points("LINESTRING(0 0,1 1)", 2u); + test_num_points("LINESTRING(0 0,1 1)", 2u); + test_num_points("POLYGON((0 0,10 10))", 4u); + test_num_points("POLYGON((0 0,1 1,0 1,0 0))", 4u); + test_num_points("POLYGON((0 0,10 10,0 10,0 0))", 4u); + test_num_points("POLYGON((0 0,0 10,10 10,10 0,0 0),(4 4,6 4,6 6,4 6,4 4))", 10u); + test_num_points("MULTIPOINT((0 0),(1 1))", 2u); + test_num_points("MULTILINESTRING((0 0,1 1),(2 2,3 3,4 4))", 5u); + test_num_points("MULTIPOLYGON(((0 0,0 10,10 10,10 0,0 0)),((0 10,1 10,1 9,0 10)))", 9u); +} + From 71be9ab855a6f21113672bb0a2443166a2ef2d82 Mon Sep 17 00:00:00 2001 From: Barend Gehrels Date: Wed, 14 May 2014 14:19:04 +0200 Subject: [PATCH 60/66] [test] added include for multi --- test/algorithms/from_wkt.hpp | 1 + 1 file changed, 1 insertion(+) diff --git a/test/algorithms/from_wkt.hpp b/test/algorithms/from_wkt.hpp index 5390db868..5c78afdea 100644 --- a/test/algorithms/from_wkt.hpp +++ b/test/algorithms/from_wkt.hpp @@ -14,6 +14,7 @@ #define BOOST_GEOMETRY_TEST_FROM_WKT_HPP #include +#include template inline Geometry from_wkt(std::string const& wkt) From f6d0b4054ae735e60e917cf8c56edfa689d91207 Mon Sep 17 00:00:00 2001 From: Menelaos Karavelas Date: Wed, 14 May 2014 15:20:57 +0300 Subject: [PATCH 61/66] [distance] fix unused variable warnings produced by clang++ with -Wextra and warnings by VS (reported by Adam) --- .../algorithms/detail/distance/backward_compatibility.hpp | 6 +++--- .../geometry/algorithms/detail/distance/box_to_box.hpp | 1 + .../algorithms/detail/distance/point_to_geometry.hpp | 4 +++- .../algorithms/detail/distance/range_to_segment_or_box.hpp | 3 +++ .../geometry/algorithms/detail/distance/segment_to_box.hpp | 6 ++++++ 5 files changed, 16 insertions(+), 4 deletions(-) diff --git a/include/boost/geometry/algorithms/detail/distance/backward_compatibility.hpp b/include/boost/geometry/algorithms/detail/distance/backward_compatibility.hpp index 603963cbf..5dd69cbcd 100644 --- a/include/boost/geometry/algorithms/detail/distance/backward_compatibility.hpp +++ b/include/boost/geometry/algorithms/detail/distance/backward_compatibility.hpp @@ -110,7 +110,7 @@ struct distance static inline typename return_type::type>::type apply(Point const& point, Linestring const& linestring, - Strategy const& strategy) + Strategy const&) { typedef typename detail::distance::default_ps_strategy < @@ -143,7 +143,7 @@ struct distance static inline return_type apply(Point const& point, Ring const& ring, - Strategy const& strategy) + Strategy const&) { typedef typename detail::distance::default_ps_strategy < @@ -181,7 +181,7 @@ struct distance static inline return_type apply(Point const& point, Polygon const& polygon, - Strategy const& strategy) + Strategy const&) { typedef typename detail::distance::default_ps_strategy < diff --git a/include/boost/geometry/algorithms/detail/distance/box_to_box.hpp b/include/boost/geometry/algorithms/detail/distance/box_to_box.hpp index 98b3be0f7..7b032a19c 100644 --- a/include/boost/geometry/algorithms/detail/distance/box_to_box.hpp +++ b/include/boost/geometry/algorithms/detail/distance/box_to_box.hpp @@ -43,6 +43,7 @@ struct distance >::type apply(Box1 const& box1, Box2 const& box2, Strategy const& strategy) { + boost::ignore_unused_variable_warning(strategy); return strategy.apply(box1, box2); } }; diff --git a/include/boost/geometry/algorithms/detail/distance/point_to_geometry.hpp b/include/boost/geometry/algorithms/detail/distance/point_to_geometry.hpp index 4d6a598ad..7b89dcad1 100644 --- a/include/boost/geometry/algorithms/detail/distance/point_to_geometry.hpp +++ b/include/boost/geometry/algorithms/detail/distance/point_to_geometry.hpp @@ -390,10 +390,11 @@ struct distance Segment const& segment, Strategy const& strategy) { - typename point_type::type p[2]; geometry::detail::assign_point_from_index<0>(segment, p[0]); geometry::detail::assign_point_from_index<1>(segment, p[1]); + + boost::ignore_unused_variable_warning(strategy); return strategy.apply(point, p[0], p[1]); } }; @@ -413,6 +414,7 @@ struct distance >::type apply(Point const& point, Box const& box, Strategy const& strategy) { + boost::ignore_unused_variable_warning(strategy); return strategy.apply(point, box); } }; diff --git a/include/boost/geometry/algorithms/detail/distance/range_to_segment_or_box.hpp b/include/boost/geometry/algorithms/detail/distance/range_to_segment_or_box.hpp index db2bcf68f..e1d113ff3 100644 --- a/include/boost/geometry/algorithms/detail/distance/range_to_segment_or_box.hpp +++ b/include/boost/geometry/algorithms/detail/distance/range_to_segment_or_box.hpp @@ -106,6 +106,7 @@ private: SegmentPoints const& segment_points, ComparableStrategy const& strategy) { + boost::ignore_unused_variable_warning(strategy); return strategy.apply(point, segment_points[0], segment_points[1]); } }; @@ -126,6 +127,8 @@ private: BoxPoints const& box_points, ComparableStrategy const& strategy) { + boost::ignore_unused_variable_warning(strategy); + comparable_return_type cd_min = strategy.apply(point, box_points[0], box_points[3]); diff --git a/include/boost/geometry/algorithms/detail/distance/segment_to_box.hpp b/include/boost/geometry/algorithms/detail/distance/segment_to_box.hpp index 3efa7673a..4a6f23839 100644 --- a/include/boost/geometry/algorithms/detail/distance/segment_to_box.hpp +++ b/include/boost/geometry/algorithms/detail/distance/segment_to_box.hpp @@ -81,6 +81,9 @@ private: { typedef cast_to_result cast; + boost::ignore_unused_variable_warning(pp_strategy); + boost::ignore_unused_variable_warning(ps_strategy); + // assert that the segment has non-negative slope BOOST_ASSERT( (math::equals(geometry::get<0>(p0), geometry::get<0>(p1)) @@ -217,6 +220,9 @@ private: { typedef cast_to_result cast; + boost::ignore_unused_variable_warning(pp_strategy); + boost::ignore_unused_variable_warning(ps_strategy); + // assert that the segment has negative slope BOOST_ASSERT ( geometry::get<0>(p0) < geometry::get<0>(p1) From 453a2c3784a4e2c625a589d3a2c70cea89d961a2 Mon Sep 17 00:00:00 2001 From: Menelaos Karavelas Date: Wed, 14 May 2014 15:39:12 +0300 Subject: [PATCH 62/66] [set ops L/L] fix unused variable warnings produced with clang++ with -Wextra --- .../geometry/algorithms/detail/overlay/follow_linear_linear.hpp | 2 +- .../geometry/algorithms/detail/turns/filter_continue_turns.hpp | 2 +- .../geometry/algorithms/detail/turns/remove_duplicate_turns.hpp | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/include/boost/geometry/algorithms/detail/overlay/follow_linear_linear.hpp b/include/boost/geometry/algorithms/detail/overlay/follow_linear_linear.hpp index 131154f82..6407706cb 100644 --- a/include/boost/geometry/algorithms/detail/overlay/follow_linear_linear.hpp +++ b/include/boost/geometry/algorithms/detail/overlay/follow_linear_linear.hpp @@ -289,7 +289,7 @@ protected: public: template static inline OutputIterator - apply(Linestring const& linestring, Linear const& linear, + apply(Linestring const& linestring, Linear const&, TurnIterator first, TurnIterator beyond, OutputIterator oit) { diff --git a/include/boost/geometry/algorithms/detail/turns/filter_continue_turns.hpp b/include/boost/geometry/algorithms/detail/turns/filter_continue_turns.hpp index 4f38e3e73..17fbd65dd 100644 --- a/include/boost/geometry/algorithms/detail/turns/filter_continue_turns.hpp +++ b/include/boost/geometry/algorithms/detail/turns/filter_continue_turns.hpp @@ -24,7 +24,7 @@ namespace detail { namespace turns template struct filter_continue_turns { - static inline void apply(Turns& turns) {} + static inline void apply(Turns&) {} }; diff --git a/include/boost/geometry/algorithms/detail/turns/remove_duplicate_turns.hpp b/include/boost/geometry/algorithms/detail/turns/remove_duplicate_turns.hpp index 41f52c059..d48736c8f 100644 --- a/include/boost/geometry/algorithms/detail/turns/remove_duplicate_turns.hpp +++ b/include/boost/geometry/algorithms/detail/turns/remove_duplicate_turns.hpp @@ -23,7 +23,7 @@ namespace detail { namespace turns template struct remove_duplicate_turns { - static inline void apply(Turns& turns) {} + static inline void apply(Turns&) {} }; From aebd3cefe25bd9c6098760baa0a5ef2155547382 Mon Sep 17 00:00:00 2001 From: Menelaos Karavelas Date: Wed, 14 May 2014 15:39:56 +0300 Subject: [PATCH 63/66] [test][set ops L/L] fix unused variable warnings produced with clang++ and -Wextra --- test/algorithms/test_set_ops_linear_linear.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/algorithms/test_set_ops_linear_linear.hpp b/test/algorithms/test_set_ops_linear_linear.hpp index 51d9d5794..c3ff6757d 100644 --- a/test/algorithms/test_set_ops_linear_linear.hpp +++ b/test/algorithms/test_set_ops_linear_linear.hpp @@ -92,7 +92,7 @@ struct multilinestring_equals template struct unique { - void operator()(MultiLinestring& mls) + void operator()(MultiLinestring&) { } }; From 1083dce4363c585af23bc810a53281846c3d7b60 Mon Sep 17 00:00:00 2001 From: Menelaos Karavelas Date: Wed, 14 May 2014 15:40:27 +0300 Subject: [PATCH 64/66] [test] fix unused variable warnings produced with clang++ and -Wextra --- test/to_svg.hpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/to_svg.hpp b/test/to_svg.hpp index 54891b7bf..9f7c37749 100644 --- a/test/to_svg.hpp +++ b/test/to_svg.hpp @@ -29,7 +29,7 @@ #include template -inline void turns_to_svg(Turns const& turns, Mapper & mapper, bool enrich = false) +inline void turns_to_svg(Turns const& turns, Mapper & mapper, bool /*enrich*/ = false) { // turn points in orange, + enrichment/traversal info typedef typename bg::coordinate_type::type coordinate_type; @@ -196,7 +196,7 @@ struct to_svg_assign_policy }; template -inline void to_svg(G const& g, std::string const& filename, bool sort = true) +inline void to_svg(G const& g, std::string const& filename, bool /*sort*/ = true) { namespace bg = boost::geometry; From 4f19973453f64538e537d7e08d3d4f733a53ba26 Mon Sep 17 00:00:00 2001 From: Barend Gehrels Date: Wed, 14 May 2014 14:41:24 +0200 Subject: [PATCH 65/66] [centroid] removed redundant distance include causing circular reference for unit test "geometries/adapted" --- include/boost/geometry/algorithms/centroid.hpp | 1 - 1 file changed, 1 deletion(-) diff --git a/include/boost/geometry/algorithms/centroid.hpp b/include/boost/geometry/algorithms/centroid.hpp index 106818d67..191866b9a 100644 --- a/include/boost/geometry/algorithms/centroid.hpp +++ b/include/boost/geometry/algorithms/centroid.hpp @@ -32,7 +32,6 @@ #include #include -#include #include #include #include From 8dcd329db770c847fe68e0d0c8c07abd3ee20747 Mon Sep 17 00:00:00 2001 From: Adam Wulkiewicz Date: Wed, 14 May 2014 15:13:01 +0200 Subject: [PATCH 66/66] [index] Use default_comparable_distance_result whenever possible --- .../algorithms/comparable_distance_centroid.hpp | 8 ++++---- .../detail/algorithms/comparable_distance_far.hpp | 6 +++--- .../detail/algorithms/comparable_distance_near.hpp | 8 ++++---- .../geometry/index/detail/algorithms/minmaxdist.hpp | 10 +++++----- .../index/detail/algorithms/path_intersection.hpp | 7 ++++++- .../index/detail/algorithms/segment_intersection.hpp | 5 ++++- .../geometry/index/detail/distance_predicates.hpp | 8 ++++---- .../geometry/index/detail/rtree/rstar/insert.hpp | 11 +++++++---- 8 files changed, 37 insertions(+), 26 deletions(-) diff --git a/include/boost/geometry/index/detail/algorithms/comparable_distance_centroid.hpp b/include/boost/geometry/index/detail/algorithms/comparable_distance_centroid.hpp index 841876eb3..c4e44cae1 100644 --- a/include/boost/geometry/index/detail/algorithms/comparable_distance_centroid.hpp +++ b/include/boost/geometry/index/detail/algorithms/comparable_distance_centroid.hpp @@ -2,7 +2,7 @@ // // squared distance between point and centroid of the box or point // -// Copyright (c) 2011-2013 Adam Wulkiewicz, Lodz, Poland. +// Copyright (c) 2011-2014 Adam Wulkiewicz, Lodz, Poland. // // Use, modification and distribution is subject to the Boost Software License, // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at @@ -24,7 +24,7 @@ template < size_t N> struct sum_for_indexable { - typedef typename geometry::default_distance_result::type result_type; + typedef typename geometry::default_comparable_distance_result::type result_type; inline static result_type apply(Point const& pt, PointIndexable const& i) { @@ -38,7 +38,7 @@ template < size_t DimensionIndex> struct sum_for_indexable_dimension { - typedef typename geometry::default_distance_result::type result_type; + typedef typename geometry::default_comparable_distance_result::type result_type; inline static result_type apply(Point const& pt, BoxIndexable const& i) { @@ -59,7 +59,7 @@ struct sum_for_indexable_dimension -typename geometry::default_distance_result::type +typename geometry::default_comparable_distance_result::type comparable_distance_centroid(Point const& pt, Indexable const& i) { return detail::sum_for_indexable< diff --git a/include/boost/geometry/index/detail/algorithms/comparable_distance_far.hpp b/include/boost/geometry/index/detail/algorithms/comparable_distance_far.hpp index 07dfcfc0f..214fbf6aa 100644 --- a/include/boost/geometry/index/detail/algorithms/comparable_distance_far.hpp +++ b/include/boost/geometry/index/detail/algorithms/comparable_distance_far.hpp @@ -2,7 +2,7 @@ // // squared distance between point and furthest point of the box or point // -// Copyright (c) 2011-2013 Adam Wulkiewicz, Lodz, Poland. +// Copyright (c) 2011-2014 Adam Wulkiewicz, Lodz, Poland. // // Use, modification and distribution is subject to the Boost Software License, // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at @@ -26,7 +26,7 @@ template < size_t DimensionIndex> struct sum_for_indexable_dimension { - typedef typename geometry::default_distance_result::type result_type; + typedef typename geometry::default_comparable_distance_result::type result_type; inline static result_type apply(Point const& pt, BoxIndexable const& i) { @@ -49,7 +49,7 @@ struct sum_for_indexable_dimension -typename geometry::default_distance_result::type +typename geometry::default_comparable_distance_result::type comparable_distance_far(Point const& pt, Indexable const& i) { return detail::sum_for_indexable< diff --git a/include/boost/geometry/index/detail/algorithms/comparable_distance_near.hpp b/include/boost/geometry/index/detail/algorithms/comparable_distance_near.hpp index 5584bf85e..15368a7d2 100644 --- a/include/boost/geometry/index/detail/algorithms/comparable_distance_near.hpp +++ b/include/boost/geometry/index/detail/algorithms/comparable_distance_near.hpp @@ -2,7 +2,7 @@ // // squared distance between point and nearest point of the box or point // -// Copyright (c) 2011-2013 Adam Wulkiewicz, Lodz, Poland. +// Copyright (c) 2011-2014 Adam Wulkiewicz, Lodz, Poland. // // Use, modification and distribution is subject to the Boost Software License, // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at @@ -23,7 +23,7 @@ template < size_t N> struct sum_for_indexable { - typedef typename geometry::default_distance_result::type result_type; + typedef typename geometry::default_comparable_distance_result::type result_type; inline static result_type apply(Point const& pt, PointIndexable const& i) { @@ -37,7 +37,7 @@ template < size_t DimensionIndex> struct sum_for_indexable_dimension { - typedef typename geometry::default_distance_result::type result_type; + typedef typename geometry::default_comparable_distance_result::type result_type; inline static result_type apply(Point const& pt, BoxIndexable const& i) { @@ -60,7 +60,7 @@ struct sum_for_indexable_dimension -typename geometry::default_distance_result::type +typename geometry::default_comparable_distance_result::type comparable_distance_near(Point const& pt, Indexable const& i) { return detail::sum_for_indexable< diff --git a/include/boost/geometry/index/detail/algorithms/minmaxdist.hpp b/include/boost/geometry/index/detail/algorithms/minmaxdist.hpp index 680fb202b..ab6291504 100644 --- a/include/boost/geometry/index/detail/algorithms/minmaxdist.hpp +++ b/include/boost/geometry/index/detail/algorithms/minmaxdist.hpp @@ -2,7 +2,7 @@ // // minmaxdist used in R-tree k nearest neighbors query // -// Copyright (c) 2011-2013 Adam Wulkiewicz, Lodz, Poland. +// Copyright (c) 2011-2014 Adam Wulkiewicz, Lodz, Poland. // // Use, modification and distribution is subject to the Boost Software License, // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at @@ -28,7 +28,7 @@ template < size_t DimensionIndex> struct smallest_for_indexable_dimension { - typedef typename geometry::default_distance_result::type result_type; + typedef typename geometry::default_comparable_distance_result::type result_type; inline static result_type apply(Point const& pt, BoxIndexable const& i, result_type const& maxd) { @@ -73,7 +73,7 @@ struct minmaxdist_impl template struct minmaxdist_impl { - typedef typename geometry::default_distance_result::type result_type; + typedef typename geometry::default_comparable_distance_result::type result_type; inline static result_type apply(Point const& pt, Indexable const& i) { @@ -84,7 +84,7 @@ struct minmaxdist_impl template struct minmaxdist_impl { - typedef typename geometry::default_distance_result::type result_type; + typedef typename geometry::default_comparable_distance_result::type result_type; inline static result_type apply(Point const& pt, Indexable const& i) { @@ -104,7 +104,7 @@ struct minmaxdist_impl * This is comparable distace. */ template -typename geometry::default_distance_result::type +typename geometry::default_comparable_distance_result::type minmaxdist(Point const& pt, Indexable const& i) { return detail::minmaxdist_impl< diff --git a/include/boost/geometry/index/detail/algorithms/path_intersection.hpp b/include/boost/geometry/index/detail/algorithms/path_intersection.hpp index a9e0f3dcb..fe92596ba 100644 --- a/include/boost/geometry/index/detail/algorithms/path_intersection.hpp +++ b/include/boost/geometry/index/detail/algorithms/path_intersection.hpp @@ -2,7 +2,7 @@ // // n-dimensional box-linestring intersection // -// Copyright (c) 2011-2013 Adam Wulkiewicz, Lodz, Poland. +// Copyright (c) 2011-2014 Adam Wulkiewicz, Lodz, Poland. // // Use, modification and distribution is subject to the Boost Software License, // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at @@ -23,6 +23,11 @@ struct path_intersection BOOST_MPL_ASSERT_MSG((false), NOT_IMPLEMENTED_FOR_THIS_GEOMETRY_OR_INDEXABLE, (path_intersection)); }; +// TODO: FP type must be used as a relative distance type! +// and default_distance_result can be some user-defined int type +// BUT! This code is experimental and probably won't be released at all +// since more flexible user-defined-nearest predicate should be added instead + template struct path_intersection { diff --git a/include/boost/geometry/index/detail/algorithms/segment_intersection.hpp b/include/boost/geometry/index/detail/algorithms/segment_intersection.hpp index a6ad30181..ec7a88f49 100644 --- a/include/boost/geometry/index/detail/algorithms/segment_intersection.hpp +++ b/include/boost/geometry/index/detail/algorithms/segment_intersection.hpp @@ -2,7 +2,7 @@ // // n-dimensional box-segment intersection // -// Copyright (c) 2011-2013 Adam Wulkiewicz, Lodz, Poland. +// Copyright (c) 2011-2014 Adam Wulkiewicz, Lodz, Poland. // // Use, modification and distribution is subject to the Boost Software License, // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at @@ -110,6 +110,9 @@ struct segment_intersection template static inline bool apply(Indexable const& b, Point const& p0, Point const& p1, RelativeDistance & relative_distance) { + +// TODO: this ASSERT CHECK is wrong for user-defined CoordinateTypes! + static const bool check = !::boost::is_integral::value; BOOST_MPL_ASSERT_MSG(check, RELATIVE_DISTANCE_MUST_BE_FLOATING_POINT_TYPE, (RelativeDistance)); diff --git a/include/boost/geometry/index/detail/distance_predicates.hpp b/include/boost/geometry/index/detail/distance_predicates.hpp index a8980cc41..3e057290a 100644 --- a/include/boost/geometry/index/detail/distance_predicates.hpp +++ b/include/boost/geometry/index/detail/distance_predicates.hpp @@ -3,7 +3,7 @@ // Spatial index distance predicates, calculators and checkers // used in nearest query - specialized for envelopes // -// Copyright (c) 2011-2013 Adam Wulkiewicz, Lodz, Poland. +// Copyright (c) 2011-2014 Adam Wulkiewicz, Lodz, Poland. // // Use, modification and distribution is subject to the Boost Software License, // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at @@ -108,7 +108,7 @@ struct calculate_distance< nearest, Indexable, Tag > { typedef detail::relation relation; typedef typename relation::value_type point_type; - typedef typename geometry::default_distance_result::type result_type; + typedef typename geometry::default_comparable_distance_result::type result_type; static inline bool apply(nearest const& p, Indexable const& i, result_type & result) { @@ -121,7 +121,7 @@ template struct calculate_distance< nearest< to_centroid >, Indexable, value_tag> { typedef Point point_type; - typedef typename geometry::default_distance_result::type result_type; + typedef typename geometry::default_comparable_distance_result::type result_type; static inline bool apply(nearest< to_centroid > const& p, Indexable const& i, result_type & result) { @@ -134,7 +134,7 @@ template struct calculate_distance< nearest< to_furthest >, Indexable, value_tag> { typedef Point point_type; - typedef typename geometry::default_distance_result::type result_type; + typedef typename geometry::default_comparable_distance_result::type result_type; static inline bool apply(nearest< to_furthest > const& p, Indexable const& i, result_type & result) { diff --git a/include/boost/geometry/index/detail/rtree/rstar/insert.hpp b/include/boost/geometry/index/detail/rtree/rstar/insert.hpp index 37bc31efa..c903d6ca2 100644 --- a/include/boost/geometry/index/detail/rtree/rstar/insert.hpp +++ b/include/boost/geometry/index/detail/rtree/rstar/insert.hpp @@ -2,7 +2,7 @@ // // R-tree R*-tree insert algorithm implementation // -// Copyright (c) 2011-2013 Adam Wulkiewicz, Lodz, Poland. +// Copyright (c) 2011-2014 Adam Wulkiewicz, Lodz, Poland. // // Use, modification and distribution is subject to the Boost Software License, // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at @@ -45,7 +45,9 @@ public: typedef typename elements_type::value_type element_type; typedef typename geometry::point_type::type point_type; // TODO: awulkiew - change second point_type to the point type of the Indexable? - typedef typename geometry::default_distance_result::type distance_type; + typedef typename + geometry::default_comparable_distance_result::type + comparable_distance_type; elements_type & elements = rtree::elements(n); @@ -63,8 +65,9 @@ public: // fill the container of centers' distances of children from current node's center typedef typename index::detail::rtree::container_from_elements_type< elements_type, - std::pair + std::pair >::type sorted_elements_type; + sorted_elements_type sorted_elements; // If constructor is used instead of resize() MS implementation leaks here sorted_elements.reserve(elements_count); // MAY THROW, STRONG (V, E: alloc, copy) @@ -84,7 +87,7 @@ public: sorted_elements.begin(), sorted_elements.begin() + reinserted_elements_count, sorted_elements.end(), - distances_dsc); // MAY THROW, BASIC (V, E: copy) + distances_dsc); // MAY THROW, BASIC (V, E: copy) // copy elements which will be reinserted result_elements.clear();