From 4e7344fa7ab1fb60f77c3126ba7b269f290dbc6a Mon Sep 17 00:00:00 2001 From: =?utf8?q?Ra=C3=BAl=20Mar=C3=ADn=20Rodr=C3=ADguez?= Date: Fri, 29 Mar 2019 14:23:00 +0000 Subject: [PATCH] Fix postgis_type_name with (GEOMETRYM,3) Patch by Matt Bretl Closes https://github.com/postgis/postgis/pull/387 References #4361 git-svn-id: http://svn.osgeo.org/postgis/trunk@17365 b70326c6-7e19-0410-871a-916f4a2858ee --- postgis/postgis.sql.in | 156 ++++++++++++------------ regress/core/postgis_type_name.sql | 12 ++ regress/core/postgis_type_name_expected | 11 ++ 3 files changed, 102 insertions(+), 77 deletions(-) diff --git a/postgis/postgis.sql.in b/postgis/postgis.sql.in index f887757c1..504cda790 100644 --- a/postgis/postgis.sql.in +++ b/postgis/postgis.sql.in @@ -5616,89 +5616,91 @@ CREATE OR REPLACE FUNCTION postgis_type_name(geomname varchar, coord_dimension i RETURNS varchar AS $$ - SELECT CASE WHEN $3 THEN new_name ELSE old_name END As geomname + SELECT CASE WHEN $3 THEN new_name ELSE old_name END As geomname FROM - ( VALUES - ('GEOMETRY', 'Geometry', 2) , - ('GEOMETRY', 'GeometryZ', 3) , - ('GEOMETRY', 'GeometryZM', 4) , - ('GEOMETRYCOLLECTION', 'GeometryCollection', 2) , - ('GEOMETRYCOLLECTION', 'GeometryCollectionZ', 3) , - ('GEOMETRYCOLLECTIONM', 'GeometryCollectionM', 3) , - ('GEOMETRYCOLLECTION', 'GeometryCollectionZM', 4) , - - ('POINT', 'Point',2) , - ('POINTM','PointM',3) , - ('POINT', 'PointZ',3) , - ('POINT', 'PointZM',4) , - - ('MULTIPOINT','MultiPoint',2) , - ('MULTIPOINT','MultiPointZ',3) , - ('MULTIPOINTM','MultiPointM',3) , - ('MULTIPOINT','MultiPointZM',4) , - - ('POLYGON', 'Polygon',2) , - ('POLYGON', 'PolygonZ',3) , - ('POLYGONM', 'PolygonM',3) , - ('POLYGON', 'PolygonZM',4) , - - ('MULTIPOLYGON', 'MultiPolygon',2) , - ('MULTIPOLYGON', 'MultiPolygonZ',3) , - ('MULTIPOLYGONM', 'MultiPolygonM',3) , - ('MULTIPOLYGON', 'MultiPolygonZM',4) , - - ('MULTILINESTRING', 'MultiLineString',2) , - ('MULTILINESTRING', 'MultiLineStringZ',3) , - ('MULTILINESTRINGM', 'MultiLineStringM',3) , - ('MULTILINESTRING', 'MultiLineStringZM',4) , - - ('LINESTRING', 'LineString',2) , - ('LINESTRING', 'LineStringZ',3) , - ('LINESTRINGM', 'LineStringM',3) , - ('LINESTRING', 'LineStringZM',4) , - - ('CIRCULARSTRING', 'CircularString',2) , - ('CIRCULARSTRING', 'CircularStringZ',3) , - ('CIRCULARSTRINGM', 'CircularStringM',3) , - ('CIRCULARSTRING', 'CircularStringZM',4) , - - ('COMPOUNDCURVE', 'CompoundCurve',2) , - ('COMPOUNDCURVE', 'CompoundCurveZ',3) , - ('COMPOUNDCURVEM', 'CompoundCurveM',3) , - ('COMPOUNDCURVE', 'CompoundCurveZM',4) , - - ('CURVEPOLYGON', 'CurvePolygon',2) , - ('CURVEPOLYGON', 'CurvePolygonZ',3) , - ('CURVEPOLYGONM', 'CurvePolygonM',3) , - ('CURVEPOLYGON', 'CurvePolygonZM',4) , - - ('MULTICURVE', 'MultiCurve',2 ) , - ('MULTICURVE', 'MultiCurveZ',3 ) , - ('MULTICURVEM', 'MultiCurveM',3 ) , - ('MULTICURVE', 'MultiCurveZM',4 ) , - - ('MULTISURFACE', 'MultiSurface', 2) , - ('MULTISURFACE', 'MultiSurfaceZ', 3) , - ('MULTISURFACEM', 'MultiSurfaceM', 3) , - ('MULTISURFACE', 'MultiSurfaceZM', 4) , - - ('POLYHEDRALSURFACE', 'PolyhedralSurface',2) , - ('POLYHEDRALSURFACE', 'PolyhedralSurfaceZ',3) , - ('POLYHEDRALSURFACEM', 'PolyhedralSurfaceM',3) , - ('POLYHEDRALSURFACE', 'PolyhedralSurfaceZM',4) , - - ('TRIANGLE', 'Triangle',2) , - ('TRIANGLE', 'TriangleZ',3) , - ('TRIANGLEM', 'TriangleM',3) , - ('TRIANGLE', 'TriangleZM',4) , + ( VALUES + ('GEOMETRY', 'Geometry', 2), + ('GEOMETRY', 'GeometryZ', 3), + ('GEOMETRYM', 'GeometryM', 3), + ('GEOMETRY', 'GeometryZM', 4), + + ('GEOMETRYCOLLECTION', 'GeometryCollection', 2), + ('GEOMETRYCOLLECTION', 'GeometryCollectionZ', 3), + ('GEOMETRYCOLLECTIONM', 'GeometryCollectionM', 3), + ('GEOMETRYCOLLECTION', 'GeometryCollectionZM', 4), + + ('POINT', 'Point', 2), + ('POINT', 'PointZ', 3), + ('POINTM','PointM', 3), + ('POINT', 'PointZM', 4), + + ('MULTIPOINT','MultiPoint', 2), + ('MULTIPOINT','MultiPointZ', 3), + ('MULTIPOINTM','MultiPointM', 3), + ('MULTIPOINT','MultiPointZM', 4), + + ('POLYGON', 'Polygon', 2), + ('POLYGON', 'PolygonZ', 3), + ('POLYGONM', 'PolygonM', 3), + ('POLYGON', 'PolygonZM', 4), + + ('MULTIPOLYGON', 'MultiPolygon', 2), + ('MULTIPOLYGON', 'MultiPolygonZ', 3), + ('MULTIPOLYGONM', 'MultiPolygonM', 3), + ('MULTIPOLYGON', 'MultiPolygonZM', 4), + + ('MULTILINESTRING', 'MultiLineString', 2), + ('MULTILINESTRING', 'MultiLineStringZ', 3), + ('MULTILINESTRINGM', 'MultiLineStringM', 3), + ('MULTILINESTRING', 'MultiLineStringZM', 4), + + ('LINESTRING', 'LineString', 2), + ('LINESTRING', 'LineStringZ', 3), + ('LINESTRINGM', 'LineStringM', 3), + ('LINESTRING', 'LineStringZM', 4), + + ('CIRCULARSTRING', 'CircularString', 2), + ('CIRCULARSTRING', 'CircularStringZ', 3), + ('CIRCULARSTRINGM', 'CircularStringM' ,3), + ('CIRCULARSTRING', 'CircularStringZM', 4), + + ('COMPOUNDCURVE', 'CompoundCurve', 2), + ('COMPOUNDCURVE', 'CompoundCurveZ', 3), + ('COMPOUNDCURVEM', 'CompoundCurveM', 3), + ('COMPOUNDCURVE', 'CompoundCurveZM', 4), + + ('CURVEPOLYGON', 'CurvePolygon', 2), + ('CURVEPOLYGON', 'CurvePolygonZ', 3), + ('CURVEPOLYGONM', 'CurvePolygonM', 3), + ('CURVEPOLYGON', 'CurvePolygonZM', 4), + + ('MULTICURVE', 'MultiCurve', 2), + ('MULTICURVE', 'MultiCurveZ', 3), + ('MULTICURVEM', 'MultiCurveM', 3), + ('MULTICURVE', 'MultiCurveZM', 4), + + ('MULTISURFACE', 'MultiSurface', 2), + ('MULTISURFACE', 'MultiSurfaceZ', 3), + ('MULTISURFACEM', 'MultiSurfaceM', 3), + ('MULTISURFACE', 'MultiSurfaceZM', 4), + + ('POLYHEDRALSURFACE', 'PolyhedralSurface', 2), + ('POLYHEDRALSURFACE', 'PolyhedralSurfaceZ', 3), + ('POLYHEDRALSURFACEM', 'PolyhedralSurfaceM', 3), + ('POLYHEDRALSURFACE', 'PolyhedralSurfaceZM', 4), + + ('TRIANGLE', 'Triangle', 2), + ('TRIANGLE', 'TriangleZ', 3), + ('TRIANGLEM', 'TriangleM', 3), + ('TRIANGLE', 'TriangleZM', 4), ('TIN', 'Tin', 2), ('TIN', 'TinZ', 3), - ('TIN', 'TinM', 3), + ('TINM', 'TinM', 3), ('TIN', 'TinZM', 4) ) As g(old_name, new_name, coord_dimension) - WHERE (upper(old_name) = upper($1) OR upper(new_name) = upper($1)) - AND coord_dimension = $2; + WHERE (upper(old_name) = upper($1) OR upper(new_name) = upper($1)) + AND coord_dimension = $2; $$ LANGUAGE 'sql' IMMUTABLE STRICT _PARALLEL _COST_HIGH; diff --git a/regress/core/postgis_type_name.sql b/regress/core/postgis_type_name.sql index f52c3dc17..f0a03d80d 100644 --- a/regress/core/postgis_type_name.sql +++ b/regress/core/postgis_type_name.sql @@ -1,3 +1,15 @@ +SELECT 'GEOMETRY(0)', postgis_type_name('GEOMETRY', 0); +SELECT 'GEOMETRY(1)', postgis_type_name('GEOMETRY', 1); +SELECT 'GEOMETRY(2)', postgis_type_name('GEOMETRY', 2); +SELECT 'GEOMETRY(3)', postgis_type_name('GEOMETRY', 3); +SELECT 'GEOMETRY(4)', postgis_type_name('GEOMETRY', 4); +SELECT 'GEOMETRY(5)', postgis_type_name('GEOMETRY', 5); +SELECT 'GEOMETRYM(2)', postgis_type_name('GEOMETRYM', 2); +SELECT 'GEOMETRYM(3)', postgis_type_name('GEOMETRYM', 3); +SELECT 'GEOMETRYZ(3)', postgis_type_name('GEOMETRYZ', 3); +SELECT 'GEOMETRYZM(3)', postgis_type_name('GEOMETRYZM', 3); +SELECT 'GEOMETRYZM(4)', postgis_type_name('GEOMETRYZM', 4); + SELECT 'POINT(0)', postgis_type_name('POINT', 0); SELECT 'POINT(1)', postgis_type_name('POINT', 1); SELECT 'POINT(2)', postgis_type_name('POINT', 2); diff --git a/regress/core/postgis_type_name_expected b/regress/core/postgis_type_name_expected index 438522330..e21899043 100644 --- a/regress/core/postgis_type_name_expected +++ b/regress/core/postgis_type_name_expected @@ -1,3 +1,14 @@ +GEOMETRY(0)| +GEOMETRY(1)| +GEOMETRY(2)|Geometry +GEOMETRY(3)|GeometryZ +GEOMETRY(4)|GeometryZM +GEOMETRY(5)| +GEOMETRYM(2)| +GEOMETRYM(3)|GeometryM +GEOMETRYZ(3)|GeometryZ +GEOMETRYZM(3)| +GEOMETRYZM(4)|GeometryZM POINT(0)| POINT(1)| POINT(2)|Point -- 2.40.0