function getPinsListe($long, $lat, $min, $max, $distancemax) { $longrang = 1.0; $latrang = 1.0; $c = 0; $toFar = false; $restmp = array(); for ($i = 0; $c <= $min; $i++) { $restmp = getToilettesRange($long, $lat, $longrang, $latrang); $c = count($restmp); for ($i = 0; $i < $c; $i++) { $restmp[$i]['distance'] = distanceWGS84($long, $lat, $restmp[$i]['long84'], $restmp[$i]['lat84']); if ($restmp[$i]['distance'] > $distancemax) { $toFar = true; } } $longrang = $longrang * 1.5; $latrang = $latrang * 1.5; if ($toFar) { break; } } $res = array(); $index = 0; if ($toFar) { for ($i = 0; $i < $c; $i++) { if ($restmp[$i]['distance'] < $distancemax) { $res[$index] = $restmp[$i]; $index++; } } } else { $res = $restmp; } $c = count($res); if ($c == 0) { return null; } $id_distance; $sorted; for ($i = 0; $i < $c; $i++) { $id_distance[$i] = $res[$i]['distance']; } asort($id_distance); $i = 0; foreach ($id_distance as $key => $value) { $sorted[$i] = $res[$key]; $i++; } if ($c > $max) { $sorted = array_slice($sorted, 0, $max); } return $sorted; }
<?php require_once '../controller/toilettes.php'; $wc = getfiches(1); echo "<pre>"; print_r($wc); echo "</pre>"; $wc = getImages(80); echo "<pre>"; print_r($wc); echo "</pre>"; $wc = getToilettesRange(351861.03, 6789173.05, 1000, 1000); echo "<pre>"; print_r($wc); echo "</pre>";