暂无图片
暂无图片
暂无图片
暂无图片
暂无图片

MySQL的SQL语句 - 数据定义语句(13)- CREATE SPATIAL REFERENCE SYSTEM 语句

林员外聊编程 2020-08-08
271
CREATE SPATIAL REFERENCE SYSTEM 语句
 
CREATE OR REPLACE SPATIAL REFERENCE SYSTEM
srid srs_attribute ...


CREATE SPATIAL REFERENCE SYSTEM
[IF NOT EXISTS]
srid srs_attribute ...


srs_attribute: {
NAME 'srs_name'
| DEFINITION 'definition'
| ORGANIZATION 'org_name' IDENTIFIED BY org_id
| DESCRIPTION 'description'
}


srid, org_id: 32-bit unsigned integer
 
此语句创建空间参考系统(SRS)定义并将其存储在数据字典中。这需要 SUPER 权限。可以使用 INFORMATION_SCHEMA.ST_SPATIAL_REFERENCE_SYSTEMS 表检查得到的数据字典条目。
 
SRID 值必须是唯一的,因此,如果既没有指定 OR REPLACE 也没有指定 IF NOT EXISTS 语句,则如果具有给定 srid 值的 SRS 定义已经存在,则会发生错误。
 
使用 CREATE OR REPLACE 语法,将替换具有相同 SRID 值的任何现有SRS定义,除非 SRID 值被现有表中的某个列使用。在这种情况下,会发生错误。例如:
 
mysql> CREATE OR REPLACE SPATIAL REFERENCE SYSTEM 4326 ...;
ERROR 3716 (SR005): Can't modify SRID 4326. There is at
least one column depending on it.
 
要确定哪些列使用 SRID,请使用以下查询,将 4326 替换为要创建的 SRID 值:
 
SELECT * FROM INFORMATION_SCHEMA.ST_GEOMETRY_COLUMNS WHERE SRS_ID=4326;
 
使用 CREATE ... IF NOT EXISTS 语法,如果现有SRS定义具有相同SRID值,新定义将被忽略并发出警告。
 
SRID值必须在32位无符号整数的范围内,但有以下限制:
 
● SRID 0是有效的SRID,但不能与 CREATE SPATIAL REFERENCE SYSTEM 一起使用。
 
● 如果该值在保留的SRID范围内,则会出现警告。保留范围为[0, 32767](由EPSG保留)、[60000000, 69999999](由EPSG保留)和[20000000000, 2147483647](由MySQL保留)。EPSG 代表欧洲石油调查集团。
 
● 用户创建的SRSSRID值不应在保留范围内。这样做有可能导致 SRID 值与将来随MySQL一起发布的SRS定义发生冲突,结果是不会为MySQL升级安装新的系统提供的SRS,或者覆盖用户定义的SRS
 
语句的属性必须满足以下条件:
 
● 属性可以以任何顺序给出,但是属性不能被赋值多次。
 
● NAME DEFINITION 属性是必需的。
 
● NAME srs_name 属性值必须唯一。ORGANIZATION org_name  org_id 属性值的组合必须唯一。
 
● NAME srs_name 属性值和 ORGANIZATION org_name 属性值不能为空,也不能以空格开头或结尾。
 
● 属性中的字符串值不能包含控制字符,包括换行符。
 
● 下表显示了字符串属性值的最大长度。
 
表:CREATE SPATIAL REFERENCE SYSTEM 属性长度
 
属性
最大长度 (字符数)
NAME
80
DEFINITION
4096
ORGANIZATION
256
DESCRIPTION
2048
 
下面是一个 CREATE SPATIAL REFERENCE SYSTEM 语句的示例。为了可读性,DEFINITION 值格式化为多行。(要使语句合法,实际值必须在单行上给出。)
 
