Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Fix fromGeos returning 0 for x/y on empty point
- Loading branch information
Showing
with
8 additions
and
0 deletions.
-
+2
−0
src/core/geometry/qgsgeos.cpp
-
+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() |
|
|