Skip to content
Permalink
Browse files

[BUGFIX] QgsGeometry exportToGeoJSON return 'null' for null Geometry

  • Loading branch information
rldhont committed Apr 29, 2016
1 parent b3e642c commit 427616707e702f2ec80ffc4fccc450ccea7ecfe4
Showing with 7 additions and 1 deletion.
  1. +1 −1 src/core/geometry/qgsgeometry.cpp
  2. +6 −0 tests/src/core/testqgsgeometry.cpp
@@ -912,7 +912,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 )

0 comments on commit 4276167

Please sign in to comment.
You can’t perform that action at this time.