$include_dir="/home/hyper-archives/boost-commit/include"; include("$include_dir/msg-header.inc") ?>
Subject: [Boost-commit] svn:boost r84293 - in trunk/libs/geometry/index: example test/algorithms
From: adam.wulkiewicz_at_[hidden]
Date: 2013-05-15 19:26:56
Author: awulkiew
Date: 2013-05-15 19:26:55 EDT (Wed, 15 May 2013)
New Revision: 84293
URL: http://svn.boost.org/trac/boost/changeset/84293
Log:
geometry.index test,example: added benchmark and test for segment path queries.
Text files modified: 
   trunk/libs/geometry/index/example/benchmark_experimental.cpp    |    22 ++++++++++++++++++++--                  
   trunk/libs/geometry/index/test/algorithms/path_intersection.cpp |    26 ++++++++++++++++++++------              
   2 files changed, 40 insertions(+), 8 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-15 19:26:55 EDT (Wed, 15 May 2013)
@@ -18,6 +18,7 @@
 
 #include <boost/geometry/index/rtree.hpp>
 #include <boost/geometry/geometries/linestring.hpp>
+#include <boost/geometry/geometries/segment.hpp>
 
 namespace bg = boost::geometry;
 namespace bgi = bg::index;
@@ -25,6 +26,7 @@
 typedef bg::model::point<double, 2, bg::cs::cartesian> P;
 typedef bg::model::box<P> B;
 typedef bg::model::linestring<P> LS;
+typedef bg::model::segment<P> S;
 
 template <typename I1, typename I2, typename O>
 void mycopy(I1 first, I2 last, O o)
@@ -283,7 +285,7 @@
                 temp += result.size();
             }
             dur_t time = clock_t::now() - start;
-            std::cout << time << " - query(path(LS, " << path_values_count << ")) " << path_queries_count << " found " << temp << '\n';
+            std::cout << time << " - query(path(LS6, " << path_values_count << ")) " << path_queries_count << " found " << temp << '\n';
         }
 
         {
@@ -303,7 +305,23 @@
                 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';
+            std::cout << time << " - query(path(LS2, " << path_values_count << ")) " << path_queries_count2 << " found " << temp << '\n';
+        }
+
+        {
+            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;
+                S seg(P(x, y), P(x+max_val/100, y+max_val/100));
+                result.clear();
+                t.query(bgi::path(seg, path_values_count), std::back_inserter(result));
+                temp += result.size();
+            }
+            dur_t time = clock_t::now() - start;
+            std::cout << time << " - query(path(S, " << path_values_count << ")) " << path_queries_count2 << " found " << temp << '\n';
         }
 #endif
         {
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-15 19:26:55 EDT (Wed, 15 May 2013)
@@ -11,6 +11,12 @@
 
 #include <boost/geometry/index/detail/algorithms/path_intersection.hpp>
 
+#include <boost/geometry/geometries/point_xy.hpp>
+#include <boost/geometry/geometries/point.hpp>
+#include <boost/geometry/geometries/box.hpp>
+#include <boost/geometry/geometries/linestring.hpp>
+#include <boost/geometry/geometries/segment.hpp>
+
 //#include <boost/geometry/io/wkt/read.hpp>
 
 template <typename Box, typename Linestring>
@@ -18,11 +24,24 @@
                             bool expected_result,
                             typename bg::default_length_result<Linestring>::type expected_dist)
 {
-    typename bg::default_length_result<Linestring>::type dist;
+    typename bgi::detail::default_path_intersection_distance_type<Box, Linestring>::type dist;
+
     bool value = bgi::detail::path_intersection(box, path, dist);
     BOOST_CHECK(value == expected_result);
     if ( value && expected_result )
         BOOST_CHECK_CLOSE(dist, expected_dist, 0.0001);
+
+    if ( ::boost::size(path) == 2 )
+    {
+        typedef typename ::boost::range_value<Linestring>::type P;
+        typedef bg::model::segment<P> Seg;
+        typename bgi::detail::default_path_intersection_distance_type<Box, Seg>::type dist;
+        Seg seg(*::boost::begin(path), *(::boost::begin(path)+1));
+        bool value = bgi::detail::path_intersection(box, seg, dist);
+        BOOST_CHECK(value == expected_result);
+        if ( value && expected_result )
+            BOOST_CHECK_CLOSE(dist, expected_dist, 0.0001);
+    }
 }
 
 template <typename Box, typename Linestring>
@@ -37,11 +56,6 @@
     test_path_intersection(box, path, expected_result, expected_dist);
 }
 
-#include <boost/geometry/geometries/point_xy.hpp>
-#include <boost/geometry/geometries/point.hpp>
-#include <boost/geometry/geometries/box.hpp>
-#include <boost/geometry/geometries/linestring.hpp>
-
 void test_large_integers()
 {
     typedef bg::model::point<int, 2, bg::cs::cartesian> int_point_type;