I have a PostgreSQL table called "routes" in PostgreSQL with below structure and data. I want a query where i will provide the coordinate(Latitude and Longitude) and it will return a route closest to the startpoint to endpoint of the route. for example, (40.690503, -73.840581) falls along Atlantic Route which means the query will return the first rows
NB: A route is a path or way between startpoint and endpoint.
Below is the table structure and Sample Data
#Table Structure
CREATE TABLE public.route
(
name text NOT NULL,
startpoint point NOT NULL,
endpoint point NOT NULL,
id integer NOT NULL DEFAULT nextval('route_id_seq'::regclass),
CONSTRAINT route_pkey PRIMARY KEY (id)
)
WITH (
OIDS=FALSE
);
#Table Data
INSERT INTO public.route (name, startpoint, endpoint, id) VALUES ('Atlantic', (-73.848838,40.688299), (-73.824869,40.694831), 1);
INSERT INTO public.route (name, startpoint, endpoint, id) VALUES ('Guy Brewer', (-73.7991,40.708257), (-73.78543,40.688334), 2);