CREATE OR REPLACE SPATIAL REFERENCE SYSTEMsrid
srs_attribute
... CREATE SPATIAL REFERENCE SYSTEM [IF NOT EXISTS]srid
srs_attribute
...srs_attribute
: { NAME 'srs_name
' | DEFINITION 'definition
' | ORGANIZATION 'org_name
' IDENTIFIED BYorg_id
| DESCRIPTION 'description
' }srid
,org_id
:32-bit unsigned integer
This statement creates a spatial reference system (SRS) definition and stores it in the data dictionary. 此语句创建空间参考系(SRS)定义并将其存储在数据字典中。It requires the 它需要SUPER
privilege. SUPER
特权。The resulting data dictionary entry can be inspected using the 生成的数据字典条目可以使用INFORMATION_SCHEMA
ST_SPATIAL_REFERENCE_SYSTEMS
table.INFORMATION_SCHEMA
ST_SPATIAL_REFERENCE_SYSTEMS
表进行检查。
SRID values must be unique, so if neither SRID值必须是唯一的,因此,如果未指定OR REPLACE
nor IF NOT EXISTS
is specified, an error occurs if an SRS definition with the given srid
value already exists.OR REPLACE
或IF NOT EXISTS
,则如果具有给定SRID值的SRS定义已存在,则会发生错误。
With 使用CREATE OR REPLACE
syntax, any existing SRS definition with the same SRID value is replaced, unless the SRID value is used by some column in an existing table. CREATE OR REPLACE
语法,将替换具有相同SRID值的任何现有SRS定义,除非SRID值由现有表中的某个列使用。In that case, an error occurs. 在这种情况下,会发生错误。For example:例如:
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.
To identify which column or columns use the SRID, use this query, replacing 4326 with the SRID of the definition you are trying to create:要确定哪些列使用SRID,请使用此查询,将4326替换为您尝试创建的定义的SRID:
SELECT * FROM INFORMATION_SCHEMA.ST_GEOMETRY_COLUMNS WHERE SRS_ID=4326;
With 使用CREATE ... IF NOT EXISTS
syntax, any existing SRS definition with the same SRID value causes the new definition to be ignored and a warning occurs.CREATE ... IF NOT EXISTS
语法,则具有相同SRID值的任何现有SRS定义都会导致忽略新定义并发出警告。
SRID values must be in the range of 32-bit unsigned integers, with these restrictions:SRID值必须在32位无符号整数的范围内,并有以下限制:
SRID 0 is a valid SRID but cannot be used with SRID 0是有效的SRID,但不能用于CREATE SPATIAL REFERENCE SYSTEM
.CREATE SPATIAL REFERENCE SYSTEM
(创建空间参考系)。
If the value is in a reserved SRID range, a warning occurs. 如果该值在保留SRID范围内,则会出现警告。Reserved ranges are [0, 32767] (reserved by EPSG), [60,000,000, 69,999,999] (reserved by EPSG), and [2,000,000,000, 2,147,483,647] (reserved by MySQL). 保留范围为[0, 32767](由EPSG保留)、[60,000,000, 69,999,999](由EPSG保留)和[2,000,000,000, 2,147,483,647](由MySQL保留)。EPSG stands for the European Petroleum Survey Group.EPSG代表欧洲石油调查集团。
Users should not create SRSs with SRIDs in the reserved ranges. 用户不应使用保留范围内的SRID创建SRS。Doing so runs the risk of the SRIDs conflicting with future SRS definitions distributed with MySQL, with the result that the new system-provided SRSs are not installed for MySQL upgrades or that the user-defined SRSs are overwritten.这样做可能会导致SRID与将来随MySQL分发的SRS定义发生冲突,从而导致新的系统提供的SRS没有安装用于MySQL升级,或者用户定义的SRS被覆盖。
Attributes for the statement must satisfy these conditions:语句的属性必须满足以下条件:
Attributes can be given in any order, but no attribute can be given more than once.属性可以按任何顺序给定,但不能多次给定属性。
The NAME
and DEFINITION
attributes are mandatory.NAME
和DEFINITION
属性是必需的。
The NAME
srs_name
attribute value must be unique. NAME
srs_name
值必须是唯一的。The combination of the ORGANIZATION
org_name
and org_id
attribute values must be unique.ORGANIZATION
org_name
和org_id
属性值的组合必须是唯一的。
The NAME
srs_name
attribute value and ORGANIZATION
org_name
attribute value cannot be empty or begin or end with whitespace.NAME
srs_name
属性值和ORGANIZATION
org_name
属性值不能为空,也不能以空格开头或结尾。
String values in attribute specifications cannot contain control characters, including newline.属性规范中的字符串值不能包含控制字符,包括换行符。
The following table shows the maximum lengths for string attribute values.下表显示了字符串属性值的最大长度。
Table 13.6 CREATE SPATIAL REFERENCE SYSTEM Attribute Lengths创建空间参照系属性长度
NAME | 80 |
DEFINITION | 4096 |
ORGANIZATION | 256 |
DESCRIPTION | 2048 |
Here is an example 下面是CREATE SPATIAL REFERENCE SYSTEM
statement. CREATE SPATIAL REFERENCE SYSTEM
语句的示例。The DEFINITION
value is reformatted across multiple lines for readability. DEFINITION
值跨多行重新格式化以提高可读性。(For the statement to be legal, the value actually must be given on a single line.)(为了使语句合法,实际上必须在一行中给出值。)
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"]]';
The grammar for SRS definitions is based on the grammar defined in OpenGIS Implementation Specification: Coordinate Transformation Services, Revision 1.00, OGC 01-009, January 12, 2001, Section 7.2. SRS定义的语法基于《OpenGIS实现规范:坐标转换服务》,修订版1.00,OGC 01-009,2001年1月12日,第7.2节中定义的语法。This specification is available at http://www.opengeospatial.org/standards/ct.本规范可从以下网址获得:http://www.opengeospatial.org/standards/ct。
MySQL incorporates these changes to the specification:MySQL将以下更改合并到规范中:
Only the 只有<horz cs>
production rule is implemented (that is, geographic and projected SRSs).<horz cs>
实现了生产规则(即地理和预计SRS)。
There is an optional, nonstandard 有一个可选的非标准<authority>
clause for <parameter>
. <authority>
子句用于<parameter>
。This makes it possible to recognize projection parameters by authority instead of name.这使得可以通过权限而不是名称来识别投影参数。
The specification does not make 本规范未规定AXIS
clauses mandatory in GEOGCS
spatial reference system definitions. GEOGCS
空间参考系统定义中必须包含AXIS
子句。However, if there are no 但是,如果没有AXIS
clauses, MySQL cannot determine whether a definition has axes in latitude-longitude order or longitude-latitude order. AXIS
子句,MySQL无法确定定义中的轴是按经纬度顺序还是按经纬度顺序。MySQL enforces the nonstandard requirement that each MySQL强制执行非标准要求,即每个GEOGCS
definition must include two AXIS
clauses. GEOGCS
定义必须包含两个AXIS
子句。One must be 一个必须是NORTH
or SOUTH
, and the other EAST
or WEST
. NORTH
或SOUTH
,另一个必须是EAST
或WEST
。The AXIS
clause order determines whether the definition has axes in latitude-longitude order or longitude-latitude order.AXIS
子句顺序确定定义的轴是按经纬度顺序还是按经纬度顺序。
SRS definitions may not contain newlines.SRS定义不能包含换行符。
If an SRS definition specifies an authority code for the projection (which is recommended), an error occurs if the definition is missing mandatory parameters. 如果SRS定义指定了投影的授权代码(推荐),则如果该定义缺少强制参数,则会发生错误。In this case, the error message indicates what the problem is. 在这种情况下,错误消息指示问题所在。The projection methods and mandatory parameters that MySQL supports are shown in Table 13.7, “Supported Spatial Reference System Projection Methods” and Table 13.8, “Spatial Reference System Projection Parameters”.MySQL支持的投影方法和强制参数如表13.7“支持的空间参考系统投影方法”和表13.8“空间参考系统投影参数”所示。
For additional information about writing SRS definitions for MySQL, see Geographic Spatial Reference Systems in MySQL 8.0 and Projected Spatial Reference Systems in MySQL 8.0有关为MySQL编写SRS定义的更多信息,请参阅MySQL 8.0中的地理空间参考系统和MySQL 8.0中的投影空间参考系统。
The following table shows the projection methods that MySQL supports. 下表显示了MySQL支持的投影方法。MySQL permits unknown projection methods but cannot check the defintion for mandatory paramters and cannot convert spatial data to or from an unknown projection. MySQL允许未知投影方法,但无法检查强制参数的定义,也无法将空间数据转换为未知投影或从未知投影转换空间数据。For detailed explanations of how each projection works, including formulas, see EPSG Guidance Note 7-2.有关每个投影如何工作的详细解释,包括公式,请参阅EPSG指南注释7-2。
Table 13.7 Supported Spatial Reference System Projection Methods支持的空间参考系投影方法
EPSG Code | ||
---|---|---|
1024 | 8801, 8802, 8806, 8807 | |
1027 | 8801, 8802, 8806, 8807 | |
1028 | 8823, 8802, 8806, 8807 | |
1029 | 8823, 8802, 8806, 8807 | |
1041 | 8811, 8833, 1036, 8818, 8819, 8806, 8807 | |
1042 | 8811, 8833, 1036, 8818, 8819, 8806, 8807, 8617, 8618, 1026, 1027, 1028, 1029, 1030, 1031, 1032, 1033, 1034, 1035 | |
1043 | 8811, 8833, 1036, 8818, 8819, 8806, 8807, 8617, 8618, 1026, 1027, 1028, 1029, 1030, 1031, 1032, 1033, 1034, 1035 | |
1051 | 8821, 8822, 8823, 8824, 8826, 8827, 1038 | |
1052 | 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 | 8801, 8802, 8805, 8806, 8807 | |
9805 | 8823, 8802, 8806, 8807 | |
9806 | 8801, 8802, 8806, 8807 | |
9807 | 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 |
The following table shows the projection parameters that MySQL recognizes. 下表显示了MySQL可以识别的投影参数。Recognition occurs primarily by authority code. 识别主要通过权限代码进行。If there is no authority code, MySQL falls back to case-insensitive string matching on the parameter name. 如果没有权限代码,MySQL将返回参数名上不区分大小写的字符串匹配。For details about each parameter, look it up by code in the EPSG Online Registry.有关每个参数的详细信息,请在EPSG Online Registry中通过代码进行查找。
Table 13.8 Spatial Reference System Projection Parameters空间参考系投影参数
EPSG Code | EPSG Name | |
---|---|---|
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 |