We have a restaurant table that has lat-long data for each row.
We need to write a query that performs a search to find all restaurants within the prov
You may want to create a SPATIAL index on your table to make the searches faster.
To do this, add a POINT column to your table:
ALTER TABLE restaurant ADD coords POINT NOT NULL;
CREATE SPATIAL INDEX sx_restaurant_coords ON restaurant (coords);
SELECT *
FROM restaurant
WHERE MBRContains(coords, LineString(Point(583734 - 1609, 4507223 - 1609), Point(583734 + 1609, 4507223 + 1609))
AND GLength(LineString(Point(583734, 4507223), coords)) <= 1609
You should store coords as UTM coordinates within a single zone.