WL#9434: Axis order in WKT parsing functions

Affects: Server-8.0   —   Status: Complete

Import and export functions have to take axis order into consideration. Some spatial reference systems are latitude-longitude, while other are longitude-latitude.

This WL modifies ST_GeomFromText, ST_GeometryFromText, ST_PointFromText, ST_LineFromText, ST_LineStringFromText, ST_PolyFromText, ST_PolygonFromText, ST_GeomCollFromTxt, ST_GeomCollFromText, ST_GeometryCollectionFromText, ST_MPointFromText, ST_MultiPointFromText, ST_MLineFromText, ST_MultiLineStringFromText, ST_MPolyFromText and ST_MultiPolygonFromText to accept coordinates in the order specified in the spatial reference system. An optional options argument and an option argument value to override the default and specify a particular axis order is also added.

User Documentation

F-1
If no options argument is specified, the functions MUST interpret coordinates as in the order specified in the spatial reference system definition.
F-2
If an axis order is specified, the functions MUST interpret coordinates as in that axis order.
F-3
If the options argument contains an invalid option key, the functions MUST raise ER_INVALID_OPTION_KEY.
F-4
If the options argument contains an invalid option value, the functions MUST raise ER_INVALID_OPTION_VALUE.
F-5
If the options argument is an empty string or contains only whitespace, the functions MUST use the default axis order.
F-6
If the options argument is NULL, the functions MUST return NULL.
F-7
If the options argument contains the same option key more than once, the functions MUST raise ER_DUPLICATE_OPTION_KEY.
F-8
If the options argument is badly formed, the functions MUST raise ER_INVALID_OPTION_KEY_VALUE_PAIR, ER_INVALID_OPTION_START_CHARACTER, ER_INVALID_OPTION_END_CHARACTER or ER_INVALID_OPTION_CHARACTERS.
F-9
If the geometry is in a projected spatial reference system (or SRID 0), the coordinates are interpreted as in the order they appear in the geometry.
F-10
If the geometry is in an undefined spatial reference system, the coordinates are interpreted as in the order they appear in the input. The functions MUST raise ER_WARN_SRS_NOT_FOUND_AXIS_ORDER.
F-11
The options argument (both option keys and values) MUST be case insensitive.
NF-1
The functions MUST be non-nullable if all arguments are non-nullable.
I-1
No new files.
I-2
Interface SQL02 is extended with new three-parameter forms of WKT parsing functions:
<geometry> = ST_GeomCollFromText(<wkt string>, <srid>, <options string>)
<geometry> = ST_GeomCollFromTxt(<wkt string>, <srid>, <options string>)
<geometry> = ST_GeometryCollectionFromText(<wkt string>, <srid>, <options string>)
<geometry> = ST_GeometryFromText(<wkt string>, <srid>, <options string>)
<geometry> = ST_GeomFromText(<wkt string>, <srid>, <options string>)
<geometry> = ST_LineFromText(<wkt string>, <srid>, <options string>)
<geometry> = ST_LinestringFromText(<wkt string>, <srid>, <options string>)
<geometry> = ST_MLineFromText(<wkt string>, <srid>, <options string>)
<geometry> = ST_MPointFromText(<wkt string>, <srid>, <options string>)
<geometry> = ST_MPolyFromText(<wkt string>, <srid>, <options string>)
<geometry> = ST_MultiLinestringFromText(<wkt string>, <srid>, <options string>)
<geometry> = ST_MultiPointFromText(<wkt string>, <srid>, <options string>)
<geometry> = ST_MultiPolygonFromText(<wkt string>, <srid>, <options string>)
<geometry> = ST_PointFromText(<wkt string>, <srid>, <options string>)
<geometry> = ST_PolyFromText(<wkt string>, <srid>, <options string>)
<geometry> = ST_PolygonFromText(<wkt string>, <srid>, <options string>)
I-3
No new commands.
I-4
No new tools.
I-5
Changes to existing functionality: Coordinates of geometries in geographic SRSs will be stored in longitude-latitude order. Before this WL, they were stored in the order they appeared in the input data.
I-6
No new errors.
I-7
No new warnings.

Overall design

All WKT parsing functions use the same Item_func_geometry_from_text item, with accepted geometry type as a parameter.

Extend Create_func_geometry_from_text and Item_func_geometry_from_text to allow an extra optional string parameter.

When evaluating the function, interpret coordinates as in the specified axis order, or if no order is specified, in the order specified by the spatial reference system. In the internal geometry representation, longitude is always stored in the first (X) coordinate, and latitude is stored in the second (Y) coordinate.

Options argument

The options argument is a string and will be parsed using the options parser defined in WL#9432.

The only valid key is "axis-order". The valid values are "long-lat", "lat-long" and "srid-defined". "srid-defined" is the default if no option string is specified.