I'm developing a website where I want to test which polygons from a shapefile intersect a given rectangle. Using PHP, I thought about using
exec() function, calling a GDAL program, like
ogrinfo. However, the following command line
ogrinfo -spat x0 y0 x1 y1 my_shape_file.shp
is not working how I thought it should. It always returns the name of the layer (after "Open of ... using driver 'ESRI Shapefile' successful."), despite the polygon is inside the given rectangle (x0,y0,x1,y1) or not. Anyway, I want the polygons intersecting the rectangle, not the whole shapefile. What is wrong in my usage? The instructions say nothing! (Of course I used actual coordinates instead of x0,y0...)
EDIT: I wasn't using the layer name (as returned from the previous command) after the shapefile name:
ogrinfo -spat x0 y0 x1 y1 my_shape_file.shp layer_name
Now I only need to know if PHP extensions are preferred over external commands.