WL#9435: Axis order in WKB parsing functions
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_GeomFromWKB, ST_GeometryFromWKB, ST_PointFromWKB, ST_LineFromWKB, ST_LineStringFromWKB, ST_PolyFromWKB, ST_PolygonFromWKB, ST_GeomCollFromWKB, ST_GeometryCollectionFromWKB, ST_MPointFromWKB, ST_MultiPointFromWKB, ST_MLineFromWKB, ST_MultiLineStringFromWKB, ST_MPolyFromWKB and ST_MultiPolygonFromWKB 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 WKB parsing functions:
<geometry> = ST_GeomCollFromWKB(<wkb string>, <srid>, <options string>)
<geometry> = ST_GeometryCollectionFromWKB(<wkb string>, <srid>, <options string>)
<geometry> = ST_GeometryFromWKB(<wkb string>, <srid>, <options string>)
<geometry> = ST_GeomFromWKB(<wkb string>, <srid>, <options string>)
<geometry> = ST_LineFromWKB(<wkb string>, <srid>, <options string>)
<geometry> = ST_LinestringFromWKB(<wkb string>, <srid>, <options string>)
<geometry> = ST_MLineFromWKB(<wkb string>, <srid>, <options string>)
<geometry> = ST_MPointFromWKB(<wkb string>, <srid>, <options string>)
<geometry> = ST_MPolyFromWKB(<wkb string>, <srid>, <options string>)
<geometry> = ST_MultiLinestringFromWKB(<wkb string>, <srid>, <options string>)
<geometry> = ST_MultiPointFromWKB(<wkb string>, <srid>, <options string>)
<geometry> = ST_MultiPolygonFromWKB(<wkb string>, <srid>, <options string>)
<geometry> = ST_PointFromWKB(<wkb string>, <srid>, <options string>)
<geometry> = ST_PolyFromWKB(<wkb string>, <srid>, <options string>)
<geometry> = ST_PolygonFromWKB(<wkb 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 WKB parsing functions use the same Item_func_geometry_from_wkb item, with accepted geometry type as a parameter.
Extend Create_func_geometry_from_wkb and Item_func_geometry_from_wkb 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.
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.