|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r57070 - in sandbox/ggl/formal_review_request/libs/ggl: . example test test/algorithms test/arithmetic test/core test/iterators test/multi test/multi/algorithms test/point_concept test/strategies test/test_common
From: barend.gehrels_at_[hidden]
Date: 2009-10-22 11:26:31
Author: barendgehrels
Date: 2009-10-22 11:26:27 EDT (Thu, 22 Oct 2009)
New Revision: 57070
URL: http://svn.boost.org/trac/boost/changeset/57070
Log:
Various update/fixes for a.o. tests in length, perimeter, area, for_each
Added:
sandbox/ggl/formal_review_request/libs/ggl/Jamroot (contents, props changed)
sandbox/ggl/formal_review_request/libs/ggl/test/Jamfile.v2
- copied, changed from r56874, /sandbox/ggl/formal_review_request/libs/ggl/test/Jamroot
sandbox/ggl/formal_review_request/libs/ggl/test/algorithms/Jamfile.v2
- copied, changed from r57037, /sandbox/ggl/formal_review_request/libs/ggl/test/algorithms/Jamfile
sandbox/ggl/formal_review_request/libs/ggl/test/algorithms/for_each.cpp (contents, props changed)
sandbox/ggl/formal_review_request/libs/ggl/test/algorithms/length.cpp (contents, props changed)
sandbox/ggl/formal_review_request/libs/ggl/test/algorithms/perimeter.cpp (contents, props changed)
sandbox/ggl/formal_review_request/libs/ggl/test/algorithms/test_area.hpp (contents, props changed)
sandbox/ggl/formal_review_request/libs/ggl/test/algorithms/test_for_each.hpp (contents, props changed)
sandbox/ggl/formal_review_request/libs/ggl/test/algorithms/test_length.hpp (contents, props changed)
sandbox/ggl/formal_review_request/libs/ggl/test/algorithms/test_perimeter.hpp (contents, props changed)
sandbox/ggl/formal_review_request/libs/ggl/test/arithmetic/Jamfile.v2
- copied, changed from r56933, /sandbox/ggl/formal_review_request/libs/ggl/test/arithmetic/Jamfile
sandbox/ggl/formal_review_request/libs/ggl/test/core/Jamfile.v2
- copied, changed from r56874, /sandbox/ggl/formal_review_request/libs/ggl/test/core/Jamfile
sandbox/ggl/formal_review_request/libs/ggl/test/iterators/Jamfile.v2
- copied, changed from r56933, /sandbox/ggl/formal_review_request/libs/ggl/test/iterators/Jamfile
sandbox/ggl/formal_review_request/libs/ggl/test/multi/
sandbox/ggl/formal_review_request/libs/ggl/test/multi/Jamfile.v2 (contents, props changed)
sandbox/ggl/formal_review_request/libs/ggl/test/multi/algorithms/
sandbox/ggl/formal_review_request/libs/ggl/test/multi/algorithms/Jamfile.v2 (contents, props changed)
sandbox/ggl/formal_review_request/libs/ggl/test/multi/algorithms/multi_area.cpp (contents, props changed)
sandbox/ggl/formal_review_request/libs/ggl/test/multi/algorithms/multi_convex_hull.cpp (contents, props changed)
sandbox/ggl/formal_review_request/libs/ggl/test/multi/algorithms/multi_correct.cpp (contents, props changed)
sandbox/ggl/formal_review_request/libs/ggl/test/multi/algorithms/multi_for_each.cpp (contents, props changed)
sandbox/ggl/formal_review_request/libs/ggl/test/multi/algorithms/multi_length.cpp (contents, props changed)
sandbox/ggl/formal_review_request/libs/ggl/test/multi/algorithms/multi_perimeter.cpp (contents, props changed)
sandbox/ggl/formal_review_request/libs/ggl/test/multi/algorithms/multi_simplify.cpp (contents, props changed)
sandbox/ggl/formal_review_request/libs/ggl/test/point_concept/
sandbox/ggl/formal_review_request/libs/ggl/test/point_concept/Jamfile.v2 (contents, props changed)
sandbox/ggl/formal_review_request/libs/ggl/test/point_concept/array_point.cpp (contents, props changed)
sandbox/ggl/formal_review_request/libs/ggl/test/point_concept/function_asserting_a_point.hpp (contents, props changed)
sandbox/ggl/formal_review_request/libs/ggl/test/point_concept/function_requiring_a_point.hpp (contents, props changed)
sandbox/ggl/formal_review_request/libs/ggl/test/point_concept/point_with_incorrect_dimension.cpp (contents, props changed)
sandbox/ggl/formal_review_request/libs/ggl/test/point_concept/point_without_coordinate_type.cpp (contents, props changed)
sandbox/ggl/formal_review_request/libs/ggl/test/point_concept/point_without_dimension.cpp (contents, props changed)
sandbox/ggl/formal_review_request/libs/ggl/test/point_concept/point_without_getter.cpp (contents, props changed)
sandbox/ggl/formal_review_request/libs/ggl/test/point_concept/point_without_setter.cpp (contents, props changed)
sandbox/ggl/formal_review_request/libs/ggl/test/point_concept/well_formed_point.cpp (contents, props changed)
sandbox/ggl/formal_review_request/libs/ggl/test/point_concept/well_formed_point_traits.cpp (contents, props changed)
sandbox/ggl/formal_review_request/libs/ggl/test/strategies/Jamfile.v2
- copied, changed from r57037, /sandbox/ggl/formal_review_request/libs/ggl/test/strategies/Jamfile
Removed:
sandbox/ggl/formal_review_request/libs/ggl/test/Jamroot
sandbox/ggl/formal_review_request/libs/ggl/test/algorithms/Jamfile
sandbox/ggl/formal_review_request/libs/ggl/test/arithmetic/Jamfile
sandbox/ggl/formal_review_request/libs/ggl/test/core/Jamfile
sandbox/ggl/formal_review_request/libs/ggl/test/iterators/Jamfile
sandbox/ggl/formal_review_request/libs/ggl/test/strategies/Jamfile
Text files modified:
sandbox/ggl/formal_review_request/libs/ggl/example/c05_custom_point_pointer_example.cpp | 30 ++++++++++++-------
sandbox/ggl/formal_review_request/libs/ggl/test/Jamfile.v2 | 26 +++++++++++------
sandbox/ggl/formal_review_request/libs/ggl/test/algorithms/Jamfile.v2 | 40 +++++++++++++++++++++-----
sandbox/ggl/formal_review_request/libs/ggl/test/algorithms/area.cpp | 24 ++++------------
sandbox/ggl/formal_review_request/libs/ggl/test/arithmetic/Jamfile.v2 | 13 +++++---
sandbox/ggl/formal_review_request/libs/ggl/test/core/Jamfile.v2 | 33 +++++++++++----------
sandbox/ggl/formal_review_request/libs/ggl/test/core/access.cpp | 6 ++-
sandbox/ggl/formal_review_request/libs/ggl/test/iterators/Jamfile.v2 | 17 ++++++----
sandbox/ggl/formal_review_request/libs/ggl/test/strategies/Jamfile.v2 | 17 ++++++----
sandbox/ggl/formal_review_request/libs/ggl/test/test_common/test_point.hpp | 60 +++++++++++++++++++--------------------
sandbox/ggl/formal_review_request/libs/ggl/test/test_common/with_pointer.hpp | 31 ++++++++++++++------
11 files changed, 173 insertions(+), 124 deletions(-)
Added: sandbox/ggl/formal_review_request/libs/ggl/Jamroot
==============================================================================
--- (empty file)
+++ sandbox/ggl/formal_review_request/libs/ggl/Jamroot 2009-10-22 11:26:27 EDT (Thu, 22 Oct 2009)
@@ -0,0 +1,17 @@
+# Boost Build v2 Jamroot for Generic Geometry Library unit
+#
+# Copyright Bruno Lalande 2008
+# Copyright Barend Gehrels, Geodan Holding B.V. Amsterdam, the Netherlands.
+# Copyright (c) 2009 Mateusz Loskot <mateusz_at_[hidden]>
+#
+# 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)
+
+project
+ :
+ requirements
+ <include>../../boost
+ <include>.
+ <toolset>gcc:<cxxflags>-pedantic
+ ;
Modified: sandbox/ggl/formal_review_request/libs/ggl/example/c05_custom_point_pointer_example.cpp
==============================================================================
--- sandbox/ggl/formal_review_request/libs/ggl/example/c05_custom_point_pointer_example.cpp (original)
+++ sandbox/ggl/formal_review_request/libs/ggl/example/c05_custom_point_pointer_example.cpp 2009-10-22 11:26:27 EDT (Thu, 22 Oct 2009)
@@ -24,7 +24,7 @@
// Sample point, having x/y
struct my_point
{
- float x,y;
+ double x,y;
};
@@ -42,23 +42,31 @@
template<> struct dimension<my_point*> : boost::mpl::int_<2> {};
template<>
-struct access<my_point*>
+struct access<my_point*, 0>
{
- template <std::size_t I>
- static double get(const my_point* p)
+ static double get(my_point const* p)
{
- return I == 0 ? p->x : p->y;
- // Or implement an accessor with specializations
+ return p->x;
}
- template <int I>
- static void set(my_point* p, const double& value)
+ static void set(my_point* p, double const& value)
{
- // Or (better) implement an accessor with specializations
- if (I == 0) p->x = value;
- else if (I == 1) p->y = value;
+ p->x = value;
+ }
+};
+
+template<>
+struct access<my_point*, 1>
+{
+ static double get(my_point const* p)
+ {
+ return p->y;
}
+ static void set(my_point* p, double const& value)
+ {
+ p->y = value;
+ }
};
}} // namespace ggl::traits
Copied: sandbox/ggl/formal_review_request/libs/ggl/test/Jamfile.v2 (from r56874, /sandbox/ggl/formal_review_request/libs/ggl/test/Jamroot)
==============================================================================
--- /sandbox/ggl/formal_review_request/libs/ggl/test/Jamroot (original)
+++ sandbox/ggl/formal_review_request/libs/ggl/test/Jamfile.v2 2009-10-22 11:26:27 EDT (Thu, 22 Oct 2009)
@@ -1,17 +1,25 @@
-# Generic Geometry Library unit tests
+# test/Jamfile.v2 controls building of Generic Geometry Library unit tests
+#
+# Copyright (c) 2009 Mateusz Loskot <mateusz_at_[hidden]>
#
-# Copyright Bruno Lalande 2008
-# Copyright Barend Gehrels, Geodan Holding B.V. 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)
-project
- : requirements
- <include>../../../boost
+import testing ;
+
+project ggl-test
+ :
+ requirements
<include>.
- <toolset>gcc:<cxxflags>-pedantic
;
-import testing ;
-
+build-project core ;
+build-project point_concept ;
+# build-project geometries ;
+build-project arithmetic ;
+build-project algorithms ;
+build-project iterators ;
+build-project strategies ;
+# build-project util ;
+build-project multi ;
Deleted: sandbox/ggl/formal_review_request/libs/ggl/test/Jamroot
==============================================================================
--- sandbox/ggl/formal_review_request/libs/ggl/test/Jamroot 2009-10-22 11:26:27 EDT (Thu, 22 Oct 2009)
+++ (empty file)
@@ -1,17 +0,0 @@
-# Generic Geometry Library unit tests
-#
-# Copyright Bruno Lalande 2008
-# Copyright Barend Gehrels, Geodan Holding B.V. 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)
-
-project
- : requirements
- <include>../../../boost
- <include>.
- <toolset>gcc:<cxxflags>-pedantic
- ;
-
-import testing ;
-
Deleted: sandbox/ggl/formal_review_request/libs/ggl/test/algorithms/Jamfile
==============================================================================
--- sandbox/ggl/formal_review_request/libs/ggl/test/algorithms/Jamfile 2009-10-22 11:26:27 EDT (Thu, 22 Oct 2009)
+++ (empty file)
@@ -1,13 +0,0 @@
-# Generic Geometry Library unit tests
-#
-# Copyright Bruno Lalande 2008
-# Copyright Barend Gehrels, Geodan Holding B.V. 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)
-
-run area.cpp ;
-run correct.cpp ;
-run convex_hull.cpp ;
-run simplify.cpp ;
-run within.cpp ;
Copied: sandbox/ggl/formal_review_request/libs/ggl/test/algorithms/Jamfile.v2 (from r57037, /sandbox/ggl/formal_review_request/libs/ggl/test/algorithms/Jamfile)
==============================================================================
--- /sandbox/ggl/formal_review_request/libs/ggl/test/algorithms/Jamfile (original)
+++ sandbox/ggl/formal_review_request/libs/ggl/test/algorithms/Jamfile.v2 2009-10-22 11:26:27 EDT (Thu, 22 Oct 2009)
@@ -1,13 +1,37 @@
-# Generic Geometry Library unit tests
+# test/algorithms/Jamfile.v2
+#
+# Copyright (c) 2009 Mateusz Loskot <mateusz_at_[hidden]>
#
-# Copyright Bruno Lalande 2008
-# Copyright Barend Gehrels, Geodan Holding B.V. 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)
-run area.cpp ;
-run correct.cpp ;
-run convex_hull.cpp ;
-run simplify.cpp ;
-run within.cpp ;
+test-suite ggl-algorithms
+ :
+# [ run append.cpp ]
+ [ run area.cpp ]
+# [ run assign.cpp ]
+# [ run buffer.cpp ]
+# [ run centroid.cpp ]
+# [ run combine.cpp ]
+# [ run convert.cpp ]
+ [ run convex_hull.cpp ]
+ [ run correct.cpp ]
+# [ run disjoint.cpp ]
+# [ run distance.cpp ]
+# [ run envelope.cpp ]
+ [ run for_each.cpp ]
+# [ run intermediate.cpp ]
+# [ run intersection.cpp ]
+# [ run intersection_linestring.cpp ]
+# [ run intersection_polygon.cpp ]
+# [ run is_convex.cpp ]
+ [ run length.cpp ]
+# [ run make.cpp ]
+ [ run perimeter.cpp ]
+# [ run sectionalize.cpp ]
+# [ run selected.cpp ]
+ [ run simplify.cpp ]
+# [ run transform.cpp ]
+ [ run within.cpp ]
+ ;
Modified: sandbox/ggl/formal_review_request/libs/ggl/test/algorithms/area.cpp
==============================================================================
--- sandbox/ggl/formal_review_request/libs/ggl/test/algorithms/area.cpp (original)
+++ sandbox/ggl/formal_review_request/libs/ggl/test/algorithms/area.cpp 2009-10-22 11:26:27 EDT (Thu, 22 Oct 2009)
@@ -12,11 +12,13 @@
#include <ggl/extensions/gis/io/wkt/read_wkt.hpp>
+#include <ggl/geometries/point.hpp>
#include <ggl/geometries/box.hpp>
#include <ggl/geometries/nsphere.hpp>
#include <ggl/geometries/linear_ring.hpp>
#include <ggl/geometries/polygon.hpp>
+#include <algorithms/test_area.hpp>
@@ -33,21 +35,11 @@
BOOST_CHECK_CLOSE(d, 4 * 3.1415926535897932384626433832795, 0.001);
}
-template <typename Geometry>
-void test_geometry(std::string const& wkt, double expected)
-{
- Geometry geometry;
- read_wkt(wkt, geometry);
- double d = area(geometry);
- BOOST_CHECK_CLOSE(d, expected, 0.001);
-}
-
-
template <typename P>
void test_all()
{
- test_area_circle<P, double>();
+ //test_area_circle<P, double>();
test_geometry<ggl::box<P> >("POLYGON((0 0,2 2))", 4.0);
test_geometry<ggl::box<P> >("POLYGON((2 2,0 0))", 4.0);
@@ -72,13 +64,9 @@
int test_main(int, char* [])
{
- //test_all<int[2]>();
- //test_all<float[2]>(); not yet because cannot be copied, for polygon
- //test_all<double[2]>();
-
- //test_all<point_xy<int> >();
- //test_all<point_xy<float> >();
- test_all<ggl::point_xy<double> >();
+ test_all<ggl::point<int, 2, ggl::cs::cartesian> >();
+ test_all<ggl::point<float, 2, ggl::cs::cartesian> >();
+ test_all<ggl::point<double, 2, ggl::cs::cartesian> >();
return 0;
}
Added: sandbox/ggl/formal_review_request/libs/ggl/test/algorithms/for_each.cpp
==============================================================================
--- (empty file)
+++ sandbox/ggl/formal_review_request/libs/ggl/test/algorithms/for_each.cpp 2009-10-22 11:26:27 EDT (Thu, 22 Oct 2009)
@@ -0,0 +1,76 @@
+// Generic Geometry Library test file
+//
+// Copyright Barend Gehrels, 1995-2009, Geodan Holding B.V. 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 <ggl_test_common.hpp>
+
+#include <ggl/algorithms/for_each.hpp>
+
+#include <ggl/geometries/geometries.hpp>
+
+#include <algorithms/test_for_each.hpp>
+
+template <typename P>
+void test_all()
+{
+ test_geometry<P>
+ (
+ "POINT(1 1)"
+
+ // per point
+ , 1
+ , "POINT(101 1)"
+ , "POINT(101 100)"
+ // per segment
+ , ""
+ , 0
+ , "POINT(1 1)"
+ );
+ test_geometry<ggl::linestring<P> >
+ (
+ "LINESTRING(1 1,2 2)"
+
+ , 3
+ , "LINESTRING(101 1,102 2)"
+ , "LINESTRING(101 100,102 200)"
+
+ , "((1, 1), (2, 2))"
+ , std::sqrt(2.0)
+ , "LINESTRING(10 1,2 2)"
+ );
+ test_geometry<ggl::linear_ring<P> >
+ (
+ "POLYGON((1 1,1 4,4 4,4 1,1 1))"
+
+ , 11
+ , "POLYGON((101 1,101 4,104 4,104 1,101 1))"
+ , "POLYGON((101 100,101 400,104 400,104 100,101 100))"
+
+ , "((1, 1), (1, 4)) ((1, 4), (4, 4)) ((4, 4), (4, 1)) ((4, 1), (1, 1))"
+ , 4 * 3.0
+ , "POLYGON((10 1,10 4,4 4,4 1,1 1))"
+ );
+ test_geometry<ggl::polygon<P> >
+ (
+ "POLYGON((1 1,1 4,4 4,4 1,1 1),(2 2,3 2,3 3,2 3,2 2))"
+
+ , 23
+ , "POLYGON((101 1,101 4,104 4,104 1,101 1),(102 2,103 2,103 3,102 3,102 2))"
+ , "POLYGON((101 100,101 400,104 400,104 100,101 100),(102 200,103 200,103 300,102 300,102 200))"
+
+ , "((1, 1), (1, 4)) ((1, 4), (4, 4)) ((4, 4), (4, 1)) ((4, 1), (1, 1)) "
+ "((2, 2), (3, 2)) ((3, 2), (3, 3)) ((3, 3), (2, 3)) ((2, 3), (2, 2))"
+ , 4 * 3.0 + 4 * 1.0
+ , "POLYGON((10 1,10 4,4 4,4 1,1 1),(2 2,3 2,3 3,2 3,2 2))"
+ );
+}
+
+int test_main(int, char* [])
+{
+ test_all<ggl::point<double, 2, ggl::cs::cartesian> >();
+ return 0;
+}
Added: sandbox/ggl/formal_review_request/libs/ggl/test/algorithms/length.cpp
==============================================================================
--- (empty file)
+++ sandbox/ggl/formal_review_request/libs/ggl/test/algorithms/length.cpp 2009-10-22 11:26:27 EDT (Thu, 22 Oct 2009)
@@ -0,0 +1,99 @@
+// Generic Geometry Library test file
+//
+// Copyright Barend Gehrels, 1995-2009, Geodan Holding B.V. 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 <ggl_test_common.hpp>
+
+#include <ggl/algorithms/length.hpp>
+
+#include <ggl/extensions/gis/io/wkt/read_wkt.hpp>
+
+#include <ggl/geometries/geometries.hpp>
+
+#include <algorithms/test_length.hpp>
+
+
+namespace ggl { namespace traits {
+
+template <typename Point>
+struct tag<std::pair<Point, Point> >
+{
+ typedef segment_tag type;
+};
+
+template <typename Point>
+struct point_type<std::pair<Point, Point> >
+{
+ typedef Point type;
+};
+
+template <typename Point, std::size_t Dimension>
+struct indexed_access<std::pair<Point, Point>, 0, Dimension>
+{
+ typedef typename ggl::coordinate_type<Point>::type coordinate_type;
+
+ static inline coordinate_type get(std::pair<Point, Point> const& s)
+ {
+ return ggl::get<Dimension>(s.first);
+ }
+
+ static inline void set(std::pair<Point, Point>& s, coordinate_type const& value)
+ {
+ ggl::set<Dimension>(s.first, value);
+ }
+};
+
+
+template <typename Point, std::size_t Dimension>
+struct indexed_access<std::pair<Point, Point>, 1, Dimension>
+{
+ typedef typename ggl::coordinate_type<Point>::type coordinate_type;
+
+ static inline coordinate_type get(std::pair<Point, Point> const& s)
+ {
+ return ggl::get<Dimension>(s.second);
+ }
+
+ static inline void set(std::pair<Point, Point>& s, coordinate_type const& value)
+ {
+ ggl::set<Dimension>(s.second, value);
+ }
+};
+
+}} // namespace traits
+
+
+
+template <typename P>
+void test_all()
+{
+ // 3-4-5 triangle
+ //test_geometry<std::pair<P, P> >("LINESTRING(0 0,3 4)", 5);
+
+
+ // 3-4-5 plus 1-1
+ test_geometry<ggl::linestring<P> >("LINESTRING(0 0,3 4,4 3)", 5 + sqrt(2.0));
+
+ // Geometries with length zero
+ test_geometry<P>("POINT(0 0)", 0);
+ test_geometry<ggl::polygon<P> >("POLYGON((0 0,0 1,1 1,1 0,0 0))", 0);
+}
+
+int test_main(int, char* [])
+{
+ test_all<ggl::point_xy<int> >();
+ test_all<ggl::point_xy<float> >();
+ test_all<ggl::point_xy<double> >();
+
+#if defined(HAVE_CLN)
+ test_all<ggl::point_xy<boost::numeric_adaptor::cln_value_type> >();
+#endif
+#if defined(HAVE_GMP)
+ test_all<ggl::point_xy<boost::numeric_adaptor::gmp_value_type> >();
+#endif
+
+ return 0;
+}
Added: sandbox/ggl/formal_review_request/libs/ggl/test/algorithms/perimeter.cpp
==============================================================================
--- (empty file)
+++ sandbox/ggl/formal_review_request/libs/ggl/test/algorithms/perimeter.cpp 2009-10-22 11:26:27 EDT (Thu, 22 Oct 2009)
@@ -0,0 +1,47 @@
+// Generic Geometry Library test file
+//
+// Copyright Barend Gehrels, 1995-2009, Geodan Holding B.V. 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 <ggl_test_common.hpp>
+
+#include <ggl/algorithms/perimeter.hpp>
+
+#include <ggl/extensions/gis/io/wkt/read_wkt.hpp>
+
+#include <ggl/geometries/geometries.hpp>
+
+#include <algorithms/test_perimeter.hpp>
+
+
+template <typename P>
+void test_all()
+{
+ // 3-4-5 triangle
+ //test_geometry<std::pair<P, P> >("LINESTRING(0 0,3 4)", 5);
+
+ test_geometry<ggl::linear_ring<P> >(
+ "POLYGON((0 0,0 1,1 1,1 0,0 0))", 4);
+ test_geometry<ggl::polygon<P> >(
+ "POLYGON((0 0,0 1,1 0,0 0))", 1.0 + 1.0 + sqrt(2.0));
+ test_geometry<ggl::polygon<P> >(
+ "POLYGON((0 0,0 4,4 4,4 0,0 0),(1 1,2 1,2 2,1 2,1 1))", 20);
+}
+
+int test_main(int, char* [])
+{
+ //test_all<ggl::point_xy<int> >();
+ test_all<ggl::point_xy<float> >();
+ test_all<ggl::point_xy<double> >();
+
+#if defined(HAVE_CLN)
+ test_all<ggl::point_xy<boost::numeric_adaptor::cln_value_type> >();
+#endif
+#if defined(HAVE_GMP)
+ test_all<ggl::point_xy<boost::numeric_adaptor::gmp_value_type> >();
+#endif
+
+ return 0;
+}
Added: sandbox/ggl/formal_review_request/libs/ggl/test/algorithms/test_area.hpp
==============================================================================
--- (empty file)
+++ sandbox/ggl/formal_review_request/libs/ggl/test/algorithms/test_area.hpp 2009-10-22 11:26:27 EDT (Thu, 22 Oct 2009)
@@ -0,0 +1,59 @@
+// Generic Geometry Library test file
+//
+// Copyright Barend Gehrels, 1995-2009, Geodan Holding B.V. Amsterdam, the Netherlands.
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef GGL_TEST_AREA_HPP
+#define GGL_TEST_AREA_HPP
+
+// Test-functionality, shared between single and multi tests
+
+
+template <typename Geometry>
+void test_area(Geometry const& geometry, long double expected_area)
+{
+ long double area = ggl::area(geometry);
+
+#ifdef GGL_TEST_DEBUG
+ std::ostringstream out;
+ out << typeid(typename ggl::coordinate_type<Geometry>::type).name()
+ << std::endl
+ << typeid(typename ggl::area_result<Geometry>::type).name()
+ << std::endl
+ << "area : " << ggl::area(geometry)
+ << std::endl;
+ std::cout << out.str();
+#endif
+
+ BOOST_CHECK_CLOSE(area, expected_area, 0.0001);
+
+ // Test with explicitly defined strategies
+ ggl::strategy::area::by_triangles
+ <
+ typename ggl::point_type<Geometry>::type
+ > strategy1;
+
+ area = ggl::area(geometry, strategy1);
+
+ ggl::strategy::area::by_triangles
+ <
+ typename ggl::point_type<Geometry>::type,
+ long double
+ > strategy2;
+
+ area = ggl::area(geometry, strategy2);
+}
+
+
+template <typename Geometry>
+void test_geometry(std::string const& wkt, double expected_area)
+{
+ Geometry geometry;
+ ggl::read_wkt(wkt, geometry);
+ test_area(geometry, expected_area);
+}
+
+
+#endif
Added: sandbox/ggl/formal_review_request/libs/ggl/test/algorithms/test_for_each.hpp
==============================================================================
--- (empty file)
+++ sandbox/ggl/formal_review_request/libs/ggl/test/algorithms/test_for_each.hpp 2009-10-22 11:26:27 EDT (Thu, 22 Oct 2009)
@@ -0,0 +1,212 @@
+// Generic Geometry Library test file
+//
+// Copyright Barend Gehrels, 1995-2009, Geodan Holding B.V. Amsterdam, the Netherlands.
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef GGL_TEST_FOR_EACH_HPP
+#define GGL_TEST_FOR_EACH_HPP
+
+// Test-functionality, shared between single and multi tests
+#include <ggl/algorithms/distance.hpp>
+#include <ggl/extensions/gis/io/wkt/wkt.hpp>
+#include <ggl/util/write_dsv.hpp>
+
+
+template<typename Point>
+inline void translate_x_function(Point& p)
+{
+ ggl::set<0>(p, ggl::get<0>(p) + 100.0);
+}
+
+template<typename Point>
+struct scale_y_functor
+{
+ inline void operator()(Point& p)
+ {
+ ggl::set<1>(p, ggl::get<1>(p) * 100.0);
+ }
+};
+
+template<typename Point>
+struct sum_x_functor
+{
+ int sum;
+
+ sum_x_functor()
+ : sum(0)
+ {}
+
+ inline void operator()(Point const& p)
+ {
+ sum += int(ggl::get<0>(p));
+ }
+};
+
+// Per segment
+static std::ostringstream g_out;
+
+template<typename Segment>
+inline void stream_segment(Segment const& s)
+{
+ g_out << ggl::dsv(s) << " ";
+}
+
+template<typename Segment>
+struct sum_segment_length
+{
+ double sum;
+
+ sum_segment_length()
+ : sum(0)
+ {}
+ inline void operator()(Segment const& s)
+ {
+ sum += ggl::distance(s.first, s.second);
+ }
+};
+
+template<typename Segment>
+inline void modify_segment(Segment& s)
+{
+ if (ggl::math::equals(ggl::get<0,0>(s), 1.0))
+ {
+ ggl::set<0,0>(s, 10.0);
+ }
+}
+
+
+template <typename Geometry>
+void test_per_point_const(Geometry const& geometry, int expected)
+{
+ typedef typename ggl::point_type<Geometry>::type point_type;
+
+ sum_x_functor<point_type> functor;
+ functor = ggl::for_each_point(geometry, functor);
+ BOOST_CHECK_EQUAL(functor.sum, expected);
+}
+
+template <typename Geometry>
+void test_per_point_non_const(Geometry& geometry,
+ std::string const& expected1,
+ std::string const& expected2)
+{
+ typedef typename ggl::point_type<Geometry>::type point_type;
+
+ // function
+ ggl::for_each_point(geometry, translate_x_function<point_type>);
+ std::ostringstream out1;
+ out1 << ggl::wkt(geometry);
+
+ BOOST_CHECK_MESSAGE(out1.str() == expected1,
+ "for_each_point: "
+ << " expected " << expected1
+ << " got " << ggl::wkt(geometry));
+
+ // functor
+ ggl::for_each_point(geometry, scale_y_functor<point_type>());
+
+ std::ostringstream out2;
+ out2 << ggl::wkt(geometry);
+
+ BOOST_CHECK_MESSAGE(out2.str() == expected2,
+ "for_each_point: "
+ << " expected " << expected2
+ << " got " << ggl::wkt(geometry));
+}
+
+
+template <typename Geometry>
+void test_per_point(std::string const& wkt
+ , int expected_sum_x
+ , std::string const& expected1
+ , std::string const& expected2
+ )
+{
+ Geometry geometry;
+ ggl::read_wkt(wkt, geometry);
+ test_per_point_const(geometry, expected_sum_x);
+ test_per_point_non_const(geometry, expected1, expected2);
+}
+
+
+
+template <typename Geometry>
+void test_per_segment_const(Geometry const& geometry,
+ std::string const& expected_dsv,
+ double expected_length)
+{
+ typedef typename ggl::point_type<Geometry>::type point_type;
+
+ // function
+ g_out.str("");
+ g_out.clear();
+ ggl::for_each_segment(geometry,
+ stream_segment<ggl::segment<const point_type> >);
+ std::string out = g_out.str();
+ boost::trim(out);
+ BOOST_CHECK_EQUAL(out, expected_dsv);
+
+ // functor
+ sum_segment_length<ggl::segment<const point_type> > functor;
+ functor = ggl::for_each_segment(geometry, functor);
+
+ BOOST_CHECK_EQUAL(functor.sum, expected_length);
+}
+
+
+template <typename Geometry>
+void test_per_segment_non_const(Geometry& geometry,
+ std::string const& expected_wkt)
+{
+ typedef typename ggl::point_type<Geometry>::type point_type;
+
+ // function
+ ggl::for_each_segment(geometry,
+ modify_segment<ggl::segment<point_type> >);
+
+ std::ostringstream out;
+ out << ggl::wkt(geometry);
+
+ BOOST_CHECK_MESSAGE(out.str() == expected_wkt,
+ "for_each_segment: "
+ << " expected " << expected_wkt
+ << " got " << ggl::wkt(geometry));
+
+ // function is working here, functor works for all others,
+ // it will also work here.
+}
+
+
+template <typename Geometry>
+void test_per_segment(std::string const& wkt
+ , std::string const& expected_dsv
+ , double expected_length
+ , std::string const& expected_wkt
+ )
+{
+ Geometry geometry;
+ ggl::read_wkt(wkt, geometry);
+ test_per_segment_const(geometry, expected_dsv, expected_length);
+ test_per_segment_non_const(geometry, expected_wkt);
+}
+
+
+
+template <typename Geometry>
+void test_geometry(std::string const& wkt
+ , int expected_sum_x
+ , std::string const& expected1
+ , std::string const& expected2
+ , std::string const& expected_dsv
+ , double expected_length
+ , std::string const& expected_wkt
+ )
+{
+ test_per_point<Geometry>(wkt, expected_sum_x, expected1, expected2);
+ test_per_segment<Geometry>(wkt, expected_dsv, expected_length, expected_wkt);
+}
+
+
+#endif
Added: sandbox/ggl/formal_review_request/libs/ggl/test/algorithms/test_length.hpp
==============================================================================
--- (empty file)
+++ sandbox/ggl/formal_review_request/libs/ggl/test/algorithms/test_length.hpp 2009-10-22 11:26:27 EDT (Thu, 22 Oct 2009)
@@ -0,0 +1,43 @@
+// Generic Geometry Library test file
+//
+// Copyright Barend Gehrels, 1995-2009, Geodan Holding B.V. Amsterdam, the Netherlands.
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef GGL_TEST_LENGTH_HPP
+#define GGL_TEST_LENGTH_HPP
+
+// Test-functionality, shared between single and multi tests
+
+
+template <typename Geometry>
+void test_length(Geometry const& geometry, long double expected_length)
+{
+ long double length = ggl::length(geometry);
+
+#ifdef GGL_TEST_DEBUG
+ std::ostringstream out;
+ out << typeid(typename ggl::coordinate_type<Geometry>::type).name()
+ << std::endl
+ << typeid(typename ggl::length_result<Geometry>::type).name()
+ << std::endl
+ << "length : " << ggl::length(geometry)
+ << std::endl;
+ std::cout << out.str();
+#endif
+
+ BOOST_CHECK_CLOSE(length, expected_length, 0.0001);
+}
+
+
+template <typename Geometry>
+void test_geometry(std::string const& wkt, double expected_length)
+{
+ Geometry geometry;
+ ggl::read_wkt(wkt, geometry);
+ test_length(geometry, expected_length);
+}
+
+
+#endif
Added: sandbox/ggl/formal_review_request/libs/ggl/test/algorithms/test_perimeter.hpp
==============================================================================
--- (empty file)
+++ sandbox/ggl/formal_review_request/libs/ggl/test/algorithms/test_perimeter.hpp 2009-10-22 11:26:27 EDT (Thu, 22 Oct 2009)
@@ -0,0 +1,43 @@
+// Generic Geometry Library test file
+//
+// Copyright Barend Gehrels, 1995-2009, Geodan Holding B.V. Amsterdam, the Netherlands.
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef GGL_TEST_PERIMETER_HPP
+#define GGL_TEST_PERIMETER_HPP
+
+// Test-functionality, shared between single and multi tests
+
+
+template <typename Geometry>
+void test_perimeter(Geometry const& geometry, long double expected_perimeter)
+{
+ long double perimeter = ggl::perimeter(geometry);
+
+#ifdef GGL_TEST_DEBUG
+ std::ostringstream out;
+ out << typeid(typename ggl::coordinate_type<Geometry>::type).name()
+ << std::endl
+ << typeid(typename ggl::perimeter_result<Geometry>::type).name()
+ << std::endl
+ << "perimeter : " << ggl::perimeter(geometry)
+ << std::endl;
+ std::cout << out.str();
+#endif
+
+ BOOST_CHECK_CLOSE(perimeter, expected_perimeter, 0.0001);
+}
+
+
+template <typename Geometry>
+void test_geometry(std::string const& wkt, double expected_perimeter)
+{
+ Geometry geometry;
+ ggl::read_wkt(wkt, geometry);
+ test_perimeter(geometry, expected_perimeter);
+}
+
+
+#endif
Deleted: sandbox/ggl/formal_review_request/libs/ggl/test/arithmetic/Jamfile
==============================================================================
--- sandbox/ggl/formal_review_request/libs/ggl/test/arithmetic/Jamfile 2009-10-22 11:26:27 EDT (Thu, 22 Oct 2009)
+++ (empty file)
@@ -1,10 +0,0 @@
-# Generic Geometry Library unit tests
-#
-# Copyright Bruno Lalande 2008
-# Copyright Barend Gehrels, Geodan Holding B.V. 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)
-
-run arithmetic.cpp ;
-run dot_product.cpp ;
Copied: sandbox/ggl/formal_review_request/libs/ggl/test/arithmetic/Jamfile.v2 (from r56933, /sandbox/ggl/formal_review_request/libs/ggl/test/arithmetic/Jamfile)
==============================================================================
--- /sandbox/ggl/formal_review_request/libs/ggl/test/arithmetic/Jamfile (original)
+++ sandbox/ggl/formal_review_request/libs/ggl/test/arithmetic/Jamfile.v2 2009-10-22 11:26:27 EDT (Thu, 22 Oct 2009)
@@ -1,10 +1,13 @@
-# Generic Geometry Library unit tests
+# test/arithmetic/Jamfile.v2
+#
+# Copyright (c) 2009 Mateusz Loskot <mateusz_at_[hidden]>
#
-# Copyright Bruno Lalande 2008
-# Copyright Barend Gehrels, Geodan Holding B.V. 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)
-run arithmetic.cpp ;
-run dot_product.cpp ;
+test-suite ggl-arithmetic
+ :
+ [ run arithmetic.cpp ]
+ [ run dot_product.cpp ]
+ ;
Deleted: sandbox/ggl/formal_review_request/libs/ggl/test/core/Jamfile
==============================================================================
--- sandbox/ggl/formal_review_request/libs/ggl/test/core/Jamfile 2009-10-22 11:26:27 EDT (Thu, 22 Oct 2009)
+++ (empty file)
@@ -1,21 +0,0 @@
-# Generic Geometry Library unit tests
-#
-# Copyright Bruno Lalande 2008
-# Copyright Barend Gehrels, Geodan Holding B.V. 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)
-
-run access.cpp ;
-run coordinate_dimension.cpp ;
-run coordinate_system.cpp ;
-run coordinate_type.cpp ;
-run geometry_id.cpp ;
-run point_type.cpp ;
-run radian_access.cpp ;
-run reverse_dispatch.cpp ;
-run ring.cpp ;
-run tag.cpp ;
-run topological_dimension.cpp ;
-
-
Copied: sandbox/ggl/formal_review_request/libs/ggl/test/core/Jamfile.v2 (from r56874, /sandbox/ggl/formal_review_request/libs/ggl/test/core/Jamfile)
==============================================================================
--- /sandbox/ggl/formal_review_request/libs/ggl/test/core/Jamfile (original)
+++ sandbox/ggl/formal_review_request/libs/ggl/test/core/Jamfile.v2 2009-10-22 11:26:27 EDT (Thu, 22 Oct 2009)
@@ -1,21 +1,22 @@
-# Generic Geometry Library unit tests
+# test/core/Jamfile.v2
+#
+# Copyright (c) 2009 Mateusz Loskot <mateusz_at_[hidden]>
#
-# Copyright Bruno Lalande 2008
-# Copyright Barend Gehrels, Geodan Holding B.V. 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)
-run access.cpp ;
-run coordinate_dimension.cpp ;
-run coordinate_system.cpp ;
-run coordinate_type.cpp ;
-run geometry_id.cpp ;
-run point_type.cpp ;
-run radian_access.cpp ;
-run reverse_dispatch.cpp ;
-run ring.cpp ;
-run tag.cpp ;
-run topological_dimension.cpp ;
-
-
+test-suite ggl-core
+ :
+ [ run access.cpp ]
+ [ run coordinate_dimension.cpp ]
+ [ run coordinate_system.cpp ]
+ [ run coordinate_type.cpp ]
+ [ run geometry_id.cpp ]
+ [ run point_type.cpp ]
+ [ run radian_access.cpp ]
+ [ run reverse_dispatch.cpp ]
+ [ run ring.cpp ]
+ [ run tag.cpp ]
+ [ run topological_dimension.cpp ]
+ ;
Modified: sandbox/ggl/formal_review_request/libs/ggl/test/core/access.cpp
==============================================================================
--- sandbox/ggl/formal_review_request/libs/ggl/test/core/access.cpp (original)
+++ sandbox/ggl/formal_review_request/libs/ggl/test/core/access.cpp 2009-10-22 11:26:27 EDT (Thu, 22 Oct 2009)
@@ -87,7 +87,8 @@
test_get_set<P>();
// N-SPHERE, setting sphere center
- test_get_set<ggl::nsphere<P, double> >();
+ test_get_set<ggl::nsphere<P, coordinate_type> >();
+
// BOX, setting left/right/top/bottom
ggl::box<P> b;
@@ -116,9 +117,10 @@
test_get_set<int[2]>();
test_get_set<float[2]>();
test_get_set<double[2]>();
-
test_get_set<double[3]>();
+ test_get_set<boost::tuple<double, double> >();
+
test_all<ggl::point<int, 2, ggl::cs::cartesian> >();
test_all<ggl::point<float, 2, ggl::cs::cartesian> >();
test_all<ggl::point<double, 2, ggl::cs::cartesian> >();
Deleted: sandbox/ggl/formal_review_request/libs/ggl/test/iterators/Jamfile
==============================================================================
--- sandbox/ggl/formal_review_request/libs/ggl/test/iterators/Jamfile 2009-10-22 11:26:27 EDT (Thu, 22 Oct 2009)
+++ (empty file)
@@ -1,12 +0,0 @@
-# Generic Geometry Library unit tests
-#
-# Copyright Bruno Lalande 2008
-# Copyright Barend Gehrels, Geodan Holding B.V. 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)
-
-run circular_iterator.cpp ;
-run ever_circling_iterator.cpp ;
-run vertex_iterator.cpp ;
-run segment_iterator.cpp ;
Copied: sandbox/ggl/formal_review_request/libs/ggl/test/iterators/Jamfile.v2 (from r56933, /sandbox/ggl/formal_review_request/libs/ggl/test/iterators/Jamfile)
==============================================================================
--- /sandbox/ggl/formal_review_request/libs/ggl/test/iterators/Jamfile (original)
+++ sandbox/ggl/formal_review_request/libs/ggl/test/iterators/Jamfile.v2 2009-10-22 11:26:27 EDT (Thu, 22 Oct 2009)
@@ -1,12 +1,15 @@
-# Generic Geometry Library unit tests
+# ggl/test/iterators/Jamfile.v2
+#
+# Copyright (c) 2009 Mateusz Loskot <mateusz_at_[hidden]>
#
-# Copyright Bruno Lalande 2008
-# Copyright Barend Gehrels, Geodan Holding B.V. 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)
-run circular_iterator.cpp ;
-run ever_circling_iterator.cpp ;
-run vertex_iterator.cpp ;
-run segment_iterator.cpp ;
+test-suite ggl-iterators
+ :
+ [ run circular_iterator.cpp ]
+ [ run ever_circling_iterator.cpp ]
+ [ run segment_iterator.cpp ]
+ [ run vertex_iterator.cpp ]
+ ;
Added: sandbox/ggl/formal_review_request/libs/ggl/test/multi/Jamfile.v2
==============================================================================
--- (empty file)
+++ sandbox/ggl/formal_review_request/libs/ggl/test/multi/Jamfile.v2 2009-10-22 11:26:27 EDT (Thu, 22 Oct 2009)
@@ -0,0 +1,9 @@
+# test/arithmetic/Jamfile.v2
+#
+# Copyright (c) 2009 Barend Gehrels
+#
+# 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)
+
+build-project algorithms ;
\ No newline at end of file
Added: sandbox/ggl/formal_review_request/libs/ggl/test/multi/algorithms/Jamfile.v2
==============================================================================
--- (empty file)
+++ sandbox/ggl/formal_review_request/libs/ggl/test/multi/algorithms/Jamfile.v2 2009-10-22 11:26:27 EDT (Thu, 22 Oct 2009)
@@ -0,0 +1,18 @@
+# test/arithmetic/Jamfile.v2
+#
+# Copyright (c) 2009 Mateusz Loskot <mateusz_at_[hidden]>
+#
+# 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 ggl-multi-algorithms
+ :
+ [ run multi_area.cpp ]
+ [ run multi_convex_hull.cpp ]
+ [ run multi_correct.cpp ]
+ [ run multi_for_each.cpp ]
+ [ run multi_length.cpp ]
+ [ run multi_perimeter.cpp ]
+ [ run multi_simplify.cpp ]
+ ;
Added: sandbox/ggl/formal_review_request/libs/ggl/test/multi/algorithms/multi_area.cpp
==============================================================================
--- (empty file)
+++ sandbox/ggl/formal_review_request/libs/ggl/test/multi/algorithms/multi_area.cpp 2009-10-22 11:26:27 EDT (Thu, 22 Oct 2009)
@@ -0,0 +1,33 @@
+// Generic Geometry Library
+//
+// Copyright Barend Gehrels, Geodan B.V. 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 <ggl_test_common.hpp>
+
+#include <ggl/algorithms/area.hpp>
+#include <ggl/multi/algorithms/area.hpp>
+
+#include <ggl/extensions/gis/io/wkt/wkt.hpp>
+
+#include <ggl/geometries/polygon.hpp>
+#include <ggl/multi/geometries/multi_polygon.hpp>
+
+#include <algorithms/test_area.hpp>
+
+
+template <typename P>
+void test_all()
+{
+ typedef ggl::multi_polygon<ggl::polygon<P> > mp;
+ test_geometry<mp>("MULTIPOLYGON(((0 0,0 7,4 2,2 0,0 0)))", 16.0);
+}
+
+int test_main( int , char* [] )
+{
+ test_all<ggl::point_xy<double> >();
+
+ return 0;
+}
Added: sandbox/ggl/formal_review_request/libs/ggl/test/multi/algorithms/multi_convex_hull.cpp
==============================================================================
--- (empty file)
+++ sandbox/ggl/formal_review_request/libs/ggl/test/multi/algorithms/multi_convex_hull.cpp 2009-10-22 11:26:27 EDT (Thu, 22 Oct 2009)
@@ -0,0 +1,57 @@
+// Generic Geometry Library test file
+//
+// Copyright Barend Gehrels, 1995-2009, Geodan Holding B.V. Amsterdam, the Netherlands.
+// Copyright Bruno Lalande 2008, 2009
+// 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 <cstddef>
+#include <iterator>
+#include <string>
+
+
+#include <ggl_test_common.hpp>
+
+#include <ggl/algorithms/area.hpp>
+#include <ggl/algorithms/convex_hull.hpp>
+#include <ggl/algorithms/num_points.hpp>
+#include <ggl/geometries/geometries.hpp>
+
+#include <ggl/extensions/gis/io/wkt/read_wkt.hpp>
+
+#include <ggl/multi/core/point_type.hpp>
+
+#include <ggl/multi/algorithms/num_points.hpp>
+#include <ggl/multi/algorithms/convex_hull.hpp>
+
+#include <ggl/extensions/gis/io/wkt/wkt.hpp>
+
+#include <ggl/multi/geometries/multi_point.hpp>
+#include <ggl/multi/geometries/multi_linestring.hpp>
+#include <ggl/multi/geometries/multi_polygon.hpp>
+
+
+#include <algorithms/test_convex_hull.hpp>
+
+
+template <typename P>
+void test_all()
+{
+ typedef ggl::multi_point<P> mp;
+ typedef ggl::multi_linestring<ggl::linestring<P> > ml;
+ typedef ggl::multi_polygon<ggl::polygon<P> > mpoly;
+ test_geometry<mp>("multipoint((1.1 1.1), (2.5 2.1), (3.1 3.1), (4.9 1.1), (3.1 1.9))", 5, 4, 3.8);
+ test_geometry<ml>("multilinestring((2 4, 3 4, 3 5), (4 3,4 4,5 4))", 6, 5, 3.0);
+ test_geometry<mpoly>("multipolygon(((1 4,1 6,2 5,3 5,4 6,4 4,1 4)), ((4 2,4 3,6 3,6 2,4 2)))", 12, 7, 14.0);
+}
+
+
+int test_main(int, char* [])
+{
+ //test_all<ggl::point_xy<int> >();
+ //test_all<ggl::point_xy<float> >();
+ test_all<ggl::point_xy<double> >();
+
+ return 0;
+}
Added: sandbox/ggl/formal_review_request/libs/ggl/test/multi/algorithms/multi_correct.cpp
==============================================================================
--- (empty file)
+++ sandbox/ggl/formal_review_request/libs/ggl/test/multi/algorithms/multi_correct.cpp 2009-10-22 11:26:27 EDT (Thu, 22 Oct 2009)
@@ -0,0 +1,54 @@
+// Generic Geometry Library
+//
+// Copyright Barend Gehrels, Geodan B.V. 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 <ggl_test_common.hpp>
+
+#include <ggl/algorithms/correct.hpp>
+#include <ggl/multi/algorithms/correct.hpp>
+
+#include <ggl/extensions/gis/io/wkt/wkt.hpp>
+
+#include <ggl/geometries/box.hpp>
+#include <ggl/geometries/linear_ring.hpp>
+#include <ggl/geometries/linestring.hpp>
+#include <ggl/geometries/point.hpp>
+#include <ggl/geometries/polygon.hpp>
+#include <ggl/multi/geometries/multi_polygon.hpp>
+
+
+template <typename Geometry>
+void test_geometry(std::string const& wkt, std::string const& expected)
+{
+ Geometry geometry;
+
+ ggl::read_wkt(wkt, geometry);
+ ggl::correct(geometry);
+
+ std::ostringstream out;
+ out << ggl::wkt(geometry);
+
+ BOOST_CHECK_EQUAL(out.str(), expected);
+}
+
+template <typename P>
+void test_all()
+{
+ typedef ggl::multi_polygon<ggl::polygon<P> > cw_type;
+ std::string cw_mp =
+ "MULTIPOLYGON(((0 0,0 1,1 1,1 0,0 0)))";
+ test_geometry<cw_type>(cw_mp, cw_mp);
+
+ test_geometry<cw_type>("MULTIPOLYGON(((0 0,1 0,1 1,0 1,0 0)))",
+ cw_mp);
+}
+
+int test_main( int , char* [] )
+{
+ test_all<ggl::point_xy<double> >();
+
+ return 0;
+}
Added: sandbox/ggl/formal_review_request/libs/ggl/test/multi/algorithms/multi_for_each.cpp
==============================================================================
--- (empty file)
+++ sandbox/ggl/formal_review_request/libs/ggl/test/multi/algorithms/multi_for_each.cpp 2009-10-22 11:26:27 EDT (Thu, 22 Oct 2009)
@@ -0,0 +1,78 @@
+// Generic Geometry Library
+//
+// Copyright Barend Gehrels, Geodan B.V. 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 <ggl_test_common.hpp>
+
+#include <ggl/algorithms/for_each.hpp>
+#include <ggl/multi/algorithms/for_each.hpp>
+
+#include <ggl/extensions/gis/io/wkt/wkt.hpp>
+
+#include <ggl/geometries/box.hpp>
+#include <ggl/geometries/linear_ring.hpp>
+#include <ggl/geometries/linestring.hpp>
+#include <ggl/geometries/point.hpp>
+#include <ggl/geometries/polygon.hpp>
+
+#include <ggl/multi/geometries/multi_point.hpp>
+#include <ggl/multi/geometries/multi_linestring.hpp>
+#include <ggl/multi/geometries/multi_polygon.hpp>
+
+#include <algorithms/test_for_each.hpp>
+
+
+template <typename P>
+void test_all()
+{
+ test_geometry<ggl::multi_point<P> >
+ (
+ "MULTIPOINT((1 1))"
+
+ // per point
+ , 1
+ , "MULTIPOINT((101 1))"
+ , "MULTIPOINT((101 100))"
+ // per segment
+ , ""
+ , 0
+ , "MULTIPOINT((1 1))"
+ );
+
+ test_geometry<ggl::multi_linestring<ggl::linestring<P> > >
+ (
+ "MULTILINESTRING((1 1,2 2))"
+
+ , 3
+ , "MULTILINESTRING((101 1,102 2))"
+ , "MULTILINESTRING((101 100,102 200))"
+
+ , "((1, 1), (2, 2))"
+ , std::sqrt(2.0)
+ , "MULTILINESTRING((10 1,2 2))"
+ );
+
+ typedef ggl::multi_polygon<ggl::polygon<P> > mp;
+ test_geometry<mp>
+ (
+ "MULTIPOLYGON(((1 1,1 4,4 4,4 1,1 1)))"
+
+ , 11
+ , "MULTIPOLYGON(((101 1,101 4,104 4,104 1,101 1)))"
+ , "MULTIPOLYGON(((101 100,101 400,104 400,104 100,101 100)))"
+
+ , "((1, 1), (1, 4)) ((1, 4), (4, 4)) ((4, 4), (4, 1)) ((4, 1), (1, 1))"
+ , 4 * 3.0
+ , "MULTIPOLYGON(((10 1,10 4,4 4,4 1,1 1)))"
+ );
+}
+
+int test_main( int , char* [] )
+{
+ test_all<ggl::point_xy<double> >();
+
+ return 0;
+}
Added: sandbox/ggl/formal_review_request/libs/ggl/test/multi/algorithms/multi_length.cpp
==============================================================================
--- (empty file)
+++ sandbox/ggl/formal_review_request/libs/ggl/test/multi/algorithms/multi_length.cpp 2009-10-22 11:26:27 EDT (Thu, 22 Oct 2009)
@@ -0,0 +1,33 @@
+// Generic Geometry Library
+//
+// Copyright Barend Gehrels, Geodan B.V. 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 <ggl_test_common.hpp>
+
+#include <ggl/algorithms/length.hpp>
+#include <ggl/multi/algorithms/length.hpp>
+
+#include <ggl/extensions/gis/io/wkt/wkt.hpp>
+
+#include <ggl/geometries/linestring.hpp>
+#include <ggl/multi/geometries/multi_linestring.hpp>
+
+#include <algorithms/test_length.hpp>
+
+
+template <typename P>
+void test_all()
+{
+ test_geometry<ggl::multi_linestring<ggl::linestring<P> > >
+ ("MULTILINESTRING((0 0,3 4,4 3))", 5 + sqrt(2.0));
+}
+
+int test_main( int , char* [] )
+{
+ test_all<ggl::point_xy<double> >();
+
+ return 0;
+}
Added: sandbox/ggl/formal_review_request/libs/ggl/test/multi/algorithms/multi_perimeter.cpp
==============================================================================
--- (empty file)
+++ sandbox/ggl/formal_review_request/libs/ggl/test/multi/algorithms/multi_perimeter.cpp 2009-10-22 11:26:27 EDT (Thu, 22 Oct 2009)
@@ -0,0 +1,33 @@
+// Generic Geometry Library
+//
+// Copyright Barend Gehrels, Geodan B.V. 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 <ggl_test_common.hpp>
+
+#include <ggl/algorithms/perimeter.hpp>
+#include <ggl/multi/algorithms/perimeter.hpp>
+
+#include <ggl/extensions/gis/io/wkt/wkt.hpp>
+
+#include <ggl/geometries/polygon.hpp>
+#include <ggl/multi/geometries/multi_polygon.hpp>
+
+#include <algorithms/test_perimeter.hpp>
+
+
+template <typename P>
+void test_all()
+{
+ test_geometry<ggl::multi_polygon<ggl::polygon<P> > >(
+ "MULTIPOLYGON(((0 0,0 1,1 0,0 0)))", 1.0 + 1.0 + sqrt(2.0));
+}
+
+int test_main( int , char* [] )
+{
+ test_all<ggl::point_xy<double> >();
+
+ return 0;
+}
Added: sandbox/ggl/formal_review_request/libs/ggl/test/multi/algorithms/multi_simplify.cpp
==============================================================================
--- (empty file)
+++ sandbox/ggl/formal_review_request/libs/ggl/test/multi/algorithms/multi_simplify.cpp 2009-10-22 11:26:27 EDT (Thu, 22 Oct 2009)
@@ -0,0 +1,53 @@
+// Generic Geometry Library
+//
+// Copyright Barend Gehrels, Geodan B.V. 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 <ggl_test_common.hpp>
+
+#include <ggl/algorithms/simplify.hpp>
+#include <ggl/multi/algorithms/simplify.hpp>
+
+#include <ggl/extensions/gis/io/wkt/wkt.hpp>
+
+#include <ggl/geometries/box.hpp>
+#include <ggl/geometries/linear_ring.hpp>
+#include <ggl/geometries/linestring.hpp>
+#include <ggl/geometries/point.hpp>
+#include <ggl/geometries/polygon.hpp>
+
+#include <ggl/multi/geometries/multi_point.hpp>
+#include <ggl/multi/geometries/multi_linestring.hpp>
+#include <ggl/multi/geometries/multi_polygon.hpp>
+
+#include <algorithms/test_simplify.hpp>
+
+
+template <typename P>
+void test_all()
+{
+ test_geometry<ggl::multi_point<P> >(
+ "MULTIPOINT((0 0),(1 1))",
+ "MULTIPOINT((0 0),(1 1))", 1.0);
+
+ test_geometry<ggl::multi_linestring<ggl::linestring<P> > >(
+ "MULTILINESTRING((0 0,5 5,10 10))",
+ "MULTILINESTRING((0 0,10 10))", 1.0);
+
+ typedef ggl::multi_polygon<ggl::polygon<P> > mp;
+ test_geometry<mp>(
+ "MULTIPOLYGON(((4 0,8 2,8 7,4 9,0 7,0 2,2 1,4 0)))",
+ "MULTIPOLYGON(((4 0,8 2,8 7,4 9,0 7,0 2,4 0)))", 1.0);
+ test_geometry<mp>(
+ "MULTIPOLYGON(((4 0,8 2,8 7,4 9,0 7,0 2,2 1,4 0),(7 3,7 6,1 6,1 3,4 3,7 3)))",
+ "MULTIPOLYGON(((4 0,8 2,8 7,4 9,0 7,0 2,4 0),(7 3,7 6,1 6,1 3,7 3)))", 1.0);
+}
+
+int test_main( int , char* [] )
+{
+ test_all<ggl::point_xy<double> >();
+
+ return 0;
+}
Added: sandbox/ggl/formal_review_request/libs/ggl/test/point_concept/Jamfile.v2
==============================================================================
--- (empty file)
+++ sandbox/ggl/formal_review_request/libs/ggl/test/point_concept/Jamfile.v2 2009-10-22 11:26:27 EDT (Thu, 22 Oct 2009)
@@ -0,0 +1,19 @@
+# test/point_concept/Jamfile.v2
+#
+# Copyright (c) 2009 Mateusz Loskot <mateusz_at_[hidden]>
+#
+# 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 ggl-point-concept
+ :
+ [ compile well_formed_point.cpp ]
+ [ compile well_formed_point_traits.cpp ]
+ [ compile array_point.cpp ]
+ [ compile-fail point_without_coordinate_type.cpp ]
+ [ compile-fail point_without_dimension.cpp ]
+ [ compile-fail point_without_getter.cpp ]
+ [ compile-fail point_without_setter.cpp ]
+ [ compile-fail point_with_incorrect_dimension.cpp ]
+ ;
Added: sandbox/ggl/formal_review_request/libs/ggl/test/point_concept/array_point.cpp
==============================================================================
--- (empty file)
+++ sandbox/ggl/formal_review_request/libs/ggl/test/point_concept/array_point.cpp 2009-10-22 11:26:27 EDT (Thu, 22 Oct 2009)
@@ -0,0 +1,19 @@
+// Generic Geometry Library Point concept test file
+//
+// Copyright Bruno Lalande 2008, 2009
+// Copyright Barend Gehrels, 1995-2009, Geodan Holding B.V. 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 <test_common/test_point.hpp>
+
+#include <ggl/geometries/adapted/c_array_cartesian.hpp>
+#include "function_requiring_a_point.hpp"
+
+int main()
+{
+ float p1[3] = { 0, 0, 0 };
+ const float p2[3] = { 0, 0, 0 };
+ ggl::function_requiring_a_point(p1, p2);
+}
Added: sandbox/ggl/formal_review_request/libs/ggl/test/point_concept/function_asserting_a_point.hpp
==============================================================================
--- (empty file)
+++ sandbox/ggl/formal_review_request/libs/ggl/test/point_concept/function_asserting_a_point.hpp 2009-10-22 11:26:27 EDT (Thu, 22 Oct 2009)
@@ -0,0 +1,28 @@
+// Generic Geometry Library Point concept unit tests
+//
+// Copyright Bruno Lalande 2008, 2009
+// Copyright Barend Gehrels 1995-2009, Geodan Holding B.V. Amsterdam, the Netherlands.
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef GGL_TEST_POINT_CONCEPT_FUNCTION_ASSERTING_A_POINT_HPP
+#define GGL_TEST_POINT_CONCEPT_FUNCTION_ASSERTING_A_POINT_HPP
+
+#include <boost/concept/requires.hpp>
+
+#include <ggl/core/concepts/point_concept.hpp>
+
+namespace ggl
+{
+ template <typename P, typename CP>
+ void function_asserting_a_point(P& p1, const CP& p2)
+ {
+ BOOST_CONCEPT_ASSERT((concept::Point<P>));
+ BOOST_CONCEPT_ASSERT((concept::ConstPoint<P>));
+
+ get<0>(p1) = get<0>(p2);
+ }
+}
+
+#endif // GGL_TEST_POINT_CONCEPT_FUNCTION_ASSERTING_A_POINT_HPP
Added: sandbox/ggl/formal_review_request/libs/ggl/test/point_concept/function_requiring_a_point.hpp
==============================================================================
--- (empty file)
+++ sandbox/ggl/formal_review_request/libs/ggl/test/point_concept/function_requiring_a_point.hpp 2009-10-22 11:26:27 EDT (Thu, 22 Oct 2009)
@@ -0,0 +1,30 @@
+// Generic Geometry Library Point concept unit tests
+//
+// Copyright Bruno Lalande 2008, 2009
+// Copyright Barend Gehrels 1995-2009, Geodan Holding B.V. Amsterdam, the Netherlands.
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef GGL_TEST_POINT_CONCEPT_FUNCTION_REQUIRING_A_POINT_HPP
+#define GGL_TEST_POINT_CONCEPT_FUNCTION_REQUIRING_A_POINT_HPP
+
+#include <boost/concept/requires.hpp>
+
+#include <ggl/core/concepts/point_concept.hpp>
+
+namespace ggl
+{
+ template <typename P, typename C>
+
+ inline BOOST_CONCEPT_REQUIRES(
+ ((concept::Point<P>))
+ ((concept::ConstPoint<C>)),
+ (void))
+ function_requiring_a_point(P& p1, const C& p2)
+ {
+ set<0>(p1, get<0>(p2));
+ }
+}
+
+#endif // GGL_TEST_POINT_CONCEPT_FUNCTION_REQUIRING_A_POINT_HPP
Added: sandbox/ggl/formal_review_request/libs/ggl/test/point_concept/point_with_incorrect_dimension.cpp
==============================================================================
--- (empty file)
+++ sandbox/ggl/formal_review_request/libs/ggl/test/point_concept/point_with_incorrect_dimension.cpp 2009-10-22 11:26:27 EDT (Thu, 22 Oct 2009)
@@ -0,0 +1,51 @@
+// Generic Geometry Library Point concept test file
+//
+// Copyright Bruno Lalande 2008, 2009
+// Copyright Barend Gehrels, 1995-2009, Geodan Holding B.V. 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 <test_common/test_point.hpp>
+
+#include "function_asserting_a_point.hpp"
+#include "function_requiring_a_point.hpp"
+
+#include <ggl/core/cs.hpp>
+
+struct point
+{
+ float x, y;
+};
+
+namespace ggl { namespace traits {
+
+template <> struct tag<point> { typedef point_tag type; };
+template <> struct coordinate_type<point> { typedef float type; };
+template <> struct coordinate_system<point> { typedef ggl::cs::cartesian type; };
+template <> struct dimension<point> { enum { value = 3 }; };
+
+template <> struct access<point, 0>
+{
+ static float get(point const& p) { return p.x; }
+ static void set(point& p, float value) { p.x = value; }
+};
+
+template <> struct access<point, 1>
+{
+ static float get(point const& p) { return p.y; }
+ static void set(point& p, float value) { p.y = value; }
+};
+
+
+}} // namespace ggl::traits
+
+
+int main()
+{
+ point p1;
+ const point p2;
+ ggl::function_requiring_a_point(p1, p2);
+ ggl::function_asserting_a_point(p1, p2);
+}
Added: sandbox/ggl/formal_review_request/libs/ggl/test/point_concept/point_without_coordinate_type.cpp
==============================================================================
--- (empty file)
+++ sandbox/ggl/formal_review_request/libs/ggl/test/point_concept/point_without_coordinate_type.cpp 2009-10-22 11:26:27 EDT (Thu, 22 Oct 2009)
@@ -0,0 +1,46 @@
+// Generic Geometry Library Point concept test file
+//
+// Copyright Bruno Lalande 2008, 2009
+// Copyright Barend Gehrels, 1995-2009, Geodan Holding B.V. 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 "function_requiring_a_point.hpp"
+
+#include <ggl/core/cs.hpp>
+
+struct point
+{
+ float x, y;
+};
+
+namespace ggl { namespace traits {
+
+template <> struct tag<point> { typedef point_tag type; };
+//template <> struct coordinate_type<point> { typedef float type; };
+template <> struct coordinate_system<point> { typedef ggl::cs::cartesian type; };
+template <> struct dimension<point> { enum { value = 2 }; };
+
+template <> struct access<point, 0>
+{
+ static float get(point const& p) { return p.x; }
+ static void set(point& p, float value) { p.x = value; }
+};
+
+template <> struct access<point, 1>
+{
+ static float get(point const& p) { return p.y; }
+ static void set(point& p, float value) { p.y = value; }
+};
+
+
+}} // namespace ggl::traits
+
+int main()
+{
+ point p1;
+ const point p2;
+ ggl::function_requiring_a_point(p1, p2);
+}
Added: sandbox/ggl/formal_review_request/libs/ggl/test/point_concept/point_without_dimension.cpp
==============================================================================
--- (empty file)
+++ sandbox/ggl/formal_review_request/libs/ggl/test/point_concept/point_without_dimension.cpp 2009-10-22 11:26:27 EDT (Thu, 22 Oct 2009)
@@ -0,0 +1,48 @@
+// Generic Geometry Library Point concept test file
+//
+// Copyright Bruno Lalande 2008, 2009
+// Copyright Barend Gehrels, 1995-2009, Geodan Holding B.V. 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 "function_requiring_a_point.hpp"
+
+#include <ggl/core/cs.hpp>
+
+struct point
+{
+ float x, y;
+};
+
+
+namespace ggl { namespace traits {
+
+template <> struct tag<point> { typedef point_tag type; };
+template <> struct coordinate_type<point> { typedef float type; };
+template <> struct coordinate_system<point> { typedef ggl::cs::cartesian type; };
+//template <> struct dimension<point> { enum { value = 2 }; };
+
+template <> struct access<point, 0>
+{
+ static float get(point const& p) { return p.x; }
+ static void set(point& p, float value) { p.x = value; }
+};
+
+template <> struct access<point, 1>
+{
+ static float get(point const& p) { return p.y; }
+ static void set(point& p, float value) { p.y = value; }
+};
+
+
+}} // namespace ggl::traits
+
+
+int main()
+{
+ point p1;
+ const point p2;
+ ggl::function_requiring_a_point(p1, p2);
+}
Added: sandbox/ggl/formal_review_request/libs/ggl/test/point_concept/point_without_getter.cpp
==============================================================================
--- (empty file)
+++ sandbox/ggl/formal_review_request/libs/ggl/test/point_concept/point_without_getter.cpp 2009-10-22 11:26:27 EDT (Thu, 22 Oct 2009)
@@ -0,0 +1,44 @@
+// Generic Geometry Library Point concept test file
+//
+// Copyright Bruno Lalande 2008, 2009
+// Copyright Barend Gehrels, 1995-2009, Geodan Holding B.V. 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 "function_requiring_a_point.hpp"
+
+#include <ggl/core/cs.hpp>
+
+struct point
+{
+ float x, y;
+};
+
+namespace ggl { namespace traits {
+
+template <> struct tag<point> { typedef point_tag type; };
+template <> struct coordinate_type<point> { typedef float type; };
+template <> struct coordinate_system<point> { typedef ggl::cs::cartesian type; };
+template <> struct dimension<point> { enum { value = 2 }; };
+
+template <> struct access<point, 0>
+{
+ static void set(point& p, float value) { p.x = value; }
+};
+
+template <> struct access<point, 1>
+{
+ static void set(point& p, float value) { p.y = value; }
+};
+
+
+}} // namespace ggl::traits
+
+int main()
+{
+ point p1;
+ const point p2;
+ ggl::function_requiring_a_point(p1, p2);
+}
Added: sandbox/ggl/formal_review_request/libs/ggl/test/point_concept/point_without_setter.cpp
==============================================================================
--- (empty file)
+++ sandbox/ggl/formal_review_request/libs/ggl/test/point_concept/point_without_setter.cpp 2009-10-22 11:26:27 EDT (Thu, 22 Oct 2009)
@@ -0,0 +1,44 @@
+// Generic Geometry Library Point concept test file
+//
+// Copyright Bruno Lalande 2008, 2009
+// Copyright Barend Gehrels, 1995-2009, Geodan Holding B.V. 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 "function_requiring_a_point.hpp"
+
+#include <ggl/core/cs.hpp>
+
+struct point
+{
+ float x, y;
+};
+
+namespace ggl { namespace traits {
+
+template <> struct tag<point> { typedef point_tag type; };
+template <> struct coordinate_type<point> { typedef float type; };
+template <> struct coordinate_system<point> { typedef ggl::cs::cartesian type; };
+template <> struct dimension<point> { enum { value = 2 }; };
+
+template <> struct access<point, 0>
+{
+ static float get(point const& p) { return p.x; }
+};
+
+template <> struct access<point, 1>
+{
+ static float get(point const& p) { return p.y; }
+};
+
+
+}} // namespace ggl::traits
+
+int main()
+{
+ point p1;
+ const point p2;
+ ggl::function_requiring_a_point(p1, p2);
+}
Added: sandbox/ggl/formal_review_request/libs/ggl/test/point_concept/well_formed_point.cpp
==============================================================================
--- (empty file)
+++ sandbox/ggl/formal_review_request/libs/ggl/test/point_concept/well_formed_point.cpp 2009-10-22 11:26:27 EDT (Thu, 22 Oct 2009)
@@ -0,0 +1,27 @@
+// Generic Geometry Library Point concept test file
+//
+// Copyright Bruno Lalande 2008, 2009
+// Copyright Barend Gehrels, 1995-2009, Geodan Holding B.V. 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 <boost/tuple/tuple.hpp>
+
+#include <ggl/core/cs.hpp>
+#include <ggl/geometries/register/point.hpp>
+
+#include "function_requiring_a_point.hpp"
+
+struct point: public boost::tuple<float, float>
+{
+};
+
+GEOMETRY_REGISTER_POINT_2D(point, float, cs::cartesian, get<0>(), get<1>())
+
+int main()
+{
+ point p1;
+ const point p2;
+ ggl::function_requiring_a_point(p1, p2);
+}
Added: sandbox/ggl/formal_review_request/libs/ggl/test/point_concept/well_formed_point_traits.cpp
==============================================================================
--- (empty file)
+++ sandbox/ggl/formal_review_request/libs/ggl/test/point_concept/well_formed_point_traits.cpp 2009-10-22 11:26:27 EDT (Thu, 22 Oct 2009)
@@ -0,0 +1,81 @@
+// Generic Geometry Library Point concept test file
+//
+// Copyright Bruno Lalande 2008, 2009
+// Copyright Barend Gehrels, 1995-2009, Geodan Holding B.V. 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 <ggl/core/cs.hpp>
+
+#include "function_requiring_a_point.hpp"
+
+struct point
+{
+ point(): x(), y() {}
+ float x, y;
+};
+
+namespace ggl { namespace traits {
+
+template <>
+struct tag<point>
+{
+ typedef point_tag type;
+};
+
+template <>
+struct coordinate_type<point>
+{
+ typedef float type;
+};
+
+template <>
+struct coordinate_system<point>
+{
+ typedef ggl::cs::cartesian type;
+};
+
+template <>
+struct dimension<point>
+{
+ enum { value = 2 };
+};
+
+template <>
+struct access<point, 0>
+{
+ static float get(point const& p)
+ {
+ return p.x;
+ }
+
+ static void set(point& p, float value)
+ {
+ p.x = value;
+ }
+};
+
+template <>
+struct access<point, 1>
+{
+ static float get(point const& p)
+ {
+ return p.y;
+ }
+
+ static void set(point& p, float value)
+ {
+ p.y = value;
+ }
+};
+
+
+}} // namespace ggl::traits
+
+int main()
+{
+ point p1;
+ const point p2;
+ ggl::function_requiring_a_point(p1, p2);
+}
Deleted: sandbox/ggl/formal_review_request/libs/ggl/test/strategies/Jamfile
==============================================================================
--- sandbox/ggl/formal_review_request/libs/ggl/test/strategies/Jamfile 2009-10-22 11:26:27 EDT (Thu, 22 Oct 2009)
+++ (empty file)
@@ -1,12 +0,0 @@
-# Generic Geometry Library unit tests
-#
-# Copyright Bruno Lalande 2008
-# Copyright Barend Gehrels, Geodan Holding B.V. 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)
-
-run cross_track.cpp ;
-run haversine.cpp ;
-run pythagoras.cpp ;
-run transformer.cpp ;
Copied: sandbox/ggl/formal_review_request/libs/ggl/test/strategies/Jamfile.v2 (from r57037, /sandbox/ggl/formal_review_request/libs/ggl/test/strategies/Jamfile)
==============================================================================
--- /sandbox/ggl/formal_review_request/libs/ggl/test/strategies/Jamfile (original)
+++ sandbox/ggl/formal_review_request/libs/ggl/test/strategies/Jamfile.v2 2009-10-22 11:26:27 EDT (Thu, 22 Oct 2009)
@@ -1,12 +1,15 @@
-# Generic Geometry Library unit tests
+# test/strategies/Jamfile.v2
+#
+# Copyright (c) 2009 Mateusz Loskot <mateusz_at_[hidden]>
#
-# Copyright Bruno Lalande 2008
-# Copyright Barend Gehrels, Geodan Holding B.V. 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)
-run cross_track.cpp ;
-run haversine.cpp ;
-run pythagoras.cpp ;
-run transformer.cpp ;
+test-suite ggl-strategies
+ :
+ [ run cross_track.cpp ]
+ [ run haversine.cpp ]
+ [ run pythagoras.cpp ]
+ [ run transformer.cpp ]
+ ;
Modified: sandbox/ggl/formal_review_request/libs/ggl/test/test_common/test_point.hpp
==============================================================================
--- sandbox/ggl/formal_review_request/libs/ggl/test/test_common/test_point.hpp (original)
+++ sandbox/ggl/formal_review_request/libs/ggl/test/test_common/test_point.hpp 2009-10-22 11:26:27 EDT (Thu, 22 Oct 2009)
@@ -29,32 +29,6 @@
};
-// Struct set of metafunctions to read/write coordinates above, specialized per dimension
-template<int I>
-struct accessor {};
-
-template<>
-struct accessor<0>
-{
- static inline const float& get(const test_point& p) { return p.c1; }
- static inline void set(test_point& p, const float& value) { p.c1 = value; }
-};
-
-template<>
-struct accessor<1>
-{
- static inline const float& get(const test_point& p) { return p.c2; }
- static inline void set(test_point& p, const float& value) { p.c2 = value; }
-};
-
-template<>
-struct accessor<2>
-{
- static inline const float& get(const test_point& p) { return p.c3; }
- static inline void set(test_point& p, const float& value) { p.c3 = value; }
-};
-
-
} // namespace test
@@ -72,18 +46,42 @@
template<>
struct dimension<test::test_point>: boost::mpl::int_<3> {};
-template<> struct access<test::test_point>
+template<> struct access<test::test_point, 0>
+{
+ static inline const float& get(const test::test_point& p)
+ {
+ return p.c1;
+ }
+
+ static inline void set(test::test_point& p, const float& value)
+ {
+ p.c1 = value;
+ }
+};
+
+template<> struct access<test::test_point, 1>
+{
+ static inline const float& get(const test::test_point& p)
+ {
+ return p.c2;
+ }
+
+ static inline void set(test::test_point& p, const float& value)
+ {
+ p.c2 = value;
+ }
+};
+
+template<> struct access<test::test_point, 2>
{
- template <int I>
static inline const float& get(const test::test_point& p)
{
- return test::accessor<I>::get(p);
+ return p.c3;
}
- template <int I>
static inline void set(test::test_point& p, const float& value)
{
- test::accessor<I>::set(p, value);
+ p.c3 = value;
}
};
Modified: sandbox/ggl/formal_review_request/libs/ggl/test/test_common/with_pointer.hpp
==============================================================================
--- sandbox/ggl/formal_review_request/libs/ggl/test/test_common/with_pointer.hpp (original)
+++ sandbox/ggl/formal_review_request/libs/ggl/test/test_common/with_pointer.hpp 2009-10-22 11:26:27 EDT (Thu, 22 Oct 2009)
@@ -45,21 +45,32 @@
template<> struct dimension<test::test_point_xy*> : boost::mpl::int_<2> {};
template<>
-struct access<test::test_point_xy*>
+struct access<test::test_point_xy*, 0>
{
- template <std::size_t I>
- static double get(const test::test_point_xy* p)
+ static double get(test::test_point_xy const* p)
{
- return I == 0 ? p->x : p->y;
- // Or implement an accessor with specializations
+ return p->x;
}
- template <int I>
- static void set(test::test_point_xy* p, const double& value)
+ static void set(test::test_point_xy* p, double const& value)
{
- // Or (better) implement an accessor with specializations
- if (I == 0) p->x = value;
- else if (I == 1) p->y = value;
+ p->x = value;
+ }
+
+};
+
+
+template<>
+struct access<test::test_point_xy*, 1>
+{
+ static double get(test::test_point_xy const* p)
+ {
+ return p->y;
+ }
+
+ static void set(test::test_point_xy* p, double const& value)
+ {
+ p->y = value;
}
};
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