|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r57287 - in sandbox/ggl/formal_review_request/libs/ggl: example test test/algorithms test/iterators test/multi/algorithms test/policies test/strategies
From: barend.gehrels_at_[hidden]
Date: 2009-11-02 10:53:28
Author: barendgehrels
Date: 2009-11-02 10:53:23 EST (Mon, 02 Nov 2009)
New Revision: 57287
URL: http://svn.boost.org/trac/boost/changeset/57287
Log:
Reflection to changes in library
Added:
sandbox/ggl/formal_review_request/libs/ggl/test/algorithms/convert.cpp (contents, props changed)
sandbox/ggl/formal_review_request/libs/ggl/test/algorithms/disjoint.cpp (contents, props changed)
sandbox/ggl/formal_review_request/libs/ggl/test/algorithms/intersection.cpp (contents, props changed)
sandbox/ggl/formal_review_request/libs/ggl/test/algorithms/overlaps.cpp (contents, props changed)
sandbox/ggl/formal_review_request/libs/ggl/test/algorithms/test_intersection.hpp (contents, props changed)
sandbox/ggl/formal_review_request/libs/ggl/test/algorithms/test_overlaps.hpp (contents, props changed)
sandbox/ggl/formal_review_request/libs/ggl/test/algorithms/test_overlay.hpp (contents, props changed)
sandbox/ggl/formal_review_request/libs/ggl/test/algorithms/test_union.hpp (contents, props changed)
sandbox/ggl/formal_review_request/libs/ggl/test/algorithms/union.cpp (contents, props changed)
sandbox/ggl/formal_review_request/libs/ggl/test/policies/
sandbox/ggl/formal_review_request/libs/ggl/test/policies/Jamfile.v2 (contents, props changed)
sandbox/ggl/formal_review_request/libs/ggl/test/policies/compare.cpp (contents, props changed)
sandbox/ggl/formal_review_request/libs/ggl/test/strategies/projected_point.cpp (contents, props changed)
Removed:
sandbox/ggl/formal_review_request/libs/ggl/test/iterators/vertex_iterator.cpp
Text files modified:
sandbox/ggl/formal_review_request/libs/ggl/example/07_graph_route_example.cpp | 9 +--------
sandbox/ggl/formal_review_request/libs/ggl/example/c01_custom_point_example.cpp | 1 +
sandbox/ggl/formal_review_request/libs/ggl/example/c02_custom_box_example.cpp | 2 +-
sandbox/ggl/formal_review_request/libs/ggl/example/c04_a_custom_triangle_example.cpp | 3 +--
sandbox/ggl/formal_review_request/libs/ggl/example/c04_b_custom_triangle_example.cpp | 4 ++--
sandbox/ggl/formal_review_request/libs/ggl/example/c05_custom_point_pointer_example.cpp | 5 +----
sandbox/ggl/formal_review_request/libs/ggl/test/Jamfile.v2 | 1 +
sandbox/ggl/formal_review_request/libs/ggl/test/algorithms/Jamfile.v2 | 11 +++--------
sandbox/ggl/formal_review_request/libs/ggl/test/algorithms/area.cpp | 7 +------
sandbox/ggl/formal_review_request/libs/ggl/test/algorithms/centroid.cpp | 24 ++++++++----------------
sandbox/ggl/formal_review_request/libs/ggl/test/algorithms/convex_hull.cpp | 36 +++++++++++++++++-------------------
sandbox/ggl/formal_review_request/libs/ggl/test/algorithms/correct.cpp | 6 ++++--
sandbox/ggl/formal_review_request/libs/ggl/test/algorithms/for_each.cpp | 6 ++----
sandbox/ggl/formal_review_request/libs/ggl/test/algorithms/length.cpp | 6 +-----
sandbox/ggl/formal_review_request/libs/ggl/test/algorithms/perimeter.cpp | 5 -----
sandbox/ggl/formal_review_request/libs/ggl/test/algorithms/simplify.cpp | 6 +-----
sandbox/ggl/formal_review_request/libs/ggl/test/algorithms/test_area.hpp | 8 +++++++-
sandbox/ggl/formal_review_request/libs/ggl/test/algorithms/test_centroid.hpp | 11 ++++++++++-
sandbox/ggl/formal_review_request/libs/ggl/test/algorithms/test_convex_hull.hpp | 32 +++++++++++++++++++++++++++++---
sandbox/ggl/formal_review_request/libs/ggl/test/algorithms/test_for_each.hpp | 6 +++++-
sandbox/ggl/formal_review_request/libs/ggl/test/algorithms/test_length.hpp | 6 +++++-
sandbox/ggl/formal_review_request/libs/ggl/test/algorithms/test_perimeter.hpp | 9 ++++++++-
sandbox/ggl/formal_review_request/libs/ggl/test/algorithms/test_simplify.hpp | 7 ++++++-
sandbox/ggl/formal_review_request/libs/ggl/test/algorithms/test_within.hpp | 36 +++++++++++++++++++++++-------------
sandbox/ggl/formal_review_request/libs/ggl/test/algorithms/within.cpp | 8 +-------
sandbox/ggl/formal_review_request/libs/ggl/test/ggl_test_common.hpp | 16 ++++++++++++----
sandbox/ggl/formal_review_request/libs/ggl/test/iterators/Jamfile.v2 | 1 -
sandbox/ggl/formal_review_request/libs/ggl/test/iterators/segment_iterator.cpp | 4 +---
sandbox/ggl/formal_review_request/libs/ggl/test/multi/algorithms/Jamfile.v2 | 1 +
sandbox/ggl/formal_review_request/libs/ggl/test/multi/algorithms/multi_centroid.cpp | 17 ++++-------------
sandbox/ggl/formal_review_request/libs/ggl/test/multi/algorithms/multi_convex_hull.cpp | 9 +++------
sandbox/ggl/formal_review_request/libs/ggl/test/multi/algorithms/multi_correct.cpp | 4 ++++
sandbox/ggl/formal_review_request/libs/ggl/test/strategies/Jamfile.v2 | 1 +
sandbox/ggl/formal_review_request/libs/ggl/test/strategies/cross_track.cpp | 5 ++---
sandbox/ggl/formal_review_request/libs/ggl/test/strategies/haversine.cpp | 4 ++--
sandbox/ggl/formal_review_request/libs/ggl/test/strategies/pythagoras.cpp | 17 +++++++++--------
36 files changed, 178 insertions(+), 156 deletions(-)
Modified: sandbox/ggl/formal_review_request/libs/ggl/example/07_graph_route_example.cpp
==============================================================================
--- sandbox/ggl/formal_review_request/libs/ggl/example/07_graph_route_example.cpp (original)
+++ sandbox/ggl/formal_review_request/libs/ggl/example/07_graph_route_example.cpp 2009-11-02 10:53:23 EST (Mon, 02 Nov 2009)
@@ -22,7 +22,6 @@
#include <boost/graph/dijkstra_shortest_paths.hpp>
#include <ggl/ggl.hpp>
-#include <ggl/util/less.hpp>
#include <ggl/geometries/cartesian2d.hpp>
@@ -74,13 +73,7 @@
Tuple tuple(geometry, name);
tuples.push_back(tuple);
- ggl::combine(box, ggl::make_envelope<Box>(geometry,
- // Todo: necessary for latlong, but should not be, solve this
- ggl::strategy::envelope::combine_xy
- <
- typename ggl::point_type<Geometry>::type,
- Box
- >()));
+ ggl::combine(box, ggl::make_envelope<Box>(geometry));
}
}
}
Modified: sandbox/ggl/formal_review_request/libs/ggl/example/c01_custom_point_example.cpp
==============================================================================
--- sandbox/ggl/formal_review_request/libs/ggl/example/c01_custom_point_example.cpp (original)
+++ sandbox/ggl/formal_review_request/libs/ggl/example/c01_custom_point_example.cpp 2009-11-02 10:53:23 EST (Mon, 02 Nov 2009)
@@ -13,6 +13,7 @@
#include <ggl/algorithms/distance.hpp>
#include <ggl/algorithms/make.hpp>
#include <ggl/geometries/register/point.hpp>
+#include <ggl/strategies/strategies.hpp>
#include <ggl/util/write_dsv.hpp>
// Sample point, defining three color values
Modified: sandbox/ggl/formal_review_request/libs/ggl/example/c02_custom_box_example.cpp
==============================================================================
--- sandbox/ggl/formal_review_request/libs/ggl/example/c02_custom_box_example.cpp (original)
+++ sandbox/ggl/formal_review_request/libs/ggl/example/c02_custom_box_example.cpp 2009-11-02 10:53:23 EST (Mon, 02 Nov 2009)
@@ -14,7 +14,7 @@
#include <ggl/algorithms/within.hpp>
#include <ggl/geometries/register/point.hpp>
#include <ggl/geometries/register/box.hpp>
-
+#include <ggl/strategies/strategies.hpp>
#include <ggl/util/write_dsv.hpp>
struct my_point
Modified: sandbox/ggl/formal_review_request/libs/ggl/example/c04_a_custom_triangle_example.cpp
==============================================================================
--- sandbox/ggl/formal_review_request/libs/ggl/example/c04_a_custom_triangle_example.cpp (original)
+++ sandbox/ggl/formal_review_request/libs/ggl/example/c04_a_custom_triangle_example.cpp 2009-11-02 10:53:23 EST (Mon, 02 Nov 2009)
@@ -14,9 +14,8 @@
#include <ggl/algorithms/area.hpp>
#include <ggl/algorithms/centroid.hpp>
-
#include <ggl/geometries/register/ring.hpp>
-
+#include <ggl/strategies/strategies.hpp>
#include <ggl/util/write_dsv.hpp>
Modified: sandbox/ggl/formal_review_request/libs/ggl/example/c04_b_custom_triangle_example.cpp
==============================================================================
--- sandbox/ggl/formal_review_request/libs/ggl/example/c04_b_custom_triangle_example.cpp (original)
+++ sandbox/ggl/formal_review_request/libs/ggl/example/c04_b_custom_triangle_example.cpp 2009-11-02 10:53:23 EST (Mon, 02 Nov 2009)
@@ -17,10 +17,10 @@
#include <ggl/algorithms/centroid.hpp>
#include <ggl/geometries/adapted/tuple.hpp>
#include <ggl/geometries/adapted/tuple_cartesian.hpp>
-
+#include <ggl/geometries/register/ring.hpp>
+#include <ggl/strategies/strategies.hpp>
#include <ggl/util/write_dsv.hpp>
-#include <ggl/geometries/register/ring.hpp>
template <typename P>
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-11-02 10:53:23 EST (Mon, 02 Nov 2009)
@@ -13,13 +13,10 @@
#include <ggl/algorithms/distance.hpp>
#include <ggl/algorithms/length.hpp>
#include <ggl/algorithms/make.hpp>
-
-#include <ggl/algorithms/intersection_linestring.hpp>
#include <ggl/algorithms/intersection.hpp>
-
#include <ggl/geometries/cartesian2d.hpp>
-
#include <ggl/geometries/adapted/std_as_linestring.hpp>
+#include <ggl/strategies/strategies.hpp>
// Sample point, having x/y
struct my_point
Modified: sandbox/ggl/formal_review_request/libs/ggl/test/Jamfile.v2
==============================================================================
--- sandbox/ggl/formal_review_request/libs/ggl/test/Jamfile.v2 (original)
+++ sandbox/ggl/formal_review_request/libs/ggl/test/Jamfile.v2 2009-11-02 10:53:23 EST (Mon, 02 Nov 2009)
@@ -21,5 +21,6 @@
build-project algorithms ;
build-project iterators ;
build-project strategies ;
+build-project policies ;
# build-project util ;
build-project multi ;
Modified: sandbox/ggl/formal_review_request/libs/ggl/test/algorithms/Jamfile.v2
==============================================================================
--- sandbox/ggl/formal_review_request/libs/ggl/test/algorithms/Jamfile.v2 (original)
+++ sandbox/ggl/formal_review_request/libs/ggl/test/algorithms/Jamfile.v2 2009-11-02 10:53:23 EST (Mon, 02 Nov 2009)
@@ -11,27 +11,22 @@
# [ run append.cpp ]
[ run area.cpp ]
# [ run assign.cpp ]
-# [ run buffer.cpp ]
[ run centroid.cpp ]
# [ run combine.cpp ]
-# [ run convert.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 intersection.cpp ]
[ run length.cpp ]
# [ run make.cpp ]
[ run perimeter.cpp ]
# [ run sectionalize.cpp ]
-# [ run selected.cpp ]
[ run simplify.cpp ]
# [ run transform.cpp ]
+ [ run union.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-11-02 10:53:23 EST (Mon, 02 Nov 2009)
@@ -7,11 +7,7 @@
// http://www.boost.org/LICENSE_1_0.txt)
-#include <ggl_test_common.hpp>
-
-#include <ggl/algorithms/area.hpp>
-
-#include <ggl/extensions/gis/io/wkt/read_wkt.hpp>
+#include <algorithms/test_area.hpp>
#include <ggl/geometries/point.hpp>
#include <ggl/geometries/box.hpp>
@@ -20,7 +16,6 @@
//#define GGL_TEST_DEBUG
-#include <algorithms/test_area.hpp>
Modified: sandbox/ggl/formal_review_request/libs/ggl/test/algorithms/centroid.cpp
==============================================================================
--- sandbox/ggl/formal_review_request/libs/ggl/test/algorithms/centroid.cpp (original)
+++ sandbox/ggl/formal_review_request/libs/ggl/test/algorithms/centroid.cpp 2009-11-02 10:53:23 EST (Mon, 02 Nov 2009)
@@ -6,26 +6,19 @@
// 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/centroid.hpp>
-
-#include <ggl/algorithms/distance.hpp>
-
-#include <ggl/extensions/gis/io/wkt/read_wkt.hpp>
+#include <algorithms/test_centroid.hpp>
#include <ggl/geometries/geometries.hpp>
#include <ggl/geometries/adapted/c_array_cartesian.hpp>
#include <ggl/geometries/adapted/tuple_cartesian.hpp>
-#include <algorithms/test_centroid.hpp>
-
-
template <typename P>
void test_2d()
{
+ test_centroid<ggl::linestring<P> >("LINESTRING(1 1, 2 2, 3 3)", 2.0, 2.0);
+ test_centroid<ggl::linestring<P> >("LINESTRING(0 0,0 4, 4 4)", 1.0, 3.0);
+ test_centroid<ggl::linestring<P> >("LINESTRING(0 0,3 3,0 6,3 9,0 12)", 1.5, 6.0);
+
test_centroid<ggl::linear_ring<P> >(
"POLYGON((2 1.3,2.4 1.7,2.8 1.8,3.4 1.2"
",3.7 1.6,3.4 2,4.1 3,5.3 2.6,5.4 1.2,4.9 0.8,2.9 0.7,2 1.3))",
@@ -55,6 +48,7 @@
test_centroid<P>("POINT(3 3)", 3, 3);
}
+
template <typename P>
void test_3d()
{
@@ -63,7 +57,6 @@
}
-
int test_main(int, char* [])
{
test_2d<ggl::point_xy<double> >();
@@ -72,12 +65,11 @@
test_3d<boost::tuple<double, double, double> >();
-
#if defined(HAVE_CLN)
- test_2d<ggl::point_xy<boost::numeric_adaptor::cln_value_type> >();
+ //test_2d<ggl::point_xy<boost::numeric_adaptor::cln_value_type> >();
#endif
#if defined(HAVE_GMP)
- test_2d<ggl::point_xy<boost::numeric_adaptor::gmp_value_type> >();
+ //test_2d<ggl::point_xy<boost::numeric_adaptor::gmp_value_type> >();
#endif
return 0;
Added: sandbox/ggl/formal_review_request/libs/ggl/test/algorithms/convert.cpp
==============================================================================
--- (empty file)
+++ sandbox/ggl/formal_review_request/libs/ggl/test/algorithms/convert.cpp 2009-11-02 10:53:23 EST (Mon, 02 Nov 2009)
@@ -0,0 +1,95 @@
+// 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 <ggl_test_common.hpp>
+
+
+#include <ggl/algorithms/assign.hpp>
+#include <ggl/algorithms/convert.hpp>
+#include <ggl/algorithms/make.hpp>
+#include <ggl/algorithms/num_points.hpp>
+
+#include <ggl/geometries/geometries.hpp>
+#include <ggl/geometries/adapted/c_array_cartesian.hpp>
+#include <ggl/geometries/adapted/tuple_cartesian.hpp>
+#include <test_common/test_point.hpp>
+
+template <typename P>
+void test_all()
+{
+ typedef ggl::box<P> box_type;
+
+ P p;
+ ggl::assign(p, 1, 2);
+
+ box_type b;
+ ggl::convert(p, b);
+
+ BOOST_CHECK_CLOSE(double(ggl::get<0, 0>(b)), 1.0, 0.001);
+ BOOST_CHECK_CLOSE(double(ggl::get<0, 1>(b)), 2.0, 0.001);
+ BOOST_CHECK_CLOSE(double(ggl::get<1, 0>(b)), 1.0, 0.001);
+ BOOST_CHECK_CLOSE(double(ggl::get<1, 1>(b)), 2.0, 0.001);
+}
+
+template <typename P>
+void test_std()
+{
+ test_all<P>();
+
+ typedef ggl::box<P> box_type;
+ typedef ggl::linear_ring<P> ring_type;
+ typedef ggl::polygon<P> polygon_type;
+
+ box_type b;
+ ggl::set<ggl::min_corner, 0>(b, 1);
+ ggl::set<ggl::min_corner, 1>(b, 2);
+ ggl::set<ggl::max_corner, 0>(b, 3);
+ ggl::set<ggl::max_corner, 1>(b, 4);
+
+ ring_type ring;
+ ggl::convert(b, ring);
+
+ //std::cout << ggl::wkt(b) << std::endl;
+ //std::cout << ggl::wkt(ring) << std::endl;
+
+ typename boost::range_const_iterator<ring_type>::type it = ring.begin();
+ BOOST_CHECK_CLOSE(double(ggl::get<0>(*it)), 1.0, 0.001);
+ BOOST_CHECK_CLOSE(double(ggl::get<1>(*it)), 2.0, 0.001);
+ it++;
+ BOOST_CHECK_CLOSE(double(ggl::get<0>(*it)), 1.0, 0.001);
+ BOOST_CHECK_CLOSE(double(ggl::get<1>(*it)), 4.0, 0.001);
+ it++;
+ BOOST_CHECK_CLOSE(double(ggl::get<0>(*it)), 3.0, 0.001);
+ BOOST_CHECK_CLOSE(double(ggl::get<1>(*it)), 4.0, 0.001);
+ it++;
+ BOOST_CHECK_CLOSE(double(ggl::get<0>(*it)), 3.0, 0.001);
+ BOOST_CHECK_CLOSE(double(ggl::get<1>(*it)), 2.0, 0.001);
+ it++;
+ BOOST_CHECK_CLOSE(double(ggl::get<0>(*it)), 1.0, 0.001);
+ BOOST_CHECK_CLOSE(double(ggl::get<1>(*it)), 2.0, 0.001);
+
+ BOOST_CHECK_EQUAL(ring.size(), 5);
+
+
+ polygon_type polygon;
+
+ ggl::convert(ring, polygon);
+ BOOST_CHECK_EQUAL(ggl::num_points(polygon), 5);
+
+ ggl::convert(polygon, ring);
+ BOOST_CHECK_EQUAL(ggl::num_points(ring), 5);
+}
+
+int test_main(int, char* [])
+{
+ test_std<ggl::point<int, 2, ggl::cs::cartesian> >();
+ test_std<ggl::point<float, 2, ggl::cs::cartesian> >();
+ test_std<ggl::point<double, 2, ggl::cs::cartesian> >();
+
+ return 0;
+}
Modified: sandbox/ggl/formal_review_request/libs/ggl/test/algorithms/convex_hull.cpp
==============================================================================
--- sandbox/ggl/formal_review_request/libs/ggl/test/algorithms/convex_hull.cpp (original)
+++ sandbox/ggl/formal_review_request/libs/ggl/test/algorithms/convex_hull.cpp 2009-11-02 10:53:23 EST (Mon, 02 Nov 2009)
@@ -9,34 +9,27 @@
#include <cstddef>
#include <string>
-#include <ggl_test_common.hpp>
-
-#include <ggl/algorithms/convex_hull.hpp>
-
-
-#include <ggl/algorithms/area.hpp>
-#include <ggl/algorithms/num_points.hpp>
-
-#include <ggl/extensions/gis/io/wkt/read_wkt.hpp>
-#include <ggl/extensions/gis/io/wkt/write_wkt.hpp>
+#include <algorithms/test_convex_hull.hpp>
#include <ggl/geometries/geometries.hpp>
-#include <algorithms/test_convex_hull.hpp>
template <typename P>
-void test_all()
+void test_all(bool do_rectangular = true)
{
// from sample linestring
test_geometry<ggl::linestring<P> >(
"linestring(1.1 1.1, 2.5 2.1, 3.1 3.1, 4.9 1.1, 3.1 1.9)", 5, 4, 3.8);
- // rectangular, with concavity
- test_geometry<ggl::polygon<P> >(
- "polygon((1 1, 5 1, 5 4, 4 4, 4 3, 3 3, 3 4, 1 4, 1 1))",
- 9, 5, 12.0);
+ if (do_rectangular)
+ {
+ // rectangular, with concavity
+ test_geometry<ggl::polygon<P> >(
+ "polygon((1 1, 1 4, 3 4, 3 3, 4 3, 4 4, 5 4, 5 1, 1 1))",
+ 9, 5, 12.0);
+ }
// from sample polygon, with concavity
test_geometry<ggl::polygon<P> >(
@@ -55,9 +48,14 @@
test_all<ggl::point_xy<boost::numeric_adaptor::cln_value_type> >();
#endif
#if defined(HAVE_GMP)
- // GMP compiles but gives errors in results
- // TODO: find out what's going wrong here
- // test_all<ggl::point_xy<boost::numeric_adaptor::gmp_value_type> >();
+ // GMP compiles, but gives 'errors' in results (6 points in hull instead of 5)
+ // This is because of a vertex on the line, which is OK for the convex hull,
+ // but not OK for the strictly convex hull.
+ // Actually this is unexpected from a high-precision arithmetic library, the
+ // problem is the comparison (something is non-zero which should be calculated
+ // zero, in the direction).
+
+ test_all<ggl::point_xy<boost::numeric_adaptor::gmp_value_type> >(false);
#endif
return 0;
Modified: sandbox/ggl/formal_review_request/libs/ggl/test/algorithms/correct.cpp
==============================================================================
--- sandbox/ggl/formal_review_request/libs/ggl/test/algorithms/correct.cpp (original)
+++ sandbox/ggl/formal_review_request/libs/ggl/test/algorithms/correct.cpp 2009-11-02 10:53:23 EST (Mon, 02 Nov 2009)
@@ -6,17 +6,19 @@
// 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 <sstream>
+#include <ggl_test_common.hpp>
+
#include <ggl/algorithms/correct.hpp>
+#include <ggl/strategies/strategies.hpp>
#include <ggl/util/write_dsv.hpp>
#include <ggl/extensions/gis/io/wkt/read_wkt.hpp>
#include <ggl/extensions/gis/io/wkt/write_wkt.hpp>
+#include <ggl/geometries/point_xy.hpp>
#include <ggl/geometries/box.hpp>
#include <ggl/geometries/linear_ring.hpp>
#include <ggl/geometries/polygon.hpp>
Added: sandbox/ggl/formal_review_request/libs/ggl/test/algorithms/disjoint.cpp
==============================================================================
--- (empty file)
+++ sandbox/ggl/formal_review_request/libs/ggl/test/algorithms/disjoint.cpp 2009-11-02 10:53:23 EST (Mon, 02 Nov 2009)
@@ -0,0 +1,79 @@
+// 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 <iostream>
+#include <string>
+
+
+#include <ggl_test_common.hpp>
+
+#include <ggl/algorithms/disjoint.hpp>
+#include <ggl/geometries/geometries.hpp>
+#include <ggl/extensions/gis/io/wkt/read_wkt.hpp>
+
+#include <test_common/test_point.hpp>
+
+
+
+template <typename G1, typename G2>
+void test_disjoint(std::string const& wkt1, std::string const& wkt2, bool expected)
+{
+ G1 g1;
+ ggl::read_wkt(wkt1, g1);
+
+ G2 g2;
+ ggl::read_wkt(wkt2, g2);
+
+ bool detected = ggl::disjoint(g1, g2);
+ BOOST_CHECK_MESSAGE(detected == expected,
+ "disjoint: " << wkt1
+ << " and " << wkt2
+ << " -> Expected: " << expected
+ << " detected: " << detected);
+}
+
+
+
+template <typename P>
+void test_all()
+{
+ typedef ggl::box<P> box;
+ test_disjoint<P, P>("point(1 1)", "point(1 1)", false);
+ test_disjoint<P, P>("point(1 1)", "point(1.001 1)", true);
+
+ // left-right
+ test_disjoint<box, box>("box(1 1, 2 2)", "box(3 1, 4 2)", true);
+ test_disjoint<box, box>("box(1 1, 2 2)", "box(2 1, 3 2)", false);
+ test_disjoint<box, box>("box(1 1, 2 2)", "box(2 2, 3 3)", false);
+ test_disjoint<box, box>("box(1 1, 2 2)", "box(2.001 2, 3 3)", true);
+
+ // up-down
+ test_disjoint<box, box>("box(1 1, 2 2)", "box(1 3, 2 4)", true);
+ test_disjoint<box, box>("box(1 1, 2 2)", "box(1 2, 2 3)", false);
+ // right-left
+ test_disjoint<box, box>("box(1 1, 2 2)", "box(0 1, 1 2)", false);
+ test_disjoint<box, box>("box(1 1, 2 2)", "box(0 1, 1 2)", false);
+
+ // point-box
+ test_disjoint<P, box>("point(1 1)", "box(0 0, 2 2)", false);
+ test_disjoint<P, box>("point(2 2)", "box(0 0, 2 2)", false);
+ test_disjoint<P, box>("point(2.0001 2)", "box(1 1, 2 2)", true);
+ test_disjoint<P, box>("point(0.9999 2)", "box(1 1, 2 2)", true);
+
+ // box-point (to test reverse compiling)
+ test_disjoint<box, P>("box(1 1, 2 2)", "point(2 2)", false);
+
+}
+
+int test_main(int, char* [])
+{
+ test_all<ggl::point_xy<float> >();
+ test_all<ggl::point_xy<double> >();
+
+ return 0;
+}
Modified: sandbox/ggl/formal_review_request/libs/ggl/test/algorithms/for_each.cpp
==============================================================================
--- sandbox/ggl/formal_review_request/libs/ggl/test/algorithms/for_each.cpp (original)
+++ sandbox/ggl/formal_review_request/libs/ggl/test/algorithms/for_each.cpp 2009-11-02 10:53:23 EST (Mon, 02 Nov 2009)
@@ -6,13 +6,11 @@
// http://www.boost.org/LICENSE_1_0.txt)
-#include <ggl_test_common.hpp>
-
-#include <ggl/algorithms/for_each.hpp>
+#include <algorithms/test_for_each.hpp>
#include <ggl/geometries/geometries.hpp>
-#include <algorithms/test_for_each.hpp>
+
template <typename P>
void test_all()
Added: sandbox/ggl/formal_review_request/libs/ggl/test/algorithms/intersection.cpp
==============================================================================
--- (empty file)
+++ sandbox/ggl/formal_review_request/libs/ggl/test/algorithms/intersection.cpp 2009-11-02 10:53:23 EST (Mon, 02 Nov 2009)
@@ -0,0 +1,191 @@
+// 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 <iostream>
+#include <string>
+
+
+#include <algorithms/test_intersection.hpp>
+#include <algorithms/test_overlay.hpp>
+
+#include <ggl/geometries/adapted/std_as_linestring.hpp>
+
+#include <test_common/test_point.hpp>
+#include <test_common/with_pointer.hpp>
+
+
+
+template <typename P>
+void test_all()
+{
+ typedef ggl::linestring<P> linestring;
+ typedef ggl::polygon<P> polygon;
+ typedef ggl::box<P> box;
+
+ std::string clip = "box(2 2,8 8)";
+
+ // Basic check: box/linestring, is clipping OK? should compile in any order
+ test_one<linestring, linestring, box>(1, "LINESTRING(0 0,10 10)", clip, 1, 2, sqrt(2.0 * 6.0 * 6.0));
+ test_one<linestring, box, linestring>(2, clip, "LINESTRING(0 0,10 10)", 1, 2, sqrt(2.0 * 6.0 * 6.0));
+
+ // Completely inside
+ test_one<linestring, linestring, box>(3, "LINESTRING(3 3,7 7)", clip, 1, 2, sqrt(2.0 * 4.0 * 4.0));
+
+ // Completely outside
+ test_one<linestring, linestring, box>(4, "LINESTRING(9 9,10 10)", clip, 0, 0, 0);
+
+ // Touching with point (-> output linestring with ONE point)
+ //std::cout << "Note: this line is degenerate! Might be removed!" << std::endl;
+ test_one<linestring, linestring, box>(5, "LINESTRING(8 8,10 10)", clip, 1, 2, 0.0);
+
+ // Along border
+ test_one<linestring, linestring, box>(6, "LINESTRING(2 2,2 8)", clip, 1, 2, 6);
+
+ // Outputting two lines (because of 3-4-5 constructions (0.3,0.4,0.5)
+ // which occur 4 times, the length is expected to be 2.0)
+ test_one<linestring, linestring, box>(7, "LINESTRING(1.7 1.6,2.3 2.4,2.9 1.6,3.5 2.4,4.1 1.6)", clip, 2, 6, 4 * 0.5);
+
+
+ test_one<polygon, box, polygon>(10, example_box, example_ring,
+ 2, 12, 1.09125);
+
+ test_one<polygon, box, polygon>(11, example_box, example_polygon,
+ 3, 19, 0.840166);
+
+ test_one<polygon, polygon, polygon>(12, example_star, example_ring,
+ 1, 18, 2.80983);
+
+ test_one<polygon, polygon, polygon>(13, example_star, example_polygon,
+ 1, 22, 2.5020508);
+
+
+ test_one<polygon, box, polygon>(20, example_box,
+ "POLYGON((3.4 2,4.1 3,5.3 2.6,5.4 1.2,4.9 0.8,2.9 0.7,2 1.3,2.4 1.7,2.8 1.8,3.4 1.2,3.7 1.6,3.4 2))",
+ 2, 12, 1.09125);
+
+ test_one<polygon, box, polygon>(21, example_box,
+ "POLYGON((2 1.3,2.4 1.7,2.8 1.8,3.4 1.2,3.7 1.6,3.4 2,4.1 2.5,5.3 2.5,5.4 1.2,4.9 0.8,2.9 0.7,2 1.3))",
+ 2, 12, 1.00375);
+ test_one<polygon, box, polygon>(22, example_box,
+ "POLYGON((2 1.3,2.4 1.7,2.8 1.8,3.4 1.2,3.7 1.6,3.4 2,4.1 2.5,4.5 2.5,4.5 1.2,4.9 0.8,2.9 0.7,2 1.3))",
+ 2, 12, 1.00375);
+ test_one<polygon, box, polygon>(23, example_box,
+ "POLYGON((2 1.3,2.4 1.7,2.8 1.8,3.4 1.2,3.7 1.6,3.4 2,4.1 2.5,4.5 2.5,4.5 2.3,5.0 2.3,5.0 2.1,4.5 2.1,4.5 1.9,4.0 1.9,4.5 1.2,4.9 0.8,2.9 0.7,2 1.3))",
+ 2, 14, 0.860892);
+
+ test_one<polygon, box, polygon>(24, example_box,
+ "POLYGON((2 1.3,2.4 1.7,2.8 1.8,3.4 1.2,3.7 1.6,3.4 2,4.1 2.5,4.5 1.2,2.9 0.7,2 1.3))",
+ 2, 11, 0.7575961);
+
+ test_one<polygon, box, polygon>(25, example_box,
+ "POLYGON((2 1.3,2.4 1.7,2.8 1.8,3.4 1.2,3.7 1.6,3.4 2,4.0 3.0,5.0 2.0,2.9 0.7,2 1.3))",
+ 2, 13, 1.0744456);
+
+ test_one<polygon, box, polygon>(26, "box(0 0, 3 3)",
+ "POLYGON((2 2, 1 4, 2 4, 3 3, 2 2))", 1, 4, 0.75);
+
+ test_one<polygon, polygon, polygon>(27,
+ first_within_second[0], first_within_second[1],
+ 1, 5, 1.0);
+
+ test_one<polygon, polygon, polygon>(28,
+ first_within_second[1], first_within_second[0],
+ 1, 5, 1.0);
+
+ test_one<polygon, polygon, polygon>(29,
+ first_within_hole_of_second[0], first_within_hole_of_second[1],
+ 0, 0, 0.0);
+
+ // Two forming new hole
+ test_one<polygon, polygon, polygon>(30,
+ new_hole[0], new_hole[1],
+ 2, 10, 2.0);
+
+ // Two identical
+ test_one<polygon, polygon, polygon>(31,
+ identical[0], identical[1],
+ 1, 5, 1.0);
+
+ // Two, inside each other, having intersections but holes are disjoint
+ test_one<polygon, polygon, polygon>(32,
+ intersect_holes_disjoint[0], intersect_holes_disjoint[1],
+ 1, 15, 18.0);
+
+ // Two, inside each other, having no intersections but holes are disjoint
+ test_one<polygon, polygon, polygon>(33,
+ intersect_holes_disjoint[0], intersect_holes_disjoint[1],
+ 1, 15, 18.0);
+
+ // Two, inside each other, having intersections; holes separate intersections
+ test_one<polygon, polygon, polygon>(34,
+ intersect_holes_intersect[0], intersect_holes_intersect[1],
+ 1, 14, 18.25);
+
+ test_one<polygon, polygon, polygon>(35,
+ intersect_holes_intersect_and_disjoint[0], intersect_holes_intersect_and_disjoint[1],
+ 1, 19, 17.25);
+
+ test_one<polygon, polygon, polygon>(36,
+ intersect_holes_intersect_and_touch[0], intersect_holes_intersect_and_touch[1],
+ 1, 24, 17.25);
+
+
+ test_one<polygon, polygon, polygon>(37,
+ winded[0], winded[1],
+ 1, 22, 40.0);
+
+
+
+ /*
+ test_one<polygon, box, polygon>(99, "box(115041.10 471900.10, 118334.60 474523.40)",
+ "POLYGON ((115483.40 474533.40, 116549.40 474059.20, 117199.90 473762.50, 117204.90 473659.50, 118339.40 472796.90, 118334.50 472757.90, 118315.10 472604.00, 118344.60 472520.90, 118277.90 472419.10, 118071.40 472536.80, 118071.40 472536.80, 117943.10 472287.70, 117744.90 472248.40, 117708.00 472034.50, 117481.90 472056.90, 117481.90 472056.90, 117272.30 471890.10, 117077.90 472161.20, 116146.60 473054.50, 115031.10 473603.30, 115483.40 474533.40))",
+ 1, 26, 3727690.74);
+ */
+
+}
+
+void test_pointer_version()
+{
+ std::vector<test::test_point_xy*> ln;
+ test::test_point_xy* p;
+ p = new test::test_point_xy; p->x = 0; p->y = 0; ln.push_back(p);
+ p = new test::test_point_xy; p->x = 10; p->y = 10; ln.push_back(p);
+
+ ggl::box<ggl::point_xy<double> > box;
+ ggl::assign(box, 2, 2, 8, 8);
+
+ typedef ggl::linestring<ggl::point_xy<double> > output_type;
+ std::vector<output_type> clip;
+ ggl::intersection<output_type>(box, ln, std::back_inserter(clip));
+
+ double length = 0;
+ int n = 0;
+ for (std::vector<output_type>::const_iterator it = clip.begin();
+ it != clip.end(); ++it)
+ {
+ length += ggl::length(*it);
+ n += ggl::num_points(*it);
+ }
+
+ BOOST_CHECK_EQUAL(clip.size(), 1);
+ BOOST_CHECK_EQUAL(n, 2);
+ BOOST_CHECK_CLOSE(length, sqrt(2.0 * 6.0 * 6.0), 0.001);
+
+
+ for (unsigned int i = 0; i < ln.size(); i++)
+ {
+ delete ln[i];
+ }
+}
+
+int test_main(int, char* [])
+{
+ test_all<ggl::point_xy<double> >();
+ test_pointer_version();
+ return 0;
+}
Modified: sandbox/ggl/formal_review_request/libs/ggl/test/algorithms/length.cpp
==============================================================================
--- sandbox/ggl/formal_review_request/libs/ggl/test/algorithms/length.cpp (original)
+++ sandbox/ggl/formal_review_request/libs/ggl/test/algorithms/length.cpp 2009-11-02 10:53:23 EST (Mon, 02 Nov 2009)
@@ -5,15 +5,11 @@
// 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 <algorithms/test_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 {
Added: sandbox/ggl/formal_review_request/libs/ggl/test/algorithms/overlaps.cpp
==============================================================================
--- (empty file)
+++ sandbox/ggl/formal_review_request/libs/ggl/test/algorithms/overlaps.cpp 2009-11-02 10:53:23 EST (Mon, 02 Nov 2009)
@@ -0,0 +1,63 @@
+// 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 <algorithms/test_overlaps.hpp>
+
+
+#include <ggl/geometries/box.hpp>
+#include <ggl/geometries/cartesian2d.hpp>
+#include <ggl/geometries/linear_ring.hpp>
+#include <ggl/geometries/linestring.hpp>
+#include <ggl/geometries/point.hpp>
+#include <ggl/geometries/point_xy.hpp>
+#include <ggl/geometries/polygon.hpp>
+
+
+template <typename P>
+void test_2d()
+{
+ test_geometry<ggl::box<P>, ggl::box<P> >("BOX(1 1, 3 3)", "BOX(0 0,2 2)", true);
+
+ // touch -> false
+ test_geometry<ggl::box<P>, ggl::box<P> >("BOX(1 1, 3 3)", "BOX(3 3,5 5)", false);
+
+ // disjoint -> false
+ test_geometry<ggl::box<P>, ggl::box<P> >("BOX(1 1, 3 3)", "BOX(4 4,6 6)", false);
+
+ // within -> false
+ test_geometry<ggl::box<P>, ggl::box<P> >("BOX(1 1, 5 5)", "BOX(2 2,3 3)", false);
+
+ // within+touch -> false
+ test_geometry<ggl::box<P>, ggl::box<P> >("BOX(1 1, 5 5)", "BOX(2 2,5 5)", false);
+}
+
+template <typename P>
+void test_3d()
+{
+ test_geometry<ggl::box<P>, ggl::box<P> >("BOX(1 1 1, 3 3 3)", "BOX(0 0 0,2 2 2)", true);
+ test_geometry<ggl::box<P>, ggl::box<P> >("BOX(1 1 1, 3 3 3)", "BOX(3 3 3,5 5 5)", false);
+ test_geometry<ggl::box<P>, ggl::box<P> >("BOX(1 1 1, 3 3 3)", "BOX(4 4 4,6 6 6)", false);
+}
+
+
+
+int test_main( int , char* [] )
+{
+ test_2d<ggl::point_xy<int> >();
+ test_2d<ggl::point_xy<double> >();
+
+#if defined(HAVE_CLN)
+ test_2d<ggl::point_xy<boost::numeric_adaptor::cln_value_type> >();
+#endif
+#if defined(HAVE_GMP)
+ test_2d<ggl::point_xy<boost::numeric_adaptor::gmp_value_type> >();
+#endif
+
+ //test_3d<ggl::point<double, 3, ggl::cs::cartesian> >();
+
+ return 0;
+}
Modified: sandbox/ggl/formal_review_request/libs/ggl/test/algorithms/perimeter.cpp
==============================================================================
--- sandbox/ggl/formal_review_request/libs/ggl/test/algorithms/perimeter.cpp (original)
+++ sandbox/ggl/formal_review_request/libs/ggl/test/algorithms/perimeter.cpp 2009-11-02 10:53:23 EST (Mon, 02 Nov 2009)
@@ -5,11 +5,6 @@
// 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>
Modified: sandbox/ggl/formal_review_request/libs/ggl/test/algorithms/simplify.cpp
==============================================================================
--- sandbox/ggl/formal_review_request/libs/ggl/test/algorithms/simplify.cpp (original)
+++ sandbox/ggl/formal_review_request/libs/ggl/test/algorithms/simplify.cpp 2009-11-02 10:53:23 EST (Mon, 02 Nov 2009)
@@ -8,17 +8,13 @@
#include <iterator>
-#include <ggl_test_common.hpp>
-#include <ggl/algorithms/simplify.hpp>
-#include <ggl/algorithms/distance.hpp>
+#include <algorithms/test_simplify.hpp>
#include <ggl/geometries/geometries.hpp>
-#include <ggl/extensions/gis/io/wkt/wkt.hpp>
#include <test_common/test_point.hpp>
-#include <algorithms/test_simplify.hpp>
Modified: sandbox/ggl/formal_review_request/libs/ggl/test/algorithms/test_area.hpp
==============================================================================
--- sandbox/ggl/formal_review_request/libs/ggl/test/algorithms/test_area.hpp (original)
+++ sandbox/ggl/formal_review_request/libs/ggl/test/algorithms/test_area.hpp 2009-11-02 10:53:23 EST (Mon, 02 Nov 2009)
@@ -8,7 +8,13 @@
#ifndef GGL_TEST_AREA_HPP
#define GGL_TEST_AREA_HPP
-// Test-functionality, shared between single and multi tests
+
+#include <ggl_test_common.hpp>
+
+#include <ggl/algorithms/area.hpp>
+#include <ggl/strategies/strategies.hpp>
+
+#include <ggl/extensions/gis/io/wkt/read_wkt.hpp>
template <typename Geometry>
Modified: sandbox/ggl/formal_review_request/libs/ggl/test/algorithms/test_centroid.hpp
==============================================================================
--- sandbox/ggl/formal_review_request/libs/ggl/test/algorithms/test_centroid.hpp (original)
+++ sandbox/ggl/formal_review_request/libs/ggl/test/algorithms/test_centroid.hpp 2009-11-02 10:53:23 EST (Mon, 02 Nov 2009)
@@ -10,6 +10,15 @@
// Test-functionality, shared between single and multi tests
+#include <ggl_test_common.hpp>
+
+#include <ggl/strategies/strategies.hpp>
+#include <ggl/algorithms/centroid.hpp>
+#include <ggl/algorithms/distance.hpp>
+
+#include <ggl/extensions/gis/io/wkt/read_wkt.hpp>
+
+
template<std::size_t D>
struct check_result
{
@@ -48,7 +57,7 @@
// Calculate it with user defined strategy
point_type c2;
ggl::centroid(geometry, c2,
- ggl::strategy::centroid::bashein_detmer<point_type, point_type, CalculationType>());
+ ggl::strategy::centroid_::bashein_detmer<point_type, point_type, CalculationType>());
std::cout << typeid(CalculationType).name() << ": " << std::setprecision(20)
<< ggl::get<0>(c2) << " " << ggl::get<1>(c2)
Modified: sandbox/ggl/formal_review_request/libs/ggl/test/algorithms/test_convex_hull.hpp
==============================================================================
--- sandbox/ggl/formal_review_request/libs/ggl/test/algorithms/test_convex_hull.hpp (original)
+++ sandbox/ggl/formal_review_request/libs/ggl/test/algorithms/test_convex_hull.hpp 2009-11-02 10:53:23 EST (Mon, 02 Nov 2009)
@@ -8,7 +8,18 @@
#ifndef GGL_TEST_CONVEX_HULL_HPP
#define GGL_TEST_CONVEX_HULL_HPP
-// Test-functionality, shared between single and multi tests
+#include <ggl_test_common.hpp>
+
+#include <ggl/algorithms/convex_hull.hpp>
+#include <ggl/algorithms/area.hpp>
+#include <ggl/algorithms/num_points.hpp>
+
+#include <ggl/strategies/strategies.hpp>
+
+#include <ggl/extensions/gis/io/wkt/read_wkt.hpp>
+#include <ggl/extensions/gis/io/wkt/write_wkt.hpp>
+
+#include <ggl/geometries/polygon.hpp>
template <typename Geometry, typename Hull>
@@ -65,13 +76,28 @@
// Test version with ring as output
ggl::clear(hull);
- convex_hull(geometry, hull.outer());
+ ggl::convex_hull(geometry, hull.outer());
test_convex_hull(geometry, hull, size_original, size_hull, expected_area, false);
// Test version with polygon as output
ggl::clear(hull);
- convex_hull(geometry, hull);
+ ggl::convex_hull(geometry, hull);
+ test_convex_hull(geometry, hull, size_original, size_hull, expected_area, false);
+
+ // Test version with strategy
+ ggl::clear(hull);
+ ggl::strategy::convex_hull::graham_andrew
+ <
+ Geometry,
+ typename ggl::point_type<Geometry>::type
+ > graham;
+ ggl::convex_hull(geometry, hull.outer(), graham);
test_convex_hull(geometry, hull, size_original, size_hull, expected_area, false);
+
+ // Test version with output iterator and strategy
+ ggl::clear(hull);
+ ggl::convex_hull_inserter(geometry, std::back_inserter(hull.outer()), graham);
+ test_convex_hull(geometry, hull, size_original, size_hull, expected_area, ! Clockwise);
}
template <typename Geometry>
Modified: sandbox/ggl/formal_review_request/libs/ggl/test/algorithms/test_for_each.hpp
==============================================================================
--- sandbox/ggl/formal_review_request/libs/ggl/test/algorithms/test_for_each.hpp (original)
+++ sandbox/ggl/formal_review_request/libs/ggl/test/algorithms/test_for_each.hpp 2009-11-02 10:53:23 EST (Mon, 02 Nov 2009)
@@ -8,8 +8,12 @@
#ifndef GGL_TEST_FOR_EACH_HPP
#define GGL_TEST_FOR_EACH_HPP
-// Test-functionality, shared between single and multi tests
+#include <ggl_test_common.hpp>
+
+#include <ggl/algorithms/for_each.hpp>
+
#include <ggl/algorithms/distance.hpp>
+#include <ggl/strategies/strategies.hpp>
#include <ggl/extensions/gis/io/wkt/wkt.hpp>
#include <ggl/util/write_dsv.hpp>
Added: sandbox/ggl/formal_review_request/libs/ggl/test/algorithms/test_intersection.hpp
==============================================================================
--- (empty file)
+++ sandbox/ggl/formal_review_request/libs/ggl/test/algorithms/test_intersection.hpp 2009-11-02 10:53:23 EST (Mon, 02 Nov 2009)
@@ -0,0 +1,112 @@
+// 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_INTERSECTION_HPP
+#define GGL_TEST_INTERSECTION_HPP
+
+#include <fstream>
+
+#include <ggl_test_common.hpp>
+
+#include <ggl/algorithms/intersection.hpp>
+#include <ggl/algorithms/area.hpp>
+#include <ggl/algorithms/length.hpp>
+#include <ggl/algorithms/num_points.hpp>
+#include <ggl/algorithms/simplify.hpp>
+
+#include <ggl/geometries/geometries.hpp>
+
+#include <ggl/strategies/strategies.hpp>
+
+#include <ggl/extensions/gis/io/wkt/read_wkt.hpp>
+
+
+#if defined(TEST_WITH_SVG)
+# include <test_util/svg_mapper.hpp>
+#endif
+
+
+template <typename OutputType, typename G1, typename G2>
+void test_intersection(int caseid, G1 const& g1, G2 const& g2,
+ int expected_count = 0, int expected_point_count = 0,
+ double expected_length_or_area = 0)
+{
+ static const bool is_line = ggl::geometry_id<OutputType>::type::value == 2;
+
+ std::vector<OutputType> clip;
+ ggl::intersection<OutputType>(g1, g2, std::back_inserter(clip));
+
+ double length_or_area = 0;
+ int n = 0;
+ for (typename std::vector<OutputType>::const_iterator it = clip.begin();
+ it != clip.end(); ++it)
+ {
+ // instead of specialization we check it run-time here
+ length_or_area += is_line
+ ? ggl::length(*it)
+ : ggl::area(*it);
+
+ // Simplify to get a correct point-count without duplicate points
+ // (note that overlay might be adapted to avoid duplicates)
+ OutputType simplified;
+ ggl::simplify(*it, simplified, 0.0001);
+ n += ggl::num_points(simplified);
+
+ //std::cout << std::endl << "case " << caseid << " ";
+ //std::cout << ggl::dsv(*it) << std::endl;
+ }
+
+
+ BOOST_CHECK_EQUAL(clip.size(), expected_count);
+ BOOST_CHECK_EQUAL(n, expected_point_count);
+ BOOST_CHECK_CLOSE(length_or_area, expected_length_or_area, 0.001);
+
+
+#if defined(TEST_WITH_SVG)
+ {
+ std::ostringstream filename;
+ filename << "intersection" << caseid << ".svg";
+
+ std::ofstream svg(filename.str().c_str());
+
+ svg_mapper<typename ggl::point_type<G2>::type> mapper(svg, 500, 500);
+ mapper.add(g1);
+ mapper.add(g2);
+
+ mapper.map(g1, is_line
+ ? "opacity:0.6;stroke:rgb(0,0,255);stroke-width:5"
+ : "opacity:0.6;fill:rgb(0,0,255);stroke:rgb(0,0,0);stroke-width:1");
+ mapper.map(g2, "opacity:0.6;fill:rgb(0,255,0);stroke:rgb(0,0,0);stroke-width:1");
+
+ for (typename std::vector<OutputType>::const_iterator it = clip.begin();
+ it != clip.end(); ++it)
+ {
+ mapper.map(*it, "opacity:0.6;fill:none;stroke:rgb(255,0,0);stroke-width:5");
+ }
+ }
+#endif
+}
+
+template <typename OutputType, typename G1, typename G2>
+void test_one(int caseid, std::string const& wkt1, std::string const& wkt2,
+ int expected_count = 0, int expected_point_count = 0,
+ double expected_length_or_area = 0)
+{
+ G1 g1;
+ ggl::read_wkt(wkt1, g1);
+
+ G2 g2;
+ ggl::read_wkt(wkt2, g2);
+
+ test_intersection<OutputType>(caseid, g1, g2,
+ expected_count, expected_point_count,
+ expected_length_or_area);
+}
+
+
+
+#endif
Modified: sandbox/ggl/formal_review_request/libs/ggl/test/algorithms/test_length.hpp
==============================================================================
--- sandbox/ggl/formal_review_request/libs/ggl/test/algorithms/test_length.hpp (original)
+++ sandbox/ggl/formal_review_request/libs/ggl/test/algorithms/test_length.hpp 2009-11-02 10:53:23 EST (Mon, 02 Nov 2009)
@@ -8,7 +8,11 @@
#ifndef GGL_TEST_LENGTH_HPP
#define GGL_TEST_LENGTH_HPP
-// Test-functionality, shared between single and multi tests
+#include <ggl_test_common.hpp>
+
+#include <ggl/algorithms/length.hpp>
+#include <ggl/extensions/gis/io/wkt/read_wkt.hpp>
+#include <ggl/strategies/strategies.hpp>
template <typename Geometry>
Added: sandbox/ggl/formal_review_request/libs/ggl/test/algorithms/test_overlaps.hpp
==============================================================================
--- (empty file)
+++ sandbox/ggl/formal_review_request/libs/ggl/test/algorithms/test_overlaps.hpp 2009-11-02 10:53:23 EST (Mon, 02 Nov 2009)
@@ -0,0 +1,43 @@
+// Generic Geometry2 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_OVERLAPS_HPP
+#define GGL_TEST_OVERLAPS_HPP
+
+
+#include <ggl_test_common.hpp>
+
+#include <ggl/core/ring_type.hpp>
+#include <ggl/algorithms/overlaps.hpp>
+#include <ggl/strategies/strategies.hpp>
+#include <ggl/geometries/linear_ring.hpp>
+#include <ggl/geometries/polygon.hpp>
+
+#include <ggl/extensions/gis/io/wkt/read_wkt.hpp>
+
+
+template <typename Geometry1, typename Geometry2>
+void test_geometry(std::string const& wkt1,
+ std::string const& wkt2, bool expected)
+{
+ Geometry1 geometry1;
+ Geometry2 geometry2;
+
+ ggl::read_wkt(wkt1, geometry1);
+ ggl::read_wkt(wkt2, geometry2);
+
+ bool detected = ggl::overlaps(geometry1, geometry2);
+
+ BOOST_CHECK_MESSAGE(detected == expected,
+ "overlaps: " << wkt1
+ << " in " << wkt2
+ << " -> Expected: " << expected
+ << " detected: " << detected);
+}
+
+
+#endif
Added: sandbox/ggl/formal_review_request/libs/ggl/test/algorithms/test_overlay.hpp
==============================================================================
--- (empty file)
+++ sandbox/ggl/formal_review_request/libs/ggl/test/algorithms/test_overlay.hpp 2009-11-02 10:53:23 EST (Mon, 02 Nov 2009)
@@ -0,0 +1,80 @@
+// 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_OVERLAY_HPP
+#define GGL_TEST_OVERLAY_HPP
+
+#include <string>
+
+static std::string example_box = "box(1.5 1.5, 4.5 2.5)";
+static std::string example_ring =
+ "POLYGON((2 1.3,2.4 1.7,2.8 1.8,3.4 1.2,3.7 1.6,3.4 2,4.1 3,5.3 2.6,5.4 1.2,4.9 0.8,2.9 0.7,2 1.3))";
+
+static std::string example_polygon =
+ "POLYGON((2 1.3,2.4 1.7,2.8 1.8,3.4 1.2,3.7 1.6,3.4 2,4.1 3,5.3 2.6,5.4 1.2,4.9 0.8,2.9 0.7,2 1.3)"
+ "(4.0 2.0, 4.2 1.4, 4.8 1.9, 4.4 2.2, 4.0 2.0))";
+
+
+
+static std::string example_star =
+ "POLYGON((4.0 -0.5 , 3.5 1.0 , 2.0 1.5 , 3.5 2.0 , 4.0 3.5 , 4.5 2.0 , 6.0 1.5 , 4.5 1.0 , 4.0 -0.5))";
+
+static std::string identical[2] =
+ {"POLYGON((0 0,0 1,1 1,1 0,0 0))",
+ "POLYGON((1 1,1 0,0 0,0 1,1 1))"};
+
+
+static std::string new_hole[2] =
+ {"POLYGON((2 2,2 5,5 5,5 2,2 2))",
+ "POLYGON((0 0,0 6,3 6,3 4,1 4,1 3,3 3,3 0,0 0))"};
+
+
+static std::string side_side[2] =
+ {"POLYGON((0 0,0 1,1 1,1 0,0 0))",
+ "POLYGON((1 0,1 1,2 1,2 0,1 0))"};
+
+
+ // First within second
+static std::string first_within_second[2] =
+ {"POLYGON((2 2,2 3,3 3,3 2,2 2))",
+ "POLYGON((0 0, 0 5, 5 5, 5 0, 0 0))"};
+
+
+ // First within hole of second
+static std::string first_within_hole_of_second[2] =
+ {"POLYGON((2 2,2 3,3 3,3 2,2 2))",
+ "POLYGON((0 0, 0 5, 5 5, 5 0, 0 0),(1 1,4 1,4 4,1 4,1 1))"};
+
+
+// within each other, having no intersections but many holes within each other
+static std::string winded[2] =
+ {"POLYGON((0 0,0 11,11 11,11 0,0 0),(3 3,4 3,4 4,3 4,3 3),(5 3,6 3,6 4,5 4,5 3),(2 6,7 6,7 6,7 9,2 9,2 6),(9 2,10 2,10 5,9 5,9 2))",
+ "POLYGON((1 1,1 10,10 10,10 6,8 6,8 1,1 1),(2 2,7 2,7 5,2 5,2 2),(3 7,4 7,4 8,3 8,3 7),(5 7,6 7,6 8,5 8,5 7),(8 7,9 7,9 8,8 8,8 7))"};
+
+static std::string intersect_holes_disjoint[2] =
+ {"POLYGON((0 0,0 7,5 7,5 0,0 0),(2 2,3 2,3 3,2 3,2 2))",
+ "POLYGON((1 1,1 6,6 6,6 1,1 1),(2 4,3 4,3 5,2 5,2 4))"};
+
+static std::string within_holes_disjoint[2] =
+ {"POLYGON((0 0,0 7,7 7,7 0,0 0),(2 2,3 2,3 3,2 3,2 2))",
+ "POLYGON((1 1,1 6,6 6,6 1,1 1),(2 4,3 4,3 5,2 5,2 4))"};
+
+static std::string intersect_holes_intersect[2] =
+ {"POLYGON((0 0,0 7,5 7,5 0,0 0),(2 2,3 2,3 3,2 3,2 2))",
+ "POLYGON((1 1,1 6,6 6,6 1,1 1),(2.5 2.5,3.5 2.5,3.5 3.5,2.5 3.5,2.5 2.5))"};
+
+static std::string intersect_holes_intersect_and_disjoint[2] =
+ {"POLYGON((0 0,0 7,5 7,5 0,0 0),(2 2,3 2,3 3,2 3,2 2),(2 4,3 4,3 5,2 5,2 4))",
+ "POLYGON((1 1,1 6,6 6,6 1,1 1),(2.5 2.5,3.5 2.5,3.5 3.5,2.5 3.5,2.5 2.5))"};
+
+
+static std::string intersect_holes_intersect_and_touch[2] =
+ {"POLYGON((0 0,0 7,5 7,5 0,0 0),(2 2,3 2,3 3,2 3,2 2),(2.5 4,3 4.5,2.5 5,2 4.5,2.5 4))",
+ "POLYGON((1 1,1 6,6 6,6 1,1 1),(2.5 2.5,3.5 2.5,3.5 3.5,2.5 3.5,2.5 2.5),(3.5 4,4 4.5,3.5 5,3 4.5,3.5 4))"};
+
+
+#endif
Modified: sandbox/ggl/formal_review_request/libs/ggl/test/algorithms/test_perimeter.hpp
==============================================================================
--- sandbox/ggl/formal_review_request/libs/ggl/test/algorithms/test_perimeter.hpp (original)
+++ sandbox/ggl/formal_review_request/libs/ggl/test/algorithms/test_perimeter.hpp 2009-11-02 10:53:23 EST (Mon, 02 Nov 2009)
@@ -8,7 +8,14 @@
#ifndef GGL_TEST_PERIMETER_HPP
#define GGL_TEST_PERIMETER_HPP
-// Test-functionality, shared between single and multi tests
+
+#include <ggl_test_common.hpp>
+
+#include <ggl/algorithms/perimeter.hpp>
+#include <ggl/strategies/strategies.hpp>
+
+
+#include <ggl/extensions/gis/io/wkt/read_wkt.hpp>
template <typename Geometry>
Modified: sandbox/ggl/formal_review_request/libs/ggl/test/algorithms/test_simplify.hpp
==============================================================================
--- sandbox/ggl/formal_review_request/libs/ggl/test/algorithms/test_simplify.hpp (original)
+++ sandbox/ggl/formal_review_request/libs/ggl/test/algorithms/test_simplify.hpp 2009-11-02 10:53:23 EST (Mon, 02 Nov 2009)
@@ -10,7 +10,12 @@
// Test-functionality, shared between single and multi tests
+#include <ggl_test_common.hpp>
+#include <ggl/algorithms/simplify.hpp>
+#include <ggl/algorithms/distance.hpp>
+#include <ggl/strategies/strategies.hpp>
+#include <ggl/extensions/gis/io/wkt/wkt.hpp>
template <typename Tag, typename Geometry>
struct test_inserter
@@ -61,7 +66,7 @@
typedef ggl::strategy::distance::xy_point_segment
<
point_type,
- ggl::segment<const point_type>
+ point_type
> strategy;
typedef ggl::strategy::simplify::douglas_peucker
<
Added: sandbox/ggl/formal_review_request/libs/ggl/test/algorithms/test_union.hpp
==============================================================================
--- (empty file)
+++ sandbox/ggl/formal_review_request/libs/ggl/test/algorithms/test_union.hpp 2009-11-02 10:53:23 EST (Mon, 02 Nov 2009)
@@ -0,0 +1,115 @@
+// 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_UNION_HPP
+#define GGL_TEST_UNION_HPP
+
+#include <fstream>
+
+#include <ggl_test_common.hpp>
+
+#include <ggl/algorithms/union.hpp>
+
+#include <ggl/algorithms/area.hpp>
+#include <ggl/algorithms/length.hpp>
+#include <ggl/algorithms/num_points.hpp>
+#include <ggl/algorithms/simplify.hpp>
+
+#include <ggl/geometries/geometries.hpp>
+
+#include <ggl/strategies/strategies.hpp>
+
+#include <ggl/extensions/gis/io/wkt/read_wkt.hpp>
+
+
+#if defined(TEST_WITH_SVG)
+# include <test_util/svg_mapper.hpp>
+#endif
+
+
+
+template <typename OutputType, typename G1, typename G2>
+void test_union(int caseid, G1 const& g1, G2 const& g2,
+ int expected_count, int expected_hole_count,
+ int expected_point_count, double expected_area)
+{
+ std::vector<OutputType> clip;
+ ggl::union_inserter<OutputType>(g1, g2, std::back_inserter(clip));
+
+ double area = 0;
+ int n = 0;
+ int holes = 0;
+ for (typename std::vector<OutputType>::const_iterator it = clip.begin();
+ it != clip.end(); ++it)
+ {
+ area += ggl::area(*it);
+ holes += ggl::num_interior_rings(*it);
+
+ // Simplify to get a correct point-count without duplicate points
+ // (note that overlay might be adapted to avoid duplicates)
+ OutputType simplified;
+ ggl::simplify(*it, simplified, 0.0001);
+ n += ggl::num_points(simplified);
+ }
+
+
+ /***
+ std::cout << "case: " << caseid
+ << " n: " << n
+ << " area: " << area
+ << " polygons: " << boost::size(clip)
+ << " holes: " << holes
+ << std::endl;
+ ***/
+
+ BOOST_CHECK_EQUAL(clip.size(), expected_count);
+ BOOST_CHECK_EQUAL(n, expected_point_count);
+ BOOST_CHECK_EQUAL(holes, expected_hole_count);
+ BOOST_CHECK_CLOSE(area, expected_area, 0.001);
+
+#if defined(TEST_WITH_SVG)
+ {
+ std::ostringstream filename;
+ filename << "union" << caseid << ".svg";
+
+ std::ofstream svg(filename.str().c_str());
+
+ svg_mapper<typename ggl::point_type<G2>::type> mapper(svg, 500, 500);
+ mapper.add(g1);
+ mapper.add(g2);
+
+ mapper.map(g1, "opacity:0.6;fill:rgb(0,0,255);stroke:rgb(0,0,0);stroke-width:1");
+ mapper.map(g2, "opacity:0.6;fill:rgb(0,255,0);stroke:rgb(0,0,0);stroke-width:1");
+
+ for (typename std::vector<OutputType>::const_iterator it = clip.begin();
+ it != clip.end(); ++it)
+ {
+ mapper.map(*it, "opacity:0.6;fill:none;stroke:rgb(255,0,0);stroke-width:5");
+ }
+ }
+#endif
+}
+
+template <typename OutputType, typename G1, typename G2>
+void test_one(int caseid, std::string const& wkt1, std::string const& wkt2,
+ int expected_count, int expected_hole_count,
+ int expected_point_count, double expected_area)
+{
+ G1 g1;
+ ggl::read_wkt(wkt1, g1);
+
+ G2 g2;
+ ggl::read_wkt(wkt2, g2);
+
+ test_union<OutputType>(caseid, g1, g2,
+ expected_count, expected_hole_count, expected_point_count,
+ expected_area);
+}
+
+
+
+#endif
Modified: sandbox/ggl/formal_review_request/libs/ggl/test/algorithms/test_within.hpp
==============================================================================
--- sandbox/ggl/formal_review_request/libs/ggl/test/algorithms/test_within.hpp (original)
+++ sandbox/ggl/formal_review_request/libs/ggl/test/algorithms/test_within.hpp 2009-11-02 10:53:23 EST (Mon, 02 Nov 2009)
@@ -8,28 +8,38 @@
#ifndef GGL_TEST_WITHIN_HPP
#define GGL_TEST_WITHIN_HPP
-// Test-functionality, shared between single and multi tests
+#include <ggl_test_common.hpp>
-template <typename Point, typename Geometry>
-void test_geometry(std::string const& wkt_point,
- std::string const& wkt_geometry, bool expected)
+#include <ggl/core/ring_type.hpp>
+#include <ggl/algorithms/within.hpp>
+#include <ggl/strategies/strategies.hpp>
+#include <ggl/geometries/linear_ring.hpp>
+#include <ggl/geometries/polygon.hpp>
+
+#include <ggl/extensions/gis/io/wkt/read_wkt.hpp>
+
+
+template <typename Geometry1, typename Geometry2>
+void test_geometry(std::string const& wkt1,
+ std::string const& wkt2, bool expected)
{
- Geometry geometry;
- Point point;
+ Geometry1 geometry1;
+ Geometry2 geometry2;
- ggl::read_wkt(wkt_geometry, geometry);
- ggl::read_wkt(wkt_point, point);
+ ggl::read_wkt(wkt1, geometry1);
+ ggl::read_wkt(wkt2, geometry2);
- bool detected = ggl::within(point, geometry);
+ bool detected = ggl::within(geometry1, geometry2);
BOOST_CHECK_MESSAGE(detected == expected,
- "within: " << wkt_point
- << " in " << wkt_geometry
+ "within: " << wkt1
+ << " in " << wkt2
<< " -> Expected: " << expected
<< " detected: " << detected);
}
+
template <typename Point, bool CW>
void test_ordered_ring(std::string const& wkt_point,
std::string const& wkt_geometry, bool expected, bool on_border)
@@ -67,7 +77,7 @@
<< " detected: " << detected);
}
-
+
ggl::strategy::within::crossings_multiply<Point> cm;
detected = ggl::within(point, ring, cm);
if (! on_border)
@@ -82,7 +92,7 @@
template <typename Point>
void test_ring(std::string const& wkt_point,
- std::string const& wkt_geometry,
+ std::string const& wkt_geometry,
bool expected, bool on_border)
{
test_ordered_ring<Point, true>(wkt_point, wkt_geometry, expected, on_border);
Added: sandbox/ggl/formal_review_request/libs/ggl/test/algorithms/union.cpp
==============================================================================
--- (empty file)
+++ sandbox/ggl/formal_review_request/libs/ggl/test/algorithms/union.cpp 2009-11-02 10:53:23 EST (Mon, 02 Nov 2009)
@@ -0,0 +1,148 @@
+// 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 <iostream>
+#include <string>
+
+#include <algorithms/test_union.hpp>
+#include <algorithms/test_overlay.hpp>
+
+
+template <typename P>
+void test_all()
+{
+ typedef ggl::polygon<P> polygon;
+ typedef ggl::linear_ring<P> ring;
+ typedef ggl::box<P> box;
+
+ test_one<polygon, box, polygon>(1, example_box, example_ring,
+ 1, 1, 15, 6.38875);
+
+ test_one<polygon, box, polygon>(2, example_box, example_polygon,
+ 1, 3, 23, 6.30983);
+
+ test_one<polygon, polygon, polygon>(3, example_star, example_ring,
+ 1, 0, 23, 5.67017141);
+
+ test_one<polygon, polygon, polygon>(4, example_star, example_polygon,
+ 1, 1, 27, 5.647949);
+
+ test_one<polygon, box, polygon>(5, example_box,
+ "POLYGON((3.4 2,4.1 3,5.3 2.6,5.4 1.2,4.9 0.8,2.9 0.7,2 1.3,2.4 1.7,2.8 1.8,3.4 1.2,3.7 1.6,3.4 2))",
+ 1, 1, 15, 6.38875);
+ test_one<polygon, box, polygon>(6, example_box,
+ "POLYGON((2 1.3,2.4 1.7,2.8 1.8,3.4 1.2,3.7 1.6,3.4 2,4.1 2.5,5.3 2.5,5.4 1.2,4.9 0.8,2.9 0.7,2 1.3))",
+ 1, 1, 13, 5.93625);
+
+ // Same as 3, but now as polygon
+ // (note, internally, the intersection points is different, so yes,
+ // it has to be tested)
+ test_one<polygon, polygon, polygon>(7, "POLYGON((1.5 1.5 , 1.5 2.5 , 4.5 2.5 , 4.5 1.5 , 1.5 1.5))",
+ "POLYGON((2 1.3,2.4 1.7,2.8 1.8,3.4 1.2,3.7 1.6,3.4 2,4.1 2.5,5.3 2.5,5.4 1.2,4.9 0.8,2.9 0.7,2 1.3))",
+ 1, 1, 13, 5.93625);
+
+ test_one<polygon, box, polygon>(8, example_box,
+ "POLYGON((2 1.3,2.4 1.7,2.8 1.8,3.4 1.2,3.7 1.6,3.4 2,4.1 2.5,4.5 2.5,4.5 1.2,4.9 0.8,2.9 0.7,2 1.3))",
+ 1, 1, 13, 4.651245);
+
+ test_one<polygon, box, polygon>(9, example_box,
+ "POLYGON((2 1.3,2.4 1.7,2.8 1.8,3.4 1.2,3.7 1.6,3.4 2,4.1 2.5,4.5 2.5,4.5 2.3,5.0 2.3,5.0 2.1,4.5 2.1,4.5 1.9,4.0 1.9,4.5 1.2,4.9 0.8,2.9 0.7,2 1.3))",
+ 1, 1, 19, 4.7191);
+
+ test_one<polygon, box, polygon>(10, example_box,
+ "POLYGON((2 1.3,2.4 1.7,2.8 1.8,3.4 1.2,3.7 1.6,3.4 2,4.1 2.5,4.5 1.2,2.9 0.7,2 1.3))",
+ 1, 1, 14, 4.2174);
+
+ test_one<polygon, box, polygon>(11, example_box,
+ "POLYGON((2 1.3,2.4 1.7,2.8 1.8,3.4 1.2,3.7 1.6,3.4 2,4.0 3.0,5.0 2.0,2.9 0.7,2 1.3))",
+ 1, 1, 16, 4.270554);
+
+ test_one<polygon, box, polygon>(12, "box(0 0, 3 3)",
+ "POLYGON((2 2, 1 4, 2 4, 3 3, 2 2))",
+ 1, 0, 8, 10.25);
+
+
+ // First inside second
+ test_one<polygon, polygon, polygon>(13,
+ first_within_second[0], first_within_second[1],
+ 1, 0, 5, 25.0);
+
+ // Second inside first
+ test_one<polygon, polygon, polygon>(14,
+ first_within_second[1], first_within_second[0],
+ 1, 0, 5, 25.0);
+
+ // First inside hole of second
+ test_one<polygon, polygon, polygon>(15,
+ first_within_hole_of_second[0], first_within_hole_of_second[1],
+ 2, 1, 15, 17.0);
+
+ // forming new hole
+ test_one<polygon, polygon, polygon>(16,
+ new_hole[0], new_hole[1],
+ 1, 1, 14, 23.0);
+
+ // side by side
+ test_one<polygon, polygon, polygon>(17,
+ side_side[0], side_side[1], 1, 0, 6, 2.0);
+
+ // identical
+ test_one<polygon, polygon, polygon>(18,
+ identical[0], identical[1], 1, 0, 5, 1.0);
+
+ // inside each other, having intersections; holes separate intersections
+ test_one<polygon, polygon, polygon>(19,
+ intersect_holes_intersect[0], intersect_holes_intersect[1],
+ 1, 1, 14, 39.75);
+
+ test_one<polygon, polygon, polygon>(20,
+ intersect_holes_intersect_and_disjoint[0], intersect_holes_intersect_and_disjoint[1],
+ 1, 1, 14, 39.75);
+
+ test_one<polygon, polygon, polygon>(21,
+ intersect_holes_intersect_and_touch[0], intersect_holes_intersect_and_touch[1],
+ 1, 1, 14, 39.75);
+
+ // inside each other, having intersections but holes are disjoint
+ test_one<polygon, polygon, polygon>(22,
+ intersect_holes_disjoint[0],
+ intersect_holes_disjoint[1],
+ 1, 0, 9, 40.0);
+
+ // inside each other, having no intersections but holes are disjoint
+ test_one<polygon, polygon, polygon>(23,
+ within_holes_disjoint[0], within_holes_disjoint[1],
+ 1, 0, 5, 49.0);
+
+ test_one<polygon, polygon, polygon>(24,
+ winded[0], winded[1],
+ 1, 5, 30, 114.0);
+
+ // test some other input/output types
+
+ // 1 input ring
+ test_one<polygon, polygon, ring>(31, identical[0], identical[1], 1, 0, 5, 1.0);
+ test_one<polygon, ring, polygon>(32, identical[0], identical[1], 1, 0, 5, 1.0);
+
+ // 2 input rings
+ test_one<polygon, ring, ring>(33, identical[0], identical[1], 1, 0, 5, 1.0);
+
+ // output is also ring
+ test_one<ring, ring, ring>(34, identical[0], identical[1], 1, 0, 5, 1.0);
+
+ // "new hole", tested with ring -> the newly formed hole will be omitted
+ test_one<ring, ring, ring>(35, new_hole[0], new_hole[1], 1, 0, 9, 24.0);
+
+}
+
+
+int test_main(int, char* [])
+{
+ test_all<ggl::point_xy<double> >();
+ return 0;
+}
Modified: sandbox/ggl/formal_review_request/libs/ggl/test/algorithms/within.cpp
==============================================================================
--- sandbox/ggl/formal_review_request/libs/ggl/test/algorithms/within.cpp (original)
+++ sandbox/ggl/formal_review_request/libs/ggl/test/algorithms/within.cpp 2009-11-02 10:53:23 EST (Mon, 02 Nov 2009)
@@ -5,13 +5,8 @@
// 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/within.hpp>
-
-#include <ggl/extensions/gis/io/wkt/read_wkt.hpp>
+#include <algorithms/test_within.hpp>
-#include <ggl/algorithms/assign.hpp>
#include <ggl/geometries/box.hpp>
#include <ggl/geometries/cartesian2d.hpp>
@@ -21,7 +16,6 @@
#include <ggl/geometries/point_xy.hpp>
#include <ggl/geometries/polygon.hpp>
-#include <algorithms/test_within.hpp>
template <typename P>
void test_all()
Modified: sandbox/ggl/formal_review_request/libs/ggl/test/ggl_test_common.hpp
==============================================================================
--- sandbox/ggl/formal_review_request/libs/ggl/test/ggl_test_common.hpp (original)
+++ sandbox/ggl/formal_review_request/libs/ggl/test/ggl_test_common.hpp 2009-11-02 10:53:23 EST (Mon, 02 Nov 2009)
@@ -10,12 +10,24 @@
#ifndef GGL_TEST_GGL_TEST_COMMON_HPP
#define GGL_TEST_GGL_TEST_COMMON_HPP
+#if defined(_MSC_VER)
+// We deliberately mix float/double's so turn off warnings
+#pragma warning( disable : 4244 )
+//#pragma warning( disable : 4305 )
+#endif // defined(_MSC_VER)
+
+
// Just include some always-included files
#include <boost/test/floating_point_comparison.hpp>
#include <boost/test/included/test_exec_monitor.hpp>
+#if defined(HAVE_CLN) || defined(HAVE_GMP)
+# include <boost/numeric_adaptor/numeric_adaptor.hpp>
+#endif
+
+
#if defined(HAVE_GMP)
# include <boost/numeric_adaptor/gmp_value_type.hpp>
#endif
@@ -23,9 +35,5 @@
# include <boost/numeric_adaptor/cln_value_type.hpp>
#endif
-#if defined(HAVE_CLN) || defined(HAVE_GMP)
-# include <boost/numeric_adaptor/numeric_adaptor.hpp>
-#endif
-
#endif // GGL_TEST_GGL_TEST_COMMON_HPP
Modified: sandbox/ggl/formal_review_request/libs/ggl/test/iterators/Jamfile.v2
==============================================================================
--- sandbox/ggl/formal_review_request/libs/ggl/test/iterators/Jamfile.v2 (original)
+++ sandbox/ggl/formal_review_request/libs/ggl/test/iterators/Jamfile.v2 2009-11-02 10:53:23 EST (Mon, 02 Nov 2009)
@@ -11,5 +11,4 @@
[ run circular_iterator.cpp ]
[ run ever_circling_iterator.cpp ]
[ run segment_iterator.cpp ]
- [ run vertex_iterator.cpp ]
;
Modified: sandbox/ggl/formal_review_request/libs/ggl/test/iterators/segment_iterator.cpp
==============================================================================
--- sandbox/ggl/formal_review_request/libs/ggl/test/iterators/segment_iterator.cpp (original)
+++ sandbox/ggl/formal_review_request/libs/ggl/test/iterators/segment_iterator.cpp 2009-11-02 10:53:23 EST (Mon, 02 Nov 2009)
@@ -15,13 +15,11 @@
#include <ggl_test_common.hpp>
-#include <ggl/iterators/segment_iterator.hpp>
-
-
#include <ggl/core/coordinate_type.hpp>
#include <ggl/geometries/cartesian2d.hpp>
#include <ggl/geometries/point.hpp>
#include <ggl/geometries/segment.hpp>
+#include <ggl/iterators/segment_iterator.hpp>
#include <ggl/extensions/gis/io/wkt/read_wkt.hpp>
template <typename C>
Deleted: sandbox/ggl/formal_review_request/libs/ggl/test/iterators/vertex_iterator.cpp
==============================================================================
--- sandbox/ggl/formal_review_request/libs/ggl/test/iterators/vertex_iterator.cpp 2009-11-02 10:53:23 EST (Mon, 02 Nov 2009)
+++ (empty file)
@@ -1,60 +0,0 @@
-// 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 <deque>
-
-#include <ggl_test_common.hpp>
-
-#include <ggl/iterators/vertex_iterator.hpp>
-
-#include <ggl/core/cs.hpp>
-#include <ggl/geometries/point.hpp>
-#include <ggl/geometries/linestring.hpp>
-#include <ggl/geometries/linear_ring.hpp>
-#include <ggl/geometries/polygon.hpp>
-
-template <typename G, bool IsConst, typename Expected>
-void test_geometry()
-{
- typedef typename ggl::vertex_iterator<G, IsConst>::type it;
- BOOST_CHECK_EQUAL(typeid(it).name(), typeid(Expected).name());
-}
-
-template <typename P>
-void test_all()
-{
- test_geometry<ggl::linestring<P>, true,
- typename std::vector<P>::const_iterator>();
- test_geometry<ggl::linestring<P, std::deque>, true,
- typename std::deque<P>::const_iterator>();
-
- test_geometry<ggl::linestring<P>, false,
- typename std::vector<P>::iterator>();
-
- test_geometry<ggl::linear_ring<P>, true,
- typename std::vector<P>::const_iterator>();
- test_geometry<std::vector<P>, true,
- typename std::vector<P>::const_iterator>();
-
- // So by nature of point_const_iterator, even a polygon should
- // deliver a the iterator of the rings making it up
- test_geometry<ggl::polygon<P>, true,
- typename std::vector<P>::const_iterator>();
- test_geometry<ggl::polygon<P, std::deque>, true,
- typename std::deque<P>::const_iterator>();
- test_geometry<ggl::polygon<P, std::deque, std::deque>, true,
- typename std::deque<P>::const_iterator>();
- test_geometry<ggl::polygon<P, std::deque, std::deque>, false,
- typename std::deque<P>::iterator>();
-}
-
-int test_main(int, char* [])
-{
- test_all<ggl::point<double, 2, ggl::cs::cartesian> >();
-
- return 0;
-}
Modified: sandbox/ggl/formal_review_request/libs/ggl/test/multi/algorithms/Jamfile.v2
==============================================================================
--- sandbox/ggl/formal_review_request/libs/ggl/test/multi/algorithms/Jamfile.v2 (original)
+++ sandbox/ggl/formal_review_request/libs/ggl/test/multi/algorithms/Jamfile.v2 2009-11-02 10:53:23 EST (Mon, 02 Nov 2009)
@@ -12,6 +12,7 @@
[ run multi_centroid.cpp ]
[ run multi_convex_hull.cpp ]
[ run multi_correct.cpp ]
+ [ run multi_envelope.cpp ]
[ run multi_for_each.cpp ]
[ run multi_length.cpp ]
[ run multi_perimeter.cpp ]
Modified: sandbox/ggl/formal_review_request/libs/ggl/test/multi/algorithms/multi_centroid.cpp
==============================================================================
--- sandbox/ggl/formal_review_request/libs/ggl/test/multi/algorithms/multi_centroid.cpp (original)
+++ sandbox/ggl/formal_review_request/libs/ggl/test/multi/algorithms/multi_centroid.cpp 2009-11-02 10:53:23 EST (Mon, 02 Nov 2009)
@@ -7,31 +7,22 @@
// http://www.boost.org/LICENSE_1_0.txt)
-#include <ggl_test_common.hpp>
+#include <algorithms/test_centroid.hpp>
+#include <ggl/multi/algorithms/centroid.hpp>
+#include <ggl/multi/strategies/centroid.hpp>
+#include <ggl/multi/strategies/cartesian/centroid_average.hpp>
-#include <ggl/algorithms/assign.hpp>
-#include <ggl/algorithms/centroid.hpp>
-#include <ggl/algorithms/distance.hpp>
-#include <ggl/algorithms/make.hpp>
-#include <ggl/extensions/gis/io/wkt/read_wkt.hpp>
#include <ggl/geometries/geometries.hpp>
#include <ggl/multi/geometries/multi_point.hpp>
#include <ggl/multi/geometries/multi_polygon.hpp>
-
-#include <ggl/multi/algorithms/centroid.hpp>
-
#include <ggl/extensions/gis/io/wkt/read_wkt_multi.hpp>
-#include <algorithms/test_centroid.hpp>
// #define REPORT_RESULTS
-
-
-
template <typename P>
void test_2d(bool is_integer = false)
{
Modified: sandbox/ggl/formal_review_request/libs/ggl/test/multi/algorithms/multi_convex_hull.cpp
==============================================================================
--- sandbox/ggl/formal_review_request/libs/ggl/test/multi/algorithms/multi_convex_hull.cpp (original)
+++ sandbox/ggl/formal_review_request/libs/ggl/test/multi/algorithms/multi_convex_hull.cpp 2009-11-02 10:53:23 EST (Mon, 02 Nov 2009)
@@ -10,18 +10,16 @@
#include <iterator>
#include <string>
+#include <algorithms/test_convex_hull.hpp>
-#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/iterators/range_type.hpp>
+
#include <ggl/multi/algorithms/num_points.hpp>
#include <ggl/multi/algorithms/convex_hull.hpp>
@@ -32,7 +30,6 @@
#include <ggl/multi/geometries/multi_polygon.hpp>
-#include <algorithms/test_convex_hull.hpp>
template <typename P>
Modified: sandbox/ggl/formal_review_request/libs/ggl/test/multi/algorithms/multi_correct.cpp
==============================================================================
--- sandbox/ggl/formal_review_request/libs/ggl/test/multi/algorithms/multi_correct.cpp (original)
+++ sandbox/ggl/formal_review_request/libs/ggl/test/multi/algorithms/multi_correct.cpp 2009-11-02 10:53:23 EST (Mon, 02 Nov 2009)
@@ -8,6 +8,9 @@
#include <ggl_test_common.hpp>
#include <ggl/algorithms/correct.hpp>
+
+#include <ggl/strategies/strategies.hpp>
+
#include <ggl/multi/algorithms/correct.hpp>
#include <ggl/extensions/gis/io/wkt/wkt.hpp>
@@ -15,6 +18,7 @@
#include <ggl/geometries/box.hpp>
#include <ggl/geometries/linear_ring.hpp>
#include <ggl/geometries/linestring.hpp>
+#include <ggl/geometries/point_xy.hpp>
#include <ggl/geometries/point.hpp>
#include <ggl/geometries/polygon.hpp>
#include <ggl/multi/geometries/multi_polygon.hpp>
Added: sandbox/ggl/formal_review_request/libs/ggl/test/policies/Jamfile.v2
==============================================================================
--- (empty file)
+++ sandbox/ggl/formal_review_request/libs/ggl/test/policies/Jamfile.v2 2009-11-02 10:53:23 EST (Mon, 02 Nov 2009)
@@ -0,0 +1,12 @@
+# test/util/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)
+
+test-suite ggl-policies
+ :
+ [ run compare.cpp ]
+ ;
Added: sandbox/ggl/formal_review_request/libs/ggl/test/policies/compare.cpp
==============================================================================
--- (empty file)
+++ sandbox/ggl/formal_review_request/libs/ggl/test/policies/compare.cpp 2009-11-02 10:53:23 EST (Mon, 02 Nov 2009)
@@ -0,0 +1,134 @@
+// 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 <algorithm>
+
+#include <ggl/algorithms/make.hpp>
+#include <ggl/util/write_dsv.hpp>
+
+#include <ggl/policies/compare.hpp>
+
+#include <ggl/strategies/strategies.hpp>
+
+#include <ggl/geometries/point.hpp>
+#include <ggl/geometries/adapted/c_array_cartesian.hpp>
+#include <ggl/geometries/adapted/tuple_cartesian.hpp>
+
+#include <test_common/test_point.hpp>
+
+
+template <typename Container>
+inline std::string coordinates(Container const& points)
+{
+ std::ostringstream out;
+ typedef typename boost::range_value<Container>::type point_type;
+ for (typename boost::range_const_iterator<Container>::type it = boost::begin(points);
+ it != boost::end(points);
+ ++it)
+ {
+ out << ggl::dsv(*it);
+ }
+ return out.str();
+}
+
+template <typename P>
+void test_2d()
+{
+ typedef typename ggl::coordinate_type<P>::type ct;
+
+ std::vector<P> v;
+ v.push_back(ggl::make<P>(3, 1));
+ v.push_back(ggl::make<P>(2, 3));
+ v.push_back(ggl::make<P>(2, 2));
+ v.push_back(ggl::make<P>(1, 3));
+
+ // Sort on coordinates in order x,y,z
+ std::sort(v.begin(), v.end(), ggl::less<P>());
+ std::string s = coordinates(v);
+ BOOST_CHECK_EQUAL(s, "(1, 3)(2, 2)(2, 3)(3, 1)");
+
+ // Reverse sort
+ std::sort(v.begin(), v.end(), ggl::greater<P>());
+ s = coordinates(v);
+ BOOST_CHECK_EQUAL(s, "(3, 1)(2, 3)(2, 2)(1, 3)");
+
+ // Sort backwards on coordinates in order x,y,z
+ //std::sort(v.begin(), v.end(), ggl::greater<P>());
+ //std::string s = coordinates(v);
+ //BOOST_CHECK_EQUAL(s, "(1, 3)(2, 2)(2, 3)(3, 1)");
+
+ // Refill to remove duplicate coordinates
+ v.clear();
+ v.push_back(ggl::make<P>(4, 1));
+ v.push_back(ggl::make<P>(3, 2));
+ v.push_back(ggl::make<P>(2, 3));
+ v.push_back(ggl::make<P>(1, 4));
+
+ // Sort ascending on only x-coordinate
+ std::sort(v.begin(), v.end(), ggl::less<P, 0>());
+ s = coordinates(v);
+ BOOST_CHECK_EQUAL(s, "(1, 4)(2, 3)(3, 2)(4, 1)");
+
+ // Sort ascending on only y-coordinate
+ std::sort(v.begin(), v.end(), ggl::less<P, 1>());
+ s = coordinates(v);
+ BOOST_CHECK_EQUAL(s, "(4, 1)(3, 2)(2, 3)(1, 4)");
+
+ // Sort descending on only x-coordinate
+ std::sort(v.begin(), v.end(), ggl::greater<P, 0>());
+ s = coordinates(v);
+ //BOOST_CHECK_EQUAL(s, "(4, 1)(3, 2)(2, 3)(1, 4)");
+
+ // Sort descending on only y-coordinate
+ std::sort(v.begin(), v.end(), ggl::greater<P, 1>());
+ s = coordinates(v);
+ BOOST_CHECK_EQUAL(s, "(1, 4)(2, 3)(3, 2)(4, 1)");
+}
+
+
+template <typename P>
+void test_spherical()
+{
+ typedef typename ggl::coordinate_type<P>::type ct;
+
+ std::vector<P> v;
+ v.push_back(ggl::make<P>( 179.73, 71.56)); // east
+ v.push_back(ggl::make<P>( 177.47, 71.23)); // less east
+ v.push_back(ggl::make<P>(-178.78, 70.78)); // further east, = west, this is the most right point
+
+ // Sort on coordinates in order x,y,z
+ std::sort(v.begin(), v.end(), ggl::less<P>());
+ std::string s = coordinates(v);
+ BOOST_CHECK_EQUAL(s, "(177.47, 71.23)(179.73, 71.56)(-178.78, 70.78)");
+
+ // Sort ascending on only x-coordinate
+ std::sort(v.begin(), v.end(), ggl::less<P, 0>());
+ s = coordinates(v);
+ BOOST_CHECK_EQUAL(s, "(177.47, 71.23)(179.73, 71.56)(-178.78, 70.78)");
+
+ // Sort ascending on only x-coordinate, but override with std-comparison,
+ // (so this is the normal sorting behaviour that would have been used
+ // if it would not have been spherical)
+ std::sort(v.begin(), v.end(), ggl::less<P, 0, std::less<ct> >());
+ s = coordinates(v);
+ BOOST_CHECK_EQUAL(s, "(-178.78, 70.78)(177.47, 71.23)(179.73, 71.56)");
+}
+
+
+int test_main(int, char* [])
+{
+ //test_2d<ggl::point<int, 2, ggl::cs::cartesian> >();
+ //test_2d<ggl::point<float, 2, ggl::cs::cartesian> >();
+ //test_2d<boost::tuple<double, double> >();
+ test_2d<ggl::point<double, 2, ggl::cs::cartesian> >();
+
+ test_spherical<ggl::point<double, 2, ggl::cs::spherical<ggl::degree> > >();
+
+ return 0;
+}
Modified: sandbox/ggl/formal_review_request/libs/ggl/test/strategies/Jamfile.v2
==============================================================================
--- sandbox/ggl/formal_review_request/libs/ggl/test/strategies/Jamfile.v2 (original)
+++ sandbox/ggl/formal_review_request/libs/ggl/test/strategies/Jamfile.v2 2009-11-02 10:53:23 EST (Mon, 02 Nov 2009)
@@ -10,6 +10,7 @@
:
[ run cross_track.cpp ]
[ run haversine.cpp ]
+ [ run projected_point.cpp ]
[ run pythagoras.cpp ]
[ run transformer.cpp ]
;
Modified: sandbox/ggl/formal_review_request/libs/ggl/test/strategies/cross_track.cpp
==============================================================================
--- sandbox/ggl/formal_review_request/libs/ggl/test/strategies/cross_track.cpp (original)
+++ sandbox/ggl/formal_review_request/libs/ggl/test/strategies/cross_track.cpp 2009-11-02 10:53:23 EST (Mon, 02 Nov 2009)
@@ -29,7 +29,7 @@
typedef ggl::strategy::distance::cross_track
<
Point,
- ggl::segment<const Point>
+ Point
> strategy_type;
@@ -45,8 +45,7 @@
ggl::assign(p1, lon1, lat1);
ggl::assign(p2, lon2, lat2);
ggl::assign(p3, lon3, lat3);
- typename strategy_type::return_type d
- = strategy(p1, ggl::segment<const Point>(p2, p3));
+ typename strategy_type::return_type d = strategy.apply(p1, p2, p3);
BOOST_CHECK_CLOSE((double) d, expected, tolerance);
}
Modified: sandbox/ggl/formal_review_request/libs/ggl/test/strategies/haversine.cpp
==============================================================================
--- sandbox/ggl/formal_review_request/libs/ggl/test/strategies/haversine.cpp (original)
+++ sandbox/ggl/formal_review_request/libs/ggl/test/strategies/haversine.cpp 2009-11-02 10:53:23 EST (Mon, 02 Nov 2009)
@@ -44,7 +44,7 @@
Point p1, p2;
ggl::assign(p1, lon1, lat1);
ggl::assign(p2, lon2, lat2);
- typename haversine_type::return_type d1 = strategy(p1, p2);
+ typename haversine_type::return_type d1 = strategy.apply(p1, p2);
BOOST_CHECK_CLOSE((double) d1, expected, tolerance);
}
@@ -56,7 +56,7 @@
double const average_earth_radius = 6372795.0;
// earth to unit-sphere -> divide by earth circumference, then it is from 0-1,
- // then multiply with 2 PI, so effectively just divide by earth raius
+ // then multiply with 2 PI, so effectively just divide by earth radius
double e2u = 1.0 / average_earth_radius;
// ~ Amsterdam/Paris
Added: sandbox/ggl/formal_review_request/libs/ggl/test/strategies/projected_point.cpp
==============================================================================
--- (empty file)
+++ sandbox/ggl/formal_review_request/libs/ggl/test/strategies/projected_point.cpp 2009-11-02 10:53:23 EST (Mon, 02 Nov 2009)
@@ -0,0 +1,99 @@
+// 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 <ggl_test_common.hpp>
+
+#include <ggl/strategies/cartesian/distance_projected_point.hpp>
+#include <ggl/strategies/concepts/distance_concept.hpp>
+
+#include <ggl/extensions/gis/io/wkt/read_wkt.hpp>
+
+
+#include <ggl/geometries/point.hpp>
+#include <ggl/geometries/adapted/c_array_cartesian.hpp>
+#include <ggl/geometries/adapted/tuple_cartesian.hpp>
+#include <test_common/test_point.hpp>
+
+
+template <typename P1, typename P2>
+void test_all_2d()
+{
+ P1 p;
+ P2 sp1, sp2;
+ ggl::read_wkt("POINT(1 1)", p);
+ ggl::read_wkt("POINT(0 0)", sp1);
+ ggl::read_wkt("POINT(2 3)", sp2);
+
+ typedef typename ggl::strategy::distance::xy_point_segment
+ <
+ P1,
+ P2
+ > strategy_type;
+
+ BOOST_CONCEPT_ASSERT
+ (
+ (ggl::concept::PointSegmentDistanceStrategy<strategy_type>)
+ );
+
+
+ strategy_type strategy;
+ std::cout << strategy.apply(p, sp1, sp2) << std::endl;
+}
+
+
+template <typename P>
+void test_all_2d()
+{
+ using ggl::point;
+ using ggl::cs::cartesian;
+
+ //test_all_2d<P, int[2]>();
+ //test_all_2d<P, float[2]>();
+ //test_all_2d<P, double[2]>();
+ //test_all_2d<P, test::test_point>();
+ //test_all_2d<P, point<int, 2, cartesian> >();
+ //test_all_2d<P, point<float, 2, cartesian> >();
+ test_all_2d<P, point<double, 2, cartesian> >();
+}
+
+int test_main(int, char* [])
+{
+ using ggl::point;
+ using ggl::cs::cartesian;
+
+#if ! defined(_MSC_VER)
+ test_all_2d<int[2]>();
+ test_all_2d<float[2]>();
+ test_all_2d<double[2]>();
+#endif
+ //test_all_2d<test::test_point>();
+
+#if ! defined(_MSC_VER)
+ test_all_2d<point<int, 2, cartesian> >();
+#endif
+ test_all_2d<point<float, 2, cartesian> >();
+ test_all_2d<point<double, 2, cartesian> >();
+
+
+#if defined(HAVE_CLN)
+ // combination of CLN with normal types
+ typedef boost::numeric_adaptor::cln_value_type cln_type;
+ typedef point<cln_type, 2, cartesian> cln_point;
+ test_all_2d<cln_point>();
+
+#endif
+#if defined(HAVE_GMP)
+ typedef boost::numeric_adaptor::gmp_value_type gmp_type;
+ typedef point<gmp_type, 2, cartesian> gmp_point;
+ test_all_2d<gmp_point>();
+
+#endif
+
+ return 0;
+}
Modified: sandbox/ggl/formal_review_request/libs/ggl/test/strategies/pythagoras.cpp
==============================================================================
--- sandbox/ggl/formal_review_request/libs/ggl/test/strategies/pythagoras.cpp (original)
+++ sandbox/ggl/formal_review_request/libs/ggl/test/strategies/pythagoras.cpp 2009-11-02 10:53:23 EST (Mon, 02 Nov 2009)
@@ -10,7 +10,7 @@
#include <ggl_test_common.hpp>
#include <ggl/algorithms/assign.hpp>
-#include <ggl/strategies/cartesian/cart_distance.hpp>
+#include <ggl/strategies/cartesian/distance_pythagoras.hpp>
#include <ggl/geometries/point.hpp>
@@ -28,7 +28,7 @@
P2 p2;
ggl::assign(p2, 1, 2, 3);
BOOST_CHECK_EQUAL(double(
- typename ggl::coordinate_type<P1>::type(pythagoras(p1, p2))), 0);
+ typename ggl::coordinate_type<P1>::type(pythagoras.apply(p1, p2))), 0);
}
template <typename P1, typename P2>
@@ -42,13 +42,13 @@
P2 p2;
ggl::assign(p2, 1, 0, 0);
BOOST_CHECK_EQUAL(double(
- typename ggl::coordinate_type<P1>::type(pythagoras(p1, p2))), 1);
+ typename ggl::coordinate_type<P1>::type(pythagoras.apply(p1, p2))), 1);
ggl::assign(p2, 0, 1, 0);
BOOST_CHECK_EQUAL(double(
- typename ggl::coordinate_type<P1>::type(pythagoras(p1, p2))), 1);
+ typename ggl::coordinate_type<P1>::type(pythagoras.apply(p1, p2))), 1);
ggl::assign(p2, 0, 0, 1);
BOOST_CHECK_EQUAL(double(
- typename ggl::coordinate_type<P1>::type(pythagoras(p1, p2))), 1);
+ typename ggl::coordinate_type<P1>::type(pythagoras.apply(p1, p2))), 1);
}
template <typename P1, typename P2>
@@ -61,7 +61,7 @@
P2 p2;
ggl::assign(p2, 9, 8, 7);
BOOST_CHECK_CLOSE(double(
- typename ggl::coordinate_type<P1>::type(pythagoras(p1, p2))),
+ typename ggl::coordinate_type<P1>::type(pythagoras.apply(p1, p2))),
sqrt((double)116), 0.001);
}
@@ -74,7 +74,8 @@
<
point_type,
point_type,
- CalculationType> pythagoras_type;
+ CalculationType
+ > pythagoras_type;
pythagoras_type pythagoras;
@@ -82,7 +83,7 @@
point_type p1, p2;
ggl::assign(p1, x1, y1);
ggl::assign(p2, x2, y2);
- typename pythagoras_type::return_type d1 = pythagoras(p1, p2);
+ typename pythagoras_type::return_type d1 = pythagoras.apply(p1, p2);
/*
std::cout << typeid(CalculationType).name()
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