空间参考系统(SRS)用于空间数据,是基于坐标的地理位置系统。A spatial reference system (SRS) for spatial data is a coordinate-based system for geographic locations.
空间参考系统有不同类型:There are different types of spatial reference systems:
投影 SRS 是将地球投影到平面上的系统,也就是平面地图。例如,在一个地球仪内部放置灯泡,光线照射到环绕地球仪的纸筒上,可以将地图投影到纸上。结果是地理参照的:每个点都对应地球上的一个位置。该平面上的坐标系统是笛卡尔坐标系,使用长度单位(米、英尺等),而不是经纬度。A projected SRS is a projection of a globe onto a flat surface; that is, a flat map. For example, a light bulb inside a globe that shines on a paper cylinder surrounding the globe projects a map onto the paper. The result is georeferenced: Each point maps to a place on the globe. The coordinate system on that plane is Cartesian using a length unit (meters, feet, and so forth), rather than degrees of longitude and latitude.
在这种情况下,地球仪是椭球体,也就是扁平的球体。地球的南北轴略短于东西轴,所以稍微扁平的球体更准确,但完美的球体计算速度更快。The globes in this case are ellipsoids; that is, flattened spheres. Earth is a bit shorter in its North-South axis than its East-West axis, so a slightly flattened sphere is more correct, but perfect spheres permit faster calculations.
地理空间参考系统(SRS)是一种非投影的 SRS,用于表示在椭球体上的经纬度(或纬度-经度)坐标,可以使用任意角度单位。A geographic SRS is a nonprojected SRS representing longitude-latitude (or latitude-longitude) coordinates on an ellipsoid, in any angular unit.
在 MySQL 中用 SRID 0 表示的 SRS 代表一个无限的平面笛卡尔平面,其轴上没有分配任何单位。与投影 SRS 不同,它不是地理参考的,也不一定表示地球。它是一个可以用于任何用途的抽象平面。SRID 0 是 MySQL 中空间数据的默认 SRID。The SRS denoted in MySQL by SRID 0 represents an infinite flat Cartesian plane with no units assigned to its axes. Unlike projected SRSs, it is not georeferenced and it does not necessarily represent Earth. It is an abstract plane that can be used for anything. SRID 0 is the default SRID for spatial data in MySQL.
MySQL 在数据字典 mysql.st_spatial_reference_systems 表中维护有关可用空间参考系统(SRS)的信息,该表可以存储投影和地理 SRS 的条目。此数据字典表是不可见的,但 SRS 条目的内容可以通过 INFORMATION_SCHEMA ST_SPATIAL_REFERENCE_SYSTEMS 表访问,该表作为 mysql.st_spatial_reference_systems 的视图实现(参见 第 28.3.36 节,“INFORMATION_SCHEMA ST_SPATIAL_REFERENCE_SYSTEMS 表”)。MySQL maintains information about available spatial reference
systems for spatial data in the data dictionary
mysql.st_spatial_reference_systems table,
which can store entries for projected and geographic SRSs. This
data dictionary table is invisible, but SRS entry contents are
available through the INFORMATION_SCHEMA
ST_SPATIAL_REFERENCE_SYSTEMS table,
implemented as a view on
mysql.st_spatial_reference_systems (see
Section 28.3.36, “The INFORMATION_SCHEMA ST_SPATIAL_REFERENCE_SYSTEMS Table”).
下面的例子显示了 SRS 条目的样子:The following example shows what an SRS entry looks like:
mysql>SELECT *FROM INFORMATION_SCHEMA.ST_SPATIAL_REFERENCE_SYSTEMSWHERE SRS_ID = 4326\G*************************** 1. row *************************** SRS_NAME: WGS 84 SRS_ID: 4326 ORGANIZATION: EPSG ORGANIZATION_COORDSYS_ID: 4326 DEFINITION: GEOGCS["WGS 84",DATUM["World Geodetic System 1984", SPHEROID["WGS 84",6378137,298.257223563, AUTHORITY["EPSG","7030"]],AUTHORITY["EPSG","6326"]], PRIMEM["Greenwich",0,AUTHORITY["EPSG","8901"]], UNIT["degree",0.017453292519943278, AUTHORITY["EPSG","9122"]], AXIS["Lat",NORTH],AXIS["Long",EAST], AUTHORITY["EPSG","4326"]] DESCRIPTION:
此条目描述了用于 GPS 系统的空间参考系统(SRS)。其名称为 (SRS_NAME) WGS 84,ID 为 (SRS_ID) 4326,这是 欧洲石油勘测组(EPSG)使用的 ID。This entry describes the SRS used for GPS systems. It has the
name (SRS_NAME) WGS 84 and the ID
(SRS_ID) 4326, which is the ID used by the
European Petroleum Survey
Group (EPSG).
DEFINITION 列中的 SRS 定义是 WKT 值,表示方式遵循 开放地理空间联盟 文档 OGC 12-063r5 中的规定。SRS definitions in the DEFINITION column are
WKT values, represented as specified in the
Open Geospatial
Consortium document
OGC
12-063r5.
SRS_ID 的值表示与几何值的 SRID 相同类型的值,或者作为 SRID 参数传递给空间函数。SRID 0(无单位的笛卡尔平面)是特殊的。它始终是合法的空间参考系统 ID,并且可以用于任何依赖 SRID 值的空间数据计算。SRS_ID values represent the same kind of
values as the SRID of geometry values or passed as the SRID
argument to spatial functions. SRID 0 (the unitless Cartesian
plane) is special. It is always a legal spatial reference system
ID and can be used in any computations on spatial data that
depend on SRID values.
对于多个几何值的计算,所有值必须具有相同的 SRID,否则会发生错误。For computations on multiple geometry values, all values must have the same SRID or an error occurs.
当 GIS 函数需要定义时,会按需解析 SRS 定义。解析后的定义会存储在数据字典缓存中,以便重用,并避免为每个需要 SRS 信息的语句产生解析开销。SRS definition parsing occurs on demand when definitions are needed by GIS functions. Parsed definitions are stored in the data dictionary cache to enable reuse and avoid incurring parsing overhead for every statement that needs SRS information.
为了能够操作存储在数据字典中的 SRS 条目,MySQL 提供了以下 SQL 语句:To enable manipulation of SRS entries stored in the data dictionary, MySQL provides these SQL statements:
CREATE SPATIAL REFERENCE SYSTEM:请参见 第 15.1.19 节,“CREATE SPATIAL REFERENCE SYSTEM 语句”。此语句的描述包括关于 SRS 组件的更多信息。CREATE SPATIAL REFERENCE SYSTEM: See Section 15.1.19, “CREATE SPATIAL REFERENCE SYSTEM Statement”. The description for this statement includes additional information about SRS components.DROP SPATIAL REFERENCE SYSTEM:请参见 第 15.1.31 节,“DROP SPATIAL REFERENCE SYSTEM 语句”。DROP SPATIAL REFERENCE SYSTEM: See Section 15.1.31, “DROP SPATIAL REFERENCE SYSTEM Statement”.