Skip to content

Commit

Permalink
Support google line encodings that include a backslash character (Ref…
Browse files Browse the repository at this point in the history
…erences #3713)

git-svn-id: http://svn.osgeo.org/postgis/trunk@16130 b70326c6-7e19-0410-871a-916f4a2858ee
  • Loading branch information
pramsey committed Nov 30, 2017
1 parent 47521da commit e476ecc
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
7 changes: 7 additions & 0 deletions liblwgeom/cunit/cu_out_encoded_polyline.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)",
Expand Down
4 changes: 0 additions & 4 deletions liblwgeom/lwout_encoded_polyline.c
Original file line number Diff line number Diff line change
Expand Up @@ -108,17 +108,13 @@ 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;
}

numberToEncode += 63;
stringbuffer_aprintf(sb, "%c", (char)numberToEncode);
if(92 == numberToEncode)
stringbuffer_aprintf(sb, "%c", (char)numberToEncode);
}

lwfree(delta);
Expand Down
4 changes: 2 additions & 2 deletions postgis/lwgeom_export.c
Original file line number Diff line number Diff line change
Expand Up @@ -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))
{
Expand All @@ -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);
Expand Down

0 comments on commit e476ecc

Please sign in to comment.