| Line 14... |
Line 14... |
| 14 |
* @license GPL v3 <http://www.gnu.org/licenses/gpl.txt>
|
14 |
* @license GPL v3 <http://www.gnu.org/licenses/gpl.txt>
|
| 15 |
* @license CECILL v2 <http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt>
|
15 |
* @license CECILL v2 <http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt>
|
| 16 |
* @copyright 1999-2014 Tela Botanica <accueil@tela-botanica.org>
|
16 |
* @copyright 1999-2014 Tela Botanica <accueil@tela-botanica.org>
|
| 17 |
*/
|
17 |
*/
|
| 18 |
class CoordSearch extends Cel {
|
18 |
class CoordSearch extends Cel {
|
| 19 |
|
19 |
|
| 20 |
public function getRessource() {
|
20 |
public function getRessource() {
|
| 21 |
return $this->getElement(array());
|
21 |
return $this->getElement(array());
|
| 22 |
}
|
22 |
}
|
| 23 |
|
23 |
|
| 24 |
public function getElement($uid){
|
24 |
public function getElement($uid){
|
| 25 |
$header = '';
|
25 |
$header = '';
|
| 26 |
$retour = array();
|
26 |
$retour = [];
|
| Line 27... |
Line 27... |
| 27 |
|
27 |
|
| 28 |
$params = $this->traiterParametres();
|
28 |
$params = $this->traiterParametres();
|
| Line -... |
Line 29... |
| - |
|
29 |
$recherche_zones_geo = new RechercheInfosZoneGeo($this->config);
|
| 29 |
$recherche_zones_geo = new RechercheInfosZoneGeo($this->config);
|
30 |
|
| - |
|
31 |
if( !empty($params)) {
|
| - |
|
32 |
if ($this->estUneRequeteReverseGeocoding($params)) {
|
| - |
|
33 |
$informations = $recherche_zones_geo->obtenirInfosPourCoordonnees([
|
| - |
|
34 |
'latitude' => $params['lat'],
|
| - |
|
35 |
'longitude' => $params['lon'],
|
| - |
|
36 |
]);
|
| - |
|
37 |
} elseif ($this->estUneRequeteGeocodingCodeInseeCommune($params)) {
|
| - |
|
38 |
$informations = $recherche_zones_geo->obtenirInfosPourCodeInseeCommune($params['code']);
|
| - |
|
39 |
} elseif ($this->estUneRequeteGeocoding($params)) {
|
| - |
|
40 |
$informations = $recherche_zones_geo->obtenirInfosPourNom(
|
| - |
|
41 |
$params['zone'],
|
| - |
|
42 |
$params['pays'],
|
| - |
|
43 |
$params['code']
|
| - |
|
44 |
);
|
| - |
|
45 |
} elseif ($this->estUneRequeteGeocodingGroupe($params)) {
|
| - |
|
46 |
// renvoie des infos sur un groupes de zones géographiques, si celui-ci
|
| - |
|
47 |
// est décrit dans la table cel_groupes_zones_geo
|
| - |
|
48 |
$informations = $recherche_zones_geo->obtenirInfosPourGroupeZonesFrance($params['groupe_zones']);
|
| - |
|
49 |
}
|
| - |
|
50 |
|
| Line 30... |
Line -... |
| 30 |
|
- |
|
| 31 |
if ($this->estUneRequeteReverseGeocoding($params)) {
|
- |
|
| 32 |
|
- |
|
| 33 |
$coordonnees = array('latitude' => $params['lat'], 'longitude' => $params['lon']);
|
- |
|
| 34 |
$informations_zones = $recherche_zones_geo->obtenirInfosPourCoordonnees($coordonnees);
|
- |
|
| 35 |
$header = 'Content-Type: application/json; charset=UTF-8';
|
- |
|
| 36 |
$retour = json_encode($informations_zones);
|
- |
|
| 37 |
} elseif ($this->estUneRequeteGeocodingCodeInseeCommune($params)) {
|
- |
|
| 38 |
$informations_coord = $recherche_zones_geo->obtenirInfosPourCodeInseeCommune($params['code']);
|
- |
|
| 39 |
$header = 'Content-Type: application/json; charset=UTF-8';
|
- |
|
| 40 |
$retour = json_encode($informations_coord);
|
- |
|
| 41 |
} elseif ($this->estUneRequeteGeocoding($params)) {
|
- |
|
| 42 |
$informations_coord = $recherche_zones_geo->obtenirInfosPourNom($params['zone'], $params['pays'], $params['code']);
|
- |
|
| 43 |
$header = 'Content-Type: application/json; charset=UTF-8';
|
- |
|
| 44 |
$retour = json_encode($informations_coord);
|
- |
|
| 45 |
|
- |
|
| 46 |
} elseif ($this->estUneRequeteGeocodingGroupe($params)) {
|
- |
|
| 47 |
// renvoie des infos sur un groupes de zones géographiques, si celui-ci
|
51 |
$altitude = $recherche_zones_geo->obtenirAltitude($informations);
|
| 48 |
// est décrit dans la table cel_groupes_zones_geo
|
52 |
$informations = array_merge($informations, $altitude);
|
| 49 |
$informations_groupe = $recherche_zones_geo->obtenirInfosPourGroupeZonesFrance($params['groupe_zones']);
|
53 |
|
| 50 |
$header = 'Content-Type: application/json; charset=UTF-8';
|
54 |
$header = 'Content-Type: application/json; charset=UTF-8';
|
| 51 |
$retour = json_encode($informations_groupe);
|
55 |
$retour = json_encode($informations);
|
| 52 |
|
56 |
|
| 53 |
} else {
|
57 |
} else {
|
| 54 |
$header = 'HTTP/1.0 400 Bad Request';
|
58 |
$header = 'HTTP/1.0 400 Bad Request';
|
| 55 |
$retour = 'zone ou Coordonnées ou code INSEE non spécifié.e';
|
59 |
$retour = 'zone ou Coordonnées ou code INSEE non spécifié.e';
|
| 56 |
}
|
60 |
}
|
| 57 |
|
61 |
|
| Line 58... |
Line 62... |
| 58 |
header($header);
|
62 |
header($header);
|
| Line 71... |
Line 75... |
| 71 |
$parametresTraites[$p] = $val;
|
75 |
$parametresTraites[$p] = $val;
|
| 72 |
}
|
76 |
}
|
| Line 73... |
Line 77... |
| 73 |
|
77 |
|
| 74 |
return $parametresTraites;
|
78 |
return $parametresTraites;
|
| 75 |
}
|
79 |
}
|
| 76 |
|
80 |
|
| 77 |
protected function estUneRequeteReverseGeocoding($params) {
|
81 |
protected function estUneRequeteReverseGeocoding($params) {
|
| 78 |
return ($params['lat'] != '' && $params['lon'] != '');
|
82 |
return ($params['lat'] != '' && $params['lon'] != '');
|
| Line 79... |
Line 83... |
| 79 |
}
|
83 |
}
|