2016-06-13 194 views
0

我目前使用C++ GEOS API迭代vector typedef Points(x和y成员变量)。GEOS C++ geos :: Geometry Buffer(0)假凸断上的凸洞

我通过创建一个geos::geom::Geometry对象,将此向量变成凸凹对象,在0处缓冲以防止自相交,然后创建一个凸的Hull。

每当我发送一个已经是凸凹的对象时,我得到以下断言: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 ::几何*,双面):断言`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 
+0

断言不是分段错误。断言是在代码中检查以确定在继续之前是否满足某些条件,并且检查失败。 – PaulMcKenzie

+0

对不起,我的意思是断言。它在内部库中检查失败 – DaynaJuliana

回答

0

断言表明您factory和/或box几何形状没有任何实例连接PrecisionModel

在当前GEOS C++ API,默认constractor是无法访问的,你创建的工厂是这样的:现在

auto factory = geos::geom::GeometryFactory::create() 

factory使用默认浮点精度模型和factory->getPrecisionModel()必须是非nullptr

geos::geom::GeometryFactory::create*功能族创建的任何几何实例都收到工厂的精度模型,即box->getPrecisionModel()返回的指针指向PrecisionModel类的同一个实例。