I've already checked all previous similar question. I'm asking again just because I need to be more specific by describing the database structure I am working with.
CREATE TABLE stores (name varchar, geom geometry); CREATE INDEX geoid ON stores USING gist((geom::geography)) INSERT INTO stores VALUES ('Store name', 'ST_SetSRID(ST_MakePoint(16.123, 51.321), 4326)') /* where 16.123 is longitude and 51.321 is latitude */
Until now we only perform search-in-radius (circle) queries, with the following sintax
SELECT ST_X(geom) as longitude, ST_Y(geom) as latitude FROM stores WHERE ST_DWithin("stores"."geom", ST_MakePoint(15, 50)::geography, 10000) /* where 15 is longitude, 50 is latitude and 10000 is the radius in meters */
As stated in the title, now we also need to perform some query to get all stores within a bounding box, starting from lat_north, lng_east, lat_south, lng_west.
Should I use the ST_DWithin function again? Maybe with the ST_MakeEnvelope. I'm also confused by the use of the geography cast in the "radius" query.