Skip to content

Commit

Permalink
[Server] The RFC 7946 GeoJSON specification recommends limiting coord…
Browse files Browse the repository at this point in the history
…inate precision to 6
  • Loading branch information
rldhont committed Feb 10, 2017
1 parent 06506fe commit fe2b34d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
6 changes: 4 additions & 2 deletions src/core/qgsjsonutils.h
Expand Up @@ -38,11 +38,13 @@ class CORE_EXPORT QgsJSONExporter

/** Constructor for QgsJSONExporter.
* @param vectorLayer associated vector layer (required for related attribute export)
* @param precision maximum number of decimal places to use for geometry coordinates
* @param precision maximum number of decimal places to use for geometry coordinates,
* the RFC 7946 GeoJSON specification recommends limiting coordinate precision to 6
*/
QgsJSONExporter( const QgsVectorLayer* vectorLayer = nullptr, int precision = 17 );
QgsJSONExporter( const QgsVectorLayer* vectorLayer = nullptr, int precision = 6 );

/** Sets the maximum number of decimal places to use in geometry coordinates.
* The RFC 7946 GeoJSON specification recommends limiting coordinate precision to 6
* @param precision number of decimal places
* @see precision()
*/
Expand Down
5 changes: 4 additions & 1 deletion src/server/qgswfsserver.cpp
Expand Up @@ -1913,7 +1913,10 @@ QString QgsWFSServer::createFeatureGeoJSON( QgsFeature* feat, int prec, QgsCoord

QgsJSONExporter exporter;
exporter.setSourceCrs( crs );
exporter.setPrecision( prec );
//QgsJSONExporter force transform geometry to ESPG:4326
//and the RFC 7946 GeoJSON specification recommends limiting coordinate precision to 6
Q_UNUSED( prec );
//exporter.setPrecision( prec );

//copy feature so we can modify its geometry as required
QgsFeature f( *feat );
Expand Down

0 comments on commit fe2b34d

Please sign in to comment.