目前,我正在使用C++ GEOS来迭代typedef Points (x和y成员变量)的vector。
我通过创建一个convexHull对象将该向量转换为geos::geom::Geometry,在0处缓冲以防止自交,然后创建一个凸包。
每当我发送一个已经是convexHull的对象时,我就会得到以下断言:Assertion 'precisionModel' failed。
这是GEOS的错误吗?我需要小心不要在凸多边形上缓冲吗?
/tmp/libgeos/src/operation/buffer/BufferBuilder.cpp:373: geo_algos_test2::geom::geom::geom* geos::operation::buffer::BufferBuilder::buffer(const geos::geom::*,double):断言“精确模型”失败。*
这是我的代码:
// 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发布于 2017-02-15 22:29:37
断言表明您的factory和/或box几何没有附加任何PrecisionModel实例。
在当前的GEOS C++ API中,无法访问默认的构造器,因此可以这样创建工厂:
auto factory = geos::geom::GeometryFactory::create()现在,factory使用默认的浮点精度模型,而factory->getPrecisionModel()必须是非nullptr的.
使用geos::geom::GeometryFactory::create*函数族创建的任何几何实例都接收工厂的精确模型,即box->getPrecisionModel()返回指向PrecisionModel类的同一个实例的指针。
https://stackoverflow.com/questions/37780628
复制相似问题