Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r84831 - in trunk/libs/geometry/extensions/test: . nsphere
From: adam.wulkiewicz_at_[hidden]
Date: 2013-06-18 18:52:55


Author: awulkiew
Date: 2013-06-18 18:52:55 EDT (Tue, 18 Jun 2013)
New Revision: 84831
URL: http://svn.boost.org/trac/boost/changeset/84831

Log:
[geometry][extensions] test: nsphere added for testing, added disjoint/intersects, content and margin tests.

Added:
   trunk/libs/geometry/extensions/test/nsphere/Jamfile.v2 (contents, props changed)
   trunk/libs/geometry/extensions/test/nsphere/disjoint.cpp (contents, props changed)
   trunk/libs/geometry/extensions/test/nsphere/index_content.cpp (contents, props changed)
   trunk/libs/geometry/extensions/test/nsphere/index_margin.cpp (contents, props changed)
Text files modified:
   trunk/libs/geometry/extensions/test/Jamfile.v2 | 1
   trunk/libs/geometry/extensions/test/nsphere/Jamfile.v2 | 25 ++++++++++++++++
   trunk/libs/geometry/extensions/test/nsphere/disjoint.cpp | 59 ++++++++++++++++++++++++++++++++++++++++
   trunk/libs/geometry/extensions/test/nsphere/index_content.cpp | 50 +++++++++++++++++++++++++++++++++
   trunk/libs/geometry/extensions/test/nsphere/index_margin.cpp | 50 +++++++++++++++++++++++++++++++++
   5 files changed, 185 insertions(+), 0 deletions(-)

Modified: trunk/libs/geometry/extensions/test/Jamfile.v2
==============================================================================
--- trunk/libs/geometry/extensions/test/Jamfile.v2 Tue Jun 18 18:51:33 2013 (r84830)
+++ trunk/libs/geometry/extensions/test/Jamfile.v2 2013-06-18 18:52:55 EDT (Tue, 18 Jun 2013) (r84831)
@@ -22,4 +22,5 @@
 build-project arithmetic ;
 build-project gis ;
 build-project iterators ;
+build-project nsphere ;
 

Added: trunk/libs/geometry/extensions/test/nsphere/Jamfile.v2
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ trunk/libs/geometry/extensions/test/nsphere/Jamfile.v2 2013-06-18 18:52:55 EDT (Tue, 18 Jun 2013) (r84831)
@@ -0,0 +1,25 @@
+# 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) 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)
+
+test-suite boost-geometry-extensions-nsphere
+ :
+ [ run access.cpp ]
+ [ run area.cpp ]
+ [ run circle.cpp ]
+ [ run multi_within.cpp ]
+ [ run point_type.cpp ]
+ [ run within.cpp ]
+
+ [ run disjoint.cpp ]
+ [ run index_content.cpp ]
+ [ run index_margin.cpp ]
+ ;
+

Added: trunk/libs/geometry/extensions/test/nsphere/disjoint.cpp
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ trunk/libs/geometry/extensions/test/nsphere/disjoint.cpp 2013-06-18 18:52:55 EDT (Tue, 18 Jun 2013) (r84831)
@@ -0,0 +1,59 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+//
+// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
+// Copyright (c) 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)
+
+#include <geometry_test_common.hpp>
+
+#include <boost/geometry/extensions/nsphere/nsphere.hpp>
+
+#include <boost/geometry/geometries/geometries.hpp>
+#include <boost/geometry/geometries/point_xy.hpp>
+
+#include <boost/geometry/strategies/strategies.hpp>
+
+#include <boost/geometry/io/wkt/read.hpp>
+
+typedef bg::model::d2::point_xy<double> point_type;
+typedef bg::model::box<point_type> box_type;
+typedef bg::model::nsphere<point_type, double> circle_type;
+
+template <typename Geometry>
+void test_circle(Geometry const& geometry, std::string const& wkt_geometry, bool expected)
+{
+ circle_type circle(point_type(1.0, 1.0), 3.0);
+
+ bool detected = bg::disjoint(geometry, circle);
+
+ BOOST_CHECK_MESSAGE(detected == expected,
+ "disjoint: " << wkt_geometry
+ << " in circle (1,1) with radius 3"
+ << " -> Expected: " << expected
+ << " detected: " << detected);
+}
+
+template <typename Geometry>
+void test_circle(std::string const& wkt_geometry, bool expected)
+{
+ Geometry geometry;
+ bg::read_wkt(wkt_geometry, geometry);
+
+ test_circle<Geometry>(geometry, wkt_geometry, expected);
+}
+
+int test_main( int , char* [] )
+{
+ test_circle<point_type>("POINT(2 1)", false);
+ test_circle<point_type>("POINT(12 1)", true);
+
+ test_circle<box_type>("BOX(2 1, 4 4)", false);
+ test_circle<box_type>("BOX(-3 -3, -2 -2)", true);
+
+ test_circle<circle_type>(circle_type(point_type(4, 4), 2), "CIRCLE(4 4, 2)", false);
+ test_circle<circle_type>(circle_type(point_type(4, 4), 0.5), "CIRCLE(4 4, 0.5)", true);
+
+ return 0;
+}

