First Time here. Anyway, I have a database that I want to use to store user locations. I want to be able to get all the users with in say 15 miles. How do I do this. I'm using PostGIS 2.1. My SQL query is SELECT * FROM locations WHERE ST_DWithin(usercoord, ST_GeomFromText('POINT(%s %s)', 4326), %s) AND NAME!=%s; usercoord is he geometry table with a SRID of 4326. I tried I'm using Python to execute the query. %s is just a place holder. The third %s is for the distance. I tried reading but I got even more confused. should the distance be in radians or should the distance be in km? I tried making it into radians. However, it didnt look like it worked. I put in 3959 in distance and got all of the users in then table. I have Users in Michigan, US and Pompei, Italy so that can't be in Km or Mi. But then I tried to convert the miles into radians and that didnt select the people with in 15 miles. So how should I get all the users with in x miles?
No comments:
Post a Comment