Opened 6 years ago

Closed 6 years ago

#4108 closed enhancement (fixed)

Add ability to specify float precision in ExportToJson

Reported by: kenshi Owned by: warmerdam
Priority: normal Milestone: 1.9.0
Component: OGR_SF Version: 1.7.1
Severity: normal Keywords: geojson
Cc:

Description

It seems like ExportToJson? is truncating floating point numbers to 6 decimal places. It would be nice if this was configurable via a parameter.

Below is the output of a geometry, one using ExportToWkt? and the other with ExportToJson?

POLYGON ((-177.41507893643012 28.197433657347258,-177.41548874778033 28.197776874353025,-177.415311162861911 28.197624902643991,-177.41524286097021 28.197607827171069,-177.415174559078508 28.197570261130632,-177.415092596808449 28.197491713955202,-177.41507893643012 28.197433657347258))

{ "type": "Polygon", "coordinates": [ [ [ -177.415079, 28.197434 ], [ -177.415489, 28.197777 ], [ -177.415311, 28.197625 ], [ -177.415243, 28.197608 ], [ -177.415175, 28.197570 ], [ -177.415093, 28.197492 ], [ -177.415079, 28.197434 ] ] ] }

Change History (1)

comment:1 Changed 6 years ago by Even Rouault

Component: defaultOGR_SF
Keywords: geojson added
Milestone: 1.9.0
Resolution: fixed
Status: newclosed

r22490 /trunk/gdal/ (19 files in 8 dirs): GeoJSON/CouchDB: add COORDINATE_PRECISION layer creation option to specify the maximum number of figures after decimal point in coordinates; set to 15 by default with smart truncation of trailing zeros (like done for WKT); add OGR_G_ExportToJsonEx() to accept a list of options, including COORDINATE_PRECISION; extend SWIG Geometry.ExportToJson?() to accept a list of options (#4108)

Note: See TracTickets for help on using tickets.