Added: trunk/libs/geometry/extensions/test/nsphere/index_content.cpp
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ trunk/libs/geometry/extensions/test/nsphere/index_content.cpp 2013-06-18 18:52:55 EDT (Tue, 18 Jun 2013) (r84831)
@@ -0,0 +1,50 @@
+// 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.
+
+// 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 <geometry_test_common.hpp>
+
+#include <boost/geometry/geometries/geometries.hpp>
+#include <boost/geometry/strategies/strategies.hpp>
+
+#include <boost/geometry/extensions/nsphere/nsphere.hpp>
+
+template <typename P, typename T>
+void test_content_circle()
+{
+ bg::model::nsphere<P, T> c;
+
+ bg::set<0>(c.center(), 0);
+ bg::set<1>(c.center(), 0);
+ c.radius(2);
+
+ double d = bg::index::detail::content(c);
+ BOOST_CHECK_CLOSE(d, 4 * 3.1415926535897932384626433832795, 0.001);
+}
+
+template <typename P, typename T>
+void test_content_sphere()
+{
+ bg::model::nsphere<P, T> s;
+
+ bg::set<0>(s, 0);
+ bg::set<1>(s, 0);
+ bg::set<2>(s, 0);
+ bg::set_radius<0>(s, 2);
+
+ double d = bg::index::detail::content(s);
+ BOOST_CHECK_CLOSE(d, 32 * 3.1415926535897932384626433832795 / 3.0, 0.001);
+}
+
+int test_main(int, char* [])
+{
+ test_content_circle<bg::model::point<double, 2, bg::cs::cartesian>, double>();
+ test_content_sphere<bg::model::point<double, 3, bg::cs::cartesian>, double>();
+ return 0;
+}

Added: trunk/libs/geometry/extensions/test/nsphere/index_margin.cpp
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ trunk/libs/geometry/extensions/test/nsphere/index_margin.cpp 2013-06-18 18:52:55 EDT (Tue, 18 Jun 2013) (r84831)
@@ -0,0 +1,50 @@
+// 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.
+
+// 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 <geometry_test_common.hpp>
+
+#include <boost/geometry/geometries/geometries.hpp>
+#include <boost/geometry/strategies/strategies.hpp>
+
+#include <boost/geometry/extensions/nsphere/nsphere.hpp>
+
+template <typename P, typename T>
+void test_comparable_margin_circle()
+{
+ bg::model::nsphere<P, T> c;
+
+ bg::set<0>(c.center(), 0);
+ bg::set<1>(c.center(), 0);
+ c.radius(2);
+
+ double d = bg::index::detail::comparable_margin(c);
+ BOOST_CHECK_CLOSE(d, 2, 0.001);
+}
+
+template <typename P, typename T>
+void test_comparable_margin_sphere()
+{
+ bg::model::nsphere<P, T> s;
+
+ bg::set<0>(s, 0);
+ bg::set<1>(s, 0);
+ bg::set<2>(s, 0);
+ bg::set_radius<0>(s, 2);
+
+ double d = bg::index::detail::comparable_margin(s);
+ BOOST_CHECK_CLOSE(d, 4, 0.001);
+}
+
+int test_main(int, char* [])
+{
+ test_comparable_margin_circle<bg::model::point<double, 2, bg::cs::cartesian>, double>();
+ test_comparable_margin_sphere<bg::model::point<double, 3, bg::cs::cartesian>, double>();
+ return 0;
+}


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