CREATE SPATIAL REFERENCE SYSTEM 4120
NAME 'Greek'
ORGANIZATION 'EPSG' IDENTIFIED BY 4120
DEFINITION
'GEOGCS["Greek",DATUM["Greek",SPHEROID["Bessel 1841",
6377397.155,299.1528128,AUTHORITY["EPSG","7004"]],
AUTHORITY["EPSG","6120"]],PRIMEM["Greenwich",0,
AUTHORITY["EPSG","8901"]],UNIT["degree",0.017453292519943278,
AUTHORITY["EPSG","9122"]],AXIS["Lat",NORTH],AXIS["Lon",EAST],
AUTHORITY["EPSG","4120"]]';
 
SRS定义的语法基于 OpenGIS实现规范:坐标转换服务,修订版 1.00OGC 01-009 2001112日,第7.2节中定义的语法。本规范可在 http://www.opengeospatial.org/standards/ct 找到。
 
MySQL 将以下更改合并到规范中:
 
● 仅实现了 <horz cs> 生产规则(即地理和投影 SRS)。
 
● <parameter> 有一个可选的、非标准的 <authority> 子句。可以通过权限而不是名称来识别投影参数。
 
● 本规范并未强制要求 GEOGCS 空间参考系统定义中的 AXIS 子句是必须的。但是,如果没有 AXIS 子句,MySQL 无法确定定义的轴是纬度-经度顺序还是经度-纬度顺序。MySQL强制要求每个 GEOGCS 定义必须包含两个 AXIS 子句。一个必须是 NORTH SOUTH,另一个是 EAST WESTAXIS 子句顺序决定定义是否具有纬度-经度顺序或经度-纬度顺序的轴。
 
● SRS定义不能包含换行符。
 
如果SRS定义为投影指定了一个授权代码(推荐),如果定义缺少必需的参数,则会发生错误。在这种情况下,错误消息指示问题所在。MySQL支持的投影方法和必须参数参见下面的表。
 
下表显示了MySQL支持的投影方法。MySQL允许使用未知的投影方法,但不能检查必须参数的定义,也不能转换来自或者发送到未知投影的空间数据。有关每个投影如何工作的详细说明,包括公式,请参见 EPSG Guidance Note 7-2
 
支持的空间参照系投影方法:
 
EPSG 代码
投影名称
必须参数 (EPSG 代码)
1024
Popular Visualisation Pseudo Mercator
8801, 8802, 8806, 8807
1027
Lambert Azimuthal Equal Area (Spherical)
8801, 8802, 8806, 8807
1028
Equidistant Cylindrical
8823, 8802, 8806, 8807
1029
Equidistant Cylindrical (Spherical)
8823, 8802, 8806, 8807
1041
Krovak (North Orientated)
8811, 8833, 1036, 8818, 8819, 8806, 8807
1042
Krovak Modified
8811, 8833, 1036, 8818, 8819, 8806, 8807, 8617, 8618, 1026, 1027, 1028, 1029, 1030, 1031, 1032, 1033, 1034, 1035
1043
Krovak Modified (North Orientated)
8811, 8833, 1036, 8818, 8819, 8806, 8807, 8617, 8618, 1026, 1027, 1028, 1029, 1030, 1031, 1032, 1033, 1034, 1035
1051
Lambert Conic Conformal (2SP Michigan)
8821, 8822, 8823, 8824, 8826, 8827, 1038
1052
Colombia Urban
8801, 8802, 8806, 8807, 1039
9801
Lambert Conic Conformal (1SP)
8801, 8802, 8805, 8806, 8807
9802
Lambert Conic Conformal (2SP)
8821, 8822, 8823, 8824, 8826, 8827
9803
Lambert Conic Conformal (2SP Belgium)
8821, 8822, 8823, 8824, 8826, 8827
9804
Mercator (variant A)
8801, 8802, 8805, 8806, 8807
9805
Mercator (variant B)
8823, 8802, 8806, 8807
9806
Cassini-Soldner
8801, 8802, 8806, 8807
9807
Transverse Mercator
8801, 8802, 8805, 8806, 8807
9808
Transverse Mercator (South Orientated)
8801, 8802, 8805, 8806, 8807
9809
Oblique Stereographic
8801, 8802, 8805, 8806, 8807
9810
Polar Stereographic (variant A)
8801, 8802, 8805, 8806, 8807
9811
New Zealand Map Grid
8801, 8802, 8806, 8807
9812
Hotine Oblique Mercator (variant A)
8811, 8812, 8813, 8814, 8815, 8806, 8807
9813
Laborde Oblique Mercator
8811, 8812, 8813, 8815, 8806, 8807
9815
Hotine Oblique Mercator (variant B)
8811, 8812, 8813, 8814, 8815, 8816, 8817
9816
Tunisia Mining Grid
8821, 8822, 8826, 8827
9817
Lambert Conic Near-Conformal
8801, 8802, 8805, 8806, 8807
9818
American Polyconic
8801, 8802, 8806, 8807
9819
Krovak
8811, 8833, 1036, 8818, 8819, 8806, 8807
9820
Lambert Azimuthal Equal Area
8801, 8802, 8806, 8807
9822
Albers Equal Area
8821, 8822, 8823, 8824, 8826, 8827
9824
Transverse Mercator Zoned Grid System
8801, 8830, 8831, 8805, 8806, 8807
9826
Lambert Conic Conformal (West Orientated)
8801, 8802, 8805, 8806, 8807
9828
Bonne (South Orientated)
8801, 8802, 8806, 8807
9829
Polar Stereographic (variant B)
8832, 8833, 8806, 8807
9830
Polar Stereographic (variant C)
8832, 8833, 8826, 8827
9831
Guam Projection
8801, 8802, 8806, 8807
9832
Modified Azimuthal Equidistant
8801, 8802, 8806, 8807
9833
Hyperbolic Cassini-Soldner
8801, 8802, 8806, 8807
9834
Lambert Cylindrical Equal Area (Spherical)
8823, 8802, 8806, 8807
9835
Lambert Cylindrical Equal Area
8823, 8802, 8806, 8807
 
 
下表显示了MySQL可以识别的投影参数。识别主要通过权限代码进行。如果没有权限代码,MySQL将匹配参数名,不区分大小写。有关每个参数的详细信息,请在https://www.epsg-registry.org/查找。
 
