Skip to content

Commit

Permalink
Do not transform geometries when exporting in json
Browse files Browse the repository at this point in the history
  • Loading branch information
pblottiere committed Nov 5, 2019
1 parent 1865675 commit 15fb672
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/core/qgsjsonutils.cpp
Expand Up @@ -107,7 +107,7 @@ json QgsJsonExporter::exportFeatureToJsonObject( const QgsFeature &feature, cons
try
{
QgsGeometry transformed = geom;
if ( transformed.transform( mTransform ) == 0 )
if ( mTransformGeometries && transformed.transform( mTransform ) == 0 )
geom = transformed;
}
catch ( QgsCsException &cse )
Expand Down
9 changes: 9 additions & 0 deletions src/core/qgsjsonutils.h
Expand Up @@ -153,6 +153,13 @@ class CORE_EXPORT QgsJsonExporter
*/
QgsCoordinateReferenceSystem sourceCrs() const;

/**
* Sets whether geometries should be transformed in EPSG 4326 (default
* behavior) or just keep as it is.
* \since QGIS 3.10
*/
void setTransformGeometries( bool activate ) { mTransformGeometries = activate; }

/**
* Sets the list of attributes to include in the JSON exports.
* \param attributes list of attribute indexes, or an empty list to include all
Expand Down Expand Up @@ -270,6 +277,8 @@ class CORE_EXPORT QgsJsonExporter
QgsCoordinateTransform mTransform;

bool mAttributeDisplayName = false;

bool mTransformGeometries = true;
};

/**
Expand Down
1 change: 1 addition & 0 deletions src/server/services/wms/qgswmsrenderer.cpp
Expand Up @@ -2219,6 +2219,7 @@ namespace QgsWms
exporter.setAttributeDisplayName( true );
exporter.setAttributes( attributes );
exporter.setIncludeGeometry( withGeometry );
exporter.setTransformGeometries( false );

for ( const auto &feature : qgis::as_const( features ) )
{
Expand Down

0 comments on commit 15fb672

Please sign in to comment.