Details
Description
With Oracle there are two functions to get the MBR. From the Oracle spatial docs:
The SDO_AGGR_MBR function, documented in Chapter 12, also returns the MBR of
geometries. The SDO_TUNE.EXTENT_OF function has better performance than the
SDO_AGGR_MBR function if the data is non-geodetic and if a spatial index is defined
on the geometry column; however, the SDO_TUNE.EXTENT_OF function is limited to
two-dimensional geometries, whereas the SDO_AGGR_MBR function is not. In
addition, the SDO_TUNE.EXTENT_OF function computes the extent for all
geometries in a table; by contrast, the SDO_AGGR_MBR function can operate on
subsets of rows.
The SDO_TUNE.EXTENT_OF function returns NULL if the data is inconsistent.
If a non-geodetic spatial index is used, this function may return an approximate MBR
that encloses the largest extent of data stored in the index, even if data was
subsequently deleted. This can occur because the function extracts MBR information
from a non-geodetic spatial index, if one exists.
SDO_AGGR_MBR will do a full scan of the table, we need to avoid it when possible.
This means we need to determine if the srid is considered geodetic by oracle
(look into the MDSYS.GEODETIC_SRIDS view) and then decide which function to use.
So we need the NATIVE_SRID and a connection to run the query.