空间参考系投影参数
 
EPSG 代码
MySQL识别Name
EPSG 名称
1026
c1
C1
1027
c2
C2
1028
c3
C3
1029
c4
C4
1030
c5
C5
1031
c6
C6
1032
c7
C7
1033
c8
C8
1034
c9
C9
1035
c10
C10
1036
azimuth
Co-latitude of cone axis
1038
ellipsoid_scale_factor
Ellipsoid scaling factor
1039
projection_plane_height_at_origin
Projection plane origin height
8617
evaluation_point_ordinate_1
Ordinate 1 of evaluation point
8618
evaluation_point_ordinate_2
Ordinate 2 of evaluation point
8801
latitude_of_origin
Latitude of natural origin
8802
central_meridian
Longitude of natural origin
8805
scale_factor
Scale factor at natural origin
8806
false_easting
False easting
8807
false_northing
False northing
8811
latitude_of_center
Latitude of projection centre
8812
longitude_of_center
Longitude of projection centre
8813
azimuth
Azimuth of initial line
8814
rectified_grid_angle
Angle from Rectified to Skew Grid
8815
scale_factor
Scale factor on initial line
8816
false_easting
Easting at projection centre
8817
false_northing
Northing at projection centre
8818
pseudo_standard_parallel_1
Latitude of pseudo standard parallel
8819
scale_factor
Scale factor on pseudo standard parallel
8821
latitude_of_origin
Latitude of false origin
8822
central_meridian
Longitude of false origin
8823
standard_parallel_1, standard_parallel1
Latitude of 1st standard parallel
8824
standard_parallel_2, standard_parallel2
Latitude of 2nd standard parallel
8826
false_easting
Easting at false origin
8827
false_northing
Northing at false origin
8830
initial_longitude
Initial longitude
8831
zone_width
Zone width
8832
standard_parallel
Latitude of standard parallel
8833
longitude_of_center
Longitude of origin
 
官方文档:
https://dev.mysql.com/doc/refman/8.0/en/create-spatial-reference-system.html

文章转载自林员外聊编程,如果涉嫌侵权,请发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。

评论