Hello. I have a query on my table which uses a spatial index to include only polygons that contain a point. This works fine but I’ve recently added a second geometry column storing a point geometry which I’ve also created a spatial index for.
Is there a way to force my query to use the polygon index?
Here is my query and apologies for any poor layout:
--Return 1 if given point is in a land polygon or 0 otherwise
SELECT CASE WHEN EXISTS (
SELECT 1
FROM spt_LandPolygons AS l
WHERE l.ROWID IN (
SELECT ROWID FROM SpatialIndex WHERE (
( f_table_name = 'spt_LandPolygons' )
AND ( search_frame = MakePoint( ?,? ) )
)
)
AND ST_Contains( l.lpolygon , MakePoint( ?,? ))
)
THEN 1 ELSE 0 END AS PointInside;
Best, Chris