Skip to content
Permalink
Browse files

Fix fromGeos returning 0 for x/y on empty point

  • Loading branch information
elpaso authored and nyalldawson committed Feb 5, 2021
1 parent 17d8204 commit a0ddf6fbc995ca72551ea3cdbab57c2a017ae6c8
Showing with 8 additions and 0 deletions.
  1. +2 −0 src/core/geometry/qgsgeos.cpp
  2. +6 −0 tests/src/core/testqgsgeometry.cpp
@@ -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()

0 comments on commit a0ddf6f

Please sign in to comment.