Around me places
(Sorry for my bad english; i'm french)
Hi!
I have a SQlite database, withy latitude and longitude data inside.
I can show correctly on a map, but I can't show "Around me" places…
I tried a code witch gives a result in meters, the rows aren't ordered by distance, and the distance is impossible, like 554658165184684514456513 meters for something at 100 meters…
Does someone have a code sample to calculate distances in meters, orders SQL by distance? Thanks!
Ivan
EDIT: I can't give you the code, my Mac isn't usable for now
2 Answers
-
If it's something still needed, I'd suggest you to have a look at this Guide so you may got accurate help from community.
-
Hi
I have found the solution. We can put following code in PHP server.
set @orig_lat=22.980141148209555; set @orig_lon=72.4916124343872; set @dist=10; SELECT *, 3956 * 2 * ASIN(SQRT( POWER(SIN((@orig_lat - abs(lat)) * pi()/180 / 2),2) + COS(@orig_lat * pi()/180 ) * COS(abs(lat) * pi()/180) * POWER(SIN((@orig_lon - lon) * pi()/180 / 2), 2) )) * 1.60934 as distance FROM hotels ;
thanks