]> granicus.if.org Git - postgis/commitdiff
Support google line encodings that include a backslash character (References #3713)
authorPaul Ramsey <pramsey@cleverelephant.ca>
Thu, 30 Nov 2017 21:41:27 +0000 (21:41 +0000)
committerPaul Ramsey <pramsey@cleverelephant.ca>
Thu, 30 Nov 2017 21:41:27 +0000 (21:41 +0000)
git-svn-id: http://svn.osgeo.org/postgis/branches/2.4@16131 b70326c6-7e19-0410-871a-916f4a2858ee

NEWS
liblwgeom/cunit/cu_out_encoded_polyline.c
liblwgeom/lwout_encoded_polyline.c
postgis/lwgeom_export.c

diff --git a/NEWS b/NEWS
index 271a99cd843fa5f7d7d2e279d484e628a718c252..107d7ad78c42f74e01361f32a54a64da993a542f 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -2,7 +2,7 @@ PostGIS 2.4.3
 2017/xx/xx
 
  * Bug fixes *
-  -
+  - #3713, Support encodings that happen to output a '\' character
 
 
 PostGIS 2.4.2
index ebaa31ce7b847421926c81128dfa9729a76f0a13..95c12e941fd704b6ddee0e23bf5825d364a53a3b 100644 (file)
@@ -39,6 +39,13 @@ static void do_encoded_polyline_test(char * in, int precision, char * out)
 
 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@bVvVzJb~@j\\");
+               return;
+
        /* Linestring */
        do_encoded_polyline_test(
            "LINESTRING(-120.2 38.5,-120.95 40.7,-126.453 43.252)",
index 050b4587c3fbc6fb435006d512b0c100b16ba227..2f3a4aa3f06e5b3ae36468d09d3aa7f5888ea65d 100644 (file)
@@ -108,8 +108,6 @@ char * pointarray_to_encoded_polyline(const POINTARRAY *pa, int precision)
                         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 @@ char * pointarray_to_encoded_polyline(const POINTARRAY *pa, int precision)
 
                numberToEncode += 63;
                stringbuffer_aprintf(sb, "%c", (char)numberToEncode);
-               if(92 == numberToEncode)
-                       stringbuffer_aprintf(sb, "%c", (char)numberToEncode);
        }
 
        lwfree(delta);
index 9630232adb3e02f5347b931180503e99c068a390..74bf1aafdfa11055ef232afd52a73591cf8a38f8 100644 (file)
@@ -635,7 +635,6 @@ Datum LWGEOM_asEncodedPolyline(PG_FUNCTION_ARGS)
                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 @@ Datum LWGEOM_asEncodedPolyline(PG_FUNCTION_ARGS)
 
        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);