【发布时间】:2016-06-13 01:09:47
【问题描述】:
我目前正在使用 C++ GEOS API 遍历 typedef Points 的 vector(x 和 y 成员变量)。
我通过创建一个geos::geom::Geometry 对象将这个向量变成一个凸包,在 0 处缓冲以防止自相交,然后创建一个凸包。
每当我发送一个已经是凸包的对象时,我都会得到以下断言:Assertion 'precisionModel' failed。
这是一个 GEOS 错误吗?我需要注意不要在凸多边形上缓冲吗?
geo_algos_test2: /tmp/libgeos/src/operation/buffer/BufferBuilder.cpp:373: geos::geom::Geometry* geos::operation::buffer::BufferBuilder::buffer(const geos: :geom::Geometry*, double): 断言 `precisionModel' 失败。*
这是我的代码:
// Remove self intersections or collinear points
geos::geom::GeometryFactory factory;
geos::geom::CoordinateSequence* temp =
factory.getCoordinateSequenceFactory()->create((std::size_t)0, 0);
// Convert vector of cruise points to GEOS
for (auto point : poly) {
temp->add(geos::geom::Coordinate(point.x, point.y));
}
// Add beggining point to create linear ring
temp->add(geos::geom::Coordinate(poly.begin()->x, poly.begin()->y));
// Create Linear Ring For Constructor
geos::geom::LinearRing* box = factory.createLinearRing(temp);
// Factory returns a pointer, dereference this
geos::geom::Geometry* GEOSPoly = factory.createPolygon(box, NULL);
// Remove Self Intersections and create Hull
return GEOSPoly->buffer(0); //line that causes assertion
【问题讨论】:
-
断言不是分段错误。断言是对代码进行的检查,以查看在继续之前是否满足某些条件,并且检查失败。
-
对不起,我的意思是断言。它在他们的内部库中检查失败