Skip to content
Permalink
Browse files

Avoid crash when export as GML an empty geometry

  • Loading branch information
lbartoletti committed Oct 25, 2017
1 parent 7922608 commit 650a1227b60994eb4fd6fc71763ddcf0150e599d
@@ -313,6 +313,10 @@ QDomElement QgsCircularString::asGML3( QDomDocument &doc, int precision, const Q
points( pts );

QDomElement elemCurve = doc.createElementNS( ns, QStringLiteral( "Curve" ) );

if ( isEmpty() )
return elemCurve;

QDomElement elemSegments = doc.createElementNS( ns, QStringLiteral( "segments" ) );
QDomElement elemArcString = doc.createElementNS( ns, QStringLiteral( "ArcString" ) );
elemArcString.appendChild( QgsGeometryUtils::pointsToGML3( pts, doc, precision, ns, is3D() ) );
@@ -271,6 +271,10 @@ QDomElement QgsCompoundCurve::asGML2( QDomDocument &doc, int precision, const QS
QDomElement QgsCompoundCurve::asGML3( QDomDocument &doc, int precision, const QString &ns ) const
{
QDomElement compoundCurveElem = doc.createElementNS( ns, QStringLiteral( "CompositeCurve" ) );

if ( isEmpty() )
return compoundCurveElem;

for ( const QgsCurve *curve : mCurves )
{
QDomElement curveMemberElem = doc.createElementNS( ns, QStringLiteral( "curveMember" ) );
@@ -291,6 +291,10 @@ QDomElement QgsLineString::asGML2( QDomDocument &doc, int precision, const QStri
points( pts );

QDomElement elemLineString = doc.createElementNS( ns, QStringLiteral( "LineString" ) );

if ( isEmpty() )
return elemLineString;

elemLineString.appendChild( QgsGeometryUtils::pointsToGML2( pts, doc, precision, ns ) );

return elemLineString;
@@ -302,6 +306,10 @@ QDomElement QgsLineString::asGML3( QDomDocument &doc, int precision, const QStri
points( pts );

QDomElement elemLineString = doc.createElementNS( ns, QStringLiteral( "LineString" ) );

if ( isEmpty() )
return elemLineString;

elemLineString.appendChild( QgsGeometryUtils::pointsToGML3( pts, doc, precision, ns, is3D() ) );
return elemLineString;
}
@@ -60,6 +60,10 @@ QDomElement QgsMultiCurve::asGML2( QDomDocument &doc, int precision, const QStri
{
// GML2 does not support curves
QDomElement elemMultiLineString = doc.createElementNS( ns, QStringLiteral( "MultiLineString" ) );

if ( isEmpty() )
return elemMultiLineString;

for ( const QgsAbstractGeometry *geom : mGeometries )
{
if ( qgsgeometry_cast<const QgsCurve *>( geom ) )
@@ -78,6 +82,10 @@ QDomElement QgsMultiCurve::asGML2( QDomDocument &doc, int precision, const QStri
QDomElement QgsMultiCurve::asGML3( QDomDocument &doc, int precision, const QString &ns ) const
{
QDomElement elemMultiCurve = doc.createElementNS( ns, QStringLiteral( "MultiCurve" ) );

if ( isEmpty() )
return elemMultiCurve;

for ( const QgsAbstractGeometry *geom : mGeometries )
{
if ( qgsgeometry_cast<const QgsCurve *>( geom ) )
@@ -51,6 +51,10 @@ bool QgsMultiLineString::fromWkt( const QString &wkt )
QDomElement QgsMultiLineString::asGML2( QDomDocument &doc, int precision, const QString &ns ) const
{
QDomElement elemMultiLineString = doc.createElementNS( ns, QStringLiteral( "MultiLineString" ) );

if ( isEmpty() )
return elemMultiLineString;

for ( const QgsAbstractGeometry *geom : mGeometries )
{
if ( const QgsLineString *lineString = qgsgeometry_cast<const QgsLineString *>( geom ) )
@@ -67,6 +71,10 @@ QDomElement QgsMultiLineString::asGML2( QDomDocument &doc, int precision, const
QDomElement QgsMultiLineString::asGML3( QDomDocument &doc, int precision, const QString &ns ) const
{
QDomElement elemMultiCurve = doc.createElementNS( ns, QStringLiteral( "MultiCurve" ) );

if ( isEmpty() )
return elemMultiCurve;

for ( const QgsAbstractGeometry *geom : mGeometries )
{
if ( const QgsLineString *lineString = qgsgeometry_cast<const QgsLineString *>( geom ) )
@@ -63,6 +63,10 @@ void QgsMultiPointV2::clear()
QDomElement QgsMultiPointV2::asGML2( QDomDocument &doc, int precision, const QString &ns ) const
{
QDomElement elemMultiPoint = doc.createElementNS( ns, QStringLiteral( "MultiPoint" ) );

if ( isEmpty() )
return elemMultiPoint;

for ( const QgsAbstractGeometry *geom : mGeometries )
{
if ( qgsgeometry_cast<const QgsPoint *>( geom ) )
@@ -79,6 +83,10 @@ QDomElement QgsMultiPointV2::asGML2( QDomDocument &doc, int precision, const QSt
QDomElement QgsMultiPointV2::asGML3( QDomDocument &doc, int precision, const QString &ns ) const
{
QDomElement elemMultiPoint = doc.createElementNS( ns, QStringLiteral( "MultiPoint" ) );

if ( isEmpty() )
return elemMultiPoint;

for ( const QgsAbstractGeometry *geom : mGeometries )
{
if ( qgsgeometry_cast<const QgsPoint *>( geom ) )
@@ -52,6 +52,10 @@ QDomElement QgsMultiPolygonV2::asGML2( QDomDocument &doc, int precision, const Q
{
// GML2 does not support curves
QDomElement elemMultiPolygon = doc.createElementNS( ns, QStringLiteral( "MultiPolygon" ) );

if ( isEmpty() )
return elemMultiPolygon;

for ( const QgsAbstractGeometry *geom : mGeometries )
{
if ( qgsgeometry_cast<const QgsPolygonV2 *>( geom ) )
@@ -68,6 +72,10 @@ QDomElement QgsMultiPolygonV2::asGML2( QDomDocument &doc, int precision, const Q
QDomElement QgsMultiPolygonV2::asGML3( QDomDocument &doc, int precision, const QString &ns ) const
{
QDomElement elemMultiSurface = doc.createElementNS( ns, QStringLiteral( "MultiPolygon" ) );

if ( isEmpty() )
return elemMultiSurface;

for ( const QgsAbstractGeometry *geom : mGeometries )
{
if ( qgsgeometry_cast<const QgsPolygonV2 *>( geom ) )
@@ -60,6 +60,10 @@ QDomElement QgsMultiSurface::asGML2( QDomDocument &doc, int precision, const QSt
{
// GML2 does not support curves
QDomElement elemMultiPolygon = doc.createElementNS( ns, QStringLiteral( "MultiPolygon" ) );

if ( isEmpty() )
return elemMultiPolygon;

for ( const QgsAbstractGeometry *geom : mGeometries )
{
if ( qgsgeometry_cast<const QgsSurface *>( geom ) )
@@ -78,6 +82,10 @@ QDomElement QgsMultiSurface::asGML2( QDomDocument &doc, int precision, const QSt
QDomElement QgsMultiSurface::asGML3( QDomDocument &doc, int precision, const QString &ns ) const
{
QDomElement elemMultiSurface = doc.createElementNS( ns, QStringLiteral( "MultiSurface" ) );

if ( isEmpty() )
return elemMultiSurface;

for ( const QgsAbstractGeometry *geom : mGeometries )
{
if ( qgsgeometry_cast<const QgsSurface *>( geom ) )

Large diffs are not rendered by default.

0 comments on commit 650a122

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