Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r86535 - trunk/libs/geometry/test/algorithms
From: barend.gehrels_at_[hidden]
Date: 2013-11-01 10:54:58


Author: barendgehrels
Date: 2013-11-01 10:54:58 EDT (Fri, 01 Nov 2013)
New Revision: 86535
URL: http://svn.boost.org/trac/boost/changeset/86535

Log:
[geometry] fixed strategy type, reported by Menelaos on the list

Text files modified:
   trunk/libs/geometry/test/algorithms/distance.cpp | 24 +++++++++++++++++++++++-
   1 files changed, 23 insertions(+), 1 deletions(-)

Modified: trunk/libs/geometry/test/algorithms/distance.cpp
==============================================================================
--- trunk/libs/geometry/test/algorithms/distance.cpp Fri Nov 1 10:54:34 2013 (r86534)
+++ trunk/libs/geometry/test/algorithms/distance.cpp 2013-11-01 10:54:58 EDT (Fri, 01 Nov 2013) (r86535)
@@ -12,7 +12,6 @@
 // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
 // http://www.boost.org/LICENSE_1_0.txt)
 
-#define TEST_ARRAY
 
 #include <sstream>
 
@@ -150,6 +149,27 @@
     BOOST_CHECK_CLOSE(d1, return_type(1), 0.001);
 }
 
+template <typename Point, typename Geometry, typename T>
+void test_distance_linear(std::string const& wkt_point, std::string const& wkt_geometry, T const& expected)
+{
+ Point p;
+ bg::read_wkt(wkt_point, p);
+
+ Geometry g;
+ bg::read_wkt(wkt_geometry, g);
+
+ typedef typename bg::default_distance_result<Point>::type return_type;
+ return_type d = bg::distance(p, g);
+
+ // For point-to-linestring (or point-to-polygon), both a point-strategy and a point-segment-strategy can be specified.
+ // Test this.
+ return_type ds1 = bg::distance(p, g, bg::strategy::distance::pythagoras<>());
+ return_type ds2 = bg::distance(p, g, bg::strategy::distance::projected_point<>());
+
+ BOOST_CHECK_CLOSE(d, return_type(expected), 0.001);
+ BOOST_CHECK_CLOSE(ds1, return_type(expected), 0.001);
+ BOOST_CHECK_CLOSE(ds2, return_type(expected), 0.001);
+}
 
 template <typename P>
 void test_distance_array_as_linestring()
@@ -233,6 +253,8 @@
 
     test_geometry<P, test::wrapped_boost_array<P, 2> >("POINT(3 1)", "LINESTRING(1 1,4 4)", sqrt(2.0));
 
+ test_distance_linear<P, bg::model::linestring<P> >("POINT(3 1)", "LINESTRING(1 1,4 4)", sqrt(2.0));
+
 }
 
 template <typename P>


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