Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
GDAL 1.11.5 patch for dealing with json-c lib 0.13
diff --git a/frmts/arg/argdataset.cpp b/frmts/arg/argdataset.cpp
index 5a7e646..c40101a 100644
--- a/frmts/arg/argdataset.cpp
+++ b/frmts/arg/argdataset.cpp
@@ -55,6 +55,10 @@ static float CPLNaN(void)
# endif
#endif
+#ifndef error_ptr
+#define error_ptr(error) ((void*)error)
+#endif
+
/************************************************************************/
/* ==================================================================== */
/* ARGDataset */
diff --git a/ogr/ogrsf_frmts/geojson/ogrgeojsonwriter.cpp b/ogr/ogrsf_frmts/geojson/ogrgeojsonwriter.cpp
index 198b134..5612632 100644
--- a/ogr/ogrsf_frmts/geojson/ogrgeojsonwriter.cpp
+++ b/ogr/ogrsf_frmts/geojson/ogrgeojsonwriter.cpp
@@ -27,11 +27,16 @@
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
****************************************************************************/
+
+#define JSON_C_VER_013 (13 << 8)
+
#include "ogrgeojsonwriter.h"
#include "ogrgeojsonutils.h"
#include "ogr_geojson.h"
#include <json.h> // JSON-C
-#include <json_object_private.h>
+#if (!defined(JSON_C_VERSION_NUM)) || (JSON_C_VERSION_NUM < JSON_C_VER_013)
+#include <json_object_private.h> // just for sizeof(struct json_object)
+#endif
#include <printbuf.h>
#include <ogr_api.h>
#include <ogr_p.h>
@@ -607,12 +612,17 @@ static int OGR_json_double_with_precision_to_string(struct json_object *jso,
CPL_UNUSED int flags)
{
char szBuffer[75];
- int nPrecision = (int) (size_t) jso->_userdata;
- OGRFormatDouble( szBuffer, sizeof(szBuffer), jso->o.c_double, '.',
+ int nPrecision =
+#if (!defined(JSON_C_VERSION_NUM)) || (JSON_C_VERSION_NUM < JSON_C_VER_013)
+ (int) (size_t) jso->_userdata;
+#else
+ (int) (size_t) json_object_get_userdata(jso);
+#endif
+ OGRFormatDouble( szBuffer, sizeof(szBuffer), json_object_get_double(jso), '.',
(nPrecision < 0) ? 15 : nPrecision );
if( szBuffer[0] == 't' /*oobig */ )
{
- snprintf(szBuffer, sizeof(szBuffer), "%.18g", jso->o.c_double);
+ snprintf(szBuffer, sizeof(szBuffer), "%.18g", json_object_get_double(jso));
}
return printbuf_memappend(pb, szBuffer, strlen(szBuffer));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment