Bug in rtree of box when queried with segment?

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Bug in rtree of box when queried with segment?

Adrian Muresan
Hello,

There seems to be a bug that gives false results when querying a box rtree with a segment like in the example below. In this example the rtree contains a y-planar box, but the bug reproduces even with a non-planar box (have tried with a min corner of {0, -5, 0}). The query segment is a z-aligned line.

Note that if you replace the query with a box instead of a segment then it works as expected. I have tried this with boost 1.56 and 1.59.

Any ideas?
Thanks!

#include <vector>
#include "gtest/gtest.h"
#include "gmock/gmock.h"
#include <boost/geometry.hpp>
#include <boost/geometry/geometries/point.hpp>
#include <boost/geometry/geometries/box.hpp>
#include <boost/geometry/geometries/segment.hpp>
#include <boost/geometry/index/rtree.hpp>
#include <vector>
#include <iterator>
#include <memory>

namespace bg = boost::geometry;
namespace bgi = boost::geometry::index;
typedef bg::model::point<double, 3, bg::cs::cartesian> point_def;
typedef bg::model::box<point_def> box;
typedef bg::model::segment<point_def> segment;
typedef std::pair<box, size_t> tri_box;
typedef bgi::rtree< tri_box, bgi::linear<8>> tree_type;

using namespace std;

TEST(boost_rtree, cant_intersect_box_with_segment) {
  vector<tri_box> buff(1);
  buff[0].first = box{point_def{0, 0, 0}, point_def{10, 0, 10}};
  buff[0].second = 1;
  tree_type tree(buff);

  segment query{point_def{2, 1, 0}, point_def{2, 1, 10}};
//  box query{point_def{2, 1, 0}, point_def{2, 1, 10}};
  vector<tri_box> out;

  size_t count = tree.query(bgi::intersects(query), back_inserter(out));

  ASSERT_EQ(0, count);
  ASSERT_EQ(0, out.size());
}



_______________________________________________
Geometry mailing list
[hidden email]
http://lists.boost.org/mailman/listinfo.cgi/geometry
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Bug in rtree of box when queried with segment?

Adrian Muresan
Update, there's an easier way to reproduce this as a box-segment intersection:




De : Adrian Muresan <[hidden email]>
À : "[hidden email]" <[hidden email]>
Envoyé le : Mercredi 9 septembre 2015 13h00
Objet : Bug in rtree of box when queried with segment?

Hello,

There seems to be a bug that gives false results when querying a box rtree with a segment like in the example below. In this example the rtree contains a y-planar box, but the bug reproduces even with a non-planar box (have tried with a min corner of {0, -5, 0}). The query segment is a z-aligned line.

Note that if you replace the query with a box instead of a segment then it works as expected. I have tried this with boost 1.56 and 1.59.

Any ideas?
Thanks!

#include <vector>
#include "gtest/gtest.h"
#include "gmock/gmock.h"
#include <boost/geometry.hpp>
#include <boost/geometry/geometries/point.hpp>
#include <boost/geometry/geometries/box.hpp>
#include <boost/geometry/geometries/segment.hpp>
#include <boost/geometry/index/rtree.hpp>
#include <vector>
#include <iterator>
#include <memory>

namespace bg = boost::geometry;
namespace bgi = boost::geometry::index;
typedef bg::model::point<double, 3, bg::cs::cartesian> point_def;
typedef bg::model::box<point_def> box;
typedef bg::model::segment<point_def> segment;
typedef std::pair<box, size_t> tri_box;
typedef bgi::rtree< tri_box, bgi::linear<8>> tree_type;

using namespace std;

TEST(boost_rtree, cant_intersect_box_with_segment) {
  vector<tri_box> buff(1);
  buff[0].first = box{point_def{0, 0, 0}, point_def{10, 0, 10}};
  buff[0].second = 1;
  tree_type tree(buff);

  segment query{point_def{2, 1, 0}, point_def{2, 1, 10}};
//  box query{point_def{2, 1, 0}, point_def{2, 1, 10}};
  vector<tri_box> out;

  size_t count = tree.query(bgi::intersects(query), back_inserter(out));

  ASSERT_EQ(0, count);
  ASSERT_EQ(0, out.size());
}





_______________________________________________
Geometry mailing list
[hidden email]
http://lists.boost.org/mailman/listinfo.cgi/geometry
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Bug in rtree of box when queried with segment?

Adam Wulkiewicz
Hi Adrian,

2015-09-14 16:34 GMT+02:00 Adrian Muresan <[hidden email]>:
Update, there's an easier way to reproduce this as a box-segment intersection:


Yes, this seems to be a bug in intersects/disjoints. Could you please create a ticket here: https://svn.boost.org/trac/boost/newticket ?

Or if you'd like to help with the development you could find this bug in the code and create a pull request with a fix on GitHub:
https://github.com/boostorg/geometry
here is a tutorial:
https://github.com/boostorg/geometry/wiki/Contribution-Tutorial

Regards,
Adam

_______________________________________________
Geometry mailing list
[hidden email]
http://lists.boost.org/mailman/listinfo.cgi/geometry
Loading...