Skip to content

Commit fe2b34d

Browse files
committed
[Server] The RFC 7946 GeoJSON specification recommends limiting coordinate precision to 6
1 parent 06506fe commit fe2b34d

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

src/core/qgsjsonutils.h

+4-2
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,13 @@ class CORE_EXPORT QgsJSONExporter
3838

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

4546
/** Sets the maximum number of decimal places to use in geometry coordinates.
47+
* The RFC 7946 GeoJSON specification recommends limiting coordinate precision to 6
4648
* @param precision number of decimal places
4749
* @see precision()
4850
*/

src/server/qgswfsserver.cpp

+4-1
Original file line numberDiff line numberDiff line change
@@ -1913,7 +1913,10 @@ QString QgsWFSServer::createFeatureGeoJSON( QgsFeature* feat, int prec, QgsCoord
19131913

19141914
QgsJSONExporter exporter;
19151915
exporter.setSourceCrs( crs );
1916-
exporter.setPrecision( prec );
1916+
//QgsJSONExporter force transform geometry to ESPG:4326
1917+
//and the RFC 7946 GeoJSON specification recommends limiting coordinate precision to 6
1918+
Q_UNUSED( prec );
1919+
//exporter.setPrecision( prec );
19171920

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

0 commit comments

Comments
 (0)