I have PostGIS table with a geometry column of multipolygons, SRID 4269.
Google maps returns all results in SRID 4326. So you need to first either.
ST_Transform()
your input coordinates to 4326 on the table.- Create an index on the result of the
ST_Transform
.
Let's assume the latter.
CREATE INDEX ON myTable USING GIST (ST_Transform(myGeom, 4326));
VACUUM ANALYZE myTable;
Then what you can do is, is build a bounding box with ST_MakeEnvelope
, and run the query. The end query will look something like,
SELECT *
FROM myTable
WHERE ST_MakeEnvelope(xmin,ymin,xmax,ymax) && ST_TranslateST_Transform(myTable.geom,4326);