Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Update method's name and add doc
  • Loading branch information
pblottiere committed Jan 28, 2019
1 parent 03447f8 commit 5da6004
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/core/qgsjsonutils.cpp
Expand Up @@ -238,7 +238,7 @@ QString QgsJsonExporter::exportFeatures( const QgsFeatureList &features ) const
}

QString layerName;
if ( mIncludeLayerName )
if ( mIncludeName )
layerName.append( QStringLiteral( "\n \"name\": \"%1\",\n" ).arg( mLayer->name() ) );

return QStringLiteral( "{%1 \"type\": \"FeatureCollection\",\n \"features\":[\n%2\n]}" ).arg( layerName, featureJSON.join( QStringLiteral( ",\n" ) ) );
Expand Down
17 changes: 14 additions & 3 deletions src/core/qgsjsonutils.h
Expand Up @@ -75,9 +75,20 @@ class CORE_EXPORT QgsJsonExporter
*/
bool includeGeometry() const { return mIncludeGeometry; }

void setIncludeLayerName( bool includeLayerName ) { mIncludeLayerName = includeLayerName; }
/**
* Sets whether to include layer's name in the JSON exports.
* \param includeName set to false to prevent name inclusion
* \see includeName()
* \since QGIS 3.6
*/
void setIncludeName( bool includeName ) { mIncludeName = includeName; }

bool includeLayerName() const { return mIncludeLayerName; }
/**
* Returns whether layer's name will be included in the JSON exports.
* \see setIncludeName()
* \since QGIS 3.6
*/
bool includeName() const { return mIncludeName; }

/**
* Sets whether to include attributes in the JSON exports.
Expand Down Expand Up @@ -227,7 +238,7 @@ class CORE_EXPORT QgsJsonExporter

QgsCoordinateTransform mTransform;

bool mIncludeLayerName = false;
bool mIncludeName = false;
};

/**
Expand Down
2 changes: 1 addition & 1 deletion src/server/services/wms/qgswmsrenderer.cpp
Expand Up @@ -2340,7 +2340,7 @@ namespace QgsWms
QgsJsonExporter exporter( vl );
exporter.setAttributes( attributes );
exporter.setIncludeGeometry( withGeometry );
exporter.setIncludeLayerName( true );
exporter.setIncludeName( true );

if ( i > 0 )
json.append( QStringLiteral( "," ) );
Expand Down

0 comments on commit 5da6004

Please sign in to comment.