I’m working with postgis and rails for the first time in a long time, and am having a terrible time with documentation on how to do some simple things. I want to:
- create a table with a list of lat/longs with srid of 4326 in a column called “start”
- search that column for all points in a certain radius from a specified lat/long
My sticking points:
- I’m wondering what the native data type in postgres should be. There is nothing I can find that is reliable. How should my migration look? I’ve got something tentative working with
t.st_point :start, geographic: true
- How to do this search? That is, what postgis function will be most efficient? I want the radius to be in meters or kilometers. I’m looking at ST_DWithin, but it doesn’t seem to find points very close. How do I figure out the units its returning in?
- I have about 16 million points in the table so what index type should use to speed up this search?
Any help would be much appreciated. This should be an easy task but it seems like these projects have atrophied a bit since I last visited them.
2