Search code examples
geolocationoracle-spatial

Geo Fence: Find number of features (points/lines/polygons) inside a polygon using oracle spatial


How do i write a SQL query (using Oracle Spatial) to find the number of features available inside a polygon (geofence);

The features could be either points, lines or a polygon itself.

Thanks.


Solution

  • Try that statement:

    select count(*) from geometry_table t where SDO_RELATE(t.geom_column, geofence, 'mask=INSIDE') = 'TRUE'
    /
    

    It is mandetory that the first parameter of SDO_RELATE is the geometry column with a spatial index.