Answer the question
In order to leave comments, you need to log in
How to correctly store coordinates in postgresql and then subtract the distance from the user to a specific object?
I found the Postgis
extension , added the position
column in the database and overwrote all the coordinates:
UPDATE product_locations SET
"position" = ST_SetSRID(ST_MakePoint(longitude, latitude),4326);
SELECT
*,
ST_Distance ( position::geography, ST_GeographyFromText('SRID=4326;POINT(40.5774008 -73.9647576)') ) / 1000 AS distance
FROM
product_locations
ORDER BY
id asc
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question