Generally, the Haversine Formula is the best one to calculate distance 
between two points, given the lat/long of both the client and the hotel.
See http://en.wikipedia.org/wiki/Haversine_formula for more information.

SELECT acos(sin(radians(P2.latitude)) * sin(radians(P2.latitude)) + 
cos(radians(P1.latitude)) * cos(radians(P2.latitude)) * 
cos(radians(P1.longitude) - radians(P2.longitude))) * 3963.1 AS distance

In CakePHP, you can implement that as a calculated field.

On Wednesday, August 1, 2012 8:26:53 AM UTC-4, yassine yas wrote:
>
> hi daniel
>
> i have the same probleme like you and i want to help me.
>
> my english is not good.
>
> well i develop a backEnd that receive the request of the client (lat & 
> lng) and it's calculate the distance from the client to the hotels
>
> how can i calculate the distance i calculated field and sort it
>
> thanks
>

-- 
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com.
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php?hl=en-US.


Reply via email to