13.1.19 CREATE SPATIAL REFERENCE SYSTEM Statement语句

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

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 OR REPLACE nor IF NOT EXISTS is specified, an error occurs if an SRS definition with the given srid value already exists.SRID值必须是唯一的,因此,如果未指定OR REPLACEIF 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位无符号整数的范围内,并有以下限制:

Attributes for the statement must satisfy these conditions:语句的属性必须满足以下条件:

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将以下更改合并到规范中:

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 CodeProjection Name投影名称Mandatory Parameters (EPSG Codes)强制性参数(EPSG代码)
1024Popular Visualisation Pseudo Mercator流行的可视化伪墨卡托8801, 8802, 8806, 8807
1027Lambert Azimuthal Equal Area (Spherical)兰伯特方位相等面积(球形)8801, 8802, 8806, 8807
1028Equidistant Cylindrical等距圆柱8823, 8802, 8806, 8807
1029Equidistant Cylindrical (Spherical)等距圆柱形(球形)8823, 8802, 8806, 8807
1041Krovak (North Orientated)克罗瓦克(北向)8811, 8833, 1036, 8818, 8819, 8806, 8807
1042Krovak Modified克罗瓦克改良8811, 8833, 1036, 8818, 8819, 8806, 8807, 8617, 8618, 1026, 1027, 1028, 1029, 1030, 1031, 1032, 1033, 1034, 1035
1043Krovak Modified (North Orientated)Krovak改装(北向)8811, 8833, 1036, 8818, 8819, 8806, 8807, 8617, 8618, 1026, 1027, 1028, 1029, 1030, 1031, 1032, 1033, 1034, 1035
1051Lambert Conic Conformal (2SP Michigan)Lambert圆锥共形(2SP密歇根)8821, 8822, 8823, 8824, 8826, 8827, 1038
1052Colombia Urban哥伦比亚城市8801, 8802, 8806, 8807, 1039
9801Lambert Conic Conformal (1SP)8801, 8802, 8805, 8806, 8807
9802Lambert Conic Conformal (2SP)8821, 8822, 8823, 8824, 8826, 8827
9803Lambert Conic Conformal (2SP Belgium)8821, 8822, 8823, 8824, 8826, 8827
9804Mercator (variant A)墨卡托(变型A)8801, 8802, 8805, 8806, 8807
9805Mercator (variant B)墨卡托(变型B)8823, 8802, 8806, 8807
9806Cassini-Soldner卡西尼索尔德纳8801, 8802, 8806, 8807
9807Transverse Mercator横轴墨卡托投影8801, 8802, 8805, 8806, 8807
9808Transverse Mercator (South Orientated)8801, 8802, 8805, 8806, 8807
9809Oblique Stereographic8801, 8802, 8805, 8806, 8807
9810Polar Stereographic (variant A)8801, 8802, 8805, 8806, 8807
9811New Zealand Map Grid8801, 8802, 8806, 8807
9812Hotine Oblique Mercator (variant A)8811, 8812, 8813, 8814, 8815, 8806, 8807
9813Laborde Oblique Mercator8811, 8812, 8813, 8815, 8806, 8807
9815Hotine Oblique Mercator (variant B)8811, 8812, 8813, 8814, 8815, 8816, 8817
9816Tunisia Mining Grid8821, 8822, 8826, 8827
9817Lambert Conic Near-Conformal8801, 8802, 8805, 8806, 8807
9818American Polyconic8801, 8802, 8806, 8807
9819Krovak8811, 8833, 1036, 8818, 8819, 8806, 8807
9820Lambert Azimuthal Equal Area8801, 8802, 8806, 8807
9822Albers Equal Area8821, 8822, 8823, 8824, 8826, 8827
9824Transverse Mercator Zoned Grid System8801, 8830, 8831, 8805, 8806, 8807
9826Lambert Conic Conformal (West Orientated)8801, 8802, 8805, 8806, 8807
9828Bonne (South Orientated)8801, 8802, 8806, 8807
9829Polar Stereographic (variant B)8832, 8833, 8806, 8807
9830Polar Stereographic (variant C)8832, 8833, 8826, 8827
9831Guam Projection8801, 8802, 8806, 8807
9832Modified Azimuthal Equidistant8801, 8802, 8806, 8807
9833Hyperbolic Cassini-Soldner8801, 8802, 8806, 8807
9834Lambert Cylindrical Equal Area (Spherical)8823, 8802, 8806, 8807
9835Lambert Cylindrical Equal Area8823, 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 CodeFallback Name (Recognized by MySQL)回退名称(由MySQL识别)EPSG Name
1026c1C1
1027c2C2
1028c3C3
1029c4C4
1030c5C5
1031c6C6
1032c7C7
1033c8C8
1034c9C9
1035c10C10
1036azimuthCo-latitude of cone axis
1038ellipsoid_scale_factorEllipsoid scaling factor
1039projection_plane_height_at_originProjection plane origin height
8617evaluation_point_ordinate_1Ordinate 1 of evaluation point
8618evaluation_point_ordinate_2Ordinate 2 of evaluation point
8801latitude_of_originLatitude of natural origin
8802central_meridianLongitude of natural origin
8805scale_factorScale factor at natural origin
8806false_eastingFalse easting
8807false_northingFalse northing
8811latitude_of_centerLatitude of projection centre
8812longitude_of_centerLongitude of projection centre
8813azimuthAzimuth of initial line
8814rectified_grid_angleAngle from Rectified to Skew Grid
8815scale_factorScale factor on initial line
8816false_eastingEasting at projection centre
8817false_northingNorthing at projection centre
8818pseudo_standard_parallel_1Latitude of pseudo standard parallel
8819scale_factorScale factor on pseudo standard parallel
8821latitude_of_originLatitude of false origin
8822central_meridianLongitude of false origin
8823standard_parallel_1, standard_parallel1Latitude of 1st standard parallel
8824standard_parallel_2, standard_parallel2Latitude of 2nd standard parallel
8826false_eastingEasting at false origin
8827false_northingNorthing at false origin
8830initial_longitudeInitial longitude
8831zone_widthZone width
8832standard_parallelLatitude of standard parallel
8833longitude_of_centerLongitude of origin