Boost rtree給出了與段查詢的某些交集的錯誤交集結果。 在這種情況下,邊界框在y = 0時是一個y平面的10×10平方。我用從(2,1,0)到(2,1,10)的z對齊線查詢。有趣的是,如果我用查詢框而不是段,那麼它按預期工作。當盒子不是平面的時候,這個行爲也是存在的,只是將最小角落移動到(0,-5,0)並且它仍然發生。提示框的交叉點給出與段的錯誤交集
我使用這個錯誤還是它在提升錯誤?
編輯:在Boost 1.56和1.59上試過了。
#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); // fails here
ASSERT_EQ(0, out.size());
}
編輯:問題正在採取行動,擴大郵件列表:lists.boost.org/geometry/2015/09/3472.php
是的,作爲sehe寫這似乎是不相交/相交的錯誤。正如我在列表中的電子郵件中所寫的那樣,您可以創建一張票,以便獲得有關此錯誤的更新。或者如果你想貢獻,你可以在GitHub上創建一個修正請求。 –