Skip to content

适用虚谷数据库版本

v12.9



适用虚谷数据库版本

v12.9


POSTGIS_TYPE_NAME

📄字数 3.1K
👁️阅读量 加载中...

功能描述

由几何类型名称和维度,返回几何类型名称。

语法格式

sql
VARCHAR POSTGIS_TYPE_NAME(VARCHAR geom_name,INTEGER coord_dimension,BOOLEAN use_new_name = true);

参数说明

  • geom_name: 几何类型名称。
  • coord_dimension:坐标维度。
  • use_new_name:是否新版本几何名称,默认:true。

函数返回类型

VARCHAR 类型

几何类型名称映射表

旧版名称新版名称坐标维度
GEOMETRYGeometry2
GEOMETRYGeometryZ3
GEOMETRYMGeometryM3
GEOMETRYGeometryZM4
GEOMETRYCOLLECTIONGeometryCollection2
GEOMETRYCOLLECTIONGeometryCollectionZ3
GEOMETRYCOLLECTIONMGeometryCollectionM3
GEOMETRYCOLLECTIONGeometryCollectionZM4
POINTPoint2
POINTPointZ3
POINTMPointM3
POINTPointZM4
MULTIPOINTMultiPoint2
MULTIPOINTMultiPointZ3
MULTIPOINTMMultiPointM3
MULTIPOINTMultiPointZM4
POLYGONPolygon2
POLYGONPolygonZ3
POLYGONMPolygonM3
POLYGONPolygonZM4
MULTIPOLYGONMultiPolygon2
MULTIPOLYGONMultiPolygonZ3
MULTIPOLYGONMMultiPolygonM3
MULTIPOLYGONMultiPolygonZM4
MULTILINESTRINGMultiLineString2
MULTILINESTRINGMultiLineStringZ3
MULTILINESTRINGMMultiLineStringM3
MULTILINESTRINGMultiLineStringZM4
LINESTRINGLineString2
LINESTRINGLineStringZ3
LINESTRINGMLineStringM3
LINESTRINGLineStringZM4
CIRCULARSTRINGCircularString2
CIRCULARSTRINGCircularStringZ3
CIRCULARSTRINGMCircularStringM3
CIRCULARSTRINGCircularStringZM4
COMPOUNDCURVECompoundCurve2
COMPOUNDCURVECompoundCurveZ3
COMPOUNDCURVEMCompoundCurveM3
COMPOUNDCURVECompoundCurveZM4
CURVEPOLYGONCurvePolygon2
CURVEPOLYGONCurvePolygonZ3
CURVEPOLYGONMCurvePolygonM3
CURVEPOLYGONCurvePolygonZM4
MULTICURVEMultiCurve2
MULTICURVEMultiCurveZ3
MULTICURVEMMultiCurveM3
MULTICURVEMultiCurveZM4
MULTISURFACEMultiSurface2
MULTISURFACEMultiSurfaceZ3
MULTISURFACEMMultiSurfaceM3
MULTISURFACEMultiSurfaceZM4
POLYHEDRALSURFACEPolyhedralSurface2
POLYHEDRALSURFACEPolyhedralSurfaceZ3
POLYHEDRALSURFACEMPolyhedralSurfaceM3
POLYHEDRALSURFACEPolyhedralSurfaceZM4
TRIANGLETriangle2
TRIANGLETriangleZ3
TRIANGLEMTriangleM3
TRIANGLETriangleZM4
TINTin2
TINTinZ3
TINMTinM3
TINTinZM4

使用说明

  1. 几何类型和坐标维度不匹配时,返回 NULL。
  2. 新旧版本对 M/Z/ZM 修饰符限定不同。

示例

几何类型名称:

sql
SQL> select
    postgis_type_name('GEOMETRY',5) as dim5,
    postgis_type_name('GEOMETRY',4) as dim4,
    postgis_type_name('GEOMETRY',3) as dim3,
    postgis_type_name('GEOMETRY',2) as dim2,
    postgis_type_name('GEOMETRY',1) as dim1,
    postgis_type_name('GEOMETRY',5,false) as dim5_old,
    postgis_type_name('GEOMETRY',4,false) as dim4_old,
    postgis_type_name('GEOMETRY',3,false) as dim3_old,
    postgis_type_name('GEOMETRY',2,false) as dim2_old,
    postgis_type_name('GEOMETRY',1,false) as dim1_old;

+--------+------------+-----------+----------+--------+----------+----------+----------+----------+----------+
|  DIM5  |    DIM4    |   DIM3    |   DIM2   |  DIM1  | DIM5_OLD | DIM4_OLD | DIM3_OLD | DIM2_OLD | DIM1_OLD |
+--------+------------+-----------+----------+--------+----------+----------+----------+----------+----------+
| <NULL> | GeometryZM | GeometryZ | Geometry | <NULL> | <NULL>   | GEOMETRY | GEOMETRY | GEOMETRY | <NULL>   |
+--------+------------+-----------+----------+--------+----------+----------+----------+----------+----------+

线串的类型名称:

sql
SQL> select
    postgis_type_name('LINESTRING',5) as dim5,
    postgis_type_name('LINESTRING',4) as dim4,
    postgis_type_name('LINESTRING',3) as dim3,
    postgis_type_name('LINESTRING',2) as dim2,
    postgis_type_name('LINESTRING',1) as dim1,
    postgis_type_name('LINESTRING',5,false) as dim5_old,
    postgis_type_name('LINESTRING',4,false) as dim4_old,
    postgis_type_name('LINESTRING',3,false) as dim3_old,
    postgis_type_name('LINESTRING',2,false) as dim2_old,
    postgis_type_name('LINESTRING',1,false) as dim1_old;

+--------+--------------+-------------+------------+--------+----------+------------+------------+------------+----------+
|  DIM5  |     DIM4     |    DIM3     |    DIM2    |  DIM1  | DIM5_OLD |  DIM4_OLD  |  DIM3_OLD  |  DIM2_OLD  | DIM1_OLD |
+--------+--------------+-------------+------------+--------+----------+------------+------------+------------+----------+
| <NULL> | LineStringZM | LineStringZ | LineString | <NULL> | <NULL>   | LINESTRING | LINESTRING | LINESTRING | <NULL>   |
+--------+--------------+-------------+------------+--------+----------+------------+------------+------------+----------+

SQL> select
    postgis_type_name('LINESTRINGM',2) as LINESTRINGM,
    postgis_type_name('LINESTRINGM',3) as LINESTRINGM3,
    postgis_type_name('LINESTRINGZ',3) as LINESTRINGZ3,
    postgis_type_name('LINESTRINGZM',3) as LINESTRINGZM3,
    postgis_type_name('LINESTRINGZM',4) as LINESTRINGZM4;

+-------------+--------------+--------------+---------------+---------------+
| LINESTRINGM | LINESTRINGM3 | LINESTRINGZ3 | LINESTRINGZM3 | LINESTRINGZM4 |
+-------------+--------------+--------------+---------------+---------------+
| <NULL>      | LineStringM  | LineStringZ  | <NULL>        | LineStringZM  |
+-------------+--------------+--------------+---------------+---------------+