mirror of
https://github.com/qgis/QGIS.git
synced 2025-02-27 00:33:48 -05:00
[BUGFIX] QgsGeometry exportToGeoJSON return 'null' for null Geometry
This commit is contained in:
parent
abfd7740bd
commit
f48e74f33c
@ -928,7 +928,7 @@ QString QgsGeometry::exportToGeoJSON( int precision ) const
|
||||
{
|
||||
if ( !d->geometry )
|
||||
{
|
||||
return QString();
|
||||
return QString( "null" );
|
||||
}
|
||||
return d->geometry->asJSON( precision );
|
||||
}
|
||||
|
@ -3311,6 +3311,12 @@ void TestQgsGeometry::exportToGeoJSON()
|
||||
obtained = geom->exportToGeoJSON();
|
||||
geojson = "{\"type\": \"MultiPolygon\", \"coordinates\": [[[ [0, 0], [10, 0], [10, 10], [0, 10], [0, 0]]], [[ [2, 2], [4, 2], [4, 4], [2, 4], [2, 2]]]] }";
|
||||
QCOMPARE( obtained, geojson );
|
||||
|
||||
// no geometry
|
||||
QgsGeometry nullGeom( nullptr );
|
||||
obtained = nullGeom.exportToGeoJSON();
|
||||
geojson = "null";
|
||||
QCOMPARE( obtained, geojson );
|
||||
}
|
||||
|
||||
bool TestQgsGeometry::renderCheck( const QString& theTestName, const QString& theComment, int mismatchCount )
|
||||
|
Loading…
x
Reference in New Issue
Block a user