Skip to content

Commit

Permalink
Use NaN for unset Z/M values
Browse files Browse the repository at this point in the history
  • Loading branch information
domi4484 authored and 3nids committed Nov 15, 2022
1 parent c5f2b5c commit f6b6f81
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/core/qgsvectorfilewriter.cpp
Expand Up @@ -2798,9 +2798,9 @@ gdal::ogr_feature_unique_ptr QgsVectorFileWriter::createFeature( const QgsFeatur
// add m/z values if not present in the input wkb type -- this is needed for formats which determine
// geometry type based on features, e.g. geojson
if ( QgsWkbTypes::hasZ( mWkbType ) && !QgsWkbTypes::hasZ( geom.wkbType() ) )
geom.get()->addZValue( 0 );
geom.get()->addZValue( std::numeric_limits<double>::quiet_NaN() );
if ( QgsWkbTypes::hasM( mWkbType ) && !QgsWkbTypes::hasM( geom.wkbType() ) )
geom.get()->addMValue( 0 );
geom.get()->addMValue( std::numeric_limits<double>::quiet_NaN() );

if ( !mGeom2 )
{
Expand All @@ -2824,7 +2824,11 @@ gdal::ogr_feature_unique_ptr QgsVectorFileWriter::createFeature( const QgsFeatur
return nullptr;
}

QByteArray wkb( geom.asWkb() );
QgsAbstractGeometry::WkbFlags wkbFlags;
if ( mOgrDriverName == QLatin1String( "ESRI Shapefile" ) )
wkbFlags |= QgsAbstractGeometry::FlagExportNanAsDoubleMin;

QByteArray wkb( geom.asWkb( wkbFlags ) );
OGRErr err = OGR_G_ImportFromWkb( mGeom2, reinterpret_cast<unsigned char *>( const_cast<char *>( wkb.constData() ) ), wkb.length() );
if ( err != OGRERR_NONE )
{
Expand Down

0 comments on commit f6b6f81

Please sign in to comment.