Skip to content

Commit

Permalink
Use pk as WFS id in GeoJSON export
Browse files Browse the repository at this point in the history
  • Loading branch information
mhugent committed Feb 19, 2018
1 parent b3eaede commit 26cf317
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
7 changes: 4 additions & 3 deletions src/server/qgswfsserver.cpp
Expand Up @@ -1377,7 +1377,7 @@ void QgsWFSServer::setGetFeature( QgsRequestHandler& request, const QString& for
fcString += " ";
else
fcString += " ,";
fcString += createFeatureGeoJSON( feat, prec, crs, attrIndexes, excludedAttributes );
fcString += createFeatureGeoJSON( feat, prec, crs, attrIndexes, excludedAttributes, pkAttributes );
fcString += "\n";

result = fcString.toUtf8();
Expand Down Expand Up @@ -1926,9 +1926,10 @@ QgsFeatureIds QgsWFSServer::getFeatureIdsFromFilter( const QDomElement& filterEl
return fids;
}

QString QgsWFSServer::createFeatureGeoJSON( QgsFeature* feat, int prec, QgsCoordinateReferenceSystem& crs, const QgsAttributeList& attrIndexes, const QSet<QString>& excludedAttributes ) /*const*/
QString QgsWFSServer::createFeatureGeoJSON( QgsFeature* feat, int prec, QgsCoordinateReferenceSystem& crs, const QgsAttributeList& attrIndexes, const QSet<QString>& excludedAttributes,
const QgsAttributeList& pkAttributes ) /*const*/
{
QString id = QString( "%1.%2" ).arg( mTypeName, FID_TO_STRING( feat->id() ) );
QString id = QString( "%1.%2" ).arg( mTypeName, featureGmlId( feat, pkAttributes ) );

QgsJSONExporter exporter;
exporter.setSourceCrs( crs );
Expand Down
3 changes: 2 additions & 1 deletion src/server/qgswfsserver.h
Expand Up @@ -120,7 +120,8 @@ class QgsWFSServer: public QgsOWSServer
QgsFeatureIds getFeatureIdsFromFilter( const QDomElement& filter, QgsVectorLayer* layer );

//methods to write GeoJSON
QString createFeatureGeoJSON( QgsFeature* feat, int prec, QgsCoordinateReferenceSystem& crs, const QgsAttributeList& attrIndexes, const QSet<QString>& excludedAttributes ) /*const*/;
QString createFeatureGeoJSON( QgsFeature* feat, int prec, QgsCoordinateReferenceSystem& crs, const QgsAttributeList& attrIndexes, const QSet<QString>& excludedAttributes,
const QgsAttributeList& pkAttributes = QgsAttributeList() ) /*const*/;

//methods to write GML2
QDomElement createFeatureGML2( QgsFeature* feat, QDomDocument& doc, int prec, QgsCoordinateReferenceSystem& crs, const QgsAttributeList& attrIndexes, const QSet<QString>& excludedAttributes,
Expand Down

0 comments on commit 26cf317

Please sign in to comment.