mirror of
https://github.com/qgis/QGIS.git
synced 2025-11-22 00:14:55 -05:00
Fix fromGeos returning 0 for x/y on empty point
This commit is contained in:
parent
bdccd78c54
commit
a89d564934
@ -1111,6 +1111,8 @@ std::unique_ptr<QgsAbstractGeometry> QgsGeos::fromGeos( const GEOSGeometry *geos
|
||||
{
|
||||
case GEOS_POINT: // a point
|
||||
{
|
||||
if ( GEOSisEmpty_r( geosinit()->ctxt, geos ) )
|
||||
return qgis::make_unique< QgsPoint >();
|
||||
const GEOSCoordSequence *cs = GEOSGeom_getCoordSeq_r( geosinit()->ctxt, geos );
|
||||
unsigned int nPoints = 0;
|
||||
GEOSCoordSeq_getSize_r( geosinit()->ctxt, cs, &nPoints );
|
||||
|
||||
@ -613,6 +613,12 @@ void TestQgsGeometry::geos()
|
||||
QCOMPARE( GEOSGetNumGeometries_r( QgsGeos::getGEOSHandler(), asGeos.get() ), 2 );
|
||||
res = QgsGeometry( QgsGeos::fromGeos( asGeos.get() ) );
|
||||
QCOMPARE( res.asWkt(), QStringLiteral( "MultiPolygon (((0 0, 0 1, 1 1, 0 0)),((10 0, 10 1, 11 1, 10 0)))" ) );
|
||||
|
||||
// Empty geometry
|
||||
QgsPoint point;
|
||||
asGeos = QgsGeos::asGeos( &point );
|
||||
res = QgsGeometry( QgsGeos::fromGeos( asGeos.get() ) );
|
||||
QCOMPARE( res.asWkt(), QgsPoint().asWkt( ) );
|
||||
}
|
||||
|
||||
void TestQgsGeometry::point()
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user