[postgis-tickets] r16131 - Support google line encodings that include a backslash character (References #3713)

Paul Ramsey pramsey at cleverelephant.ca
Thu Nov 30 13:41:27 PST 2017


Author: pramsey
Date: 2017-11-30 13:41:27 -0800 (Thu, 30 Nov 2017)
New Revision: 16131

Modified:
   branches/2.4/NEWS
   branches/2.4/liblwgeom/cunit/cu_out_encoded_polyline.c
   branches/2.4/liblwgeom/lwout_encoded_polyline.c
   branches/2.4/postgis/lwgeom_export.c
Log:
Support google line encodings that include a backslash character (References #3713)



Modified: branches/2.4/NEWS
===================================================================
--- branches/2.4/NEWS	2017-11-30 21:41:18 UTC (rev 16130)
+++ branches/2.4/NEWS	2017-11-30 21:41:27 UTC (rev 16131)
@@ -2,7 +2,7 @@
 2017/xx/xx
 
  * Bug fixes *
-  -
+  - #3713, Support encodings that happen to output a '\' character
 
 
 PostGIS 2.4.2

Modified: branches/2.4/liblwgeom/cunit/cu_out_encoded_polyline.c
===================================================================
--- branches/2.4/liblwgeom/cunit/cu_out_encoded_polyline.c	2017-11-30 21:41:18 UTC (rev 16130)
+++ branches/2.4/liblwgeom/cunit/cu_out_encoded_polyline.c	2017-11-30 21:41:27 UTC (rev 16131)
@@ -39,6 +39,13 @@
 
 static void out_encoded_polyline_test_geoms(void)
 {
+	/* Magic Linestring */
+	do_encoded_polyline_test(
+	    "SRID=4326;LINESTRING(33.6729 38.7071,33.6692 38.701,33.6673 38.6972,33.6626 38.6871)",
+	    5,
+	    "k~fkFsvolEbe at bVvVzJb~@j\\");
+		return;
+
 	/* Linestring */
 	do_encoded_polyline_test(
 	    "LINESTRING(-120.2 38.5,-120.95 40.7,-126.453 43.252)",

Modified: branches/2.4/liblwgeom/lwout_encoded_polyline.c
===================================================================
--- branches/2.4/liblwgeom/lwout_encoded_polyline.c	2017-11-30 21:41:18 UTC (rev 16130)
+++ branches/2.4/liblwgeom/lwout_encoded_polyline.c	2017-11-30 21:41:27 UTC (rev 16131)
@@ -108,8 +108,6 @@
 			 each value with 0x20 if another bit chunk follows and add 63*/
 			int nextValue = (0x20 | (numberToEncode & 0x1f)) + 63;
 			stringbuffer_aprintf(sb, "%c", (char)nextValue);
-			if(92 == nextValue)
-				stringbuffer_aprintf(sb, "%c", (char)nextValue);
 
 			/* Break the binary value out into 5-bit chunks */
 			numberToEncode >>= 5;
@@ -117,8 +115,6 @@
 
 		numberToEncode += 63;
 		stringbuffer_aprintf(sb, "%c", (char)numberToEncode);
-		if(92 == numberToEncode)
-			stringbuffer_aprintf(sb, "%c", (char)numberToEncode);
 	}
 
 	lwfree(delta);

Modified: branches/2.4/postgis/lwgeom_export.c
===================================================================
--- branches/2.4/postgis/lwgeom_export.c	2017-11-30 21:41:18 UTC (rev 16130)
+++ branches/2.4/postgis/lwgeom_export.c	2017-11-30 21:41:27 UTC (rev 16131)
@@ -635,7 +635,6 @@
 		PG_RETURN_NULL();
 	}
 	lwgeom = lwgeom_from_gserialized(geom);
-	PG_FREE_IF_COPY(geom, 0);
 
 	if (PG_NARGS() > 1 && !PG_ARGISNULL(1))
 	{
@@ -645,8 +644,9 @@
 
 	encodedpolyline = lwgeom_to_encoded_polyline(lwgeom, precision);
 	lwgeom_free(lwgeom);
+	PG_FREE_IF_COPY(geom, 0);
 
-  result = cstring2text(encodedpolyline);
+	result = cstring2text(encodedpolyline);
 	lwfree(encodedpolyline);
 
 	PG_RETURN_TEXT_P(result);



More information about the postgis-tickets mailing list