35,17 → 35,21 |
return $this->getInformationsPourCoordonnees(); |
} |
|
private function getInformationsPourCoordonnees($params) { |
public function getInformationsPourCoordonnees($params) { |
|
$lat = $_GET['lat']; |
$lon = $_GET['lon']; |
|
$infos_altitude_json = file_get_contents('http://maps.googleapis.com/maps/api/elevation/json?sensor=false&locations='.$lat.','.$lon); |
$infos_commune_json = file_get_contents("http://api.geonames.org/findNearbyJSON?featureClass=ADM4&lat=".urlencode($lat)."&lng=".urlencode($lon)."&style=full") ; |
// les erreurs sont mises sous silence car le cas où file_get_contents ne retourne rien |
// correspond à un cas valide où l'on a pas de données sur ses coordonnées |
// (ce cas est traité dans formaterTableauInformationsCoordsPourEnvoi) |
$url_atitude = "http://api.tela-botanica.org/service:eflore:0.1/nasa-srtm/altitude?lon=".urlencode($lon)."&lat=".urlencode($lat); |
$infos_altitude_json = @file_get_contents($url_atitude); |
|
// à voir l'utilisation de google places lors de la mise en place d'un compte google premier api |
//$infos_commune = file_get_contents('https://maps.googleapis.com/maps/api/place/search/json?sensor=false&locations='.$lat.','.$lon); |
$url_commune = "http://api.tela-botanica.org/service:eflore:0.1/osm/nom-commune?lon=".urlencode($lon)."&lat=".urlencode($lat); |
$infos_commune_json = @file_get_contents($url_commune); |
|
|
$infos_localites = $this->formaterTableauInformationsCoordsPourEnvoi($infos_altitude_json, $infos_commune_json); |
|
return $infos_localites; |
58,9 → 62,8 |
$commune = $this->remplacerNomCommunePourRecherche($commune); |
|
$requete_infos_communes = 'SELECT * FROM ods_communes WHERE oc_nom LIKE '.$this->proteger($commune).' ORDER BY oc_nom LIMIT 0,10'; |
|
$infos_communes = $this->executerRequete($requete_infos_communes); |
|
|
$infos_communes_formatees = $this->formaterTableauInformationsCommunePourEnvoi($infos_communes); |
|
return $infos_communes_formatees; |
114,29 → 117,42 |
|
$infos_altitude = json_decode($infos_altitude_json); |
$infos_commune = json_decode($infos_commune_json); |
|
$altitude = $infos_altitude->results[0]->elevation; |
$altitude = number_format($altitude, 0, '', ''); |
|
$lat = $infos_altitude->results[0]->location->lat; |
$lon = $infos_altitude->results[0]->location->lng; |
$altitude = ""; |
$dpt = ""; |
$lat = ""; |
$lon = ""; |
$altitude = ""; |
$code_insee = ""; |
$commune = ""; |
$commune_phenoclim = false; |
|
$commune = $infos_commune->geonames[0]->adminName4; |
$dpt = $infos_commune->geonames[0]->adminCode2; |
|
$cp_recherche = $dpt; |
if(strlen($cp_recherche) == 4) { |
$cp_recherche = '0'.$cp_recherche; |
} |
|
$commune_phenoclim = $this->estUneCommunePhenoclim(array('code_postal' => $cp_recherche)); |
|
$cp_recherche = substr($cp_recherche,0,2); |
if(is_object($infos_altitude)) { |
$altitude = $infos_altitude->altitude; |
$altitude = number_format($altitude, 0, '', ''); |
$lat = $infos_altitude->latitude; |
$lon = $infos_altitude->longitude; |
} |
|
$code_insee = ''; |
if($commune != null) { |
$code_insee = $this->obtenirCodeInseeCommune($commune, $cp_recherche); |
} |
if(is_object($infos_commune)) { |
$commune = $infos_commune->nom; |
$dpt = $infos_commune->codeINSEE; |
|
$cp_recherche = $dpt; |
if(strlen($cp_recherche) == 4) { |
$cp_recherche = '0'.$cp_recherche; |
} |
|
$commune_phenoclim = $this->estUneCommunePhenoclim(array('code_postal' => $cp_recherche)); |
|
$cp_recherche = substr($cp_recherche,0,2); |
|
$code_insee = ''; |
if($commune != null) { |
$code_insee = $this->obtenirCodeInseeCommune($commune, $cp_recherche); |
} |
} |
|
$infos_communes = array( |
'commune' => $commune, |
182,6 → 198,7 |
'commune_phenoclim' => $commune_phenoclim |
); |
} |
|
return $infos_formatees; |
} |
|