Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r86549 - trunk/libs/geometry/test/algorithms
From: barend.gehrels_at_[hidden]
Date: 2013-11-03 12:33:00


Author: barendgehrels
Date: 2013-11-03 12:33:00 EST (Sun, 03 Nov 2013)
New Revision: 86549
URL: http://svn.boost.org/trac/boost/changeset/86549

Log:
[geometry] Added real-life testcase for simplify

Text files modified:
   trunk/libs/geometry/test/algorithms/simplify.cpp | 19 ++++++++++++++++---
   trunk/libs/geometry/test/algorithms/test_simplify.hpp | 10 ++++++----
   2 files changed, 22 insertions(+), 7 deletions(-)

Modified: trunk/libs/geometry/test/algorithms/simplify.cpp
==============================================================================
--- trunk/libs/geometry/test/algorithms/simplify.cpp Sun Nov 3 11:17:23 2013 (r86548)
+++ trunk/libs/geometry/test/algorithms/simplify.cpp 2013-11-03 12:33:00 EST (Sun, 03 Nov 2013) (r86549)
@@ -38,6 +38,21 @@
         "LINESTRING(0 0,5 5,7 5,10 10)",
         "LINESTRING(0 0,5 5,7 5,10 10)", 1.0);
 
+ // Mail 2013-10-07, real-life test, piece of River Leine
+ // PostGIS returns exactly the same result
+ test_geometry<bg::model::linestring<P> >(
+ "LINESTRING(4293586 3290439,4293568 3290340,4293566 3290332,4293570 3290244,4293576 3290192"
+ ",4293785 3289660,4293832 3289597,4293879 3289564,4293937 3289545,4294130 3289558"
+ ",4294204 3289553,4294240 3289539,4294301 3289479,4294317 3289420,4294311 3289353"
+ ",4294276 3289302,4293870 3289045,4293795 3288978,4293713 3288879,4293669 3288767"
+ ",4293654 3288652,4293657 3288563,4293690 3288452,4293761 3288360,4293914 3288215"
+ ",4293953 3288142,4293960 3288044,4293951 3287961,4293913 3287875,4293708 3287628"
+ ",4293658 3287542,4293633 3287459,4293630 3287383,4293651 3287323,4293697 3287271"
+ ",4293880 3287128,4293930 3287045,4293938 3286977,4293931 3286901,4293785 3286525"
+ ",4293775 3286426,4293786 3286358,4293821 3286294,4294072 3286076,4294134 3285986)",
+ "LINESTRING(4293586 3290439,4293785 3289660,4294317 3289420,4293654 3288652,4293960 3288044"
+ ",4293633 3287459,4293786 3286358,4294134 3285986)", 250);
+
     /* TODO fix this
     test_geometry<test::wrapped_boost_array<P, 10> >(
         "LINESTRING(0 0,5 5,7 5,10 10)",
@@ -62,9 +77,7 @@
 
 select astext(ST_Simplify(geomfromtext('LINESTRING(0 0, 5 5, 10 10)'),1.0)) as simplified
 union all select astext(ST_Simplify(geomfromtext('LINESTRING(0 0, 5 5, 6 5, 10 10)'),1.0))
-union all select astext(ST_Simplify(geomfromtext('LINESTRING(0 0, 5 5, 7 5, 10 10)'),1.0))
-union all select astext(ST_Simplify(geomfromtext('POLYGON((4 0, 8 2, 8 7, 4 9, 0 7, 0 2, 2 1, 4 0))'),1.0))
-union all select astext(ST_Simplify(geomfromtext('POLYGON((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))'),1.0))
+etc
 */
 
     // Just check compilation

Modified: trunk/libs/geometry/test/algorithms/test_simplify.hpp
==============================================================================
--- trunk/libs/geometry/test/algorithms/test_simplify.hpp Sun Nov 3 11:17:23 2013 (r86548)
+++ trunk/libs/geometry/test/algorithms/test_simplify.hpp 2013-11-03 12:33:00 EST (Sun, 03 Nov 2013) (r86549)
@@ -11,6 +11,8 @@
 
 // Test-functionality, shared between single and multi tests
 
+#include <iomanip>
+#include <sstream>
 #include <geometry_test_common.hpp>
 #include <boost/geometry/algorithms/simplify.hpp>
 #include <boost/geometry/algorithms/distance.hpp>
@@ -35,7 +37,7 @@
             std::back_inserter(simplified), distance);
 
         std::ostringstream out;
- out << bg::wkt(simplified);
+ out << std::setprecision(16) << bg::wkt(simplified);
         BOOST_CHECK_EQUAL(out.str(), expected);
     }
 };
@@ -53,12 +55,12 @@
 
     {
         std::ostringstream out;
- out << bg::wkt(simplified);
+ out << std::setprecision(16) << bg::wkt(simplified);
 
         BOOST_CHECK_MESSAGE(out.str() == expected,
             "simplify: " << bg::wkt(geometry)
             << " expected " << expected
- << " got " << bg::wkt(simplified));
+ << " got " << out.str());
     }
 
     // Check using user-specified strategy
@@ -76,7 +78,7 @@
 
     {
         std::ostringstream out;
- out << bg::wkt(simplified);
+ out << std::setprecision(16) << bg::wkt(simplified);
         BOOST_CHECK_EQUAL(out.str(), expected);
     }
 


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