diff --git a/doc/compiling.qbk b/doc/compiling.qbk index 01c99fb74..1cde2c6a0 100644 --- a/doc/compiling.qbk +++ b/doc/compiling.qbk @@ -35,22 +35,42 @@ __boost_geometry__ library has been successfully tested with the following compilers: * __msvc__ (including Express Editions) + * 14.0 (__msvc__ 14 CTP) [/reported by develop report on March, 2015] + * 12.0 (__msvc__ 2013) [/reported by develop report on March, 2015] + * 11.0 (__msvc__ 2012) [/reported by develop report on March, 2015] * 10.0 (__msvc__ 2010) [/reported by Trunk report May 8, 2011] * 9.0 (__msvc__ 2008) [/reported by Trunk report May 8, 2011] * 8.0 (__msvc__ 2005) [/reported by Trunk report May 8, 2011] * gcc + * gcc 5.0.0 [/reported by develop report on March, 2015] + * gcc 4.9.2 [/reported by develop report on March, 2015] + * gcc 4.9.0 [/reported by develop report on March, 2015] + * gcc 4.8.4 [/reported by develop report on March, 2015] + * gcc 4.8.1 [/reported by develop report on March, 2015] + * gcc 4.8.0 [/reported by develop report on March, 2015] + * gcc 4.7.3 [/reported by develop report on March, 2015] + * gcc 4.7.2 [/reported by develop report on March, 2015] * gcc 4.7.0 [/reported by Trunk report February 12, 2012] + * gcc 4.6.4 [/reported by develop report on March, 2015] * gcc 4.6.2 [/reported by Trunk report February 12, 2012] * gcc 4.6.1 [/reported by Trunk report May 8, 2011] * gcc 4.6.0 [/reported by Trunk report May 8, 2011] + * gcc 4.5.3 [/reported by develop report on March, 2015] * gcc 4.5.2 [/reported by Trunk report May 8, 2011] + * gcc 4.4.7 [/reported by develop report on March, 2015] * gcc 4.4.0 [/reported by Trunk report May 8, 2011] * gcc 4.3.4 [/reported by Trunk report March 26, 2011] * gcc 4.2.1 [/reported by Trunk report May 8, 2011] * gcc 3.4.6 [/reported by Trunk report March 26, 2011] * clang + * clang 3.6 [/reported by develop report on March, 2015] + * clang 3.5 [/reported by develop report on March, 2015] + * clang 3.4 [/reported by develop report on March, 2015] * clang 3.3 [/reported by mloskot on October, 2013] * clang 3.2 [/reported by Trunk report March 26, 2011] + * clang 3.1 [/reported by develop report on March, 2015] + * clang 3.0 [/reported by develop report on March, 2015] + * clang 2.9 [/reported by develop report on March, 2015] * darwin * darwin 4.0.1 [/reported by Trunk report March 26, 2011] * darwin 4.4 [/reported by Trunk report March 26, 2011] diff --git a/doc/doxy/Doxyfile b/doc/doxy/Doxyfile index 633625f46..3aa8b86f4 100644 --- a/doc/doxy/Doxyfile +++ b/doc/doxy/Doxyfile @@ -89,6 +89,7 @@ ALIASES = qbk{1}="\xmlonly \1 \endxmlonly" \ param_x="First coordinate (usually x-coordinate)" \ param_y="Second coordinate (usually y-coordinate)" \ param_z="Third coordinate (usually z-coordinate)" \ + constructor_default_no_init="Default constructor, no initialization" \ constructor_default{1}="Default constructor, creating an empty \1" \ constructor_begin_end{1}="Constructor with begin and end, filling the \1" \ constructor_initializer_list{1}="Constructor taking std::initializer_list, filling the \1" \ @@ -200,13 +201,6 @@ INPUT = . .. ../../../../boost/geometry/core \ ../../../../boost/geometry/iterators \ ../../../../boost/geometry/io/wkt \ ../../../../boost/geometry/io/svg \ - ../../../../boost/geometry/multi/algorithms \ - ../../../../boost/geometry/multi/algorithms/detail \ - ../../../../boost/geometry/multi/core \ - ../../../../boost/geometry/multi/geometries \ - ../../../../boost/geometry/multi/geometries/register \ - ../../../../boost/geometry/multi/geometries/concepts \ - ../../../../boost/geometry/multi/strategies/cartesian \ ../../../../boost/geometry/policies \ ../../../../boost/geometry/policies/relate \ ../../../../boost/geometry/strategies \ diff --git a/doc/doxy/doxygen_input/pages/doxygen_pages.hpp b/doc/doxy/doxygen_input/pages/doxygen_pages.hpp index 7ec99f557..7369d3eb6 100644 --- a/doc/doxy/doxygen_input/pages/doxygen_pages.hpp +++ b/doc/doxy/doxygen_input/pages/doxygen_pages.hpp @@ -118,9 +118,6 @@ For users using only Cartesian points, with floating point coordinates (double), etc. Using this headerfile the library seems to be a non-template library, so it is convenient for users that are not so into the template world. -For users using multi-geometries: -- \#include - \section advanced_includes Advanced includes This section is for users who have their own geometries and want to use algorithms from the Boost.Geometry. diff --git a/doc/doxy/doxygen_input/sourcecode/doxygen_4.cpp b/doc/doxy/doxygen_input/sourcecode/doxygen_4.cpp index b6fdecb73..e7960271c 100644 --- a/doc/doxy/doxygen_input/sourcecode/doxygen_4.cpp +++ b/doc/doxy/doxygen_input/sourcecode/doxygen_4.cpp @@ -15,8 +15,6 @@ OBSOLETE #include #include -#include - #include #include diff --git a/doc/imports.qbk b/doc/imports.qbk index eb49aef9c..3625fc2e8 100644 --- a/doc/imports.qbk +++ b/doc/imports.qbk @@ -82,7 +82,17 @@ [import src/examples/core/tag.cpp] [import src/examples/core/tag_cast.cpp] +[import src/examples/geometries/box.cpp] +[import src/examples/geometries/linestring.cpp] +[import src/examples/geometries/multi_linestring.cpp] +[import src/examples/geometries/multi_point.cpp] +[import src/examples/geometries/multi_polygon.cpp] +[import src/examples/geometries/point_xy.cpp] [import src/examples/geometries/point.cpp] +[import src/examples/geometries/polygon.cpp] +[import src/examples/geometries/ring.cpp] +[import src/examples/geometries/segment.cpp] + [import src/examples/geometries/adapted/c_array.cpp] [import src/examples/geometries/adapted/boost_array.cpp] [import src/examples/geometries/adapted/boost_fusion.cpp] diff --git a/doc/index/introduction.qbk b/doc/index/introduction.qbk index daf2e39f3..e0c5b03e0 100644 --- a/doc/index/introduction.qbk +++ b/doc/index/introduction.qbk @@ -56,8 +56,10 @@ The examples of structures of trees created by use of different algorithms and e [[*100k knn queries*] [6.37s] [2.09s] [0.64s] [0.52s]] ] +The configuration of the machine used for testing was: /Intel(R) Core(TM) i7 870 @ 2.93GHz, 8GB RAM, MS Windows 7 x64/. +The code was compiled with optimization for speed (`O2`). + The performance of the R-tree for different values of Max parameter and Min=0.5*Max is presented in the table below. -The configuration of the machine used for testing is: /Intel(R) Core(TM) i7 870 @ 2.93GHz, 8GB RAM, MS Windows 7 x64/. In the two upper figures you can see the performance of the __rtree__ storing random, relatively small, non-overlapping, 2d boxes. In the lower ones, the performance of the __rtree__ also storing random, 2d boxes, but this time quite big and possibly overlapping. As you can see, the __rtree__ performance is different in both cases. diff --git a/doc/reference/geometries/box.qbk b/doc/reference/geometries/box.qbk new file mode 100644 index 000000000..100db1387 --- /dev/null +++ b/doc/reference/geometries/box.qbk @@ -0,0 +1,16 @@ +[/============================================================================ + Boost.Geometry (aka GGL, Generic Geometry Library) + + Copyright (c) 2009-2012 Barend Gehrels, Amsterdam, the Netherlands. + Copyright (c) 2009-2012 Mateusz Loskot, London, UK. + Copyright (c) 2009-2012 Bruno Lalande, Paris, France. + Copyright (c) 2015 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) +=============================================================================/] + +[heading Examples] +[box] +[box_output] diff --git a/doc/reference/geometries/linestring.qbk b/doc/reference/geometries/linestring.qbk new file mode 100644 index 000000000..b22e8d2ea --- /dev/null +++ b/doc/reference/geometries/linestring.qbk @@ -0,0 +1,16 @@ +[/============================================================================ + Boost.Geometry (aka GGL, Generic Geometry Library) + + Copyright (c) 2009-2012 Barend Gehrels, Amsterdam, the Netherlands. + Copyright (c) 2009-2012 Mateusz Loskot, London, UK. + Copyright (c) 2009-2012 Bruno Lalande, Paris, France. + Copyright (c) 2015 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) +=============================================================================/] + +[heading Examples] +[linestring] +[linestring_output] diff --git a/doc/reference/geometries/multi_linestring.qbk b/doc/reference/geometries/multi_linestring.qbk new file mode 100644 index 000000000..b2ee9b155 --- /dev/null +++ b/doc/reference/geometries/multi_linestring.qbk @@ -0,0 +1,16 @@ +[/============================================================================ + Boost.Geometry (aka GGL, Generic Geometry Library) + + Copyright (c) 2009-2012 Barend Gehrels, Amsterdam, the Netherlands. + Copyright (c) 2009-2012 Mateusz Loskot, London, UK. + Copyright (c) 2009-2012 Bruno Lalande, Paris, France. + Copyright (c) 2015 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) +=============================================================================/] + +[heading Examples] +[multi_linestring] +[multi_linestring_output] diff --git a/doc/reference/geometries/multi_point.qbk b/doc/reference/geometries/multi_point.qbk new file mode 100644 index 000000000..342242f86 --- /dev/null +++ b/doc/reference/geometries/multi_point.qbk @@ -0,0 +1,16 @@ +[/============================================================================ + Boost.Geometry (aka GGL, Generic Geometry Library) + + Copyright (c) 2009-2012 Barend Gehrels, Amsterdam, the Netherlands. + Copyright (c) 2009-2012 Mateusz Loskot, London, UK. + Copyright (c) 2009-2012 Bruno Lalande, Paris, France. + Copyright (c) 2015 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) +=============================================================================/] + +[heading Examples] +[multi_point] +[multi_point_output] diff --git a/doc/reference/geometries/multi_polygon.qbk b/doc/reference/geometries/multi_polygon.qbk new file mode 100644 index 000000000..1397dba17 --- /dev/null +++ b/doc/reference/geometries/multi_polygon.qbk @@ -0,0 +1,16 @@ +[/============================================================================ + Boost.Geometry (aka GGL, Generic Geometry Library) + + Copyright (c) 2009-2012 Barend Gehrels, Amsterdam, the Netherlands. + Copyright (c) 2009-2012 Mateusz Loskot, London, UK. + Copyright (c) 2009-2012 Bruno Lalande, Paris, France. + Copyright (c) 2015 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) +=============================================================================/] + +[heading Examples] +[multi_polygon] +[multi_polygon_output] diff --git a/doc/reference/geometries/point_xy.qbk b/doc/reference/geometries/point_xy.qbk new file mode 100644 index 000000000..ead56d36f --- /dev/null +++ b/doc/reference/geometries/point_xy.qbk @@ -0,0 +1,18 @@ +[/============================================================================ + Boost.Geometry (aka GGL, Generic Geometry Library) + + Copyright (c) 2009-2012 Barend Gehrels, Amsterdam, the Netherlands. + Copyright (c) 2009-2012 Mateusz Loskot, London, UK. + Copyright (c) 2009-2012 Bruno Lalande, Paris, France. + + 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) +=============================================================================/] + +[heading Examples] +[point_xy] +[point_xy_output] + +[include reference/geometries/point_assign_warning.qbk] + diff --git a/doc/reference/geometries/polygon.qbk b/doc/reference/geometries/polygon.qbk new file mode 100644 index 000000000..7b6909088 --- /dev/null +++ b/doc/reference/geometries/polygon.qbk @@ -0,0 +1,16 @@ +[/============================================================================ + Boost.Geometry (aka GGL, Generic Geometry Library) + + Copyright (c) 2009-2012 Barend Gehrels, Amsterdam, the Netherlands. + Copyright (c) 2009-2012 Mateusz Loskot, London, UK. + Copyright (c) 2009-2012 Bruno Lalande, Paris, France. + Copyright (c) 2015 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) +=============================================================================/] + +[heading Examples] +[polygon] +[polygon_output] diff --git a/doc/reference/geometries/ring.qbk b/doc/reference/geometries/ring.qbk new file mode 100644 index 000000000..746466a44 --- /dev/null +++ b/doc/reference/geometries/ring.qbk @@ -0,0 +1,16 @@ +[/============================================================================ + Boost.Geometry (aka GGL, Generic Geometry Library) + + Copyright (c) 2009-2012 Barend Gehrels, Amsterdam, the Netherlands. + Copyright (c) 2009-2012 Mateusz Loskot, London, UK. + Copyright (c) 2009-2012 Bruno Lalande, Paris, France. + Copyright (c) 2015 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) +=============================================================================/] + +[heading Examples] +[ring] +[ring_output] diff --git a/doc/reference/geometries/segment.qbk b/doc/reference/geometries/segment.qbk new file mode 100644 index 000000000..1336dcaac --- /dev/null +++ b/doc/reference/geometries/segment.qbk @@ -0,0 +1,16 @@ +[/============================================================================ + Boost.Geometry (aka GGL, Generic Geometry Library) + + Copyright (c) 2009-2012 Barend Gehrels, Amsterdam, the Netherlands. + Copyright (c) 2009-2012 Mateusz Loskot, London, UK. + Copyright (c) 2009-2012 Bruno Lalande, Paris, France. + Copyright (c) 2015 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) +=============================================================================/] + +[heading Examples] +[segment] +[segment_output] diff --git a/doc/release_notes.qbk b/doc/release_notes.qbk index 57dd261b0..68a26d961 100644 --- a/doc/release_notes.qbk +++ b/doc/release_notes.qbk @@ -18,6 +18,23 @@ [section:release_notes Release Notes] +[/=================] +[heading Boost 1.59] +[/=================] + +[*Additional functionality] + +* Added rtree const_iterator, begin(), end() and the support for Boost.Range. +* The support for C++11 `std::initializer_list` in geometries models. + +[*Improvements] + +* Upgraded rtree const_query_iterator category to ForwardIterator. + +[*Solved tickets] + +* [@https://svn.boost.org/trac/boost/ticket/11113 11113] Support easy enumeration of all elements with BOOST_FOREACH + [/=================] [heading Boost 1.58] [/=================] @@ -37,22 +54,30 @@ [*Solved tickets] +* [@https://svn.boost.org/trac/boost/ticket/8379 8379] Invalid comparison of the result of determinant * [@https://svn.boost.org/trac/boost/ticket/10108 10108] Error in overlay operations in specific cases where geometries touch at one point +* [@https://svn.boost.org/trac/boost/ticket/10201 10201] Suggestion to use different function to compare coordinates [wontfix] * [@https://svn.boost.org/trac/boost/ticket/10467 10467] Template parameter name coliding with B0 macro name defined in termios.h +* [@https://svn.boost.org/trac/boost/ticket/10640 10640] Invalid result of buffer() for CCW Polygons. * [@https://svn.boost.org/trac/boost/ticket/10666 10666] MSVC compiler warning C4127: conditional expression is constant * [@https://svn.boost.org/trac/boost/ticket/10747 10747] Error in rescaling causing errors in areal/areal set operations * [@https://svn.boost.org/trac/boost/ticket/10770 10770] Buffer fails for large distances, or rough round joins, where concavities where not intersected properly +* [@https://svn.boost.org/trac/boost/ticket/10658 10658] sym_difference yields bad result for int polygons +* [@https://svn.boost.org/trac/boost/ticket/10835 10835] Difference of multilinestring and polygon yields wrong result * [@https://svn.boost.org/trac/boost/ticket/10861 10861] Rtree failing to compile for Value being a pair or a tuple containing pointer to Geometry and the default equal_to<> used * [@https://svn.boost.org/trac/boost/ticket/10863 10863] Template parameter name coliding with B0 macro name defined in termios.h (duplicate of 10467) * [@https://svn.boost.org/trac/boost/ticket/10887 10887] Invalid result of within() and relate() for Linear/MultiPolygon * [@https://svn.boost.org/trac/boost/ticket/10890 10890] Invalid result of disjoint() for Point/Segment. * [@https://svn.boost.org/trac/boost/ticket/10904 10904] Invalid calculation of most significant Dimension of a segment in relate_cartesian_segments strategy * [@https://svn.boost.org/trac/boost/ticket/10912 10912] Invalid result of within() and relate() for Areal/Areal +* [@https://svn.boost.org/trac/boost/ticket/10951 10951] Tests failing on windows with intel compiler due to lack of /bigobj flag. * [@https://svn.boost.org/trac/boost/ticket/10957 10957] Assertion failure and invalid results of various relational operations. * [@https://svn.boost.org/trac/boost/ticket/10958 10958] Invalid results of disjoint() L/L and L/A. * [@https://svn.boost.org/trac/boost/ticket/10959 10959] Assertion failure in get_turns() used with no_rescale_policy. * [@https://svn.boost.org/trac/boost/ticket/10960 10960] Invalid result of get_turns() for L/A, missing turn. * [@https://svn.boost.org/trac/boost/ticket/10961 10961] Invalid result of get_turns() for L/A, invalid turn for a Linear spike. +* [@https://svn.boost.org/trac/boost/ticket/11112 11112] Compilation failure on Solaris due to a CS name clash (used for a macro on this platform) +* [@https://svn.boost.org/trac/boost/ticket/11121 11121] Invalid result of difference() for integral coordinates [*Bugfixes] @@ -68,6 +93,9 @@ * Bug in buffers for interior rings with large negative buffer distances * Bug in closing_iterator not working properly when the input range is empty * Bug in is_simple, not handling properly closed simple linestrings within multilinestrings +* Bug in rtree constructors taking a pair of Iterators or a Range (packing algorithm), the use of reference to destroyed temporary when Iterator's reference is not true reference, e.g. for some of the Range Adaptors. It also affects distance() and comparable_distance(). This bug may cause unexpected behavior of the rtree or distance() algorithm, e.g. an assertion failure or a SEGFAULT. +* Bug in rtree count() member function, the use of reference to destroyed temporary when object of type convertible but not the same as value_type or indexable_type is passed. If this happens, wrong result may be returned, in most cases 0. +* Bugs related to the handling of Ranges, preventing compilation of Geometries using non-Container Ranges in some algorithms (thanks to Samuel Debionne) [/=================] [heading Boost 1.57] diff --git a/doc/src/docutils/tools/doxygen_xml2qbk/for_debugger.ini b/doc/src/docutils/tools/doxygen_xml2qbk/for_debugger.ini index 7849e8f66..6dbaa7006 100644 --- a/doc/src/docutils/tools/doxygen_xml2qbk/for_debugger.ini +++ b/doc/src/docutils/tools/doxygen_xml2qbk/for_debugger.ini @@ -8,6 +8,6 @@ xml=../../../../doxy/doxygen_output/xml/structboost_1_1geometry_1_1closeable__vi start_include=boost/geometry/ convenience_header_path=../../../../../../../boost/geometry/ -convenience_headers=geometry.hpp,geometries/geometries.hpp,multi/multi.hpp +convenience_headers=geometry.hpp,geometries/geometries.hpp skip_namespace=boost::geometry:: diff --git a/doc/src/docutils/tools/doxygen_xml2qbk/quickbook_output.hpp b/doc/src/docutils/tools/doxygen_xml2qbk/quickbook_output.hpp index 7fed9f83f..17f20bf42 100644 --- a/doc/src/docutils/tools/doxygen_xml2qbk/quickbook_output.hpp +++ b/doc/src/docutils/tools/doxygen_xml2qbk/quickbook_output.hpp @@ -973,7 +973,11 @@ void quickbook_template_parameter_list_alt(std::vector const& paramet if ( !p.default_value.empty() ) { out << " = "; - inline_str_with_links(p.default_value, out); + // don't display default values from details + if ( p.default_value.find("detail") != std::string::npos ) + out << "/default/"; + else + inline_str_with_links(p.default_value, out); } first = false; @@ -996,13 +1000,20 @@ void quickbook_synopsis_alt(function const& f, std::ostream& out) offset += f.name.size(); break; case function_member : - inline_str_with_links(f.return_type, out); - out << " `" << f.name << "`"; - offset += f.return_type_without_links.size() + 1 + f.name.size(); - break; case function_free : - inline_str_with_links(f.definition, out); - offset += f.definition.size(); + // don't display return types from details + if ( f.return_type.find("detail") != std::string::npos ) + { + out << "/unspecified/"; + offset += 11; + } + else + { + inline_str_with_links(f.return_type, out); + offset += f.return_type_without_links.size(); + } + out << " `" << f.name << "`"; + offset += 1 + f.name.size(); break; case function_define : out << "`#define " << f.name << "`"; @@ -1036,7 +1047,11 @@ void quickbook_synopsis_alt(function const& f, std::ostream& out) if ( !p.default_value.empty() ) { out << " = "; - inline_str_with_links(p.default_value, out); + // don't display default values from details + if ( p.default_value.find("detail") != std::string::npos ) + out << "/default/"; + else + inline_str_with_links(p.default_value, out); } first = false; } @@ -1076,20 +1091,24 @@ void quickbook_synopsis_alt(class_or_struct const& cos, configuration const& con if (! cos.base_classes.empty()) { - out << "` : "; bool first = true; BOOST_FOREACH(base_class const& bc, cos.base_classes) { - if (! first) - { + // don't display base classes from details + if ( bc.name.find("detail") != std::string::npos ) + continue; + + if (first) + out << "` : "; + else out << std::endl << " , "; - } out << output_if_different(bc.derivation, "private") << output_if_different(bc.virtuality, "non-virtual") << namespace_skipped(bc.name, config); first = false; } - out << "`" << std::endl; + if (!first) + out << "`" << std::endl; } out << "`{`" << std::endl diff --git a/doc/src/docutils/tools/support_status/support_status.cpp b/doc/src/docutils/tools/support_status/support_status.cpp index 9372a1967..6bf00b5d0 100644 --- a/doc/src/docutils/tools/support_status/support_status.cpp +++ b/doc/src/docutils/tools/support_status/support_status.cpp @@ -1,8 +1,8 @@ // Boost.Geometry (aka GGL, Generic Geometry Library) // Tool reporting Implementation Support Status in QBK or plain text format -// Copyright (c) 2011-2012 Bruno Lalande, Paris, France. -// Copyright (c) 2011-2012 Barend Gehrels, Amsterdam, the Netherlands. +// Copyright (c) 2011-2015 Bruno Lalande, Paris, France. +// Copyright (c) 2011-2015 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 @@ -48,26 +48,6 @@ #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 "text_outputter.hpp" @@ -103,6 +83,11 @@ typedef boost::mpl::vector< struct algorithm: boost::geometry::dispatch::algorithm \ {}; +#define DECLARE_UNARY_ALGORITHM_WITH_BOOLEAN(algorithm) \ + template \ + struct algorithm: boost::geometry::dispatch::algorithm \ + {}; + #define DECLARE_BINARY_ALGORITHM(algorithm) \ template \ struct algorithm: boost::geometry::dispatch::algorithm \ @@ -129,7 +114,7 @@ DECLARE_UNARY_ALGORITHM(is_valid) DECLARE_UNARY_ALGORITHM(length) DECLARE_UNARY_ALGORITHM(num_geometries) DECLARE_UNARY_ALGORITHM(num_interior_rings) -DECLARE_UNARY_ALGORITHM(num_points) +DECLARE_UNARY_ALGORITHM_WITH_BOOLEAN(num_points) DECLARE_UNARY_ALGORITHM(num_segments) DECLARE_BINARY_ALGORITHM(overlaps) DECLARE_UNARY_ALGORITHM(perimeter) diff --git a/doc/src/examples/geometries/Jamfile.v2 b/doc/src/examples/geometries/Jamfile.v2 index 68a99b57a..cd0e71e6d 100644 --- a/doc/src/examples/geometries/Jamfile.v2 +++ b/doc/src/examples/geometries/Jamfile.v2 @@ -13,7 +13,16 @@ project boost-geometry-doc-src-example-geometries : # requirements ; +exe box : box.cpp ; +exe linestring : linestring.cpp ; exe point : point.cpp ; +exe point_xy : point_xy.cpp ; +exe polygon : polygon.cpp ; +exe multi_linestring : multi_linestring.cpp ; +exe multi_point : multi_point.cpp ; +exe multi_polygon : multi_polygon.cpp ; +exe ring : ring.cpp ; +exe segment : segment.cpp ; build-project adapted ; build-project register ; diff --git a/doc/src/examples/geometries/box.cpp b/doc/src/examples/geometries/box.cpp new file mode 100644 index 000000000..0dfecc83d --- /dev/null +++ b/doc/src/examples/geometries/box.cpp @@ -0,0 +1,58 @@ +// Boost.Geometry +// QuickBook Example + +// Copyright (c) 2011-2012 Barend Gehrels, Amsterdam, the Netherlands. +// Copyright (c) 2015 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) + +//[box +//` Declaration and use of the Boost.Geometry model::box, modelling the Box Concept + +#include +#include + +namespace bg = boost::geometry; + +int main() +{ + typedef bg::model::point point_t; + typedef bg::model::box box_t; + + box_t box1; /*< Default-construct a box. >*/ + box_t box2(point_t(0.0, 0.0), point_t(5.0, 5.0)); /*< Construct, assigning min and max corner point. >*/ + +#ifndef BOOST_NO_CXX11_UNIFIED_INITIALIZATION_SYNTAX + + box_t box3{{0.0, 0.0}, {5.0, 5.0}}; /*< Construct, using C++11 unified initialization syntax. >*/ + +#endif + + bg::set(box1, 1.0); /*< Set a coordinate, generic. >*/ + bg::set(box1, 2.0); + box1.max_corner().set<0>(3.0); /*< Set a coordinate, class-specific ([*Note]: prefer `bg::set()`). >*/ + box1.max_corner().set<1>(4.0); + + double min_x = bg::get(box1); /*< Get a coordinate, generic. >*/ + double min_y = bg::get(box1); + double max_x = box1.max_corner().get<0>(); /*< Get a coordinate, class-specific ([*Note]: prefer `bg::get()`). >*/ + double max_y = box1.max_corner().get<1>(); + + std::cout << min_x << ", " << min_y << ", " << max_x << ", " << max_y << std::endl; + + return 0; +} + +//] + + +//[box_output +/*` +Output: +[pre +1, 2, 3, 4 +] +*/ +//] diff --git a/doc/src/examples/geometries/linestring.cpp b/doc/src/examples/geometries/linestring.cpp new file mode 100644 index 000000000..b2ba1ae8b --- /dev/null +++ b/doc/src/examples/geometries/linestring.cpp @@ -0,0 +1,55 @@ +// Boost.Geometry +// QuickBook Example + +// Copyright (c) 2011-2012 Barend Gehrels, Amsterdam, the Netherlands. +// Copyright (c) 2015 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) + +//[linestring +//` Declaration and use of the Boost.Geometry model::linestring, modelling the Linestring Concept + +#include +#include +#include + +namespace bg = boost::geometry; + +int main() +{ + typedef bg::model::point point_t; + typedef bg::model::linestring linestring_t; + + linestring_t ls1; /*< Default-construct a linestring. >*/ + +#if !defined(BOOST_NO_CXX11_UNIFIED_INITIALIZATION_SYNTAX) \ + && !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST) + + linestring_t ls2{{0.0, 0.0}, {1.0, 0.0}, {1.0, 2.0}}; /*< Construct a linestring containing three points, using C++11 unified initialization syntax. >*/ + +#endif + + bg::append(ls1, point_t(0.0, 0.0)); /*< Append point. >*/ + bg::append(ls1, point_t(1.0, 0.0)); + bg::append(ls1, point_t(1.0, 2.0)); + + double l = bg::length(ls1); + + std::cout << l << std::endl; + + return 0; +} + +//] + + +//[linestring_output +/*` +Output: +[pre +3 +] +*/ +//] diff --git a/doc/src/examples/geometries/multi_linestring.cpp b/doc/src/examples/geometries/multi_linestring.cpp new file mode 100644 index 000000000..b7a039cf9 --- /dev/null +++ b/doc/src/examples/geometries/multi_linestring.cpp @@ -0,0 +1,62 @@ +// Boost.Geometry +// QuickBook Example + +// Copyright (c) 2011-2012 Barend Gehrels, Amsterdam, the Netherlands. +// Copyright (c) 2015 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) + +//[multi_linestring +//` Declaration and use of the Boost.Geometry model::multi_linestring, modelling the MultiLinestring Concept + +#include +#include +#include + +namespace bg = boost::geometry; + +int main() +{ + typedef bg::model::point point_t; + typedef bg::model::linestring linestring_t; + typedef bg::model::multi_linestring mlinestring_t; + + mlinestring_t mls1; /*< Default-construct a multi_linestring. >*/ + +#if !defined(BOOST_NO_CXX11_UNIFIED_INITIALIZATION_SYNTAX) \ + && !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST) + + mlinestring_t mls2{{{0.0, 0.0}, {0.0, 1.0}, {2.0, 1.0}}, + {{1.0, 0.0}, {2.0, 0.0}}}; /*< Construct a multi_linestring containing two linestrings, using C++11 unified initialization syntax. >*/ + +#endif + + mls1.resize(2); /*< Resize a multi_linestring, store two linestrings. >*/ + + bg::append(mls1[0], point_t(0.0, 0.0)); /*< Append point to the first linestring. >*/ + bg::append(mls1[0], point_t(0.0, 1.0)); + bg::append(mls1[0], point_t(2.0, 1.0)); + + bg::append(mls1[1], point_t(1.0, 0.0)); /*< Append point to the second linestring. >*/ + bg::append(mls1[1], point_t(2.0, 0.0)); + + double l = bg::length(mls1); + + std::cout << l << std::endl; + + return 0; +} + +//] + + +//[multi_linestring_output +/*` +Output: +[pre +4 +] +*/ +//] diff --git a/doc/src/examples/geometries/multi_point.cpp b/doc/src/examples/geometries/multi_point.cpp new file mode 100644 index 000000000..89d63d737 --- /dev/null +++ b/doc/src/examples/geometries/multi_point.cpp @@ -0,0 +1,55 @@ +// Boost.Geometry +// QuickBook Example + +// Copyright (c) 2011-2012 Barend Gehrels, Amsterdam, the Netherlands. +// Copyright (c) 2015 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) + +//[multi_point +//` Declaration and use of the Boost.Geometry model::multi_point, modelling the MultiPoint Concept + +#include +#include +#include + +namespace bg = boost::geometry; + +int main() +{ + typedef bg::model::point point_t; + typedef bg::model::multi_point mpoint_t; + + mpoint_t mpt1; /*< Default-construct a multi_point. >*/ + +#if !defined(BOOST_NO_CXX11_UNIFIED_INITIALIZATION_SYNTAX) \ + && !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST) + + mpoint_t mpt2{{{0.0, 0.0}, {1.0, 1.0}, {2.0, 2.0}}}; /*< Construct a multi_point containing three points, using C++11 unified initialization syntax. >*/ + +#endif + + bg::append(mpt1, point_t(0.0, 0.0)); /*< Append point to the multi_point. >*/ + bg::append(mpt1, point_t(1.0, 1.0)); + bg::append(mpt1, point_t(2.0, 2.0)); + + std::size_t count = bg::num_points(mpt1); + + std::cout << count << std::endl; + + return 0; +} + +//] + + +//[multi_point_output +/*` +Output: +[pre +3 +] +*/ +//] diff --git a/doc/src/examples/geometries/multi_polygon.cpp b/doc/src/examples/geometries/multi_polygon.cpp new file mode 100644 index 000000000..d5414868f --- /dev/null +++ b/doc/src/examples/geometries/multi_polygon.cpp @@ -0,0 +1,75 @@ +// Boost.Geometry +// QuickBook Example + +// Copyright (c) 2011-2012 Barend Gehrels, Amsterdam, the Netherlands. +// Copyright (c) 2015 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) + +//[multi_polygon +//` Declaration and use of the Boost.Geometry model::multi_polygon, modelling the MultiPolygon Concept + +#include +#include +#include + +namespace bg = boost::geometry; + +int main() +{ + typedef bg::model::point point_t; + typedef bg::model::polygon polygon_t; /*< Default parameters, clockwise, closed polygon. >*/ + typedef bg::model::multi_polygon mpolygon_t; /*< Clockwise, closed multi_polygon. >*/ + + mpolygon_t mpoly1; /*< Default-construct a multi_polygon. >*/ + +#if !defined(BOOST_NO_CXX11_UNIFIED_INITIALIZATION_SYNTAX) \ + && !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST) + + mpolygon_t mpoly2{{{{0.0, 0.0}, {0.0, 5.0}, {5.0, 5.0}, {5.0, 0.0}, {0.0, 0.0}}, + {{1.0, 1.0}, {4.0, 1.0}, {4.0, 4.0}, {1.0, 4.0}, {1.0, 1.0}}}, + {{{5.0, 5.0}, {5.0, 6.0}, {6.0, 6.0}, {6.0, 5.0}, {5.0, 5.0}}}}; /*< Construct a multi_polygon containing two polygons, using C++11 unified initialization syntax. >*/ + +#endif + + mpoly1.resize(2); /*< Resize a multi_polygon, store two polygons. >*/ + + bg::append(mpoly1[0].outer(), point_t(0.0, 0.0)); /*< Append point to the exterior ring of the first polygon. >*/ + bg::append(mpoly1[0].outer(), point_t(0.0, 5.0)); + bg::append(mpoly1[0].outer(), point_t(5.0, 5.0)); + bg::append(mpoly1[0].outer(), point_t(5.0, 0.0)); + bg::append(mpoly1[0].outer(), point_t(0.0, 0.0)); + + mpoly1[0].inners().resize(1); /*< Resize a container of interior rings of the first polygon. >*/ + bg::append(mpoly1[0].inners()[0], point_t(1.0, 1.0)); /*< Append point to the interior ring of the first polygon. >*/ + bg::append(mpoly1[0].inners()[0], point_t(4.0, 1.0)); + bg::append(mpoly1[0].inners()[0], point_t(4.0, 4.0)); + bg::append(mpoly1[0].inners()[0], point_t(1.0, 4.0)); + bg::append(mpoly1[0].inners()[0], point_t(1.0, 1.0)); + + bg::append(mpoly1[1].outer(), point_t(5.0, 5.0)); /*< Append point to the exterior ring of the second polygon. >*/ + bg::append(mpoly1[1].outer(), point_t(5.0, 6.0)); + bg::append(mpoly1[1].outer(), point_t(6.0, 6.0)); + bg::append(mpoly1[1].outer(), point_t(6.0, 5.0)); + bg::append(mpoly1[1].outer(), point_t(5.0, 5.0)); + + double a = bg::area(mpoly1); + + std::cout << a << std::endl; + + return 0; +} + +//] + + +//[multi_polygon_output +/*` +Output: +[pre +17 +] +*/ +//] diff --git a/doc/src/examples/geometries/point.cpp b/doc/src/examples/geometries/point.cpp index 82774cd83..6373217c8 100644 --- a/doc/src/examples/geometries/point.cpp +++ b/doc/src/examples/geometries/point.cpp @@ -19,11 +19,12 @@ int main() { bg::model::point point1; bg::model::point point2(1.0, 2.0, 3.0); /*< Construct, assigning three coordinates >*/ - point1.set<0>(1.0); /*< Set a coordinate. [*Note]: prefer using `bg::set<0>(point1, 1.0);` >*/ - point1.set<1>(2.0); - double x = point1.get<0>(); /*< Get a coordinate. [*Note]: prefer using `x = bg::get<0>(point1);` >*/ - double y = point1.get<1>(); + bg::set<0>(point1, 1.0); /*< Set a coordinate, generic. >*/ + point1.set<1>(2.0); /*< Set a coordinate, class-specific ([*Note]: prefer `bg::set()`). >*/ + + double x = bg::get<0>(point1); /*< Get a coordinate, generic. >*/ + double y = point1.get<1>(); /*< Get a coordinate, class-specific ([*Note]: prefer `bg::get()`). >*/ std::cout << x << ", " << y << std::endl; return 0; diff --git a/doc/src/examples/geometries/point_xy.cpp b/doc/src/examples/geometries/point_xy.cpp new file mode 100644 index 000000000..96eedf82b --- /dev/null +++ b/doc/src/examples/geometries/point_xy.cpp @@ -0,0 +1,44 @@ +// Boost.Geometry (aka GGL, Generic Geometry Library) +// QuickBook Example + +// Copyright (c) 2011-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) + +//[point_xy +//` Declaration and use of the Boost.Geometry model::d2::point_xy, modelling the Point Concept + +#include +#include +#include + +namespace bg = boost::geometry; + +int main() +{ + bg::model::d2::point_xy point1; + bg::model::d2::point_xy point2(1.0, 2.0); /*< Construct, assigning coordinates. >*/ + + bg::set<0>(point1, 1.0); /*< Set a coordinate, generic. >*/ + point1.y(2.0); /*< Set a coordinate, class-specific ([*Note]: prefer `bg::set()`). >*/ + + double x = bg::get<0>(point1); /*< Get a coordinate, generic. >*/ + double y = point1.y(); /*< Get a coordinate, class-specific ([*Note]: prefer `bg::get()`). >*/ + + std::cout << x << ", " << y << std::endl; + return 0; +} + +//] + + +//[point_xy_output +/*` +Output: +[pre +1, 2 +] +*/ +//] diff --git a/doc/src/examples/geometries/polygon.cpp b/doc/src/examples/geometries/polygon.cpp new file mode 100644 index 000000000..199a00824 --- /dev/null +++ b/doc/src/examples/geometries/polygon.cpp @@ -0,0 +1,65 @@ +// Boost.Geometry +// QuickBook Example + +// Copyright (c) 2011-2012 Barend Gehrels, Amsterdam, the Netherlands. +// Copyright (c) 2015 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) + +//[polygon +//` Declaration and use of the Boost.Geometry model::polygon, modelling the Polygon Concept + +#include +#include +#include + +namespace bg = boost::geometry; + +int main() +{ + typedef bg::model::point point_t; + typedef bg::model::polygon polygon_t; /*< Default parameters, clockwise, closed polygon. >*/ + + polygon_t poly1; /*< Default-construct a polygon. >*/ + +#if !defined(BOOST_NO_CXX11_UNIFIED_INITIALIZATION_SYNTAX) \ + && !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST) + + polygon_t polygon2{{{0.0, 0.0}, {0.0, 5.0}, {5.0, 5.0}, {5.0, 0.0}, {0.0, 0.0}}, + {{1.0, 1.0}, {4.0, 1.0}, {4.0, 4.0}, {1.0, 4.0}, {1.0, 1.0}}}; /*< Construct a polygon containing an exterior and interior ring, using C++11 unified initialization syntax. >*/ + +#endif + + bg::append(poly1.outer(), point_t(0.0, 0.0)); /*< Append point to the exterior ring. >*/ + bg::append(poly1.outer(), point_t(0.0, 5.0)); + bg::append(poly1.outer(), point_t(5.0, 5.0)); + bg::append(poly1.outer(), point_t(5.0, 0.0)); + bg::append(poly1.outer(), point_t(0.0, 0.0)); + + poly1.inners().resize(1); /*< Resize a container of interior rings. >*/ + bg::append(poly1.inners()[0], point_t(1.0, 1.0)); /*< Append point to the interior ring. >*/ + bg::append(poly1.inners()[0], point_t(4.0, 1.0)); + bg::append(poly1.inners()[0], point_t(4.0, 4.0)); + bg::append(poly1.inners()[0], point_t(1.0, 4.0)); + bg::append(poly1.inners()[0], point_t(1.0, 1.0)); + + double a = bg::area(poly1); + + std::cout << a << std::endl; + + return 0; +} + +//] + + +//[polygon_output +/*` +Output: +[pre +16 +] +*/ +//] diff --git a/doc/src/examples/geometries/ring.cpp b/doc/src/examples/geometries/ring.cpp new file mode 100644 index 000000000..1818ee127 --- /dev/null +++ b/doc/src/examples/geometries/ring.cpp @@ -0,0 +1,57 @@ +// Boost.Geometry +// QuickBook Example + +// Copyright (c) 2011-2012 Barend Gehrels, Amsterdam, the Netherlands. +// Copyright (c) 2015 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) + +//[ring +//` Declaration and use of the Boost.Geometry model::ring, modelling the Ring Concept + +#include +#include +#include + +namespace bg = boost::geometry; + +int main() +{ + typedef bg::model::point point_t; + typedef bg::model::ring ring_t; /*< Default parameters, clockwise, closed ring. >*/ + + ring_t ring1; /*< Default-construct a ring. >*/ + +#if !defined(BOOST_NO_CXX11_UNIFIED_INITIALIZATION_SYNTAX) \ + && !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST) + + ring_t ring2{{0.0, 0.0}, {0.0, 5.0}, {5.0, 5.0}, {5.0, 0.0}, {0.0, 0.0}}; /*< Construct a ring containing four points plus one closing point, using C++11 unified initialization syntax. >*/ + +#endif + + bg::append(ring1, point_t(0.0, 0.0)); /*< Append point. >*/ + bg::append(ring1, point_t(0.0, 5.0)); + bg::append(ring1, point_t(5.0, 5.0)); + bg::append(ring1, point_t(5.0, 0.0)); + bg::append(ring1, point_t(0.0, 0.0)); + + double a = bg::area(ring1); + + std::cout << a << std::endl; + + return 0; +} + +//] + + +//[ring_output +/*` +Output: +[pre +25 +] +*/ +//] diff --git a/doc/src/examples/geometries/segment.cpp b/doc/src/examples/geometries/segment.cpp new file mode 100644 index 000000000..3cbb4453c --- /dev/null +++ b/doc/src/examples/geometries/segment.cpp @@ -0,0 +1,59 @@ +// Boost.Geometry +// QuickBook Example + +// Copyright (c) 2011-2012 Barend Gehrels, Amsterdam, the Netherlands. +// Copyright (c) 2015 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) + +//[segment +//` Declaration and use of the Boost.Geometry model::segment, modelling the Segment Concept + +#include +#include +#include + +namespace bg = boost::geometry; + +int main() +{ + typedef bg::model::point point_t; + typedef bg::model::segment segment_t; + + segment_t seg1; /*< Default-construct a segment. >*/ + segment_t seg2(point_t(0.0, 0.0), point_t(5.0, 5.0)); /*< Construct, assigning the first and the second point. >*/ + +#ifndef BOOST_NO_CXX11_UNIFIED_INITIALIZATION_SYNTAX + + segment_t seg3{{0.0, 0.0}, {5.0, 5.0}}; /*< Construct, using C++11 unified initialization syntax. >*/ + +#endif + + bg::set<0, 0>(seg1, 1.0); /*< Set a coordinate. >*/ + bg::set<0, 1>(seg1, 2.0); + bg::set<1, 0>(seg1, 3.0); + bg::set<1, 1>(seg1, 4.0); + + double x0 = bg::get<0, 0>(seg1); /*< Get a coordinate. >*/ + double y0 = bg::get<0, 1>(seg1); + double x1 = bg::get<1, 0>(seg1); + double y1 = bg::get<1, 1>(seg1); + + std::cout << x0 << ", " << y0 << ", " << x1 << ", " << y1 << std::endl; + + return 0; +} + +//] + + +//[segment_output +/*` +Output: +[pre +1, 2, 3, 4 +] +*/ +//] diff --git a/example/c03_custom_linestring_example.cpp b/example/c03_custom_linestring_example.cpp index 8c6fd3697..587695749 100644 --- a/example/c03_custom_linestring_example.cpp +++ b/example/c03_custom_linestring_example.cpp @@ -18,8 +18,6 @@ #include #include -// To register the 'geographic' distance function to calculate distance over the earth: -#include #include // Define a GPS point with coordinates in latitude/longitude and some additional values diff --git a/example/c10_custom_cs_example.cpp b/example/c10_custom_cs_example.cpp index 098916cd6..3a802cc79 100644 --- a/example/c10_custom_cs_example.cpp +++ b/example/c10_custom_cs_example.cpp @@ -14,10 +14,6 @@ #include -#ifdef OPTIONALLY_ELLIPSOIDAL // see below -#include -#endif - // 1: declare a coordinate system. For example for Mars // Like for the Earth, we let the use choose between degrees or radians // (Unfortunately, in real life Mars has two coordinate systems: @@ -54,7 +50,7 @@ namespace boost { namespace geometry { namespace strategy { namespace distance { { template -struct default_strategy +struct default_strategy { typedef haversine type; }; @@ -98,7 +94,7 @@ int main() // giving 834.444 km d = boost::geometry::distance(viking1, pathfinder, boost::geometry::strategy::distance::andoyer - (boost::geometry::detail::ellipsoid(3396.2, 3376.2))); + (boost::geometry::srs::spheroid(3396.2, 3376.2))); std::cout << "Ellipsoidal distance: " << d << " km" << std::endl; #endif diff --git a/example/c11_custom_cs_transform_example.cpp b/example/c11_custom_cs_transform_example.cpp index 84c94eb06..b6878b6e7 100644 --- a/example/c11_custom_cs_transform_example.cpp +++ b/example/c11_custom_cs_transform_example.cpp @@ -90,7 +90,7 @@ namespace boost { namespace geometry { namespace strategy { namespace distance { }; template <> - struct default_strategy + struct default_strategy { typedef shift_and_calc_distance type; }; diff --git a/extensions/test/Jamfile.v2 b/extensions/test/Jamfile.v2 index c7e33b210..f7bf7de92 100644 --- a/extensions/test/Jamfile.v2 +++ b/extensions/test/Jamfile.v2 @@ -16,6 +16,8 @@ project boost-geometry-extensions-test ../../test ../../../boost/geometry/extensions/contrib/ttmath msvc:on + msvc:/bigobj + windows,intel:/bigobj /boost/timer//boost_timer ; diff --git a/extensions/test/gis/projections/projections.cpp b/extensions/test/gis/projections/projections.cpp index 097539d2c..a825b3ff9 100644 --- a/extensions/test/gis/projections/projections.cpp +++ b/extensions/test/gis/projections/projections.cpp @@ -42,16 +42,8 @@ inline void check(double v, double ve, std::string const& name, std::string const& axis) { - //BOOST_CHECK_CLOSE(v, ve, 0.001); - // Instead of (non-existing) BOOST_CHECK_CLOSE_MESSAGE(v, ve, 0.001, bla bla) - - if (! boost::test_tools::check_is_close(v, ve, boost::test_tools::fpc::percent_tolerance(0.001))) - { - std::ostringstream out; - out << "\n" << name << " " << axis << " -> " << v << " != " << ve; - BOOST_ERROR(out.str()); - } - + // (non-existing) BOOST_CHECK_CLOSE_MESSAGE(v, ve, 0.001, "\n" << name << " " << axis << " -> " << v << " != " << ve); + BOOST_CHECK_CLOSE(v, ve, 0.001); } template @@ -210,7 +202,7 @@ void test_all() test_forward

("putp6", 4.897000, 52.371000, 324931.055842, 5842588.644796, "+proj=putp6 +ellps=WGS84 +units=m"); test_forward

("putp6p", 4.897000, 52.371000, 338623.512107, 6396742.919679, "+proj=putp6p +ellps=WGS84 +units=m"); test_forward

("qua_aut", 4.897000, 52.371000, 370892.621714, 5629072.862494, "+proj=qua_aut +ellps=WGS84 +units=m"); - test_forward

("robin", 4.897000, 52.371000, 394576.507489, 5571243.439235, "+proj=robin +ellps=WGS84 +units=m"); + test_forward

("robin", 4.897000, 52.371000, 394576.507489, 5570940.631371, "+proj=robin +ellps=WGS84 +units=m"); test_forward

("rouss", 4.897000, 52.371000, 412826.227669, 6248368.849775, "+proj=rouss +ellps=WGS84 +units=m"); test_forward

("rpoly", 4.897000, 52.371000, 332447.130797, 5841164.662431, "+proj=rpoly +ellps=WGS84 +units=m"); test_forward

("sinu", 4.897000, 52.371000, 333528.909809, 5804625.044313, "+proj=sinu +ellps=WGS84 +units=m"); @@ -325,7 +317,7 @@ void test_all() test_inverse

("putp6", 324931.055842, 5842588.644796, 4.897000, 52.371000, "+proj=putp6 +ellps=WGS84 +units=m"); test_inverse

("putp6p", 338623.512107, 6396742.919679, 4.897000, 52.371000, "+proj=putp6p +ellps=WGS84 +units=m"); test_inverse

("qua_aut", 370892.621714, 5629072.862494, 4.897000, 52.371000, "+proj=qua_aut +ellps=WGS84 +units=m"); - test_inverse

("robin", 394576.507489, 5571243.439235, 4.897000, 52.371000, "+proj=robin +ellps=WGS84 +units=m"); + test_inverse

("robin", 394576.507489, 5570940.631371, 4.897000, 52.371000, "+proj=robin +ellps=WGS84 +units=m"); test_inverse

("rouss", 412826.227669, 6248368.849775, 4.959853, 52.433747, "+proj=rouss +ellps=WGS84 +units=m"); // F/I: 8188.459174 test_inverse

("sinu", 333528.909809, 5804625.044313, 4.897000, 52.371000, "+proj=sinu +ellps=WGS84 +units=m"); test_inverse

("somerc", 545131.546415, 6833623.829215, 4.897000, 52.371000, "+proj=somerc +ellps=WGS84 +units=m"); diff --git a/include/boost/geometry/algorithms/centroid.hpp b/include/boost/geometry/algorithms/centroid.hpp index 67ed68ac0..c4d995d78 100644 --- a/include/boost/geometry/algorithms/centroid.hpp +++ b/include/boost/geometry/algorithms/centroid.hpp @@ -1,9 +1,9 @@ // 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) 2014 Adam Wulkiewicz, Lodz, Poland. +// Copyright (c) 2007-2015 Barend Gehrels, Amsterdam, the Netherlands. +// Copyright (c) 2008-2015 Bruno Lalande, Paris, France. +// Copyright (c) 2009-2015 Mateusz Loskot, London, UK. +// Copyright (c) 2014-2015 Adam Wulkiewicz, Lodz, Poland. // This file was modified by Oracle on 2014, 2015. // Modifications copyright (c) 2014-2015 Oracle and/or its affiliates. @@ -56,7 +56,6 @@ #include #include -#include #include diff --git a/include/boost/geometry/algorithms/detail/buffer/buffered_piece_collection.hpp b/include/boost/geometry/algorithms/detail/buffer/buffered_piece_collection.hpp index a501e3f19..c13e12449 100644 --- a/include/boost/geometry/algorithms/detail/buffer/buffered_piece_collection.hpp +++ b/include/boost/geometry/algorithms/detail/buffer/buffered_piece_collection.hpp @@ -548,9 +548,8 @@ struct buffered_piece_collection // reliable integer-based ring. All turns can be compared (inside) to this // rings to see if they are inside. - for (typename piece_vector_type::iterator it = boost::begin(m_pieces); - it != boost::end(m_pieces); - ++it) + for (typename boost::range_iterator::type + it = boost::begin(m_pieces); it != boost::end(m_pieces); ++it) { piece& pc = *it; int piece_segment_index = pc.first_seg_id.segment_index; @@ -562,9 +561,9 @@ struct buffered_piece_collection } // Walk through them, in reverse to insert at right index int index_offset = pc.robust_turns.size() - 1; - for (typename std::vector::const_reverse_iterator - rit = pc.robust_turns.rbegin(); - rit != pc.robust_turns.rend(); + for (typename boost::range_reverse_iterator >::type + rit = boost::const_rbegin(pc.robust_turns); + rit != boost::const_rend(pc.robust_turns); ++rit, --index_offset) { int const index_in_vector = 1 + rit->seg_id.segment_index - piece_segment_index; diff --git a/include/boost/geometry/algorithms/detail/buffer/buffered_ring.hpp b/include/boost/geometry/algorithms/detail/buffer/buffered_ring.hpp index 9ea8bc1e8..0889663a2 100644 --- a/include/boost/geometry/algorithms/detail/buffer/buffered_ring.hpp +++ b/include/boost/geometry/algorithms/detail/buffer/buffered_ring.hpp @@ -1,6 +1,6 @@ // Boost.Geometry (aka GGL, Generic Geometry Library) -// Copyright (c) 2012-2014 Barend Gehrels, Amsterdam, the Netherlands. +// Copyright (c) 2012-2015 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 @@ -19,6 +19,8 @@ #include +#include + #include #include #include @@ -26,8 +28,6 @@ #include #include -#include - namespace boost { namespace geometry { diff --git a/include/boost/geometry/algorithms/detail/buffer/turn_in_piece_visitor.hpp b/include/boost/geometry/algorithms/detail/buffer/turn_in_piece_visitor.hpp index a7731549d..8803efdec 100644 --- a/include/boost/geometry/algorithms/detail/buffer/turn_in_piece_visitor.hpp +++ b/include/boost/geometry/algorithms/detail/buffer/turn_in_piece_visitor.hpp @@ -9,6 +9,9 @@ #ifndef BOOST_GEOMETRY_ALGORITHMS_DETAIL_BUFFER_TURN_IN_PIECE_VISITOR #define BOOST_GEOMETRY_ALGORITHMS_DETAIL_BUFFER_TURN_IN_PIECE_VISITOR + +#include + #include #include @@ -172,7 +175,8 @@ public : typename strategy_type::state_type state; strategy_type strategy; - + boost::ignore_unused(strategy); + for (std::size_t s = 0; s < piece.sections.size(); s++) { section_type const& section = piece.sections[s]; diff --git a/include/boost/geometry/algorithms/detail/distance/geometry_to_segment_or_box.hpp b/include/boost/geometry/algorithms/detail/distance/geometry_to_segment_or_box.hpp index 57257dbdc..d6de7cac9 100644 --- a/include/boost/geometry/algorithms/detail/distance/geometry_to_segment_or_box.hpp +++ b/include/boost/geometry/algorithms/detail/distance/geometry_to_segment_or_box.hpp @@ -185,10 +185,10 @@ public: Geometry const > segment_iterator_type; - typedef typename std::vector + typedef typename boost::range_const_iterator < - segment_or_box_point - >::const_iterator seg_or_box_iterator_type; + std::vector + >::type seg_or_box_const_iterator; typedef assign_new_min_iterator assign_new_value; @@ -219,8 +219,9 @@ public: // segment or box comparable_return_type cd_min1(0); point_iterator_type pit_min; - seg_or_box_iterator_type it_min1 = seg_or_box_points.begin(); - seg_or_box_iterator_type it_min2 = ++seg_or_box_points.begin(); + seg_or_box_const_iterator it_min1 = boost::const_begin(seg_or_box_points); + seg_or_box_const_iterator it_min2 = it_min1; + ++it_min2; bool first = true; for (point_iterator_type pit = points_begin(geometry); @@ -229,11 +230,11 @@ public: comparable_return_type cd; std::pair < - seg_or_box_iterator_type, seg_or_box_iterator_type + seg_or_box_const_iterator, seg_or_box_const_iterator > it_pair = point_to_point_range::apply(*pit, - seg_or_box_points.begin(), - seg_or_box_points.end(), + boost::const_begin(seg_or_box_points), + boost::const_end(seg_or_box_points), cstrategy, cd); @@ -250,12 +251,11 @@ public: // segments of the geometry comparable_return_type cd_min2(0); segment_iterator_type sit_min; - typename std::vector::const_iterator it_min; + seg_or_box_const_iterator it_min; first = true; - for (typename std::vector::const_iterator it - = seg_or_box_points.begin(); - it != seg_or_box_points.end(); ++it, first = false) + for (seg_or_box_const_iterator it = boost::const_begin(seg_or_box_points); + it != boost::const_end(seg_or_box_points); ++it, first = false) { comparable_return_type cd; segment_iterator_type sit diff --git a/include/boost/geometry/algorithms/detail/intersection/multi.hpp b/include/boost/geometry/algorithms/detail/intersection/multi.hpp index b1f13862f..88b49b016 100644 --- a/include/boost/geometry/algorithms/detail/intersection/multi.hpp +++ b/include/boost/geometry/algorithms/detail/intersection/multi.hpp @@ -1,9 +1,9 @@ // Boost.Geometry (aka GGL, Generic Geometry Library) -// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands. +// Copyright (c) 2007-2015 Barend Gehrels, Amsterdam, the Netherlands. // This file was modified by Oracle on 2014. -// Modifications copyright (c) 2014, Oracle and/or its affiliates. +// Modifications copyright (c) 2014-2015, Oracle and/or its affiliates. // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle @@ -36,8 +36,6 @@ #include #include -// TODO: remove this after moving num_point from multi directory -#include namespace boost { namespace geometry { diff --git a/include/boost/geometry/algorithms/detail/is_valid/has_duplicates.hpp b/include/boost/geometry/algorithms/detail/is_valid/has_duplicates.hpp index 5878841e7..6aa8c98c9 100644 --- a/include/boost/geometry/algorithms/detail/is_valid/has_duplicates.hpp +++ b/include/boost/geometry/algorithms/detail/is_valid/has_duplicates.hpp @@ -36,7 +36,10 @@ struct has_duplicates static inline bool apply(Range const& range, VisitPolicy& visitor) { typedef typename closeable_view::type view_type; - typedef typename boost::range_iterator::type iterator; + typedef typename boost::range_const_iterator + < + view_type const + >::type const_iterator; view_type view(range); @@ -47,9 +50,10 @@ struct has_duplicates geometry::equal_to::type> equal; - iterator it = boost::begin(view); - iterator next = ++boost::begin(view); - for (; next != boost::end(view); ++it, ++next) + const_iterator it = boost::const_begin(view); + const_iterator next = it; + ++next; + for (; next != boost::const_end(view); ++it, ++next) { if ( equal(*it, *next) ) { diff --git a/include/boost/geometry/algorithms/detail/partition.hpp b/include/boost/geometry/algorithms/detail/partition.hpp index 25a34ba2e..8b19add47 100644 --- a/include/boost/geometry/algorithms/detail/partition.hpp +++ b/include/boost/geometry/algorithms/detail/partition.hpp @@ -1,6 +1,11 @@ // Boost.Geometry (aka GGL, Generic Geometry Library) -// Copyright (c) 2011-2014 Barend Gehrels, Amsterdam, the Netherlands. +// Copyright (c) 2011-2015 Barend Gehrels, Amsterdam, the Netherlands. + +// This file was modified by Oracle on 2015. +// Modifications copyright (c) 2015 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 @@ -9,10 +14,13 @@ #ifndef BOOST_GEOMETRY_ALGORITHMS_DETAIL_PARTITION_HPP #define BOOST_GEOMETRY_ALGORITHMS_DETAIL_PARTITION_HPP +#include #include -#include -#include +#include +#include #include +#include + namespace boost { namespace geometry { @@ -20,8 +28,6 @@ namespace boost { namespace geometry namespace detail { namespace partition { -typedef std::vector index_vector_type; - template inline void divide_box(Box const& box, Box& lower_box, Box& upper_box) { @@ -38,31 +44,26 @@ inline void divide_box(Box const& box, Box& lower_box, Box& upper_box) geometry::set(upper_box, mid); } -// Divide collection into three subsets: lower, upper and oversized +// Divide forward_range into three subsets: lower, upper and oversized // (not-fitting) // (lower == left or bottom, upper == right or top) -template +template inline void divide_into_subsets(Box const& lower_box, Box const& upper_box, - InputCollection const& collection, - index_vector_type const& input, - index_vector_type& lower, - index_vector_type& upper, - index_vector_type& exceeding) + IteratorVector const& input, + IteratorVector& lower, + IteratorVector& upper, + IteratorVector& exceeding) { - typedef boost::range_iterator + typedef typename boost::range_iterator < - index_vector_type const - >::type index_iterator_type; + IteratorVector const + >::type it_type; - for(index_iterator_type it = boost::begin(input); - it != boost::end(input); - ++it) + for(it_type it = boost::begin(input); it != boost::end(input); ++it) { - bool const lower_overlapping = OverlapsPolicy::apply(lower_box, - collection[*it]); - bool const upper_overlapping = OverlapsPolicy::apply(upper_box, - collection[*it]); + bool const lower_overlapping = OverlapsPolicy::apply(lower_box, **it); + bool const upper_overlapping = OverlapsPolicy::apply(upper_box, **it); if (lower_overlapping && upper_overlapping) { @@ -84,99 +85,109 @@ inline void divide_into_subsets(Box const& lower_box, } } -template -inline void expand_with_elements(Box& total, - InputCollection const& collection, - index_vector_type const& input) +template +< + typename ExpandPolicy, + typename Box, + typename IteratorVector +> +inline void expand_with_elements(Box& total, IteratorVector const& input) { - typedef boost::range_iterator::type it_type; + typedef typename boost::range_iterator::type it_type; for(it_type it = boost::begin(input); it != boost::end(input); ++it) { - ExpandPolicy::apply(total, collection[*it]); + ExpandPolicy::apply(total, **it); } } -// Match collection with itself -template -inline void handle_one(InputCollection const& collection, - index_vector_type const& input, - Policy& policy) +// Match forward_range with itself +template +inline void handle_one(IteratorVector const& input, Policy& policy) { if (boost::size(input) == 0) { return; } - typedef boost::range_iterator::type - index_iterator_type; + typedef typename boost::range_iterator::type it_type; // Quadratic behaviour at lowest level (lowest quad, or all exceeding) - for(index_iterator_type it1 = boost::begin(input); - it1 != boost::end(input); - ++it1) + for (it_type it1 = boost::begin(input); it1 != boost::end(input); ++it1) { - index_iterator_type it2 = it1; - for(++it2; it2 != boost::end(input); ++it2) + it_type it2 = it1; + for (++it2; it2 != boost::end(input); ++it2) { - policy.apply(collection[*it1], collection[*it2]); + policy.apply(**it1, **it2); } } } -// Match collection 1 with collection 2 +// Match forward range 1 with forward range 2 template < - typename InputCollection1, - typename InputCollection2, - typename Policy + typename Policy, + typename IteratorVector1, + typename IteratorVector2 > -inline void handle_two( - InputCollection1 const& collection1, index_vector_type const& input1, - InputCollection2 const& collection2, index_vector_type const& input2, +inline void handle_two(IteratorVector1 const& input1, + IteratorVector2 const& input2, Policy& policy) { + typedef typename boost::range_iterator + < + IteratorVector1 const + >::type iterator_type1; + + typedef typename boost::range_iterator + < + IteratorVector2 const + >::type iterator_type2; + if (boost::size(input1) == 0 || boost::size(input2) == 0) { return; } - typedef boost::range_iterator - < - index_vector_type const - >::type index_iterator_type; - - for(index_iterator_type it1 = boost::begin(input1); + for(iterator_type1 it1 = boost::begin(input1); it1 != boost::end(input1); ++it1) { - for(index_iterator_type it2 = boost::begin(input2); + for(iterator_type2 it2 = boost::begin(input2); it2 != boost::end(input2); ++it2) { - policy.apply(collection1[*it1], collection2[*it2]); + policy.apply(**it1, **it2); } } } -inline bool recurse_ok(index_vector_type const& input, +template +inline bool recurse_ok(IteratorVector const& input, std::size_t min_elements, std::size_t level) { return boost::size(input) >= min_elements && level < 100; } -inline bool recurse_ok(index_vector_type const& input1, - index_vector_type const& input2, +template +inline bool recurse_ok(IteratorVector1 const& input1, + IteratorVector2 const& input2, std::size_t min_elements, std::size_t level) { return boost::size(input1) >= min_elements && recurse_ok(input2, min_elements, level); } -inline bool recurse_ok(index_vector_type const& input1, - index_vector_type const& input2, - index_vector_type const& input3, +template +< + typename IteratorVector1, + typename IteratorVector2, + typename IteratorVector3 +> +inline bool recurse_ok(IteratorVector1 const& input1, + IteratorVector2 const& input2, + IteratorVector3 const& input3, std::size_t min_elements, std::size_t level) { return boost::size(input1) >= min_elements @@ -193,7 +204,7 @@ template typename ExpandPolicy2, typename VisitBoxPolicy > -class partition_two_collections; +class partition_two_ranges; template @@ -204,79 +215,71 @@ template typename ExpandPolicy, typename VisitBoxPolicy > -class partition_one_collection +class partition_one_range { - typedef std::vector index_vector_type; - - template - static inline Box get_new_box(InputCollection const& collection, - index_vector_type const& input) + template + static inline Box get_new_box(IteratorVector const& input) { Box box; geometry::assign_inverse(box); - expand_with_elements(box, collection, input); + expand_with_elements(box, input); return box; } - template + template static inline void next_level(Box const& box, - InputCollection const& collection, - index_vector_type const& input, + IteratorVector const& input, std::size_t level, std::size_t min_elements, Policy& policy, VisitBoxPolicy& box_policy) { if (recurse_ok(input, min_elements, level)) { - partition_one_collection + partition_one_range < 1 - Dimension, Box, OverlapsPolicy, ExpandPolicy, VisitBoxPolicy - >::apply(box, collection, input, - level + 1, min_elements, policy, box_policy); + >::apply(box, input, level + 1, min_elements, policy, box_policy); } else { - handle_one(collection, input, policy); + handle_one(input, policy); } } - // Function to switch to two collections if there are geometries exceeding - // the separation line - template + // Function to switch to two forward ranges if there are + // geometries exceeding the separation line + template static inline void next_level2(Box const& box, - InputCollection const& collection, - index_vector_type const& input1, - index_vector_type const& input2, + IteratorVector const& input1, + IteratorVector const& input2, std::size_t level, std::size_t min_elements, Policy& policy, VisitBoxPolicy& box_policy) { - if (recurse_ok(input1, input2, min_elements, level)) { - partition_two_collections + partition_two_ranges < 1 - Dimension, Box, OverlapsPolicy, OverlapsPolicy, ExpandPolicy, ExpandPolicy, VisitBoxPolicy - >::apply(box, collection, input1, collection, input2, - level + 1, min_elements, policy, box_policy); + >::apply(box, input1, input2, level + 1, min_elements, + policy, box_policy); } else { - handle_two(collection, input1, collection, input2, policy); + handle_two(input1, input2, policy); } } public : - template + template static inline void apply(Box const& box, - InputCollection const& collection, - index_vector_type const& input, + IteratorVector const& input, std::size_t level, std::size_t min_elements, Policy& policy, VisitBoxPolicy& box_policy) @@ -286,33 +289,31 @@ public : Box lower_box, upper_box; divide_box(box, lower_box, upper_box); - index_vector_type lower, upper, exceeding; - divide_into_subsets(lower_box, upper_box, collection, + IteratorVector lower, upper, exceeding; + divide_into_subsets(lower_box, upper_box, input, lower, upper, exceeding); if (boost::size(exceeding) > 0) { // Get the box of exceeding-only - Box exceeding_box = get_new_box(collection, exceeding); + Box exceeding_box = get_new_box(exceeding); // Recursively do exceeding elements only, in next dimension they // will probably be less exceeding within the new box - next_level(exceeding_box, collection, exceeding, level, - min_elements, policy, box_policy); + next_level(exceeding_box, exceeding, level, min_elements, + policy, box_policy); - // Switch to two collections, combine exceeding with lower resp upper - // but not lower/lower, upper/upper - next_level2(exceeding_box, collection, exceeding, lower, level, - min_elements, policy, box_policy); - next_level2(exceeding_box, collection, exceeding, upper, level, - min_elements, policy, box_policy); + // Switch to two forward ranges, combine exceeding with + // lower resp upper, but not lower/lower, upper/upper + next_level2(exceeding_box, exceeding, lower, level, min_elements, + policy, box_policy); + next_level2(exceeding_box, exceeding, upper, level, min_elements, + policy, box_policy); } // Recursively call operation both parts - next_level(lower_box, collection, lower, level, min_elements, - policy, box_policy); - next_level(upper_box, collection, upper, level, min_elements, - policy, box_policy); + next_level(lower_box, lower, level, min_elements, policy, box_policy); + next_level(upper_box, upper, level, min_elements, policy, box_policy); } }; @@ -326,25 +327,21 @@ template typename ExpandPolicy2, typename VisitBoxPolicy > -class partition_two_collections +class partition_two_ranges { - typedef std::vector index_vector_type; - template < - typename InputCollection1, - typename InputCollection2, - typename Policy + typename Policy, + typename IteratorVector1, + typename IteratorVector2 > static inline void next_level(Box const& box, - InputCollection1 const& collection1, - index_vector_type const& input1, - InputCollection2 const& collection2, - index_vector_type const& input2, + IteratorVector1 const& input1, + IteratorVector2 const& input2, std::size_t level, std::size_t min_elements, Policy& policy, VisitBoxPolicy& box_policy) { - partition_two_collections + partition_two_ranges < 1 - Dimension, Box, @@ -353,50 +350,38 @@ class partition_two_collections ExpandPolicy1, ExpandPolicy2, VisitBoxPolicy - >::apply(box, collection1, input1, collection2, input2, - level + 1, min_elements, - policy, box_policy); + >::apply(box, input1, input2, level + 1, min_elements, + policy, box_policy); } - template - < - typename ExpandPolicy, - typename InputCollection - > - static inline Box get_new_box(InputCollection const& collection, - index_vector_type const& input) + template + static inline Box get_new_box(IteratorVector const& input) { Box box; geometry::assign_inverse(box); - expand_with_elements(box, collection, input); + expand_with_elements(box, input); return box; } - template - < - typename InputCollection1, - typename InputCollection2 - > - static inline Box get_new_box(InputCollection1 const& collection1, - index_vector_type const& input1, - InputCollection2 const& collection2, - index_vector_type const& input2) + template + static inline Box get_new_box(IteratorVector1 const& input1, + IteratorVector2 const& input2) { - Box box = get_new_box(collection1, input1); - expand_with_elements(box, collection2, input2); + Box box = get_new_box(input1); + expand_with_elements(box, input2); return box; } public : template < - typename InputCollection1, - typename InputCollection2, - typename Policy + typename Policy, + typename IteratorVector1, + typename IteratorVector2 > static inline void apply(Box const& box, - InputCollection1 const& collection1, index_vector_type const& input1, - InputCollection2 const& collection2, index_vector_type const& input2, + IteratorVector1 const& input1, + IteratorVector2 const& input2, std::size_t level, std::size_t min_elements, Policy& policy, VisitBoxPolicy& box_policy) @@ -406,11 +391,11 @@ public : Box lower_box, upper_box; divide_box(box, lower_box, upper_box); - index_vector_type lower1, upper1, exceeding1; - index_vector_type lower2, upper2, exceeding2; - divide_into_subsets(lower_box, upper_box, collection1, + IteratorVector1 lower1, upper1, exceeding1; + IteratorVector2 lower2, upper2, exceeding2; + divide_into_subsets(lower_box, upper_box, input1, lower1, upper1, exceeding1); - divide_into_subsets(lower_box, upper_box, collection2, + divide_into_subsets(lower_box, upper_box, input2, lower2, upper2, exceeding2); if (boost::size(exceeding1) > 0) @@ -419,35 +404,31 @@ public : if (recurse_ok(exceeding1, exceeding2, min_elements, level)) { - Box exceeding_box = get_new_box(collection1, exceeding1, - collection2, exceeding2); - next_level(exceeding_box, collection1, exceeding1, - collection2, exceeding2, level, - min_elements, policy, box_policy); + Box exceeding_box = get_new_box(exceeding1, exceeding2); + next_level(exceeding_box, exceeding1, exceeding2, level, + min_elements, policy, box_policy); } else { - handle_two(collection1, exceeding1, collection2, exceeding2, - policy); + handle_two(exceeding1, exceeding2, policy); } // All exceeding from 1 with lower and upper of 2: - // (Check sizes of all three collections to avoid recurse into + // (Check sizes of all three forward ranges to avoid recurse into // the same combinations again and again) if (recurse_ok(lower2, upper2, exceeding1, min_elements, level)) { - Box exceeding_box - = get_new_box(collection1, exceeding1); - next_level(exceeding_box, collection1, exceeding1, - collection2, lower2, level, min_elements, policy, box_policy); - next_level(exceeding_box, collection1, exceeding1, - collection2, upper2, level, min_elements, policy, box_policy); + Box exceeding_box = get_new_box(exceeding1); + next_level(exceeding_box, exceeding1, lower2, level, + min_elements, policy, box_policy); + next_level(exceeding_box, exceeding1, upper2, level, + min_elements, policy, box_policy); } else { - handle_two(collection1, exceeding1, collection2, lower2, policy); - handle_two(collection1, exceeding1, collection2, upper2, policy); + handle_two(exceeding1, lower2, policy); + handle_two(exceeding1, upper2, policy); } } @@ -456,37 +437,36 @@ public : // All exceeding from 2 with lower and upper of 1: if (recurse_ok(lower1, upper1, exceeding2, min_elements, level)) { - Box exceeding_box - = get_new_box(collection2, exceeding2); - next_level(exceeding_box, collection1, lower1, - collection2, exceeding2, level, min_elements, policy, box_policy); - next_level(exceeding_box, collection1, upper1, - collection2, exceeding2, level, min_elements, policy, box_policy); + Box exceeding_box = get_new_box(exceeding2); + next_level(exceeding_box, lower1, exceeding2, level, + min_elements, policy, box_policy); + next_level(exceeding_box, upper1, exceeding2, level, + min_elements, policy, box_policy); } else { - handle_two(collection1, lower1, collection2, exceeding2, policy); - handle_two(collection1, upper1, collection2, exceeding2, policy); + handle_two(lower1, exceeding2, policy); + handle_two(upper1, exceeding2, policy); } } if (recurse_ok(lower1, lower2, min_elements, level)) { - next_level(lower_box, collection1, lower1, collection2, lower2, level, - min_elements, policy, box_policy); + next_level(lower_box, lower1, lower2, level, + min_elements, policy, box_policy); } else { - handle_two(collection1, lower1, collection2, lower2, policy); + handle_two(lower1, lower2, policy); } if (recurse_ok(upper1, upper2, min_elements, level)) { - next_level(upper_box, collection1, upper1, collection2, upper2, level, - min_elements, policy, box_policy); + next_level(upper_box, upper1, upper2, level, + min_elements, policy, box_policy); } else { - handle_two(collection1, upper1, collection2, upper2, policy); + handle_two(upper1, upper2, policy); } } }; @@ -523,63 +503,67 @@ template > class partition { - typedef std::vector index_vector_type; - - template - static inline void expand_to_collection(InputCollection const& collection, - Box& total, index_vector_type& index_vector) + template + < + typename ExpandPolicy, + typename IncludePolicy, + typename ForwardRange, + typename IteratorVector + > + static inline void expand_to_range(ForwardRange const& forward_range, + Box& total, IteratorVector& iterator_vector) { - std::size_t index = 0; - for(typename boost::range_iterator::type it - = boost::begin(collection); - it != boost::end(collection); - ++it, ++index) + for(typename boost::range_iterator::type it + = boost::begin(forward_range); + it != boost::end(forward_range); + ++it) { if (IncludePolicy::apply(*it)) { ExpandPolicy::apply(total, *it); - index_vector.push_back(index); + iterator_vector.push_back(it); } } } public : - template - static inline void apply(InputCollection const& collection, + template + static inline void apply(ForwardRange const& forward_range, VisitPolicy& visitor, std::size_t min_elements = 16, VisitBoxPolicy box_visitor = detail::partition::visit_no_policy() ) { - if (std::size_t(boost::size(collection)) > min_elements) + typedef typename boost::range_iterator + < + ForwardRange const + >::type iterator_type; + + if (std::size_t(boost::size(forward_range)) > min_elements) { - index_vector_type index_vector; + std::vector iterator_vector; Box total; assign_inverse(total); - expand_to_collection(collection, - total, index_vector); + expand_to_range(forward_range, + total, iterator_vector); - detail::partition::partition_one_collection + detail::partition::partition_one_range < 0, Box, OverlapsPolicy1, ExpandPolicy1, VisitBoxPolicy - >::apply(total, collection, index_vector, 0, min_elements, - visitor, box_visitor); + >::apply(total, iterator_vector, 0, min_elements, + visitor, box_visitor); } else { - typedef typename boost::range_iterator - < - InputCollection const - >::type iterator_type; - for(iterator_type it1 = boost::begin(collection); - it1 != boost::end(collection); + for(iterator_type it1 = boost::begin(forward_range); + it1 != boost::end(forward_range); ++it1) { iterator_type it2 = it1; - for(++it2; it2 != boost::end(collection); ++it2) + for(++it2; it2 != boost::end(forward_range); ++it2) { visitor.apply(*it1, *it2); } @@ -589,53 +573,55 @@ public : template < - typename InputCollection1, - typename InputCollection2, + typename ForwardRange1, + typename ForwardRange2, typename VisitPolicy > - static inline void apply(InputCollection1 const& collection1, - InputCollection2 const& collection2, + static inline void apply(ForwardRange1 const& forward_range1, + ForwardRange2 const& forward_range2, VisitPolicy& visitor, std::size_t min_elements = 16, - VisitBoxPolicy box_visitor = detail::partition::visit_no_policy() + VisitBoxPolicy box_visitor + = detail::partition::visit_no_policy() ) { - if (std::size_t(boost::size(collection1)) > min_elements - && std::size_t(boost::size(collection2)) > min_elements) + typedef typename boost::range_iterator + < + ForwardRange1 const + >::type iterator_type1; + + typedef typename boost::range_iterator + < + ForwardRange2 const + >::type iterator_type2; + + if (std::size_t(boost::size(forward_range1)) > min_elements + && std::size_t(boost::size(forward_range2)) > min_elements) { - index_vector_type index_vector1, index_vector2; + std::vector iterator_vector1; + std::vector iterator_vector2; Box total; assign_inverse(total); - expand_to_collection(collection1, - total, index_vector1); - expand_to_collection(collection2, - total, index_vector2); + expand_to_range(forward_range1, + total, iterator_vector1); + expand_to_range(forward_range2, + total, iterator_vector2); - detail::partition::partition_two_collections + detail::partition::partition_two_ranges < 0, Box, OverlapsPolicy1, OverlapsPolicy2, ExpandPolicy1, ExpandPolicy2, VisitBoxPolicy - >::apply(total, - collection1, index_vector1, - collection2, index_vector2, - 0, min_elements, visitor, box_visitor); + >::apply(total, iterator_vector1, iterator_vector2, + 0, min_elements, visitor, box_visitor); } else { - typedef typename boost::range_iterator - < - InputCollection1 const - >::type iterator_type1; - typedef typename boost::range_iterator - < - InputCollection2 const - >::type iterator_type2; - for(iterator_type1 it1 = boost::begin(collection1); - it1 != boost::end(collection1); + for(iterator_type1 it1 = boost::begin(forward_range1); + it1 != boost::end(forward_range1); ++it1) { - for(iterator_type2 it2 = boost::begin(collection2); - it2 != boost::end(collection2); + for(iterator_type2 it2 = boost::begin(forward_range2); + it2 != boost::end(forward_range2); ++it2) { visitor.apply(*it1, *it2); diff --git a/include/boost/geometry/algorithms/detail/relate/result.hpp b/include/boost/geometry/algorithms/detail/relate/result.hpp index c32877852..e26bda67f 100644 --- a/include/boost/geometry/algorithms/detail/relate/result.hpp +++ b/include/boost/geometry/algorithms/detail/relate/result.hpp @@ -236,11 +236,11 @@ struct interrupt_dispatch static inline bool apply(Mask const& mask) { char m = mask.template get(); - return check(m); + return check_element(m); } template - static inline bool check(char m) + static inline bool check_element(char m) { if ( BOOST_GEOMETRY_CONDITION(V >= '0' && V <= '9') ) { @@ -395,7 +395,7 @@ inline bool may_update(Mask const& mask, Matrix const& matrix) ::template apply(mask, matrix); } -// check() +// check_matrix() template struct check_dispatch @@ -486,7 +486,7 @@ struct check_dispatch< boost::tuples::cons > }; template -inline bool check(Mask const& mask, Matrix const& matrix) +inline bool check_matrix(Mask const& mask, Matrix const& matrix) { return check_dispatch::apply(mask, matrix); } @@ -547,7 +547,7 @@ public: result_type result() const { return !interrupt - && check(m_mask, static_cast(*this)); + && check_matrix(m_mask, static_cast(*this)); } template @@ -965,7 +965,7 @@ struct static_check_dispatch }; template -struct static_check +struct static_check_matrix { template static inline bool apply(Matrix const& matrix) @@ -998,7 +998,7 @@ public: result_type result() const { return (!Interrupt || !interrupt) - && static_check:: + && static_check_matrix:: apply(static_cast(*this)); } diff --git a/include/boost/geometry/extensions/contrib/ttmath_stub.hpp b/include/boost/geometry/extensions/contrib/ttmath_stub.hpp index e2ade189b..014378e06 100644 --- a/include/boost/geometry/extensions/contrib/ttmath_stub.hpp +++ b/include/boost/geometry/extensions/contrib/ttmath_stub.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-2015 Barend Gehrels, Amsterdam, the Netherlands. +// Copyright (c) 2008-2015 Bruno Lalande, Paris, France. +// Copyright (c) 2009-2015 Mateusz Loskot, London, UK. + +// This file was modified by Oracle on 2014, 2015. +// Modifications copyright (c) 2014-2015, 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. @@ -83,7 +88,6 @@ namespace ttmath return ACos(v); } - template inline Big atan2(Big const& y, Big const& x) { @@ -103,6 +107,13 @@ namespace ttmath return two * ATan((sqrt(x * x + y * y) - x) / y); } + // needed in order to work with boost::geometry::math::mod + template + inline Big mod(Big const& x, + Big const& y) + { + return Mod(x, y); + } } // Specific structure implementing constructor @@ -116,18 +127,18 @@ struct ttmath_big : ttmath::Big<1,4> : ttmath::Big<1,4>(v) {} + // unary operator+() is implemented for completeness + inline ttmath_big const& operator+() const + { + return *this; + } + // needed in order to work with boost::geometry::math::abs inline ttmath_big operator-() const { return ttmath::Big<1,4>::operator-(); } - // needed because unary operator-() is defined (above) - inline ttmath_big operator-(ttmath_big const& other) const - { - return ttmath::Big<1,4>::operator-(other); - } - /* inline operator double() const { @@ -141,6 +152,29 @@ struct ttmath_big : ttmath::Big<1,4> */ }; + +// arithmetic operators for ttmath_big objects, defined as free functions +inline ttmath_big operator+(ttmath_big const& x, ttmath_big const& y) +{ + return static_cast const&>(x).operator+(y); +} + +inline ttmath_big operator-(ttmath_big const& x, ttmath_big const& y) +{ + return static_cast const&>(x).operator-(y); +} + +inline ttmath_big operator*(ttmath_big const& x, ttmath_big const& y) +{ + return static_cast const&>(x).operator*(y); +} + +inline ttmath_big operator/(ttmath_big const& x, ttmath_big const& y) +{ + return static_cast const&>(x).operator/(y); +} + + namespace boost{ namespace geometry { namespace math { diff --git a/include/boost/geometry/extensions/gis/geographic/strategies/dms_parser.hpp b/include/boost/geometry/extensions/gis/geographic/strategies/dms_parser.hpp index af746e821..884b4b072 100644 --- a/include/boost/geometry/extensions/gis/geographic/strategies/dms_parser.hpp +++ b/include/boost/geometry/extensions/gis/geographic/strategies/dms_parser.hpp @@ -254,15 +254,15 @@ namespace strategy #ifndef DOXYGEN_NO_STRATEGY_SPECIALIZATIONS -template class CS> -struct strategy_parse > +template class CoordinateSystem> +struct strategy_parse > { typedef strategy::dms_parser type; }; -template class CS> -struct strategy_parse > +template class CoordinateSystem> +struct strategy_parse > { typedef strategy::dms_parser type; }; diff --git a/include/boost/geometry/extensions/gis/projections/proj/aeqd.hpp b/include/boost/geometry/extensions/gis/projections/proj/aeqd.hpp index a0b599763..5e240ee1a 100644 --- a/include/boost/geometry/extensions/gis/projections/proj/aeqd.hpp +++ b/include/boost/geometry/extensions/gis/projections/proj/aeqd.hpp @@ -115,7 +115,7 @@ namespace boost { namespace geometry { namespace projections ct = cos(t); st = sin(t); Az = atan2(sin(lp_lon) * ct, this->m_proj_parm.cosph0 * st - this->m_proj_parm.sinph0 * coslam * ct); cA = cos(Az); sA = sin(Az); - s = aasin( fabs(sA) < TOL ? + s = aasin(fabs(sA) < TOL ? (this->m_proj_parm.cosph0 * st - this->m_proj_parm.sinph0 * coslam * ct) / cA : sin(lp_lon) * ct / sA ); H = this->m_proj_parm.He * cA; diff --git a/include/boost/geometry/extensions/gis/projections/proj/aitoff.hpp b/include/boost/geometry/extensions/gis/projections/proj/aitoff.hpp index dfa18b963..b20ca3fcb 100644 --- a/include/boost/geometry/extensions/gis/projections/proj/aitoff.hpp +++ b/include/boost/geometry/extensions/gis/projections/proj/aitoff.hpp @@ -135,6 +135,7 @@ namespace boost { namespace geometry { namespace projections \par Projection characteristics - Miscellaneous - Spheroid + - no inverse \par Example \image html ex_aitoff.gif */ @@ -156,6 +157,7 @@ namespace boost { namespace geometry { namespace projections \par Projection characteristics - Miscellaneous - Spheroid + - no inverse - lat_1 \par Example \image html ex_wintri.gif diff --git a/include/boost/geometry/extensions/gis/projections/proj/goode.hpp b/include/boost/geometry/extensions/gis/projections/proj/goode.hpp index 56204bf83..2058f2c47 100644 --- a/include/boost/geometry/extensions/gis/projections/proj/goode.hpp +++ b/include/boost/geometry/extensions/gis/projections/proj/goode.hpp @@ -41,7 +41,6 @@ #include #include #include - #include #include diff --git a/include/boost/geometry/extensions/gis/projections/proj/hatano.hpp b/include/boost/geometry/extensions/gis/projections/proj/hatano.hpp index 1c34ecec0..b415503c8 100644 --- a/include/boost/geometry/extensions/gis/projections/proj/hatano.hpp +++ b/include/boost/geometry/extensions/gis/projections/proj/hatano.hpp @@ -49,8 +49,8 @@ namespace boost { namespace geometry { namespace projections static const int NITER = 20; static const double EPS = 1e-7; static const double ONETOL = 1.000001; - static const double CN = 2.67595; - static const double CS = 2.43763; + static const double CN_ = 2.67595; + static const double CS_ = 2.43763; static const double RCN = 0.37369906014686373063; static const double RCS = 0.41023453108141924738; static const double FYCN = 1.75859; @@ -80,7 +80,7 @@ namespace boost { namespace geometry { namespace projections double th1, c; int i; - c = sin(lp_lat) * (lp_lat < 0. ? CS : CN); + c = sin(lp_lat) * (lp_lat < 0. ? CS_ : CN_); for (i = NITER; i; --i) { lp_lat -= th1 = (lp_lat + sin(lp_lat) - c) / (1. + cos(lp_lat)); if (fabs(th1) < EPS) break; diff --git a/include/boost/geometry/extensions/gis/projections/proj/lcca.hpp b/include/boost/geometry/extensions/gis/projections/proj/lcca.hpp index 7fd3bcabb..3c7cdffe5 100644 --- a/include/boost/geometry/extensions/gis/projections/proj/lcca.hpp +++ b/include/boost/geometry/extensions/gis/projections/proj/lcca.hpp @@ -117,7 +117,8 @@ namespace boost { namespace geometry { namespace projections template void setup_lcca(Parameters& par, par_lcca& proj_parm) { - double s2p0, N0, R0, tan0/*, tan20*/; + double s2p0, N0, R0, tan0, tan20; + boost::ignore_unused(tan20); pj_enfn(par.es, proj_parm.en); if (!pj_param(par.params, "tlat_0").i) throw proj_exception(50); if (par.phi0 == 0.) throw proj_exception(51); @@ -128,7 +129,7 @@ namespace boost { namespace geometry { namespace projections N0 = sqrt(R0); R0 *= par.one_es * N0; tan0 = tan(par.phi0); - //tan20 = tan0 * tan0; + tan20 = tan0 * tan0; proj_parm.r0 = N0 / tan0; proj_parm.C = 1. / (6. * R0 * N0); // par.inv = e_inverse; diff --git a/include/boost/geometry/extensions/gis/projections/proj/mbtfpp.hpp b/include/boost/geometry/extensions/gis/projections/proj/mbtfpp.hpp index 3c7af1f48..c25c56376 100644 --- a/include/boost/geometry/extensions/gis/projections/proj/mbtfpp.hpp +++ b/include/boost/geometry/extensions/gis/projections/proj/mbtfpp.hpp @@ -46,7 +46,7 @@ namespace boost { namespace geometry { namespace projections { #ifndef DOXYGEN_NO_DETAIL namespace detail { namespace mbtfpp{ - static const double CS = .95257934441568037152; + static const double CS_ = .95257934441568037152; static const double FXC = .92582009977255146156; static const double FYC = 3.40168025708304504493; static const double C23 = .66666666666666666666; @@ -70,7 +70,7 @@ namespace boost { namespace geometry { namespace projections inline void fwd(geographic_type& lp_lon, geographic_type& lp_lat, cartesian_type& xy_x, cartesian_type& xy_y) const { - lp_lat = asin(CS * sin(lp_lat)); + lp_lat = asin(CS_ * sin(lp_lat)); xy_x = FXC * lp_lon * (2. * cos(C23 * lp_lat) - 1.); xy_y = FYC * sin(C13 * lp_lat); } @@ -84,7 +84,7 @@ namespace boost { namespace geometry { namespace projections } else lp_lat = asin(lp_lat); lp_lon = xy_x / ( FXC * (2. * cos(C23 * (lp_lat *= 3.)) - 1.) ); - if (fabs(lp_lat = sin(lp_lat) / CS) >= 1.) { + if (fabs(lp_lat = sin(lp_lat) / CS_) >= 1.) { if (fabs(lp_lat) > ONEEPS) throw proj_exception(); else lp_lat = (lp_lat < 0.) ? -HALFPI : HALFPI; } else diff --git a/include/boost/geometry/extensions/gis/projections/proj/putp3.hpp b/include/boost/geometry/extensions/gis/projections/proj/putp3.hpp index 4a674f8e3..46ac57bd9 100644 --- a/include/boost/geometry/extensions/gis/projections/proj/putp3.hpp +++ b/include/boost/geometry/extensions/gis/projections/proj/putp3.hpp @@ -142,7 +142,6 @@ namespace boost { namespace geometry { namespace projections \tparam Parameters parameter type \par Projection characteristics - Pseudocylindrical - - no inverse - Spheroid \par Example \image html ex_putp3p.gif diff --git a/include/boost/geometry/extensions/gis/projections/proj/putp6.hpp b/include/boost/geometry/extensions/gis/projections/proj/putp6.hpp index c04842e82..c91d847f8 100644 --- a/include/boost/geometry/extensions/gis/projections/proj/putp6.hpp +++ b/include/boost/geometry/extensions/gis/projections/proj/putp6.hpp @@ -98,7 +98,7 @@ namespace boost { namespace geometry { namespace projections lp_lat = xy_y / this->m_proj_parm.C_y; r = sqrt(1. + lp_lat * lp_lat); lp_lon = xy_x / (this->m_proj_parm.C_x * (this->m_proj_parm.D - r)); - lp_lat = aasin( ( (this->m_proj_parm.A - r) * lp_lat - log(lp_lat + r) ) / this->m_proj_parm.B); + lp_lat = aasin(( (this->m_proj_parm.A - r) * lp_lat - log(lp_lat + r) ) / this->m_proj_parm.B); } }; diff --git a/include/boost/geometry/extensions/gis/projections/proj/robin.hpp b/include/boost/geometry/extensions/gis/projections/proj/robin.hpp index 53769ceb9..8397c71a6 100644 --- a/include/boost/geometry/extensions/gis/projections/proj/robin.hpp +++ b/include/boost/geometry/extensions/gis/projections/proj/robin.hpp @@ -55,49 +55,54 @@ namespace boost { namespace geometry { namespace projections static const double ONEEPS = 1.000001; static const double EPS = 1e-8; - /* note: following terms based upon 5 deg. intervals in degrees. */ - static struct COEFS { + + + struct COEFS { double c0, c1, c2, c3; - } X[] = { - {1, -5.67239e-12, -7.15511e-05, 3.11028e-06}, - {0.9986, -0.000482241, -2.4897e-05, -1.33094e-06}, - {0.9954, -0.000831031, -4.4861e-05, -9.86588e-07}, - {0.99, -0.00135363, -5.96598e-05, 3.67749e-06}, - {0.9822, -0.00167442, -4.4975e-06, -5.72394e-06}, - {0.973, -0.00214869, -9.03565e-05, 1.88767e-08}, - {0.96, -0.00305084, -9.00732e-05, 1.64869e-06}, - {0.9427, -0.00382792, -6.53428e-05, -2.61493e-06}, - {0.9216, -0.00467747, -0.000104566, 4.8122e-06}, - {0.8962, -0.00536222, -3.23834e-05, -5.43445e-06}, - {0.8679, -0.00609364, -0.0001139, 3.32521e-06}, - {0.835, -0.00698325, -6.40219e-05, 9.34582e-07}, - {0.7986, -0.00755337, -5.00038e-05, 9.35532e-07}, - {0.7597, -0.00798325, -3.59716e-05, -2.27604e-06}, - {0.7186, -0.00851366, -7.0112e-05, -8.63072e-06}, - {0.6732, -0.00986209, -0.000199572, 1.91978e-05}, - {0.6213, -0.010418, 8.83948e-05, 6.24031e-06}, - {0.5722, -0.00906601, 0.000181999, 6.24033e-06}, - {0.5322, 0.,0.,0.} }, - Y[] = { - {0, 0.0124, 3.72529e-10, 1.15484e-09}, - {0.062, 0.0124001, 1.76951e-08, -5.92321e-09}, - {0.124, 0.0123998, -7.09668e-08, 2.25753e-08}, - {0.186, 0.0124008, 2.66917e-07, -8.44523e-08}, - {0.248, 0.0123971, -9.99682e-07, 3.15569e-07}, - {0.31, 0.0124108, 3.73349e-06, -1.1779e-06}, - {0.372, 0.0123598, -1.3935e-05, 4.39588e-06}, - {0.434, 0.0125501, 5.20034e-05, -1.00051e-05}, - {0.4958, 0.0123198, -9.80735e-05, 9.22397e-06}, - {0.5571, 0.0120308, 4.02857e-05, -5.2901e-06}, - {0.6176, 0.0120369, -3.90662e-05, 7.36117e-07}, - {0.6769, 0.0117015, -2.80246e-05, -8.54283e-07}, - {0.7346, 0.0113572, -4.08389e-05, -5.18524e-07}, - {0.7903, 0.0109099, -4.86169e-05, -1.0718e-06}, - {0.8435, 0.0103433, -6.46934e-05, 5.36384e-09}, - {0.8936, 0.00969679, -6.46129e-05, -8.54894e-06}, - {0.9394, 0.00840949, -0.000192847, -4.21023e-06}, - {0.9761, 0.00616525, -0.000256001, -4.21021e-06}, - {1., 0.,0.,0} }; + }; + + static const struct COEFS X[] = { + {1, 2.2199e-17, -7.15515e-05, 3.1103e-06}, + {0.9986, -0.000482243, -2.4897e-05, -1.3309e-06}, + {0.9954, -0.00083103, -4.48605e-05, -9.86701e-07}, + {0.99, -0.00135364, -5.9661e-05, 3.6777e-06}, + {0.9822, -0.00167442, -4.49547e-06, -5.72411e-06}, + {0.973, -0.00214868, -9.03571e-05, 1.8736e-08}, + {0.96, -0.00305085, -9.00761e-05, 1.64917e-06}, + {0.9427, -0.00382792, -6.53386e-05, -2.6154e-06}, + {0.9216, -0.00467746, -0.00010457, 4.81243e-06}, + {0.8962, -0.00536223, -3.23831e-05, -5.43432e-06}, + {0.8679, -0.00609363, -0.000113898, 3.32484e-06}, + {0.835, -0.00698325, -6.40253e-05, 9.34959e-07}, + {0.7986, -0.00755338, -5.00009e-05, 9.35324e-07}, + {0.7597, -0.00798324, -3.5971e-05, -2.27626e-06}, + {0.7186, -0.00851367, -7.01149e-05, -8.6303e-06}, + {0.6732, -0.00986209, -0.000199569, 1.91974e-05}, + {0.6213, -0.010418, 8.83923e-05, 6.24051e-06}, + {0.5722, -0.00906601, 0.000182, 6.24051e-06}, + {0.5322, -0.00677797, 0.000275608, 6.24051e-06} + }; + static const struct COEFS Y[] = { + {-5.20417e-18, 0.0124, 1.21431e-18, -8.45284e-11}, + {0.062, 0.0124, -1.26793e-09, 4.22642e-10}, + {0.124, 0.0124, 5.07171e-09, -1.60604e-09}, + {0.186, 0.0123999, -1.90189e-08, 6.00152e-09}, + {0.248, 0.0124002, 7.10039e-08, -2.24e-08}, + {0.31, 0.0123992, -2.64997e-07, 8.35986e-08}, + {0.372, 0.0124029, 9.88983e-07, -3.11994e-07}, + {0.434, 0.0123893, -3.69093e-06, -4.35621e-07}, + {0.4958, 0.0123198, -1.02252e-05, -3.45523e-07}, + {0.5571, 0.0121916, -1.54081e-05, -5.82288e-07}, + {0.6176, 0.0119938, -2.41424e-05, -5.25327e-07}, + {0.6769, 0.011713, -3.20223e-05, -5.16405e-07}, + {0.7346, 0.0113541, -3.97684e-05, -6.09052e-07}, + {0.7903, 0.0109107, -4.89042e-05, -1.04739e-06}, + {0.8435, 0.0103431, -6.4615e-05, -1.40374e-09}, + {0.8936, 0.00969686, -6.4636e-05, -8.547e-06}, + {0.9394, 0.00840947, -0.000192841, -4.2106e-06}, + {0.9761, 0.00616527, -0.000256, -4.2106e-06}, + {1, 0.00328947, -0.000319159, -4.2106e-06} + }; // template class, using CRTP to implement forward/inverse template diff --git a/include/boost/geometry/extensions/gis/projections/proj/sconics.hpp b/include/boost/geometry/extensions/gis/projections/proj/sconics.hpp index f5a536af0..191d3e018 100644 --- a/include/boost/geometry/extensions/gis/projections/proj/sconics.hpp +++ b/include/boost/geometry/extensions/gis/projections/proj/sconics.hpp @@ -112,7 +112,6 @@ namespace boost { namespace geometry { namespace projections break; case PCONIC: rho = this->m_proj_parm.c2 * (this->m_proj_parm.c1 - tan(lp_lat - this->m_proj_parm.sig)); - // rho = this->m_proj_parm.c2 * (this->m_proj_parm.c1 - tan(lp_lat)); BUG STILL IN proj (reported 2012-03-03) break; default: rho = this->m_proj_parm.rho_c - lp_lat; diff --git a/include/boost/geometry/extensions/gis/projections/proj/sterea.hpp b/include/boost/geometry/extensions/gis/projections/proj/sterea.hpp index 95ed81a89..05bc9f5cd 100644 --- a/include/boost/geometry/extensions/gis/projections/proj/sterea.hpp +++ b/include/boost/geometry/extensions/gis/projections/proj/sterea.hpp @@ -116,9 +116,7 @@ namespace boost { namespace geometry { namespace projections template void setup_sterea(Parameters& par, par_sterea& proj_parm) { - - double R; proj_parm.en = detail::gauss::gauss_ini(par.e, par.phi0, proj_parm.phic0, R); proj_parm.sinc0 = sin(proj_parm.phic0); diff --git a/include/boost/geometry/extensions/gis/projections/proj/tmerc.hpp b/include/boost/geometry/extensions/gis/projections/proj/tmerc.hpp index fff3798fd..fcacc828f 100644 --- a/include/boost/geometry/extensions/gis/projections/proj/tmerc.hpp +++ b/include/boost/geometry/extensions/gis/projections/proj/tmerc.hpp @@ -98,7 +98,7 @@ namespace boost { namespace geometry { namespace projections { xy_x = HUGE_VAL; xy_y = HUGE_VAL; - throw proj_exception( -14 ); + throw proj_exception(-14 ); return; } @@ -184,7 +184,7 @@ namespace boost { namespace geometry { namespace projections { xy_x = HUGE_VAL; xy_y = HUGE_VAL; - throw proj_exception( -14 ); + throw proj_exception(-14 ); return; } diff --git a/include/boost/geometry/extensions/gis/projections/proj/urm5.hpp b/include/boost/geometry/extensions/gis/projections/proj/urm5.hpp index 05c1501a6..7d1fba571 100644 --- a/include/boost/geometry/extensions/gis/projections/proj/urm5.hpp +++ b/include/boost/geometry/extensions/gis/projections/proj/urm5.hpp @@ -106,7 +106,8 @@ namespace boost { namespace geometry { namespace projections \par Projection characteristics - Pseudocylindrical - Spheroid - - n= q= alphi= + - no inverse + - n= q= alpha= \par Example \image html ex_urm5.gif */ diff --git a/include/boost/geometry/geometries/box.hpp b/include/boost/geometry/geometries/box.hpp index a2e3d4fd7..5fcf171f0 100644 --- a/include/boost/geometry/geometries/box.hpp +++ b/include/boost/geometry/geometries/box.hpp @@ -17,10 +17,14 @@ #include #include +#include #include #include +#if defined(BOOST_GEOMETRY_ENABLE_ACCESS_DEBUGGING) +#include +#endif namespace boost { namespace geometry @@ -29,18 +33,21 @@ namespace boost { namespace geometry namespace model { - /*! - \brief Class box: defines a box made of two describing points - \ingroup geometries - \details Box is always described by a min_corner() and a max_corner() point. If another - rectangle is used, use linear_ring or polygon. - \note Boxes are for selections and for calculating the envelope of geometries. Not all algorithms - are implemented for box. Boxes are also used in Spatial Indexes. - \tparam Point point type. The box takes a point type as template parameter. - The point type can be any point type. - It can be 2D but can also be 3D or more dimensional. - The box can also take a latlong point type as template parameter. +\brief Class box: defines a box made of two describing points +\ingroup geometries +\details Box is always described by a min_corner() and a max_corner() point. If another + rectangle is used, use linear_ring or polygon. +\note Boxes are for selections and for calculating the envelope of geometries. Not all algorithms +are implemented for box. Boxes are also used in Spatial Indexes. +\tparam Point point type. The box takes a point type as template parameter. +The point type can be any point type. +It can be 2D but can also be 3D or more dimensional. +The box can also take a latlong point type as template parameter. + +\qbk{[include reference/geometries/box.qbk]} +\qbk{before.synopsis, [heading Model of]} +\qbk{before.synopsis, [link geometry.reference.concepts.concept_box Box Concept]} */ template @@ -50,7 +57,25 @@ class box public: - inline box() {} +#if !defined(BOOST_GEOMETRY_ENABLE_ACCESS_DEBUGGING) +#if !defined(BOOST_NO_CXX11_DEFAULTED_FUNCTIONS) + /// \constructor_default_no_init + box() = default; +#else + /// \constructor_default_no_init + inline box() + {} +#endif +#else // defined(BOOST_GEOMETRY_ENABLE_ACCESS_DEBUGGING) + inline box() + { + m_created = 1; + } + ~box() + { + m_created = 0; + } +#endif /*! \brief Constructor taking the minimum corner point and the maximum corner point @@ -59,18 +84,50 @@ public: { geometry::convert(min_corner, m_min_corner); geometry::convert(max_corner, m_max_corner); + +#if defined(BOOST_GEOMETRY_ENABLE_ACCESS_DEBUGGING) + m_created = 1; +#endif } - inline Point const& min_corner() const { return m_min_corner; } - inline Point const& max_corner() const { return m_max_corner; } + inline Point const& min_corner() const + { +#if defined(BOOST_GEOMETRY_ENABLE_ACCESS_DEBUGGING) + BOOST_ASSERT(m_created == 1); +#endif + return m_min_corner; + } + inline Point const& max_corner() const + { +#if defined(BOOST_GEOMETRY_ENABLE_ACCESS_DEBUGGING) + BOOST_ASSERT(m_created == 1); +#endif + return m_max_corner; + } - inline Point& min_corner() { return m_min_corner; } - inline Point& max_corner() { return m_max_corner; } + inline Point& min_corner() + { +#if defined(BOOST_GEOMETRY_ENABLE_ACCESS_DEBUGGING) + BOOST_ASSERT(m_created == 1); +#endif + return m_min_corner; + } + inline Point& max_corner() + { +#if defined(BOOST_GEOMETRY_ENABLE_ACCESS_DEBUGGING) + BOOST_ASSERT(m_created == 1); +#endif + return m_max_corner; + } private: Point m_min_corner; Point m_max_corner; + +#if defined(BOOST_GEOMETRY_ENABLE_ACCESS_DEBUGGING) + int m_created; +#endif }; diff --git a/include/boost/geometry/geometries/linestring.hpp b/include/boost/geometry/geometries/linestring.hpp index 68dc87a3c..22c9c99de 100644 --- a/include/boost/geometry/geometries/linestring.hpp +++ b/include/boost/geometry/geometries/linestring.hpp @@ -26,12 +26,10 @@ #include -#ifdef BOOST_GEOMETRY_EXPERIMENTAL_ENABLE_INITIALIZER_LIST #include #ifndef BOOST_NO_CXX11_HDR_INITIALIZER_LIST #include #endif -#endif namespace boost { namespace geometry { @@ -46,6 +44,7 @@ namespace model \tparam Container \tparam_container \tparam Allocator \tparam_allocator +\qbk{[include reference/geometries/linestring.qbk]} \qbk{before.synopsis, [heading Model of] [link geometry.reference.concepts.concept_linestring Linestring Concept] @@ -76,7 +75,6 @@ public : : base_type(begin, end) {} -#ifdef BOOST_GEOMETRY_EXPERIMENTAL_ENABLE_INITIALIZER_LIST #ifndef BOOST_NO_CXX11_HDR_INITIALIZER_LIST /// \constructor_initializer_list{linestring} @@ -97,7 +95,6 @@ public : // } //#endif -#endif #endif }; diff --git a/include/boost/geometry/geometries/multi_linestring.hpp b/include/boost/geometry/geometries/multi_linestring.hpp index 195a58139..cd08fdbe1 100644 --- a/include/boost/geometry/geometries/multi_linestring.hpp +++ b/include/boost/geometry/geometries/multi_linestring.hpp @@ -23,12 +23,10 @@ #include #include -#ifdef BOOST_GEOMETRY_EXPERIMENTAL_ENABLE_INITIALIZER_LIST #include #ifndef BOOST_NO_CXX11_HDR_INITIALIZER_LIST #include #endif -#endif namespace boost { namespace geometry { @@ -43,6 +41,7 @@ namespace model e.g. a highway (with interruptions) \ingroup geometries +\qbk{[include reference/geometries/multi_linestring.qbk]} \qbk{before.synopsis, [heading Model of] [link geometry.reference.concepts.concept_multi_linestring MultiLineString Concept] @@ -58,7 +57,10 @@ class multi_linestring : public Container > { BOOST_CONCEPT_ASSERT( (concept::Linestring) ); -#ifdef BOOST_GEOMETRY_EXPERIMENTAL_ENABLE_INITIALIZER_LIST +#ifndef BOOST_NO_CXX11_HDR_INITIALIZER_LIST + + // default constructor and base_type definitions are required only + // if the constructor taking std::initializer_list is defined typedef Container > base_type; @@ -68,8 +70,6 @@ public: : base_type() {} -#ifndef BOOST_NO_CXX11_HDR_INITIALIZER_LIST - /// \constructor_initializer_list{multi_linestring} inline multi_linestring(std::initializer_list l) : base_type(l.begin(), l.end()) @@ -88,7 +88,6 @@ public: // } //#endif -#endif #endif }; diff --git a/include/boost/geometry/geometries/multi_point.hpp b/include/boost/geometry/geometries/multi_point.hpp index a5e64bb91..ab4cd8817 100644 --- a/include/boost/geometry/geometries/multi_point.hpp +++ b/include/boost/geometry/geometries/multi_point.hpp @@ -23,12 +23,10 @@ #include #include -#ifdef BOOST_GEOMETRY_EXPERIMENTAL_ENABLE_INITIALIZER_LIST #include #ifndef BOOST_NO_CXX11_HDR_INITIALIZER_LIST #include #endif -#endif namespace boost { namespace geometry { @@ -45,6 +43,8 @@ namespace model \tparam Allocator \tparam_allocator \details Multipoint can be used to group points belonging to each other, e.g. a constellation, or the result set of an intersection + +\qbk{[include reference/geometries/multi_point.qbk]} \qbk{before.synopsis, [heading Model of] [link geometry.reference.concepts.concept_multi_point MultiPoint Concept] @@ -74,7 +74,6 @@ public : : base_type(begin, end) {} -#ifdef BOOST_GEOMETRY_EXPERIMENTAL_ENABLE_INITIALIZER_LIST #ifndef BOOST_NO_CXX11_HDR_INITIALIZER_LIST /// \constructor_initializer_list{multi_point} @@ -95,7 +94,6 @@ public : // } //#endif -#endif #endif }; diff --git a/include/boost/geometry/geometries/multi_polygon.hpp b/include/boost/geometry/geometries/multi_polygon.hpp index 51fcf235f..9db74b4ec 100644 --- a/include/boost/geometry/geometries/multi_polygon.hpp +++ b/include/boost/geometry/geometries/multi_polygon.hpp @@ -23,12 +23,10 @@ #include #include -#ifdef BOOST_GEOMETRY_EXPERIMENTAL_ENABLE_INITIALIZER_LIST #include #ifndef BOOST_NO_CXX11_HDR_INITIALIZER_LIST #include #endif -#endif namespace boost { namespace geometry { @@ -42,6 +40,7 @@ namespace model e.g. Hawaii \ingroup geometries +\qbk{[include reference/geometries/multi_polygon.qbk]} \qbk{before.synopsis, [heading Model of] [link geometry.reference.concepts.concept_multi_polygon MultiPolygon Concept] @@ -57,7 +56,10 @@ class multi_polygon : public Container > { BOOST_CONCEPT_ASSERT( (concept::Polygon) ); -#ifdef BOOST_GEOMETRY_EXPERIMENTAL_ENABLE_INITIALIZER_LIST +#ifndef BOOST_NO_CXX11_HDR_INITIALIZER_LIST + + // default constructor and base_type definitions are required only + // if the constructor taking std::initializer_list is defined typedef Container > base_type; @@ -67,8 +69,6 @@ public: : base_type() {} -#ifndef BOOST_NO_CXX11_HDR_INITIALIZER_LIST - /// \constructor_initializer_list{multi_polygon} inline multi_polygon(std::initializer_list l) : base_type(l.begin(), l.end()) @@ -87,7 +87,6 @@ public: // } //#endif -#endif #endif }; diff --git a/include/boost/geometry/geometries/point.hpp b/include/boost/geometry/geometries/point.hpp index 056c7d5d0..5f78bcff2 100644 --- a/include/boost/geometry/geometries/point.hpp +++ b/include/boost/geometry/geometries/point.hpp @@ -22,14 +22,20 @@ #include +#include +#include #include -#include #include #include #include #include +#if defined(BOOST_GEOMETRY_ENABLE_ACCESS_DEBUGGING) +#include +#include +#endif + namespace boost { namespace geometry { @@ -100,7 +106,10 @@ template > class point { -private: + BOOST_MPL_ASSERT_MSG((DimensionCount >= 1), + DIMENSION_GREATER_THAN_ZERO_EXPECTED, + (boost::mpl::int_)); + // The following enum is used to fully instantiate the // CoordinateSystem class and check the correctness of the units // passed for non-Cartesian coordinate systems. @@ -108,11 +117,27 @@ private: public: - /// @brief Default constructor, no initialization +#if !defined(BOOST_GEOMETRY_ENABLE_ACCESS_DEBUGGING) +#if !defined(BOOST_NO_CXX11_DEFAULTED_FUNCTIONS) + /// \constructor_default_no_init + point() = default; +#else + /// \constructor_default_no_init inline point() + {} +#endif +#else // defined(BOOST_GEOMETRY_ENABLE_ACCESS_DEBUGGING) + point() { - BOOST_STATIC_ASSERT(DimensionCount >= 1); + m_created = 1; + std::fill_n(m_values_initialized, DimensionCount, 0); } + ~point() + { + m_created = 0; + std::fill_n(m_values_initialized, DimensionCount, 0); + } +#endif /// @brief Constructor to set one value explicit inline point(CoordinateType const& v0) @@ -120,6 +145,11 @@ public: detail::array_assign::apply(m_values, v0); detail::array_assign::apply(m_values, CoordinateType()); detail::array_assign::apply(m_values, CoordinateType()); + +#if defined(BOOST_GEOMETRY_ENABLE_ACCESS_DEBUGGING) + m_created = 1; + std::fill_n(m_values_initialized, (std::min)(std::size_t(3), DimensionCount), 1); +#endif } /// @brief Constructor to set two values @@ -128,6 +158,11 @@ public: detail::array_assign::apply(m_values, v0); detail::array_assign::apply(m_values, v1); detail::array_assign::apply(m_values, CoordinateType()); + +#if defined(BOOST_GEOMETRY_ENABLE_ACCESS_DEBUGGING) + m_created = 1; + std::fill_n(m_values_initialized, (std::min)(std::size_t(3), DimensionCount), 1); +#endif } /// @brief Constructor to set three values @@ -137,6 +172,11 @@ public: detail::array_assign::apply(m_values, v0); detail::array_assign::apply(m_values, v1); detail::array_assign::apply(m_values, v2); + +#if defined(BOOST_GEOMETRY_ENABLE_ACCESS_DEBUGGING) + m_created = 1; + std::fill_n(m_values_initialized, (std::min)(std::size_t(3), DimensionCount), 1); +#endif } /// @brief Get a coordinate @@ -145,6 +185,10 @@ public: template inline CoordinateType const& get() const { +#if defined(BOOST_GEOMETRY_ENABLE_ACCESS_DEBUGGING) + BOOST_ASSERT(m_created == 1); + BOOST_ASSERT(m_values_initialized[K] == 1); +#endif BOOST_STATIC_ASSERT(K < DimensionCount); return m_values[K]; } @@ -155,6 +199,10 @@ public: template inline void set(CoordinateType const& value) { +#if defined(BOOST_GEOMETRY_ENABLE_ACCESS_DEBUGGING) + BOOST_ASSERT(m_created == 1); + m_values_initialized[K] = 1; +#endif BOOST_STATIC_ASSERT(K < DimensionCount); m_values[K] = value; } @@ -162,6 +210,11 @@ public: private: CoordinateType m_values[DimensionCount]; + +#if defined(BOOST_GEOMETRY_ENABLE_ACCESS_DEBUGGING) + int m_created; + int m_values_initialized[DimensionCount]; +#endif }; diff --git a/include/boost/geometry/geometries/point_xy.hpp b/include/boost/geometry/geometries/point_xy.hpp index 652930666..bbc35d5ce 100644 --- a/include/boost/geometry/geometries/point_xy.hpp +++ b/include/boost/geometry/geometries/point_xy.hpp @@ -16,6 +16,7 @@ #include +#include #include #include @@ -32,6 +33,7 @@ namespace model { namespace d2 \tparam CoordinateType numeric type, for example, double, float, int \tparam CoordinateSystem coordinate system, defaults to cs::cartesian +\qbk{[include reference/geometries/point_xy.qbk]} \qbk{before.synopsis, [heading Model of] [link geometry.reference.concepts.concept_point Point Concept] @@ -45,10 +47,14 @@ class point_xy : public model::point { public: - /// Default constructor, does not initialize anything +#ifndef BOOST_NO_CXX11_DEFAULTED_FUNCTIONS + /// \constructor_default_no_init + point_xy() = default; +#else + /// \constructor_default_no_init inline point_xy() - : model::point() {} +#endif /// Constructor with x/y values inline point_xy(CoordinateType const& x, CoordinateType const& y) diff --git a/include/boost/geometry/geometries/polygon.hpp b/include/boost/geometry/geometries/polygon.hpp index 5f2e87a11..5e6064e89 100644 --- a/include/boost/geometry/geometries/polygon.hpp +++ b/include/boost/geometry/geometries/polygon.hpp @@ -27,12 +27,10 @@ #include #include -#ifdef BOOST_GEOMETRY_EXPERIMENTAL_ENABLE_INITIALIZER_LIST #include #ifndef BOOST_NO_CXX11_HDR_INITIALIZER_LIST #include #endif -#endif namespace boost { namespace geometry { @@ -57,6 +55,7 @@ namespace model \note The container collecting the points in the rings can be different from the container collecting the inner rings. They all default to vector. +\qbk{[include reference/geometries/polygon.qbk]} \qbk{before.synopsis, [heading Model of] [link geometry.reference.concepts.concept_polygon Polygon Concept] @@ -91,7 +90,10 @@ public: inline ring_type& outer() { return m_outer; } inline inner_container_type & inners() { return m_inners; } -#ifdef BOOST_GEOMETRY_EXPERIMENTAL_ENABLE_INITIALIZER_LIST +#ifndef BOOST_NO_CXX11_HDR_INITIALIZER_LIST + + // default constructor definition is required only + // if the constructor taking std::initializer_list is defined /// \constructor_default{polygon} inline polygon() @@ -99,7 +101,6 @@ public: , m_inners() {} -#ifndef BOOST_NO_CXX11_HDR_INITIALIZER_LIST /// \constructor_initializer_list{polygon} inline polygon(std::initializer_list l) : m_outer(l.size() > 0 ? *l.begin() : ring_type()) @@ -128,7 +129,6 @@ public: // } //#endif -#endif #endif /// Utility method, clears outer and inner rings diff --git a/include/boost/geometry/geometries/ring.hpp b/include/boost/geometry/geometries/ring.hpp index 502c95d75..01bcf58cf 100644 --- a/include/boost/geometry/geometries/ring.hpp +++ b/include/boost/geometry/geometries/ring.hpp @@ -27,12 +27,10 @@ #include -#ifdef BOOST_GEOMETRY_EXPERIMENTAL_ENABLE_INITIALIZER_LIST #include #ifndef BOOST_NO_CXX11_HDR_INITIALIZER_LIST #include #endif -#endif namespace boost { namespace geometry { @@ -50,6 +48,7 @@ namespace model \tparam Container container type, for example std::vector, std::deque \tparam Allocator container-allocator-type +\qbk{[include reference/geometries/ring.qbk]} \qbk{before.synopsis, [heading Model of] [link geometry.reference.concepts.concept_ring Ring Concept] @@ -80,7 +79,6 @@ public : : base_type(begin, end) {} -#ifdef BOOST_GEOMETRY_EXPERIMENTAL_ENABLE_INITIALIZER_LIST #ifndef BOOST_NO_CXX11_HDR_INITIALIZER_LIST /// \constructor_initializer_list{ring} @@ -101,7 +99,6 @@ public : // } //#endif -#endif #endif }; diff --git a/include/boost/geometry/geometries/segment.hpp b/include/boost/geometry/geometries/segment.hpp index 3f47f79ec..af406aa09 100644 --- a/include/boost/geometry/geometries/segment.hpp +++ b/include/boost/geometry/geometries/segment.hpp @@ -35,14 +35,32 @@ namespace model by two distinct end points, and contains every point on the line between its end points. \note There is also a point-referring-segment, class referring_segment, containing point references, where points are NOT copied + +\qbk{[include reference/geometries/segment.qbk]} +\qbk{before.synopsis, +[heading Model of] +[link geometry.reference.concepts.concept_segment Segment Concept] +} */ template class segment : public std::pair { + BOOST_CONCEPT_ASSERT( (concept::Point) ); + public : + +#ifndef BOOST_NO_CXX11_DEFAULTED_FUNCTIONS + /// \constructor_default_no_init + segment() = default; +#else + /// \constructor_default_no_init inline segment() {} +#endif + /*! + \brief Constructor taking the first and the second point + */ inline segment(Point const& p1, Point const& p2) { this->first = p1; @@ -83,6 +101,9 @@ public: point_type& first; point_type& second; + /*! + \brief Constructor taking the first and the second point + */ inline referring_segment(point_type& p1, point_type& p2) : first(p1) , second(p2) diff --git a/include/boost/geometry/geometry.hpp b/include/boost/geometry/geometry.hpp index 8d34a0e4e..7d3a99519 100644 --- a/include/boost/geometry/geometry.hpp +++ b/include/boost/geometry/geometry.hpp @@ -90,10 +90,6 @@ #include #include -// Include multi a.o. because it can give weird effects -// if you don't (e.g. area=0 of a multipolygon) -#include - // check includes all concepts #include diff --git a/include/boost/geometry/index/detail/distance_predicates.hpp b/include/boost/geometry/index/detail/distance_predicates.hpp index 3e057290a..9a9371df9 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-2014 Adam Wulkiewicz, Lodz, Poland. +// Copyright (c) 2011-2015 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 @@ -104,13 +104,13 @@ struct calculate_distance // this handles nearest() with default Point parameter, to_nearest() and bounds template -struct calculate_distance< nearest, Indexable, Tag > +struct calculate_distance< predicates::nearest, Indexable, Tag > { typedef detail::relation relation; typedef typename relation::value_type point_type; typedef typename geometry::default_comparable_distance_result::type result_type; - static inline bool apply(nearest const& p, Indexable const& i, result_type & result) + static inline bool apply(predicates::nearest const& p, Indexable const& i, result_type & result) { result = geometry::comparable_distance(relation::value(p.point_or_relation), i); return true; @@ -118,12 +118,12 @@ struct calculate_distance< nearest, Indexable, Tag > }; template -struct calculate_distance< nearest< to_centroid >, Indexable, value_tag> +struct calculate_distance< predicates::nearest< to_centroid >, Indexable, value_tag> { typedef Point point_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) + static inline bool apply(predicates::nearest< to_centroid > const& p, Indexable const& i, result_type & result) { result = index::detail::comparable_distance_centroid(p.point_or_relation.value, i); return true; @@ -131,12 +131,12 @@ struct calculate_distance< nearest< to_centroid >, Indexable, value_tag> }; template -struct calculate_distance< nearest< to_furthest >, Indexable, value_tag> +struct calculate_distance< predicates::nearest< to_furthest >, Indexable, value_tag> { typedef Point point_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) + static inline bool apply(predicates::nearest< to_furthest > const& p, Indexable const& i, result_type & result) { result = index::detail::comparable_distance_far(p.point_or_relation.value, i); return true; @@ -144,13 +144,13 @@ struct calculate_distance< nearest< to_furthest >, Indexable, value_tag> }; template -struct calculate_distance< path, Indexable, Tag> +struct calculate_distance< predicates::path, Indexable, Tag> { typedef typename index::detail::default_path_intersection_distance_type< Indexable, SegmentOrLinestring >::type result_type; - static inline bool apply(path const& p, Indexable const& i, result_type & result) + static inline bool apply(predicates::path const& p, Indexable const& i, result_type & result) { return index::detail::path_intersection(i, p.geometry, result); } diff --git a/include/boost/geometry/index/detail/predicates.hpp b/include/boost/geometry/index/detail/predicates.hpp index b92256649..01afd16ba 100644 --- a/include/boost/geometry/index/detail/predicates.hpp +++ b/include/boost/geometry/index/detail/predicates.hpp @@ -2,7 +2,7 @@ // // Spatial query predicates definition and checks. // -// Copyright (c) 2011-2013 Adam Wulkiewicz, Lodz, Poland. +// Copyright (c) 2011-2015 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 @@ -16,6 +16,8 @@ namespace boost { namespace geometry { namespace index { namespace detail { +namespace predicates { + // ------------------------------------------------------------------ // // predicates // ------------------------------------------------------------------ // @@ -23,6 +25,7 @@ namespace boost { namespace geometry { namespace index { namespace detail { template struct satisfies_impl { + satisfies_impl() : fun(NULL) {} satisfies_impl(Fun f) : fun(f) {} Fun * fun; }; @@ -30,6 +33,7 @@ struct satisfies_impl template struct satisfies_impl { + satisfies_impl() {} satisfies_impl(Fun const& f) : fun(f) {} Fun fun; }; @@ -40,6 +44,7 @@ struct satisfies { typedef satisfies_impl::value> base; + satisfies() {} satisfies(Fun const& f) : base(f) {} satisfies(base const& b) : base(b) {} }; @@ -58,6 +63,7 @@ struct within_tag {}; template struct spatial_predicate { + spatial_predicate() {} spatial_predicate(Geometry const& g) : geometry(g) {} Geometry geometry; }; @@ -73,6 +79,9 @@ struct spatial_predicate template struct nearest { + nearest() +// : count(0) + {} nearest(PointOrRelation const& por, unsigned k) : point_or_relation(por) , count(k) @@ -84,6 +93,9 @@ struct nearest template struct path { + path() +// : count(0) + {} path(SegmentOrLinestring const& g, unsigned k) : geometry(g) , count(k) @@ -92,6 +104,8 @@ struct path unsigned count; }; +} // namespace predicates + // ------------------------------------------------------------------ // // predicate_check // ------------------------------------------------------------------ // @@ -108,20 +122,20 @@ struct predicate_check // ------------------------------------------------------------------ // template -struct predicate_check, value_tag> +struct predicate_check, value_tag> { template - static inline bool apply(satisfies const& p, Value const& v, Indexable const&) + static inline bool apply(predicates::satisfies const& p, Value const& v, Indexable const&) { return p.fun(v); } }; template -struct predicate_check, value_tag> +struct predicate_check, value_tag> { template - static inline bool apply(satisfies const& p, Value const& v, Indexable const&) + static inline bool apply(predicates::satisfies const& p, Value const& v, Indexable const&) { return !p.fun(v); } @@ -136,7 +150,7 @@ struct spatial_predicate_call }; template <> -struct spatial_predicate_call +struct spatial_predicate_call { template static inline bool apply(G1 const& g1, G2 const& g2) @@ -146,7 +160,7 @@ struct spatial_predicate_call }; template <> -struct spatial_predicate_call +struct spatial_predicate_call { template static inline bool apply(G1 const& g1, G2 const& g2) @@ -156,7 +170,7 @@ struct spatial_predicate_call }; template <> -struct spatial_predicate_call +struct spatial_predicate_call { template static inline bool apply(G1 const& g1, G2 const& g2) @@ -166,7 +180,7 @@ struct spatial_predicate_call }; template <> -struct spatial_predicate_call +struct spatial_predicate_call { template static inline bool apply(G1 const& g1, G2 const& g2) @@ -176,7 +190,7 @@ struct spatial_predicate_call }; template <> -struct spatial_predicate_call +struct spatial_predicate_call { template static inline bool apply(G1 const& g1, G2 const& g2) @@ -186,7 +200,7 @@ struct spatial_predicate_call }; template <> -struct spatial_predicate_call +struct spatial_predicate_call { template static inline bool apply(G1 const& g1, G2 const& g2) @@ -196,7 +210,7 @@ struct spatial_predicate_call }; template <> -struct spatial_predicate_call +struct spatial_predicate_call { template static inline bool apply(G1 const& g1, G2 const& g2) @@ -206,7 +220,7 @@ struct spatial_predicate_call }; template <> -struct spatial_predicate_call +struct spatial_predicate_call { template static inline bool apply(G1 const& g1, G2 const& g2) @@ -219,9 +233,9 @@ struct spatial_predicate_call // spatial predicate template -struct predicate_check, value_tag> +struct predicate_check, value_tag> { - typedef spatial_predicate Pred; + typedef predicates::spatial_predicate Pred; template static inline bool apply(Pred const& p, Value const&, Indexable const& i) @@ -232,9 +246,9 @@ struct predicate_check, value_tag> // negated spatial predicate template -struct predicate_check, value_tag> +struct predicate_check, value_tag> { - typedef spatial_predicate Pred; + typedef predicates::spatial_predicate Pred; template static inline bool apply(Pred const& p, Value const&, Indexable const& i) @@ -246,20 +260,20 @@ struct predicate_check, value_tag> // ------------------------------------------------------------------ // template -struct predicate_check, value_tag> +struct predicate_check, value_tag> { template - static inline bool apply(nearest const&, Value const&, Box const&) + static inline bool apply(predicates::nearest const&, Value const&, Box const&) { return true; } }; template -struct predicate_check, value_tag> +struct predicate_check, value_tag> { template - static inline bool apply(path const&, Value const&, Box const&) + static inline bool apply(predicates::path const&, Value const&, Box const&) { return true; } @@ -270,10 +284,10 @@ struct predicate_check, value_tag> // ------------------------------------------------------------------ // template -struct predicate_check, bounds_tag> +struct predicate_check, bounds_tag> { template - static bool apply(satisfies const&, Value const&, Box const&) + static bool apply(predicates::satisfies const&, Value const&, Box const&) { return true; } @@ -295,53 +309,53 @@ struct predicate_check, bounds_tag> // spatial predicate - default template -struct predicate_check, bounds_tag> +struct predicate_check, bounds_tag> { - typedef spatial_predicate Pred; + typedef predicates::spatial_predicate Pred; template static inline bool apply(Pred const& p, Value const&, Indexable const& i) { - return spatial_predicate_call::apply(i, p.geometry); + return spatial_predicate_call::apply(i, p.geometry); } }; // spatial predicate - contains template -struct predicate_check, bounds_tag> +struct predicate_check, bounds_tag> { - typedef spatial_predicate Pred; + typedef predicates::spatial_predicate Pred; template static inline bool apply(Pred const& p, Value const&, Indexable const& i) { - return spatial_predicate_call::apply(i, p.geometry); + return spatial_predicate_call::apply(i, p.geometry); } }; // spatial predicate - covers template -struct predicate_check, bounds_tag> +struct predicate_check, bounds_tag> { - typedef spatial_predicate Pred; + typedef predicates::spatial_predicate Pred; template static inline bool apply(Pred const& p, Value const&, Indexable const& i) { - return spatial_predicate_call::apply(i, p.geometry); + return spatial_predicate_call::apply(i, p.geometry); } }; // spatial predicate - disjoint template -struct predicate_check, bounds_tag> +struct predicate_check, bounds_tag> { - typedef spatial_predicate Pred; + typedef predicates::spatial_predicate Pred; template static inline bool apply(Pred const& p, Value const&, Indexable const& i) { - return !spatial_predicate_call::apply(i, p.geometry); + return !spatial_predicate_call::apply(i, p.geometry); } }; @@ -359,9 +373,9 @@ struct predicate_check, bounds_ // negated spatial predicate - default template -struct predicate_check, bounds_tag> +struct predicate_check, bounds_tag> { - typedef spatial_predicate Pred; + typedef predicates::spatial_predicate Pred; template static inline bool apply(Pred const& p, Value const&, Indexable const& i) @@ -372,9 +386,9 @@ struct predicate_check, bounds_tag> // negated spatial predicate - contains template -struct predicate_check, bounds_tag> +struct predicate_check, bounds_tag> { - typedef spatial_predicate Pred; + typedef predicates::spatial_predicate Pred; template static inline bool apply(Pred const& , Value const&, Indexable const& ) @@ -385,9 +399,9 @@ struct predicate_check, bounds_t // negated spatial predicate - covers template -struct predicate_check, bounds_tag> +struct predicate_check, bounds_tag> { - typedef spatial_predicate Pred; + typedef predicates::spatial_predicate Pred; template static inline bool apply(Pred const& , Value const&, Indexable const& ) @@ -398,22 +412,22 @@ struct predicate_check, bounds_tag // negated spatial predicate - intersects template -struct predicate_check, bounds_tag> +struct predicate_check, bounds_tag> { - typedef spatial_predicate Pred; + typedef predicates::spatial_predicate Pred; template static inline bool apply(Pred const& p, Value const&, Indexable const& i) { - return !spatial_predicate_call::apply(i, p.geometry); + return !spatial_predicate_call::apply(i, p.geometry); } }; // negated spatial predicate - overlaps template -struct predicate_check, bounds_tag> +struct predicate_check, bounds_tag> { - typedef spatial_predicate Pred; + typedef predicates::spatial_predicate Pred; template static inline bool apply(Pred const& , Value const&, Indexable const& ) @@ -424,34 +438,34 @@ struct predicate_check, bounds_t // negated spatial predicate - touches template -struct predicate_check, bounds_tag> +struct predicate_check, bounds_tag> { - typedef spatial_predicate Pred; + typedef predicates::spatial_predicate Pred; template static inline bool apply(Pred const& p, Value const&, Indexable const& i) { - return !spatial_predicate_call::apply(i, p.geometry); + return !spatial_predicate_call::apply(i, p.geometry); } }; // ------------------------------------------------------------------ // template -struct predicate_check, bounds_tag> +struct predicate_check, bounds_tag> { template - static inline bool apply(nearest const&, Value const&, Box const&) + static inline bool apply(predicates::nearest const&, Value const&, Box const&) { return true; } }; template -struct predicate_check, bounds_tag> +struct predicate_check, bounds_tag> { template - static inline bool apply(path const&, Value const&, Box const&) + static inline bool apply(predicates::path const&, Value const&, Box const&) { return true; } @@ -697,13 +711,13 @@ struct predicates_is_distance }; template -struct predicates_is_distance< nearest > +struct predicates_is_distance< predicates::nearest > { static const unsigned value = 1; }; template -struct predicates_is_distance< path > +struct predicates_is_distance< predicates::path > { static const unsigned value = 1; }; diff --git a/include/boost/geometry/index/detail/rtree/iterators.hpp b/include/boost/geometry/index/detail/rtree/iterators.hpp new file mode 100644 index 000000000..a47dd7ea4 --- /dev/null +++ b/include/boost/geometry/index/detail/rtree/iterators.hpp @@ -0,0 +1,122 @@ +// Boost.Geometry Index +// +// R-tree iterators +// +// Copyright (c) 2011-2015 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_INDEX_DETAIL_RTREE_ITERATORS_HPP +#define BOOST_GEOMETRY_INDEX_DETAIL_RTREE_ITERATORS_HPP + +namespace boost { namespace geometry { namespace index { namespace detail { namespace rtree { namespace iterators { + +template +struct end_iterator +{ + typedef std::forward_iterator_tag iterator_category; + typedef Value value_type; + typedef typename Allocators::const_reference reference; + typedef typename Allocators::difference_type difference_type; + typedef typename Allocators::const_pointer pointer; + + reference operator*() const + { + BOOST_GEOMETRY_INDEX_ASSERT(false, "iterator not dereferencable"); + pointer p(0); + return *p; + } + + const value_type * operator->() const + { + BOOST_GEOMETRY_INDEX_ASSERT(false, "iterator not dereferencable"); + const value_type * p = 0; + return p; + } + + end_iterator & operator++() + { + BOOST_GEOMETRY_INDEX_ASSERT(false, "iterator not incrementable"); + return *this; + } + + end_iterator operator++(int) + { + BOOST_GEOMETRY_INDEX_ASSERT(false, "iterator not incrementable"); + return *this; + } + + friend bool operator==(end_iterator const& /*l*/, end_iterator const& /*r*/) + { + return true; + } +}; + +template +class iterator +{ + typedef visitors::iterator visitor_type; + typedef typename visitor_type::node_pointer node_pointer; + +public: + typedef std::forward_iterator_tag iterator_category; + typedef Value value_type; + typedef typename Allocators::const_reference reference; + typedef typename Allocators::difference_type difference_type; + typedef typename Allocators::const_pointer pointer; + + inline iterator() + {} + + inline iterator(node_pointer root) + { + m_visitor.initialize(root); + } + + reference operator*() const + { + return m_visitor.dereference(); + } + + const value_type * operator->() const + { + return boost::addressof(m_visitor.dereference()); + } + + iterator & operator++() + { + m_visitor.increment(); + return *this; + } + + iterator operator++(int) + { + iterator temp = *this; + this->operator++(); + return temp; + } + + friend bool operator==(iterator const& l, iterator const& r) + { + return l.m_visitor == r.m_visitor; + } + + friend bool operator==(iterator const& l, end_iterator const& /*r*/) + { + return l.m_visitor.is_end(); + } + + friend bool operator==(end_iterator const& /*l*/, iterator const& r) + { + return r.m_visitor.is_end(); + } + +private: + visitor_type m_visitor; +}; + +}}}}}} // namespace boost::geometry::index::detail::rtree::iterators + +#endif // BOOST_GEOMETRY_INDEX_DETAIL_RTREE_ITERATORS_HPP diff --git a/include/boost/geometry/index/detail/rtree/node/auto_deallocator.hpp b/include/boost/geometry/index/detail/rtree/node/auto_deallocator.hpp deleted file mode 100644 index dd55c6d76..000000000 --- a/include/boost/geometry/index/detail/rtree/node/auto_deallocator.hpp +++ /dev/null @@ -1,38 +0,0 @@ -// Boost.Geometry Index -// -// R-tree auto deallocator -// -// Copyright (c) 2011-2013 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_INDEX_DETAIL_RTREE_NODE_AUTO_DEALLOCATOR_HPP -#define BOOST_GEOMETRY_INDEX_DETAIL_RTREE_NODE_AUTO_DEALLOCATOR_HPP - -namespace boost { namespace geometry { namespace index { - -namespace detail { namespace rtree { - -template -class auto_deallocator -{ - auto_deallocator(auto_deallocator const&); - auto_deallocator & operator=(auto_deallocator const&); -public: - typedef typename Alloc::pointer pointer; - inline auto_deallocator(Alloc & a, pointer p) : m_alloc(a), m_ptr(p) {} - inline ~auto_deallocator() { if ( m_ptr ) boost::container::allocator_traits::deallocate(m_alloc, m_ptr, 1); } - inline void release() { m_ptr = 0; } - inline pointer ptr() { return m_ptr; } -private: - Alloc & m_alloc; - pointer m_ptr; -}; - -}} // namespace detail::rtree - -}}} // namespace boost::geometry::index - -#endif // BOOST_GEOMETRY_INDEX_DETAIL_RTREE_NODE_AUTO_DEALLOCATOR_HPP diff --git a/include/boost/geometry/index/detail/rtree/node/node.hpp b/include/boost/geometry/index/detail/rtree/node/node.hpp index a632ece66..528d47317 100644 --- a/include/boost/geometry/index/detail/rtree/node/node.hpp +++ b/include/boost/geometry/index/detail/rtree/node/node.hpp @@ -2,7 +2,7 @@ // // R-tree nodes // -// Copyright (c) 2011-2014 Adam Wulkiewicz, Lodz, Poland. +// Copyright (c) 2011-2015 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 @@ -16,8 +16,8 @@ #include #include -#include #include +#include //#include //#include @@ -27,7 +27,7 @@ #include #include -#include +#include #include @@ -70,11 +70,11 @@ struct destroy_element typedef typename rtree::internal_node::type internal_node; typedef typename rtree::leaf::type leaf; - typedef rtree::node_auto_ptr node_auto_ptr; + typedef rtree::subtree_destroyer subtree_destroyer; inline static void apply(typename internal_node::elements_type::value_type & element, Allocators & allocators) { - node_auto_ptr dummy(element.second, allocators); + subtree_destroyer dummy(element.second, allocators); element.second = 0; } @@ -108,11 +108,11 @@ private: inline static void apply_dispatch(It first, It last, Allocators & allocators, boost::mpl::bool_ const& /*is_range_of_values*/) { - typedef rtree::node_auto_ptr node_auto_ptr; + typedef rtree::subtree_destroyer subtree_destroyer; for ( ; first != last ; ++first ) { - node_auto_ptr dummy(first->second, allocators); + subtree_destroyer dummy(first->second, allocators); first->second = 0; } } diff --git a/include/boost/geometry/index/detail/rtree/node/scoped_deallocator.hpp b/include/boost/geometry/index/detail/rtree/node/scoped_deallocator.hpp new file mode 100644 index 000000000..2d08d89ef --- /dev/null +++ b/include/boost/geometry/index/detail/rtree/node/scoped_deallocator.hpp @@ -0,0 +1,48 @@ +// Boost.Geometry Index +// +// R-tree scoped deallocator +// +// Copyright (c) 2011-2015 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_INDEX_DETAIL_RTREE_NODE_SCOPED_DEALLOCATOR_HPP +#define BOOST_GEOMETRY_INDEX_DETAIL_RTREE_NODE_SCOPED_DEALLOCATOR_HPP + +namespace boost { namespace geometry { namespace index { + +namespace detail { namespace rtree { + +template +class scoped_deallocator +{ + scoped_deallocator(scoped_deallocator const&); + scoped_deallocator & operator=(scoped_deallocator const&); +public: + typedef typename Alloc::pointer pointer; + inline scoped_deallocator(pointer p, Alloc & a) + : m_ptr(p), m_alloc(a) + {} + inline ~scoped_deallocator() + { + if ( m_ptr ) + { + boost::container::allocator_traits::deallocate(m_alloc, m_ptr, 1); + } + } + inline void release() + { + m_ptr = 0; + } +private: + pointer m_ptr; + Alloc & m_alloc; +}; + +}} // namespace detail::rtree + +}}} // namespace boost::geometry::index + +#endif // BOOST_GEOMETRY_INDEX_DETAIL_RTREE_NODE_SCOPED_DEALLOCATOR_HPP diff --git a/include/boost/geometry/index/detail/rtree/node/node_auto_ptr.hpp b/include/boost/geometry/index/detail/rtree/node/subtree_destroyer.hpp similarity index 71% rename from include/boost/geometry/index/detail/rtree/node/node_auto_ptr.hpp rename to include/boost/geometry/index/detail/rtree/node/subtree_destroyer.hpp index c19e123b6..3376068ee 100644 --- a/include/boost/geometry/index/detail/rtree/node/node_auto_ptr.hpp +++ b/include/boost/geometry/index/detail/rtree/node/subtree_destroyer.hpp @@ -1,15 +1,15 @@ // Boost.Geometry Index // -// R-tree node auto ptr +// R-tree subtree scoped destroyer // -// Copyright (c) 2011-2013 Adam Wulkiewicz, Lodz, Poland. +// Copyright (c) 2011-2015 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_INDEX_DETAIL_RTREE_NODE_NODE_AUTO_PTR_HPP -#define BOOST_GEOMETRY_INDEX_DETAIL_RTREE_NODE_NODE_AUTO_PTR_HPP +#ifndef BOOST_GEOMETRY_INDEX_DETAIL_RTREE_NODE_SUBTREE_DESTROYED_HPP +#define BOOST_GEOMETRY_INDEX_DETAIL_RTREE_NODE_SUBTREE_DESTROYED_HPP #include @@ -17,31 +17,29 @@ namespace boost { namespace geometry { namespace index { namespace detail { namespace rtree { -// TODO - change the name to node_scoped_ptr - template -class node_auto_ptr +class subtree_destroyer { typedef typename rtree::node::type node; typedef typename Allocators::node_pointer pointer; - node_auto_ptr(node_auto_ptr const&); - node_auto_ptr & operator=(node_auto_ptr const&); + subtree_destroyer(subtree_destroyer const&); + subtree_destroyer & operator=(subtree_destroyer const&); public: - node_auto_ptr(pointer ptr, Allocators & allocators) + subtree_destroyer(pointer ptr, Allocators & allocators) : m_ptr(ptr) , m_allocators(allocators) {} - ~node_auto_ptr() + ~subtree_destroyer() { reset(); } void reset(pointer ptr = 0) { - if ( m_ptr ) + if ( m_ptr && m_ptr != ptr ) { detail::rtree::visitors::destroy del_v(m_ptr, m_allocators); detail::rtree::apply_visitor(del_v, *m_ptr); @@ -78,4 +76,4 @@ private: }}} // namespace boost::geometry::index -#endif // BOOST_GEOMETRY_INDEX_DETAIL_RTREE_NODE_NODE_AUTO_PTR_HPP +#endif // BOOST_GEOMETRY_INDEX_DETAIL_RTREE_NODE_SUBTREE_DESTROYED_HPP diff --git a/include/boost/geometry/index/detail/rtree/node/variant_dynamic.hpp b/include/boost/geometry/index/detail/rtree/node/variant_dynamic.hpp index f5a05f914..8e052e521 100644 --- a/include/boost/geometry/index/detail/rtree/node/variant_dynamic.hpp +++ b/include/boost/geometry/index/detail/rtree/node/variant_dynamic.hpp @@ -181,7 +181,7 @@ struct create_variant_node if ( 0 == p ) throw_runtime_error("boost::geometry::index::rtree node creation failed"); - auto_deallocator deallocator(alloc_node, p); + scoped_deallocator deallocator(p, alloc_node); Al::construct(alloc_node, boost::addressof(*p), Node(alloc_node)); // implicit cast to Variant diff --git a/include/boost/geometry/index/detail/rtree/node/weak_dynamic.hpp b/include/boost/geometry/index/detail/rtree/node/weak_dynamic.hpp index b828b35f4..d49e34782 100644 --- a/include/boost/geometry/index/detail/rtree/node/weak_dynamic.hpp +++ b/include/boost/geometry/index/detail/rtree/node/weak_dynamic.hpp @@ -197,7 +197,7 @@ struct create_weak_node if ( 0 == p ) throw_runtime_error("boost::geometry::index::rtree node creation failed"); - auto_deallocator deallocator(alloc_node, p); + scoped_deallocator deallocator(p, alloc_node); Al::construct(alloc_node, boost::addressof(*p), alloc_node); diff --git a/include/boost/geometry/index/detail/rtree/pack_create.hpp b/include/boost/geometry/index/detail/rtree/pack_create.hpp index 1c24fdb91..b7be41ab2 100644 --- a/include/boost/geometry/index/detail/rtree/pack_create.hpp +++ b/include/boost/geometry/index/detail/rtree/pack_create.hpp @@ -2,7 +2,7 @@ // // R-tree initial packing // -// Copyright (c) 2011-2014 Adam Wulkiewicz, Lodz, Poland. +// Copyright (c) 2011-2015 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 @@ -122,7 +122,7 @@ class pack typedef typename rtree::leaf::type leaf; typedef typename Allocators::node_pointer node_pointer; - typedef rtree::node_auto_ptr node_auto_ptr; + typedef rtree::subtree_destroyer subtree_destroyer; typedef typename Allocators::size_type size_type; typedef typename geometry::point_type::type point_type; @@ -161,7 +161,12 @@ public: geometry::assign_inverse(hint_box); for ( ; first != last ; ++first ) { - typename Translator::result_type indexable = translator(*first); + // NOTE: support for iterators not returning true references adapted + // to Geometry concept and default translator returning true reference + // An alternative would be to dereference the iterator and translate + // in one expression each time the indexable was needed. + typename std::iterator_traits::reference in_ref = *first; + typename Translator::result_type indexable = translator(in_ref); // NOTE: added for consistency with insert() // CONSIDER: alternative - ignore invalid indexable or throw an exception @@ -205,7 +210,7 @@ private: // create new leaf node node_pointer n = rtree::create_node::apply(allocators); // MAY THROW (A) - node_auto_ptr auto_remover(n, allocators); + subtree_destroyer auto_remover(n, allocators); leaf & l = rtree::get(*n); // reserve space for values @@ -215,8 +220,11 @@ private: geometry::assign_inverse(elements_box); for ( ; first != last ; ++first ) { - rtree::elements(l).push_back(*(first->second)); // MAY THROW (A?,C) + // NOTE: push_back() must be called at the end in order to support move_iterator. + // The iterator is dereferenced 2x (no temporary reference) to support + // non-true reference types and move_iterator without boost::forward<>. geometry::expand(elements_box, translator(*(first->second))); + rtree::elements(l).push_back(*(first->second)); // MAY THROW (A?,C) } auto_remover.release(); @@ -230,7 +238,7 @@ private: // create new internal node node_pointer n = rtree::create_node::apply(allocators); // MAY THROW (A) - node_auto_ptr auto_remover(n, allocators); + subtree_destroyer auto_remover(n, allocators); internal_node & in = rtree::get(*n); // reserve space for values @@ -272,7 +280,7 @@ private: // in case if push_back() do throw here // and even if this is not probable (previously reserved memory, nonthrowing pairs copy) // this case is also tested by exceptions test. - node_auto_ptr auto_remover(el.second, allocators); + subtree_destroyer auto_remover(el.second, allocators); // this container should have memory allocated, reserve() called outside elements.push_back(el); // MAY THROW (A?,C) - however in normal conditions shouldn't auto_remover.release(); diff --git a/include/boost/geometry/index/detail/rtree/query_iterators.hpp b/include/boost/geometry/index/detail/rtree/query_iterators.hpp index 1bcb97988..83be106b8 100644 --- a/include/boost/geometry/index/detail/rtree/query_iterators.hpp +++ b/include/boost/geometry/index/detail/rtree/query_iterators.hpp @@ -11,6 +11,8 @@ #ifndef BOOST_GEOMETRY_INDEX_DETAIL_RTREE_QUERY_ITERATORS_HPP #define BOOST_GEOMETRY_INDEX_DETAIL_RTREE_QUERY_ITERATORS_HPP +#include + //#define BOOST_GEOMETRY_INDEX_DETAIL_QUERY_ITERATORS_USE_MOVE namespace boost { namespace geometry { namespace index { namespace detail { namespace rtree { namespace iterators { @@ -18,7 +20,7 @@ namespace boost { namespace geometry { namespace index { namespace detail { name template struct end_query_iterator { - typedef std::input_iterator_tag iterator_category; + typedef std::forward_iterator_tag iterator_category; typedef Value value_type; typedef typename Allocators::const_reference reference; typedef typename Allocators::difference_type difference_type; @@ -63,12 +65,15 @@ class spatial_query_iterator typedef typename visitor_type::node_pointer node_pointer; public: - typedef std::input_iterator_tag iterator_category; + typedef std::forward_iterator_tag iterator_category; typedef Value value_type; typedef typename Allocators::const_reference reference; typedef typename Allocators::difference_type difference_type; typedef typename Allocators::const_pointer pointer; + inline spatial_query_iterator() + {} + inline spatial_query_iterator(Translator const& t, Predicates const& p) : m_visitor(t, p) {} @@ -128,12 +133,15 @@ class distance_query_iterator typedef typename visitor_type::node_pointer node_pointer; public: - typedef std::input_iterator_tag iterator_category; + typedef std::forward_iterator_tag iterator_category; typedef Value value_type; typedef typename Allocators::const_reference reference; typedef typename Allocators::difference_type difference_type; typedef typename Allocators::const_pointer pointer; + inline distance_query_iterator() + {} + inline distance_query_iterator(Translator const& t, Predicates const& p) : m_visitor(t, p) {} @@ -186,22 +194,19 @@ private: visitor_type m_visitor; }; + template inline bool operator!=(L const& l, R const& r) { return !(l == r); } -}}}}}} // namespace boost::geometry::index::detail::rtree::iterators - - -namespace boost { namespace geometry { namespace index { namespace detail { namespace rtree { namespace iterators { template class query_iterator_base { public: - typedef std::input_iterator_tag iterator_category; + typedef std::forward_iterator_tag iterator_category; typedef Value value_type; typedef typename Allocators::const_reference reference; typedef typename Allocators::difference_type difference_type; @@ -224,12 +229,13 @@ class query_iterator_wrapper typedef query_iterator_base base_t; public: - typedef std::input_iterator_tag iterator_category; + typedef std::forward_iterator_tag iterator_category; typedef Value value_type; typedef typename Allocators::const_reference reference; typedef typename Allocators::difference_type difference_type; typedef typename Allocators::const_pointer pointer; + query_iterator_wrapper() : m_iterator() {} explicit query_iterator_wrapper(Iterator const& it) : m_iterator(it) {} virtual base_t * clone() const { return new query_iterator_wrapper(m_iterator); } @@ -253,16 +259,17 @@ template class query_iterator { typedef query_iterator_base iterator_base; - typedef std::auto_ptr iterator_ptr; + typedef boost::scoped_ptr iterator_ptr; public: - typedef std::input_iterator_tag iterator_category; + typedef std::forward_iterator_tag iterator_category; typedef Value value_type; typedef typename Allocators::const_reference reference; typedef typename Allocators::difference_type difference_type; typedef typename Allocators::const_pointer pointer; - query_iterator() {} + query_iterator() + {} template query_iterator(It const& it) @@ -280,21 +287,24 @@ public: #ifndef BOOST_GEOMETRY_INDEX_DETAIL_QUERY_ITERATORS_USE_MOVE query_iterator & operator=(query_iterator const& o) { - m_ptr.reset(o.m_ptr.get() ? o.m_ptr->clone() : 0); + if ( this != boost::addressof(o) ) + { + m_ptr.reset(o.m_ptr.get() ? o.m_ptr->clone() : 0); + } return *this; } #ifndef BOOST_NO_CXX11_RVALUE_REFERENCES query_iterator(query_iterator && o) - : m_ptr(o.m_ptr.get()) + : m_ptr(0) { - o.m_ptr.release(); + m_ptr.swap(o.m_ptr); } query_iterator & operator=(query_iterator && o) { if ( this != boost::addressof(o) ) { - m_ptr.reset(o.m_ptr.get()); - o.m_ptr.release(); + m_ptr.swap(o.m_ptr); + o.m_ptr.reset(); } return *this; } @@ -305,20 +315,23 @@ private: public: query_iterator & operator=(BOOST_COPY_ASSIGN_REF(query_iterator) o) { - m_ptr.reset(o.m_ptr.get() ? o.m_ptr->clone() : 0); + if ( this != boost::addressof(o) ) + { + m_ptr.reset(o.m_ptr.get() ? o.m_ptr->clone() : 0); + } return *this; } query_iterator(BOOST_RV_REF(query_iterator) o) - : m_ptr(o.m_ptr.get()) + : m_ptr(0) { - o.m_ptr.release(); + m_ptr.swap(o.m_ptr); } query_iterator & operator=(BOOST_RV_REF(query_iterator) o) { if ( this != boost::addressof(o) ) { - m_ptr.reset(o.m_ptr.get()); - o.m_ptr.release(); + m_ptr.swap(o.m_ptr); + o.m_ptr.reset(); } return *this; } diff --git a/include/boost/geometry/index/detail/rtree/visitors/copy.hpp b/include/boost/geometry/index/detail/rtree/visitors/copy.hpp index 8fc25ac80..86ffc99ca 100644 --- a/include/boost/geometry/index/detail/rtree/visitors/copy.hpp +++ b/include/boost/geometry/index/detail/rtree/visitors/copy.hpp @@ -2,7 +2,7 @@ // // R-tree deep copying visitor implementation // -// Copyright (c) 2011-2013 Adam Wulkiewicz, Lodz, Poland. +// Copyright (c) 2011-2015 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 @@ public: typedef typename rtree::internal_node::type internal_node; typedef typename rtree::leaf::type leaf; - typedef rtree::node_auto_ptr node_auto_ptr; + typedef rtree::subtree_destroyer subtree_destroyer; typedef typename Allocators::node_pointer node_pointer; explicit inline copy(Allocators & allocators) @@ -35,7 +35,7 @@ public: inline void operator()(internal_node & n) { node_pointer raw_new_node = rtree::create_node::apply(m_allocators); // MAY THROW, STRONG (N: alloc) - node_auto_ptr new_node(raw_new_node, m_allocators); + subtree_destroyer new_node(raw_new_node, m_allocators); typedef typename rtree::elements_type::type elements_type; elements_type & elements = rtree::elements(n); @@ -48,7 +48,7 @@ public: rtree::apply_visitor(*this, *it->second); // MAY THROW (V, E: alloc, copy, N: alloc) // for exception safety - node_auto_ptr auto_result(result, m_allocators); + subtree_destroyer auto_result(result, m_allocators); elements_dst.push_back( rtree::make_ptr_pair(it->first, result) ); // MAY THROW, STRONG (E: alloc, copy) @@ -62,7 +62,7 @@ public: inline void operator()(leaf & l) { node_pointer raw_new_node = rtree::create_node::apply(m_allocators); // MAY THROW, STRONG (N: alloc) - node_auto_ptr new_node(raw_new_node, m_allocators); + subtree_destroyer new_node(raw_new_node, m_allocators); typedef typename rtree::elements_type::type elements_type; elements_type & elements = rtree::elements(l); diff --git a/include/boost/geometry/index/detail/rtree/visitors/distance_query.hpp b/include/boost/geometry/index/detail/rtree/visitors/distance_query.hpp index fc0929e9e..b93071443 100644 --- a/include/boost/geometry/index/detail/rtree/visitors/distance_query.hpp +++ b/include/boost/geometry/index/detail/rtree/visitors/distance_query.hpp @@ -337,6 +337,13 @@ public: }; typedef std::vector internal_stack_type; + inline distance_query_incremental() + : m_translator(NULL) +// , m_pred() + , current_neighbor((std::numeric_limits::max)()) +// , next_closest_node_distance((std::numeric_limits::max)()) + {} + inline distance_query_incremental(Translator const& translator, Predicates const& pred) : m_translator(::boost::addressof(translator)) , m_pred(pred) @@ -428,6 +435,7 @@ public: { BOOST_GEOMETRY_INDEX_ASSERT(l.current_neighbor != r.current_neighbor || (std::numeric_limits::max)() == l.current_neighbor || + (std::numeric_limits::max)() == r.current_neighbor || l.neighbors[l.current_neighbor].second == r.neighbors[r.current_neighbor].second, "not corresponding iterators"); return l.current_neighbor == r.current_neighbor; diff --git a/include/boost/geometry/index/detail/rtree/visitors/insert.hpp b/include/boost/geometry/index/detail/rtree/visitors/insert.hpp index 388b3193f..e697c065e 100644 --- a/include/boost/geometry/index/detail/rtree/visitors/insert.hpp +++ b/include/boost/geometry/index/detail/rtree/visitors/insert.hpp @@ -2,7 +2,7 @@ // // R-tree inserting visitor implementation // -// Copyright (c) 2011-2013 Adam Wulkiewicz, Lodz, Poland. +// Copyright (c) 2011-2015 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 @@ -115,7 +115,7 @@ protected: typedef typename rtree::internal_node::type internal_node; typedef typename rtree::leaf::type leaf; - typedef rtree::node_auto_ptr node_auto_ptr; + typedef rtree::subtree_destroyer subtree_destroyer; public: typedef index::detail::varray< @@ -133,8 +133,8 @@ public: { // TODO - consider creating nodes always with sufficient memory allocated - // create additional node, use auto ptr for automatic destruction on exception - node_auto_ptr second_node(rtree::create_node::apply(allocators), allocators); // MAY THROW, STRONG (N: alloc) + // create additional node, use auto destroyer for automatic destruction on exception + subtree_destroyer second_node(rtree::create_node::apply(allocators), allocators); // MAY THROW, STRONG (N: alloc) // create reference to the newly created node Node & n2 = rtree::get(*second_node); @@ -232,7 +232,7 @@ protected: typedef typename rtree::internal_node::type internal_node; typedef typename rtree::leaf::type leaf; - typedef rtree::node_auto_ptr node_auto_ptr; + typedef rtree::subtree_destroyer subtree_destroyer; typedef typename Allocators::node_pointer node_pointer; typedef typename Allocators::size_type size_type; @@ -340,7 +340,7 @@ protected: // Implement template struct node_element_type or something like that // for exception safety - node_auto_ptr additional_node_ptr(additional_nodes[0].second, m_allocators); + subtree_destroyer additional_node_ptr(additional_nodes[0].second, m_allocators); // node is not the root - just add the new node if ( !m_traverse_data.current_is_root() ) @@ -356,7 +356,7 @@ protected: BOOST_GEOMETRY_INDEX_ASSERT(&n == &rtree::get(*m_root_node), "node should be the root"); // create new root and add nodes - node_auto_ptr new_root(rtree::create_node::apply(m_allocators), m_allocators); // MAY THROW, STRONG (N:alloc) + subtree_destroyer new_root(rtree::create_node::apply(m_allocators), m_allocators); // MAY THROW, STRONG (N:alloc) BOOST_TRY { @@ -365,7 +365,7 @@ protected: } BOOST_CATCH(...) { - // clear new root to not delete in the ~node_auto_ptr() potentially stored old root node + // clear new root to not delete in the ~subtree_destroyer() potentially stored old root node rtree::elements(rtree::get(*new_root)).clear(); BOOST_RETHROW // RETHROW } diff --git a/include/boost/geometry/index/detail/rtree/visitors/iterator.hpp b/include/boost/geometry/index/detail/rtree/visitors/iterator.hpp new file mode 100644 index 000000000..621231ae9 --- /dev/null +++ b/include/boost/geometry/index/detail/rtree/visitors/iterator.hpp @@ -0,0 +1,134 @@ +// Boost.Geometry Index +// +// R-tree iterator visitor implementation +// +// Copyright (c) 2011-2015 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_INDEX_DETAIL_RTREE_VISITORS_ITERATOR_HPP +#define BOOST_GEOMETRY_INDEX_DETAIL_RTREE_VISITORS_ITERATOR_HPP + +namespace boost { namespace geometry { namespace index { + +namespace detail { namespace rtree { namespace visitors { + +template +class iterator + : public rtree::visitor::type +{ +public: + typedef typename rtree::node::type node; + typedef typename rtree::internal_node::type internal_node; + typedef typename rtree::leaf::type leaf; + + typedef typename Allocators::size_type size_type; + typedef typename Allocators::const_reference const_reference; + typedef typename Allocators::node_pointer node_pointer; + + typedef typename rtree::elements_type::type::const_iterator internal_iterator; + typedef typename rtree::elements_type::type leaf_elements; + typedef typename rtree::elements_type::type::const_iterator leaf_iterator; + + inline iterator() + : m_values(NULL) + , m_current() + {} + + inline void operator()(internal_node const& n) + { + typedef typename rtree::elements_type::type elements_type; + elements_type const& elements = rtree::elements(n); + + m_internal_stack.push_back(std::make_pair(elements.begin(), elements.end())); + } + + inline void operator()(leaf const& n) + { + m_values = ::boost::addressof(rtree::elements(n)); + m_current = rtree::elements(n).begin(); + } + + const_reference dereference() const + { + BOOST_GEOMETRY_INDEX_ASSERT(m_values, "not dereferencable"); + return *m_current; + } + + void initialize(node_pointer root) + { + rtree::apply_visitor(*this, *root); + search_value(); + } + + void increment() + { + ++m_current; + search_value(); + } + + void search_value() + { + for (;;) + { + // if leaf is choosen, move to the next value in leaf + if ( m_values ) + { + // there are more values in the current leaf + if ( m_current != m_values->end() ) + { + return; + } + // no more values, clear current leaf + else + { + m_values = 0; + } + } + // if leaf isn't choosen, move to the next leaf + else + { + // return if there is no more nodes to traverse + if ( m_internal_stack.empty() ) + return; + + // no more children in current node, remove it from stack + if ( m_internal_stack.back().first == m_internal_stack.back().second ) + { + m_internal_stack.pop_back(); + continue; + } + + internal_iterator it = m_internal_stack.back().first; + ++m_internal_stack.back().first; + + // push the next node to the stack + rtree::apply_visitor(*this, *(it->second)); + } + } + } + + bool is_end() const + { + return 0 == m_values; + } + + friend bool operator==(iterator const& l, iterator const& r) + { + return (l.m_values == r.m_values) && (0 == l.m_values || l.m_current == r.m_current ); + } + +private: + + std::vector< std::pair > m_internal_stack; + const leaf_elements * m_values; + leaf_iterator m_current; +}; + +}}} // namespace detail::rtree::visitors + +}}} // namespace boost::geometry::index + +#endif // BOOST_GEOMETRY_INDEX_DETAIL_RTREE_VISITORS_ITERATOR_HPP diff --git a/include/boost/geometry/index/detail/rtree/visitors/remove.hpp b/include/boost/geometry/index/detail/rtree/visitors/remove.hpp index a55f5d3fe..494d5a019 100644 --- a/include/boost/geometry/index/detail/rtree/visitors/remove.hpp +++ b/include/boost/geometry/index/detail/rtree/visitors/remove.hpp @@ -30,7 +30,7 @@ class remove typedef typename rtree::internal_node::type internal_node; typedef typename rtree::leaf::type leaf; - typedef rtree::node_auto_ptr node_auto_ptr; + typedef rtree::subtree_destroyer subtree_destroyer; typedef typename Allocators::node_pointer node_pointer; typedef typename Allocators::size_type size_type; @@ -264,7 +264,7 @@ private: // destroy current and remaining nodes for ( ; it != m_underflowed_nodes.rend() ; ++it ) { - node_auto_ptr dummy(it->second, m_allocators); + subtree_destroyer dummy(it->second, m_allocators); } //m_underflowed_nodes.clear(); diff --git a/include/boost/geometry/index/detail/rtree/visitors/spatial_query.hpp b/include/boost/geometry/index/detail/rtree/visitors/spatial_query.hpp index f00189fe7..b9cd0ae2c 100644 --- a/include/boost/geometry/index/detail/rtree/visitors/spatial_query.hpp +++ b/include/boost/geometry/index/detail/rtree/visitors/spatial_query.hpp @@ -94,10 +94,18 @@ public: static const unsigned predicates_len = index::detail::predicates_length::value; + inline spatial_query_incremental() + : m_translator(NULL) +// , m_pred() + , m_values(NULL) + , m_current() + {} + inline spatial_query_incremental(Translator const& t, Predicates const& p) : m_translator(::boost::addressof(t)) , m_pred(p) - , m_values(0) + , m_values(NULL) + , m_current() {} inline void operator()(internal_node const& n) diff --git a/include/boost/geometry/index/detail/serialization.hpp b/include/boost/geometry/index/detail/serialization.hpp index 34036e390..550a37565 100644 --- a/include/boost/geometry/index/detail/serialization.hpp +++ b/include/boost/geometry/index/detail/serialization.hpp @@ -1,6 +1,6 @@ // Boost.Geometry Index // -// Copyright (c) 2011-2014 Adam Wulkiewicz, Lodz, Poland. +// Copyright (c) 2011-2015 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 @@ -353,7 +353,7 @@ class load typedef typename Options::parameters_type parameters_type; typedef typename Allocators::node_pointer node_pointer; - typedef rtree::node_auto_ptr node_auto_ptr; + typedef rtree::subtree_destroyer subtree_destroyer; typedef typename Allocators::size_type size_type; public: @@ -385,7 +385,7 @@ private: if ( current_level < leafs_level ) { node_pointer n = rtree::create_node::apply(allocators); // MAY THROW (A) - node_auto_ptr auto_remover(n, allocators); + subtree_destroyer auto_remover(n, allocators); internal_node & in = rtree::get(*n); elements_type & elements = rtree::elements(in); @@ -408,7 +408,7 @@ private: BOOST_GEOMETRY_INDEX_ASSERT(current_level == leafs_level, "unexpected value"); node_pointer n = rtree::create_node::apply(allocators); // MAY THROW (A) - node_auto_ptr auto_remover(n, allocators); + subtree_destroyer auto_remover(n, allocators); leaf & l = rtree::get(*n); typedef typename rtree::elements_type::type elements_type; @@ -537,7 +537,7 @@ void load(Archive & ar, boost::geometry::index::rtree & rt, unsig typedef typename options_type::parameters_type parameters_type; typedef typename allocators_type::node_pointer node_pointer; - typedef detail::rtree::node_auto_ptr node_auto_ptr; + typedef detail::rtree::subtree_destroyer subtree_destroyer; view tree(rt); @@ -554,7 +554,7 @@ void load(Archive & ar, boost::geometry::index::rtree & rt, unsig n = detail::rtree::load ::apply(ar, version, leafs_level, loaded_values_count, params, tree.members().translator(), tree.members().allocators()); // MAY THROW - node_auto_ptr remover(n, tree.members().allocators()); + subtree_destroyer remover(n, tree.members().allocators()); if ( loaded_values_count != values_count ) BOOST_THROW_EXCEPTION(std::runtime_error("unexpected number of values")); // TODO change exception type remover.release(); @@ -564,7 +564,7 @@ void load(Archive & ar, boost::geometry::index::rtree & rt, unsig tree.members().values_count = values_count; tree.members().leafs_level = leafs_level; - node_auto_ptr remover(tree.members().root, tree.members().allocators()); + subtree_destroyer remover(tree.members().root, tree.members().allocators()); tree.members().root = n; } diff --git a/include/boost/geometry/index/parameters.hpp b/include/boost/geometry/index/parameters.hpp index fd6df716e..2b9490768 100644 --- a/include/boost/geometry/index/parameters.hpp +++ b/include/boost/geometry/index/parameters.hpp @@ -70,8 +70,7 @@ inline size_t default_rstar_reinserted_elements_d_calc(size_t max_elements, size \tparam MinElements Minimum number of elements in nodes. Default: 0.3*Max. */ template ::value -> + size_t MinElements = detail::default_min_elements_s::value> struct linear { BOOST_MPL_ASSERT_MSG((0 < MinElements && 2*MinElements <= MaxElements+1), diff --git a/include/boost/geometry/index/predicates.hpp b/include/boost/geometry/index/predicates.hpp index 10033abff..3bb1bf4d8 100644 --- a/include/boost/geometry/index/predicates.hpp +++ b/include/boost/geometry/index/predicates.hpp @@ -2,7 +2,7 @@ // // Spatial query predicates // -// Copyright (c) 2011-2014 Adam Wulkiewicz, Lodz, Poland. +// Copyright (c) 2011-2015 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 @@ -43,10 +43,15 @@ bgi::query(spatial_index, bgi::contains(box), std::back_inserter(result)); \param g The Geometry object. */ template inline -detail::spatial_predicate +detail::predicates::spatial_predicate contains(Geometry const& g) { - return detail::spatial_predicate(g); + return detail::predicates::spatial_predicate + < + Geometry, + detail::predicates::contains_tag, + false + >(g); } /*! @@ -68,10 +73,15 @@ bgi::query(spatial_index, bgi::covered_by(box), std::back_inserter(result)); \param g The Geometry object. */ template inline -detail::spatial_predicate +detail::predicates::spatial_predicate covered_by(Geometry const& g) { - return detail::spatial_predicate(g); + return detail::predicates::spatial_predicate + < + Geometry, + detail::predicates::covered_by_tag, + false + >(g); } /*! @@ -93,10 +103,15 @@ bgi::query(spatial_index, bgi::covers(box), std::back_inserter(result)); \param g The Geometry object. */ template inline -detail::spatial_predicate +detail::predicates::spatial_predicate covers(Geometry const& g) { - return detail::spatial_predicate(g); + return detail::predicates::spatial_predicate + < + Geometry, + detail::predicates::covers_tag, + false + >(g); } /*! @@ -118,10 +133,15 @@ bgi::query(spatial_index, bgi::disjoint(box), std::back_inserter(result)); \param g The Geometry object. */ template inline -detail::spatial_predicate +detail::predicates::spatial_predicate disjoint(Geometry const& g) { - return detail::spatial_predicate(g); + return detail::predicates::spatial_predicate + < + Geometry, + detail::predicates::disjoint_tag, + false + >(g); } /*! @@ -145,10 +165,15 @@ bgi::query(spatial_index, bgi::intersects(polygon), std::back_inserter(result)); \param g The Geometry object. */ template inline -detail::spatial_predicate +detail::predicates::spatial_predicate intersects(Geometry const& g) { - return detail::spatial_predicate(g); + return detail::predicates::spatial_predicate + < + Geometry, + detail::predicates::intersects_tag, + false + >(g); } /*! @@ -170,10 +195,15 @@ bgi::query(spatial_index, bgi::overlaps(box), std::back_inserter(result)); \param g The Geometry object. */ template inline -detail::spatial_predicate +detail::predicates::spatial_predicate overlaps(Geometry const& g) { - return detail::spatial_predicate(g); + return detail::predicates::spatial_predicate + < + Geometry, + detail::predicates::overlaps_tag, + false + >(g); } #ifdef BOOST_GEOMETRY_INDEX_DETAIL_EXPERIMENTAL @@ -192,10 +222,15 @@ returns true. \param g The Geometry object. */ template inline -detail::spatial_predicate +detail::predicates::spatial_predicate touches(Geometry const& g) { - return detail::spatial_predicate(g); + return detail::predicates::spatial_predicate + < + Geometry, + detail::predicates::touches_tag, + false + >(g); } #endif // BOOST_GEOMETRY_INDEX_DETAIL_EXPERIMENTAL @@ -219,10 +254,15 @@ bgi::query(spatial_index, bgi::within(box), std::back_inserter(result)); \param g The Geometry object. */ template inline -detail::spatial_predicate +detail::predicates::spatial_predicate within(Geometry const& g) { - return detail::spatial_predicate(g); + return detail::predicates::spatial_predicate + < + Geometry, + detail::predicates::within_tag, + false + >(g); } /*! @@ -259,10 +299,10 @@ std::back_inserter(result)); \param pred The unary predicate function or function object. */ template inline -detail::satisfies +detail::predicates::satisfies satisfies(UnaryPredicate const& pred) { - return detail::satisfies(pred); + return detail::predicates::satisfies(pred); } /*! @@ -289,10 +329,10 @@ Only one \c nearest() predicate may be used in a query. \param k The maximum number of values to return. */ template inline -detail::nearest +detail::predicates::nearest nearest(Geometry const& geometry, unsigned k) { - return detail::nearest(geometry, k); + return detail::predicates::nearest(geometry, k); } #ifdef BOOST_GEOMETRY_INDEX_DETAIL_EXPERIMENTAL @@ -319,15 +359,15 @@ Only one distance predicate (\c nearest() or \c path()) may be used in a query. \param k The maximum number of values to return. */ template inline -detail::path +detail::predicates::path path(SegmentOrLinestring const& linestring, unsigned k) { - return detail::path(linestring, k); + return detail::predicates::path(linestring, k); } #endif // BOOST_GEOMETRY_INDEX_DETAIL_EXPERIMENTAL -namespace detail { +namespace detail { namespace predicates { // operator! generators @@ -378,7 +418,7 @@ operator&&(boost::tuples::cons const& t, Pred const& p) >::apply(t, p); } -} // namespace detail +}} // namespace detail::predicates }}} // namespace boost::geometry::index diff --git a/include/boost/geometry/index/rtree.hpp b/include/boost/geometry/index/rtree.hpp index c39dd01b6..84c4da8a2 100644 --- a/include/boost/geometry/index/rtree.hpp +++ b/include/boost/geometry/index/rtree.hpp @@ -3,7 +3,7 @@ // R-tree implementation // // Copyright (c) 2008 Federico J. Fernandez. -// Copyright (c) 2011-2014 Adam Wulkiewicz, Lodz, Poland. +// Copyright (c) 2011-2015 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 @@ -59,6 +59,7 @@ #include #include +#include #include #include #include @@ -78,6 +79,7 @@ #include +#include #include #ifdef BOOST_GEOMETRY_INDEX_DETAIL_EXPERIMENTAL @@ -96,12 +98,13 @@ namespace boost { namespace geometry { namespace index { /*! \brief The R-tree spatial index. -This is self-balancing spatial index capable to store various types of Values and balancing algorithms. +This is self-balancing spatial index capable to store various types of Values +and balancing algorithms. \par Parameters The user must pass a type defining the Parameters which will -be used in rtree creation process. This type is used e.g. to specify balancing algorithm -with specific parameters like min and max number of elements in node. +be used in rtree creation process. This type is used e.g. to specify balancing +algorithm with specific parameters like min and max number of elements in node. \par Predefined algorithms with compile-time parameters are: @@ -116,23 +119,31 @@ Predefined algorithms with run-time parameters are: \li \c boost::geometry::index::dynamic_rstar. \par IndexableGetter -The object of IndexableGetter type translates from Value to Indexable each time r-tree requires it. Which means that this -operation is done for each Value access. Therefore the IndexableGetter should return the Indexable by -const reference instead of a value. Default one can translate all types adapted to Point, Box or Segment -concepts (called Indexables). It also handles std::pair and -boost::tuple. For example, if std::pair is stored in the -container, the default IndexableGetter translates from std::pair const& to Box const&. +The object of IndexableGetter type translates from Value to Indexable each time +r-tree requires it. This means that this operation is done for each Value +access. Therefore the IndexableGetter should return the Indexable by +a reference type. The Indexable should not be calculated since it could harm +the performance. The default IndexableGetter can translate all types adapted +to Point, Box or Segment concepts (called Indexables). Furthermore, it can +handle std::pair, boost::tuple +and std::tuple when possible. For example, for Value +of type std::pair, the default IndexableGetter translates +from std::pair const& to Box const&. \par EqualTo -The object of EqualTo type compares Values and returns true if they're equal. It's similar to std::equal_to<>. -The default EqualTo returns the result of boost::geometry::equals() for types adapted to some Geometry concept -defined in Boost.Geometry and the result of operator= for other types. Components of Pairs and Tuples are compared left-to-right. +The object of EqualTo type compares Values and returns true if they +are equal. It's similar to std::equal_to<>. The default EqualTo +returns the result of boost::geometry::equals() for types adapted to +some Geometry concept defined in Boost.Geometry and the result of +operator== for other types. Components of Pairs and Tuples are +compared left-to-right. \tparam Value The type of objects stored in the container. \tparam Parameters Compile-time parameters. \tparam IndexableGetter The function object extracting Indexable from Value. \tparam EqualTo The function object comparing objects of type Value. -\tparam Allocator The allocator used to allocate/deallocate memory, construct/destroy nodes and Values. +\tparam Allocator The allocator used to allocate/deallocate memory, + construct/destroy nodes and Values. */ template < typename Value, @@ -188,7 +199,7 @@ private: typedef typename allocators_type::node_pointer node_pointer; typedef ::boost::container::allocator_traits allocator_traits_type; - typedef detail::rtree::node_auto_ptr node_auto_ptr; + typedef detail::rtree::subtree_destroyer subtree_destroyer; friend class detail::rtree::utilities::view; #ifdef BOOST_GEOMETRY_INDEX_DETAIL_EXPERIMENTAL @@ -211,8 +222,17 @@ public: /*! \brief Unsigned integral type used by the container. */ typedef typename allocators_type::size_type size_type; - /*! \brief Type of const query iterator. */ - typedef index::detail::rtree::iterators::query_iterator const_query_iterator; + /*! \brief Type of const iterator, category ForwardIterator. */ + typedef index::detail::rtree::iterators::iterator + < + value_type, options_type, translator_type, box_type, allocators_type + > const_iterator; + + /*! \brief Type of const query iterator, category ForwardIterator. */ + typedef index::detail::rtree::iterators::query_iterator + < + value_type, allocators_type + > const_query_iterator; public: @@ -757,6 +777,27 @@ public: tree.query(bgi::overlaps(box) && bgi::satisfies(my_fun), std::back_inserter(result)); // return 5 elements nearest to pt and elements are intersecting box tree.query(bgi::nearest(pt, 5) && bgi::intersects(box), std::back_inserter(result)); + + // For each found value do_something (it is a type of function object) + tree.query(bgi::intersects(box), + boost::make_function_output_iterator(do_something())); + + // For each value stored in the rtree do_something + // always_true is a type of function object always returning true + tree.query(bgi::satisfies(always_true()), + boost::make_function_output_iterator(do_something())); + + // C++11 (lambda expression) + tree.query(bgi::intersects(box), + boost::make_function_output_iterator([](value_type const& val){ + // do something + })); + + // C++14 (generic lambda expression) + tree.query(bgi::intersects(box), + boost::make_function_output_iterator([](auto const& val){ + // do something + })); \endverbatim \par Throws @@ -765,7 +806,7 @@ public: \warning Only one \c nearest() perdicate may be passed to the query. Passing more of them results in compile-time error. - + \param predicates Predicates. \param out_it The output iterator, e.g. generated by std::back_inserter(). @@ -785,11 +826,11 @@ public: } /*! - \brief Returns the query iterator pointing at the begin of the query range. + \brief Returns a query iterator pointing at the begin of the query range. + + This method returns an iterator which may be used to perform iterative queries. + For the information about predicates which may be passed to this method see query(). - This method returns the iterator which may be used to perform iterative queries. For the information - about the predicates which may be passed to this method see query(). - \par Example \verbatim for ( Rtree::const_query_iterator it = tree.qbegin(bgi::nearest(pt, 10000)) ; @@ -799,12 +840,29 @@ public: if ( has_enough_nearest_values() ) break; } + + // C++11 (auto) + for ( auto it = tree.qbegin(bgi::nearest(pt, 3)) ; it != tree.qend() ; ++it ) + { + // do something with value + } + + // C++14 (generic lambda expression) + std::for_each(tree.qbegin(bgi::nearest(pt, 3)), tree.qend(), [](auto const& val){ + // do something with value + }); \endverbatim + \par Iterator category + ForwardIterator + \par Throws If predicates copy throws. If allocation throws. + \warning + The modification of the rtree may invalidate the iterators. + \param predicates Predicates. \return The iterator pointing at the begin of the query range. @@ -816,10 +874,10 @@ public: } /*! - \brief Returns the query iterator pointing at the end of the query range. + \brief Returns a query iterator pointing at the end of the query range. + + This method returns an iterator which may be used to check if the query has ended. - This method returns the iterator which may be used to check if the query has ended. - \par Example \verbatim for ( Rtree::const_query_iterator it = tree.qbegin(bgi::nearest(pt, 10000)) ; @@ -829,10 +887,27 @@ public: if ( has_enough_nearest_values() ) break; } + + // C++11 (auto) + for ( auto it = tree.qbegin(bgi::nearest(pt, 3)) ; it != tree.qend() ; ++it ) + { + // do something with value + } + + // C++14 (generic lambda expression) + std::for_each(tree.qbegin(bgi::nearest(pt, 3)), tree.qend(), [](auto const& val){ + // do something with value + }); \endverbatim + \par Iterator category + ForwardIterator + \par Throws Nothing + + \warning + The modification of the rtree may invalidate the iterators. \return The iterator pointing at the end of the query range. */ @@ -845,10 +920,10 @@ public: private: #endif /*! - \brief Returns the query iterator pointing at the begin of the query range. + \brief Returns a query iterator pointing at the begin of the query range. - This method returns the iterator which may be used to perform iterative queries. For the information - about the predicates which may be passed to this method see query(). + This method returns an iterator which may be used to perform iterative queries. + For the information about predicates which may be passed to this method see query(). The type of the returned iterator depends on the type of passed Predicates but the iterator of this type may be assigned to the variable of const_query_iterator type. If you'd like to use the type of the iterator @@ -858,16 +933,24 @@ private: \par Example \verbatim // Store the result in the container using std::copy() - it requires both iterators of the same type - std::copy(tree.qbegin(bgi::intersects(box)), tree.qend(bgi::intersects(box)), std::back_inserter(result)); + std::copy(tree.qbegin_(bgi::intersects(box)), tree.qend_(bgi::intersects(box)), std::back_inserter(result)); // Store the result in the container using std::copy() and type-erased iterators - Rtree::const_query_iterator first = tree.qbegin(bgi::intersects(box)); - Rtree::const_query_iterator last = tree.qend(); + Rtree::const_query_iterator first = tree.qbegin_(bgi::intersects(box)); + Rtree::const_query_iterator last = tree.qend_(); std::copy(first, last, std::back_inserter(result)); // Boost.Typeof typedef BOOST_TYPEOF(tree.qbegin(bgi::nearest(pt, 10000))) Iter; - for ( Iter it = tree.qbegin(bgi::nearest(pt, 10000)) ; it != tree.qend() ; ++it ) + for ( Iter it = tree.qbegin_(bgi::nearest(pt, 10000)) ; it != tree.qend_() ; ++it ) + { + // do something with value + if ( has_enough_nearest_values() ) + break; + } + + // C++11 (auto) + for ( auto it = tree.qbegin_(bgi::nearest(pt, 10000)) ; it != tree.qend_() ; ++it ) { // do something with value if ( has_enough_nearest_values() ) @@ -875,10 +958,16 @@ private: } \endverbatim + \par Iterator category + ForwardIterator + \par Throws If predicates copy throws. If allocation throws. + \warning + The modification of the rtree may invalidate the iterators. + \param predicates Predicates. \return The iterator pointing at the begin of the query range. @@ -928,12 +1017,18 @@ private: \par Example \verbatim // Store the result in the container using std::copy() - it requires both iterators of the same type - std::copy(tree.qbegin(bgi::intersects(box)), tree.qend(bgi::intersects(box)), std::back_inserter(result)); + std::copy(tree.qbegin_(bgi::intersects(box)), tree.qend_(bgi::intersects(box)), std::back_inserter(result)); \endverbatim + \par Iterator category + ForwardIterator + \par Throws If predicates copy throws. + \warning + The modification of the rtree may invalidate the iterators. + \param predicates Predicates. \return The iterator pointing at the end of the query range. @@ -980,13 +1075,21 @@ private: \par Example \verbatim // Store the result in the container using std::copy() and type-erased iterators - Rtree::const_query_iterator first = tree.qbegin(bgi::intersects(box)); - Rtree::const_query_iterator last = tree.qend(); + Rtree::const_query_iterator first = tree.qbegin_(bgi::intersects(box)); + Rtree::const_query_iterator last = tree.qend_(); std::copy(first, last, std::back_inserter(result)); // Boost.Typeof typedef BOOST_TYPEOF(tree.qbegin(bgi::nearest(pt, 10000))) Iter; - for ( Iter it = tree.qbegin(bgi::nearest(pt, 10000)) ; it != tree.qend() ; ++it ) + for ( Iter it = tree.qbegin_(bgi::nearest(pt, 10000)) ; it != tree.qend_() ; ++it ) + { + // do something with value + if ( has_enough_nearest_values() ) + break; + } + + // C++11 (auto) + for ( auto it = tree.qbegin_(bgi::nearest(pt, 10000)) ; it != tree.qend_() ; ++it ) { // do something with value if ( has_enough_nearest_values() ) @@ -994,8 +1097,14 @@ private: } \endverbatim + \par Iterator category + ForwardIterator + \par Throws Nothing + + \warning + The modification of the rtree may invalidate the iterators. \return The iterator pointing at the end of the query range. */ @@ -1007,6 +1116,88 @@ private: public: + /*! + \brief Returns the iterator pointing at the begin of the rtree values range. + + This method returns the iterator which may be used to iterate over all values + stored in the rtree. + + \par Example + \verbatim + // Copy all values into the vector + std::copy(tree.begin(), tree.end(), std::back_inserter(vec)); + + for ( Rtree::const_iterator it = tree.begin() ; it != tree.end() ; ++it ) + { + // do something with value + } + + // C++11 (auto) + for ( auto it = tree.begin() ; it != tree.end() ; ++it ) + { + // do something with value + } + + // C++14 (generic lambda expression) + std::for_each(tree.begin(), tree.end(), [](auto const& val){ + // do something with value + }) + \endverbatim + + \par Iterator category + ForwardIterator + + \par Throws + If allocation throws. + + \warning + The modification of the rtree may invalidate the iterators. + + \return The iterator pointing at the begin of the range. + */ + const_iterator begin() const + { + if ( !m_members.root ) + return const_iterator(); + + return const_iterator(m_members.root); + } + + /*! + \brief Returns the iterator pointing at the end of the rtree values range. + + This method returns the iterator which may be compared with the iterator returned by begin() + in order to check if the iteration has ended. + + \par Example + \verbatim + for ( Rtree::const_iterator it = tree.begin() ; it != tree.end() ; ++it ) + { + // do something with value + } + + // C++11 (lambda expression) + std::for_each(tree.begin(), tree.end(), [](value_type const& val){ + // do something with value + }) + \endverbatim + + \par Iterator category + ForwardIterator + + \par Throws + Nothing. + + \warning + The modification of the rtree may invalidate the iterators. + + \return The iterator pointing at the end of the range. + */ + const_iterator end() const + { + return const_iterator(); + } + /*! \brief Returns the number of stored values. @@ -1088,6 +1279,8 @@ public: template size_type count(ValueOrIndexable const& vori) const { + // the input should be convertible to Value or Indexable type + enum { as_val = 0, as_ind, dont_know }; typedef boost::mpl::int_ < @@ -1113,15 +1306,9 @@ public: indexable_type >::type value_or_indexable; - if ( !m_members.root ) - return 0; - - detail::rtree::visitors::count - count_v(vori, m_members.translator()); - - detail::rtree::apply_visitor(count_v, *m_members.root); - - return count_v.found_count; + // NOTE: If an object of convertible but not the same type is passed + // into the function, here a temporary will be created. + return this->template raw_count(vori); } /*! @@ -1357,7 +1544,7 @@ private: dst.m_members.parameters() = src.m_members.parameters(); } - // TODO use node_auto_ptr + // TODO use subtree_destroyer if ( dst.m_members.root ) { detail::rtree::visitors::destroy @@ -1493,6 +1680,33 @@ private: return distance_v.finish(); } + + /*! + \brief Count elements corresponding to value or indexable. + + \par Exception-safety + strong + */ + template + size_type raw_count(ValueOrIndexable const& vori) const + { + if ( !m_members.root ) + return 0; + + detail::rtree::visitors::count + < + ValueOrIndexable, + value_type, + options_type, + translator_type, + box_type, + allocators_type + > count_v(vori, m_members.translator()); + + detail::rtree::apply_visitor(count_v, *m_members.root); + + return count_v.found_count; + } struct members_holder : public translator_type @@ -1731,6 +1945,10 @@ bgi::query(tree, bgi::intersects(poly) && !bgi::within(box), std::back_inserter( bgi::query(tree, bgi::overlaps(box) && bgi::satisfies(my_fun), std::back_inserter(result)); // return 5 elements nearest to pt and elements are intersecting box bgi::query(tree, bgi::nearest(pt, 5) && bgi::intersects(box), std::back_inserter(result)); + +// For each found value do_something (it is a type of function object) +tree.query(bgi::intersects(box), + boost::make_function_output_iterator(do_something())); \endverbatim \par Throws @@ -1765,20 +1983,19 @@ about the predicates which may be passed to this method see query(). \par Example \verbatim - -for ( Rtree::const_query_iterator it = qbegin(tree, bgi::nearest(pt, 10000)) ; - it != qend(tree) ; ++it ) -{ - // do something with value - if ( has_enough_nearest_values() ) - break; -} +std::for_each(bgi::qbegin(tree, bgi::nearest(pt, 3)), bgi::qend(tree), do_something()); \endverbatim +\par Iterator category +ForwardIterator + \par Throws If predicates copy throws. If allocation throws. +\warning +The modification of the rtree may invalidate the iterators. + \ingroup rtree_functions \param tree The rtree. @@ -1802,19 +2019,18 @@ This method returns the iterator which may be used to check if the query has end \par Example \verbatim - -for ( Rtree::const_query_iterator it = qbegin(tree, bgi::nearest(pt, 10000)) ; - it != qend(tree) ; ++it ) -{ - // do something with value - if ( has_enough_nearest_values() ) - break; -} +std::for_each(bgi::qbegin(tree, bgi::nearest(pt, 3)), bgi::qend(tree), do_something()); \endverbatim +\par Iterator category +ForwardIterator + \par Throws Nothing +\warning +The modification of the rtree may invalidate the iterators. + \ingroup rtree_functions \return The iterator pointing at the end of the query range. @@ -1826,6 +2042,72 @@ qend(rtree const& tree) return tree.qend(); } +/*! +\brief Returns the iterator pointing at the begin of the rtree values range. + +This method returns the iterator which may be used to iterate over all values +stored in the rtree. + +\par Example +\verbatim +std::for_each(bgi::begin(tree), bgi::end(tree), do_something()); +// the same as +std::for_each(boost::begin(tree), boost::end(tree), do_something()); +\endverbatim + +\par Iterator category +ForwardIterator + +\par Throws +If allocation throws. + +\warning +The modification of the rtree may invalidate the iterators. + +\ingroup rtree_functions + +\return The iterator pointing at the begin of the range. +*/ +template inline +typename rtree::const_iterator +begin(rtree const& tree) +{ + return tree.begin(); +} + +/*! +\brief Returns the iterator pointing at the end of the rtree values range. + +This method returns the iterator which may be compared with the iterator returned by begin() +in order to check if the iteration has ended. + +\par Example +\verbatim +std::for_each(bgi::begin(tree), bgi::end(tree), do_something()); +// the same as +std::for_each(boost::begin(tree), boost::end(tree), do_something()); +\endverbatim + +\par Iterator category +ForwardIterator + +\par Throws +Nothing. + +\warning +The modification of the rtree may invalidate the iterators. + +\ingroup rtree_functions + +\return The iterator pointing at the end of the range. +*/ +template inline +typename rtree::const_iterator +end(rtree const& tree) +{ + return tree.end(); +} + /*! \brief Remove all values from the index. @@ -1912,6 +2194,23 @@ inline void swap(rtree & }}} // namespace boost::geometry::index +// Boost.Range adaptation +namespace boost { + +template +struct range_mutable_iterator + < + boost::geometry::index::rtree + > +{ + typedef typename boost::geometry::index::rtree + < + Value, Parameters, IndexableGetter, EqualTo, Allocator + >::const_iterator type; +}; + +} // namespace boost + // TODO: don't include the implementation at the end of the file #include diff --git a/include/boost/geometry/io/svg/svg_mapper.hpp b/include/boost/geometry/io/svg/svg_mapper.hpp index b53fef2ce..9982d0f7e 100644 --- a/include/boost/geometry/io/svg/svg_mapper.hpp +++ b/include/boost/geometry/io/svg/svg_mapper.hpp @@ -1,6 +1,6 @@ // Boost.Geometry (aka GGL, Generic Geometry Library) -// Copyright (c) 2009-2012 Barend Gehrels, Amsterdam, the Netherlands. +// Copyright (c) 2009-2015 Barend Gehrels, Amsterdam, the Netherlands. // Parts of Boost.Geometry are redesigned from Geodan's Geographic Library // (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands. @@ -37,9 +37,6 @@ #include #include -#include -#include - #include // Helper geometries (all points are transformed to integer-points) diff --git a/include/boost/geometry/iterators/flatten_iterator.hpp b/include/boost/geometry/iterators/flatten_iterator.hpp index 07450afbe..da564f116 100644 --- a/include/boost/geometry/iterators/flatten_iterator.hpp +++ b/include/boost/geometry/iterators/flatten_iterator.hpp @@ -215,12 +215,9 @@ private: --m_outer_it; } while ( empty(m_outer_it) ); - m_inner_it = --AccessInnerEnd::apply(*m_outer_it); - } - else - { - --m_inner_it; - } + m_inner_it = AccessInnerEnd::apply(*m_outer_it); + } + --m_inner_it; } }; diff --git a/include/boost/geometry/multi/multi.hpp b/include/boost/geometry/multi/multi.hpp index 4b3063e52..85d763ee6 100644 --- a/include/boost/geometry/multi/multi.hpp +++ b/include/boost/geometry/multi/multi.hpp @@ -1,11 +1,11 @@ // 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-2015 Barend Gehrels, Amsterdam, the Netherlands. +// Copyright (c) 2008-2015 Bruno Lalande, Paris, France. +// Copyright (c) 2009-2015 Mateusz Loskot, London, UK. -// This file was modified by Oracle on 2013. -// Modifications copyright (c) 2013, Oracle and/or its affiliates. +// This file was modified by Oracle on 2013, 2015. +// Modifications copyright (c) 2013-2015, Oracle and/or its affiliates. // Parts of Boost.Geometry are redesigned from Geodan's Geographic Library // (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands. @@ -17,65 +17,8 @@ #ifndef BOOST_GEOMETRY_MULTI_HPP #define BOOST_GEOMETRY_MULTI_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 -#include -#include -#include -#include -#include - -#include - -#include -#include -#include - -#include -#include - -#include -#include -#include -#include -#include -#include - -#include - -#include -#include - -#include -#include - +// keep this file for now, for backward compatibility +// functionality-wise, make it equivalent to boost/geometry/geometry.hpp +#include #endif // BOOST_GEOMETRY_MULTI_HPP diff --git a/include/boost/geometry/policies/relate/direction.hpp b/include/boost/geometry/policies/relate/direction.hpp index 4b0a2f818..2c903bd79 100644 --- a/include/boost/geometry/policies/relate/direction.hpp +++ b/include/boost/geometry/policies/relate/direction.hpp @@ -242,7 +242,7 @@ struct segments_direction static inline return_type segments_collinear( Segment1 const& , Segment2 const& , bool opposite, int a1_wrt_b, int a2_wrt_b, int b1_wrt_a, int b2_wrt_a, - Ratio const& ra_from_wrt_b, Ratio const& ra_to_wrt_b, + Ratio const& /*ra_from_wrt_b*/, Ratio const& /*ra_to_wrt_b*/, Ratio const& /*rb_from_wrt_a*/, Ratio const& /*rb_to_wrt_a*/) { return_type r('c', opposite); diff --git a/include/boost/geometry/policies/relate/intersection_points.hpp b/include/boost/geometry/policies/relate/intersection_points.hpp index eaa8fafd4..082dc4ca7 100644 --- a/include/boost/geometry/policies/relate/intersection_points.hpp +++ b/include/boost/geometry/policies/relate/intersection_points.hpp @@ -19,6 +19,7 @@ #include #include #include +#include #include #include #include @@ -60,12 +61,24 @@ struct segments_intersection_points // denominator. In case of integer this results in an integer // division. BOOST_ASSERT(ratio.denominator() != 0); - set<0>(point, boost::numeric_cast( - get<0, 0>(segment) - + ratio.numerator() * dx / ratio.denominator())); - set<1>(point, boost::numeric_cast( - get<0, 1>(segment) - + ratio.numerator() * dy / ratio.denominator())); + + typedef typename promote_integral::type promoted_type; + + promoted_type const numerator + = boost::numeric_cast(ratio.numerator()); + promoted_type const denominator + = boost::numeric_cast(ratio.denominator()); + promoted_type const dx_promoted = boost::numeric_cast(dx); + promoted_type const dy_promoted = boost::numeric_cast(dy); + + set<0>(point, get<0, 0>(segment) + boost::numeric_cast + < + coordinate_type + >(numerator * dx_promoted / denominator)); + set<1>(point, get<0, 1>(segment) + boost::numeric_cast + < + coordinate_type + >(numerator * dy_promoted / denominator)); } diff --git a/include/boost/geometry/strategies/cartesian/cart_intersect.hpp b/include/boost/geometry/strategies/cartesian/cart_intersect.hpp index bb0749d61..a7bd38522 100644 --- a/include/boost/geometry/strategies/cartesian/cart_intersect.hpp +++ b/include/boost/geometry/strategies/cartesian/cart_intersect.hpp @@ -200,7 +200,11 @@ struct relate_cartesian_segments get<1>(robust_b1) - get<1>(robust_a1), robust_db0, robust_db); - if (robust_da0 == 0) + math::detail::equals_factor_policy + policy(robust_dx_a, robust_dy_a, robust_dx_b, robust_dy_b); + robust_coordinate_type const zero = 0; + if (math::detail::equals_by_policy(robust_da0, zero, policy) + || math::detail::equals_by_policy(robust_db0, zero, policy)) { // If this is the case, no rescaling is done for FP precision. // We set it to collinear, but it indicates a robustness issue. diff --git a/include/boost/geometry/strategies/cartesian/side_by_triangle.hpp b/include/boost/geometry/strategies/cartesian/side_by_triangle.hpp index d6324d454..77443d46a 100644 --- a/include/boost/geometry/strategies/cartesian/side_by_triangle.hpp +++ b/include/boost/geometry/strategies/cartesian/side_by_triangle.hpp @@ -46,6 +46,24 @@ namespace strategy { namespace side template class side_by_triangle { + template + struct eps_policy + { + eps_policy() {} + template + eps_policy(Type const& a, Type const& b, Type const& c, Type const& d) + : policy(a, b, c, d) + {} + Policy policy; + }; + + struct eps_empty + { + eps_empty() {} + template + eps_empty(Type const&, Type const&, Type const&, Type const&) {} + }; + public : // Template member function, because it is not always trivial @@ -61,10 +79,11 @@ public : typename PromotedType, typename P1, typename P2, - typename P + typename P, + typename EpsPolicy > static inline - PromotedType side_value(P1 const& p1, P2 const& p2, P const& p) + PromotedType side_value(P1 const& p1, P2 const& p2, P const& p, EpsPolicy & eps_policy) { CoordinateType const x = get<0>(p); CoordinateType const y = get<1>(p); @@ -79,6 +98,8 @@ public : PromotedType const dpx = x - sx1; PromotedType const dpy = y - sy1; + eps_policy = EpsPolicy(dx, dy, dpx, dpy); + return geometry::detail::determinant ( dx, dy, @@ -87,6 +108,21 @@ public : } + template + < + typename CoordinateType, + typename PromotedType, + typename P1, + typename P2, + typename P + > + static inline + PromotedType side_value(P1 const& p1, P2 const& p2, P const& p) + { + eps_empty dummy; + return side_value(p1, p2, p, dummy); + } + template < @@ -96,18 +132,18 @@ public : > struct compute_side_value { - template - static inline PromotedType apply(P1 const& p1, P2 const& p2, P const& p) + template + static inline PromotedType apply(P1 const& p1, P2 const& p2, P const& p, EpsPolicy & epsp) { - return side_value(p1, p2, p); + return side_value(p1, p2, p, epsp); } }; template struct compute_side_value { - template - static inline PromotedType apply(P1 const& p1, P2 const& p2, P const& p) + template + static inline PromotedType apply(P1 const& p1, P2 const& p2, P const& p, EpsPolicy & epsp) { // For robustness purposes, first check if any two points are // the same; in this case simply return that the points are @@ -135,24 +171,24 @@ public : if (less(p, p2)) { // p is the lexicographically smallest - return side_value(p, p1, p2); + return side_value(p, p1, p2, epsp); } else { // p2 is the lexicographically smallest - return side_value(p2, p, p1); + return side_value(p2, p, p1, epsp); } } if (less(p1, p2)) { // p1 is the lexicographically smallest - return side_value(p1, p2, p); + return side_value(p1, p2, p, epsp); } else { // p2 is the lexicographically smallest - return side_value(p2, p, p1); + return side_value(p2, p, p1, epsp); } } }; @@ -191,13 +227,14 @@ public : && boost::is_integral::value && boost::is_integral::value; + eps_policy< math::detail::equals_factor_policy > epsp; promoted_type s = compute_side_value < coordinate_type, promoted_type, are_all_integral_coordinates - >::apply(p1, p2, p); + >::apply(p1, p2, p, epsp); promoted_type const zero = promoted_type(); - return math::equals(s, zero) ? 0 + return math::detail::equals_by_policy(s, zero, epsp.policy) ? 0 : s > zero ? 1 : -1; } diff --git a/include/boost/geometry/util/math.hpp b/include/boost/geometry/util/math.hpp index fb9b976ac..721f1682a 100644 --- a/include/boost/geometry/util/math.hpp +++ b/include/boost/geometry/util/math.hpp @@ -23,6 +23,8 @@ #include #include +#include + #include #ifdef BOOST_GEOMETRY_SQRT_CHECK_FINITENESS #include @@ -30,6 +32,7 @@ #include #include #include +#include #include @@ -43,11 +46,104 @@ namespace math namespace detail { +template +inline T const& greatest(T const& v1, T const& v2) +{ + return (std::max)(v1, v2); +} -template +template +inline T const& greatest(T const& v1, T const& v2, T const& v3) +{ + return (std::max)(greatest(v1, v2), v3); +} + +template +inline T const& greatest(T const& v1, T const& v2, T const& v3, T const& v4) +{ + return (std::max)(greatest(v1, v2, v3), v4); +} + +template +inline T const& greatest(T const& v1, T const& v2, T const& v3, T const& v4, T const& v5) +{ + return (std::max)(greatest(v1, v2, v3, v4), v5); +} + + +template ::value> +struct abs +{ + static inline T apply(T const& value) + { + T const zero = T(); + return value < zero ? -value : value; + } +}; + +template +struct abs +{ + static inline T apply(T const& value) + { + return fabs(value); + } +}; + + +struct equals_default_policy +{ + template + static inline T apply(T const& a, T const& b) + { + // See http://www.parashift.com/c++-faq-lite/newbie.html#faq-29.17 + return greatest(abs::apply(a), abs::apply(b), T(1)); + } +}; + +template ::value> +struct equals_factor_policy +{ + equals_factor_policy() + : factor(1) {} + explicit equals_factor_policy(T const& v) + : factor(greatest(abs::apply(v), T(1))) + {} + equals_factor_policy(T const& v0, T const& v1, T const& v2, T const& v3) + : factor(greatest(abs::apply(v0), abs::apply(v1), + abs::apply(v2), abs::apply(v3), + T(1))) + {} + + T const& apply(T const&, T const&) const + { + return factor; + } + + T factor; +}; + +template +struct equals_factor_policy +{ + equals_factor_policy() {} + explicit equals_factor_policy(T const&) {} + equals_factor_policy(T const& , T const& , T const& , T const& ) {} + + static inline T apply(T const&, T const&) + { + return T(1); + } +}; + +template ::value> struct equals { - static inline bool apply(Type const& a, Type const& b) + template + static inline bool apply(Type const& a, Type const& b, Policy const&) { return a == b; } @@ -56,25 +152,31 @@ struct equals template struct equals { - static inline Type get_max(Type const& a, Type const& b, Type const& c) + template + static inline bool apply(Type const& a, Type const& b, Policy const& policy) { - return (std::max)((std::max)(a, b), c); - } + boost::ignore_unused(policy); - static inline bool apply(Type const& a, Type const& b) - { if (a == b) { return true; } - // See http://www.parashift.com/c++-faq-lite/newbie.html#faq-29.17, - // FUTURE: replace by some boost tool or boost::test::close_at_tolerance - return std::abs(a - b) <= std::numeric_limits::epsilon() * get_max(std::abs(a), std::abs(b), 1.0); + return abs::apply(a - b) <= std::numeric_limits::epsilon() * policy.apply(a, b); } }; -template +template +inline bool equals_by_policy(T1 const& a, T2 const& b, Policy const& policy) +{ + return detail::equals + < + typename select_most_precise::type + >::apply(a, b, policy); +} + +template ::value> struct smaller { static inline bool apply(Type const& a, Type const& b) @@ -88,7 +190,7 @@ struct smaller { static inline bool apply(Type const& a, Type const& b) { - if (equals::apply(a, b)) + if (equals::apply(a, b, equals_default_policy())) { return false; } @@ -97,8 +199,11 @@ struct smaller }; -template -struct equals_with_epsilon : public equals {}; +template ::value> +struct equals_with_epsilon + : public equals +{}; template < @@ -191,6 +296,63 @@ struct square_root }; + +template +< + typename T, + bool IsFundemantal = boost::is_fundamental::value /* false */ +> +struct modulo +{ + typedef T return_type; + + static inline T apply(T const& value1, T const& value2) + { + // for non-fundamental number types assume that a free + // function mod() is defined either: + // 1) at T's scope, or + // 2) at global scope + return mod(value1, value2); + } +}; + +template +< + typename Fundamental, + bool IsIntegral = boost::is_integral::value +> +struct modulo_for_fundamental +{ + typedef Fundamental return_type; + + static inline Fundamental apply(Fundamental const& value1, + Fundamental const& value2) + { + return value1 % value2; + } +}; + +// specialization for floating-point numbers +template +struct modulo_for_fundamental +{ + typedef Fundamental return_type; + + static inline Fundamental apply(Fundamental const& value1, + Fundamental const& value2) + { + return std::fmod(value1, value2); + } +}; + +// specialization for fundamental number type +template +struct modulo + : modulo_for_fundamental +{}; + + + /*! \brief Short construct to enable partial specialization for PI, currently not possible in Math. */ @@ -270,44 +432,36 @@ inline T relaxed_epsilon(T const& factor) template inline bool equals(T1 const& a, T2 const& b) { - typedef typename select_most_precise::type select_type; return detail::equals < - select_type, - boost::is_floating_point::type::value - >::apply(a, b); + typename select_most_precise::type + >::apply(a, b, detail::equals_default_policy()); } template inline bool equals_with_epsilon(T1 const& a, T2 const& b) { - typedef typename select_most_precise::type select_type; return detail::equals_with_epsilon < - select_type, - boost::is_floating_point::type::value - >::apply(a, b); + typename select_most_precise::type + >::apply(a, b, detail::equals_default_policy()); } template inline bool smaller(T1 const& a, T2 const& b) { - typedef typename select_most_precise::type select_type; return detail::smaller < - select_type, - boost::is_floating_point::type::value + typename select_most_precise::type >::apply(a, b); } template inline bool larger(T1 const& a, T2 const& b) { - typedef typename select_most_precise::type select_type; return detail::smaller < - select_type, - boost::is_floating_point::type::value + typename select_most_precise::type >::apply(b, a); } @@ -358,6 +512,24 @@ sqrt(T const& value) >::apply(value); } +/*! +\brief Short utility to return the modulo of two values +\ingroup utility +\param value1 First value +\param value2 Second value +\return The result of the modulo operation on the (ordered) pair +(value1, value2) +*/ +template +inline typename detail::modulo::return_type +mod(T const& value1, T const& value2) +{ + return detail::modulo + < + T, boost::is_fundamental::value + >::apply(value1, value2); +} + /*! \brief Short utility to workaround gcc/clang problem that abs is converting to integer and that older versions of MSVC does not support abs of long long... @@ -366,8 +538,7 @@ sqrt(T const& value) template inline T abs(T const& value) { - T const zero = T(); - return value < zero ? -value : value; + return detail::abs::apply(value); } /*! @@ -386,12 +557,11 @@ static inline int sign(T const& value) \ingroup utility \note If the source T is NOT an integral type and Result is an integral type the value is rounded towards the closest integral value. Otherwise it's - just casted. + casted. */ template inline Result round(T const& v) { - // NOTE: boost::round() could be used instead but it throws in some situations return detail::round::apply(v); } diff --git a/include/boost/geometry/util/promote_integral.hpp b/include/boost/geometry/util/promote_integral.hpp new file mode 100644 index 000000000..6b23403be --- /dev/null +++ b/include/boost/geometry/util/promote_integral.hpp @@ -0,0 +1,318 @@ +// Boost.Geometry (aka GGL, Generic Geometry Library) + +// Copyright (c) 2015, 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_UTIL_PROMOTE_INTEGRAL_HPP +#define BOOST_GEOMETRY_UTIL_PROMOTE_INTEGRAL_HPP + +// For now deactivate the use of multiprecision integers +// TODO: activate it later +#define BOOST_GEOMETRY_NO_MULTIPRECISION_INTEGER + +#include +#include + +#include +#include +#include +#include +#include +#include +#include + +#if !defined(BOOST_GEOMETRY_NO_MULTIPRECISION_INTEGER) +#include +#endif + +#include +#include +#include +#include + + +namespace boost { namespace geometry +{ + +#ifndef DOXYGEN_NO_DETAIL +namespace detail { namespace promote_integral +{ + +// meta-function that returns the bit size of a type +template +< + typename T, + bool IsFundamental = boost::is_fundamental::type::value +> +struct bit_size +{}; + + +// for fundamental types, just return CHAR_BIT * sizeof(T) +template +struct bit_size + : boost::mpl::size_t<(CHAR_BIT * sizeof(T))> +{}; + + +#if !defined(BOOST_GEOMETRY_NO_MULTIPRECISION_INTEGER) +// partial specialization for cpp_int +template +< + unsigned MinSize, + unsigned MaxSize, + boost::multiprecision::cpp_integer_type SignType, + boost::multiprecision::cpp_int_check_type Checked, + typename Allocator, + boost::multiprecision::expression_template_option ExpressionTemplates +> +struct bit_size + < + boost::multiprecision::number + < + boost::multiprecision::cpp_int_backend + < + MinSize, MaxSize, SignType, Checked, Allocator + >, + ExpressionTemplates + >, + false + > : boost::mpl::size_t +{}; +#endif // BOOST_GEOMETRY_NO_MULTIPRECISION_INTEGER + + +template +< + typename T, + typename Iterator, + typename EndIterator, + std::size_t MinSize +> +struct promote_to_larger +{ + typedef typename boost::mpl::deref::type current_type; + + typedef typename boost::mpl::if_c + < + (bit_size::type::value >= MinSize), + current_type, + typename promote_to_larger + < + T, + typename boost::mpl::next::type, + EndIterator, + MinSize + >::type + >::type type; +}; + +// The following specialization is required to finish the loop over +// all list elements +template +struct promote_to_larger +{ + // if promotion fails, keep the number T + // (and cross fingers that overflow will not occur) + typedef T type; +}; + +}} // namespace detail::promote_integral +#endif // DOXYGEN_NO_DETAIL + + + +/*! + \brief Meta-function to define an integral type with size + than is (roughly) twice the bit size of T + \ingroup utility + \details + This meta-function tries to promote the fundamental integral type T + to a another integral type with size (roughly) twice the bit size of T. + + To do this, two times the bit size of T is tested against the bit sizes of: + short, int, long, boost::long_long_type, boost::int128_t + and the one that first matches is chosen. + + For unsigned types the bit size of T is tested against the bit + sizes of the types above, if T is promoted to a signed type, or + the bit sizes of + unsigned short, unsigned int, unsigned long, std::size_t, + boost::ulong_long_type, boost::uint128_t + if T is promoted to an unsigned type. + + By default an unsigned type is promoted to a signed type. + This behavior is controlled by the PromoteUnsignedToUnsigned + boolean template parameter, whose default value is "false". + To promote an unsigned type to an unsigned type set the value of + this template parameter to "true". + + If the macro BOOST_GEOMETRY_NO_MULTIPRECISION_INTEGER is not + defined, boost's multiprecision integer cpp_int<> is used as a + last resort. + + If BOOST_GEOMETRY_NO_MULTIPRECISION_INTEGER is defined and an + appropriate type cannot be detected, the input type is returned as is. + + Finally, if the passed type is either a floating-point type or a + user-defined type it is returned as is. + + \note boost::long_long_type and boost::ulong_long_type are + considered only if the macro BOOST_HAS_LONG_LONG is defined + + \note boost::int128_type and boost::uint128_type are considered + only if the macros BOOST_HAS_INT128 and BOOST_GEOMETRY_ENABLE_INT128 + are defined +*/ +template +< + typename T, + bool PromoteUnsignedToUnsigned = false, + bool UseCheckedInteger = false, + bool IsIntegral = boost::is_integral::type::value +> +class promote_integral +{ +private: + static bool const is_unsigned = boost::is_unsigned::type::value; + + typedef detail::promote_integral::bit_size bit_size_type; + +#if !defined(BOOST_GEOMETRY_NO_MULTIPRECISION_INTEGER) + // Define the proper check policy for the multiprecision integer + typedef typename boost::mpl::if_c + < + UseCheckedInteger, + boost::integral_constant + < + boost::multiprecision::cpp_int_check_type, + boost::multiprecision::checked + >, + boost::integral_constant + < + boost::multiprecision::cpp_int_check_type, + boost::multiprecision::unchecked + > + >::type check_policy_type; + + // Meta-function to get the multiprecision integer type for the + // given size and sign type (signed/unsigned) + template + < + unsigned int Size, + boost::multiprecision::cpp_integer_type SignType + > + struct multiprecision_integer_type + { + typedef boost::multiprecision::number + < + boost::multiprecision::cpp_int_backend + < + Size, + Size, + SignType, + check_policy_type::value, + void + > + > type; + }; +#endif + + // Define the minimum size (in bits) needed for the promoted type + // If T is the input type and P the promoted type, then the + // minimum number of bits for P are (below b stands for the number + // of bits of T): + // * if T is unsigned and P is unsigned: 2 * b + // * if T is signed and P is signed: 2 * b - 1 + // * if T is unsigned and P is signed: 2 * b + 1 + typedef typename boost::mpl::if_c + < + (PromoteUnsignedToUnsigned && is_unsigned), + boost::mpl::size_t<(2 * bit_size_type::value)>, + typename boost::mpl::if_c + < + is_unsigned, + boost::mpl::size_t<(2 * bit_size_type::value + 1)>, + boost::mpl::size_t<(2 * bit_size_type::value - 1)> + >::type + >::type min_bit_size_type; + + // Define the list of signed integral types we are going to use + // for promotion + typedef boost::mpl::list + < + short, int, long +#if defined(BOOST_HAS_LONG_LONG) + , boost::long_long_type +#endif +#if defined(BOOST_HAS_INT128) && defined(BOOST_GEOMETRY_ENABLE_INT128) + , boost::int128_type +#endif +#if !defined(BOOST_GEOMETRY_NO_MULTIPRECISION_INTEGER) + , typename multiprecision_integer_type + < + min_bit_size_type::value, + boost::multiprecision::signed_magnitude + >::type +#endif + > signed_integral_types; + + // Define the list of unsigned integral types we are going to use + // for promotion + typedef boost::mpl::list + < + unsigned short, unsigned int, unsigned long, std::size_t +#if defined(BOOST_HAS_LONG_LONG) + , boost::ulong_long_type +#endif +#if defined(BOOST_HAS_INT128) && defined(BOOST_GEOMETRY_ENABLE_INT128) + , boost::uint128_type +#endif +#if !defined(BOOST_GEOMETRY_NO_MULTIPRECISION_INTEGER) + , typename multiprecision_integer_type + < + min_bit_size_type::value, + boost::multiprecision::unsigned_magnitude + >::type +#endif + > unsigned_integral_types; + + // Define the list of integral types that will be used for + // promotion (depending in whether we was to promote unsigned to + // unsigned or not) + typedef typename boost::mpl::if_c + < + (is_unsigned && PromoteUnsignedToUnsigned), + unsigned_integral_types, + signed_integral_types + >::type integral_types; + +public: + typedef typename detail::promote_integral::promote_to_larger + < + T, + typename boost::mpl::begin::type, + typename boost::mpl::end::type, + min_bit_size_type::value + >::type type; +}; + + +template +class promote_integral + < + T, PromoteUnsignedToUnsigned, UseCheckedInteger, false + > +{ +public: + typedef T type; +}; + + +}} // namespace boost::geometry + +#endif // BOOST_GEOMETRY_UTIL_PROMOTE_INTEGRAL_HPP diff --git a/index/test/Jamfile.v2 b/index/test/Jamfile.v2 index fc45a830e..f19f6834c 100644 --- a/index/test/Jamfile.v2 +++ b/index/test/Jamfile.v2 @@ -15,13 +15,15 @@ project boost-geometry-index-test ../../test # libs/geometry/test #../../../../boost/geometry/extensions/contrib/ttmath msvc:on + msvc:/bigobj + windows,intel:/bigobj /boost/timer//boost_timer ; test-suite boost-geometry-index-varray : [ run varray_old.cpp ] - [ run varray.cpp : : : msvc:/bigobj ] + [ run varray.cpp ] ; build-project algorithms ; diff --git a/index/test/rtree/Jamfile.v2 b/index/test/rtree/Jamfile.v2 index 463ccb3fa..23578b4e9 100644 --- a/index/test/rtree/Jamfile.v2 +++ b/index/test/rtree/Jamfile.v2 @@ -12,6 +12,7 @@ build-project generated ; test-suite boost-geometry-index-rtree : + [ run rtree_move_pack.cpp ] [ run rtree_values.cpp ] [ compile-fail rtree_values_invalid.cpp ] ; diff --git a/index/test/rtree/exceptions/Jamfile.v2 b/index/test/rtree/exceptions/Jamfile.v2 index 1728b245b..84855c4fd 100644 --- a/index/test/rtree/exceptions/Jamfile.v2 +++ b/index/test/rtree/exceptions/Jamfile.v2 @@ -17,6 +17,7 @@ rule test_all : # test-files : # requirements msvc:/bigobj + windows,intel:/bigobj ] ; } diff --git a/index/test/rtree/generated/Jamfile.v2 b/index/test/rtree/generated/Jamfile.v2 index f3900741b..a5a6f3e41 100644 --- a/index/test/rtree/generated/Jamfile.v2 +++ b/index/test/rtree/generated/Jamfile.v2 @@ -17,6 +17,7 @@ rule test_all : # test-files : # requirements msvc:/bigobj + windows,intel:/bigobj ] ; } diff --git a/index/test/rtree/interprocess/Jamfile.v2 b/index/test/rtree/interprocess/Jamfile.v2 index f5b9de66c..1a52eb953 100644 --- a/index/test/rtree/interprocess/Jamfile.v2 +++ b/index/test/rtree/interprocess/Jamfile.v2 @@ -23,7 +23,8 @@ rule test_all gcc,windows:"-lole32 -loleaut32 -lpsapi -ladvapi32" windows,clang:"-lole32 -loleaut32 -lpsapi -ladvapi32" msvc:/bigobj - linux:"-lrt" + windows,intel:/bigobj + linux:"-lrt" ] ; } diff --git a/index/test/rtree/rtree_move_pack.cpp b/index/test/rtree/rtree_move_pack.cpp new file mode 100644 index 000000000..b7210772d --- /dev/null +++ b/index/test/rtree/rtree_move_pack.cpp @@ -0,0 +1,134 @@ +// Boost.Geometry Index +// Unit Test + +// Copyright (c) 2015 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) + +#include + +#include +#include +#include +#include + +#include + +class point_cm +{ + BOOST_COPYABLE_AND_MOVABLE(point_cm) + +public: + point_cm(double xx = 0, double yy = 0) + : x(xx) + , y(yy) + , moved(false) + {} + point_cm(point_cm const& other) + : x(other.x) + , y(other.y) + , moved(false) + { + BOOST_CHECK_MESSAGE(false, "copy not allowed"); + } + point_cm & operator=(BOOST_COPY_ASSIGN_REF(point_cm) other) + { + BOOST_CHECK_MESSAGE(false, "copy not allowed"); + x = other.x; + y = other.y; + moved = false; + return *this; + } + point_cm(BOOST_RV_REF(point_cm) other) + : x(other.x) + , y(other.y) + , moved(false) + { + BOOST_CHECK_MESSAGE(!other.moved, "only one move allowed"); + other.moved = true; + } + point_cm & operator=(BOOST_RV_REF(point_cm) other) + { + BOOST_CHECK_MESSAGE(!other.moved, "only one move allowed"); + x = other.x; + y = other.y; + moved = false; + other.moved = true; + return *this; + } + + double x, y; + bool moved; +}; + +template +struct indexable +{ + typedef Point const& result_type; + result_type operator()(Point const& p) const + { + BOOST_CHECK_MESSAGE(!p.moved, "can't access indexable of moved Value"); + return p; + } +}; + +BOOST_GEOMETRY_REGISTER_POINT_2D(point_cm, double, bg::cs::cartesian, x, y) + +template +void append(Vector & vec, double x, double y) +{ + point_cm pt(x, y); + BOOST_CHECK(!pt.moved); + vec.push_back(boost::move(pt)); + BOOST_CHECK(pt.moved); +} + +struct test_moved +{ + test_moved(bool ex) + : expected(ex) + {} + template + void operator()(Point const& p) const + { + BOOST_CHECK_EQUAL(p.moved, expected); + } + bool expected; +}; + +template +void test_rtree(Params const& params = Params()) +{ + // sanity check + boost::container::vector vec; + append(vec, 0, 0); append(vec, 0, 1); append(vec, 0, 2); + append(vec, 1, 0); append(vec, 1, 1); append(vec, 1, 2); + append(vec, 2, 0); append(vec, 2, 1); append(vec, 2, 2); + + std::for_each(vec.begin(), vec.end(), test_moved(false)); + + bgi::rtree > rt( + boost::make_move_iterator(vec.begin()), + boost::make_move_iterator(vec.end()), + params); + + std::for_each(vec.begin(), vec.end(), test_moved(true)); + + BOOST_CHECK_EQUAL(rt.size(), vec.size()); +} + + +int test_main(int, char* []) +{ + test_rtree< point_cm, bgi::linear<4> >(); + test_rtree< point_cm, bgi::quadratic<4> >(); + test_rtree< point_cm, bgi::rstar<4> >(); + + test_rtree(bgi::dynamic_linear(4)); + test_rtree(bgi::dynamic_quadratic(4)); + test_rtree(bgi::dynamic_rstar(4)); + + return 0; +} diff --git a/index/test/rtree/rtree_values.cpp b/index/test/rtree/rtree_values.cpp index 2059a8141..e9eb13810 100644 --- a/index/test/rtree/rtree_values.cpp +++ b/index/test/rtree/rtree_values.cpp @@ -22,6 +22,30 @@ struct point BOOST_GEOMETRY_REGISTER_POINT_2D(point, double, bg::cs::cartesian, x, y) +template +void check_convertible_to_value(Rtree const& rt, Convertible const& conv) +{ + static const bool + is_conv_to_indexable + = boost::is_convertible::value; + static const bool + is_conv_to_value + = boost::is_convertible::value; + static const bool + is_same_as_indexable + = boost::is_same::value; + static const bool + is_same_as_value + = boost::is_same::value; + + BOOST_CHECK_EQUAL(is_same_as_indexable, false); + BOOST_CHECK_EQUAL(is_same_as_value, false); + BOOST_CHECK_EQUAL(is_conv_to_indexable, false); + BOOST_CHECK_EQUAL(is_conv_to_value, true); + + typename Rtree::value_type const& val = conv; + BOOST_CHECK(rt.value_eq()(val, conv)); +} template void test_pair() @@ -45,6 +69,11 @@ void test_pair() rt.insert(std::make_pair(box, (unsigned short)0)); BOOST_CHECK_EQUAL(rt.size(), 3u); + check_convertible_to_value(rt, std::make_pair(box, 0)); + check_convertible_to_value(rt, std::make_pair(box, (unsigned short)0)); + BOOST_CHECK(bg::covered_by(rt.indexable_get()(std::make_pair(box, 0)), rt.bounds())); + BOOST_CHECK(bg::covered_by(rt.indexable_get()(std::make_pair(box, (unsigned short)0)), rt.bounds())); + BOOST_CHECK_EQUAL(rt.count(val), 3u); BOOST_CHECK_EQUAL(rt.count(std::make_pair(box, 0)), 3u); BOOST_CHECK_EQUAL(rt.count(std::make_pair(box, (unsigned short)0)), 3u); diff --git a/index/test/rtree/test_rtree.hpp b/index/test/rtree/test_rtree.hpp index 12f5e61a5..75f787947 100644 --- a/index/test/rtree/test_rtree.hpp +++ b/index/test/rtree/test_rtree.hpp @@ -733,6 +733,38 @@ void copy_alt(First first, Last last, Out out) *out = *first; } +// test query iterators +template +void check_fwd_iterators(QItF first, QItL last) +{ + QItF vinit = QItF(); + BOOST_CHECK(vinit == last); + +#ifdef BOOST_GEOMETRY_INDEX_DETAIL_EXPERIMENTAL + QItL vinit2 = QItL(); + BOOST_CHECK(vinit2 == last); +#endif + + QItF def; + BOOST_CHECK(def == last); + +#ifdef BOOST_GEOMETRY_INDEX_DETAIL_EXPERIMENTAL + QItL def2; + BOOST_CHECK(def2 == last); +#endif + + QItF it = first; + for ( ; it != last && first != last ; ++it, ++first) + { + BOOST_CHECK(it == first); + + bg::index::equal_to::value_type> eq; + BOOST_CHECK(eq(*it, *first)); + } + BOOST_CHECK(it == last); + BOOST_CHECK(first == last); +} + // spatial query template @@ -766,6 +798,8 @@ void spatial_query(Rtree & rtree, Predicates const& pred, std::vector con exactly_the_same_outputs(rtree, output3, output4); + check_fwd_iterators(rtree.qbegin(pred), rtree.qend()); + #ifdef BOOST_GEOMETRY_INDEX_DETAIL_EXPERIMENTAL { std::vector output4; @@ -774,6 +808,9 @@ void spatial_query(Rtree & rtree, Predicates const& pred, std::vector con output4.clear(); copy_alt(rtree.qbegin_(pred), rtree.qend_(), std::back_inserter(output4)); compare_outputs(rtree, output4, expected_output); + + check_fwd_iterators(rtree.qbegin_(pred), rtree.qend_(pred)); + check_fwd_iterators(rtree.qbegin_(pred), rtree.qend_()); } #endif } @@ -1217,6 +1254,8 @@ inline void nearest_query_k(Rtree const& rtree, std::vector const& input, compare_nearest_outputs(rtree, output3, expected_output, pt, greatest_distance); check_sorted_by_distance(rtree, output3, pt); + check_fwd_iterators(rtree.qbegin(bgi::nearest(pt, k)), rtree.qend()); + #ifdef BOOST_GEOMETRY_INDEX_DETAIL_EXPERIMENTAL { std::vector output4; @@ -1225,6 +1264,9 @@ inline void nearest_query_k(Rtree const& rtree, std::vector const& input, output4.clear(); copy_alt(rtree.qbegin_(bgi::nearest(pt, k)), rtree.qend_(), std::back_inserter(output4)); exactly_the_same_outputs(rtree, output4, output3); + + check_fwd_iterators(rtree.qbegin_(bgi::nearest(pt, k)), rtree.qend_(bgi::nearest(pt, k))); + check_fwd_iterators(rtree.qbegin_(bgi::nearest(pt, k)), rtree.qend_()); } #endif } @@ -1580,6 +1622,31 @@ void clear(Rtree const& tree, std::vector const& input, Box const& qbox) } } +template +void range(Rtree & tree, std::vector const& input) +{ + check_fwd_iterators(tree.begin(), tree.end()); + + size_t count = std::distance(tree.begin(), tree.end()); + BOOST_CHECK(count == tree.size()); + BOOST_CHECK(count == input.size()); + + count = std::distance(boost::begin(tree), boost::end(tree)); + BOOST_CHECK(count == tree.size()); + + count = boost::size(tree); + BOOST_CHECK(count == tree.size()); + + count = 0; + BOOST_FOREACH(Value const& v, tree) + { + boost::ignore_unused(v); + ++count; + } + BOOST_CHECK(count == tree.size()); + +} + // rtree queries template @@ -1806,12 +1873,36 @@ void test_rtree_bounds(Parameters const& parameters, Allocator const& allocator) BOOST_CHECK(bg::equals(t.bounds(), b)); } +// test rtree iterator + +template +void test_rtree_range(Parameters const& parameters, Allocator const& allocator) +{ + typedef std::pair Value; + + typedef bgi::indexable I; + typedef bgi::equal_to E; + typedef typename Allocator::template rebind::other A; + typedef bgi::rtree Tree; + typedef typename Tree::bounds_type B; + + Tree t(parameters, I(), E(), allocator); + std::vector input; + B qbox; + + generate::rtree(t, input, qbox); + + basictest::range(t, input); + basictest::range((Tree const&)t, input); +} + template void test_rtree_additional(Parameters const& parameters, Allocator const& allocator) { test_count_rtree_values(parameters, allocator); test_rtree_count(parameters, allocator); test_rtree_bounds(parameters, allocator); + test_rtree_range(parameters, allocator); } // run all tests for one Algorithm for some number of rtrees diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 index 6963a0575..7ba3fa4b6 100644 --- a/test/Jamfile.v2 +++ b/test/Jamfile.v2 @@ -16,7 +16,9 @@ project boost-geometry-test . ../../../boost/geometry/extensions/contrib/ttmath msvc:on + msvc:/bigobj clang:-Wno-unneeded-internal-declaration # supress warning by Boost.None + windows,intel:/bigobj ; build-project core ; diff --git a/test/algorithms/Jamfile.v2 b/test/algorithms/Jamfile.v2 index e6bd3512f..5fd0e3c04 100644 --- a/test/algorithms/Jamfile.v2 +++ b/test/algorithms/Jamfile.v2 @@ -16,21 +16,21 @@ test-suite boost-geometry-algorithms : - [ run append.cpp : : : msvc:/bigobj ] - [ run area.cpp : : : msvc:/bigobj ] + [ run append.cpp ] + [ run area.cpp ] [ run assign.cpp ] [ run buffer.cpp ] - [ run centroid.cpp : : : msvc:/bigobj ] - [ run comparable_distance.cpp : : : msvc:/bigobj ] - [ run convex_hull.cpp : : : msvc:/bigobj ] - [ run correct.cpp : : : msvc:/bigobj ] - [ run convert.cpp : : : msvc:/bigobj ] - [ run envelope.cpp : : : msvc:/bigobj ] + [ run centroid.cpp ] + [ run comparable_distance.cpp ] + [ run convex_hull.cpp ] + [ run correct.cpp ] + [ run convert.cpp ] + [ run envelope.cpp ] [ run expand.cpp ] [ run for_each.cpp ] - [ run is_simple.cpp : : : msvc:/bigobj ] - [ run is_valid.cpp : : : msvc:/bigobj ] - [ run is_valid_failure.cpp : : : msvc:/bigobj ] + [ run is_simple.cpp ] + [ run is_valid.cpp ] + [ run is_valid_failure.cpp ] [ run length.cpp ] [ run make.cpp ] [ run multi_area.cpp ] diff --git a/test/algorithms/append.cpp b/test/algorithms/append.cpp index 2a3d01a86..0eda9669c 100644 --- a/test/algorithms/append.cpp +++ b/test/algorithms/append.cpp @@ -1,12 +1,12 @@ // 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) 2007-2015 Barend Gehrels, Amsterdam, the Netherlands. +// Copyright (c) 2008-2015 Bruno Lalande, Paris, France. +// Copyright (c) 2009-2015 Mateusz Loskot, London, UK. -// This file was modified by Oracle on 2014. -// Modifications copyright (c) 2014, Oracle and/or its affiliates. +// This file was modified by Oracle on 2014, 2015. +// Modifications copyright (c) 2014-2015, Oracle and/or its affiliates. // Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle @@ -24,25 +24,20 @@ #include #include +#include +#include #include #include #include #include #include +#include #include #include #include #include -// includes for multi-geometries -#include -#include -#include -#include -#include -#include -#include BOOST_GEOMETRY_REGISTER_LINESTRING_TEMPLATED(std::vector) BOOST_GEOMETRY_REGISTER_LINESTRING_TEMPLATED(std::deque) diff --git a/test/algorithms/buffer/Jamfile.v2 b/test/algorithms/buffer/Jamfile.v2 index 125c600db..c7a37a646 100644 --- a/test/algorithms/buffer/Jamfile.v2 +++ b/test/algorithms/buffer/Jamfile.v2 @@ -14,13 +14,13 @@ project boost-geometry-algorithms-buffer test-suite boost-geometry-algorithms-buffer : - [ run point_buffer.cpp : : : BOOST_GEOMETRY_TEST_ONLY_ONE_TYPE msvc:/bigobj ] - [ run linestring_buffer.cpp : : : BOOST_GEOMETRY_TEST_ONLY_ONE_TYPE msvc:/bigobj ] - [ run polygon_buffer.cpp : : : BOOST_GEOMETRY_TEST_ONLY_ONE_TYPE msvc:/bigobj ] - [ run multi_point_buffer.cpp : : : BOOST_GEOMETRY_TEST_ONLY_ONE_TYPE msvc:/bigobj ] - [ run multi_linestring_buffer.cpp : : : BOOST_GEOMETRY_TEST_ONLY_ONE_TYPE msvc:/bigobj ] - [ run multi_polygon_buffer.cpp : : : BOOST_GEOMETRY_TEST_ONLY_ONE_TYPE msvc:/bigobj ] - [ run aimes_linestring_buffer.cpp : : : BOOST_GEOMETRY_TEST_ONLY_ONE_TYPE msvc:/bigobj ] -# [ run country_buffer.cpp : : : BOOST_GEOMETRY_TEST_ONLY_ONE_TYPE msvc:/bigobj ] # Uncomment if you want to test this manually; requires access to data/ folder + [ run point_buffer.cpp : : : BOOST_GEOMETRY_TEST_ONLY_ONE_TYPE ] + [ run linestring_buffer.cpp : : : BOOST_GEOMETRY_TEST_ONLY_ONE_TYPE ] + [ run polygon_buffer.cpp : : : BOOST_GEOMETRY_TEST_ONLY_ONE_TYPE ] + [ run multi_point_buffer.cpp : : : BOOST_GEOMETRY_TEST_ONLY_ONE_TYPE ] + [ run multi_linestring_buffer.cpp : : : BOOST_GEOMETRY_TEST_ONLY_ONE_TYPE ] + [ run multi_polygon_buffer.cpp : : : BOOST_GEOMETRY_TEST_ONLY_ONE_TYPE ] + [ run aimes_linestring_buffer.cpp : : : BOOST_GEOMETRY_TEST_ONLY_ONE_TYPE ] +# [ run country_buffer.cpp : : : BOOST_GEOMETRY_TEST_ONLY_ONE_TYPE ] # Uncomment if you want to test this manually; requires access to data/ folder ; diff --git a/test/algorithms/buffer/country_buffer.cpp b/test/algorithms/buffer/country_buffer.cpp index 66e985728..51d871ed9 100644 --- a/test/algorithms/buffer/country_buffer.cpp +++ b/test/algorithms/buffer/country_buffer.cpp @@ -1,7 +1,7 @@ // Boost.Geometry (aka GGL, Generic Geometry Library) // Unit Test -// Copyright (c) 2014 Barend Gehrels, Amsterdam, the Netherlands. +// Copyright (c) 2014-2015 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 @@ -9,8 +9,6 @@ #include -#include - template std::string read_from_file(std::string const& filename) @@ -148,80 +146,80 @@ void test_all() std::string no = read_from_file("data/no.wkt"); std::string uk = read_from_file("data/uk.wkt"); - test_one("gr10", gr, 336274443102, 10); - test_one("gr20", gr, 442303404970, 20); - test_one("gr50", gr, 680414236746, 50); - test_one("gr100", gr, 910435136622, 100); + test_one("gr10", gr, 336279815057, 10); + test_one("gr20", gr, 442317493728, 20); + test_one("gr50", gr, 680442278144, 50); + test_one("gr100", gr, 910474619262, 100); - test_one("gr10", gr, 139315436711, -10); - test_one("gr20", gr, 96996694672, -20); - test_one("gr50", gr, 31400319981, -50); - test_one("gr100", gr, 2038866888, -100); + test_one("gr10", gr, 139313148239, -10); + test_one("gr20", gr, 96991352461, -20); + test_one("gr50", gr, 31391928703, -50); + test_one("gr100", gr, 2035400463, -100); - test_one("it1", it, 569862957683, 1); - test_one("it2", it, 579239031444, 2); - test_one("it5", it, 607624450258, 5); - test_one("it10", it, 655015072045, 10); - test_one("it20", it, 749341988637, 20); - test_one("it50", it, 1018283833002, 50); - test_one("it100", it, 1436371098919, 100); + test_one("it1", it, 569863002352, 1); + test_one("it2", it, 579239205460, 2); + test_one("it5", it, 607625467971, 5); + test_one("it10", it, 655018590164, 10); + test_one("it20", it, 749353300126, 20); + test_one("it50", it, 1018323108593, 50); + test_one("it100", it, 1436451405440, 100); - test_one("it1", it, 551474452673, -1); - test_one("it2", it, 542617896207, -2); - test_one("it5", it, 517403395015, -5); - test_one("it10", it, 477948804826, -10); - test_one("it20", it, 404704185411, -20); - test_one("it50", it, 238775955402, -50); - test_one("it100", it, 69800921399, -100); + test_one("it1", it, 551474409670, -1); + test_one("it2", it, 542617726944, -2); + test_one("it5", it, 517402446347, -5); + test_one("it10", it, 477945526913, -10); + test_one("it20", it, 404693994961, -20); + test_one("it50", it, 238748456044, -50); + test_one("it100", it, 69768639974, -100); test_one("it200", it, 0, -200); - test_one("nl1", nl, 97391149343, 1); - test_one("nl2", nl, 100816629886, 2); - test_one("nl5", nl, 110239413808, 5); - test_one("nl10", nl, 123407160072, 10); - test_one("nl20", nl, 145044379084, 20); - test_one("nl50", nl, 201197559681, 50); - test_one("nl100", nl, 303275571989, 100); + test_one("nl1", nl, 97391171492, 1); + test_one("nl2", nl, 100816708947, 2); + test_one("nl5", nl, 110239800198, 5); + test_one("nl10", nl, 123408276767, 10); + test_one("nl20", nl, 145046916470, 20); + test_one("nl50", nl, 201207309280, 50); + test_one("nl100", nl, 303300936130, 100); - test_one("nl1", nl, 90095062551, -1); - test_one("nl2", nl, 86601922962, -2); - test_one("nl5", nl, 77308154694, -5); - test_one("nl10", nl, 64669734511, -10); - test_one("nl20", nl, 46685545338, -20); - test_one("nl50", nl, 10248593002, -50); + test_one("nl1", nl, 90095047258, -1); + test_one("nl2", nl, 86601864925, -2); + test_one("nl5", nl, 77307843491, -5); + test_one("nl10", nl, 64668873412, -10); + test_one("nl20", nl, 46683532991, -20); + test_one("nl50", nl, 10244522894, -50); test_one("nl100", nl, 0, -100); - test_one("no1", no, 1819566431968, 1); - test_one("no2", no, 1865040587680, 2); - test_one("no5", no, 1973612505198, 5); - test_one("no10", no, 2102026964987, 10); - test_one("no20", no, 2292154347925, 20); - test_one("no50", no, 2725424299143, 50); - test_one("no100", no, 3374865875758, 100); + test_one("no1", no, 1819566643132, 1); + test_one("no2", no, 1865041330273, 2); + test_one("no5", no, 1973615513085, 5); + test_one("no10", no, 2102034197635, 10); + test_one("no20", no, 2292171193871, 20); + test_one("no50", no, 2725475412131, 50); + test_one("no100", no, 3374987097497, 100); - test_one("no1", no, 1725145481020, -1); - test_one("no2", no, 1678942941890, -2); - test_one("no5", no, 1547331904374, -5); - test_one("no10", no, 1361206959153, -10); - test_one("no20", no, 1089865725529, -20); - test_one("no50", no, 649657900609, -50); - test_one("no100", no, 306772606713, -100); + test_one("no1", no, 1725145365167, -1); + test_one("no2", no, 1678942477834, -2); + test_one("no5", no, 1547329288139, -5); + test_one("no10", no, 1361198992659, -10); + test_one("no20", no, 1089847769281, -20); + test_one("no50", no, 649622185906, -50); + test_one("no100", no, 306739135037, -100); - test_one("uk1", uk, 733080699236, 1); - test_one("uk2", uk, 749555588975, 2); - test_one("uk5", uk, 793750965288, 5); - test_one("uk10", uk, 857677152435, 10); - test_one("uk20", uk, 970474644257, 20); - test_one("uk50", uk, 1247789678698, 50); - test_one("uk100", uk, 1659782604299, 100); + test_one("uk1", uk, 733080792661, 1); + test_one("uk2", uk, 749555934157, 2); + test_one("uk5", uk, 793752670139, 5); + test_one("uk10", uk, 857682293758, 10); + test_one("uk20", uk, 970488073372, 20); + test_one("uk50", uk, 1247830326998, 50); + test_one("uk100", uk, 1659861947865, 100); - test_one("uk1", uk, 699378162790, -1); - test_one("uk2", uk, 683086653377, -2); - test_one("uk5", uk, 637326518646, -5); - test_one("uk10", uk, 572560284244, -10); - test_one("uk20", uk, 479267296848, -20); - test_one("uk50", uk, 274851268903, -50); - test_one("uk100", uk, 78225232337, -100); + test_one("uk1", uk, 699378105887, -1); + test_one("uk2", uk, 683086430553, -2); + test_one("uk5", uk, 637325270073, -5); + test_one("uk10", uk, 572556645697, -10); + test_one("uk20", uk, 479258135850, -20); + test_one("uk50", uk, 274828075226, -50); + test_one("uk100", uk, 78205462121, -100); } int test_main(int, char* []) diff --git a/test/algorithms/buffer/linestring_buffer.cpp b/test/algorithms/buffer/linestring_buffer.cpp index 337ea2824..5179eff9b 100644 --- a/test/algorithms/buffer/linestring_buffer.cpp +++ b/test/algorithms/buffer/linestring_buffer.cpp @@ -63,6 +63,8 @@ static std::string const mysql_report_2015_03_02a = "LINESTRING(0 0,0 5,5 5,5 0, static std::string const mysql_report_2015_03_02b = "LINESTRING(0 1,0 5,5 5,5 0,1 0)"; // not closed, 1 difference static std::string const mysql_report_2015_03_02c = "LINESTRING(0 2,0 5,5 5,5 0,2 0)"; // not closed, 2 difference +static std::string const mysql_report_2015_04_01 = "LINESTRING(103 5,107 2,111 4,116 -1,115 0,112 4)"; + template void test_all() @@ -201,6 +203,10 @@ void test_all() double const d15 = 1.5; test_one("mysql_report_2015_03_02c_asym1", mysql_report_2015_03_02c, join_round(7), end_round(7), 39.714, d10, d15); test_one("mysql_report_2015_03_02c_asym2", mysql_report_2015_03_02c, join_round(7), end_round(7), 46.116, d15, d10); +#if defined(BOOST_GEOMETRY_BUFFER_INCLUDE_FAILING_TESTS) + double const d100 = 10; + test_one("mysql_report_2015_04_01", mysql_report_2015_04_01, join_round(32), end_round(32), 1.0/*NON ZERO*/, d100); +#endif } diff --git a/test/algorithms/buffer/multi_linestring_buffer.cpp b/test/algorithms/buffer/multi_linestring_buffer.cpp index 24aca1a67..1f09ceeb8 100644 --- a/test/algorithms/buffer/multi_linestring_buffer.cpp +++ b/test/algorithms/buffer/multi_linestring_buffer.cpp @@ -1,7 +1,7 @@ // Boost.Geometry (aka GGL, Generic Geometry Library) // Unit Test -// Copyright (c) 2012-2014 Barend Gehrels, Amsterdam, the Netherlands. +// Copyright (c) 2012-2015 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 @@ -9,8 +9,6 @@ #include -#include - static std::string const simplex = "MULTILINESTRING((0 0,4 5),(5 4,10 0))"; static std::string const two_bends = "MULTILINESTRING((0 0,4 5,7 4,10 6),(1 5,5 9,8 6))"; static std::string const turn_inside = "MULTILINESTRING((0 0,4 5,7 4,10 6),(1 5,5 9,8 6),(0 4,-2 6))"; @@ -31,6 +29,7 @@ static std::string const mikado2 = "MULTILINESTRING((-6.117647058823528993798390 static std::string const mikado3 = "MULTILINESTRING((1 18,4.0559006211180124168436122999992 7.8136645962732922399140989000443),(6.7243816254416959310447055031545 -1.0812720848056533995418249105569,7 -2,7 -8,14 3.6666666666666669627261399000417),(15.297872340425531234586742357351 5.8297872340425538340014099958353,16 7,15.214285714285713524418497399893 5.8445378151260509724806979647838),(13.685863874345550073030608473346 3.5968586387434555717845796607435,-1 -18,-3.7900797165633304253162805252941 -11.117803365810452476125647081062),(-11.540540540540540348501963308081 8,-16 19,8 14),(1 -10,6.5999999999999996447286321199499 -1.200000000000000177635683940025),(11.5 6.5,15 12),(19 10,11.564231738035264385189293534495 6.4886649874055422060337150469422),(-13.438785504407443127661281323526 -5.3183153770812925387190261972137,-17 -7,-12.970074812967581578959652688354 -7.7556109725685784539450651209336),(-2.3532338308457703135445626685396 -9.7462686567164187323442092747428,-1 -10,12.285714285714286475581502600107 3.2857142857142864755815026001073),(14.90000000000000035527136788005 5.9000000000000003552713678800501,15 6,14.893004115226338157640384451952 5.9012345679012341292946075554937),(11.987804878048780921062643756159 3.2195121951219514144781896902714,-11 -18),(-12.210826210826210669324609625619 -11.703703703703702387883822666481,-15 -15,-11.463576158940396609864365018439 -15.589403973509934786534358863719),(-8.9189189189189193029960733838379 -16.013513513513512265262761502527,-3 -17,-7.0297239915074314353660156484693 -14.210191082802548834251865628175),(-12.450511945392491952588898129761 -10.457337883959045399251408525743,-16 -8,-12.923076923076923350208744523115 -8),(-0.52380952380952372493538859998807 -8,18 -8),(2 -19,-2.2961165048543685784920853620861 -9.6917475728155331182733789319173),(6.0463576158940393057150686217938 -1.7284768211920527036795647291001,7 -3,6.4482758620689653028534848999698 -1.3448275862068967967388744000345),(-1.3333333333333339254522798000835 8,4 16,2.9090909090909091716525836091023 8),(0.64705882352941168633719826175366 -6.8823529411764710062016092706472,-3 -16))"; static std::string const mikado4 = "MULTILINESTRING((-15 2,-15 -17,-6 11,-1.9358288770053475591481628725887 10.572192513368984023713892383967),(2.1545064377682408007785852532834 10.14163090128755406738036981551,6.87603305785123986026974307606 9.6446280991735537924114396446384),(8.4810810810810810522752944962122 9.475675675675674369813350494951,13 9),(-15 0,-8 9,-2.9850746268656713766631582984701 4.4865671641791049495395782287233),(-1.8235294117647056211239942058455 3.4411764705882355031008046353236,-1.1428571428571423496123315999284 2.8285714285714291804652020800859),(1.2307692307692308375521861307789 0.69230769230769229061195346730528,1.2857142857142858094476878250134 0.64285714285714290472384391250671,2 0,1.9459459459459460539676456392044 0.51351351351351348650808859019889),(1.908127208480565384363103476062 0.87279151943462895957281943992712,1.9078014184397162900097555393586 0.87588652482269502286271745106205),(1.4685990338164249813246442499803 5.0483091787439615671928550000302,0.63551401869158885560295857430901 12.962616822429906093816498469096,0 19,2.9565217391304345895264304999728 8.6521739130434784925682834000327),(0 19,3.4942528735632185643567027000245 6.770114942528735468840750399977),(4.75 2.375,5.2427184466019420838733822165523 0.65048543689320226235395239200443),(5.5384615384615383248956277384423 -0.38461538461538458122390693461057,5.7358490566037731994697423942853 -1.0754716981132084185901476303115),(5.9777777777777778567269706400111 -1.9222222222222207221875578397885,6.867052023121386739035187929403 -5.0346820809248553629799971531611,10 -16,-14 -19,-12 -12),(0 10,1.9476439790575916788384347455576 5.4554973821989527493769855936989),(-4 1,-4.2790697674418600726653494348284 0.16279069767441856075862460784265))"; +static std::string const mysql_15_04_10 = "MULTILINESTRING((-58 19, 61 88),(1.922421e+307 1.520384e+308, 15 42, 89 -93,-89 -22),(-63 -5, -262141 -536870908, -3 87, 77 -69))"; template void test_all() @@ -99,6 +98,10 @@ void test_all() test_one("mikado4_large", mikado4, join_round32, end_round32, 11212832197.267, 59772.0); test_one("mikado4_small", mikado4, join_round32, end_round32, 2103.686, 10.0); test_one("mikado4_small", mikado4, join_round32, end_flat, 1930.785, 10.0); + +#ifdef BOOST_GEOMETRY_BUFFER_INCLUDE_FAILING_TESTS + test_one("mysql_15_04_10", mysql_15_04_10, join_round32, end_round32, 29151950703.779/*something big*/, 0x98); +#endif } diff --git a/test/algorithms/buffer/multi_point_buffer.cpp b/test/algorithms/buffer/multi_point_buffer.cpp index 5c4cbd6a7..d5fcf0583 100644 --- a/test/algorithms/buffer/multi_point_buffer.cpp +++ b/test/algorithms/buffer/multi_point_buffer.cpp @@ -9,8 +9,6 @@ #include -#include - static std::string const simplex = "MULTIPOINT((5 5),(7 7))"; static std::string const three = "MULTIPOINT((5 8),(9 8),(7 11))"; diff --git a/test/algorithms/buffer/multi_polygon_buffer.cpp b/test/algorithms/buffer/multi_polygon_buffer.cpp index 4b526a8e6..eef6d5155 100644 --- a/test/algorithms/buffer/multi_polygon_buffer.cpp +++ b/test/algorithms/buffer/multi_polygon_buffer.cpp @@ -1,7 +1,7 @@ // Boost.Geometry (aka GGL, Generic Geometry Library) // Unit Test -// Copyright (c) 2012-2014 Barend Gehrels, Amsterdam, the Netherlands. +// Copyright (c) 2012-2015 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 @@ -9,8 +9,6 @@ #include -#include - static std::string const simplex = "MULTIPOLYGON(((0 1,2 5,5 3,0 1)),((1 1,5 2,5 0,1 1)))"; diff --git a/test/algorithms/buffer/test_buffer.hpp b/test/algorithms/buffer/test_buffer.hpp index dc0177d15..6b0d91105 100644 --- a/test/algorithms/buffer/test_buffer.hpp +++ b/test/algorithms/buffer/test_buffer.hpp @@ -542,13 +542,17 @@ void test_buffer(std::string const& caseid, Geometry const& geometry, if (expected_area > -0.1) { + double const difference = area - expected_area; BOOST_CHECK_MESSAGE ( - bg::math::abs(area - expected_area) < tolerance, + bg::math::abs(difference) < tolerance, complete.str() << " not as expected. " << std::setprecision(18) - << " Expected: " << expected_area - << " Detected: " << area + << " Expected: " << expected_area + << " Detected: " << area + << " Diff: " << difference + << std::setprecision(3) + << " , " << 100.0 * (difference / expected_area) << "%" ); if (check_self_intersections) diff --git a/test/algorithms/centroid.cpp b/test/algorithms/centroid.cpp index dc6993996..b5fb87a81 100644 --- a/test/algorithms/centroid.cpp +++ b/test/algorithms/centroid.cpp @@ -145,6 +145,7 @@ void test_large_integers() bg::centroid(double_poly, double_centroid); int_point_type double_centroid_as_int; + bg::assign_zero(double_centroid_as_int); bg::assign(int_centroid, double_centroid_as_int); BOOST_CHECK_EQUAL(bg::get<0>(int_centroid), bg::get<0>(double_centroid_as_int)); diff --git a/test/algorithms/detail/Jamfile.v2 b/test/algorithms/detail/Jamfile.v2 index 015e2be6a..b6bd15949 100644 --- a/test/algorithms/detail/Jamfile.v2 +++ b/test/algorithms/detail/Jamfile.v2 @@ -10,6 +10,7 @@ test-suite boost-geometry-algorithms-detail : + [ run as_range.cpp ] [ run partition.cpp ] ; diff --git a/test/util/as_range.cpp b/test/algorithms/detail/as_range.cpp similarity index 92% rename from test/util/as_range.cpp rename to test/algorithms/detail/as_range.cpp index f8696eeca..dd6aabf28 100644 --- a/test/util/as_range.cpp +++ b/test/algorithms/detail/as_range.cpp @@ -17,7 +17,7 @@ #include -#include +#include #include #include @@ -47,10 +47,10 @@ void test_geometry(std::string const& wkt, double expected_x, double expected_y) bg::read_wkt(wkt, geometry); - double s = sum<0>(bg::as_range(geometry)); + double s = sum<0>(bg::detail::as_range(geometry)); BOOST_CHECK_CLOSE(s, expected_x, 0.001); - s = sum<1>(bg::as_range(geometry)); + s = sum<1>(bg::detail::as_range(geometry)); BOOST_CHECK_CLOSE(s, expected_y, 0.001); } diff --git a/test/algorithms/detail/partition.cpp b/test/algorithms/detail/partition.cpp index e55c87307..bf50b880f 100644 --- a/test/algorithms/detail/partition.cpp +++ b/test/algorithms/detail/partition.cpp @@ -1,6 +1,6 @@ // Boost.Geometry (aka GGL, Generic Geometry Library) // -// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands. +// Copyright (c) 2007-2015 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) @@ -11,14 +11,13 @@ #include -#include +#include #include #include #include #include -#include #if defined(TEST_WITH_SVG) # include diff --git a/test/algorithms/distance/Jamfile.v2 b/test/algorithms/distance/Jamfile.v2 index 1eb679dd7..bb76a8622 100644 --- a/test/algorithms/distance/Jamfile.v2 +++ b/test/algorithms/distance/Jamfile.v2 @@ -16,9 +16,9 @@ test-suite boost-geometry-algorithms-distance : - [ run distance.cpp : : : msvc:/bigobj ] - [ run distance_areal_areal.cpp : : : msvc:/bigobj ] - [ run distance_linear_areal.cpp : : : msvc:/bigobj ] + [ run distance.cpp ] + [ 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 ] diff --git a/test/algorithms/distance/distance.cpp b/test/algorithms/distance/distance.cpp index 84e066808..2f9c74c39 100644 --- a/test/algorithms/distance/distance.cpp +++ b/test/algorithms/distance/distance.cpp @@ -1,9 +1,9 @@ // 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) 2007-2015 Barend Gehrels, Amsterdam, the Netherlands. +// Copyright (c) 2008-2015 Bruno Lalande, Paris, France. +// Copyright (c) 2009-2015 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. @@ -30,12 +30,6 @@ #include #include -// includes for multi-geometries -#include -#include -#include -#include - #include BOOST_GEOMETRY_REGISTER_C_ARRAY_CS(cs::cartesian) diff --git a/test/algorithms/distance/distance_areal_areal.cpp b/test/algorithms/distance/distance_areal_areal.cpp index 53d01dda0..37c324e81 100644 --- a/test/algorithms/distance/distance_areal_areal.cpp +++ b/test/algorithms/distance/distance_areal_areal.cpp @@ -1,7 +1,7 @@ // Boost.Geometry (aka GGL, Generic Geometry Library) // Unit Test -// Copyright (c) 2014, Oracle and/or its affiliates. +// Copyright (c) 2014-2015, Oracle and/or its affiliates. // Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle @@ -79,12 +79,12 @@ void test_distance_polygon_multipolygon(Strategy const& strategy) 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); + 0.1, 0.01, strategy); 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); + 0, 0, strategy); } //=========================================================================== @@ -155,12 +155,12 @@ void test_distance_multipolygon_ring(Strategy const& strategy) tester::apply("multipolygon(((-10 -10,10 -10,10 10,-10 10,-10 -10)),\ ((20 -1,21 2,30 -10,20 -1)))", "polygon((12 0,14 0,19 0,19.9 -1,12 0))", - 0.1, 0.01, strategy, true); + 0.1, 0.01, strategy); tester::apply("multipolygon(((-10 -10,10 -10,10 10,-10 10,-10 -10)),\ ((20 -1,21 2,30 -10,20 -1)))", "polygon((19 0,19.9 -1,12 0,20.5 0.5,19 0))", - 0, 0, strategy, true); + 0, 0, strategy); } //=========================================================================== diff --git a/test/algorithms/distance/distance_linear_areal.cpp b/test/algorithms/distance/distance_linear_areal.cpp index 0c97c2beb..ae396ba47 100644 --- a/test/algorithms/distance/distance_linear_areal.cpp +++ b/test/algorithms/distance/distance_linear_areal.cpp @@ -1,7 +1,7 @@ // Boost.Geometry (aka GGL, Generic Geometry Library) // Unit Test -// Copyright (c) 2014, Oracle and/or its affiliates. +// Copyright (c) 2014-2015, Oracle and/or its affiliates. // Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle @@ -84,27 +84,27 @@ void test_distance_linestring_polygon(Strategy const& strategy) tester::apply("linestring(-1 20,1 20,1 30)", "polygon((-10 -10,10 -10,10 10,-10 10,-10 -10))", - 10, 100, strategy, true); + 10, 100, strategy); tester::apply("linestring(-5 1,-2 1)", "polygon((0 0,10 0,10 10,0 10,0 0))", - 2, 4, strategy, true); + 2, 4, strategy); tester::apply("linestring(-1 20,1 20,1 5)", "polygon((-10 -10,10 -10,10 10,-10 10,-10 -10))", - 0, 0, strategy, true); + 0, 0, strategy); tester::apply("linestring(-1 20,1 20,1 -20)", "polygon((-10 -10,10 -10,10 10,-10 10,-10 -10))", - 0, 0, strategy, true); + 0, 0, strategy); tester::apply("linestring(-2 1)", "polygon((0 0,10 0,10 10,0 10,0 0))", - 2, 4, strategy, true); + 2, 4, strategy); tester::apply("linestring(-5 1,-2 1)", "polygon((0 0))", - sqrt(5.0), 5, strategy, true); + sqrt(5.0), 5, strategy); } //=========================================================================== @@ -123,7 +123,7 @@ void test_distance_linestring_open_polygon(Strategy const& strategy) tester::apply("linestring(-5 1,-2 1)", "polygon((0 0,10 0,10 10,0 10))", - 2, 4, strategy, true); + 2, 4, strategy); } //=========================================================================== @@ -142,23 +142,23 @@ void test_distance_multilinestring_polygon(Strategy const& strategy) 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); + 10, 100, strategy); 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); + 0, 0, strategy); 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); + 0, 0, strategy); tester::apply("multilinestring((-100 -100,-90 -90),(1 20))", "polygon((-10 -10,10 -10,10 10,-10 10,-10 -10))", - 10, 100, strategy, true); + 10, 100, strategy); tester::apply("multilinestring((-100 -100,-90 -90),(-1 20,1 20,1 30))", "polygon((-110 -110))", - sqrt(200.0), 200, strategy, true); + sqrt(200.0), 200, strategy); } //=========================================================================== @@ -213,22 +213,22 @@ void test_distance_linestring_multipolygon(Strategy const& strategy) 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); + 2, 4, strategy); 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); + 2, 4, strategy); 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); + 0, 0, strategy); 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); + 0, 0, strategy); } //=========================================================================== @@ -247,11 +247,11 @@ void test_distance_linestring_open_multipolygon(Strategy const& strategy) tester::apply("linestring(-5 1,-2 1)", "multipolygon(((0 0,10 0,10 10,0 10)))", - 2, 4, strategy, true); + 2, 4, strategy); tester::apply("linestring(-5 1,-3 1)", "multipolygon(((20 20,21 20,21 21,20 21)),((0 0,10 0,10 10,0 10)))", - 3, 9, strategy, true); + 3, 9, strategy); } //=========================================================================== @@ -271,12 +271,12 @@ void test_distance_multilinestring_multipolygon(Strategy const& strategy) 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); + 0.1, 0.01, strategy); 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); + 0, 0, strategy); } //=========================================================================== @@ -320,15 +320,15 @@ void test_distance_linestring_ring(Strategy const& strategy) tester::apply("linestring(-1 20,1 20,1 30)", "polygon((-10 -10,10 -10,10 10,-10 10,-10 -10))", - 10, 100, strategy, true); + 10, 100, strategy); tester::apply("linestring(-1 20,1 20,1 5)", "polygon((-10 -10,10 -10,10 10,-10 10,-10 -10))", - 0, 0, strategy, true); + 0, 0, strategy); tester::apply("linestring(-1 20,1 20,1 -20)", "polygon((-10 -10,10 -10,10 10,-10 10,-10 -10))", - 0, 0, strategy, true); + 0, 0, strategy); } //=========================================================================== @@ -347,15 +347,15 @@ void test_distance_multilinestring_ring(Strategy const& strategy) 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); + 10, 100, strategy); 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); + 0, 0, strategy); 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); + 0, 0, strategy); } //=========================================================================== diff --git a/test/algorithms/distance/distance_linear_linear.cpp b/test/algorithms/distance/distance_linear_linear.cpp index 5c5654511..efd1ceab9 100644 --- a/test/algorithms/distance/distance_linear_linear.cpp +++ b/test/algorithms/distance/distance_linear_linear.cpp @@ -1,7 +1,7 @@ // Boost.Geometry (aka GGL, Generic Geometry Library) // Unit Test -// Copyright (c) 2014, Oracle and/or its affiliates. +// Copyright (c) 2014-2015, Oracle and/or its affiliates. // Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle @@ -194,11 +194,11 @@ void test_distance_linestring_multilinestring(Strategy const& strategy) 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); + 0, 0, strategy); 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); + sqrt(0.005), 0.005, strategy); tester::apply("linestring(1 1,2 2)", "multilinestring((2.5 0,4 0,5 0),(3 3,3 3))", diff --git a/test/algorithms/distance/distance_pointlike_areal.cpp b/test/algorithms/distance/distance_pointlike_areal.cpp index 9eb943f1c..fd5c6c852 100644 --- a/test/algorithms/distance/distance_pointlike_areal.cpp +++ b/test/algorithms/distance/distance_pointlike_areal.cpp @@ -1,7 +1,7 @@ // Boost.Geometry (aka GGL, Generic Geometry Library) // Unit Test -// Copyright (c) 2014, Oracle and/or its affiliates. +// Copyright (c) 2014-2015, Oracle and/or its affiliates. // Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle diff --git a/test/algorithms/distance/distance_pointlike_linear.cpp b/test/algorithms/distance/distance_pointlike_linear.cpp index df9ea0e79..ad22bf120 100644 --- a/test/algorithms/distance/distance_pointlike_linear.cpp +++ b/test/algorithms/distance/distance_pointlike_linear.cpp @@ -1,7 +1,7 @@ // Boost.Geometry (aka GGL, Generic Geometry Library) // Unit Test -// Copyright (c) 2014, Oracle and/or its affiliates. +// Copyright (c) 2014-2015, Oracle and/or its affiliates. // Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle @@ -49,6 +49,11 @@ void test_distance_point_segment(Strategy const& 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); + + // distance is a NaN + tester::apply("POINT(4.297374e+307 8.433875e+307)", + "SEGMENT(26 87,13 95)", + 0, 0, strategy, false); } //=========================================================================== @@ -70,6 +75,11 @@ void test_distance_point_linestring(Strategy const& strategy) // linestring with a single point tester::apply("point(0 0)", "linestring(2 0)", 2, 4, strategy); + + // distance is a NaN + tester::apply("POINT(4.297374e+307 8.433875e+307)", + "LINESTRING(26 87,13 95)", + 0, 0, strategy, false); } //=========================================================================== diff --git a/test/algorithms/distance/distance_pointlike_pointlike.cpp b/test/algorithms/distance/distance_pointlike_pointlike.cpp index 4f267504d..265faeb9f 100644 --- a/test/algorithms/distance/distance_pointlike_pointlike.cpp +++ b/test/algorithms/distance/distance_pointlike_pointlike.cpp @@ -1,7 +1,7 @@ // Boost.Geometry (aka GGL, Generic Geometry Library) // Unit Test -// Copyright (c) 2014, Oracle and/or its affiliates. +// Copyright (c) 2014-2015, Oracle and/or its affiliates. // Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle @@ -44,6 +44,11 @@ void test_distance_point_point(Strategy const& strategy) tester::apply("point(1 1)", "point(1 1)", 0, 0, strategy); + + // distance overflows + tester::apply("point(0 0)", + "point(4.297374e+307 8.433875e+307)", + 0, 0, strategy, false); } //=========================================================================== diff --git a/test/algorithms/distance/test_distance_common.hpp b/test/algorithms/distance/test_distance_common.hpp index 62e87e368..11ef52c40 100644 --- a/test/algorithms/distance/test_distance_common.hpp +++ b/test/algorithms/distance/test_distance_common.hpp @@ -1,7 +1,7 @@ // Boost.Geometry (aka GGL, Generic Geometry Library) // Unit Test -// Copyright (c) 2014, Oracle and/or its affiliates. +// Copyright (c) 2014-2015, Oracle and/or its affiliates. // Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle @@ -14,6 +14,7 @@ #include #include +#include #include #include #include @@ -25,15 +26,12 @@ #include #include #include -#include -#include -#include +#include +#include +#include #include -#include - #include -#include #include #include @@ -128,18 +126,34 @@ struct pretty_print_geometry template struct check_equal { - static inline void apply(T const& value1, T const& value2) + static inline void apply(T const& detected, T const& expected, + bool is_finite) { - BOOST_CHECK( value1 == value2 ); + if (is_finite) + { + BOOST_CHECK(detected == expected); + } + else + { + BOOST_CHECK(! boost::math::isfinite(detected)); + } } }; template <> struct check_equal { - static inline void apply(double value1, double value2) + static inline void apply(double detected, double expected, + bool is_finite) { - BOOST_CHECK_CLOSE( value1, value2, 0.0001 ); + if (is_finite) + { + BOOST_CHECK_CLOSE(detected, expected, 0.0001); + } + else + { + BOOST_CHECK(! boost::math::isfinite(detected)); + } } }; @@ -158,8 +172,125 @@ struct test_distance_of_geometries template -struct test_distance_of_geometries +class test_distance_of_geometries { +private: + template + < + typename G1, + typename G2, + typename DistanceType, + typename ComparableDistanceType, + typename Strategy + > + static inline + void base_test(std::string const& header, + G1 const& g1, G2 const& g2, + DistanceType const& expected_distance, + ComparableDistanceType const& expected_comparable_distance, + Strategy const& strategy, + bool is_finite) + { + typedef typename bg::default_distance_result + < + G1, G2 + >::type default_distance_result; + + typedef typename bg::strategy::distance::services::return_type + < + Strategy, G1, G2 + >::type distance_result_from_strategy; + + static const bool same_regular = boost::is_same + < + default_distance_result, + distance_result_from_strategy + >::type::value; + + BOOST_CHECK( same_regular ); + + + typedef typename bg::default_comparable_distance_result + < + G1, G2 + >::type default_comparable_distance_result; + + typedef typename bg::strategy::distance::services::return_type + < + typename bg::strategy::distance::services::comparable_type + < + Strategy + >::type, + G1, + G2 + >::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(g1, g2); + + check_equal + < + default_distance_result + >::apply(dist_def, expected_distance, is_finite); + + + // check distance with passed strategy + distance_result_from_strategy dist = bg::distance(g1, g2, strategy); + + check_equal + < + default_distance_result + >::apply(dist, expected_distance, is_finite); + + + // check comparable distance with default strategy + default_comparable_distance_result cdist_def = + bg::comparable_distance(g1, g2); + + check_equal + < + default_comparable_distance_result + >::apply(cdist_def, expected_comparable_distance, is_finite); + + + // check comparable distance with passed strategy + comparable_distance_result_from_strategy cdist = + bg::comparable_distance(g1, g2, strategy); + + check_equal + < + default_comparable_distance_result + >::apply(cdist, expected_comparable_distance, is_finite); + +#ifdef BOOST_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" << header + << " (def. strategy) = " << dist_def << " ; " + << "distance" << header + <<" (passed strategy) = " << dist << " ; " + << "comp. distance" << header <<" (def. strategy) = " + << cdist_def << " ; " + << "comp. distance" << header <<" (passed strategy) = " + << cdist << std::endl; +#endif + } + +public: template < typename DistanceType, @@ -172,14 +303,14 @@ struct test_distance_of_geometries DistanceType const& expected_distance, ComparableDistanceType const& expected_comparable_distance, Strategy const& strategy, - bool test_reversed = true) + bool is_finite = true) { Geometry1 geometry1 = from_wkt(wkt1); Geometry2 geometry2 = from_wkt(wkt2); apply(geometry1, geometry2, expected_distance, expected_comparable_distance, - strategy, test_reversed); + strategy, is_finite); } @@ -195,7 +326,7 @@ struct test_distance_of_geometries DistanceType const& expected_distance, ComparableDistanceType const& expected_comparable_distance, Strategy const& strategy, - bool test_reversed = true) + bool is_finite = true) { #ifdef BOOST_GEOMETRY_TEST_DEBUG typedef pretty_print_geometry PPG1; @@ -205,155 +336,18 @@ 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; - typedef typename bg::strategy::distance::services::return_type - < - Strategy, Geometry1, Geometry2 - >::type distance_result_from_strategy; + base_test("", geometry1, geometry2, + expected_distance, expected_comparable_distance, + strategy, is_finite); - static const bool same_regular = boost::is_same - < - default_distance_result, - distance_result_from_strategy - >::type::value; - - BOOST_CHECK( same_regular ); - - - 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); + base_test("[reversed args]", geometry2, geometry1, + expected_distance, expected_comparable_distance, + strategy, is_finite); #ifdef BOOST_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) = " - << cdist_def << " ; " - << "comp. distance (passed strategy) = " - << cdist << std::endl; - - if ( !test_reversed ) - { - std::cout << std::endl; - } + std::cout << std::endl; #endif - - if ( test_reversed ) - { - // check distance with default strategy - dist_def = bg::distance(geometry2, geometry1); - - check_equal - < - default_distance_result - >::apply(dist_def, expected_distance); - - - // check distance with given strategy - dist = bg::distance(geometry2, geometry1, strategy); - - check_equal - < - default_distance_result - >::apply(dist, expected_distance); - - - // check comparable distance with default strategy - cdist_def = bg::comparable_distance(geometry2, geometry1); - - 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); - - check_equal - < - default_comparable_distance_result - >::apply(cdist, expected_comparable_distance); - -#ifdef BOOST_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 - } } }; @@ -383,7 +377,8 @@ struct test_distance_of_geometries std::string const& wkt_polygon, DistanceType const& expected_distance, ComparableDistanceType const& expected_comparable_distance, - Strategy const& strategy) + Strategy const& strategy, + bool is_finite = true) { Segment segment = from_wkt(wkt_segment); Polygon polygon = from_wkt(wkt_polygon); @@ -391,7 +386,8 @@ struct test_distance_of_geometries polygon, expected_distance, expected_comparable_distance, - strategy); + strategy, + is_finite); } @@ -406,10 +402,12 @@ struct test_distance_of_geometries Polygon const& polygon, DistanceType const& expected_distance, ComparableDistanceType const& expected_comparable_distance, - Strategy const& strategy) + Strategy const& strategy, + bool is_finite = true) { base::apply(segment, polygon, expected_distance, - expected_comparable_distance, strategy); + expected_comparable_distance, strategy, is_finite); + if ( bg::num_interior_rings(polygon) == 0 ) { #ifdef BOOST_GEOMETRY_TEST_DEBUG std::cout << "... testing also exterior ring ..." << std::endl; @@ -421,7 +419,8 @@ struct test_distance_of_geometries bg::exterior_ring(polygon), expected_distance, expected_comparable_distance, - strategy); + strategy, + is_finite); } } }; @@ -446,7 +445,8 @@ struct test_distance_of_geometries std::string const& wkt_segment, DistanceType const& expected_distance, ComparableDistanceType const& expected_comparable_distance, - Strategy const& strategy) + Strategy const& strategy, + bool is_finite = true) { test_distance_of_geometries < @@ -455,7 +455,8 @@ struct test_distance_of_geometries wkt_box, expected_distance, expected_comparable_distance, - strategy); + strategy, + is_finite); } }; @@ -481,7 +482,8 @@ struct test_distance_of_geometries std::string const& wkt_box, DistanceType const& expected_distance, ComparableDistanceType const& expected_comparable_distance, - Strategy const& strategy) + Strategy const& strategy, + bool is_finite = true) { Segment segment = from_wkt(wkt_segment); Box box = from_wkt(wkt_box); @@ -489,7 +491,8 @@ struct test_distance_of_geometries box, expected_distance, expected_comparable_distance, - strategy); + strategy, + is_finite); } @@ -504,7 +507,8 @@ struct test_distance_of_geometries Box const& box, DistanceType const& expected_distance, ComparableDistanceType const& expected_comparable_distance, - Strategy const& strategy) + Strategy const& strategy, + bool is_finite = true) { typedef typename bg::strategy::distance::services::return_type < @@ -523,7 +527,7 @@ struct test_distance_of_geometries base::apply(segment, box, expected_distance, - expected_comparable_distance, strategy); + expected_comparable_distance, strategy, is_finite); comparable_strategy cstrategy = bg::strategy::distance::services::get_comparable @@ -547,12 +551,14 @@ struct test_distance_of_geometries check_equal < distance_result_type - >::apply(distance_generic, expected_distance); + >::apply(distance_generic, expected_distance, is_finite); check_equal < comparable_distance_result_type - >::apply(comparable_distance_generic, expected_comparable_distance); + >::apply(comparable_distance_generic, + expected_comparable_distance, + is_finite); #ifdef BOOST_GEOMETRY_TEST_DEBUG std::cout << "... testing with naive seg-box distance algorithm..." diff --git a/test/algorithms/distance/test_distance_se_common.hpp b/test/algorithms/distance/test_distance_se_common.hpp index 5e846346d..5d514c826 100644 --- a/test/algorithms/distance/test_distance_se_common.hpp +++ b/test/algorithms/distance/test_distance_se_common.hpp @@ -1,7 +1,7 @@ // Boost.Geometry (aka GGL, Generic Geometry Library) // Unit Test -// Copyright (c) 2014, Oracle and/or its affiliates. +// Copyright (c) 2014-2015, Oracle and/or its affiliates. // Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle @@ -25,15 +25,12 @@ #include #include #include -#include -#include -#include +#include +#include +#include #include -#include - #include -#include #include #include diff --git a/test/algorithms/multi_area.cpp b/test/algorithms/multi_area.cpp index 3dbc658e1..fdb9ea6d7 100644 --- a/test/algorithms/multi_area.cpp +++ b/test/algorithms/multi_area.cpp @@ -1,6 +1,6 @@ // Boost.Geometry (aka GGL, Generic Geometry Library) // -// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands. +// Copyright (c) 2007-2015 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) @@ -8,14 +8,11 @@ #include -#include - #include #include -#include +#include #include -#include diff --git a/test/algorithms/multi_centroid.cpp b/test/algorithms/multi_centroid.cpp index 03cb8ecde..c98b3f164 100644 --- a/test/algorithms/multi_centroid.cpp +++ b/test/algorithms/multi_centroid.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-2015 Barend Gehrels, Amsterdam, the Netherlands. +// Copyright (c) 2008-2015 Bruno Lalande, Paris, France. +// Copyright (c) 2009-2015 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. @@ -17,18 +17,12 @@ #include -#include -#include -#include +#include +#include #include #include -#include -#include -#include -#include - // #define REPORT_RESULTS diff --git a/test/algorithms/multi_clear.cpp b/test/algorithms/multi_clear.cpp index 39d777930..44f4716e0 100644 --- a/test/algorithms/multi_clear.cpp +++ b/test/algorithms/multi_clear.cpp @@ -1,6 +1,6 @@ // Boost.Geometry (aka GGL, Generic Geometry Library) // -// Copyright (c) 2011-2012 Barend Gehrels, Amsterdam, the Netherlands. +// Copyright (c) 2011-2015 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) @@ -9,17 +9,11 @@ #include #include -#include -#include #include -#include #include #include -#include -#include -#include #include diff --git a/test/algorithms/multi_convert.cpp b/test/algorithms/multi_convert.cpp index 0bfdf6ea6..ad24d3d7a 100644 --- a/test/algorithms/multi_convert.cpp +++ b/test/algorithms/multi_convert.cpp @@ -1,22 +1,12 @@ // Boost.Geometry (aka GGL, Generic Geometry Library) // -// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands. +// Copyright (c) 2007-2015 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 - template void test_mixed_point_types() diff --git a/test/algorithms/multi_convex_hull.cpp b/test/algorithms/multi_convex_hull.cpp index ef493e8f5..eaf0ddc8d 100644 --- a/test/algorithms/multi_convex_hull.cpp +++ b/test/algorithms/multi_convex_hull.cpp @@ -1,12 +1,12 @@ // 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-2015 Barend Gehrels, Amsterdam, the Netherlands. +// Copyright (c) 2008-2015 Bruno Lalande, Paris, France. +// Copyright (c) 2009-2015 Mateusz Loskot, London, UK. -// This file was modified by Oracle on 2014. -// Modifications copyright (c) 2014 Oracle and/or its affiliates. +// This file was modified by Oracle on 2014, 2015. +// Modifications copyright (c) 2014-2015 Oracle and/or its affiliates. // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle @@ -26,22 +26,16 @@ #include #include -#include +#include +#include -#include -#include +#include -#include +#include -#include -#include - -#include -#include - -#include -#include -#include +#include +#include +#include diff --git a/test/algorithms/multi_correct.cpp b/test/algorithms/multi_correct.cpp index 7359d3f76..be61640cd 100644 --- a/test/algorithms/multi_correct.cpp +++ b/test/algorithms/multi_correct.cpp @@ -1,6 +1,6 @@ // Boost.Geometry (aka GGL, Generic Geometry Library) // -// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands. +// Copyright (c) 2007-2015 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) @@ -11,10 +11,7 @@ #include -#include - #include -#include #include #include @@ -22,7 +19,7 @@ #include #include #include -#include +#include template diff --git a/test/algorithms/multi_envelope.cpp b/test/algorithms/multi_envelope.cpp index bafa5dc25..5ebbc6eee 100644 --- a/test/algorithms/multi_envelope.cpp +++ b/test/algorithms/multi_envelope.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-2015 Barend Gehrels, Amsterdam, the Netherlands. +// Copyright (c) 2008-2015 Bruno Lalande, Paris, France. +// Copyright (c) 2009-2015 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. @@ -15,14 +15,6 @@ #include - -#include -#include -#include -#include - -#include - #include #include #include diff --git a/test/algorithms/multi_for_each.cpp b/test/algorithms/multi_for_each.cpp index 70165a44f..e9c02b685 100644 --- a/test/algorithms/multi_for_each.cpp +++ b/test/algorithms/multi_for_each.cpp @@ -1,6 +1,6 @@ // Boost.Geometry (aka GGL, Generic Geometry Library) // -// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands. +// Copyright (c) 2007-2015 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) @@ -8,10 +8,8 @@ #include #include -#include #include -#include #include #include @@ -20,9 +18,9 @@ #include #include -#include -#include -#include +#include +#include +#include #include diff --git a/test/algorithms/multi_length.cpp b/test/algorithms/multi_length.cpp index 5d94be158..3738665f1 100644 --- a/test/algorithms/multi_length.cpp +++ b/test/algorithms/multi_length.cpp @@ -1,6 +1,6 @@ // Boost.Geometry (aka GGL, Generic Geometry Library) // -// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands. +// Copyright (c) 2007-2015 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) @@ -8,15 +8,8 @@ #include -#include - #include #include -#include - -#include -#include - template diff --git a/test/algorithms/multi_num_geometries.cpp b/test/algorithms/multi_num_geometries.cpp index bf7a3cee4..292e06ea9 100644 --- a/test/algorithms/multi_num_geometries.cpp +++ b/test/algorithms/multi_num_geometries.cpp @@ -1,6 +1,6 @@ // Boost.Geometry (aka GGL, Generic Geometry Library) // -// Copyright (c) 2011-2012 Barend Gehrels, Amsterdam, the Netherlands. +// Copyright (c) 2011-2015 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) @@ -8,16 +8,11 @@ #include #include -#include #include -#include #include #include -#include -#include -#include template void test_geometry(std::string const& wkt, int expected) diff --git a/test/algorithms/multi_num_interior_rings.cpp b/test/algorithms/multi_num_interior_rings.cpp index 73fcdc114..2f9991fe9 100644 --- a/test/algorithms/multi_num_interior_rings.cpp +++ b/test/algorithms/multi_num_interior_rings.cpp @@ -1,6 +1,6 @@ // Boost.Geometry (aka GGL, Generic Geometry Library) // -// Copyright (c) 2011-2012 Barend Gehrels, Amsterdam, the Netherlands. +// Copyright (c) 2011-2015 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) @@ -8,16 +8,11 @@ #include #include -#include #include -#include #include #include -#include -#include -#include template void test_geometry(std::string const& wkt, int expected) diff --git a/test/algorithms/multi_num_points.cpp b/test/algorithms/multi_num_points.cpp index d43b71d47..68b814e32 100644 --- a/test/algorithms/multi_num_points.cpp +++ b/test/algorithms/multi_num_points.cpp @@ -1,6 +1,6 @@ // Boost.Geometry (aka GGL, Generic Geometry Library) // -// Copyright (c) 2011-2012 Barend Gehrels, Amsterdam, the Netherlands. +// Copyright (c) 2011-2015 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) @@ -8,16 +8,14 @@ #include #include -#include #include -#include #include #include -#include -#include -#include +#include +#include +#include #include diff --git a/test/algorithms/multi_perimeter.cpp b/test/algorithms/multi_perimeter.cpp index 8268fed62..3ddd8395c 100644 --- a/test/algorithms/multi_perimeter.cpp +++ b/test/algorithms/multi_perimeter.cpp @@ -1,6 +1,6 @@ // Boost.Geometry (aka GGL, Generic Geometry Library) // -// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands. +// Copyright (c) 2007-2015 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) @@ -8,14 +8,12 @@ #include #include -#include #include -#include #include #include -#include +#include #include diff --git a/test/algorithms/multi_reverse.cpp b/test/algorithms/multi_reverse.cpp index 78334928d..f3a7f574d 100644 --- a/test/algorithms/multi_reverse.cpp +++ b/test/algorithms/multi_reverse.cpp @@ -1,6 +1,6 @@ // Boost.Geometry (aka GGL, Generic Geometry Library) // -// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands. +// Copyright (c) 2007-2015 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) @@ -8,18 +8,12 @@ #include #include -#include #include -#include #include #include -#include -#include -#include - #include diff --git a/test/algorithms/multi_simplify.cpp b/test/algorithms/multi_simplify.cpp index 8b9d92265..f142f91d8 100644 --- a/test/algorithms/multi_simplify.cpp +++ b/test/algorithms/multi_simplify.cpp @@ -1,17 +1,12 @@ // Boost.Geometry (aka GGL, Generic Geometry Library) // -// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands. +// Copyright (c) 2007-2015 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 @@ -20,9 +15,9 @@ #include -#include -#include -#include +#include +#include +#include #include diff --git a/test/algorithms/multi_transform.cpp b/test/algorithms/multi_transform.cpp index 9c0002583..66cb8ba6e 100644 --- a/test/algorithms/multi_transform.cpp +++ b/test/algorithms/multi_transform.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-2015 Barend Gehrels, Amsterdam, the Netherlands. +// Copyright (c) 2008-2015 Bruno Lalande, Paris, France. +// Copyright (c) 2009-2015 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. @@ -22,14 +22,7 @@ #include #include -#include - -#include -#include -#include - #include -#include // This test is a little different from transform.cpp test. diff --git a/test/algorithms/multi_unique.cpp b/test/algorithms/multi_unique.cpp index 397e46265..9061d7ef3 100644 --- a/test/algorithms/multi_unique.cpp +++ b/test/algorithms/multi_unique.cpp @@ -1,6 +1,6 @@ // Boost.Geometry (aka GGL, Generic Geometry Library) // -// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands. +// Copyright (c) 2007-2015 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) @@ -8,18 +8,10 @@ #include #include -#include - -#include -#include #include #include -#include -#include -#include - #include diff --git a/test/algorithms/num_points.cpp b/test/algorithms/num_points.cpp index 1c266d8af..6d24f43f0 100644 --- a/test/algorithms/num_points.cpp +++ b/test/algorithms/num_points.cpp @@ -1,10 +1,10 @@ // 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. +// Copyright (c) 2007-2015 Barend Gehrels, Amsterdam, the Netherlands. +// Copyright (c) 2008-2015 Bruno Lalande, Paris, France. +// Copyright (c) 2009-2015 Mateusz Loskot, London, UK. +// Copyright (c) 2013-2015 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 @@ -15,12 +15,9 @@ #include #include -#include #include -#include #include -#include template struct box_dD diff --git a/test/algorithms/overlay/Jamfile.v2 b/test/algorithms/overlay/Jamfile.v2 index 2d736874b..fc27dbf59 100644 --- a/test/algorithms/overlay/Jamfile.v2 +++ b/test/algorithms/overlay/Jamfile.v2 @@ -16,9 +16,10 @@ test-suite boost-geometry-algorithms-overlay : [ run assemble.cpp ] - [ run ccw_traverse.cpp : : : msvc:/bigobj ] + [ run ccw_traverse.cpp ] [ run get_turn_info.cpp ] [ run get_turns.cpp ] + [ run get_turns_areal_areal.cpp ] [ run get_turns_linear_linear.cpp ] [ run get_turns_linear_areal.cpp ] [ run multi_traverse.cpp : : : BOOST_GEOMETRY_TEST_ONLY_ONE_TYPE BOOST_GEOMETRY_RESCALE_TO_ROBUST ] diff --git a/test/algorithms/overlay/dissolver.cpp b/test/algorithms/overlay/dissolver.cpp index 28bd3e560..c928fa7b3 100644 --- a/test/algorithms/overlay/dissolver.cpp +++ b/test/algorithms/overlay/dissolver.cpp @@ -1,7 +1,7 @@ // Boost.Geometry (aka GGL, Generic Geometry Library) // Unit Test -// Copyright (c) 2010-2012 Barend Gehrels, Amsterdam, the Netherlands. +// Copyright (c) 2010-2015 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 @@ -17,9 +17,8 @@ #include #include -#include -#include -#include +#include +#include #include diff --git a/test/algorithms/overlay/get_turns_areal_areal.cpp b/test/algorithms/overlay/get_turns_areal_areal.cpp new file mode 100644 index 000000000..f84c8d0bf --- /dev/null +++ b/test/algorithms/overlay/get_turns_areal_areal.cpp @@ -0,0 +1,62 @@ +// Boost.Geometry +// Unit Test + +// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands. +// Copyright (c) 2008-2012 Bruno Lalande, Paris, France. +// Copyright (c) 2009-2012 Mateusz Loskot, London, UK. + +// This file was modified by Oracle on 2015. +// Modifications copyright (c) 2015 Oracle and/or its affiliates. + +// Contributed and/or modified by Adam Wulkiewicz, 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 +// http://www.boost.org/LICENSE_1_0.txt) + +#include "test_get_turns.hpp" +#include + +//TEST +//#include + +template +void test_all() +{ + typedef bg::model::point pt; + //typedef bg::model::ring ring; + typedef bg::model::polygon poly; + //typedef bg::model::multi_polygon mpoly; + + // mailing list report 17.03.2015 + // operations ok but wrong IPs for int + // (the coordinates are generates at endpoints only) + { + // cw(duplicated point) + test_geometry("POLYGON((-8042 -1485,-8042 250,-8042 250,15943 254,15943 -1485,-8042 -1485))", + "POLYGON((-7901 -1485,-7901 529,-7901 529, 15802 544, 15802 -1485, -7901 -1485))", + expected_pusher<0>()("iiu")("iui")("mcc")("cui")); + //to_svg("POLYGON((-8042 -1485,-8042 250,15943 254,15943 -1485,-8042 -1485))", + // "POLYGON((-7901 -1485,-7901 529,15802 544, 15802 -1485, -7901 -1485))", + // "poly_poly_1.svg"); + test_geometry("POLYGON((-7901 -1485,-7901 529,-7901 529, 15802 544, 15802 -1485, -7901 -1485))", + "POLYGON((-8042 -1485,-8042 250,-8042 250,15943 254,15943 -1485,-8042 -1485))", + expected_pusher<0>()("iui")("iiu")("mcc")("ciu")); + } +} + +int test_main(int, char* []) +{ + test_all(); + test_all(); + test_all(); + +#if ! defined(_MSC_VER) + test_all(); +#endif + +#if defined(HAVE_TTMATH) + test_all(); +#endif + return 0; +} diff --git a/test/algorithms/overlay/get_turns_linear_linear.cpp b/test/algorithms/overlay/get_turns_linear_linear.cpp index 9278c02fd..cc7003f8e 100644 --- a/test/algorithms/overlay/get_turns_linear_linear.cpp +++ b/test/algorithms/overlay/get_turns_linear_linear.cpp @@ -21,7 +21,7 @@ #include //TEST -#include +//#include template void test_all() @@ -224,7 +224,7 @@ void test_all() test_geometry("LINESTRING(3 -0.6,1 -0.8,0 -0.9)", "LINESTRING(4 2.232432,1 -0.8,9 0)", - expected("tuu++")); + expected("tui=+")("miu+=")); test_geometry("LINESTRING(3 -0.6, 0 -0.9, -1 -1)", "LINESTRING(4 2.232432, 0 -0.9, 9 0)", @@ -267,18 +267,23 @@ void test_all() if ( BOOST_GEOMETRY_CONDITION((boost::is_same::value)) ) { // BUG - the operations are correct but IP coordinates are wrong + // ok now also the 3rd turn is wrong +#ifdef BOOST_GEOMETRY_TEST_ENABLE_FAILING test_geometry("LINESTRING(8 5,5 1,-2 3,1 10)", "LINESTRING(1.9375 1.875, 1.7441860465116283 1.9302325581395348, -0.7692307692307692 2.6483516483516487, -2 3, -1.0071942446043165 5.316546762589928)", - expected("mii++")("ccc==")("tuu++")); + expected("mii++")("ccc==")("ccc==")("mux==")); + // Now tii++ is generated instead of ccc== + test_geometry("LINESTRING(8 5,5 1,-2 3,1 10)", "LINESTRING(1.9375 1.875, 1.7441860465116283 1.9302325581395348, -0.7692307692307692 2.6483516483516487, -2 3, -0.5 6.5)", - expected("mii++")("ccc==")("tii++")("mux==")); + expected("mii++")("ccc==")("ccc==")("mux==")); + // Now tii++ is generated instead of ccc== + +#endif - // FAILING - wrong number of turns test_geometry("LINESTRING(-0.5 7,8 1,0 -0.2)", "LINESTRING(2 8,4 0.4,8 1,0 5)", - //expected("iuu++")("mui=+")("tiu+=")); - expected("")("")); + expected("iuu++")("mui=+")("tiu+=")); // assertion failure in 1.57 // FAILING - no assertion failure but the result is not very good @@ -290,6 +295,63 @@ void test_all() expected("")("")); } + // In 1.57 the results of those combinations was different for MinGW + // (probably also QCC and GCC5.0) and MSVC/GCC. The results was depending + // on the instructions generated by the compiler when calculating the + // determinants. + // See also: https://svn.boost.org/trac/boost/ticket/8379 + // https://github.com/boostorg/geometry/pull/259 + if ( BOOST_GEOMETRY_CONDITION((boost::is_same::value)) ) + { + test_geometry("LINESTRING(0 0, 10 0, 20 1)", + "LINESTRING(12 10, 13 0.3, 14 0.4, 15 0.5)", + expected("mii++")("ccc==")("mux==")); + test_geometry("LINESTRING(0 0, 10 0, 110 1)", + "LINESTRING(12 10, 13 0.03, 14 0.04, 15 0.05)", + expected("mii++")("ccc==")("mux==")); + test_geometry("LINESTRING(0 0, 10 0, 110 1)", + "LINESTRING(102 10, 103 0.93, 104 0.94, 105 0.95)", + expected("mii++")("ccc==")("mux==")); + test_geometry("LINESTRING(100 0, 110 0, 120 1)", + "LINESTRING(112 10, 113 0.3, 114 0.4, 115 0.5)", + expected("mii++")("ccc==")("mux==")); + test_geometry("LINESTRING(0 0, 10 0, 20 1)", + "LINESTRING(15 0.5, 14 0.4, 13 0.3, 12 10)", + expected("miu+=")("mui=+")); + test_geometry("LINESTRING(20 1, 10 0, 0 0)", + "LINESTRING(12 10, 13 0.3, 14 0.4, 15 0.5)", + expected("mui=+")("mix+=")); + test_geometry("LINESTRING(20 1, 10 0, 0 0)", + "LINESTRING(15 0.5, 14 0.4, 13 0.3, 12 10)", + expected("muu==")("ccc==")("mii++")); + + test_geometry("LINESTRING(0 0, 10 0, 20 1)", + "LINESTRING(13 0.3, 14 0.4, 15 0.5)", + expected("mii++")("ccc==")("mux==")); + test_geometry("LINESTRING(0 0, 10 0, 20 1)", + "LINESTRING(15 0.5, 14 0.4, 13 0.3)", + expected("mix+=")("mui=+")); + test_geometry("LINESTRING(20 1, 10 0, 0 0)", + "LINESTRING(13 0.3, 14 0.4, 15 0.5)", + expected("mui=+")("mix+=")); + test_geometry("LINESTRING(20 1, 10 0, 0 0)", + "LINESTRING(15 0.5, 14 0.4, 13 0.3)", + expected("mux==")("ccc==")("mii++")); + + test_geometry("LINESTRING(0 0, 10 0, 20 1)", + "LINESTRING(12 10, 13 0.3, 14 0.4)", + expected("mii++")("mux==")); + test_geometry("LINESTRING(0 0, 10 0, 20 1)", + "LINESTRING(14 0.4, 13 0.3, 12 10)", + expected("miu+=")("mui=+")); + test_geometry("LINESTRING(20 1, 10 0, 0 0)", + "LINESTRING(12 10, 13 0.3, 14 0.4)", + expected("mui=+")("mix+=")); + test_geometry("LINESTRING(20 1, 10 0, 0 0)", + "LINESTRING(14 0.4, 13 0.3, 12 10)", + expected("muu==")("mii++")); + } + // TODO: //test_geometry("LINESTRING(0 0,2 0,1 0)", "LINESTRING(0 1,0 0,2 0)", "1FF00F102"); //test_geometry("LINESTRING(2 0,0 0,1 0)", "LINESTRING(0 1,0 0,2 0)", "1FF00F102"); diff --git a/test/algorithms/overlay/multi_overlay_common.hpp b/test/algorithms/overlay/multi_overlay_common.hpp index 6a49c300d..4b98944da 100644 --- a/test/algorithms/overlay/multi_overlay_common.hpp +++ b/test/algorithms/overlay/multi_overlay_common.hpp @@ -1,8 +1,8 @@ // 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) 2007-2015 Barend Gehrels, Amsterdam, the Netherlands. +// Copyright (c) 2008-2015 Bruno Lalande, Paris, France. // 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) @@ -12,11 +12,11 @@ #define GEOMETRY_TEST_MULTI_OVERLAY_COMMON_HPP -#include -#include +#include +#include -#include -//#include +#include +//#include diff --git a/test/algorithms/overlay/multi_traverse.cpp b/test/algorithms/overlay/multi_traverse.cpp index 7cab06c96..d600ce9cb 100644 --- a/test/algorithms/overlay/multi_traverse.cpp +++ b/test/algorithms/overlay/multi_traverse.cpp @@ -1,7 +1,7 @@ // Boost.Geometry (aka GGL, Generic Geometry Library) // Unit Test -// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands. +// Copyright (c) 2007-2015 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 @@ -15,27 +15,19 @@ #define BOOST_GEOMETRY_TEST_MULTI #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 "multi_overlay_cases.hpp" diff --git a/test/algorithms/overlay/overlay_cases.hpp b/test/algorithms/overlay/overlay_cases.hpp index ced26da52..1a28e0c06 100644 --- a/test/algorithms/overlay/overlay_cases.hpp +++ b/test/algorithms/overlay/overlay_cases.hpp @@ -1,7 +1,13 @@ // Boost.Geometry (aka GGL, Generic Geometry Library) // Unit Test // -// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands. +// Copyright (c) 2007-2015 Barend Gehrels, Amsterdam, the Netherlands. + +// This file was modified by Oracle on 2015. +// Modifications copyright (c) 2015, 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 // http://www.boost.org/LICENSE_1_0.txt) @@ -833,7 +839,29 @@ static std::string ticket_10747_e[2] = "POLYGON((0.00000025165824 0.00000025165824,0.00000041943040 0.00000025165824,0.00000041943040 0.00000041943040,0.00000025165824 0.00000041943040,0.00000025165824 0.00000025165824))" }; +static std::string ticket_10658[2] = + { + "POLYGON((516 1608,1308 1932,2094 2466,2094 32767,516 32767,516 1608))", + "POLYGON((516 2484,1308 3066,2094 3150,2094 32767,516 32767,516 2484))" + }; +static std::string ticket_10835[3] = + { + "MULTILINESTRING((5239 2113,1020 2986))", + "POLYGON((5233 2113,5200 2205,1020 2205,1020 2022,5200 2022))", + "POLYGON((5233 2986,5200 3078,1020 3078,1020 2895,5200 2895))" + }; +static std::string ticket_10868[2] = + { + "POLYGON((42817136 -3774506,43029074 -3929862,31446819 18947953,30772384 19615678,30101303 19612322,30114725 16928001,33520458 6878575,35332375 2413654,35725796 2024148))", + "POLYGON((-33386239 -33721784,33721785 -33386239,33386240 33721785,-33721784 33386240))" + }; + +static std::string ticket_11121[2] = + { + "POLYGON((-8042 -1485,-8042 250,-8042 250,15943 254,15943 -1485,-8042 -1485))", + "POLYGON((-7901 -1485,-7901 529,-7901 529,15802 544,15802 -1485,-7901 -1485))" + }; #endif // BOOST_GEOMETRY_TEST_OVERLAY_CASES_HPP diff --git a/test/algorithms/overlay/test_get_turns.hpp b/test/algorithms/overlay/test_get_turns.hpp index 6aa781910..314c5c8c4 100644 --- a/test/algorithms/overlay/test_get_turns.hpp +++ b/test/algorithms/overlay/test_get_turns.hpp @@ -156,6 +156,10 @@ void check_geometry_range( bool ok = boost::size(expected) == turns.size(); +#ifdef BOOST_GEOMETRY_TEST_DEBUG + std::vector turns_dbg = turns; +#endif + BOOST_CHECK_MESSAGE(ok, "get_turns: " << wkt1 << " and " << wkt2 << " -> Expected turns #: " << boost::size(expected) << " detected turns #: " << turns.size()); @@ -170,11 +174,43 @@ void check_geometry_range( turns.erase(it); else { + ok = false; BOOST_CHECK_MESSAGE(false, "get_turns: " << wkt1 << " and " << wkt2 << " -> Expected turn: " << *sit << " not found"); } } + +#ifdef BOOST_GEOMETRY_TEST_DEBUG + if ( !ok ) + { + std::cout << "Coordinates: " + << typeid(typename bg::coordinate_type::type).name() + << ", " + << typeid(typename bg::coordinate_type::type).name() + << std::endl; + std::cout << "Detected: "; + if ( turns_dbg.empty() ) + { + std::cout << "{empty}"; + } + else + { + for ( typename std::vector::const_iterator it = turns_dbg.begin() ; + it != turns_dbg.end() ; ++it ) + { + if ( it != turns_dbg.begin() ) + std::cout << ", "; + std::cout << bg::method_char(it->method); + std::cout << bg::operation_char(it->operations[0].operation); + std::cout << bg::operation_char(it->operations[1].operation); + std::cout << equal_turn<1>::is_colinear_char(it->operations[0].is_collinear); + std::cout << equal_turn<1>::is_colinear_char(it->operations[1].is_collinear); + } + } + std::cout << std::endl; + } +#endif } template diff --git a/test/algorithms/overlay/traverse.cpp b/test/algorithms/overlay/traverse.cpp index 0ae6bfd0a..4589fdc2e 100644 --- a/test/algorithms/overlay/traverse.cpp +++ b/test/algorithms/overlay/traverse.cpp @@ -1,7 +1,7 @@ // Boost.Geometry (aka GGL, Generic Geometry Library) // Unit Test -// Copyright (c) 2010-2012 Barend Gehrels, Amsterdam, the Netherlands. +// Copyright (c) 2010-2015 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 @@ -57,8 +57,7 @@ #include -#include -#include +#include #if defined(TEST_WITH_SVG) diff --git a/test/algorithms/point_on_surface.cpp b/test/algorithms/point_on_surface.cpp index 00b6f1236..0a89d960d 100644 --- a/test/algorithms/point_on_surface.cpp +++ b/test/algorithms/point_on_surface.cpp @@ -1,13 +1,13 @@ // Boost.Geometry (aka GGL, Generic Geometry Library) // Unit Test -// Copyright (c) 2007-2013 Barend Gehrels, Amsterdam, the Netherlands. -// Copyright (c) 2008-2013 Bruno Lalande, Paris, France. -// Copyright (c) 2009-2013 Mateusz Loskot, London, UK. -// Copyright (c) 2013 Adam Wulkiewicz, Lodz, Poland. +// Copyright (c) 2007-2015 Barend Gehrels, Amsterdam, the Netherlands. +// Copyright (c) 2008-2015 Bruno Lalande, Paris, France. +// Copyright (c) 2009-2015 Mateusz Loskot, London, UK. +// Copyright (c) 2013-2015 Adam Wulkiewicz, Lodz, Poland. -// This file was modified by Oracle on 2014. -// Modifications copyright (c) 2014 Oracle and/or its affiliates. +// This file was modified by Oracle on 2014, 2015. +// Modifications copyright (c) 2014-2015 Oracle and/or its affiliates. // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle @@ -43,11 +43,7 @@ #include #if defined(BOOST_GEOMETRY_UNIT_TEST_MULTI) -# include -# include -# include -# include -# include +# include #endif diff --git a/test/algorithms/relational_operations/Jamfile.v2 b/test/algorithms/relational_operations/Jamfile.v2 index 5b432e2e9..2c0c34c9e 100644 --- a/test/algorithms/relational_operations/Jamfile.v2 +++ b/test/algorithms/relational_operations/Jamfile.v2 @@ -16,16 +16,16 @@ test-suite boost-geometry-algorithms-relational : - [ run covered_by.cpp : : : msvc:/bigobj ] - [ run crosses.cpp : : : msvc:/bigobj ] - [ run equals.cpp : : : msvc:/bigobj ] - [ run intersects.cpp : : : msvc:/bigobj ] - [ run multi_covered_by.cpp : : : msvc:/bigobj ] - [ run multi_equals.cpp : : : msvc:/bigobj ] - [ run multi_intersects.cpp : : : msvc:/bigobj ] - [ run multi_touches.cpp : : : msvc:/bigobj ] - [ run overlaps.cpp : : : msvc:/bigobj ] - [ run touches.cpp : : : msvc:/bigobj ] + [ run covered_by.cpp ] + [ run crosses.cpp ] + [ run equals.cpp ] + [ run intersects.cpp ] + [ run multi_covered_by.cpp ] + [ run multi_equals.cpp ] + [ run multi_intersects.cpp ] + [ run multi_touches.cpp ] + [ run overlaps.cpp ] + [ run touches.cpp ] ; build-project disjoint ; diff --git a/test/algorithms/relational_operations/disjoint/Jamfile.v2 b/test/algorithms/relational_operations/disjoint/Jamfile.v2 index a2423a745..8586e9a2c 100644 --- a/test/algorithms/relational_operations/disjoint/Jamfile.v2 +++ b/test/algorithms/relational_operations/disjoint/Jamfile.v2 @@ -16,7 +16,7 @@ test-suite boost-geometry-algorithms-disjoint : - [ run disjoint.cpp : : : msvc:/bigobj ] - [ run disjoint_coverage.cpp : : : msvc:/bigobj ] - [ run multi_disjoint.cpp : : : msvc:/bigobj ] + [ run disjoint.cpp ] + [ run disjoint_coverage.cpp ] + [ run multi_disjoint.cpp ] ; diff --git a/test/algorithms/relational_operations/disjoint/disjoint_coverage.cpp b/test/algorithms/relational_operations/disjoint/disjoint_coverage.cpp index 4708fd6db..f2d6d3ee0 100644 --- a/test/algorithms/relational_operations/disjoint/disjoint_coverage.cpp +++ b/test/algorithms/relational_operations/disjoint/disjoint_coverage.cpp @@ -1,6 +1,6 @@ // Boost.Geometry (aka GGL, Generic Geometry Library) -// Copyright (c) 2014, Oracle and/or its affiliates. +// Copyright (c) 2014-2015, Oracle and/or its affiliates. // Licensed under the Boost Software License version 1.0. // http://www.boost.org/users/license.html @@ -19,25 +19,13 @@ #include #include -#include #include -#include -#include -#include -#include +#include #include -#include -#include -#include -#include -#include - -#include -#include -#include +#include #include diff --git a/test/algorithms/relational_operations/disjoint/multi_disjoint.cpp b/test/algorithms/relational_operations/disjoint/multi_disjoint.cpp index 330a66e52..8bc8a6b55 100644 --- a/test/algorithms/relational_operations/disjoint/multi_disjoint.cpp +++ b/test/algorithms/relational_operations/disjoint/multi_disjoint.cpp @@ -1,7 +1,7 @@ // Boost.Geometry (aka GGL, Generic Geometry Library) // Unit Test -// Copyright (c) 2012 Barend Gehrels, Amsterdam, the Netherlands. +// Copyright (c) 2012-2015 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 @@ -12,17 +12,6 @@ #include -#include -#include -#include -#include -#include -#include -#include -#include -#include - - #include #include diff --git a/test/algorithms/relational_operations/disjoint/test_disjoint.hpp b/test/algorithms/relational_operations/disjoint/test_disjoint.hpp index 55a22e9bd..9e4902421 100644 --- a/test/algorithms/relational_operations/disjoint/test_disjoint.hpp +++ b/test/algorithms/relational_operations/disjoint/test_disjoint.hpp @@ -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-2015 Barend Gehrels, Amsterdam, the Netherlands. +// Copyright (c) 2008-2015 Bruno Lalande, Paris, France. +// Copyright (c) 2009-2015 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. @@ -22,8 +22,7 @@ #include #include -#include -#include +#include template diff --git a/test/algorithms/relational_operations/equals.cpp b/test/algorithms/relational_operations/equals.cpp index 7bd0772f5..3fc067646 100644 --- a/test/algorithms/relational_operations/equals.cpp +++ b/test/algorithms/relational_operations/equals.cpp @@ -18,15 +18,6 @@ #include #include -#include - -#include -#include -#include -#include -#include -#include -#include namespace bgm = bg::model; diff --git a/test/algorithms/relational_operations/multi_covered_by.cpp b/test/algorithms/relational_operations/multi_covered_by.cpp index 7489435b4..720e72716 100644 --- a/test/algorithms/relational_operations/multi_covered_by.cpp +++ b/test/algorithms/relational_operations/multi_covered_by.cpp @@ -1,6 +1,6 @@ // Boost.Geometry (aka GGL, Generic Geometry Library) // -// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands. +// Copyright (c) 2007-2015 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) @@ -11,16 +11,13 @@ #include #include -#include -#include -#include +#include #include -#include +#include #include -#include #include "test_covered_by.hpp" diff --git a/test/algorithms/relational_operations/multi_equals.cpp b/test/algorithms/relational_operations/multi_equals.cpp index d1239d38f..6984f29e5 100644 --- a/test/algorithms/relational_operations/multi_equals.cpp +++ b/test/algorithms/relational_operations/multi_equals.cpp @@ -1,6 +1,6 @@ // Boost.Geometry (aka GGL, Generic Geometry Library) // -// Copyright (c) 2010-2012 Barend Gehrels, Amsterdam, the Netherlands. +// Copyright (c) 2010-2015 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) @@ -8,15 +8,10 @@ #include "test_equals.hpp" -#include -#include +#include #include #include -#include - -#include - template diff --git a/test/algorithms/relational_operations/multi_intersects.cpp b/test/algorithms/relational_operations/multi_intersects.cpp index 1880064f8..6ed8b358f 100644 --- a/test/algorithms/relational_operations/multi_intersects.cpp +++ b/test/algorithms/relational_operations/multi_intersects.cpp @@ -1,7 +1,7 @@ // Boost.Geometry (aka GGL, Generic Geometry Library) // Unit Test -// Copyright (c) 2012 Barend Gehrels, Amsterdam, the Netherlands. +// Copyright (c) 2012-2015 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 @@ -19,7 +19,6 @@ #include #include -#include template void test_all() diff --git a/test/algorithms/relational_operations/multi_touches.cpp b/test/algorithms/relational_operations/multi_touches.cpp index 86456b04a..65de6b52c 100644 --- a/test/algorithms/relational_operations/multi_touches.cpp +++ b/test/algorithms/relational_operations/multi_touches.cpp @@ -1,6 +1,6 @@ // Boost.Geometry (aka GGL, Generic Geometry Library) // -// Copyright (c) 2010-2012 Barend Gehrels, Amsterdam, the Netherlands. +// Copyright (c) 2010-2015 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) @@ -8,24 +8,9 @@ #include "test_touches.hpp" -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include - -#include - +#include +#include +#include template diff --git a/test/algorithms/relational_operations/relate/Jamfile.v2 b/test/algorithms/relational_operations/relate/Jamfile.v2 index 871b8eb17..7e6bb61c9 100644 --- a/test/algorithms/relational_operations/relate/Jamfile.v2 +++ b/test/algorithms/relational_operations/relate/Jamfile.v2 @@ -16,8 +16,8 @@ test-suite boost-geometry-algorithms-relate : - [ run relate_areal_areal.cpp : : : msvc:/bigobj ] - [ run relate_linear_areal.cpp : : : msvc:/bigobj ] - [ run relate_linear_linear.cpp : : : msvc:/bigobj ] - [ run relate_pointlike_xxx.cpp : : : msvc:/bigobj ] + [ run relate_areal_areal.cpp ] + [ run relate_linear_areal.cpp ] + [ run relate_linear_linear.cpp ] + [ run relate_pointlike_xxx.cpp ] ; diff --git a/test/algorithms/relational_operations/test_covered_by.hpp b/test/algorithms/relational_operations/test_covered_by.hpp index b9d8f5853..5403e8edb 100644 --- a/test/algorithms/relational_operations/test_covered_by.hpp +++ b/test/algorithms/relational_operations/test_covered_by.hpp @@ -1,8 +1,8 @@ // Boost.Geometry (aka GGL, Generic Geometry Library) // Unit Test -// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands. -// Copyright (c) 2013 Adam Wulkiewicz, Lodz, Poland. +// Copyright (c) 2007-2015 Barend Gehrels, Amsterdam, the Netherlands. +// Copyright (c) 2013-2015 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 @@ -22,13 +22,10 @@ #include #include #include +#include #include -#include -#include -#include - template void check_geometry(Geometry1 const& geometry1, Geometry2 const& geometry2, diff --git a/test/algorithms/relational_operations/test_intersects.hpp b/test/algorithms/relational_operations/test_intersects.hpp index 7a8af7161..9c4c7914b 100644 --- a/test/algorithms/relational_operations/test_intersects.hpp +++ b/test/algorithms/relational_operations/test_intersects.hpp @@ -1,8 +1,8 @@ // Boost.Geometry (aka GGL, Generic Geometry Library) // Unit Test -// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands. -// Copyright (c) 2013 Adam Wulkiewicz, Lodz, Poland. +// Copyright (c) 2007-2015 Barend Gehrels, Amsterdam, the Netherlands. +// Copyright (c) 2013-2015 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 @@ -14,27 +14,20 @@ #include + +#include +#include #include +#include #include #include #include #include +#include +#include #include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include - template void test_geometry(std::string const& wkt1, std::string const& wkt2, bool expected) diff --git a/test/algorithms/relational_operations/within/Jamfile.v2 b/test/algorithms/relational_operations/within/Jamfile.v2 index d2a679571..dc33b40cc 100644 --- a/test/algorithms/relational_operations/within/Jamfile.v2 +++ b/test/algorithms/relational_operations/within/Jamfile.v2 @@ -16,10 +16,10 @@ test-suite boost-geometry-algorithms-within : - [ run multi_within.cpp : : : msvc:/bigobj ] - [ run within.cpp : : : msvc:/bigobj ] - [ run within_areal_areal.cpp : : : msvc:/bigobj ] - [ run within_linear_areal.cpp : : : msvc:/bigobj ] - [ run within_linear_linear.cpp : : : msvc:/bigobj ] - [ run within_pointlike_xxx.cpp : : : msvc:/bigobj ] + [ run multi_within.cpp ] + [ run within.cpp ] + [ run within_areal_areal.cpp ] + [ run within_linear_areal.cpp ] + [ run within_linear_linear.cpp ] + [ run within_pointlike_xxx.cpp ] ; diff --git a/test/algorithms/relational_operations/within/multi_within.cpp b/test/algorithms/relational_operations/within/multi_within.cpp index cf5573aa6..b41529cc0 100644 --- a/test/algorithms/relational_operations/within/multi_within.cpp +++ b/test/algorithms/relational_operations/within/multi_within.cpp @@ -1,6 +1,6 @@ // Boost.Geometry (aka GGL, Generic Geometry Library) // -// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands. +// Copyright (c) 2007-2015 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) @@ -8,19 +8,14 @@ #include #include -#include #include #include #include #include - -#include -#include - #include -#include +#include #include "test_within.hpp" diff --git a/test/algorithms/relational_operations/within/test_within.hpp b/test/algorithms/relational_operations/within/test_within.hpp index c82bdaf7e..b92b029dd 100644 --- a/test/algorithms/relational_operations/within/test_within.hpp +++ b/test/algorithms/relational_operations/within/test_within.hpp @@ -1,11 +1,11 @@ // Boost.Geometry (aka GGL, Generic Geometry Library) // Unit Test -// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands. -// Copyright (c) 2013 Adam Wulkiewicz, Lodz, Poland. +// Copyright (c) 2007-2015 Barend Gehrels, Amsterdam, the Netherlands. +// Copyright (c) 2013-2015 Adam Wulkiewicz, Lodz, Poland. -// This file was modified by Oracle on 2014. -// Modifications copyright (c) 2014 Oracle and/or its affiliates. +// This file was modified by Oracle on 2014, 2015. +// Modifications copyright (c) 2014-2015 Oracle and/or its affiliates. // Use, modification and distribution is subject to the Boost Software License, // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at @@ -26,6 +26,7 @@ #include #include #include +#include #include @@ -38,10 +39,6 @@ #include -#include -#include -#include - template void check_geometry(Geometry1 const& geometry1, Geometry2 const& geometry2, diff --git a/test/algorithms/relational_operations/within/within.cpp b/test/algorithms/relational_operations/within/within.cpp index 2300a4ec5..c8999e4db 100644 --- a/test/algorithms/relational_operations/within/within.cpp +++ b/test/algorithms/relational_operations/within/within.cpp @@ -1,10 +1,10 @@ // Boost.Geometry (aka GGL, Generic Geometry Library) -// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands. -// Copyright (c) 2013 Adam Wulkiewicz, Lodz, Poland. +// Copyright (c) 2007-2015 Barend Gehrels, Amsterdam, the Netherlands. +// Copyright (c) 2013-2015 Adam Wulkiewicz, Lodz, Poland. -// This file was modified by Oracle on 2014. -// Modifications copyright (c) 2014 Oracle and/or its affiliates. +// This file was modified by Oracle on 2014, 2015. +// Modifications copyright (c) 2014-2015 Oracle and/or its affiliates. // Use, modification and distribution is subject to the Boost Software License, // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at @@ -17,10 +17,9 @@ #include #include -#include -#include -#include -#include +#include +#include +#include template void test_all() diff --git a/test/algorithms/relational_operations/within/within_areal_areal.cpp b/test/algorithms/relational_operations/within/within_areal_areal.cpp index a2901ba4b..559543945 100644 --- a/test/algorithms/relational_operations/within/within_areal_areal.cpp +++ b/test/algorithms/relational_operations/within/within_areal_areal.cpp @@ -1,7 +1,7 @@ // Boost.Geometry (aka GGL, Generic Geometry Library) -// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands. -// Copyright (c) 2013 Adam Wulkiewicz, Lodz, Poland. +// Copyright (c) 2007-2015 Barend Gehrels, Amsterdam, the Netherlands. +// Copyright (c) 2013-2015 Adam Wulkiewicz, Lodz, Poland. // This file was modified by Oracle on 2014, 2015. // Modifications copyright (c) 2014-2015 Oracle and/or its affiliates. @@ -18,8 +18,7 @@ #include #include -#include -#include +#include template void test_a_a() diff --git a/test/algorithms/relational_operations/within/within_linear_areal.cpp b/test/algorithms/relational_operations/within/within_linear_areal.cpp index 889ff3692..14e541d36 100644 --- a/test/algorithms/relational_operations/within/within_linear_areal.cpp +++ b/test/algorithms/relational_operations/within/within_linear_areal.cpp @@ -1,10 +1,10 @@ // Boost.Geometry (aka GGL, Generic Geometry Library) -// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands. -// Copyright (c) 2013 Adam Wulkiewicz, Lodz, Poland. +// Copyright (c) 2007-2015 Barend Gehrels, Amsterdam, the Netherlands. +// Copyright (c) 2013-2015 Adam Wulkiewicz, Lodz, Poland. -// This file was modified by Oracle on 2014. -// Modifications copyright (c) 2014 Oracle and/or its affiliates. +// This file was modified by Oracle on 2014, 2015. +// Modifications copyright (c) 2014-2015 Oracle and/or its affiliates. // Use, modification and distribution is subject to the Boost Software License, // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at @@ -17,9 +17,8 @@ #include #include -#include -#include -#include +#include +#include template void test_l_a() diff --git a/test/algorithms/relational_operations/within/within_linear_linear.cpp b/test/algorithms/relational_operations/within/within_linear_linear.cpp index 6467e0110..f2e2876bf 100644 --- a/test/algorithms/relational_operations/within/within_linear_linear.cpp +++ b/test/algorithms/relational_operations/within/within_linear_linear.cpp @@ -1,10 +1,10 @@ // Boost.Geometry (aka GGL, Generic Geometry Library) -// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands. -// Copyright (c) 2013 Adam Wulkiewicz, Lodz, Poland. +// Copyright (c) 2007-2015 Barend Gehrels, Amsterdam, the Netherlands. +// Copyright (c) 2013-2015 Adam Wulkiewicz, Lodz, Poland. -// This file was modified by Oracle on 2014. -// Modifications copyright (c) 2014 Oracle and/or its affiliates. +// This file was modified by Oracle on 2014, 2015. +// Modifications copyright (c) 2014-2015 Oracle and/or its affiliates. // Use, modification and distribution is subject to the Boost Software License, // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at @@ -17,8 +17,7 @@ #include #include -#include -#include +#include template void test_l_l() diff --git a/test/algorithms/relational_operations/within/within_pointlike_xxx.cpp b/test/algorithms/relational_operations/within/within_pointlike_xxx.cpp index 5ea4f09f2..ff9e67f12 100644 --- a/test/algorithms/relational_operations/within/within_pointlike_xxx.cpp +++ b/test/algorithms/relational_operations/within/within_pointlike_xxx.cpp @@ -1,10 +1,10 @@ // Boost.Geometry (aka GGL, Generic Geometry Library) -// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands. -// Copyright (c) 2013 Adam Wulkiewicz, Lodz, Poland. +// Copyright (c) 2007-2015 Barend Gehrels, Amsterdam, the Netherlands. +// Copyright (c) 2013-2015 Adam Wulkiewicz, Lodz, Poland. -// This file was modified by Oracle on 2014. -// Modifications copyright (c) 2014 Oracle and/or its affiliates. +// This file was modified by Oracle on 2014, 2015. +// Modifications copyright (c) 2014-2015 Oracle and/or its affiliates. // Use, modification and distribution is subject to the Boost Software License, // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at @@ -17,10 +17,9 @@ #include #include -#include -#include -#include -#include +#include +#include +#include template void test_p_p() diff --git a/test/algorithms/remove_spikes.cpp b/test/algorithms/remove_spikes.cpp index 8f7fd75bb..f4e252103 100644 --- a/test/algorithms/remove_spikes.cpp +++ b/test/algorithms/remove_spikes.cpp @@ -1,10 +1,10 @@ // Boost.Geometry (aka GGL, Generic Geometry Library) // Unit Test -// Copyright (c) 2007-2013 Barend Gehrels, Amsterdam, the Netherlands. -// Copyright (c) 2008-2013 Bruno Lalande, Paris, France. -// Copyright (c) 2009-2013 Mateusz Loskot, London, UK. -// Copyright (c) 2013 Adam Wulkiewicz, Lodz, Poland. +// Copyright (c) 2007-2015 Barend Gehrels, Amsterdam, the Netherlands. +// Copyright (c) 2008-2015 Bruno Lalande, Paris, France. +// Copyright (c) 2009-2015 Mateusz Loskot, London, UK. +// Copyright (c) 2013-2015 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 @@ -36,14 +36,7 @@ #include #if defined(BOOST_GEOMETRY_UNIT_TEST_MULTI) - -# include - -# include -# include -# include -# include -# include +# include #endif diff --git a/test/algorithms/set_operations/difference/Jamfile.v2 b/test/algorithms/set_operations/difference/Jamfile.v2 index bead4559e..7cbcb8ada 100644 --- a/test/algorithms/set_operations/difference/Jamfile.v2 +++ b/test/algorithms/set_operations/difference/Jamfile.v2 @@ -16,10 +16,10 @@ test-suite boost-geometry-algorithms-difference : - [ run difference.cpp : : : BOOST_GEOMETRY_TEST_ONLY_ONE_TYPE msvc:/bigobj ] + [ run difference.cpp : : : BOOST_GEOMETRY_TEST_ONLY_ONE_TYPE ] [ run difference_linear_linear.cpp ] [ run difference_pl_l.cpp ] [ run difference_pl_pl.cpp ] - [ 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_difference.cpp : : : BOOST_GEOMETRY_TEST_ONLY_ONE_TYPE ] + [ run multi_difference_spike.cpp : : : BOOST_GEOMETRY_TEST_ONLY_ONE_TYPE ] ; diff --git a/test/algorithms/set_operations/difference/difference.cpp b/test/algorithms/set_operations/difference/difference.cpp index c1da88ad8..c0fcd57b0 100644 --- a/test/algorithms/set_operations/difference/difference.cpp +++ b/test/algorithms/set_operations/difference/difference.cpp @@ -1,27 +1,30 @@ // Boost.Geometry (aka GGL, Generic Geometry Library) // Unit Test -// Copyright (c) 2010-2012 Barend Gehrels, Amsterdam, the Netherlands. +// Copyright (c) 2010-2015 Barend Gehrels, Amsterdam, the Netherlands. + +// This file was modified by Oracle on 2015. +// Modifications copyright (c) 2015, 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 // http://www.boost.org/LICENSE_1_0.txt) -#include -#include #include +#include +#include +#include // If defined, tests are run without rescaling-to-integer or robustness policy // Test which would fail then are disabled automatically // #define BOOST_GEOMETRY_NO_ROBUSTNESS #include -#include +#include -#include -#include -#include -#include +#include #include @@ -29,7 +32,6 @@ #include #include #include -#include #ifdef HAVE_TTMATH @@ -86,6 +88,88 @@ void test_areal_linear() test_one_lp("case27", "LINESTRING(4 4,4 5,5 5)", poly_9, 1, 3, 2.0); } +template +void test_ticket_10658(std::string const& wkt_out) +{ + typedef bg::model::point point_type; + typedef bg::model::polygon + < + point_type, /*ClockWise*/false, /*Closed*/false + > polygon_type; + typedef bg::model::multi_polygon multipolygon_type; + + polygon_type polygon1; + bg::read_wkt(ticket_10658[0], polygon1); + polygon_type polygon2; + bg::read_wkt(ticket_10658[1], polygon2); + + multipolygon_type multipolygon_out; + bg::sym_difference(polygon1, polygon2, multipolygon_out); + std::stringstream stream; + stream << bg::wkt(multipolygon_out); + + BOOST_CHECK_EQUAL(stream.str(), wkt_out); +} + +template +void test_ticket_10835(std::string const& wkt_out1, std::string const& wkt_out2) +{ + typedef bg::model::point point_type; + typedef bg::model::linestring linestring_type; + typedef bg::model::multi_linestring multilinestring_type; + typedef bg::model::polygon + < + point_type, /*ClockWise*/false, /*Closed*/false + > polygon_type; + + multilinestring_type multilinestring; + bg::read_wkt(ticket_10835[0], multilinestring); + polygon_type polygon1; + bg::read_wkt(ticket_10835[1], polygon1); + polygon_type polygon2; + bg::read_wkt(ticket_10835[2], polygon2); + + multilinestring_type multilinestringOut1; + bg::difference(multilinestring, polygon1, multilinestringOut1); + std::stringstream stream; + stream << bg::wkt(multilinestringOut1); + + BOOST_CHECK_EQUAL(stream.str(), wkt_out1); + + multilinestring_type multilinestringOut2; + bg::difference(multilinestringOut1, polygon2, multilinestringOut2); + stream.str(""); + stream.clear(); + stream << bg::wkt(multilinestringOut2); + + BOOST_CHECK_EQUAL(stream.str(), wkt_out2); +} + +template +void test_ticket_11121() +{ + typedef bg::model::point point_type; + typedef bg::model::polygon + < + point_type, /*ClockWise*/false, /*Closed*/false + > polygon_type; + typedef bg::model::multi_polygon multipolygon_type; + + polygon_type polygon1; + bg::read_wkt(ticket_11121[0], polygon1); + polygon_type polygon2; + bg::read_wkt(ticket_11121[1], polygon2); + + multipolygon_type diff12, diff21, sym_diff; + bg::difference(polygon1, polygon2, diff12); + bg::difference(polygon2, polygon1, diff21); + bg::sym_difference(polygon1, polygon2, sym_diff); + + BOOST_CHECK(bg::is_valid(diff12)); + BOOST_CHECK(bg::is_valid(diff21)); + BOOST_CHECK(bg::is_valid(sym_diff)); +} + template void test_all() { @@ -553,7 +637,17 @@ void test_specific() test_one("ggl_list_20120717_volker", ggl_list_20120717_volker[0], ggl_list_20120717_volker[1], 1, 11, 3371540, - 0, 0, 0, 0.001); // output is discarded + 1, 4, 384, 0.001); + + test_one("ticket_10658", + ticket_10658[0], ticket_10658[1], + 1, 6, 1510434, + 0, 0, 0); + + test_one("ticket_11121", + ticket_11121[0], ticket_11121[1], + 2, 8, 489763.5, + 1, 4, 6743503.5); } @@ -566,6 +660,22 @@ int test_main(int, char* []) test_specific, false, false>(); + test_ticket_10658 + ("MULTIPOLYGON(((516 2484,516 1608,1308 1932,2094 2466,2094 3150,1308 3066,516 2484)))"); + + test_ticket_10658 + ("MULTIPOLYGON(((516 2484,516 1608,1308 1932,2094 2466,2094 3150,1308 3066,516 2484)))"); + + test_ticket_10835 + ("MULTILINESTRING((5239 2113,5233 2114),(4795 2205,1020 2986))", + "MULTILINESTRING((5239 2113,5233 2114),(4795 2205,1460 2895))"); + + test_ticket_10835 + ("MULTILINESTRING((5239 2113,5232.52 2114.34),(4794.39 2205,1020 2986))", + "MULTILINESTRING((5239 2113,5232.52 2114.34),(4794.39 2205,1459.78 2895))"); + + test_ticket_11121(); + #if ! defined(BOOST_GEOMETRY_TEST_ONLY_ONE_TYPE) test_all >(); diff --git a/test/algorithms/set_operations/difference/difference_linear_linear.cpp b/test/algorithms/set_operations/difference/difference_linear_linear.cpp index b1ae1a21b..91f54b945 100644 --- a/test/algorithms/set_operations/difference/difference_linear_linear.cpp +++ b/test/algorithms/set_operations/difference/difference_linear_linear.cpp @@ -23,7 +23,7 @@ #include "test_difference_linear_linear.hpp" #include -#include +#include #include typedef bg::model::point point_type; @@ -548,7 +548,6 @@ BOOST_AUTO_TEST_CASE( test_difference_linestring_linestring ) "lldf31s" ); -#ifdef GEOMETRY_TEST_INCLUDE_FAILING_TESTS tester::apply (from_wkt("LINESTRING(8 1, 4 .4,2 8)"), from_wkt("LINESTRING(0 -.2, 8 1)"), @@ -586,9 +585,7 @@ BOOST_AUTO_TEST_CASE( test_difference_linestring_linestring ) "lldf31y+", 1e-10 ); -#endif -#ifdef GEOMETRY_TEST_INCLUDE_FAILING_TESTS tester::apply (from_wkt("LINESTRING(10.0002 2,9 -1032.34324, .3 8, 0 5, 8 1, 4 .4, 2 8)"), from_wkt("LINESTRING(0 -.2, 8 1, -.5 7, 6 +.2)"), @@ -611,7 +608,6 @@ BOOST_AUTO_TEST_CASE( test_difference_linestring_linestring ) from_wkt("MULTILINESTRING((0 0,4 .5),(8 1,-.5 7))"), "lldf32" ); -#endif } @@ -1157,7 +1153,6 @@ BOOST_AUTO_TEST_CASE( test_difference_multilinestring_multilinestring ) "mlmldf19" ); -#ifdef GEOMETRY_TEST_INCLUDE_FAILING_TESTS tester::apply (from_wkt("MULTILINESTRING((1 5, -4.3 -.1), (0 6, 8.6 6, 189.7654 5, 1 3, 6 3, 3 5, 6 2.232432, 0 4), (-6 5, 1 2.232432), (3 -1032.34324, 9 0, 189.7654 1, -1.4 3, 3 189.7654, +.3 10.0002, 1 5, 6 3, 5 1, 9 1, 10.0002 -1032.34324, -0.7654 0, 5 3, 3 4), (2.232432 2.232432, 8.6 +.4, 0.0 2.232432, 4 0, -8.8 10.0002), (1 0, 6 6, 7 2, -0 8.4), (-0.7654 3, +.6 8, 4 -1032.34324, 1 6, 0 4), (0 7, 2 1, 8 -7, 7 -.7, -1032.34324 9), (5 0, 10.0002 4, 8 7, 3 3, -8.1 5))"), from_wkt("MULTILINESTRING((5 10.0002, 2 7, -0.7654 0, 5 3), (0 -0.7654, 4 10.0002, 4 +.1, -.8 3, -.1 8, 10.0002 2, +.9 -1032.34324))"), @@ -1189,7 +1184,6 @@ BOOST_AUTO_TEST_CASE( test_difference_multilinestring_multilinestring ) "mlmldf25-r", 1e-10 ); -#endif } diff --git a/test/algorithms/set_operations/difference/difference_pl_pl.cpp b/test/algorithms/set_operations/difference/difference_pl_pl.cpp index 14a80f485..eaf58b216 100644 --- a/test/algorithms/set_operations/difference/difference_pl_pl.cpp +++ b/test/algorithms/set_operations/difference/difference_pl_pl.cpp @@ -1,6 +1,6 @@ // Boost.Geometry (aka GGL, Generic Geometry Library) -// Copyright (c) 2014, Oracle and/or its affiliates. +// Copyright (c) 2014-2015, Oracle and/or its affiliates. // Licensed under the Boost Software License version 1.0. // http://www.boost.org/users/license.html @@ -20,9 +20,9 @@ #include -#include "../test_set_ops_pl_pl.hpp" +#include "../test_set_ops_pointlike.hpp" -#include +#include typedef bg::model::point point_type; typedef bg::model::multi_point multi_point_type; @@ -51,17 +51,19 @@ BOOST_AUTO_TEST_CASE( test_difference_point_point ) > tester; tester::apply - (from_wkt

("POINT(0 0)"), + ("ppdf01", + from_wkt

("POINT(0 0)"), from_wkt

("POINT(1 1)"), from_wkt("MULTIPOINT(0 0)"), - from_wkt("MULTIPOINT(1 1)"), - "ppdf01"); + from_wkt("MULTIPOINT(1 1)") + ); tester::apply - (from_wkt

("POINT(0 0)"), + ("ppdf02", from_wkt

("POINT(0 0)"), - from_wkt("MULTIPOINT()"), - "ppdf02"); + from_wkt

("POINT(0 0)"), + from_wkt("MULTIPOINT()") + ); } @@ -82,58 +84,66 @@ BOOST_AUTO_TEST_CASE( test_difference_multipoint_point ) > tester; tester::apply - (from_wkt("MULTIPOINT(0 0)"), + ("mppdf01", + from_wkt("MULTIPOINT(0 0)"), from_wkt

("POINT(1 1)"), from_wkt("MULTIPOINT(0 0)"), - from_wkt("MULTIPOINT(1 1)"), - "mppdf01"); + from_wkt("MULTIPOINT(1 1)") + ); tester::apply - (from_wkt("MULTIPOINT(0 0)"), + ("mppdf02", + from_wkt("MULTIPOINT(0 0)"), from_wkt

("POINT(0 0)"), - from_wkt("MULTIPOINT()"), - "mppdf02"); + from_wkt("MULTIPOINT()") + ); tester::apply - (from_wkt("MULTIPOINT(0 0,0 0)"), + ("mppdf03", + from_wkt("MULTIPOINT(0 0,0 0)"), from_wkt

("POINT(1 1)"), from_wkt("MULTIPOINT(0 0,0 0)"), - from_wkt("MULTIPOINT(1 1)"), - "mppdf03"); + from_wkt("MULTIPOINT(1 1)") + ); tester::apply - (from_wkt("MULTIPOINT(0 0,0 0)"), + ("mppdf04", + from_wkt("MULTIPOINT(0 0,0 0)"), from_wkt

("POINT(0 0)"), - from_wkt("MULTIPOINT()"), - "mppdf04"); + from_wkt("MULTIPOINT()") + ); tester::apply - (from_wkt("MULTIPOINT(0 0,0 0,1 0)"), + ("mppdf05", + from_wkt("MULTIPOINT(0 0,0 0,1 0)"), from_wkt

("POINT(1 1)"), from_wkt("MULTIPOINT(0 0,0 0,1 0)"), - from_wkt("MULTIPOINT(1 1)"), - "mppdf05"); + from_wkt("MULTIPOINT(1 1)") + ); tester::apply - (from_wkt("MULTIPOINT(0 0,0 0,1 0)"), + ("mppdf06", + from_wkt("MULTIPOINT(0 0,0 0,1 0)"), from_wkt

("POINT(1 0)"), from_wkt("MULTIPOINT(0 0,0 0)"), - from_wkt("MULTIPOINT()"), - "mppdf06"); + from_wkt("MULTIPOINT()") + ); tester::apply - (from_wkt("MULTIPOINT(0 0,0 0,1 0)"), + ("mppdf07", + from_wkt("MULTIPOINT(0 0,0 0,1 0)"), from_wkt

("POINT(0 0)"), from_wkt("MULTIPOINT(1 0)"), - from_wkt("MULTIPOINT()"), - "mppdf07"); + from_wkt("MULTIPOINT()") + ); tester::apply - (from_wkt("MULTIPOINT()"), + ("mppdf08", + from_wkt("MULTIPOINT()"), from_wkt

("POINT(0 0)"), from_wkt("MULTIPOINT()"), - from_wkt("MULTIPOINT(0 0)"), - "mppdf08"); + from_wkt("MULTIPOINT(0 0)") + ); } @@ -154,25 +164,28 @@ BOOST_AUTO_TEST_CASE( test_difference_point_multipoint ) > tester; tester::apply - (from_wkt

("POINT(0 0)"), + ("pmpdf01", + from_wkt

("POINT(0 0)"), from_wkt("MULTIPOINT(1 0,1 1,1 1)"), from_wkt("MULTIPOINT(0 0)"), - from_wkt("MULTIPOINT(1 0,1 1,1 1)"), - "pmpdf01"); + from_wkt("MULTIPOINT(1 0,1 1,1 1)") + ); tester::apply - (from_wkt

("POINT(0 0)"), + ("pmpdf02", + from_wkt

("POINT(0 0)"), from_wkt("MULTIPOINT(1 0,0 0,1 1,0 0)"), from_wkt("MULTIPOINT()"), - from_wkt("MULTIPOINT(1 0,1 1)"), - "pmpdf02"); + from_wkt("MULTIPOINT(1 0,1 1)") + ); tester::apply - (from_wkt

("POINT(0 0)"), + ("pmpdf03", + from_wkt

("POINT(0 0)"), from_wkt("MULTIPOINT()"), from_wkt("MULTIPOINT(0 0)"), - from_wkt("MULTIPOINT()"), - "pmpdf03"); + from_wkt("MULTIPOINT()") + ); } @@ -192,35 +205,40 @@ BOOST_AUTO_TEST_CASE( test_difference_multipoint_multipoint ) > tester; tester::apply - (from_wkt("MULTIPOINT(2 2,3 3,0 0,0 0,2 2,1 1,1 1,1 0,1 0)"), + ("mpmpdf01", + from_wkt("MULTIPOINT(2 2,3 3,0 0,0 0,2 2,1 1,1 1,1 0,1 0)"), from_wkt("MULTIPOINT(1 0,1 1,1 1,4 4)"), from_wkt("MULTIPOINT(2 2,3 3,0 0,0 0,2 2)"), - from_wkt("MULTIPOINT(4 4)"), - "mpmpdf01"); + from_wkt("MULTIPOINT(4 4)") + ); tester::apply - (from_wkt("MULTIPOINT(0 0,1 1,1 0,1 1)"), + ("mpmpdf02", + from_wkt("MULTIPOINT(0 0,1 1,1 0,1 1)"), from_wkt("MULTIPOINT(1 0,0 0,1 1,0 0)"), - from_wkt("MULTIPOINT()"), - "mpmpdf02"); + from_wkt("MULTIPOINT()") + ); tester::apply - (from_wkt("MULTIPOINT()"), - from_wkt("MULTIPOINT(1 0,0 0,1 1,0 0)"), + ("mpmpdf03", from_wkt("MULTIPOINT()"), from_wkt("MULTIPOINT(1 0,0 0,1 1,0 0)"), - "mpmpdf03"); + from_wkt("MULTIPOINT()"), + from_wkt("MULTIPOINT(1 0,0 0,1 1,0 0)") + ); tester::apply - (from_wkt("MULTIPOINT(0 0,1 1,1 0,1 1)"), - from_wkt("MULTIPOINT()"), + ("mpmpdf04", from_wkt("MULTIPOINT(0 0,1 1,1 0,1 1)"), from_wkt("MULTIPOINT()"), - "mpmpdf04"); + from_wkt("MULTIPOINT(0 0,1 1,1 0,1 1)"), + from_wkt("MULTIPOINT()") + ); tester::apply - (from_wkt("MULTIPOINT()"), + ("mpmpdf05", from_wkt("MULTIPOINT()"), from_wkt("MULTIPOINT()"), - "mpmpdf05"); + from_wkt("MULTIPOINT()") + ); } diff --git a/test/algorithms/set_operations/difference/multi_difference.cpp b/test/algorithms/set_operations/difference/multi_difference.cpp index f9e0c3d4d..3d088aae6 100644 --- a/test/algorithms/set_operations/difference/multi_difference.cpp +++ b/test/algorithms/set_operations/difference/multi_difference.cpp @@ -1,7 +1,7 @@ // Boost.Geometry (aka GGL, Generic Geometry Library) // Unit Test -// Copyright (c) 2010-2012 Barend Gehrels, Amsterdam, the Netherlands. +// Copyright (c) 2010-2015 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 @@ -27,16 +27,16 @@ #include #include -#include -#include -#include // only for testing #77 +#include +#include +#include // only for testing #77 #include -#include -#include -#include +#include +#include +#include -#include +#include template void test_areal() diff --git a/test/algorithms/set_operations/difference/multi_difference_spike.cpp b/test/algorithms/set_operations/difference/multi_difference_spike.cpp index 56a909262..f1141ca6c 100644 --- a/test/algorithms/set_operations/difference/multi_difference_spike.cpp +++ b/test/algorithms/set_operations/difference/multi_difference_spike.cpp @@ -1,7 +1,7 @@ // Boost.Geometry (aka GGL, Generic Geometry Library) // Unit Test -// Copyright (c) 2013 Barend Gehrels, Amsterdam, the Netherlands. +// Copyright (c) 2013-2015 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 @@ -11,7 +11,6 @@ #include #include #include -#include #include "test_difference.hpp" diff --git a/test/algorithms/set_operations/difference/test_difference.hpp b/test/algorithms/set_operations/difference/test_difference.hpp index e3cda5d95..65b97dea0 100644 --- a/test/algorithms/set_operations/difference/test_difference.hpp +++ b/test/algorithms/set_operations/difference/test_difference.hpp @@ -1,7 +1,7 @@ // Boost.Geometry (aka GGL, Generic Geometry Library) // Unit Test -// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands. +// Copyright (c) 2007-2015 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) @@ -30,9 +30,9 @@ #include -#include -#include -#include +#include +#include +#include #include diff --git a/test/algorithms/set_operations/intersection/Jamfile.v2 b/test/algorithms/set_operations/intersection/Jamfile.v2 index e66bfb166..1d174881f 100644 --- a/test/algorithms/set_operations/intersection/Jamfile.v2 +++ b/test/algorithms/set_operations/intersection/Jamfile.v2 @@ -16,9 +16,9 @@ test-suite boost-geometry-algorithms-intersection : - [ run intersection.cpp : : : BOOST_GEOMETRY_TEST_ONLY_ONE_TYPE msvc:/bigobj ] + [ run intersection.cpp : : : BOOST_GEOMETRY_TEST_ONLY_ONE_TYPE ] [ run intersection_linear_linear.cpp ] [ run intersection_pl_l.cpp ] [ run intersection_pl_pl.cpp ] - [ run multi_intersection.cpp : : : BOOST_GEOMETRY_TEST_ONLY_ONE_TYPE msvc:/bigobj ] + [ run multi_intersection.cpp : : : BOOST_GEOMETRY_TEST_ONLY_ONE_TYPE ] ; diff --git a/test/algorithms/set_operations/intersection/intersection.cpp b/test/algorithms/set_operations/intersection/intersection.cpp index b12e7bef7..f89e70fab 100644 --- a/test/algorithms/set_operations/intersection/intersection.cpp +++ b/test/algorithms/set_operations/intersection/intersection.cpp @@ -1,9 +1,14 @@ // 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-2015 Barend Gehrels, Amsterdam, the Netherlands. +// Copyright (c) 2008-2015 Bruno Lalande, Paris, France. +// Copyright (c) 2009-2015 Mateusz Loskot, London, UK. + +// This file was modified by Oracle on 2015. +// Modifications copyright (c) 2015, 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. @@ -12,6 +17,7 @@ // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) +#include #include #include @@ -19,11 +25,13 @@ // Test which would fail then are disabled automatically // #define BOOST_GEOMETRY_NO_ROBUSTNESS +#include #include #include #include +#include #include #include "test_intersection.hpp" @@ -35,6 +43,7 @@ #include #include + BOOST_GEOMETRY_REGISTER_LINESTRING_TEMPLATED(std::vector) @@ -349,6 +358,7 @@ void test_boxes(std::string const& wkt1, std::string const& wkt2, double expecte bg::read_wkt(wkt2, box2); Box box_out; + bg::assign_zero(box_out); bool detected = bg::intersection(box1, box2, box_out); typename bg::default_area_result::type area = bg::area(box_out); @@ -613,6 +623,32 @@ void test_boxes_nd() test_boxes_per_d(p3(0,0,0), p3(5,5,5), p3(3,3,3), p3(6,6,6), true); } +template +void test_ticket_10868(std::string const& wkt_out) +{ + typedef bg::model::point point_type; + typedef bg::model::polygon + < + point_type, /*ClockWise*/false, /*Closed*/false + > polygon_type; + typedef bg::model::multi_polygon multipolygon_type; + + polygon_type polygon1; + bg::read_wkt(ticket_10868[0], polygon1); + polygon_type polygon2; + bg::read_wkt(ticket_10868[1], polygon2); + + multipolygon_type multipolygon_out; + bg::intersection(polygon1, polygon2, multipolygon_out); + std::stringstream stream; + stream << bg::wkt(multipolygon_out); + + BOOST_CHECK_EQUAL(stream.str(), wkt_out); + + test_one("ticket_10868", + ticket_10868[0], ticket_10868[1], + 1, 7, 20266195244586); +} int test_main(int, char* []) { @@ -636,6 +672,23 @@ int test_main(int, char* []) test_boxes_nd(); +#ifdef BOOST_GEOMETRY_TEST_INCLUDE_FAILING_TESTS + // ticket #10868 still fails for 32-bit integers + test_ticket_10868("MULTIPOLYGON(((33520458 6878575,33480192 14931538,31446819 18947953,30772384 19615678,30101303 19612322,30114725 16928001,33520458 6878575)))"); + +#if !defined(BOOST_NO_INT64) || defined(BOOST_HAS_INT64_T) || defined(BOOST_HAS_MS_INT64) + test_ticket_10868("MULTIPOLYGON(((33520458 6878575,33480192 14931538,31446819 18947953,30772384 19615678,30101303 19612322,30114725 16928001,33520458 6878575)))"); +#endif + + if (BOOST_GEOMETRY_CONDITION(sizeof(long) * CHAR_BIT >= 64)) + { + test_ticket_10868("MULTIPOLYGON(((33520458 6878575,33480192 14931538,31446819 18947953,30772384 19615678,30101303 19612322,30114725 16928001,33520458 6878575)))"); + } + +#if defined(BOOST_HAS_LONG_LONG) + test_ticket_10868("MULTIPOLYGON(((33520458 6878575,33480192 14931538,31446819 18947953,30772384 19615678,30101303 19612322,30114725 16928001,33520458 6878575)))"); +#endif +#endif + return 0; } - diff --git a/test/algorithms/set_operations/intersection/intersection_linear_linear.cpp b/test/algorithms/set_operations/intersection/intersection_linear_linear.cpp index 0102edc5c..5224f10f4 100644 --- a/test/algorithms/set_operations/intersection/intersection_linear_linear.cpp +++ b/test/algorithms/set_operations/intersection/intersection_linear_linear.cpp @@ -23,7 +23,7 @@ #include "test_intersection_linear_linear.hpp" #include -#include +#include #include typedef bg::model::point point_type; diff --git a/test/algorithms/set_operations/intersection/intersection_pl_pl.cpp b/test/algorithms/set_operations/intersection/intersection_pl_pl.cpp index 27b592e7a..e564040e4 100644 --- a/test/algorithms/set_operations/intersection/intersection_pl_pl.cpp +++ b/test/algorithms/set_operations/intersection/intersection_pl_pl.cpp @@ -1,6 +1,6 @@ // Boost.Geometry (aka GGL, Generic Geometry Library) -// Copyright (c) 2014, Oracle and/or its affiliates. +// Copyright (c) 2014-2015, Oracle and/or its affiliates. // Licensed under the Boost Software License version 1.0. // http://www.boost.org/users/license.html @@ -20,9 +20,9 @@ #include -#include "../test_set_ops_pl_pl.hpp" +#include "../test_set_ops_pointlike.hpp" -#include +#include typedef bg::model::point point_type; typedef bg::model::multi_point multi_point_type; @@ -51,16 +51,18 @@ BOOST_AUTO_TEST_CASE( test_intersection_point_point ) > tester; tester::apply - (from_wkt

("POINT(0 0)"), + ("ppi01", + from_wkt

("POINT(0 0)"), from_wkt

("POINT(1 1)"), - from_wkt("MULTIPOINT()"), - "ppi01"); + from_wkt("MULTIPOINT()") + ); tester::apply - (from_wkt

("POINT(0 0)"), + ("ppi02", from_wkt

("POINT(0 0)"), - from_wkt("MULTIPOINT(0 0)"), - "ppi02"); + from_wkt

("POINT(0 0)"), + from_wkt("MULTIPOINT(0 0)") + ); } @@ -81,52 +83,60 @@ BOOST_AUTO_TEST_CASE( test_intersection_multipoint_point ) > tester; tester::apply - (from_wkt("MULTIPOINT(0 0)"), - from_wkt

("POINT(1 1)"), - from_wkt("MULTIPOINT()"), - "mppi01"); - - tester::apply - (from_wkt("MULTIPOINT(0 0)"), - from_wkt

("POINT(0 0)"), + ("mppi01", from_wkt("MULTIPOINT(0 0)"), - "mppi02"); - - tester::apply - (from_wkt("MULTIPOINT(0 0,0 0)"), from_wkt

("POINT(1 1)"), - from_wkt("MULTIPOINT()"), - "mppi03"); + from_wkt("MULTIPOINT()") + ); tester::apply - (from_wkt("MULTIPOINT(0 0,0 0)"), - from_wkt

("POINT(0 0)"), + ("mppi02", from_wkt("MULTIPOINT(0 0)"), - "mppi04"); + from_wkt

("POINT(0 0)"), + from_wkt("MULTIPOINT(0 0)") + ); tester::apply - (from_wkt("MULTIPOINT(0 0,0 0,1 0)"), + ("mppi03", + from_wkt("MULTIPOINT(0 0,0 0)"), from_wkt

("POINT(1 1)"), - from_wkt("MULTIPOINT()"), - "mppi05"); + from_wkt("MULTIPOINT()") + ); tester::apply - (from_wkt("MULTIPOINT(0 0,0 0,1 0)"), + ("mppi04", + from_wkt("MULTIPOINT(0 0,0 0)"), + from_wkt

("POINT(0 0)"), + from_wkt("MULTIPOINT(0 0)") + ); + + tester::apply + ("mppi05", + from_wkt("MULTIPOINT(0 0,0 0,1 0)"), + from_wkt

("POINT(1 1)"), + from_wkt("MULTIPOINT()") + ); + + tester::apply + ("mppi06", + from_wkt("MULTIPOINT(0 0,0 0,1 0)"), from_wkt

("POINT(1 0)"), - from_wkt("MULTIPOINT(1 0)"), - "mppi06"); + from_wkt("MULTIPOINT(1 0)") + ); tester::apply - (from_wkt("MULTIPOINT(0 0,0 0,1 0)"), + ("mppi07", + from_wkt("MULTIPOINT(0 0,0 0,1 0)"), from_wkt

("POINT(0 0)"), - from_wkt("MULTIPOINT(0 0)"), - "mppi07"); + from_wkt("MULTIPOINT(0 0)") + ); tester::apply - (from_wkt("MULTIPOINT()"), - from_wkt

("POINT(0 0)"), + ("mppi08", from_wkt("MULTIPOINT()"), - "mppi08"); + from_wkt

("POINT(0 0)"), + from_wkt("MULTIPOINT()") + ); } @@ -146,40 +156,46 @@ BOOST_AUTO_TEST_CASE( test_intersection_multipoint_multipoint ) > tester; tester::apply - (from_wkt("MULTIPOINT(2 2,3 3,0 0,0 0,2 2,1 1,1 1,1 0,1 0)"), + ("mpmpi01", + from_wkt("MULTIPOINT(2 2,3 3,0 0,0 0,2 2,1 1,1 1,1 0,1 0)"), from_wkt("MULTIPOINT(1 0,1 1,1 1,1 1)"), - from_wkt("MULTIPOINT(1 0,1 1,1 1,1 1)"), - "mpmpi01"); + from_wkt("MULTIPOINT(1 0,1 1,1 1,1 1)") + ); tester::apply - (from_wkt("MULTIPOINT(0 0,1 1,1 0,1 1)"), - from_wkt("MULTIPOINT(1 0,0 0,1 1,0 0)"), + ("mpmp02", from_wkt("MULTIPOINT(0 0,1 1,1 0,1 1)"), from_wkt("MULTIPOINT(1 0,0 0,1 1,0 0)"), - "mpmpi02"); + from_wkt("MULTIPOINT(0 0,1 1,1 0,1 1)"), + from_wkt("MULTIPOINT(1 0,0 0,1 1,0 0)") + ); tester::apply - (from_wkt("MULTIPOINT()"), + ("mpmpi03", + from_wkt("MULTIPOINT()"), from_wkt("MULTIPOINT(1 0,0 0,1 1,0 0)"), - from_wkt("MULTIPOINT()"), - "mpmpi03"); + from_wkt("MULTIPOINT()") + ); tester::apply - (from_wkt("MULTIPOINT(0 0,1 1,1 0,1 1)"), + ("mpmpi04", + from_wkt("MULTIPOINT(0 0,1 1,1 0,1 1)"), from_wkt("MULTIPOINT()"), - from_wkt("MULTIPOINT()"), - "mpmpi04"); + from_wkt("MULTIPOINT()") + ); tester::apply - (from_wkt("MULTIPOINT()"), + ("mpmpi05", from_wkt("MULTIPOINT()"), from_wkt("MULTIPOINT()"), - "mpmpi05"); + from_wkt("MULTIPOINT()") + ); tester::apply - (from_wkt("MULTIPOINT(0 0,1 0,2 0,3 0,0 0,1 0,2 0)"), + ("mpmpi06", + from_wkt("MULTIPOINT(0 0,1 0,2 0,3 0,0 0,1 0,2 0)"), from_wkt("MULTIPOINT(0 1,0 2,1 0,0 0,2 0)"), - from_wkt("MULTIPOINT(1 0,0 0,2 0)"), - "mpmpi06"); + from_wkt("MULTIPOINT(1 0,0 0,2 0)") + ); } diff --git a/test/algorithms/set_operations/intersection/multi_intersection.cpp b/test/algorithms/set_operations/intersection/multi_intersection.cpp index 46106022d..2399935cb 100644 --- a/test/algorithms/set_operations/intersection/multi_intersection.cpp +++ b/test/algorithms/set_operations/intersection/multi_intersection.cpp @@ -1,7 +1,7 @@ // Boost.Geometry (aka GGL, Generic Geometry Library) // Unit Test -// Copyright (c) 2010-2012 Barend Gehrels, Amsterdam, the Netherlands. +// Copyright (c) 2010-2015 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 @@ -20,16 +20,16 @@ #include #include -#include -#include -#include // only for testing #77 +#include +#include +#include // only for testing #77 #include -#include -#include -#include +#include +#include +#include -#include +#include template void test_areal() diff --git a/test/algorithms/set_operations/intersection/test_intersection.hpp b/test/algorithms/set_operations/intersection/test_intersection.hpp index 4a7cc645c..140250e13 100644 --- a/test/algorithms/set_operations/intersection/test_intersection.hpp +++ b/test/algorithms/set_operations/intersection/test_intersection.hpp @@ -1,7 +1,7 @@ // Boost.Geometry (aka GGL, Generic Geometry Library) // Unit Test -// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands. +// Copyright (c) 2007-2015 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) diff --git a/test/algorithms/set_operations/intersection/test_intersection_linear_linear.hpp b/test/algorithms/set_operations/intersection/test_intersection_linear_linear.hpp index 8e9254040..07105aa8b 100644 --- a/test/algorithms/set_operations/intersection/test_intersection_linear_linear.hpp +++ b/test/algorithms/set_operations/intersection/test_intersection_linear_linear.hpp @@ -12,7 +12,6 @@ #include -#include #include #include "../test_set_ops_linear_linear.hpp" #include diff --git a/test/algorithms/set_operations/sym_difference/sym_difference_linear_linear.cpp b/test/algorithms/set_operations/sym_difference/sym_difference_linear_linear.cpp index bcd0398ad..5741b1303 100644 --- a/test/algorithms/set_operations/sym_difference/sym_difference_linear_linear.cpp +++ b/test/algorithms/set_operations/sym_difference/sym_difference_linear_linear.cpp @@ -23,7 +23,7 @@ #include "test_sym_difference_linear_linear.hpp" #include -#include +#include #include typedef bg::model::point point_type; diff --git a/test/algorithms/set_operations/test_set_ops_linear_linear.hpp b/test/algorithms/set_operations/test_set_ops_linear_linear.hpp index 884b5028a..b69e78b67 100644 --- a/test/algorithms/set_operations/test_set_ops_linear_linear.hpp +++ b/test/algorithms/set_operations/test_set_ops_linear_linear.hpp @@ -21,7 +21,6 @@ #include #include #include -#include #include "test_get_turns_ll_invariance.hpp" diff --git a/test/algorithms/set_operations/test_set_ops_pl_pl.hpp b/test/algorithms/set_operations/test_set_ops_pointlike.hpp similarity index 58% rename from test/algorithms/set_operations/test_set_ops_pl_pl.hpp rename to test/algorithms/set_operations/test_set_ops_pointlike.hpp index fd825d003..cb14ebe45 100644 --- a/test/algorithms/set_operations/test_set_ops_pl_pl.hpp +++ b/test/algorithms/set_operations/test_set_ops_pointlike.hpp @@ -1,14 +1,14 @@ // Boost.Geometry (aka GGL, Generic Geometry Library) -// Copyright (c) 2014, Oracle and/or its affiliates. +// Copyright (c) 2014-2015, Oracle and/or its affiliates. // Licensed under the Boost Software License version 1.0. // http://www.boost.org/users/license.html // Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle -#ifndef BOOST_GEOMETRY_TEST_SET_OPS_PL_PL_HPP -#define BOOST_GEOMETRY_TEST_SET_OPS_PL_PL_HPP +#ifndef BOOST_GEOMETRY_TEST_SET_OPS_POINTLIKE_HPP +#define BOOST_GEOMETRY_TEST_SET_OPS_POINTLIKE_HPP #include @@ -170,6 +170,54 @@ struct set_op }; +template +< + typename Geometry, + typename Tag = typename bg::tag::type +> struct geometry_info +{}; + +template +struct geometry_info +{ + static std::size_t const topological_dimension = 0; + + static inline char const* name() { return "P"; } +}; + +template +struct geometry_info +{ + static std::size_t const topological_dimension = 0; + + static inline char const* name() { return "MP"; } +}; + +template +struct geometry_info +{ + static std::size_t const topological_dimension = 1; + + static inline char const* name() { return "L"; } +}; + +template +struct geometry_info +{ + static std::size_t const topological_dimension = 1; + + static inline char const* name() { return "ML"; } +}; + +template +struct geometry_info +{ + static std::size_t const topological_dimension = 1; + + static inline char const* name() { return "S"; } +}; + + //================================================================== //================================================================== @@ -188,54 +236,78 @@ template class test_set_op_of_pointlike_geometries { private: - template - static inline void base_test(G1 const& geometry1, - G2 const& geometry2, - MP const& mp_expected, - std::string const& case_id) + template + struct base_test { - MultiPoint mp_output; + template + static inline void apply(std::string const& case_id, + G1 const& geometry1, + G2 const& geometry2, + MP const& mp_expected) + { + MultiPoint mp_output; - set_op::apply(geometry1, geometry2, mp_output); + set_op::apply(geometry1, geometry2, mp_output); - std::string op_name = set_op::name(); + std::string op_name = set_op::name(); - BOOST_CHECK_MESSAGE( equals::apply(mp_expected, mp_output), - op_name << " P/P: " << bg::wkt(geometry1) - << " " << bg::wkt(geometry2) - << " -> Expected: " << bg::wkt(mp_expected) - << " computed: " << bg::wkt(mp_output) ); + BOOST_CHECK_MESSAGE(equals::apply(mp_expected, mp_output), + "case ID: " << case_id << ", " + << op_name << " " + << geometry_info::name() << "/" + << geometry_info::name() << ": " + << bg::wkt(geometry1) + << " " << bg::wkt(geometry2) + << " -> Expected: " << bg::wkt(mp_expected) + << " computed: " << bg::wkt(mp_output) ); - set_operation_output(op_name, case_id, - geometry1, geometry2, mp_output); + set_operation_output(op_name, case_id, + geometry1, geometry2, mp_output); #ifdef BOOST_GEOMETRY_TEST_DEBUG - std::cout << "Geometry #1: " << bg::wkt(geometry1) << std::endl; - std::cout << "Geometry #2: " << bg::wkt(geometry2) << std::endl; - std::cout << "expected " << op_name << " : " - << bg::wkt(mp_expected) << std::endl; - std::cout << op_name << " : " << bg::wkt(mp_output) << std::endl; - std::cout << std::endl; - std::cout << "************************************" << std::endl; - std::cout << std::endl; - std::cout << std::endl; + std::cout << "Geometry #1: " << bg::wkt(geometry1) << std::endl; + std::cout << "Geometry #2: " << bg::wkt(geometry2) << std::endl; + std::cout << "expected " << op_name << " : " + << bg::wkt(mp_expected) << std::endl; + std::cout << op_name << " : " << bg::wkt(mp_output) << std::endl; + std::cout << std::endl; + std::cout << "************************************" << std::endl; + std::cout << std::endl; + std::cout << std::endl; #endif - } + } + }; + template + struct base_test + { + template + static inline void apply(std::string const&, G1 const&, G2 const&, + MP const&) + { + } + }; public: - static inline void apply(Geometry1 const& geometry1, + static inline void apply(std::string const& case_id, + Geometry1 const& geometry1, Geometry2 const& geometry2, MultiPoint const& mp_expected12, - MultiPoint const& mp_expected21, - std::string const& case_id) + MultiPoint const& mp_expected21) { #ifdef BOOST_GEOMETRY_TEST_DEBUG std::cout << "test case: " << case_id << std::endl; #endif - base_test(geometry1, geometry2, mp_expected12, case_id); - base_test(geometry2, geometry1, mp_expected21, case_id); + base_test::apply(case_id, geometry1, geometry2, mp_expected12); + // try the same set operation with the arguments' order + // reversed only if the two geometries are of the same + // topological dimension + base_test + < + (geometry_info::topological_dimension + == geometry_info::topological_dimension) + >::apply(case_id, geometry2, geometry1, mp_expected21); #ifdef BOOST_GEOMETRY_TEST_DEBUG std::cout << std::endl; @@ -243,15 +315,14 @@ public: #endif } - - static inline void apply(Geometry1 const& geometry1, + static inline void apply(std::string const& case_id, + Geometry1 const& geometry1, Geometry2 const& geometry2, - MultiPoint const& mp_expected, - std::string const& case_id) + MultiPoint const& mp_expected) { - apply(geometry1, geometry2, mp_expected, mp_expected, case_id); + apply(case_id, geometry1, geometry2, mp_expected, mp_expected); } }; -#endif // BOOST_GEOMETRY_TEST_SET_OPS_PL_PL_HPP +#endif // BOOST_GEOMETRY_TEST_SET_OPS_POINTLIKE_HPP diff --git a/test/algorithms/set_operations/union/Jamfile.v2 b/test/algorithms/set_operations/union/Jamfile.v2 index d4df3ea5c..1f6b4f17e 100644 --- a/test/algorithms/set_operations/union/Jamfile.v2 +++ b/test/algorithms/set_operations/union/Jamfile.v2 @@ -16,8 +16,8 @@ test-suite boost-geometry-algorithms-union : - [ run multi_union.cpp : : : BOOST_GEOMETRY_TEST_ONLY_ONE_TYPE msvc:/bigobj ] - [ run union.cpp : : : BOOST_GEOMETRY_TEST_ONLY_ONE_TYPE msvc:/bigobj ] + [ run multi_union.cpp : : : BOOST_GEOMETRY_TEST_ONLY_ONE_TYPE ] + [ run union.cpp : : : BOOST_GEOMETRY_TEST_ONLY_ONE_TYPE ] [ run union_linear_linear.cpp ] [ run union_pl_pl.cpp ] ; diff --git a/test/algorithms/set_operations/union/multi_union.cpp b/test/algorithms/set_operations/union/multi_union.cpp index 74c9d060d..ac542220d 100644 --- a/test/algorithms/set_operations/union/multi_union.cpp +++ b/test/algorithms/set_operations/union/multi_union.cpp @@ -1,7 +1,7 @@ // Boost.Geometry (aka GGL, Generic Geometry Library) // Unit Test -// Copyright (c) 2010-2012 Barend Gehrels, Amsterdam, the Netherlands. +// Copyright (c) 2010-2015 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 @@ -18,15 +18,15 @@ #include #include -#include -#include -#include +#include +#include +#include #include -#include -#include +#include +#include -#include +#include template diff --git a/test/algorithms/set_operations/union/union_linear_linear.cpp b/test/algorithms/set_operations/union/union_linear_linear.cpp index 925c8363b..4ef79e6cc 100644 --- a/test/algorithms/set_operations/union/union_linear_linear.cpp +++ b/test/algorithms/set_operations/union/union_linear_linear.cpp @@ -1,6 +1,6 @@ // Boost.Geometry (aka GGL, Generic Geometry Library) -// Copyright (c) 2014, Oracle and/or its affiliates. +// Copyright (c) 2014-2015, Oracle and/or its affiliates. // Licensed under the Boost Software License version 1.0. // http://www.boost.org/users/license.html @@ -23,7 +23,7 @@ #include "test_union_linear_linear.hpp" #include -#include +#include #include typedef bg::model::point point_type; diff --git a/test/algorithms/set_operations/union/union_pl_pl.cpp b/test/algorithms/set_operations/union/union_pl_pl.cpp index 05be9f1f6..030a62784 100644 --- a/test/algorithms/set_operations/union/union_pl_pl.cpp +++ b/test/algorithms/set_operations/union/union_pl_pl.cpp @@ -1,6 +1,6 @@ // Boost.Geometry (aka GGL, Generic Geometry Library) -// Copyright (c) 2014, Oracle and/or its affiliates. +// Copyright (c) 2014-2015, Oracle and/or its affiliates. // Licensed under the Boost Software License version 1.0. // http://www.boost.org/users/license.html @@ -20,9 +20,9 @@ #include -#include "../test_set_ops_pl_pl.hpp" +#include "../test_set_ops_pointlike.hpp" -#include +#include typedef bg::model::point point_type; typedef bg::model::multi_point multi_point_type; @@ -51,16 +51,18 @@ BOOST_AUTO_TEST_CASE( test_union_point_point ) > tester; tester::apply - (from_wkt

("POINT(0 0)"), + ("ppu01", + from_wkt

("POINT(0 0)"), from_wkt

("POINT(1 1)"), - from_wkt("MULTIPOINT(0 0,1 1)"), - "ppu01"); + from_wkt("MULTIPOINT(0 0,1 1)") + ); tester::apply - (from_wkt

("POINT(0 0)"), + ("ppu02", from_wkt

("POINT(0 0)"), - from_wkt("MULTIPOINT(0 0)"), - "ppu02"); + from_wkt

("POINT(0 0)"), + from_wkt("MULTIPOINT(0 0)") + ); } @@ -81,52 +83,60 @@ BOOST_AUTO_TEST_CASE( test_union_multipoint_point ) > tester; tester::apply - (from_wkt("MULTIPOINT(0 0)"), - from_wkt

("POINT(1 1)"), - from_wkt("MULTIPOINT(0 0,1 1)"), - "mppu01"); - - tester::apply - (from_wkt("MULTIPOINT(0 0)"), - from_wkt

("POINT(0 0)"), + ("mppu01", from_wkt("MULTIPOINT(0 0)"), - "mppu02"); - - tester::apply - (from_wkt("MULTIPOINT(0 0,0 0)"), from_wkt

("POINT(1 1)"), - from_wkt("MULTIPOINT(0 0,0 0,1 1)"), - "mppu03"); + from_wkt("MULTIPOINT(0 0,1 1)") + ); tester::apply - (from_wkt("MULTIPOINT(0 0,0 0)"), - from_wkt

("POINT(0 0)"), + ("mppu02", from_wkt("MULTIPOINT(0 0)"), - "mppu04"); + from_wkt

("POINT(0 0)"), + from_wkt("MULTIPOINT(0 0)") + ); tester::apply - (from_wkt("MULTIPOINT(0 0,0 0,1 0)"), + ("mppu03", + from_wkt("MULTIPOINT(0 0,0 0)"), from_wkt

("POINT(1 1)"), - from_wkt("MULTIPOINT(0 0,0 0,1 0,1 1)"), - "mppu05"); + from_wkt("MULTIPOINT(0 0,0 0,1 1)") + ); tester::apply - (from_wkt("MULTIPOINT(0 0,0 0,1 0)"), - from_wkt

("POINT(1 0)"), + ("mppu04", + from_wkt("MULTIPOINT(0 0,0 0)"), + from_wkt

("POINT(0 0)"), + from_wkt("MULTIPOINT(0 0)") + ); + + tester::apply + ("mppu05", from_wkt("MULTIPOINT(0 0,0 0,1 0)"), - "mppu06"); + from_wkt

("POINT(1 1)"), + from_wkt("MULTIPOINT(0 0,0 0,1 0,1 1)") + ); tester::apply - (from_wkt("MULTIPOINT(0 0,0 0,1 0)"), - from_wkt

("POINT(0 0)"), - from_wkt("MULTIPOINT(0 0,1 0)"), - "mppu07"); + ("mppu06", + from_wkt("MULTIPOINT(0 0,0 0,1 0)"), + from_wkt

("POINT(1 0)"), + from_wkt("MULTIPOINT(0 0,0 0,1 0)") + ); tester::apply - (from_wkt("MULTIPOINT()"), + ("mppu07", + from_wkt("MULTIPOINT(0 0,0 0,1 0)"), from_wkt

("POINT(0 0)"), - from_wkt("MULTIPOINT(0 0)"), - "mppu08"); + from_wkt("MULTIPOINT(0 0,1 0)") + ); + + tester::apply + ("mppu08", + from_wkt("MULTIPOINT()"), + from_wkt

("POINT(0 0)"), + from_wkt("MULTIPOINT(0 0)") + ); } @@ -146,42 +156,47 @@ BOOST_AUTO_TEST_CASE( test_union_multipoint_multipoint ) > tester; tester::apply - (from_wkt("MULTIPOINT(2 2,3 3,0 0,0 0,2 2,1 1,1 1,1 0,1 0)"), + ("mpmpu01", + from_wkt("MULTIPOINT(2 2,3 3,0 0,0 0,2 2,1 1,1 1,1 0,1 0)"), from_wkt("MULTIPOINT(1 0,1 1,1 1,1 1)"), from_wkt("MULTIPOINT(2 2,3 3,0 0,0 0,2 2,1 1,1 1,1 0,1 0)"), - from_wkt("MULTIPOINT(1 0,1 1,1 1,1 1,2 2,3 3,0 0,0 0,2 2)"), - "mpmpu01"); + from_wkt("MULTIPOINT(1 0,1 1,1 1,1 1,2 2,3 3,0 0,0 0,2 2)") + ); tester::apply - (from_wkt("MULTIPOINT(0 0,1 1,1 0,1 1)"), - from_wkt("MULTIPOINT(1 0,0 0,1 1,0 0)"), + ("mpmpu02", from_wkt("MULTIPOINT(0 0,1 1,1 0,1 1)"), from_wkt("MULTIPOINT(1 0,0 0,1 1,0 0)"), - "mpmpu02"); - - tester::apply - (from_wkt("MULTIPOINT()"), - from_wkt("MULTIPOINT(1 0,0 0,1 1,0 0)"), - from_wkt("MULTIPOINT(1 0,0 0,1 1,0 0)"), - "mpmpu03"); - - tester::apply - (from_wkt("MULTIPOINT(0 0,1 1,1 0,1 1)"), - from_wkt("MULTIPOINT()"), from_wkt("MULTIPOINT(0 0,1 1,1 0,1 1)"), - "mpmpu04"); + from_wkt("MULTIPOINT(1 0,0 0,1 1,0 0)") + ); tester::apply - (from_wkt("MULTIPOINT()"), + ("mpmpu03", from_wkt("MULTIPOINT()"), - from_wkt("MULTIPOINT()"), - "mpmpu05"); + from_wkt("MULTIPOINT(1 0,0 0,1 1,0 0)"), + from_wkt("MULTIPOINT(1 0,0 0,1 1,0 0)") + ); tester::apply - (from_wkt("MULTIPOINT(0 0,1 0,2 0,3 0,0 0,1 0,2 0)"), + ("mpmpu04", + from_wkt("MULTIPOINT(0 0,1 1,1 0,1 1)"), + from_wkt("MULTIPOINT()"), + from_wkt("MULTIPOINT(0 0,1 1,1 0,1 1)") + ); + + tester::apply + ("mpmpu05", + from_wkt("MULTIPOINT()"), + from_wkt("MULTIPOINT()"), + from_wkt("MULTIPOINT()") + ); + + tester::apply + ("mpmpu06", + from_wkt("MULTIPOINT(0 0,1 0,2 0,3 0,0 0,1 0,2 0)"), from_wkt("MULTIPOINT(0 1,0 2,1 0,0 0,2 0)"), from_wkt("MULTIPOINT(0 0,1 0,2 0,3 0,0 0,1 0,2 0,0 1,0 2)"), - from_wkt("MULTIPOINT(0 1,0 2,1 0,0 0,2 0,3 0)"), - "mpmpu06"); + from_wkt("MULTIPOINT(0 1,0 2,1 0,0 0,2 0,3 0)") + ); } - diff --git a/test/algorithms/test_convex_hull.hpp b/test/algorithms/test_convex_hull.hpp index 1570dec2a..5e48d1e60 100644 --- a/test/algorithms/test_convex_hull.hpp +++ b/test/algorithms/test_convex_hull.hpp @@ -1,7 +1,7 @@ // Boost.Geometry (aka GGL, Generic Geometry Library) // Unit Test -// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands. +// Copyright (c) 2007-2015 Barend Gehrels, Amsterdam, the Netherlands. // This file was modified by Oracle on 2014, 2015. // Modifications copyright (c) 2014-2015 Oracle and/or its affiliates. @@ -26,8 +26,7 @@ #include -#include -#include +#include #include diff --git a/test/algorithms/test_length.hpp b/test/algorithms/test_length.hpp index 9543a3035..107bdae21 100644 --- a/test/algorithms/test_length.hpp +++ b/test/algorithms/test_length.hpp @@ -12,7 +12,7 @@ #include #include -#include +#include #include #include diff --git a/test/from_wkt.hpp b/test/from_wkt.hpp index a12dc051d..2d5f7bac6 100644 --- a/test/from_wkt.hpp +++ b/test/from_wkt.hpp @@ -1,10 +1,10 @@ // 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. +// Copyright (c) 2007-2015 Barend Gehrels, Amsterdam, the Netherlands. +// Copyright (c) 2008-2015 Bruno Lalande, Paris, France. +// Copyright (c) 2009-2015 Mateusz Loskot, London, UK. +// Copyright (c) 2013-2015 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 @@ -16,7 +16,6 @@ #include #include -#include template inline Geometry from_wkt(std::string const& wkt) diff --git a/test/geometries/Jamfile.v2 b/test/geometries/Jamfile.v2 index c09ff95ad..9999c7280 100644 --- a/test/geometries/Jamfile.v2 +++ b/test/geometries/Jamfile.v2 @@ -25,6 +25,6 @@ test-suite boost-geometry-geometries # custom_linestring_test_fail_clear #] [ run custom_linestring.cpp ] - [ run geometries.cpp : : : BOOST_GEOMETRY_EXPERIMENTAL_ENABLE_INITIALIZER_LIST ] + [ run geometries.cpp ] [ run segment.cpp ] ; diff --git a/test/geometries/adapted.cpp b/test/geometries/adapted.cpp index fd3bb6419..4dd8c8923 100644 --- a/test/geometries/adapted.cpp +++ b/test/geometries/adapted.cpp @@ -1,7 +1,7 @@ // Boost.Geometry (aka GGL, Generic Geometry Library) // Unit Test -// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands. +// Copyright (c) 2007-2015 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 @@ -14,7 +14,6 @@ #include #include -#include #include #include @@ -35,8 +34,8 @@ #elif defined(BOOST_GEOMETRY_TEST_MULTI_POINT) - #include - #include + #include + #include BOOST_GEOMETRY_REGISTER_MULTI_POINT_TEMPLATED(std::vector) BOOST_GEOMETRY_REGISTER_MULTI_POINT_TEMPLATED(std::deque) diff --git a/test/geometries/geometries.cpp b/test/geometries/geometries.cpp index 8510df1da..23dd11f52 100644 --- a/test/geometries/geometries.cpp +++ b/test/geometries/geometries.cpp @@ -1,7 +1,7 @@ // Boost.Geometry // Unit Test -// Copyright (c) 2014 Adam Wulkiewicz, Lodz, Poland. +// Copyright (c) 2014-2015 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 @@ -18,7 +18,6 @@ #include #include -#include #include typedef std::pair pt_pair_t; diff --git a/test/geometries/segment.cpp b/test/geometries/segment.cpp index 25165b6b7..c6cef3e10 100644 --- a/test/geometries/segment.cpp +++ b/test/geometries/segment.cpp @@ -58,13 +58,13 @@ void test_all() //std::cout << sizeof(typename coordinate_type::type) << std::endl; - typedef bg::model::referring_segment

CS; - //BOOST_CONCEPT_ASSERT( (concept::ConstSegment) ); + typedef bg::model::referring_segment

refseg_t; + //BOOST_CONCEPT_ASSERT( (concept::ConstSegment) ); - CS cs(p1, p2); + refseg_t seg(p1, p2); - typedef typename bg::coordinate_type::type CT; - typedef typename bg::point_type::type CSP; + typedef typename bg::coordinate_type::type CT; + typedef typename bg::point_type::type CSP; boost::ignore_unused(); } diff --git a/test/geometry_test_common.hpp b/test/geometry_test_common.hpp index ca9959ad7..f4fbd65b7 100644 --- a/test/geometry_test_common.hpp +++ b/test/geometry_test_common.hpp @@ -72,9 +72,11 @@ #endif # include +#ifndef BOOST_TEST_MODULE # include //# include # include +#endif #ifdef __clang__ # pragma clang diagnostic pop diff --git a/test/io/dsv/multi_dsv.cpp b/test/io/dsv/multi_dsv.cpp index 0af8f10e9..0b4bd8f28 100644 --- a/test/io/dsv/multi_dsv.cpp +++ b/test/io/dsv/multi_dsv.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-2015 Barend Gehrels, Amsterdam, the Netherlands. +// Copyright (c) 2008-2015 Bruno Lalande, Paris, France. +// Copyright (c) 2009-2015 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 @@ -15,9 +15,8 @@ #include #include -#include -#include -#include +#include +#include template void test_dsv(std::string const& wkt, std::string const& expected, bool json = false) diff --git a/test/io/wkt/multi_wkt.cpp b/test/io/wkt/multi_wkt.cpp index 35265feee..809f69fad 100644 --- a/test/io/wkt/multi_wkt.cpp +++ b/test/io/wkt/multi_wkt.cpp @@ -1,12 +1,12 @@ // 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-2015 Barend Gehrels, Amsterdam, the Netherlands. +// Copyright (c) 2008-2015 Bruno Lalande, Paris, France. +// Copyright (c) 2009-2015 Mateusz Loskot, London, UK. -// This file was modified by Oracle on 2014. -// Modifications copyright (c) 2014 Oracle and/or its affiliates. +// This file was modified by Oracle on 2014, 2015. +// Modifications copyright (c) 2014-2015 Oracle and/or its affiliates. // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle @@ -29,18 +29,7 @@ #include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include +#include template void test_all(); diff --git a/test/iterators/point_iterator.cpp b/test/iterators/point_iterator.cpp index b07d64ea2..59d2266cb 100644 --- a/test/iterators/point_iterator.cpp +++ b/test/iterators/point_iterator.cpp @@ -1,7 +1,7 @@ // Boost.Geometry (aka GGL, Generic Geometry Library) // Unit Test -// Copyright (c) 2014, Oracle and/or its affiliates. +// Copyright (c) 2014-2015, Oracle and/or its affiliates. // Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle @@ -29,16 +29,13 @@ #include #include -#include #include #include -#include -#include +#include #include #include -#include #include diff --git a/test/robustness/convex_hull/random_multi_points.cpp b/test/robustness/convex_hull/random_multi_points.cpp index c7b146681..93662ca9d 100644 --- a/test/robustness/convex_hull/random_multi_points.cpp +++ b/test/robustness/convex_hull/random_multi_points.cpp @@ -1,7 +1,7 @@ // Boost.Geometry (aka GGL, Generic Geometry Library) // Robustness Test - convex_hull -// Copyright (c) 2012 Barend Gehrels, Amsterdam, the Netherlands. +// Copyright (c) 2012-2015 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 @@ -23,7 +23,6 @@ #include #include #include -#include #include struct settings_type diff --git a/test/robustness/overlay/areal_areal/test_overlay_p_q.hpp b/test/robustness/overlay/areal_areal/test_overlay_p_q.hpp index fa5544a77..6fbd38b3e 100644 --- a/test/robustness/overlay/areal_areal/test_overlay_p_q.hpp +++ b/test/robustness/overlay/areal_areal/test_overlay_p_q.hpp @@ -1,7 +1,7 @@ // Boost.Geometry (aka GGL, Generic Geometry Library) // Unit Test // -// Copyright (c) 2009-2012 Barend Gehrels, Amsterdam, the Netherlands. +// Copyright (c) 2009-2015 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) @@ -27,7 +27,6 @@ #include #include #include -#include #include #include diff --git a/test/robustness/overlay/areal_areal/ticket_9081.cpp b/test/robustness/overlay/areal_areal/ticket_9081.cpp index 9c2f81597..91f336c6f 100644 --- a/test/robustness/overlay/areal_areal/ticket_9081.cpp +++ b/test/robustness/overlay/areal_areal/ticket_9081.cpp @@ -1,6 +1,6 @@ // Boost.Geometry (aka GGL, Generic Geometry Library) // Robustness Test -// Copyright (c) 2013 Barend Gehrels, Amsterdam, the Netherlands. +// Copyright (c) 2013-2015 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 @@ -20,7 +20,7 @@ #include #include #include - #include + #include #include #include diff --git a/test/robustness/overlay/buffer/many_ring_buffer.cpp b/test/robustness/overlay/buffer/many_ring_buffer.cpp index 82226a087..1fd54c23f 100644 --- a/test/robustness/overlay/buffer/many_ring_buffer.cpp +++ b/test/robustness/overlay/buffer/many_ring_buffer.cpp @@ -1,7 +1,7 @@ // Boost.Geometry (aka GGL, Generic Geometry Library) // Unit Test -// Copyright (c) 2012-2014 Barend Gehrels, Amsterdam, the Netherlands. +// Copyright (c) 2012-2015 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 @@ -14,7 +14,7 @@ #include #include -#include +#include #include #include diff --git a/test/robustness/overlay/buffer/multi_point_growth.cpp b/test/robustness/overlay/buffer/multi_point_growth.cpp index d74a6c5f6..4aed939cf 100644 --- a/test/robustness/overlay/buffer/multi_point_growth.cpp +++ b/test/robustness/overlay/buffer/multi_point_growth.cpp @@ -8,7 +8,7 @@ // http://www.boost.org/LICENSE_1_0.txt) #include -#include +#include #include #include diff --git a/test/robustness/overlay/buffer/recursive_polygons_buffer.cpp b/test/robustness/overlay/buffer/recursive_polygons_buffer.cpp index 737f22c2e..2000de657 100644 --- a/test/robustness/overlay/buffer/recursive_polygons_buffer.cpp +++ b/test/robustness/overlay/buffer/recursive_polygons_buffer.cpp @@ -1,7 +1,7 @@ // Boost.Geometry (aka GGL, Generic Geometry Library) // Robustness Test -// Copyright (c) 2012 Barend Gehrels, Amsterdam, the Netherlands. +// Copyright (c) 2012-2015 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 @@ -26,7 +26,6 @@ #include #include #include -#include #include diff --git a/test/robustness/overlay/linear_areal/recursive_polygons_linear_areal.cpp b/test/robustness/overlay/linear_areal/recursive_polygons_linear_areal.cpp index 8e057471d..c29a0df12 100644 --- a/test/robustness/overlay/linear_areal/recursive_polygons_linear_areal.cpp +++ b/test/robustness/overlay/linear_areal/recursive_polygons_linear_areal.cpp @@ -1,7 +1,7 @@ // Boost.Geometry (aka GGL, Generic Geometry Library) // Robustness Test -// Copyright (c) 2012 Barend Gehrels, Amsterdam, the Netherlands. +// Copyright (c) 2012-2015 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 @@ -26,7 +26,6 @@ #include #include #include -#include #include #include diff --git a/test/strategies/distance_default_result.cpp b/test/strategies/distance_default_result.cpp index 40315d207..e862d3313 100644 --- a/test/strategies/distance_default_result.cpp +++ b/test/strategies/distance_default_result.cpp @@ -180,7 +180,7 @@ struct test_distance_result_box //========================================================================= -template +template inline void test_segment_all() { #if defined(HAVE_TTMATH) @@ -189,32 +189,32 @@ inline void test_segment_all() #endif typedef typename boost::mpl::if_ < - typename boost::is_same::type, + 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(); + 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(); - test_distance_result_segment(); - test_distance_result_segment(); + test_distance_result_segment(); + test_distance_result_segment(); + test_distance_result_segment(); #endif } diff --git a/test/strategies/douglas_peucker.cpp b/test/strategies/douglas_peucker.cpp index 3306dbcc4..b8b09f348 100644 --- a/test/strategies/douglas_peucker.cpp +++ b/test/strategies/douglas_peucker.cpp @@ -168,11 +168,11 @@ template struct test_one_case { template - static inline void apply(std::string const& wkt, + static inline void apply(std::string const& case_id, + std::string const& wkt, double max_distance, Strategy const& strategy, - Range const& expected_result, - std::string const& case_id) + Range const& expected_result) { typedef typename bg::point_type::type point_type; std::vector result; @@ -197,16 +197,20 @@ struct test_one_case "output: "); std::cout << std::endl << std::endl; #endif - std::stringstream sstr; - print_point_range(sstr, boost::begin(expected_result), + std::stringstream stream_expected; + print_point_range(stream_expected, boost::begin(expected_result), boost::end(expected_result), ""); + std::stringstream stream_detected; + print_point_range(stream_detected, boost::begin(result), + boost::end(result), + ""); BOOST_CHECK_MESSAGE(equals::apply(result, expected_result), "case id: " << case_id << " - " << typeid_name << ", geometry: " << wkt - << ", Expected: " << sstr.str() - << " - Detected: " << bg::wkt(result)); + << ", Expected: " << stream_expected.str() + << " - Detected: " << stream_detected.str()); #ifdef BOOST_GEOMETRY_TEST_DEBUG std::cout << "---------------" << std::endl; @@ -218,7 +222,7 @@ struct test_one_case template -inline void test_with_strategy() +inline void test_with_strategy(std::string label) { std::cout.precision(20); Strategy strategy; @@ -228,45 +232,52 @@ inline void test_with_strategy() typedef bg::model::segment segment_type; typedef test_one_case tester; + label = " (" + label + ")"; + { point_type const p1(-6,-13), p2(0,-15); segment_type const s(point_type(12,-3), point_type(-12,5)); if (bg::comparable_distance(p1, s) >= bg::comparable_distance(p2, s)) { - tester::apply("LINESTRING(12 -3, 4 8,-6 -13,-9 4,0 -15,-12 5)", + tester::apply("l01c1" + label, + "LINESTRING(12 -3, 4 8,-6 -13,-9 4,0 -15,-12 5)", 10, strategy, - ba::tuple_list_of(12,-3)(4,8)(-6,-13)(-12,5), - "l01"); + ba::tuple_list_of(12,-3)(4,8)(-6,-13)(-12,5) + ); } else { - tester::apply("LINESTRING(12 -3, 4 8,-6 -13,-9 4,0 -15,-12 5)", + tester::apply("l01c2" + label, + "LINESTRING(12 -3, 4 8,-6 -13,-9 4,0 -15,-12 5)", 10, strategy, - ba::tuple_list_of(12,-3)(4,8)(-6,-13)(-9,4)(0,-15)(-12,5), - "l01"); + ba::tuple_list_of(12,-3)(4,8)(-6,-13)(-9,4)(0,-15)(-12,5) + ); } } - tester::apply("LINESTRING(-6 -13,-9 4,0 -15,-12 5)", + tester::apply("l02" + label, + "LINESTRING(-6 -13,-9 4,0 -15,-12 5)", 10, strategy, - ba::tuple_list_of(-6,-13)(-12,5), - "l02"); + ba::tuple_list_of(-6,-13)(-12,5) + ); - tester::apply("LINESTRING(12 -3, 4 8,-6 -13,-9 4,0 -14,-12 5)", + tester::apply("l03" + label, + "LINESTRING(12 -3, 4 8,-6 -13,-9 4,0 -14,-12 5)", 10, strategy, - ba::tuple_list_of(12,-3)(4,8)(-6,-13)(-12,5), - "l03"); + ba::tuple_list_of(12,-3)(4,8)(-6,-13)(-12,5) + ); - tester::apply("LINESTRING(12 -3, 4 8,-6 -13,-9 4,0 -14,-12 5)", + tester::apply("l04" + label, + "LINESTRING(12 -3, 4 8,-6 -13,-9 4,0 -14,-12 5)", 14, strategy, - ba::tuple_list_of(12,-3)(-6,-13)(-12,5), - "l04"); + ba::tuple_list_of(12,-3)(-6,-13)(-12,5) + ); { segment_type const s(point_type(0,-1), point_type(5,-4)); @@ -308,29 +319,33 @@ inline void test_with_strategy() if (bg::comparable_distance(p1, s) >= bg::comparable_distance(p2, s)) { - tester::apply(wkt, + tester::apply("l05c1" + label, + wkt, 1, strategy, - ba::tuple_list_of(0,0)(5,0)(0,-1)(5,-1)(0,-2)(5,-2)(0,-3)(5,-4)(0,0), - "l05"); - tester::apply(wkt, + ba::tuple_list_of(0,0)(5,0)(0,-1)(5,-1)(0,-2)(5,-2)(0,-3)(5,-4)(0,0) + ); + tester::apply("l05c1a" + label, + wkt, 2, strategy, - ba::tuple_list_of(0,0)(5,0)(0,-1)(5,-1)(0,-2)(5,-4)(0,0), - "l05a"); + ba::tuple_list_of(0,0)(5,0)(0,-1)(5,-1)(0,-2)(5,-4)(0,0) + ); } else { - tester::apply(wkt, + tester::apply("l05c2" + label, + wkt, 1, strategy, - ba::tuple_list_of(0,0)(5,0)(0,-1)(5,-1)(0,-2)(5,-2)(0,-4)(5,-4)(0,0), - "l05"); - tester::apply(wkt, + ba::tuple_list_of(0,0)(5,0)(0,-1)(5,-1)(0,-2)(5,-2)(0,-4)(5,-4)(0,0) + ); + tester::apply("l05c2a" + label, + wkt, 2, strategy, - ba::tuple_list_of(0,0)(5,0)(0,-1)(5,-1)(0,-4)(5,-4)(0,0), - "l05a"); + ba::tuple_list_of(0,0)(5,0)(0,-1)(5,-1)(0,-4)(5,-4)(0,0) + ); } } @@ -346,14 +361,14 @@ inline void test_with_strategy() BOOST_AUTO_TEST_CASE( test_default_strategy ) { - test_with_strategy::type>(); - test_with_strategy::type>(); - test_with_strategy::type>(); + test_with_strategy::type>("i"); + test_with_strategy::type>("f"); + test_with_strategy::type>("d"); test_with_strategy < long double, default_simplify_strategy::type - >(); + >("ld"); } BOOST_AUTO_TEST_CASE( test_with_regular_distance_strategy ) @@ -362,24 +377,24 @@ BOOST_AUTO_TEST_CASE( test_with_regular_distance_strategy ) < int, simplify_regular_distance_strategy::type - >(); + >("i"); test_with_strategy < float, simplify_regular_distance_strategy::type - >(); + >("f"); test_with_strategy < double, simplify_regular_distance_strategy::type - >(); + >("d"); test_with_strategy < long double, simplify_regular_distance_strategy::type - >(); + >("ld"); } BOOST_AUTO_TEST_CASE( test_with_comparable_distance_strategy ) @@ -388,20 +403,20 @@ BOOST_AUTO_TEST_CASE( test_with_comparable_distance_strategy ) < int, simplify_comparable_distance_strategy::type - >(); + >("i"); test_with_strategy < float, simplify_comparable_distance_strategy::type - >(); + >("f"); test_with_strategy < double, simplify_comparable_distance_strategy::type - >(); + >("d"); test_with_strategy < long double, simplify_comparable_distance_strategy::type - >(); + >("ld"); } diff --git a/test/string_from_type.hpp b/test/string_from_type.hpp index 178ff2ea0..df0141a58 100644 --- a/test/string_from_type.hpp +++ b/test/string_from_type.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-2015 Barend Gehrels, Amsterdam, the Netherlands. +// Copyright (c) 2008-2015 Bruno Lalande, Paris, France. +// Copyright (c) 2009-2015 Mateusz Loskot, London, UK. + +// This file was modified by Oracle on 2015. +// Modifications copyright (c) 2015, 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. @@ -55,9 +60,21 @@ template <> struct string_from_type template <> struct string_from_type { static std::string name() { return "i"; } }; -template <> struct string_from_type +template <> struct string_from_type { static std::string name() { return "l"; } }; +#if defined(BOOST_HAS_LONG_LONG) +// this is what g++ and clang++ use +template <> struct string_from_type +{ static std::string name() { return "x"; } }; +#endif + +#if defined(BOOST_HAS_INT128) +// this is what g++ and clang++ use +template <> struct string_from_type +{ static std::string name() { return "n"; } }; +#endif + #if defined(HAVE_TTMATH) template <> struct string_from_type { static std::string name() { return "t"; } }; diff --git a/test/util/Jamfile.v2 b/test/util/Jamfile.v2 index bfb647dc7..70a463777 100644 --- a/test/util/Jamfile.v2 +++ b/test/util/Jamfile.v2 @@ -1,11 +1,11 @@ # 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) 2007-2015 Barend Gehrels, Amsterdam, the Netherlands. +# Copyright (c) 2008-2015 Bruno Lalande, Paris, France. +# Copyright (c) 2009-2015 Mateusz Loskot, London, UK. # -# This file was modified by Oracle on 2014. -# Modifications copyright (c) 2014, Oracle and/or its affiliates. +# This file was modified by Oracle on 2014, 2015. +# Modifications copyright (c) 2014-2015, Oracle and/or its affiliates. # # Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle # @@ -18,6 +18,7 @@ test-suite boost-geometry-util [ run calculation_type.cpp ] [ run for_each_coordinate.cpp ] [ run math_sqrt.cpp ] + [ run promote_integral.cpp ] [ run range.cpp ] [ run rational.cpp ] [ run select_most_precise.cpp ] diff --git a/test/util/promote_integral.cpp b/test/util/promote_integral.cpp new file mode 100644 index 000000000..92d1b8ce4 --- /dev/null +++ b/test/util/promote_integral.cpp @@ -0,0 +1,547 @@ +// Boost.Geometry (aka GGL, Generic Geometry Library) +// Unit Test + +// Copyright (c) 2015, 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_promote_integral +#endif + +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +#include +#include + +#include + +#include +#include + +#if !defined(BOOST_GEOMETRY_NO_MULTIPRECISION_INTEGER) +#include +#endif + +#if defined(BOOST_GEOMETRY_TEST_DEBUG) +#if defined(BOOST_HAS_INT128) && defined(BOOST_GEOMETRY_ENABLE_INT128) +void print_uint128_t(std::ostream& os, boost::uint128_type i) +{ + if (i == 0) + { + os << "0"; + return; + } + + std::stringstream stream; + while (i > 0) + { + stream << static_cast(i % 10); + i /= 10; + } + std::string str = stream.str(); + std::reverse(str.begin(), str.end()); + os << str; +} + +std::ostream& operator<<(std::ostream& os, boost::int128_type i) +{ + if (i < 0) + { + os << "-"; + print_uint128_t(os, static_cast(-i)); + } + else + { + print_uint128_t(os, static_cast(i)); + } + return os; +} + +std::ostream& operator<<(std::ostream& os, boost::uint128_type i) +{ + print_uint128_t(os, i); + return os; +} +#endif // BOOST_HAS_INT128 && BOOST_GEOMETRY_ENABLE_INT128 +#endif // BOOST_GEOMETRY_TEST_DEBUG + +namespace bg = boost::geometry; + +template +< + typename T, + bool Signed = boost::is_fundamental::type::value + && ! boost::is_unsigned::type::value +> +struct absolute_value +{ + static inline T apply(T const& t) + { + return t < 0 ? -t : t; + } +}; + +template +struct absolute_value +{ + static inline T apply(T const& t) + { + return t; + } +}; + + + +template +< + typename Integral, + typename Promoted, + bool Signed = ! boost::is_unsigned::type::value +> +struct test_max_values +{ + static inline void apply() + { + Promoted min_value = (std::numeric_limits::min)(); + min_value *= min_value; + BOOST_CHECK(absolute_value::apply(min_value) == min_value); + Promoted max_value = (std::numeric_limits::max)(); + max_value *= max_value; + BOOST_CHECK(absolute_value::apply(max_value) == max_value); + +#ifdef BOOST_GEOMETRY_TEST_DEBUG + std::cout << "integral min_value^2: " << min_value << std::endl; + std::cout << "promoted max_value: " + << (std::numeric_limits::max)() << std::endl; +#endif + } +}; + +template +struct test_max_values +{ + static inline void apply() + { + Promoted max_value = (std::numeric_limits::max)(); + Promoted max_value_sqr = max_value * max_value; + BOOST_CHECK(max_value_sqr < (std::numeric_limits::max)() + && + max_value_sqr > max_value); + +#ifdef BOOST_GEOMETRY_TEST_DEBUG + std::cout << "integral max_value^2: " << max_value_sqr << std::endl; + std::cout << "promoted max_value: " + << (std::numeric_limits::max)() << std::endl; +#endif + } +}; + + +// helper function that returns the bit size of a type +template +< + typename T, + bool IsFundamental = boost::is_fundamental::type::value +> +struct bit_size_impl : boost::mpl::size_t<0> +{}; + +template +struct bit_size_impl : bg::detail::promote_integral::bit_size::type +{}; + +#if !defined(BOOST_GEOMETRY_NO_MULTIPRECISION_INTEGER) +template +< + typename Backend, + boost::multiprecision::expression_template_option ExpressionTemplates +> +struct bit_size_impl + < + boost::multiprecision::number, + false + > : bg::detail::promote_integral::bit_size + < + boost::multiprecision::number + > +{}; +#endif + + +template +std::size_t bit_size() +{ + return bit_size_impl::type::value; +} + +template +struct test_promote_integral +{ + template + static inline void apply(std::string const& case_id) + { + typedef typename bg::promote_integral + < + Type, PromoteUnsignedToUnsigned + >::type promoted_integral_type; + + bool const same_types = boost::is_same + < + promoted_integral_type, ExpectedPromotedType + >::type::value; + + BOOST_CHECK_MESSAGE(same_types, + "case ID: " << case_id + << "input type: " << typeid(Type).name() + << "; detected: " + << typeid(promoted_integral_type).name() + << "; expected: " + << typeid(ExpectedPromotedType).name()); + + if (BOOST_GEOMETRY_CONDITION((! boost::is_same + < + Type, promoted_integral_type + >::type::value))) + { + test_max_values::apply(); + } + +#ifdef BOOST_GEOMETRY_TEST_DEBUG + std::cout << "case ID: " << case_id << std::endl + << "type : " << typeid(Type).name() + << ", sizeof (bits): " << bit_size() + << ", min value: " + << (std::numeric_limits::min)() + << ", max value: " + << (std::numeric_limits::max)() + << std::endl; + std::cout << "detected promoted type : " + << typeid(promoted_integral_type).name() + << ", sizeof (bits): " << bit_size() + << ", min value: " + << (std::numeric_limits::min)() + << ", max value: " + << (std::numeric_limits::max)() + << std::endl; + std::cout << "expected promoted type : " + << typeid(ExpectedPromotedType).name() + << ", sizeof (bits): " << bit_size() + << ", min value: " + << (std::numeric_limits::min)() + << ", max value: " + << (std::numeric_limits::max)() + << std::endl; + std::cout << std::endl; +#endif + } +}; + +template +< + typename T, + bool PromoteUnsignedToUnsigned = false, + bool IsSigned = ! boost::is_unsigned::type::value +> +struct test_promotion +{ + static inline void apply(std::string case_id) + { +#ifdef BOOST_GEOMETRY_TEST_DEBUG + std::cout << "*** " + << (IsSigned ? "signed" : "unsigned") + << " -> signed ***" << std::endl; +#endif + + typedef test_promote_integral tester; + + case_id += (PromoteUnsignedToUnsigned ? "-t" : "-f"); + + std::size_t min_size = 2 * bit_size() - 1; + if (BOOST_GEOMETRY_CONDITION(! IsSigned)) + { + min_size += 2; + } + +#ifdef BOOST_GEOMETRY_TEST_DEBUG + std::cout << "min size: " << min_size << std::endl; +#endif + + if (bit_size() >= min_size) + { + tester::template apply(case_id); + } + else if (bit_size() >= min_size) + { + tester::template apply(case_id); + } + else if (bit_size() >= min_size) + { + tester::template apply(case_id); + } +#if defined(BOOST_HAS_LONG_LONG) + else if (bit_size() >= min_size) + { + tester::template apply(case_id); + } +#endif +#if defined(BOOST_HAS_INT128) && defined(BOOST_GEOMETRY_ENABLE_INT128) + else if (bit_size() >= min_size) + { + tester::template apply(case_id); + } +#endif + else + { +#if !defined(BOOST_GEOMETRY_NO_MULTIPRECISION_INTEGER) + namespace bm = boost::multiprecision; + typedef bm::number + < + bm::cpp_int_backend + < + 2 * CHAR_BIT * sizeof(T) + (IsSigned ? -1 : 1), + 2 * CHAR_BIT * sizeof(T) + (IsSigned ? -1 : 1), + bm::signed_magnitude, + bm::unchecked, + void + > + > multiprecision_integer_type; + + tester::template apply(case_id); +#else + tester::template apply(case_id); +#endif + } + } +}; + +template +struct test_promotion +{ + static inline void apply(std::string case_id) + { +#ifdef BOOST_GEOMETRY_TEST_DEBUG + std::cout << "*** unsigned -> unsigned ***" << std::endl; +#endif + case_id += "-t"; + + typedef test_promote_integral tester; + + std::size_t min_size = 2 * bit_size(); + +#ifdef BOOST_GEOMETRY_TEST_DEBUG + std::cout << "min size: " << min_size << std::endl; +#endif + + if (bit_size() >= min_size) + { + tester::apply(case_id); + } + else if (bit_size() >= min_size) + { + tester::apply(case_id); + } + else if (bit_size() >= min_size) + { + tester::apply(case_id); + } + else if (bit_size() >= min_size) + { + tester::apply(case_id); + } +#if defined(BOOST_HAS_LONG_LONG) + else if (bit_size() >= min_size) + { + tester::template apply(case_id); + } +#endif +#if defined(BOOST_HAS_INT128) && defined(BOOST_GEOMETRY_ENABLE_INT128) + else if (bit_size() >= min_size) + { + tester::template apply(case_id); + } +#endif + else + { +#if !defined(BOOST_GEOMETRY_NO_MULTIPRECISION_INTEGER) + namespace bm = boost::multiprecision; + typedef bm::number + < + bm::cpp_int_backend + < + 2 * CHAR_BIT * sizeof(T), + 2 * CHAR_BIT * sizeof(T), + bm::unsigned_magnitude, + bm::unchecked, + void + > + > multiprecision_integer_type; + + tester::apply(case_id); +#else + tester::apply(case_id); +#endif + } + } +}; + + + +BOOST_AUTO_TEST_CASE( test_char ) +{ + test_promotion::apply("char"); + test_promotion::apply("char"); + test_promotion::apply("schar"); + test_promotion::apply("schar"); + test_promotion::apply("uchar"); + test_promotion::apply("uchar"); +} + +BOOST_AUTO_TEST_CASE( test_short ) +{ + test_promotion::apply("short"); + test_promotion::apply("short"); + test_promotion::apply("ushort"); + test_promotion::apply("ushort"); +} + +BOOST_AUTO_TEST_CASE( test_int ) +{ + test_promotion::apply("int"); + test_promotion::apply("int"); + test_promotion::apply("uint"); + test_promotion::apply("uint"); +} + +BOOST_AUTO_TEST_CASE( test_long ) +{ + test_promotion::apply("long"); + test_promotion::apply("long"); + test_promotion::apply("ulong"); + test_promotion::apply("ulong"); +} + +BOOST_AUTO_TEST_CASE( test_std_size_t ) +{ + test_promotion::apply("size_t"); + test_promotion::apply("size_t"); +} + +#ifdef BOOST_HAS_LONG_LONG +BOOST_AUTO_TEST_CASE( test_long_long ) +{ + test_promotion::apply("long long"); + test_promotion::apply("long long"); + test_promotion::apply("ulong long"); + test_promotion::apply("ulong long"); +} +#endif + +#if defined(BOOST_HAS_INT128) && defined(BOOST_GEOMETRY_ENABLE_INT128) +BOOST_AUTO_TEST_CASE( test_int128 ) +{ + test_promotion::apply("int128_t"); + test_promotion::apply("int128_t"); + test_promotion::apply("uint128_t"); + test_promotion::apply("uint128_t"); +} +#endif + +#if !defined(BOOST_GEOMETRY_NO_MULTIPRECISION_INTEGER) +BOOST_AUTO_TEST_CASE( test_user_types ) +{ + namespace bm = boost::multiprecision; + typedef bm::number + < + bm::cpp_int_backend + < + 17, + 17, + bm::signed_magnitude, + bm::unchecked, + void + > + > user_signed_type1; + + typedef bm::number + < + bm::cpp_int_backend + < + 17, + 17, + bm::unsigned_magnitude, + bm::unchecked, + void + > + > user_unsigned_type1; + + typedef bm::number + < + bm::cpp_int_backend + < + 500, + 500, + bm::signed_magnitude, + bm::unchecked, + void + > + > user_signed_type2; + + typedef bm::number + < + bm::cpp_int_backend + < + 500, + 500, + bm::unsigned_magnitude, + bm::unchecked, + void + > + > user_unsigned_type2; + + // for user defined number types we do not do any promotion + typedef test_promote_integral tester1; + typedef test_promote_integral tester2; + tester1::apply("u1s"); + tester1::apply("u2s"); + tester1::apply("u1u"); + tester1::apply("u2u"); + + tester2::apply("u1s"); + tester2::apply("u2s"); + tester2::apply("u1u"); + tester2::apply("u1u"); +} +#endif + +BOOST_AUTO_TEST_CASE( test_floating_point ) +{ + typedef test_promote_integral tester1; + typedef test_promote_integral tester2; + + // for floating-point types we do not do any promotion + tester1::apply("fp-f"); + tester1::apply("fp-d"); + tester1::apply("fp-ld"); + + tester2::apply("fp-f"); + tester2::apply("fp-d"); + tester2::apply("fp-ld"); + +#ifdef HAVE_TTMATH + tester1::apply("fp-tt"); + tester2::apply("fp-tt"); +#endif +} diff --git a/test/util/select_most_precise.cpp b/test/util/select_most_precise.cpp index 11b066fa3..3ec2dec73 100644 --- a/test/util/select_most_precise.cpp +++ b/test/util/select_most_precise.cpp @@ -24,8 +24,15 @@ template void test() { typedef typename bg::select_most_precise::type type; + bool is_same = boost::is_same::type::value; - BOOST_CHECK((boost::is_same::type::value)); + BOOST_CHECK_MESSAGE(is_same, + "The most precise of types " << + "T1: {" << typeid(T1).name() << " | s: " << sizeof(T1) << "}" << + " and " << + "T2: {" << typeid(T2).name() << " | s: " << sizeof(T2) << "}" << + " does not match " << + "ExpectedType: {" << typeid(ExpectedType).name() << " | s: " << sizeof(ExpectedType) << "}"); } int test_main(int, char* []) @@ -49,11 +56,13 @@ int test_main(int, char* []) test(); test(); -#ifndef _MSC_VER - // This cannot be done for MSVC because double/long double is the same - test(); - test(); -#endif + if ( sizeof(long double) > sizeof(double) ) + { + // This cannot be done for MSVC because double/long double is the same + // This is also true for Android + test(); + test(); + } // with any other non-integer/float class test();