WL#9436: ST_SwapXY

Affects: Server-8.0   —   Status: Complete   —   Priority: Medium

When introducing geography support, data may be in latitude-longitude or longitude-latitude format. MySQL will interpret stored geometries as if they are in longitude-latitude format, i.e., the first coordinate is longitude, the second is latitude.

Users may have existing data that assumes the wrong axis order for geographic data. This WL adds a function ST_SwapXY that swaps all coordinate pairs in a geometry:

= ST_SwapXY()

User Documentation

F-1
If the function argument is NULL, the function MUST return NULL.
F-2
If the function argument is not a well-formed geometry value, the function MUST raise ER_GIS_INVALID_DATA.
F-3
If the function argument is a well-formed geometry value, the function MUST return a geometry of the same type with all X and Y coordinates swapped.
NF-1
The function MUST be non-nullable if the argument is non-nullable.
I-1
No new files.
I-2
Interface SQL02 is extended with one new function:
= ST_SwapXY()
I-3
No new commands.
I-4
No new tools.
I-5
No impact on existing functionality.
I-6
No new errors.
I-7
No new warnings.

Add a new item, Item_func_swap_xy, and a Create_func_swap_xy class for a one-argument function.

When evaluating the function, return a geometry where the X and Y coordinates of all coordinate pairs have been swapped.