Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r85371 - in trunk: boost/geometry/extensions/nsphere/strategies/cartesian libs/geometry/extensions/test/nsphere
From: barend.gehrels_at_[hidden]
Date: 2013-08-17 07:14:14


Author: barendgehrels
Date: 2013-08-17 07:14:14 EDT (Sat, 17 Aug 2013)
New Revision: 85371
URL: http://svn.boost.org/trac/boost/changeset/85371

Log:
[geometry][extensions] fixed multi_within test which missed a default_strategy, this was the same for within so uncommented the relevant lines there (and added polygon/box)

Text files modified:
   trunk/boost/geometry/extensions/nsphere/strategies/cartesian/point_in_nsphere.hpp | 47 +++++++++++++++++++++++++++++++--------
   trunk/libs/geometry/extensions/test/nsphere/multi_within.cpp | 3 ++
   trunk/libs/geometry/extensions/test/nsphere/within.cpp | 13 ++++++----
   3 files changed, 48 insertions(+), 15 deletions(-)

Modified: trunk/boost/geometry/extensions/nsphere/strategies/cartesian/point_in_nsphere.hpp
==============================================================================
--- trunk/boost/geometry/extensions/nsphere/strategies/cartesian/point_in_nsphere.hpp Sat Aug 17 06:19:28 2013 (r85370)
+++ trunk/boost/geometry/extensions/nsphere/strategies/cartesian/point_in_nsphere.hpp 2013-08-17 07:14:14 EDT (Sat, 17 Aug 2013) (r85371)
@@ -15,6 +15,7 @@
 #ifndef BOOST_GEOMETRY_EXTENSIONS_NSPHERE_STRATEGIES_CARTESIAN_POINT_IN_NSPHERE_HPP
 #define BOOST_GEOMETRY_EXTENSIONS_NSPHERE_STRATEGIES_CARTESIAN_POINT_IN_NSPHERE_HPP
 
+#include <cassert>
 
 #include <boost/geometry/core/access.hpp>
 #include <boost/geometry/core/coordinate_dimension.hpp>
@@ -23,9 +24,9 @@
 
 #include <boost/geometry/extensions/nsphere/views/center_view.hpp>
 
-namespace boost { namespace geometry { namespace strategy
+namespace boost { namespace geometry { namespace strategy
 {
-
+
 namespace within
 {
 
@@ -67,6 +68,20 @@
 };
 
 
+// For many geometry-in-nsphere, we do not have a strategy yet... but a default strategy should exist
+struct nsphere_dummy
+{
+ template <typename A, typename B>
+ static bool apply(A const& a, B const& b)
+ {
+ // Assertion if called
+ assert(false);
+ return false;
+ }
+};
+
+
+
 } // namespace within
 
 
@@ -79,13 +94,25 @@
 template <typename Point, typename NSphere>
 struct default_strategy
     <
- point_tag, nsphere_tag,
- point_tag, areal_tag,
- cartesian_tag, cartesian_tag,
+ point_tag, nsphere_tag,
+ point_tag, areal_tag,
+ cartesian_tag, cartesian_tag,
         Point, NSphere
>
 {
- typedef within::point_in_nsphere<Point, NSphere, within::point_nsphere_within_comparable_distance> type;
+ typedef within::point_in_nsphere<Point, NSphere, within::point_nsphere_within_comparable_distance> type;
+};
+
+template <typename AnyTag, typename AnyGeometry, typename NSphere>
+struct default_strategy
+ <
+ AnyTag, nsphere_tag,
+ AnyTag, areal_tag,
+ cartesian_tag, cartesian_tag,
+ AnyGeometry, NSphere
+ >
+{
+ typedef within::nsphere_dummy type;
 };
 
 
@@ -99,13 +126,13 @@
 template <typename Point, typename NSphere>
 struct default_strategy
     <
- point_tag, nsphere_tag,
- point_tag, areal_tag,
- cartesian_tag, cartesian_tag,
+ point_tag, nsphere_tag,
+ point_tag, areal_tag,
+ cartesian_tag, cartesian_tag,
         Point, NSphere
>
 {
- typedef within::point_in_nsphere<Point, NSphere, within::point_nsphere_covered_by_comparable_distance> type;
+ typedef within::point_in_nsphere<Point, NSphere, within::point_nsphere_covered_by_comparable_distance> type;
 };
 
 

Modified: trunk/libs/geometry/extensions/test/nsphere/multi_within.cpp
==============================================================================
--- trunk/libs/geometry/extensions/test/nsphere/multi_within.cpp Sat Aug 17 06:19:28 2013 (r85370)
+++ trunk/libs/geometry/extensions/test/nsphere/multi_within.cpp 2013-08-17 07:14:14 EDT (Sat, 17 Aug 2013) (r85371)
@@ -49,5 +49,8 @@
     // Multipolygon in circle
     BOOST_CHECK_EQUAL(bg::within(multi_polygon, circle), true);
 
+ multi_polygon.front().outer().insert(multi_polygon.front().outer().begin() + 1, gl_point(10, 10));
+ BOOST_CHECK_EQUAL(bg::within(multi_polygon, circle), false);
+
     return 0;
 }

Modified: trunk/libs/geometry/extensions/test/nsphere/within.cpp
==============================================================================
--- trunk/libs/geometry/extensions/test/nsphere/within.cpp Sat Aug 17 06:19:28 2013 (r85370)
+++ trunk/libs/geometry/extensions/test/nsphere/within.cpp 2013-08-17 07:14:14 EDT (Sat, 17 Aug 2013) (r85371)
@@ -36,17 +36,20 @@
         << " detected: " << detected);
 }
 
-
-
-
 template <typename P>
 void test_circles()
 {
     test_circle<P>("POINT(2 1)", true);
     test_circle<P>("POINT(12 1)", false);
 
- //test_circle<bg::model::linestring<P> >("LINESTRING(1 1,2 1,2 2)", true);
- //test_circle<bg::model::linestring<P> >("LINESTRING(1 1,2 1,2 2,10 10)", false);
+ test_circle<bg::model::linestring<P> >("LINESTRING(1 1,2 1,2 2)", true);
+ test_circle<bg::model::linestring<P> >("LINESTRING(1 1,2 1,2 2,10 10)", false);
+
+ test_circle<bg::model::polygon<P> >("POLYGON((1 1,2 1,2 2,1 1))", true);
+ test_circle<bg::model::polygon<P> >("POLYGON((1 1,2 1,2 2,10 10,1 1))", false);
+
+ test_circle<bg::model::box<P> >("BOX(1 1,2 2)", true);
+ test_circle<bg::model::box<P> >("BOX(1 1,10 10)", false);
 }
 
 


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk