[postgis-tickets] r17136 - ST_AsMVT: parse JSON numeric values with decimals as doubles

Raul raul at rmr.ninja
Fri Jan 11 05:50:49 PST 2019


Author: algunenano
Date: 2019-01-11 05:50:49 -0800 (Fri, 11 Jan 2019)
New Revision: 17136

Modified:
   branches/2.4/NEWS
   branches/2.4/postgis/mvt.c
   branches/2.4/regress/mvt_jsonb.sql
   branches/2.4/regress/mvt_jsonb_expected
Log:
ST_AsMVT: parse JSON numeric values with decimals as doubles

Closes #4292



Modified: branches/2.4/NEWS
===================================================================
--- branches/2.4/NEWS	2019-01-11 12:37:24 UTC (rev 17135)
+++ branches/2.4/NEWS	2019-01-11 13:50:49 UTC (rev 17136)
@@ -8,10 +8,10 @@
            dimensions for &&& operator to work predictably.
            (Darafei Praliaskouski, Arthur Lesuisse, Andrew Gierth, Raúl Marín)
   - #4273, Tighter parsing of WKT (Paul Ramsey)
+  - #4267, Enable Proj 6 deprecated APIs (Darafei Praliaskouski, Raúl Marín)
+  - #4292, ST_AsMVT: parse JSON numeric values with decimals as doubles (Raúl Marín)
 
- - #4267, Enable Proj 6 deprecated APIs (Darafei Praliaskouski, Raúl Marín)
 
-
 PostGIS 2.4.6
 2018/11/24
 

Modified: branches/2.4/postgis/mvt.c
===================================================================
--- branches/2.4/postgis/mvt.c	2019-01-11 12:37:24 UTC (rev 17135)
+++ branches/2.4/postgis/mvt.c	2019-01-11 13:50:49 UTC (rev 17136)
@@ -538,7 +538,7 @@
 					PointerGetDatum(v.val.numeric)));
 				double d = strtod(str, NULL);
 				long l = strtol(str, NULL, 10);
-				if ((long) d != l) {
+				if (FP_NEQUALS(d, (double)l)) {
 					MVT_PARSE_VALUE(d, mvt_kv_double_value, double_values_hash,
 						double_value, sizeof(double));
 				} else {

Modified: branches/2.4/regress/mvt_jsonb.sql
===================================================================
--- branches/2.4/regress/mvt_jsonb.sql	2019-01-11 12:37:24 UTC (rev 17135)
+++ branches/2.4/regress/mvt_jsonb.sql	2019-01-11 13:50:49 UTC (rev 17136)
@@ -1,6 +1,19 @@
-SELECT 'TA9', encode(ST_AsMVT(q, 'test', 4096, 'geom'), 'base64') FROM (SELECT '{"c1":1,"c2":"abcd"}'::jsonb,
+SELECT 'J1', encode(ST_AsMVT(q, 'test', 4096, 'geom'), 'base64') FROM (SELECT '{"c1":1,"c2":"abcd"}'::jsonb,
     ST_AsMVTGeom(ST_GeomFromText('POINT(25 17)'),
     ST_MakeBox2D(ST_Point(0, 0), ST_Point(4096, 4096)), 4096, 0, false) AS geom) AS q;
-SELECT 'TA10', encode(ST_AsMVT(q, 'test', 4096, 'geom'), 'base64') FROM (SELECT '{"c1":"abcd", "c2":"abcd"}'::jsonb,
+SELECT 'J2', encode(ST_AsMVT(q, 'test', 4096, 'geom'), 'base64') FROM (SELECT '{"c1":"abcd", "c2":"abcd"}'::jsonb,
     ST_AsMVTGeom(ST_GeomFromText('POINT(25 17)'),
     ST_MakeBox2D(ST_Point(0, 0), ST_Point(4096, 4096)), 4096, 0, false) AS geom) AS q;
+SELECT 'J3', encode(ST_AsMVT(q, 'test', 4096, 'geom'), 'base64') FROM (
+    SELECT '{"c1":"abcd", "c2":"abcd"}'::jsonb,
+            ST_AsMVTGeom(ST_GeomFromText('POINT(25 17)'), ST_MakeBox2D(ST_Point(0, 0), ST_Point(4096, 4096)), 4096, 0, false) AS geom
+    UNION ALL
+    SELECT '{"c3":"abasdadcd", "c1":5}'::jsonb,
+            ST_AsMVTGeom(ST_GeomFromText('POINT(25 17)'), ST_MakeBox2D(ST_Point(0, 0), ST_Point(4096, 4096)), 4096, 0, false) AS geom
+) AS q;
+SELECT 'J4', encode(ST_AsMVT(q, 'test', 4096, 'geom'), 'base64') FROM (
+	SELECT '1.25'::double precision AS c1,
+	ST_AsMVTGeom(ST_GeomFromText('POINT (0 0)'),
+	ST_MakeBox2D(ST_Point(0, 0), ST_Point(4096, 4096)), 4096, 0, false) AS geom,
+	'{"test":1.75}'::jsonb as properties
+) AS q;
\ No newline at end of file

Modified: branches/2.4/regress/mvt_jsonb_expected
===================================================================
--- branches/2.4/regress/mvt_jsonb_expected	2019-01-11 12:37:24 UTC (rev 17135)
+++ branches/2.4/regress/mvt_jsonb_expected	2019-01-11 13:50:49 UTC (rev 17136)
@@ -1,2 +1,6 @@
-TA9|Gi8KBHRlc3QSDhIEAAABARgBIgQJMt4/GgJjMRoCYzIiAigBIgYKBGFiY2QogCB4Ag==
-TA10|GisKBHRlc3QSDhIEAAABABgBIgQJMt4/GgJjMRoCYzIiBgoEYWJjZCiAIHgC
+J1|Gi8KBHRlc3QSDhIEAAABARgBIgQJMt4/GgJjMRoCYzIiAigBIgYKBGFiY2QogCB4Ag==
+J2|GisKBHRlc3QSDhIEAAABABgBIgQJMt4/GgJjMRoCYzIiBgoEYWJjZCiAIHgC
+J3|GlAKBHRlc3QSDhIEAAABABgBIgQJMt4/Eg4SBAABAgIYASIECTLePxoCYzEaAmMyGgJjMyIGCgRh
+YmNkIgIoBSILCglhYmFzZGFkY2QogCB4Ag==
+J4|GjsKBHRlc3QSDhIEAAABARgBIgQJAIBAGgJjMRoEdGVzdCIJGQAAAAAAAPQ/IgkZAAAAAAAA/D8o
+gCB4Ag==



More information about the postgis-tickets mailing list