Boost logo

Boost-Commit :

From: mariano.consoni_at_[hidden]
Date: 2008-06-04 15:29:01


Author: mconsoni
Date: 2008-06-04 15:29:00 EDT (Wed, 04 Jun 2008)
New Revision: 46136
URL: http://svn.boost.org/trac/boost/changeset/46136

Log:
- Initial Geometry Library integration.
 -> we add the current code
 -> the quadtree code was modificated to adapt to the new point and box classes.
 -> simple_test was adapted to the new style (the other tests are pending)

Text files modified:
   sandbox/SOC/2008/spacial_indexing/libs/spatial_index/test/simple_test.cpp | 52 +++++++++++++++++++++------------------
   1 files changed, 28 insertions(+), 24 deletions(-)

Modified: sandbox/SOC/2008/spacial_indexing/libs/spatial_index/test/simple_test.cpp
==============================================================================
--- sandbox/SOC/2008/spacial_indexing/libs/spatial_index/test/simple_test.cpp (original)
+++ sandbox/SOC/2008/spacial_indexing/libs/spatial_index/test/simple_test.cpp 2008-06-04 15:29:00 EDT (Wed, 04 Jun 2008)
@@ -9,13 +9,15 @@
 #include <boost/test/included/test_exec_monitor.hpp>
 #include <boost/shared_ptr.hpp>
 
+#include <geometry/geometry.hpp>
+
 #include <vector>
 #include <string>
 
 int test_main(int, char* [])
 {
         std::vector<std::string> data;
- std::vector<std::pair<double, double> > points;
+ std::vector< geometry::point_xy<double> > points;
 
         data.push_back("test0");
         data.push_back("test1");
@@ -24,18 +26,17 @@
         data.push_back("test4");
         data.push_back("test5");
 
- points.push_back(std::make_pair(1.0,1.0));
- points.push_back(std::make_pair(2.0,1.0));
- points.push_back(std::make_pair(5.0,5.0));
- points.push_back(std::make_pair(1.0,6.0));
- points.push_back(std::make_pair(9.0,9.0));
- points.push_back(std::make_pair(9.0,8.0));
-
- boost::shared_ptr< boost::spatial_index::spatial_index< std::pair<double, double> , std::vector<std::string>::iterator > >
- q(new boost::spatial_index::quadtree<
- std::pair<double, double> ,
- std::vector<std::string>::iterator >
- (0.0, 0.0, 20.0, 20.0));
+ points.push_back(geometry::point_xy<double>(1.0,1.0));
+ points.push_back(geometry::point_xy<double>(2.0,1.0));
+ points.push_back(geometry::point_xy<double>(5.0,5.0));
+ points.push_back(geometry::point_xy<double>(1.0,6.0));
+ points.push_back(geometry::point_xy<double>(9.0,9.0));
+ points.push_back(geometry::point_xy<double>(9.0,8.0));
+
+ geometry::box<geometry::point_xy<double> > b(geometry::point_xy<double>(0.0, 0.0), geometry::point_xy<double>(20.0, 20.0));
+
+ boost::shared_ptr< boost::spatial_index::spatial_index< geometry::point_xy<double> , std::vector<std::string>::iterator > >
+ q(new boost::spatial_index::quadtree< geometry::point_xy<double> , std::vector<std::string>::iterator >(b));
 
 // std::cerr << " --> bulk insert" << std::endl;
 // std::vector<std::string>::iterator b, e;
@@ -46,28 +47,28 @@
          std::vector<std::string>::iterator it = data.begin();
 
          std::cerr << " --> insert" << std::endl;
- q->insert(std::make_pair(1.0,1.0), it++);
+ q->insert(geometry::point_xy<double>(1.0,1.0), it++);
          std::cerr << " --> insert" << std::endl;
- q->insert(std::make_pair(2.0,1.0), it++);
+ q->insert(geometry::point_xy<double>(2.0,1.0), it++);
          std::cerr << " --> insert" << std::endl;
- q->insert(std::make_pair(5.0,5.0), it++);
+ q->insert(geometry::point_xy<double>(5.0,5.0), it++);
          std::cerr << " --> insert" << std::endl;
- q->insert(std::make_pair(1.0,6.0), it++);
+ q->insert(geometry::point_xy<double>(1.0,6.0), it++);
          std::cerr << " --> insert" << std::endl;
- q->insert(std::make_pair(9.0,9.0), it++);
+ q->insert(geometry::point_xy<double>(9.0,9.0), it++);
          std::cerr << " --> insert" << std::endl;
- q->insert(std::make_pair(9.0,8.0), it++);
+ q->insert(geometry::point_xy<double>(9.0,8.0), it++);
 
 
         std::vector<std::string>::iterator it1;
 
         std::cerr << " --> find" << std::endl;
- it1 = q->find(std::make_pair(9.0,9.0));
+ it1 = q->find(geometry::point_xy<double>(9.0,9.0));
         BOOST_CHECK_EQUAL(*it1, "test4");
         std::cout << " " << *it1 << std::endl;
 
         std::cerr << " --> find" << std::endl;
- it1 = q->find(std::make_pair(5.0,5.0));
+ it1 = q->find(geometry::point_xy<double>(5.0,5.0));
         BOOST_CHECK_EQUAL(*it1, "test2");
         std::cout << " " << *it1 << std::endl;
 
@@ -77,16 +78,19 @@
         res.push_back("test1");
         res.push_back("test2");
 
+ std::cerr << "Elements: " << q->elements() << std::endl;
+ BOOST_CHECK_EQUAL(q->elements(), 6u);
+
         std::cerr << " --> find rectangle" << std::endl;
- std::deque< std::vector<std::string>::iterator > d = q->find(0.0, 5.0, 0.0, 5.0);
+ geometry::box<geometry::point_xy<double> > query_box(geometry::point_xy<double>(0.0, 0.0), geometry::point_xy<double>(5.0, 5.0));
+ std::deque< std::vector<std::string>::iterator > d = q->find(query_box);
+ BOOST_CHECK_EQUAL(d.size(), 3u);
         unsigned int i = 0;
         for(std::deque< std::vector<std::string>::iterator >::const_iterator dit = d.begin(); dit != d.end(); ++dit) {
                 std::cerr << "Value: " << *(*dit) << std::endl;
                 BOOST_CHECK_EQUAL(*(*dit), res[i++]);
         }
 
- std::cerr << "Elements: " << q->elements() << std::endl;
- BOOST_CHECK_EQUAL(q->elements(), 6u);
 
         return 0;
 };


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