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

Raul raul at rmr.ninja
Fri Jan 11 04:37:24 PST 2019


Author: algunenano
Date: 2019-01-11 04:37:24 -0800 (Fri, 11 Jan 2019)
New Revision: 17135

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

References #4292



Modified: branches/2.5/NEWS
===================================================================
--- branches/2.5/NEWS	2019-01-11 12:33:56 UTC (rev 17134)
+++ branches/2.5/NEWS	2019-01-11 12:37:24 UTC (rev 17135)
@@ -23,10 +23,11 @@
 
   - #4267, Enable Proj 6 deprecated APIs (Darafei Praliaskouski, Raúl Marín)
 
-  - #4276, ST_AsGeoJSON documentation refresh (Darafei Praliaskouski)	
+  - #4276, ST_AsGeoJSON documentation refresh (Darafei Praliaskouski)
 
   - #4273, Tighter parsing of WKT (Paul Ramsey)
 
+  - #4292, ST_AsMVT: parse JSON numeric values with decimals as doubles (Raúl Marín)
 
 PostGIS 2.5.1
 2018/11/18

Modified: branches/2.5/postgis/mvt.c
===================================================================
--- branches/2.5/postgis/mvt.c	2019-01-11 12:33:56 UTC (rev 17134)
+++ branches/2.5/postgis/mvt.c	2019-01-11 12:37:24 UTC (rev 17135)
@@ -608,7 +608,7 @@
 					PointerGetDatum(v.val.numeric)));
 				d = strtod(str, NULL);
 				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));

Modified: branches/2.5/regress/mvt_jsonb.sql
===================================================================
--- branches/2.5/regress/mvt_jsonb.sql	2019-01-11 12:33:56 UTC (rev 17134)
+++ branches/2.5/regress/mvt_jsonb.sql	2019-01-11 12:37:24 UTC (rev 17135)
@@ -11,3 +11,9 @@
     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.5/regress/mvt_jsonb_expected
===================================================================
--- branches/2.5/regress/mvt_jsonb_expected	2019-01-11 12:33:56 UTC (rev 17134)
+++ branches/2.5/regress/mvt_jsonb_expected	2019-01-11 12:37:24 UTC (rev 17135)
@@ -2,3 +2,5 @@
 J2|GisKBHRlc3QSDhIEAAABABgBIgQJMt4/GgJjMRoCYzIiBgoEYWJjZCiAIHgC
 J3|GlAKBHRlc3QSDhIEAAABABgBIgQJMt4/Eg4SBAABAgIYASIECTLePxoCYzEaAmMyGgJjMyIGCgRh
 YmNkIgIoBSILCglhYmFzZGFkY2QogCB4Ag==
+J4|GjsKBHRlc3QSDhIEAAABARgBIgQJAIBAGgJjMRoEdGVzdCIJGQAAAAAAAPQ/IgkZAAAAAAAA/D8o
+gCB4Ag==



More information about the postgis-tickets mailing list