From: Daniel Baston Date: Tue, 6 Sep 2016 22:44:47 +0000 (+0000) Subject: #3627, Encoded polyline functions ignore precision parameter X-Git-Tag: 2.3.0rc1~28 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=27c11b26dc14225b2c9ef46ef97f5aae07362a08;p=postgis #3627, Encoded polyline functions ignore precision parameter git-svn-id: http://svn.osgeo.org/postgis/trunk@15074 b70326c6-7e19-0410-871a-916f4a2858ee --- diff --git a/postgis/lwgeom_export.c b/postgis/lwgeom_export.c index 1d684f959..a3aaeee0a 100644 --- a/postgis/lwgeom_export.c +++ b/postgis/lwgeom_export.c @@ -637,9 +637,9 @@ Datum LWGEOM_asEncodedPolyline(PG_FUNCTION_ARGS) lwgeom = lwgeom_from_gserialized(geom); PG_FREE_IF_COPY(geom, 0); - if (PG_NARGS() >2 && !PG_ARGISNULL(2)) + if (PG_NARGS() > 1 && !PG_ARGISNULL(1)) { - precision = PG_GETARG_INT32(2); + precision = PG_GETARG_INT32(1); if ( precision < 0 ) precision = 5; } diff --git a/postgis/lwgeom_in_encoded_polyline.c b/postgis/lwgeom_in_encoded_polyline.c index bbba36b9b..053d2fccd 100644 --- a/postgis/lwgeom_in_encoded_polyline.c +++ b/postgis/lwgeom_in_encoded_polyline.c @@ -47,9 +47,9 @@ Datum line_from_encoded_polyline(PG_FUNCTION_ARGS) encodedpolyline_input = PG_GETARG_TEXT_P(0); encodedpolyline = text2cstring(encodedpolyline_input); - if (PG_NARGS() >2 && !PG_ARGISNULL(2)) + if (PG_NARGS() > 1 && !PG_ARGISNULL(1)) { - precision = PG_GETARG_INT32(2); + precision = PG_GETARG_INT32(1); if ( precision < 0 ) precision = 5; } diff --git a/regress/in_encodedpolyline.sql b/regress/in_encodedpolyline.sql index 604fbc135..7e9539270 100644 --- a/regress/in_encodedpolyline.sql +++ b/regress/in_encodedpolyline.sql @@ -1,2 +1,2 @@ select 'linefromencodedpolyline_01',st_asewkt(st_linefromencodedpolyline('_p~iF~ps|U_ulLnnqC_mqNvxq`@')); -select 'linefromencodedpolyline_02',st_asewkt(st_linefromencodedpolyline('_p~iFlhz|UuksL`wjCivjNvxq`@', 6)); +select 'linefromencodedpolyline_02',st_asewkt(st_linefromencodedpolyline('_izlhAj}oidF{}jgCrotj@chtxCn`{nI', 6)); diff --git a/regress/in_encodedpolyline_expected b/regress/in_encodedpolyline_expected index 702495878..d3a53bb4d 100644 --- a/regress/in_encodedpolyline_expected +++ b/regress/in_encodedpolyline_expected @@ -1,2 +1,2 @@ linefromencodedpolyline_01|SRID=4326;LINESTRING(-120.2 38.5,-120.95 40.7,-126.453 43.252) -linefromencodedpolyline_02|SRID=4326;LINESTRING(-120.23447 38.5,-120.95 40.73435,-126.453 43.252) +linefromencodedpolyline_02|SRID=4326;LINESTRING(-120.234472 38.5,-120.95 40.734352,-126.453 43.252) diff --git a/regress/out_geometry_expected b/regress/out_geometry_expected index 9e6b08469..f045640f1 100644 --- a/regress/out_geometry_expected +++ b/regress/out_geometry_expected @@ -41,7 +41,7 @@ kml_projection_01|-74.078,4.596 encoded_polyline_01|_p~iF~ps|U_ulLnnqC_mqNvxq`@ encoded_polyline_02|_p~iF~ps|U_ulLnnqC_mqNvxq`@ ERROR: Only SRID 4326 is supported. -encoded_polyline_04|_p~iFlhz|UuksL`wjCivjNvxq`@ +encoded_polyline_04|_izlhAd}oidF{}jgCxotj@chtxCn`{nI svg_empty_geom| svg_option_01|M 1 -1 L 4 -4 5 -7 svg_option_02|M 1 -1 l 3 -3 1 -3 diff --git a/regress/tickets.sql b/regress/tickets.sql index 8c23f670d..b477d07ad 100644 --- a/regress/tickets.sql +++ b/regress/tickets.sql @@ -993,6 +993,9 @@ from road, sidewalks, params; -- #3583 Select '#3583', ST_AsText(ST_GeomFromGeoJSON('{"type":"MultiPolygon", "coordinates":[[[139.10030364990232,35.16777444430609],5842.4224490305424]]}')); +-- #3627 +SELECT '#3627a', ST_AsEncodedPolyline('SRID=4326;LINESTRING(-0.250691 49.283048,-0.250633 49.283376,-0.250502 49.283972,-0.251245 49.284028,-0.251938 49.284232,-0.251938 49.2842)', 6); +SELECT '#3627b', ST_Equals(geom, ST_LineFromEncodedPolyline(ST_AsEncodedPolyline(geom, 7), 7)) FROM (VALUES ('SRID=4326;LINESTRING (0 0, 1 1)')) AS v (geom); -- Clean up DELETE FROM spatial_ref_sys; diff --git a/regress/tickets_expected b/regress/tickets_expected index 77e21f04c..8cd896d4f 100644 --- a/regress/tickets_expected +++ b/regress/tickets_expected @@ -296,3 +296,5 @@ ERROR: invalid KML representation #3470b|50 #3579|f|t #3583|MULTIPOLYGON Z (EMPTY) +#3627a|o}~~|AdshNoSsBgd@eGoBlm@wKhj@~@? +#3627b|t