Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /***********/
- /* Données */
- /***********/
- $lat = 45.763140; // latitude
- $lng = 4.828063; // longitude
- $rayon_en_m = 2000; // rayon maximum de recherche en mètres, false si on ne veut pas de limite
- /***********/
- /* Calculs */
- /***********/
- $latlngMarge = $rayon_en_m*0.009;
- $query = 'SELECT *, 3956*2*ASIN(SQRT(POWER(SIN(('.$lat.'-ABS(lat))*PI()/180/2),2)+COS('.$lat.'*PI()/180)*COS(ABS(lat)*PI()/180)*POWER(SIN(('.$lng.'-lng)*PI()/180/2),2)))*1609.34 AS distance_m FROM table WHERE 1'.(($rayon_en_m)?' HAVING distance_m<='.$rayon_en_m:'').' ORDER BY distance_m ASC';
- // la variable distance_m vaut la distance à vol d'oiseau en mètres
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement