Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r84238 - in trunk/libs/geometry/index: example test/algorithms
From: adam.wulkiewicz_at_[hidden]
Date: 2013-05-11 18:38:37


Author: awulkiew
Date: 2013-05-11 18:38:36 EDT (Sat, 11 May 2013)
New Revision: 84238
URL: http://svn.boost.org/trac/boost/changeset/84238

Log:
geometry.index test, example: updated tests and benchmark_experimental for path_intersection of 2-point linestring.
Text files modified:
   trunk/libs/geometry/index/example/benchmark_experimental.cpp | 23 ++++++++++++++++++++++-
   trunk/libs/geometry/index/test/algorithms/path_intersection.cpp | 18 ++++++++++--------
   trunk/libs/geometry/index/test/algorithms/segment_intersection.cpp | 22 +++++++++++-----------
   3 files changed, 43 insertions(+), 20 deletions(-)

Modified: trunk/libs/geometry/index/example/benchmark_experimental.cpp
==============================================================================
--- trunk/libs/geometry/index/example/benchmark_experimental.cpp (original)
+++ trunk/libs/geometry/index/example/benchmark_experimental.cpp 2013-05-11 18:38:36 EDT (Sat, 11 May 2013)
@@ -42,7 +42,8 @@
     size_t queries_count = 100000;
     size_t nearest_queries_count = 10000;
     unsigned neighbours_count = 10;
- size_t path_queries_count = 1000;
+ size_t path_queries_count = 2000;
+ size_t path_queries_count2 = 10000;
     unsigned path_values_count = 10;
 
     float max_val = static_cast<float>(values_count / 2);
@@ -284,6 +285,26 @@
             dur_t time = clock_t::now() - start;
             std::cout << time << " - query(path(LS, " << path_values_count << ")) " << path_queries_count << " found " << temp << '\n';
         }
+
+ {
+ LS ls;
+ ls.resize(2);
+
+ clock_t::time_point start = clock_t::now();
+ size_t temp = 0;
+ for (size_t i = 0 ; i < path_queries_count2 ; ++i )
+ {
+ float x = coords[i].first;
+ float y = coords[i].second;
+ ls[0] = P(x, y);
+ ls[1] = P(x+max_val/100, y+max_val/100);
+ result.clear();
+ t.query(bgi::path(ls, path_values_count), std::back_inserter(result));
+ temp += result.size();
+ }
+ dur_t time = clock_t::now() - start;
+ std::cout << time << " - query(path(LS, " << path_values_count << ")) " << path_queries_count2 << " found " << temp << '\n';
+ }
 #endif
         {
             clock_t::time_point start = clock_t::now();

Modified: trunk/libs/geometry/index/test/algorithms/path_intersection.cpp
==============================================================================
--- trunk/libs/geometry/index/test/algorithms/path_intersection.cpp (original)
+++ trunk/libs/geometry/index/test/algorithms/path_intersection.cpp 2013-05-11 18:38:36 EDT (Sat, 11 May 2013)
@@ -89,12 +89,14 @@
     typedef bg::model::linestring<P3fc> L3fc;
     typedef bg::model::linestring<P3dc> L3dc;
     
- test_geometry<bg::model::box<P2ic>, L2ic>("POLYGON((0 1,2 4))", "LINESTRING(0 0, 2 5)", true, ::sqrt(29.0f)/5);
- test_geometry<bg::model::box<P2fc>, L2fc>("POLYGON((0 1,2 4))", "LINESTRING(0 0, 2 5)", true, ::sqrt(29.0f)/5);
- test_geometry<bg::model::box<P2dc>, L2dc>("POLYGON((0 1,2 4))", "LINESTRING(0 0, 2 5)", true, ::sqrt(29.0)/5);
- test_geometry<bg::model::box<P3ic>, L3ic>("POLYGON((0 1 2,2 4 6))", "LINESTRING(0 0 0, 2 5 7)", true, ::sqrt(78.0f)*2.0f/7);
- test_geometry<bg::model::box<P3fc>, L3fc>("POLYGON((0 1 2,2 4 6))", "LINESTRING(0 0 0, 2 5 7)", true, ::sqrt(78.0f)*2.0f/7);
- test_geometry<bg::model::box<P3dc>, L3dc>("POLYGON((0 1 2,2 4 6))", "LINESTRING(0 0 0, 2 5 7)", true, ::sqrt(78.0)*2.0/7);
+ // IMPORTANT! For 2-point linestrings comparable distance optimization is enabled!
+
+ test_geometry<bg::model::box<P2ic>, L2ic>("POLYGON((0 1,2 4))", "LINESTRING(0 0, 2 5)", true, 1.0f/5);
+ test_geometry<bg::model::box<P2fc>, L2fc>("POLYGON((0 1,2 4))", "LINESTRING(0 0, 2 5)", true, 1.0f/5);
+ test_geometry<bg::model::box<P2dc>, L2dc>("POLYGON((0 1,2 4))", "LINESTRING(0 0, 2 5)", true, 1.0/5);
+ test_geometry<bg::model::box<P3ic>, L3ic>("POLYGON((0 1 2,2 4 6))", "LINESTRING(0 0 0, 2 5 7)", true, 2.0f/7);
+ test_geometry<bg::model::box<P3fc>, L3fc>("POLYGON((0 1 2,2 4 6))", "LINESTRING(0 0 0, 2 5 7)", true, 2.0f/7);
+ test_geometry<bg::model::box<P3dc>, L3dc>("POLYGON((0 1 2,2 4 6))", "LINESTRING(0 0 0, 2 5 7)", true, 2.0/7);
 
     test_geometry<bg::model::box<P2fc>, L2fc>("POLYGON((0 1,2 4))", "LINESTRING(0 0, 1 0, 1 5)", true, 2);
     test_geometry<bg::model::box<P2fc>, L2fc>("POLYGON((0 1,2 4))", "LINESTRING(0 0, 3 0, 3 2, 0 2)", true, 6);
@@ -107,8 +109,8 @@
     typedef bg::model::linestring<P2ttmc> L2ttmc;
     typedef bg::model::linestring<P3ttmc> L3ttmc;
 
- test_geometry<bg::model::box<P2ttmc>, L2ttmc>("POLYGON((0 1,2 4))", "LINESTRING(0 0, 2 5)", true, ::sqrt(29.0f)/5);
- test_geometry<bg::model::box<P3ttmc>, L3ttmc>("POLYGON((0 1 2,2 4 6))", "LINESTRING(0 0 0, 2 5 7)", true, ::sqrt(78.0f)*2.0f/7);
+ test_geometry<bg::model::box<P2ttmc>, L2ttmc>("POLYGON((0 1,2 4))", "LINESTRING(0 0, 2 5)", true, 1.0/5);
+ test_geometry<bg::model::box<P3ttmc>, L3ttmc>("POLYGON((0 1 2,2 4 6))", "LINESTRING(0 0 0, 2 5 7)", true, 2.0/7);
 #endif
 
     test_large_integers();

Modified: trunk/libs/geometry/index/test/algorithms/segment_intersection.cpp
==============================================================================
--- trunk/libs/geometry/index/test/algorithms/segment_intersection.cpp (original)
+++ trunk/libs/geometry/index/test/algorithms/segment_intersection.cpp 2013-05-11 18:38:36 EDT (Sat, 11 May 2013)
@@ -13,22 +13,22 @@
 
 //#include <boost/geometry/io/wkt/read.hpp>
 
-template <typename Box, typename Point>
+template <typename Box, typename Point, typename RelativeDistance>
 void test_segment_intersection(Box const& box, Point const& p0, Point const& p1,
                                bool expected_result,
- typename bgi::detail::default_relative_distance_type<Box, Point>::type expected_rel_dist)
+ RelativeDistance expected_rel_dist)
 {
- typename bgi::detail::default_relative_distance_type<Box, Point>::type rel_dist;
+ RelativeDistance rel_dist;
     bool value = bgi::detail::segment_intersection(box, p0, p1, rel_dist);
     BOOST_CHECK(value == expected_result);
     if ( value && expected_result )
         BOOST_CHECK_CLOSE(rel_dist, expected_rel_dist, 0.0001);
 }
 
