I have schema for a table called "places" that looks like this with about 6000 rows:
name | county| long | lat | the_geom | id Tuthilltown | Ulster | -74.1789 | 41.6843271513 | 0101000020E61000004850FC18738B52C0974C370898D74440 | 1
the_geom was created following a tutorial from the lat/long of each places like so:
UPDATE places SET the_geom = ST_GeomFromText('POINT(' || long || ' ' || lat || ')',4326);
These are places scattered across the state of NY.
I am currently in the far north, but when I attempt to search for my nearest neighbor, it returns points in the far east e.g. Montauk.
The basic query for nearest neighbor is supposed to look like this:
SELECT name, lat, long FROM places ORDER BY the_geom <-> st_setsrid(st_makepoint( "my coordinates" ),4326) LIMIT 1;
My coordinates are not stored but rather given on the fly from my phone.
To fix this, I have thus far attempted to create an index on this table, but I am not sure how to search against the index or if it would give me the proper results.
Is this an issue with psql or is it my query (more likely)?