Opened 3 months ago

Last modified 3 months ago

#5822 new defect

Incorrect Output for ST_ASEWKT with "LINESTRING Z"

Reported by: bitner Owned by: pramsey
Priority: medium Milestone: PostGIS 3.6.0
Component: postgis Version: 3.1.x
Keywords: WKT Cc:

Description

ST_AsEWKT does not report the geometry type correctly and reports differently than ST_AsText. See below to reproduce. ST_AsEWKT returns "LINESTRING" where it should return "LINESTRING Z".

postgres=# select postgis_full_version();

postgis_full_version


POSTGIS="3.5.0 d2c3ca4" [EXTENSION] PGSQL="170" GEOS="3.9.0-CAPI-1.16.2" PROJ="7.2.1 NETWORK_ENABLED=OFF URL_ENDPOINT=https://cdn.proj.org USER_WRITABLE_DIRECTORY=/var/lib/postgresql/.local/share/proj DATABASE_PATH=/usr/share/proj/proj.db" (compiled against PROJ 7.9.0) LIBXML="2.9.10" LIBJSON="0.15" LIBPROTOBUF="1.3.3" WAGYU="0.5.0 (Internal)" TOPOLOGY

(1 row)

postgres=# SELECT ST_Astext(ST_GeomFromText('LINESTRING Z(-71.160281 42.258729 1.0,-71.160837 42.259113 2.0,-71.161144 42.25932 3.0)'));

st_astext


LINESTRING Z (-71.160281 42.258729 1,-71.160837 42.259113 2,-71.161144 42.25932 3)

(1 row)

postgres=# SELECT ST_AsEWKT(ST_GeomFromText('LINESTRING Z(-71.160281 42.258729 1.0,-71.160837 42.259113 2.0,-71.161144 42.25932 3.0)'));

st_asewkt


LINESTRING(-71.160281 42.258729 1,-71.160837 42.259113 2,-71.161144 42.25932 3)

(1 row)

Change History (1)

comment:1 by robe, 3 months ago

Milestone: PostGIS 3.5.1PostGIS 3.6.0
Version: 3.4.x3.1.x

This looks to be an issue that has existed for a while. Even testing on PostGIS 3.1, I see it returning

 SELECT ST_AsEWKT(ST_GeomFromText('LINESTRING Z(-71.160281 42.258729 1.0,-71.160837 42.259113 2.0,-71.161144 42.25932 3.0)')); 
LINESTRING(-71.160281 42.258729 1,-71.160837 42.259113 2,-71.161144 42.25932 3)

So if we change this behavior, we can't do it until 3.6.0 (can't go into micros).

I'm not sure it's worth fixing cause I think OGC concerned apps would be using ST_ASText and ST_AsEWKT has always been our own home grown WKT to serve our purposes. I'm more concerned about breaking existing apps that rely on this old behavior than doing the "Right thing" here.

@pramsey @strk you have any thoughts on this.

At anyrate I think we should all agree this can't go in as a micro change.

Note: See TracTickets for help on using tickets.