-template <typename Box, typename Point>
+template <typename Box, typename Point, typename RelativeDistance>
 void test_geometry(std::string const& wkt_g, std::string const& wkt_p0, std::string const& wkt_p1,
                    bool expected_result,
- typename bgi::detail::default_relative_distance_type<Box, Point>::type expected_rel_dist)
+ RelativeDistance expected_rel_dist)
 {
     Box box;
     bg::read_wkt(wkt_g, box);
@@ -106,14 +106,14 @@
     test_geometry<bg::model::box<P2fc>, P2fc>("POLYGON((0 1,2 4))", "POINT(0 5)", "POINT(0 0)", true, 0.2f);
     test_geometry<bg::model::box<P2dc>, P2dc>("POLYGON((0 1,2 4))", "POINT(0 0)", "POINT(0 5)", true, 0.2);
 
- test_geometry<bg::model::box<P2ic>, P2ic>("POLYGON((0 1,2 4))", "POINT(3 0)", "POINT(3 5)", false, 0);
- test_geometry<bg::model::box<P2fc>, P2fc>("POLYGON((0 1,2 4))", "POINT(3 5)", "POINT(3 0)", false, 0);
- test_geometry<bg::model::box<P2dc>, P2dc>("POLYGON((0 1,2 4))", "POINT(3 0)", "POINT(3 5)", false, 0);
+ test_geometry<bg::model::box<P2ic>, P2ic>("POLYGON((0 1,2 4))", "POINT(3 0)", "POINT(3 5)", false, 0.0f);
+ test_geometry<bg::model::box<P2fc>, P2fc>("POLYGON((0 1,2 4))", "POINT(3 5)", "POINT(3 0)", false, 0.0f);
+ test_geometry<bg::model::box<P2dc>, P2dc>("POLYGON((0 1,2 4))", "POINT(3 0)", "POINT(3 5)", false, 0.0);
 
- test_geometry<bg::model::box<P2fc>, P2fc>("POLYGON((0 1,2 4))", "POINT(1 0)", "POINT(1 1)", true, 1);
- test_geometry<bg::model::box<P2fc>, P2fc>("POLYGON((0 1,2 4))", "POINT(1 4)", "POINT(1 5)", true, 0);
+ test_geometry<bg::model::box<P2fc>, P2fc>("POLYGON((0 1,2 4))", "POINT(1 0)", "POINT(1 1)", true, 1.0f);
+ test_geometry<bg::model::box<P2fc>, P2fc>("POLYGON((0 1,2 4))", "POINT(1 4)", "POINT(1 5)", true, 0.0f);
 
- test_geometry<bg::model::box<P2fc>, P2fc>("POLYGON((0 1,2 4))", "POINT(0.5 2)", "POINT(1.5 3)", true, 0);
+ test_geometry<bg::model::box<P2fc>, P2fc>("POLYGON((0 1,2 4))", "POINT(0.5 2)", "POINT(1.5 3)", true, 0.0f);
     
 #ifdef HAVE_TTMATH
     typedef bg::model::point<ttmath_big, 2, bg::cs::cartesian> P2ttmc;


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