Hello,
I'm new to Boost.Geometry, and I have already found this docoumentation: http://geometrylibrary.geodan.nl/index.html However, I wonder where I can find the documentation of (or some code snippets using) the rtree class? Best Bernhard _______________________________________________ ggl mailing list [hidden email] http://lists.osgeo.org/mailman/listinfo/ggl |
Hi Bernhard,
> > I'm new to Boost.Geometry, and I have already found this > docoumentation: Welcome to the list! > > http://geometrylibrary.geodan.nl/index.html > > However, I wonder where I can find the documentation of (or > some code snippets using) the rtree class? They are not yet there. Sorry about that. The rtree interface will be changed (and it was therefore not part of the review). However, it works and can be used. Herewith a code snippet. #include <boost/geometry/extensions/index/rtree/rtree.hpp> namespace bg = boost::geometry; (...) // declare a spatial index with an ID (int), the ID can also be e.g. an index of a vector bg::index::rtree<bg::box_2d, int> spatial_index(12, 4); // <box, ID> (...) // fill it somewhere, normally in a loop over polygons (here: polygon) bg::box_2d envelope; bg::envelope(polygon, envelope); spatial_index.insert(envelope, id); // get all ID's intersecting a specified box: std::deque<int> overlapping = spatial_index.find(specific_envelope); // do things with these ID's / polygons belonging to these ID's or indexes Regards, Barend _______________________________________________ ggl mailing list [hidden email] http://lists.osgeo.org/mailman/listinfo/ggl |
On 2010-06-24 10:49, Barend Gehrels wrote:
> They are not yet there. Sorry about that. The rtree interface will be > changed (and it was therefore not part of the review). > > However, it works and can be used. Herewith a code snippet. Dear Barend, thank you very much for your help! I was able to get it running in 2D. However, in 3D it won't compile. Is the rtree not ready for 3D or do I have an error in my code: #include <stdio.h> #include <iostream> #include "boost/geometry/geometry.hpp" #include <boost/geometry/geometries/geometries.hpp> #include "boost/geometry/geometries/cartesian3d.hpp" #include "boost/geometry/extensions/index/rtree/rtree.hpp" using namespace std; namespace bg = boost::geometry; int main(int argc,char* argv[]) { // declare a spatial index with an ID (int), the ID can also be e.g. an index of a vector bg::index::rtree<bg::box_3d, int> spatial_index(12, 4); // <box, ID> // fill it somewhere, normally in a loop over polygons (here: polygon) int id=0; bg::point_3d p1(0.0,0.0,0.0); bg::point_3d p2(1.0,1.0,1.0); bg::box_3d box3(p1,p2); spatial_index.insert(box3, id); // get all ID's intersecting a specified box: bg::point_3d q0(.5,.5,.5); bg::point_3d q1(3.0,3.0,3.0); bg::box_3d q(q0,q1); std::deque<int> overlapping = spatial_index.find(q); cout<<"result size="<<overlapping.size()<<endl; } make /usr/bin/g++ -I/home/bernd/openSource/dev/test_rtree3d -Wall -frounding-math '-I/opt/CGAL331/include' -I/usr/include/qt3 -O3 -DNDEBUG -DCGAL_NO_ASSERTIONS -c test.cpp In file included from /home/bernd/openSource/dev/test_rtree3d/boost/geometry/geometries/concepts/box_concept.hpp:20, from /home/bernd/openSource/dev/test_rtree3d/boost/geometry/geometries/concepts/check.hpp:67, from /home/bernd/openSource/dev/test_rtree3d/boost/geometry/core/num_geometries.hpp:18, from boost/geometry/geometry.hpp:24, from test.cpp:3: /home/bernd/openSource/dev/test_rtree3d/boost/geometry/core/coordinate_dimension.hpp: In function ‘void boost::geometry::assert_dimension() [with G = boost::geometry::box<boost::geometry::point<double, 3ul, boost::geometry::cs::cartesian> >, int D = 2]’: /home/bernd/openSource/dev/test_rtree3d/boost/geometry/algorithms/area.hpp:80: instantiated from ‘static typename boost::geometry::coordinate_type<Geometry>::type boost::geometry::detail::area::box_area<Box, Strategy>::apply(const Box&, const Strategy&) [with Box = boost::geometry::box<boost::geometry::point<double, 3ul, boost::geometry::cs::cartesian> >, Strategy = boost::geometry::strategy::area::by_triangles<boost::geometry::point<double, 3ul, boost::geometry::cs::cartesian>, void>]’ /home/bernd/openSource/dev/test_rtree3d/boost/geometry/algorithms/area.hpp:247: instantiated from ‘typename boost::geometry::area_result<Geometry>::type boost::geometry::area(const Geometry&) [with Geometry = boost::geometry::box<boost::geometry::point<double, 3ul, boost::geometry::cs::cartesian> >]’ boost/geometry/extensions/index/rtree/rtree.hpp:473: instantiated from ‘void boost::geometry::index::rtree<Box, Value>::split_node(const boost::shared_ptr<boost::geometry::index::rtree_node<Box, Value> >&, boost::shared_ptr<boost::geometry::index::rtree_node<Box, Value> >&, boost::shared_ptr<boost::geometry::index::rtree_node<Box, Value> >&) const [with Box = boost::geometry::box<boost::geometry::point<double, 3ul, boost::geometry::cs::cartesian> >, Value = int]’ boost/geometry/extensions/index/rtree/rtree.hpp:262: instantiated from ‘void boost::geometry::index::rtree<Box, Value>::insert(const Box&, const Value&) [with Box = boost::geometry::box<boost::geometry::point<double, 3ul, boost::geometry::cs::cartesian> >, Value = int]’ test.cpp:24: instantiated from here /home/bernd/openSource/dev/test_rtree3d/boost/geometry/core/coordinate_dimension.hpp:80: error: invalid application of ‘sizeof’ to incomplete type ‘boost::STATIC_ASSERTION_FAILURE<false>’ /home/bernd/openSource/dev/test_rtree3d/boost/geometry/core/coordinate_dimension.hpp:80: error: invalid application of ‘sizeof’ to incomplete type ‘boost::STATIC_ASSERTION_FAILURE<false>’ make: *** [test.o] Error 1 Best Bernhard _______________________________________________ ggl mailing list [hidden email] http://lists.osgeo.org/mailman/listinfo/ggl |
Hi Bernhard,
> thank you very much for your help! You are welcome ;-) > I was able to get it running > in 2D. However, in 3D it won't compile. Is the rtree not ready > for 3D or do I have an error in my code: It is indeed not (yet) 3D enabled. Your error message gives this as a static assertion failure. Basically an rtree could work dimension agnostic (as far as I can oversee right now) but at certain points in the code it is just x/y based. Federico (who wrote most things as a student during Google Summer of Code) is now quite busy with his job. So currently no 3D for rtree, sorry about that. Most of Boost.Geometry is still 2D, though the design is dimension agnostic. Regards, Barend _______________________________________________ ggl mailing list [hidden email] http://lists.osgeo.org/mailman/listinfo/ggl |
This post has NOT been accepted by the mailing list yet.
This is wrt to boost 1.57 . I'd like to know where I could find a good documentation on using the provided R tree.
I want to populate the R tree with axis aligned rectangles (2 dimensional) and search for the rectangle(s) that enclose a given query point. That is , input a point and output the corresponding rectangles that enclose /bound it. I was unable to decipher much from the provided documentation which seem particularly lacking for spatial indexes. |
Free forum by Nabble | Edit this page |