Search code examples
oraclegeospatialoracle-spatial

Oracle Spatial: I can't get sdo_inside to work


I'm trying to build a map tile server for Oracle Spatial Database. I need to filter the query with bounding boxes so that I can get individual tile data.

I convert the bounding box data into WKT and I'm trying to use SDO_UTILS.FROM_WKTGEOMETRY with SDO_INSIDE so that I can get tile data. Here is my resulting query:

select SDO_UTIL.TO_WKTGEOMETRY(SDO_UTIL.SIMPLIFY(sdo_cs.transform(SHAPE, sdo_cs.map_epsg_srid_to_oracle(4326)), 6, 0.000001)) as GEOM,
column_1,
column_2,
column_3
from tablename 
where SDO_INSIDE(SHAPE, SDO_UTIL.FROM_WKTGEOMETRY(TO_CHAR('POLYGON ((28.125 40.979898069620155, 30.9375 40.979898069620155, 30.9375 43.068887774169625, 28.125 43.068887774169625, 28.125 40.979898069620155))'))) = 'TRUE'

This query says:

ORA-29902: Runtime error on ODCIIndexStart()
ORA-13208: [window SRID does not match layer SRID]
ORA-06512: location "MDSYS.SDO_INDEX_METHOD_10I", line 333

Then I tried sdo_cs.transform on both the column SHAPE and sdo_util.from_wktgeometry geometries in the same way as the first line of the query and it receives another error.

EDIT: I checked out the question that might contain the answer, I applied the transform and what I got is:

ORA-13226: interface not supported without a spatial index
ORA-06512: location "MDSYS.MD",  line 1723
ORA-06512: location "MDSYS.MDERR",  line 8
ORA-06512: location "MDSYS.SDO_3GL",  line 88

Solution

  • I did:

    SDO_INSIDE(SDO_UTIL.FROM_WKTGEOMETRY(SDO_UTIL.TO_WKTGEOMETRY(SHAPE)), SDO_UTIL.FROM_WKTGEOMETRY('INSERT LARGE WKT TEXT HERE'))
    

    And everything started working.