416 |
aurelien |
1 |
<?php
|
550 |
jpm |
2 |
// declare(encoding='UTF-8');
|
416 |
aurelien |
3 |
/**
|
|
|
4 |
* Service fournissant une carte dynamique des obsertions publiques du CEL.
|
|
|
5 |
* Encodage en entrée : utf8
|
|
|
6 |
* Encodage en sortie : utf8
|
|
|
7 |
*
|
|
|
8 |
* Cas d'utilisation :
|
|
|
9 |
* /CelWidgetMap/Carte/Utilisateur : carte des observations publiques d'un utilisateur.
|
|
|
10 |
* /CelWidgetMap/Carte/Utilisateur/Projet : carte des observations publiques d'un utilisateur pour un projet.
|
485 |
delphine |
11 |
* /CelWidgetMap/Carte/Utilisateur/Projet/dept : carte des observations publiques d'un utilisateur pour un projet sur un département.
|
|
|
12 |
* /CelWidgetMap/Carte/Utilisateur/Projet/dept/num_taxon : carte des observations publiques d'un utilisateur pour un projet sur un département pour un taxon.
|
416 |
aurelien |
13 |
*
|
|
|
14 |
* Carte = Type de carte. Valeurs possible : defaut,
|
|
|
15 |
* Utilisateur = identifiant (= courriel) de l'utilisateur ou * pour tous les utilisateurs.
|
|
|
16 |
* Projet = mot-clé du projet
|
|
|
17 |
*
|
|
|
18 |
* @author Jean-Pascal MILCENT <jpm@clapas.org>
|
|
|
19 |
* @license GPL v3 <http://www.gnu.org/licenses/gpl.txt>
|
|
|
20 |
* @license CECILL v2 <http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt>
|
|
|
21 |
* @version $Id$
|
|
|
22 |
* @copyright © 2010, Jean-Pascal MILCENT
|
|
|
23 |
*/
|
519 |
jpm |
24 |
// TODO : supprimer le TRIM quand les obs seront reliées correctements aux localisations (sur le code INSEE par exemple)
|
416 |
aurelien |
25 |
class CelWidgetMap extends Cel {
|
981 |
jpm |
26 |
const MARQUEUR_GROUPE = 'GROUPE';
|
|
|
27 |
const MARQUEUR_COMMUNE = 'COMMUNE';
|
|
|
28 |
const MARQUEUR_STATION = 'STATION';
|
416 |
aurelien |
29 |
/**
|
|
|
30 |
* Méthode appelée avec une requête de type GET.
|
|
|
31 |
*/
|
840 |
jpm |
32 |
public function getElement($ressources) {
|
416 |
aurelien |
33 |
$retour = null;
|
840 |
jpm |
34 |
extract($this->parametres);
|
981 |
jpm |
35 |
//Chronometre::chrono("Avant groupage");
|
1003 |
jpm |
36 |
|
840 |
jpm |
37 |
$action = array_shift($ressources);
|
|
|
38 |
if (isset($action)) {
|
|
|
39 |
$methode = $this->traiterNomMethodeGet($action);
|
416 |
aurelien |
40 |
if (method_exists($this, $methode)) {
|
840 |
jpm |
41 |
$retour = $this->$methode($ressources);
|
416 |
aurelien |
42 |
} else {
|
840 |
jpm |
43 |
$this->messages[] = "Ce type de ressource '$methode' n'est pas disponible.";
|
416 |
aurelien |
44 |
}
|
|
|
45 |
} else {
|
840 |
jpm |
46 |
$this->messages[] = "Vous devez indiquer le type de ressource.";
|
416 |
aurelien |
47 |
}
|
1003 |
jpm |
48 |
|
981 |
jpm |
49 |
//Chronometre::chrono("Apres traitement");
|
|
|
50 |
//echo Chronometre::afficherChrono();
|
416 |
aurelien |
51 |
if (is_null($retour)) {
|
|
|
52 |
$info = 'Un problème est survenu : '.print_r($this->messages, true);
|
|
|
53 |
$this->envoyer($info);
|
1003 |
jpm |
54 |
} else if (isset($retour['type']) && $retour['type'] == 'jsonVar') {
|
694 |
jpm |
55 |
$this->envoyerJsonVar($retour['variable_js'], $retour['donnees']);
|
1003 |
jpm |
56 |
} else if (isset($retour['type']) && $retour['type'] == 'jsonP') {
|
584 |
jpm |
57 |
$this->envoyerJsonp($retour['donnees']);
|
1003 |
jpm |
58 |
} else if (isset($retour['type']) && $retour['type'] == 'png') {
|
981 |
jpm |
59 |
header("Content-type: image/png");
|
|
|
60 |
imagepng($retour['img']);
|
|
|
61 |
imagedestroy($retour['img']);
|
474 |
jpm |
62 |
} else {
|
938 |
jpm |
63 |
$this->envoyerJson($retour);
|
416 |
aurelien |
64 |
}
|
|
|
65 |
}
|
1003 |
jpm |
66 |
|
416 |
aurelien |
67 |
/**
|
981 |
jpm |
68 |
* Les icones des groupes de stations
|
|
|
69 |
*/
|
|
|
70 |
public function getIconeGroupe($params) {
|
|
|
71 |
extract($this->parametres);
|
1003 |
jpm |
72 |
|
1014 |
aurelien |
73 |
//TODO: changer ceci pour une adresse indiquée dans un fichier de config
|
1032 |
aurelien |
74 |
$img = imagecreatefrompng("/home/aurelien/web/cel_GWT2/widget/documents/icones/carto/groupe/g$type.png");
|
1003 |
jpm |
75 |
|
981 |
jpm |
76 |
$noir = imagecolorallocate($img, 0, 0, 0);
|
|
|
77 |
$texte = (String) $nbre;
|
|
|
78 |
$x = (imagesx($img) - 6.0 * strlen($texte)) / 2;
|
|
|
79 |
$y = (imagesy($img) - 16) / 2;
|
1003 |
jpm |
80 |
|
981 |
jpm |
81 |
imagestring($img, 3, $x, $y, $texte, $noir);
|
1003 |
jpm |
82 |
|
981 |
jpm |
83 |
imagealphablending($img, false);
|
|
|
84 |
imagesavealpha($img, true);
|
1003 |
jpm |
85 |
|
981 |
jpm |
86 |
return array('type' => 'png', 'img' => $img);
|
|
|
87 |
}
|
1003 |
jpm |
88 |
|
981 |
jpm |
89 |
/**
|
938 |
jpm |
90 |
* Les stations de la carte par défaut
|
416 |
aurelien |
91 |
*/
|
938 |
jpm |
92 |
public function getStations($params) {
|
981 |
jpm |
93 |
$stations = null;
|
|
|
94 |
$requete = 'SELECT wgs84_latitude AS lat, wgs84_longitude AS lng, location AS nom '.
|
938 |
jpm |
95 |
'FROM cel_inventory AS i '.
|
|
|
96 |
' LEFT JOIN locations AS l '.
|
|
|
97 |
' ON (l.name = i.location AND l.code = i.id_location) '.
|
|
|
98 |
"WHERE transmission = '1' ".
|
981 |
jpm |
99 |
" AND (( ".
|
|
|
100 |
" (coord_x = '' OR coord_x IS NULL OR coord_x = '000null') ".
|
|
|
101 |
" AND (coord_y = '' OR coord_y IS NULL OR coord_y = '000null') ".
|
|
|
102 |
" ) OR mots_cles_texte LIKE '%sensible%') ".
|
|
|
103 |
$this->construireWhereRectangleCommune().
|
938 |
jpm |
104 |
$this->construireWhereDept().
|
|
|
105 |
$this->construireWhereCommune().
|
|
|
106 |
$this->construireWhereUtilisateur().
|
|
|
107 |
$this->construireWhereNumTaxon().
|
|
|
108 |
$this->construireWhereNomTaxon().
|
|
|
109 |
$this->construireWhereDate().
|
940 |
jpm |
110 |
$this->construireWhereCommentaire().
|
938 |
jpm |
111 |
$this->construireWhereProjet().
|
|
|
112 |
$this->construireWhereTag();
|
1003 |
jpm |
113 |
|
981 |
jpm |
114 |
$resultats_communes = $this->requeter($requete);
|
1003 |
jpm |
115 |
|
981 |
jpm |
116 |
$requete = 'SELECT coord_x AS lat, coord_y AS lng, location AS nom '.
|
|
|
117 |
'FROM cel_inventory AS i '.
|
|
|
118 |
' LEFT JOIN locations AS l '.
|
|
|
119 |
' ON (l.name = i.location AND l.code = i.id_location) '.
|
|
|
120 |
"WHERE transmission = '1' ".
|
|
|
121 |
" AND coord_x != '' AND coord_x IS NOT NULL AND coord_x != '000null' ".
|
|
|
122 |
" AND coord_y != '' AND coord_y IS NOT NULL AND coord_y != '000null' ".
|
|
|
123 |
" AND (mots_cles_texte IS NULL OR mots_cles_texte NOT LIKE '%sensible%') ".
|
|
|
124 |
$this->construireWhereRectangleStation().
|
|
|
125 |
$this->construireWhereDept().
|
|
|
126 |
$this->construireWhereCommune().
|
|
|
127 |
$this->construireWhereUtilisateur().
|
|
|
128 |
$this->construireWhereNumTaxon().
|
|
|
129 |
$this->construireWhereNomTaxon().
|
|
|
130 |
$this->construireWhereDate().
|
|
|
131 |
$this->construireWhereCommentaire().
|
|
|
132 |
$this->construireWhereProjet().
|
|
|
133 |
$this->construireWhereTag();
|
1003 |
jpm |
134 |
|
981 |
jpm |
135 |
$resultats_stations = $this->requeter($requete);
|
|
|
136 |
$stations = $this->traiterStations($resultats_communes, $resultats_stations);
|
1003 |
jpm |
137 |
|
981 |
jpm |
138 |
return $stations;
|
938 |
jpm |
139 |
}
|
1003 |
jpm |
140 |
|
981 |
jpm |
141 |
public function getTout($params) {
|
1003 |
jpm |
142 |
|
|
|
143 |
$emplacements = null;
|
981 |
jpm |
144 |
$requete = 'SELECT DISTINCT location AS nom, '.
|
|
|
145 |
"IF ((coord_x != '000null' AND coord_x != '' ".
|
|
|
146 |
" AND coord_y != '000null' AND coord_y != ''), ".
|
|
|
147 |
"'stations', ".
|
|
|
148 |
"'communes' ".
|
|
|
149 |
") as type_emplacement, ".
|
|
|
150 |
"IF ((coord_x != '000null' AND coord_x != '' ".
|
|
|
151 |
" AND coord_y != '000null' AND coord_y != ''), ".
|
|
|
152 |
"ROUND(coord_x,5), ".
|
|
|
153 |
"ROUND(wgs84_latitude,5) ".
|
|
|
154 |
") as lat, ".
|
|
|
155 |
"IF ((coord_x != '000null' AND coord_x != '' ".
|
|
|
156 |
" AND coord_y != '000null' AND coord_y != ''), ".
|
|
|
157 |
"ROUND(coord_y,5), ".
|
|
|
158 |
"ROUND(wgs84_longitude,5) ".
|
|
|
159 |
") as lng, ".
|
|
|
160 |
"IF ((coord_x != '000null' AND coord_x != '' ".
|
|
|
161 |
" AND coord_y != '000null' AND coord_y != ''), ".
|
|
|
162 |
'CONCAT("'.self::MARQUEUR_STATION.':",ROUND(coord_x,5),"|",ROUND(coord_y,5)), '.
|
|
|
163 |
'CONCAT("'.self::MARQUEUR_COMMUNE.':",ROUND(wgs84_latitude,5),"|",ROUND(wgs84_longitude,5)) '.
|
|
|
164 |
") as id ".
|
|
|
165 |
'FROM cel_inventory AS i '.
|
|
|
166 |
' LEFT JOIN locations AS l '.
|
|
|
167 |
' ON (l.name = i.location AND l.code = i.id_location) '.
|
|
|
168 |
"WHERE transmission = '1' ".
|
1003 |
jpm |
169 |
" AND (".
|
981 |
jpm |
170 |
"(".$this->construireWhereRectangleStationOR().
|
|
|
171 |
" AND (mots_cles_texte IS NULL OR mots_cles_texte NOT LIKE '%sensible%') ".
|
|
|
172 |
")".
|
|
|
173 |
" OR ".
|
|
|
174 |
" ( ".
|
|
|
175 |
$this->construireWhereRectangleCommuneOR().
|
|
|
176 |
" OR mots_cles_texte LIKE '%sensible%' ".
|
|
|
177 |
" ) ".
|
1003 |
jpm |
178 |
") ".
|
981 |
jpm |
179 |
$this->construireWhereDept().
|
|
|
180 |
$this->construireWhereCommune().
|
|
|
181 |
$this->construireWhereUtilisateur().
|
|
|
182 |
$this->construireWhereNumTaxon().
|
|
|
183 |
$this->construireWhereNomTaxon().
|
|
|
184 |
$this->construireWhereDate().
|
|
|
185 |
$this->construireWhereCommentaire().
|
|
|
186 |
$this->construireWhereProjet().
|
|
|
187 |
$this->construireWhereTag();
|
1003 |
jpm |
188 |
|
981 |
jpm |
189 |
$resultats_emplacements = $this->executerRequete($requete);
|
|
|
190 |
$emplacements = $this->traiterEmplacements($resultats_emplacements);
|
1003 |
jpm |
191 |
|
981 |
jpm |
192 |
return $emplacements;
|
1003 |
jpm |
193 |
|
981 |
jpm |
194 |
}
|
1003 |
jpm |
195 |
|
981 |
jpm |
196 |
private function traiterEmplacements(&$emplacements) {
|
|
|
197 |
$zoom = (int) array_key_exists('zoom', $this->parametres) ? $this->parametres['zoom'] : 11;
|
|
|
198 |
$distance = (int) array_key_exists('distance', $this->parametres) ? $this->parametres['distance'] : 20;
|
1003 |
jpm |
199 |
|
981 |
jpm |
200 |
$marqueurs = array(
|
|
|
201 |
'stats' => array('stations' => 0, 'communes' => 0, 'observations' => 0),
|
|
|
202 |
'points' => null
|
|
|
203 |
);
|
1003 |
jpm |
204 |
|
981 |
jpm |
205 |
if (! $this->etreNull($this->parametres['ne']) && ! $this->etreNull($this->parametres['sw'])) {
|
|
|
206 |
$ne = $this->decomposerLatLng($this->parametres['ne']);
|
|
|
207 |
$sw = $this->decomposerLatLng($this->parametres['sw']);
|
|
|
208 |
$marqueurs['points'] = CartoGroupage::creerGroupesQuadtree($emplacements, $ne['lat'], $ne['lng'], $sw['lat'], $sw['lng'], $zoom);
|
1003 |
jpm |
209 |
|
|
|
210 |
// laisser la classe cartoGroupage compter les élements simplifie le comptage
|
982 |
jpm |
211 |
// et permet de ne pas reparser le tableau pour compter les différents éléments
|
981 |
jpm |
212 |
$nb_elements = CartoGroupage::getNbElements();
|
1003 |
jpm |
213 |
|
981 |
jpm |
214 |
$marqueurs['stats']['stations'] = $nb_elements['stations'];
|
|
|
215 |
$marqueurs['stats']['communes'] = $nb_elements['communes'];
|
|
|
216 |
$marqueurs['stats']['observations'] = $nb_elements['observations'];
|
|
|
217 |
} else {
|
|
|
218 |
$marqueurs['points'] = $emplacements;
|
938 |
jpm |
219 |
}
|
981 |
jpm |
220 |
|
|
|
221 |
return $marqueurs;
|
938 |
jpm |
222 |
}
|
1003 |
jpm |
223 |
|
981 |
jpm |
224 |
private function traiterStations($communes, $stations) {
|
|
|
225 |
$zoom = (int) array_key_exists('zoom', $this->parametres) ? $this->parametres['zoom'] : 11;
|
|
|
226 |
$distance = (int) array_key_exists('distance', $this->parametres) ? $this->parametres['distance'] : 20;
|
1003 |
jpm |
227 |
|
981 |
jpm |
228 |
$marqueurs = array(
|
954 |
jpm |
229 |
'stats' => array('stations' => 0, 'communes' => 0, 'observations' => 0),
|
|
|
230 |
'points' => null
|
|
|
231 |
);
|
981 |
jpm |
232 |
$marqueurs['stats']['observations'] = $this->traiterNbreObs($communes) + $this->traiterNbreObs($stations);
|
1003 |
jpm |
233 |
|
954 |
jpm |
234 |
$points = array();
|
981 |
jpm |
235 |
if ($communes !== false) {
|
|
|
236 |
foreach ($communes as $commune) {
|
|
|
237 |
if (is_numeric($commune['lat']) && is_numeric($commune['lng'])) {
|
|
|
238 |
extract($commune);
|
|
|
239 |
$id = self::MARQUEUR_COMMUNE.':'.$lat.'|'.$lng;
|
1004 |
jpm |
240 |
//$this->definirLatLngMaxMin($marqueurs, $lat, $lng);
|
981 |
jpm |
241 |
$lata = round($lat, 5);
|
|
|
242 |
$lnga = round($lng, 5);
|
1003 |
jpm |
243 |
|
954 |
jpm |
244 |
if (!isset($points[$id])) {
|
981 |
jpm |
245 |
$points[$id]['id'] = $id;
|
|
|
246 |
$points[$id]['nom'] = $nom;
|
|
|
247 |
$points[$id]['lat'] = $lata;
|
|
|
248 |
$points[$id]['lng'] = $lnga;
|
954 |
jpm |
249 |
$points[$id]['nbre'] = 1;
|
981 |
jpm |
250 |
$marqueurs['stats']['communes']++;
|
840 |
jpm |
251 |
} else {
|
954 |
jpm |
252 |
$points[$id]['nbre']++;
|
840 |
jpm |
253 |
}
|
981 |
jpm |
254 |
}
|
|
|
255 |
}
|
|
|
256 |
}
|
|
|
257 |
if ($stations !== false) {
|
|
|
258 |
foreach ($stations as $station) {
|
|
|
259 |
if (is_numeric($station['lat']) && is_numeric($station['lng'])) {
|
|
|
260 |
extract($station);
|
|
|
261 |
$id = self::MARQUEUR_STATION.':'.$lat.'|'.$lng;
|
1004 |
jpm |
262 |
//$this->definirLatLngMaxMin($marqueurs, $lat, $lng);
|
981 |
jpm |
263 |
$lata = round($lat, 5);
|
|
|
264 |
$lnga = round($lng, 5);
|
|
|
265 |
$nom = $this->etreNull($nom) ? $lata.','.$lnga : $nom;
|
1003 |
jpm |
266 |
|
954 |
jpm |
267 |
if (!isset($points[$id])) {
|
981 |
jpm |
268 |
$points[$id]['id'] = $id;
|
|
|
269 |
$points[$id]['nom'] = $nom;
|
|
|
270 |
$points[$id]['lat'] = $lata;
|
|
|
271 |
$points[$id]['lng'] = $lnga;
|
954 |
jpm |
272 |
$points[$id]['nbre'] = 1;
|
981 |
jpm |
273 |
$marqueurs['stats']['stations']++;
|
954 |
jpm |
274 |
} else {
|
|
|
275 |
$points[$id]['nbre']++;
|
|
|
276 |
}
|
981 |
jpm |
277 |
}
|
416 |
aurelien |
278 |
}
|
|
|
279 |
}
|
1003 |
jpm |
280 |
|
981 |
jpm |
281 |
if (! $this->etreNull($this->parametres['ne']) && ! $this->etreNull($this->parametres['sw'])) {
|
|
|
282 |
$ne = $this->decomposerLatLng($this->parametres['ne']);
|
|
|
283 |
$sw = $this->decomposerLatLng($this->parametres['sw']);
|
|
|
284 |
$marqueurs['points'] = CartoGroupage::creerGroupesQuadtree(&$points, $ne['lat'], $ne['lng'], $sw['lat'], $sw['lng'], $zoom);
|
|
|
285 |
} else {
|
|
|
286 |
$marqueurs['points'] = $points;
|
|
|
287 |
}
|
1004 |
jpm |
288 |
//$marqueurs['stats']['latDiff'] = abs($marqueurs['stats']['latMin'] - $marqueurs['stats']['latMax']);
|
|
|
289 |
//$marqueurs['stats']['lngDiff'] = abs($marqueurs['stats']['lngMin'] - $marqueurs['stats']['lngMax']);
|
1003 |
jpm |
290 |
|
981 |
jpm |
291 |
return $marqueurs;
|
416 |
aurelien |
292 |
}
|
1003 |
jpm |
293 |
|
981 |
jpm |
294 |
private function definirLatLngMaxMin(&$marqueurs, $lat, $lng) {
|
|
|
295 |
if ($lat != null && $lng != null) {
|
|
|
296 |
$marqueurs['stats']['latMin'] = $marqueurs['stats']['latMin'] > $lat ? $lat : $marqueurs['stats']['latMin'];
|
|
|
297 |
$marqueurs['stats']['lngMin'] = $marqueurs['stats']['lngMin'] > $lng ? $lng : $marqueurs['stats']['lngMin'];
|
|
|
298 |
$marqueurs['stats']['latMax'] = $marqueurs['stats']['latMax'] < $lat ? $lat : $marqueurs['stats']['latMax'];
|
|
|
299 |
$marqueurs['stats']['lngMax'] = $marqueurs['stats']['lngMax'] < $lng ? $lng : $marqueurs['stats']['lngMax'];
|
|
|
300 |
}
|
|
|
301 |
}
|
1003 |
jpm |
302 |
|
981 |
jpm |
303 |
private function traiterNbreObs($resultats) {
|
|
|
304 |
$obs_nbre = 0;
|
|
|
305 |
if ($resultats !== false) {
|
|
|
306 |
$obs_nbre = count($resultats);
|
|
|
307 |
}
|
|
|
308 |
return $obs_nbre;
|
|
|
309 |
}
|
1003 |
jpm |
310 |
|
981 |
jpm |
311 |
private function verifierLatLng($lat, $lng) {
|
|
|
312 |
$ok_lat = $this->etreLatitude($lat) ? true : false;
|
|
|
313 |
$ok_lng = $this->etreLongitude($lng) ? true : false;
|
|
|
314 |
$ok = $ok_lat && $ok_lng;
|
1003 |
jpm |
315 |
return $ok;
|
981 |
jpm |
316 |
}
|
1003 |
jpm |
317 |
|
981 |
jpm |
318 |
private function etreLatitude($lat) {
|
|
|
319 |
$ok = false;
|
|
|
320 |
//$format = preg_match('/^[-]?[0-9]+(?:[.][0-9]+|)$/', $lat) ? true : false;
|
|
|
321 |
$ok = ($lat >= -90 && $lat <= 90) ? true : false;
|
|
|
322 |
return $ok;
|
|
|
323 |
}
|
1003 |
jpm |
324 |
|
981 |
jpm |
325 |
private function etreLongitude($lng) {
|
|
|
326 |
$ok = false;
|
|
|
327 |
//$format = preg_match('/^[-]?[0-9]+(?:[.][0-9]+|)$/', $lng) ? true : false;
|
|
|
328 |
$ok = ($lng >= -180 && $lng <= 180) ? true : false;
|
|
|
329 |
return $ok;
|
|
|
330 |
}
|
1003 |
jpm |
331 |
|
981 |
jpm |
332 |
private function etreObsSensible($tags) {
|
|
|
333 |
$sensible = true;
|
|
|
334 |
if (stristr($tags, 'sensible') === FALSE) {
|
|
|
335 |
$sensible = false;
|
|
|
336 |
}
|
|
|
337 |
return $sensible;
|
|
|
338 |
}
|
1003 |
jpm |
339 |
|
474 |
jpm |
340 |
/**
|
|
|
341 |
* Données pour l'affichage des obs d'une station
|
|
|
342 |
*/
|
|
|
343 |
public function getObservations($params) {
|
938 |
jpm |
344 |
$resultats = array();
|
|
|
345 |
$total = 0;
|
|
|
346 |
if (!$this->etreNull($this->parametres['station'])) {
|
|
|
347 |
$requete = 'SELECT SQL_CALC_FOUND_ROWS id, identifiant, nom_sel, nom_ret, num_nom_sel, num_nom_ret, num_taxon, famille, '.
|
|
|
348 |
' lieudit, location, date_observation, milieu, commentaire, '.
|
|
|
349 |
' sector, x_utm, y_utm, insee_code, date_transmission '.
|
|
|
350 |
'FROM cel_inventory AS i '.
|
|
|
351 |
' LEFT JOIN locations AS l '.
|
|
|
352 |
" ON (l.name = i.location AND l.code = i.id_location) ".
|
|
|
353 |
"WHERE transmission = '1' ".
|
|
|
354 |
$this->construireWhereCoordonnees().
|
|
|
355 |
$this->construireWhereUtilisateur().
|
|
|
356 |
$this->construireWhereNumTaxon().
|
|
|
357 |
$this->construireWhereNomTaxon().
|
|
|
358 |
$this->construireWhereDate().
|
940 |
jpm |
359 |
$this->construireWhereCommentaire().
|
938 |
jpm |
360 |
$this->construireWhereProjet().
|
|
|
361 |
$this->construireWhereTag().
|
|
|
362 |
'ORDER BY nom_sel ASC '.
|
|
|
363 |
"LIMIT {$this->start},{$this->limit} ";
|
|
|
364 |
//die($requete);
|
|
|
365 |
$resultats = $this->requeter($requete, self::SQL_RETOUR_COMPLET, self::SQL_MODE_OBJET);
|
1003 |
jpm |
366 |
|
938 |
jpm |
367 |
$requete = 'SELECT FOUND_ROWS()';
|
|
|
368 |
$total = (int) $this->requeter($requete, self::SQL_RETOUR_COLONNE);
|
474 |
jpm |
369 |
}
|
1003 |
jpm |
370 |
|
474 |
jpm |
371 |
// Post-traitement
|
938 |
jpm |
372 |
$observations = $this->traiterObservations($resultats, $total);
|
981 |
jpm |
373 |
//$observations = $this->ajouterImagesAuxObs($observations);
|
|
|
374 |
//$observations = $this->ajouterAuteursAuxObs($observations);
|
938 |
jpm |
375 |
$observations = $this->supprimerIdDesObs($observations);
|
1003 |
jpm |
376 |
|
938 |
jpm |
377 |
return $observations;
|
|
|
378 |
}
|
1003 |
jpm |
379 |
|
938 |
jpm |
380 |
private function traiterObservations($donnees, $total) {
|
|
|
381 |
$observations = array('commune' => '', 'observations' => array(), 'observateurs' => array());
|
|
|
382 |
$observations['total'] = (isset($total)) ? $total : 0;
|
|
|
383 |
if (is_array($donnees) && count($donnees) > 0) {
|
|
|
384 |
foreach ($donnees as $donnee) {
|
|
|
385 |
$observation = array();
|
|
|
386 |
$observation['idObs'] = $donnee->id;
|
|
|
387 |
$observation['nn'] = $this->etreNull($donnee->num_nom_sel) ? null : $donnee->num_nom_sel;
|
|
|
388 |
$observation['nomSci'] = $this->nettoyerTexte($donnee->nom_sel);
|
|
|
389 |
$observation['date'] = $this->formaterDate($donnee->date_observation, '%d/%m/%Y');
|
|
|
390 |
$observation['datePubli'] = $this->formaterDate($donnee->date_transmission);
|
|
|
391 |
$observation['lieu'] = $this->traiterLieu($donnee);
|
|
|
392 |
$observation['observateur'] = $donnee->identifiant;
|
|
|
393 |
$observation['urlEflore'] = $this->getUrlEflore($donnee->num_nom_sel);
|
1003 |
jpm |
394 |
|
938 |
jpm |
395 |
if (isset($donnee->location)) {
|
|
|
396 |
$observations['commune'] = $this->nettoyerTexte($donnee->location);
|
|
|
397 |
}
|
|
|
398 |
$observations['observations'][$donnee->id] = $observation;
|
1003 |
jpm |
399 |
|
938 |
jpm |
400 |
if (! array_key_exists($donnee->identifiant, $observations['observateurs'])) {
|
1003 |
jpm |
401 |
$observations['observateurs'][$donnee->identifiant] = $donnee->identifiant;
|
938 |
jpm |
402 |
}
|
|
|
403 |
}
|
487 |
jpm |
404 |
}
|
938 |
jpm |
405 |
return $observations;
|
|
|
406 |
}
|
1003 |
jpm |
407 |
|
938 |
jpm |
408 |
private function getUrlEflore($nn) {
|
|
|
409 |
$urlEflore = null;
|
|
|
410 |
if (! $this->etreNull($nn)) {
|
|
|
411 |
$urlEflore = sprintf($this->config['settings']['efloreUrlTpl'], $nn, 'illustration');
|
|
|
412 |
}
|
|
|
413 |
return $urlEflore;
|
|
|
414 |
}
|
1003 |
jpm |
415 |
|
938 |
jpm |
416 |
private function traiterLieu($donnee) {
|
|
|
417 |
$lieu = array();
|
|
|
418 |
if (!$this->etreNull($donnee->lieudit)) {
|
|
|
419 |
$lieu[] = $donnee->lieudit;
|
|
|
420 |
}
|
|
|
421 |
if (!$this->etreNull($donnee->milieu)) {
|
|
|
422 |
$lieu[] = $donnee->milieu;
|
|
|
423 |
}
|
|
|
424 |
return implode(', ', $lieu);
|
|
|
425 |
}
|
1003 |
jpm |
426 |
|
938 |
jpm |
427 |
private function chargerImages(Array $obs_ids) {
|
|
|
428 |
// Récupération des données au format Json
|
|
|
429 |
$service = 'CelImage/liste-ids?obsId='.implode(',', $obs_ids);
|
|
|
430 |
$url = sprintf($this->config['settings']['baseURLServicesCelTpl'], $service);
|
|
|
431 |
$json = $this->getRestClient()->consulter($url);
|
|
|
432 |
$donnees = json_decode($json);
|
1003 |
jpm |
433 |
|
938 |
jpm |
434 |
// Post-traitement des données
|
|
|
435 |
$images = $this->traiterImages($donnees);
|
1003 |
jpm |
436 |
|
938 |
jpm |
437 |
return $images;
|
474 |
jpm |
438 |
}
|
1003 |
jpm |
439 |
|
938 |
jpm |
440 |
private function traiterImages($donnees) {
|
|
|
441 |
$images = array();
|
|
|
442 |
if (count($donnees) > 0) {
|
|
|
443 |
foreach ($donnees as $id_obs => $id_images) {
|
|
|
444 |
foreach ($id_images as $id_img) {
|
|
|
445 |
$urls['idImg'] = $id_img;
|
|
|
446 |
$urls['guid'] = sprintf($this->config['settings']['guidImgTpl'], $id_img);
|
|
|
447 |
$urls['miniature'] = $this->getUrlImage($id_img, 'CXS');
|
|
|
448 |
$urls['normale'] = $this->getUrlImage($id_img, 'XL');
|
|
|
449 |
$images[$id_obs][] = $urls;
|
1003 |
jpm |
450 |
}
|
938 |
jpm |
451 |
}
|
|
|
452 |
}
|
|
|
453 |
return $images;
|
|
|
454 |
}
|
1003 |
jpm |
455 |
|
938 |
jpm |
456 |
private function ajouterImagesAuxObs($observations) {
|
|
|
457 |
$images = $this->chargerImages(array_keys($observations['observations']));
|
|
|
458 |
foreach ($observations['observations'] as $id => $infos) {
|
|
|
459 |
$infos['images'] = $images[$id];
|
|
|
460 |
$observations['observations'][$id] = $infos;
|
|
|
461 |
}
|
|
|
462 |
return $observations;
|
|
|
463 |
}
|
1003 |
jpm |
464 |
|
938 |
jpm |
465 |
private function ajouterAuteursAuxObs($observations) {
|
944 |
jpm |
466 |
$observateurs = $this->recupererUtilisateursIdentite(array_keys($observations['observateurs']));
|
938 |
jpm |
467 |
unset($observations['observateurs']);
|
|
|
468 |
foreach ($observations['observations'] as $id => $infos) {
|
|
|
469 |
$courriel = $infos['observateur'];
|
944 |
jpm |
470 |
$infos['observateur'] = $observateurs[$courriel]['intitule'];
|
|
|
471 |
$infos['observateurId'] = $observateurs[$courriel]['id'];
|
938 |
jpm |
472 |
$observations['observations'][$id] = $infos;
|
|
|
473 |
}
|
|
|
474 |
return $observations;
|
|
|
475 |
}
|
1003 |
jpm |
476 |
|
938 |
jpm |
477 |
private function supprimerIdDesObs($observations) {
|
|
|
478 |
// Le tableau de sortie ne doit pas avoir les id des obs en clé car sinon Jquery Template ne fonctionne pas
|
|
|
479 |
$observationSansId = $observations;
|
|
|
480 |
unset($observationSansId['observations']);
|
|
|
481 |
foreach ($observations['observations'] as $id => $infos) {
|
|
|
482 |
$observationSansId['observations'][] = $infos;
|
|
|
483 |
}
|
|
|
484 |
return $observationSansId;
|
|
|
485 |
}
|
1003 |
jpm |
486 |
|
478 |
jpm |
487 |
/**
|
938 |
jpm |
488 |
* Liste des taxons présents sur la carte
|
840 |
jpm |
489 |
*/
|
938 |
jpm |
490 |
public function getTaxons($params) {
|
840 |
jpm |
491 |
$json = null;
|
1003 |
jpm |
492 |
|
938 |
jpm |
493 |
$requete = 'SELECT SQL_CALC_FOUND_ROWS DISTINCT nom_ret, num_nom_ret, num_taxon, famille '.
|
840 |
jpm |
494 |
'FROM cel_inventory AS i '.
|
|
|
495 |
' LEFT JOIN locations AS l '.
|
|
|
496 |
' ON (l.name = i.location AND l.code = i.id_location) '.
|
|
|
497 |
"WHERE transmission = '1' ".
|
938 |
jpm |
498 |
" AND nom_ret != '' ".
|
|
|
499 |
$this->construireWhereDept().
|
|
|
500 |
$this->construireWhereCommune().
|
|
|
501 |
$this->construireWhereUtilisateur().
|
|
|
502 |
$this->construireWhereNumTaxon().
|
|
|
503 |
$this->construireWhereNomTaxon().
|
|
|
504 |
$this->construireWhereDate().
|
940 |
jpm |
505 |
$this->construireWhereCommentaire().
|
938 |
jpm |
506 |
$this->construireWhereProjet().
|
981 |
jpm |
507 |
$this->construireWhereTag().
|
938 |
jpm |
508 |
'ORDER BY nom_ret ASC '.
|
|
|
509 |
"LIMIT {$this->start},{$this->limit} ";
|
|
|
510 |
//$this->debug[] = $requete;
|
|
|
511 |
$resultats = $this->requeter($requete, self::SQL_RETOUR_COMPLET, self::SQL_MODE_OBJET);
|
1003 |
jpm |
512 |
|
938 |
jpm |
513 |
$requete = 'SELECT FOUND_ROWS()';
|
|
|
514 |
$taxons['total'] = (int) $this->requeter($requete, self::SQL_RETOUR_COLONNE);
|
1003 |
jpm |
515 |
|
938 |
jpm |
516 |
// Post-traitement
|
|
|
517 |
$taxons['taxons'] = $this->traiterTaxons($resultats);
|
1003 |
jpm |
518 |
|
938 |
jpm |
519 |
return $taxons;
|
840 |
jpm |
520 |
}
|
1003 |
jpm |
521 |
|
938 |
jpm |
522 |
private function traiterTaxons($donnees) {
|
|
|
523 |
$taxons = array();
|
|
|
524 |
if (is_array($donnees) && count($donnees) > 0) {
|
|
|
525 |
foreach ($donnees as $donnee) {
|
|
|
526 |
if (!isset($taxons[$donnee->num_taxon]) && ! $this->etreNull($donnee->nom_ret)) {
|
|
|
527 |
$taxon = array();
|
|
|
528 |
$taxon['nn'] = $donnee->num_nom_ret;
|
|
|
529 |
$taxon['nt'] = $donnee->num_taxon;
|
|
|
530 |
$taxon['nom'] = $this->nettoyerTexte($donnee->nom_ret);
|
|
|
531 |
$taxon['famille'] = $this->nettoyerTexte($donnee->famille);
|
|
|
532 |
$taxons[$donnee->num_taxon] = $taxon;
|
|
|
533 |
}
|
|
|
534 |
}
|
|
|
535 |
}
|
|
|
536 |
$taxons = array_values($taxons);
|
|
|
537 |
return $taxons;
|
|
|
538 |
}
|
1003 |
jpm |
539 |
|
938 |
jpm |
540 |
private function construireWhereCoordonnees() {
|
|
|
541 |
$sql = '';
|
|
|
542 |
// Récupération des coordonnées depuis l'id station
|
940 |
jpm |
543 |
extract($this->decomposerParametreStation());
|
938 |
jpm |
544 |
if (isset($type)) {
|
981 |
jpm |
545 |
if ($type == self::MARQUEUR_COMMUNE) {
|
954 |
jpm |
546 |
$lat = $this->proteger($lat);
|
|
|
547 |
$lng = $this->proteger($lng);
|
|
|
548 |
$sql = " AND (wgs84_latitude = $lat AND wgs84_longitude = $lng) ";
|
981 |
jpm |
549 |
} else if ($type == self::MARQUEUR_STATION) {
|
954 |
jpm |
550 |
$lat = $this->proteger($lat);
|
|
|
551 |
$lng = $this->proteger($lng);
|
|
|
552 |
$sql = " AND (coord_x = $lat AND coord_y = $lng) ";
|
938 |
jpm |
553 |
}
|
1003 |
jpm |
554 |
}
|
938 |
jpm |
555 |
return $sql;
|
|
|
556 |
}
|
1003 |
jpm |
557 |
|
940 |
jpm |
558 |
private function construireWhereCommentaire() {
|
|
|
559 |
$sql = '';
|
|
|
560 |
list($type, $commentaire) = $this->decomposerParametreCommentaire();
|
|
|
561 |
if (!$this->etreNull($commentaire)) {
|
|
|
562 |
$commentaire = $this->proteger('%'.$commentaire.'%');
|
|
|
563 |
switch ($type) {
|
|
|
564 |
case '*' :
|
|
|
565 |
$sql = $this->obtenirConditionPourCommentaires($commentaire);
|
|
|
566 |
$sql = " AND (commentaire LIKE $commentaire OR ($sql)) ";
|
|
|
567 |
break;
|
|
|
568 |
case 'observation' :
|
|
|
569 |
$sql = " AND commentaire LIKE $commentaire ";
|
|
|
570 |
break;
|
|
|
571 |
case 'photo' :
|
|
|
572 |
$sql = ' AND '.$this->obtenirConditionPourCommentaires($commentaire).' ';
|
|
|
573 |
break;
|
|
|
574 |
case 'photo.meta' :
|
|
|
575 |
$sql = ' AND '.$this->obtenirConditionPourCommentaireMeta($commentaire).' ';
|
|
|
576 |
break;
|
|
|
577 |
case 'photo.utilisateur' :
|
|
|
578 |
$sql = ' AND '.$this->obtenirConditionPourCommentaireUtilisateur($commentaire).' ';
|
|
|
579 |
break;
|
|
|
580 |
default:
|
|
|
581 |
$sql = " AND commentaire LIKE $commentaire ";
|
1003 |
jpm |
582 |
}
|
940 |
jpm |
583 |
}
|
|
|
584 |
return $sql;
|
|
|
585 |
}
|
1003 |
jpm |
586 |
|
|
|
587 |
|
938 |
jpm |
588 |
private function construireWhereNomTaxon() {
|
|
|
589 |
$sql = '';
|
940 |
jpm |
590 |
list($type, $nom) = $this->decomposerParametreTaxon();
|
|
|
591 |
if (!$this->etreNull($nom)) {
|
938 |
jpm |
592 |
$nom = $this->proteger($nom.'%');
|
|
|
593 |
switch ($type) {
|
|
|
594 |
case '*' :
|
|
|
595 |
$sql = " AND (nom_ret LIKE $nom OR nom_sel LIKE $nom OR famille LIKE $nom) ";
|
|
|
596 |
break;
|
940 |
jpm |
597 |
case 'retenu' :
|
938 |
jpm |
598 |
$sql = " AND nom_ret LIKE $nom ";
|
|
|
599 |
break;
|
940 |
jpm |
600 |
case 'selectionne' :
|
938 |
jpm |
601 |
$sql = " AND nom_sel LIKE $nom ";
|
|
|
602 |
break;
|
940 |
jpm |
603 |
case 'famille' :
|
938 |
jpm |
604 |
$sql = " AND famille LIKE $nom ";
|
|
|
605 |
break;
|
|
|
606 |
default:
|
|
|
607 |
$sql = " AND nom_ret LIKE $nom ";
|
1003 |
jpm |
608 |
}
|
938 |
jpm |
609 |
}
|
|
|
610 |
return $sql;
|
|
|
611 |
}
|
1003 |
jpm |
612 |
|
938 |
jpm |
613 |
private function construireWhereDate() {
|
|
|
614 |
$sql = '';
|
|
|
615 |
// Récupération des coordonnées depuis l'id station
|
940 |
jpm |
616 |
list($type, $date) = $this->decomposerParametreDate();
|
1003 |
jpm |
617 |
|
938 |
jpm |
618 |
if (!$this->etreNull($date)) {
|
|
|
619 |
$date = $this->proteger($date.'%');
|
|
|
620 |
switch ($type) {
|
|
|
621 |
case '*' :
|
|
|
622 |
$sql = " AND (
|
1003 |
jpm |
623 |
date_observation LIKE $date
|
|
|
624 |
OR date_creation LIKE $date
|
|
|
625 |
OR date_modification LIKE $date
|
938 |
jpm |
626 |
OR date_transmission LIKE $date) ";
|
|
|
627 |
break;
|
|
|
628 |
case 'observation' :
|
|
|
629 |
$sql = " AND date_observation LIKE $date ";
|
|
|
630 |
break;
|
|
|
631 |
case 'creation' :
|
|
|
632 |
$sql = " AND date_creation LIKE $date ";
|
|
|
633 |
break;
|
|
|
634 |
case 'modification' :
|
|
|
635 |
$sql = " AND date_modification LIKE $date ";
|
|
|
636 |
break;
|
|
|
637 |
case 'transmission' :
|
|
|
638 |
$sql = " AND date_transmission LIKE $date ";
|
|
|
639 |
break;
|
940 |
jpm |
640 |
case 'photo' :
|
|
|
641 |
$sql = $this->obtenirConditionPourDatePhoto($date);
|
|
|
642 |
break;
|
|
|
643 |
case 'ajout' :
|
|
|
644 |
$sql = $this->obtenirConditionPourDateAjout($date);
|
|
|
645 |
break;
|
938 |
jpm |
646 |
case 'liaison' :
|
940 |
jpm |
647 |
$sql = $this->obtenirConditionPourDateLiaison($date);
|
938 |
jpm |
648 |
break;
|
|
|
649 |
default:
|
|
|
650 |
$sql = " AND date_observation LIKE $date ";
|
|
|
651 |
}
|
|
|
652 |
}
|
|
|
653 |
return $sql;
|
|
|
654 |
}
|
1003 |
jpm |
655 |
|
940 |
jpm |
656 |
private function obtenirConditionPourDatePhoto($date) {
|
|
|
657 |
$observations = $this->obtenirObsLieesImg('date.photo', $date);
|
|
|
658 |
if (is_null($observations)) {
|
|
|
659 |
$this->debug[] = "Aucune observation n'est liée à une photo prise à la date : $date";
|
|
|
660 |
}
|
|
|
661 |
$sql = $this->assemblerObsEnConditionSql($observations);
|
|
|
662 |
return $sql;
|
|
|
663 |
}
|
1003 |
jpm |
664 |
|
940 |
jpm |
665 |
private function obtenirConditionPourDateLiaison($date) {
|
|
|
666 |
$observations = $this->obtenirObsLieesImg('date.liaison', $date);
|
|
|
667 |
if (is_null($observations)) {
|
|
|
668 |
$this->debug[] = "Aucune observation n'a été liée à une image à à la date : $date";
|
|
|
669 |
}
|
|
|
670 |
$sql = $this->assemblerObsEnConditionSql($observations);
|
|
|
671 |
return $sql;
|
|
|
672 |
}
|
|
|
673 |
|
|
|
674 |
private function obtenirConditionPourDateAjout($date) {
|
|
|
675 |
$observations = $this->obtenirObsLieesImg('date.ajout', $date);
|
|
|
676 |
if (is_null($observations)) {
|
|
|
677 |
$this->debug[] = "Aucune observation n'est liée à une image ajoutée à la date : $date";
|
|
|
678 |
}
|
|
|
679 |
$sql = $this->assemblerObsEnConditionSql($observations);
|
|
|
680 |
return $sql;
|
|
|
681 |
}
|
1003 |
jpm |
682 |
|
940 |
jpm |
683 |
private function obtenirConditionPourCommentaireMeta($commentaire) {
|
|
|
684 |
$observations = $this->obtenirObsLieesImg('commentaire.meta', $commentaire);
|
|
|
685 |
if (is_null($observations)) {
|
|
|
686 |
$this->debug[] = "Aucune observation n'est liée à une image dont le commentaire des méta-données correspond à : $commmentaire";
|
|
|
687 |
}
|
|
|
688 |
$operateur = '';
|
|
|
689 |
$sql = $this->assemblerObsEnConditionSql($observations, $operateur);
|
|
|
690 |
return $sql;
|
|
|
691 |
}
|
1003 |
jpm |
692 |
|
940 |
jpm |
693 |
private function obtenirConditionPourCommentaireUtilisateur($commentaire) {
|
|
|
694 |
$observations = $this->obtenirObsLieesImg('commentaire.utilisateur', $commentaire);
|
|
|
695 |
if (is_null($observations)) {
|
|
|
696 |
$this->debug[] = "Aucune observation n'est liée à une image dont le commentaire des utilisateur correspond à : $commmentaire";
|
|
|
697 |
}
|
|
|
698 |
$operateur = '';
|
|
|
699 |
$sql = $this->assemblerObsEnConditionSql($observations, $operateur);
|
|
|
700 |
return $sql;
|
|
|
701 |
}
|
1003 |
jpm |
702 |
|
940 |
jpm |
703 |
private function obtenirConditionPourCommentaires($commentaire) {
|
|
|
704 |
$observations = $this->obtenirObsLieesImg('commentaire.*', $commentaire);
|
|
|
705 |
if (is_null($observations)) {
|
|
|
706 |
$this->debug[] = "Aucune observation n'est liée à une image dont un des commentaires correspond à : $commmentaire";
|
|
|
707 |
}
|
|
|
708 |
$operateur = '';
|
|
|
709 |
$sql = $this->assemblerObsEnConditionSql($observations, $operateur);
|
|
|
710 |
return $sql;
|
|
|
711 |
}
|
1003 |
jpm |
712 |
|
940 |
jpm |
713 |
/**
|
|
|
714 |
* Récupération des identifiant d'utilisateur et des ordres des observations correspondant à une date.
|
|
|
715 |
* Retour sous forme de tableau : array[identifiant] = array(ordre, ordre...);
|
|
|
716 |
*/
|
|
|
717 |
private function obtenirObsLieesImg($type, $param) {
|
|
|
718 |
// Construction de la requête
|
|
|
719 |
$requete = 'SELECT DISTINCT coi_ce_observation AS ordre, coi_ce_utilisateur AS utilisateur '.
|
|
|
720 |
'FROM cel_images '.
|
|
|
721 |
' LEFT JOIN cel_obs_images '.
|
|
|
722 |
' ON (ci_id_image = coi_ce_image) '.
|
|
|
723 |
' LEFT JOIN cel_inventory AS i '.
|
|
|
724 |
' ON (coi_ce_utilisateur = i.identifiant AND coi_ce_observation = i.ordre) '.
|
|
|
725 |
' LEFT JOIN locations AS l '.
|
|
|
726 |
' ON (l.name = i.location AND l.code = i.id_location) '.
|
|
|
727 |
"WHERE transmission = '1' ".
|
|
|
728 |
($type == 'date.photo' ? " AND (ci_meta_date_time LIKE ".str_replace('-', ':', $param)." OR ci_meta_date LIKE $param) " : '').
|
|
|
729 |
($type == 'date.ajout' ? " AND ci_meta_date_ajout LIKE $param " : '').
|
|
|
730 |
($type == 'date.liaison' ? " AND coi_date_liaison LIKE $param " : '').
|
|
|
731 |
($type == 'commentaire.meta' ? " AND ci_meta_comment LIKE $param " : '').
|
|
|
732 |
($type == 'commentaire.utilisateur' ? " AND ci_meta_user_comment LIKE $param " : '').
|
|
|
733 |
($type == 'commentaire.*' ? " AND (ci_meta_comment LIKE $param OR ci_meta_user_comment LIKE $param) " : '').
|
1003 |
jpm |
734 |
$this->construireWhereCoordonnees().
|
940 |
jpm |
735 |
$this->construireWhereDept().
|
|
|
736 |
$this->construireWhereCommune().
|
|
|
737 |
$this->construireWhereUtilisateur().
|
|
|
738 |
$this->construireWhereNumTaxon().
|
|
|
739 |
$this->construireWhereNomTaxon().
|
|
|
740 |
$this->construireWhereProjet().
|
|
|
741 |
$this->construireWhereTag().
|
|
|
742 |
'ORDER BY utilisateur ASC, ordre ASC';
|
|
|
743 |
//$this->debug[] = $requete;
|
|
|
744 |
//die($requete);
|
|
|
745 |
$resultats = $this->executerRequete($requete);
|
1003 |
jpm |
746 |
|
940 |
jpm |
747 |
$observations = null;
|
|
|
748 |
if ($resultats != false) {
|
|
|
749 |
$observations = array();
|
|
|
750 |
foreach ($resultats as $occurence) {
|
|
|
751 |
$utilisateur = $occurence['utilisateur'];
|
|
|
752 |
$ordre = $occurence['ordre'];
|
|
|
753 |
if (!array_key_exists($utilisateur, $observations)) {
|
|
|
754 |
$observations[$utilisateur] = array();
|
|
|
755 |
}
|
|
|
756 |
if (!array_key_exists($ordre, $observations[$utilisateur])) {
|
|
|
757 |
$observations[$utilisateur][$ordre] = $ordre;
|
|
|
758 |
}
|
|
|
759 |
}
|
|
|
760 |
}
|
|
|
761 |
return $observations;
|
|
|
762 |
}
|
1003 |
jpm |
763 |
|
940 |
jpm |
764 |
private function assemblerObsEnConditionSql($observations, $operateur = 'AND') {
|
|
|
765 |
$sql = '';
|
|
|
766 |
if ($observations != null) {
|
|
|
767 |
// Pré-construction du where de la requête
|
|
|
768 |
$tpl_where = "(identifiant = '%s' AND ordre IN (%s))";
|
|
|
769 |
foreach ($observations as $utilisateur => $ordres) {
|
|
|
770 |
$morceaux_requete[] = sprintf($tpl_where, $utilisateur, implode(',', $ordres));
|
|
|
771 |
}
|
|
|
772 |
if (count($morceaux_requete) > 0) {
|
|
|
773 |
$sql = implode(" \nOR ", $morceaux_requete);
|
|
|
774 |
}
|
|
|
775 |
} else {
|
|
|
776 |
// Nous voulons que la requête ne retourne rien
|
|
|
777 |
$sql = "identifiant = '' AND ordre = ''";
|
|
|
778 |
}
|
|
|
779 |
$sql = " $operateur ($sql) ";
|
|
|
780 |
return $sql;
|
|
|
781 |
}
|
1003 |
jpm |
782 |
|
981 |
jpm |
783 |
private function construireWhereRectangleStation() {
|
|
|
784 |
$sql = '';
|
|
|
785 |
if (! $this->etreNull($this->parametres['ne']) && ! $this->etreNull($this->parametres['sw'])) {
|
|
|
786 |
$ne = $this->decomposerLatLng($this->parametres['ne']);
|
|
|
787 |
$sw = $this->decomposerLatLng($this->parametres['sw']);
|
1003 |
jpm |
788 |
|
981 |
jpm |
789 |
$latMin = $sw['lat'];
|
|
|
790 |
$lngMin = $sw['lng'];
|
1003 |
jpm |
791 |
|
981 |
jpm |
792 |
$latMax = $ne['lat'];
|
|
|
793 |
$lngMax = $ne['lng'];
|
1003 |
jpm |
794 |
|
981 |
jpm |
795 |
// ATTENTION : coord_x correspond bien à la LATITUDE!
|
1003 |
jpm |
796 |
$sql = " AND (coord_x != 0 AND coord_y != 0) ".
|
981 |
jpm |
797 |
" AND coord_x > $latMin ".
|
|
|
798 |
" AND coord_x < $latMax ".
|
|
|
799 |
" AND coord_y > $lngMin ".
|
|
|
800 |
" AND coord_y < $lngMax ";
|
|
|
801 |
}
|
|
|
802 |
return $sql;
|
|
|
803 |
}
|
1003 |
jpm |
804 |
|
981 |
jpm |
805 |
private function construireWhereRectangleStationOR() {
|
|
|
806 |
$sql = '';
|
|
|
807 |
if (! $this->etreNull($this->parametres['ne']) && ! $this->etreNull($this->parametres['sw'])) {
|
|
|
808 |
$ne = $this->decomposerLatLng($this->parametres['ne']);
|
|
|
809 |
$sw = $this->decomposerLatLng($this->parametres['sw']);
|
1003 |
jpm |
810 |
|
981 |
jpm |
811 |
$latMin = $sw['lat'];
|
|
|
812 |
$lngMin = $sw['lng'];
|
1003 |
jpm |
813 |
|
981 |
jpm |
814 |
$latMax = $ne['lat'];
|
|
|
815 |
$lngMax = $ne['lng'];
|
1003 |
jpm |
816 |
|
981 |
jpm |
817 |
// ATTENTION : coord_x correspond bien à la LATITUDE!
|
1003 |
jpm |
818 |
$sql = "( (coord_x != 0 AND coord_y != 0) ".
|
981 |
jpm |
819 |
" AND coord_x > $latMin ".
|
|
|
820 |
" AND coord_x < $latMax ".
|
|
|
821 |
" AND coord_y > $lngMin ".
|
|
|
822 |
" AND coord_y < $lngMax )";
|
|
|
823 |
}
|
|
|
824 |
return $sql;
|
|
|
825 |
}
|
1003 |
jpm |
826 |
|
981 |
jpm |
827 |
private function construireWhereRectangleCommune() {
|
|
|
828 |
$sql = '';
|
|
|
829 |
if (! $this->etreNull($this->parametres['ne']) && ! $this->etreNull($this->parametres['sw'])) {
|
|
|
830 |
$ne = $this->decomposerLatLng($this->parametres['ne']);
|
|
|
831 |
$sw = $this->decomposerLatLng($this->parametres['sw']);
|
1003 |
jpm |
832 |
|
981 |
jpm |
833 |
$latMin = $sw['lat'];
|
|
|
834 |
$lngMin = $sw['lng'];
|
1003 |
jpm |
835 |
|
981 |
jpm |
836 |
$latMax = $ne['lat'];
|
|
|
837 |
$lngMax = $ne['lng'];
|
1003 |
jpm |
838 |
|
|
|
839 |
$sql = "AND wgs84_longitude != 0 AND wgs84_latitude != 0 ".
|
981 |
jpm |
840 |
" AND wgs84_latitude > $latMin ".
|
|
|
841 |
" AND wgs84_latitude < $latMax ".
|
|
|
842 |
" AND wgs84_longitude > $lngMin ".
|
|
|
843 |
" AND wgs84_longitude < $lngMax ";
|
|
|
844 |
}
|
|
|
845 |
return $sql;
|
|
|
846 |
}
|
1003 |
jpm |
847 |
|
981 |
jpm |
848 |
private function construireWhereRectangleCommuneOR() {
|
|
|
849 |
$sql = '';
|
|
|
850 |
if (! $this->etreNull($this->parametres['ne']) && ! $this->etreNull($this->parametres['sw'])) {
|
|
|
851 |
$ne = $this->decomposerLatLng($this->parametres['ne']);
|
|
|
852 |
$sw = $this->decomposerLatLng($this->parametres['sw']);
|
1003 |
jpm |
853 |
|
981 |
jpm |
854 |
$latMin = $sw['lat'];
|
|
|
855 |
$lngMin = $sw['lng'];
|
1003 |
jpm |
856 |
|
981 |
jpm |
857 |
$latMax = $ne['lat'];
|
|
|
858 |
$lngMax = $ne['lng'];
|
1003 |
jpm |
859 |
|
|
|
860 |
$sql = "( wgs84_longitude != 0 AND wgs84_latitude != 0 ".
|
981 |
jpm |
861 |
" AND wgs84_latitude > $latMin ".
|
|
|
862 |
" AND wgs84_latitude < $latMax ".
|
|
|
863 |
" AND wgs84_longitude > $lngMin ".
|
|
|
864 |
" AND wgs84_longitude < $lngMax )";
|
|
|
865 |
}
|
|
|
866 |
return $sql;
|
|
|
867 |
}
|
1003 |
jpm |
868 |
|
938 |
jpm |
869 |
private function construireWhereDept() {
|
|
|
870 |
$sql = '';
|
|
|
871 |
// Récupération des coordonnées depuis l'id station
|
|
|
872 |
extract($this->parametres);
|
|
|
873 |
if (!$this->etreNull($dept)) {
|
|
|
874 |
$dept = $this->traiterValeursMultiples($dept);
|
|
|
875 |
$sql = " AND code IN ($dept) ";
|
|
|
876 |
}
|
|
|
877 |
return $sql;
|
|
|
878 |
}
|
1003 |
jpm |
879 |
|
938 |
jpm |
880 |
private function construireWhereCommune() {
|
|
|
881 |
$sql = '';
|
|
|
882 |
// Récupération des coordonnées depuis l'id station
|
|
|
883 |
extract($this->parametres);
|
|
|
884 |
if (!$this->etreNull($commune)) {
|
|
|
885 |
$commune = $this->proteger($commune);
|
|
|
886 |
$sql = " AND location LIKE $commune ";
|
|
|
887 |
}
|
|
|
888 |
return $sql;
|
|
|
889 |
}
|
1003 |
jpm |
890 |
|
|
|
891 |
|
938 |
jpm |
892 |
private function construireWhereUtilisateur() {
|
|
|
893 |
$sql = '';
|
|
|
894 |
// Récupération des coordonnées depuis l'id station
|
|
|
895 |
extract($this->parametres);
|
|
|
896 |
if (!$this->etreNull($utilisateur)) {
|
|
|
897 |
$utilisateur = $this->proteger($utilisateur);
|
|
|
898 |
$sql = " AND identifiant = $utilisateur ";
|
|
|
899 |
}
|
|
|
900 |
return $sql;
|
|
|
901 |
}
|
1003 |
jpm |
902 |
|
938 |
jpm |
903 |
private function construireWhereNumTaxon() {
|
|
|
904 |
$sql = '';
|
|
|
905 |
// Récupération des coordonnées depuis l'id station
|
|
|
906 |
extract($this->parametres);
|
|
|
907 |
if (!$this->etreNull($num_taxon)) {
|
|
|
908 |
$num_taxon = $this->proteger($num_taxon);
|
|
|
909 |
$sql = " AND num_taxon = $num_taxon ";
|
|
|
910 |
}
|
|
|
911 |
return $sql;
|
|
|
912 |
}
|
1003 |
jpm |
913 |
|
938 |
jpm |
914 |
private function construireWhereProjet() {
|
|
|
915 |
$sql = '';
|
|
|
916 |
// Récupération des coordonnées depuis l'id station
|
|
|
917 |
extract($this->parametres);
|
|
|
918 |
$projet_sql = $this->getSqlWhereProjet($projet);
|
|
|
919 |
if (!$this->etreNull($projet_sql)) {
|
|
|
920 |
$sql = " AND ($projet_sql) ";
|
|
|
921 |
}
|
|
|
922 |
return $sql;
|
|
|
923 |
}
|
1003 |
jpm |
924 |
|
840 |
jpm |
925 |
/**
|
938 |
jpm |
926 |
* Traitement de $projet pour construction du filtre dans la requête
|
478 |
jpm |
927 |
*/
|
938 |
jpm |
928 |
private function getSqlWhereProjet($projet) {
|
|
|
929 |
$sql = null;
|
|
|
930 |
if (! $this->etreNull($projet)) {
|
|
|
931 |
$mot_cle_encode = $this->bdd->quote($this->encoderMotCle($projet));
|
1003 |
jpm |
932 |
|
938 |
jpm |
933 |
// Construction de la requête
|
|
|
934 |
$requete = 'SELECT * '.
|
|
|
935 |
'FROM cel_mots_cles_obs '.
|
|
|
936 |
"WHERE cmc_id_mot_cle_general = $mot_cle_encode ";
|
|
|
937 |
$elements_projet = $this->executerRequete($requete);
|
1003 |
jpm |
938 |
|
938 |
jpm |
939 |
$requete_projet = array();
|
|
|
940 |
if ($elements_projet != false && count($elements_projet) > 0) {
|
|
|
941 |
// Pré-construction du where de la requête
|
|
|
942 |
$tpl_where = '(mots_cles LIKE "%%%s%%" AND identifiant = %s )';
|
1003 |
jpm |
943 |
|
938 |
jpm |
944 |
foreach ($elements_projet as $occurence) {
|
|
|
945 |
$requete_projet[] = sprintf($tpl_where, $occurence['cmc_id_mot_cle_utilisateur'], $this->bdd->quote($occurence['cmc_id_proprietaire']));
|
|
|
946 |
}
|
|
|
947 |
} else {
|
|
|
948 |
$this->messages[] = "Aucune observation ne correspond à ce mot clé.";
|
|
|
949 |
}
|
|
|
950 |
if (count($requete_projet) > 0) {
|
|
|
951 |
$sql = implode(" \nOR ", $requete_projet);
|
|
|
952 |
}
|
|
|
953 |
}
|
|
|
954 |
return $sql;
|
|
|
955 |
}
|
1003 |
jpm |
956 |
|
938 |
jpm |
957 |
private function construireWhereTag() {
|
|
|
958 |
$sql = '';
|
|
|
959 |
// Récupération des coordonnées depuis l'id station
|
840 |
jpm |
960 |
extract($this->parametres);
|
938 |
jpm |
961 |
$tag_sql = $this->getSqlWhereObsAvecImagesTaguees($tag);
|
|
|
962 |
if (!$this->etreNull($tag_sql)) {
|
|
|
963 |
$sql = " AND ($tag_sql) ";
|
489 |
jpm |
964 |
}
|
938 |
jpm |
965 |
return $sql;
|
|
|
966 |
}
|
1003 |
jpm |
967 |
|
938 |
jpm |
968 |
/**
|
|
|
969 |
* Traitement de $tag pour construction du filtre dans la requête
|
|
|
970 |
*/
|
|
|
971 |
private function getSqlWhereObsAvecImagesTaguees($tag) {
|
|
|
972 |
$sql = null;
|
|
|
973 |
if (! $this->etreNull($tag)) {
|
|
|
974 |
$tag_sql = $this->getSqlWhereMotsCles($tag);
|
|
|
975 |
// Construction de la requête
|
|
|
976 |
$requete = 'SELECT DISTINCT coi_ce_observation AS ordre, coi_ce_utilisateur AS utilisateur '.
|
|
|
977 |
'FROM cel_images '.
|
|
|
978 |
' LEFT JOIN cel_obs_images '.
|
|
|
979 |
' ON (ci_id_image = coi_ce_image) '.
|
|
|
980 |
' LEFT JOIN cel_inventory AS i '.
|
|
|
981 |
' ON (coi_ce_utilisateur = i.identifiant AND coi_ce_observation = i.ordre) '.
|
|
|
982 |
' LEFT JOIN locations AS l '.
|
|
|
983 |
" ON (l.name = i.location AND l.code = i.id_location) ".
|
|
|
984 |
"WHERE transmission = '1' ".
|
|
|
985 |
$this->construireWhereCoordonnees().
|
|
|
986 |
$this->construireWhereUtilisateur().
|
|
|
987 |
$this->construireWhereNumTaxon().
|
|
|
988 |
$this->construireWhereNomTaxon().
|
|
|
989 |
$this->construireWhereProjet().
|
|
|
990 |
(!$this->etreNull($tag_sql) ? "AND ($tag_sql) " : '').
|
|
|
991 |
'ORDER BY utilisateur ASC, ordre ASC';
|
|
|
992 |
//$this->debug[] = $requete;
|
|
|
993 |
//die($requete);
|
|
|
994 |
$elements_tag = $this->executerRequete($requete);
|
1003 |
jpm |
995 |
|
938 |
jpm |
996 |
$requete_tag = array();
|
|
|
997 |
if ($elements_tag != false && count($elements_tag) > 0) {
|
1003 |
jpm |
998 |
|
938 |
jpm |
999 |
$filtres = array();
|
|
|
1000 |
foreach ($elements_tag as $occurence) {
|
|
|
1001 |
$utilisateur = $occurence['utilisateur'];
|
|
|
1002 |
$ordre = $occurence['ordre'];
|
|
|
1003 |
if (!array_key_exists($utilisateur, $filtres)) {
|
|
|
1004 |
$filtres[$utilisateur] = array();
|
|
|
1005 |
}
|
|
|
1006 |
if (!array_key_exists($ordre, $filtres[$utilisateur])) {
|
|
|
1007 |
$filtres[$utilisateur][$ordre] = $ordre;
|
|
|
1008 |
}
|
|
|
1009 |
}
|
1003 |
jpm |
1010 |
|
938 |
jpm |
1011 |
// Pré-construction du where de la requête
|
|
|
1012 |
$tpl_where = "(identifiant = '%s' AND ordre IN (%s))";
|
|
|
1013 |
foreach ($filtres as $utilisateur => $ordres) {
|
|
|
1014 |
$requete_tag[] = sprintf($tpl_where, $utilisateur, implode(',', $ordres));
|
|
|
1015 |
}
|
1003 |
jpm |
1016 |
|
938 |
jpm |
1017 |
} else {
|
|
|
1018 |
$this->messages[] = "Aucune observation ne possède d'images avec ce mot-clé.";
|
|
|
1019 |
}
|
|
|
1020 |
if (count($requete_tag) > 0) {
|
|
|
1021 |
$sql = implode(" \nOR ", $requete_tag);
|
|
|
1022 |
}
|
489 |
jpm |
1023 |
}
|
938 |
jpm |
1024 |
return $sql;
|
478 |
jpm |
1025 |
}
|
1003 |
jpm |
1026 |
|
487 |
jpm |
1027 |
/**
|
938 |
jpm |
1028 |
* Traitement de $tag pour construction du filtre dans la requête
|
487 |
jpm |
1029 |
*/
|
938 |
jpm |
1030 |
private function getSqlWhereMotsCles($tag) {
|
|
|
1031 |
$sql = null;
|
940 |
jpm |
1032 |
$mots_cles = $this->decomposerParametreTag($tag);
|
1003 |
jpm |
1033 |
|
487 |
jpm |
1034 |
// Construction de la requête
|
938 |
jpm |
1035 |
$requete = 'SELECT cmc_id_proprietaire AS utilisateur, cmc_id_mot_cle_general AS mot_cle_general, '.
|
|
|
1036 |
' cmc_id_mot_cle_utilisateur AS mot_cle_utilisateur '.
|
|
|
1037 |
'FROM cel_mots_cles_images '.
|
|
|
1038 |
'WHERE '.$this->getSqlWhereMotsClesImages($mots_cles['motsClesEncodesProteges']);
|
487 |
jpm |
1039 |
$elements_projet = $this->executerRequete($requete);
|
938 |
jpm |
1040 |
//$this->debug[] = $requete;
|
1003 |
jpm |
1041 |
|
487 |
jpm |
1042 |
$requete_projet = array();
|
|
|
1043 |
if ($elements_projet != false && count($elements_projet) > 0) {
|
|
|
1044 |
// Pré-construction du where de la requête
|
938 |
jpm |
1045 |
if ($mots_cles['type'] == 'OR') {
|
|
|
1046 |
$tpl_where = '(ci_meta_mots_cles LIKE "%%%s,%%" AND ci_ce_utilisateur = %s )';
|
|
|
1047 |
foreach ($elements_projet as $occurence) {
|
|
|
1048 |
$requete_projet[] = sprintf($tpl_where, $occurence['mot_cle_utilisateur'], $this->bdd->quote($occurence['utilisateur']));
|
|
|
1049 |
}
|
|
|
1050 |
} else {
|
|
|
1051 |
$tpl_where_mc = "ci_meta_mots_cles LIKE '%%%s,%%'";
|
|
|
1052 |
$tpl_where = '((%s) AND ci_ce_utilisateur = %s)';
|
|
|
1053 |
$utilisateur_mc = array();
|
|
|
1054 |
foreach ($elements_projet as $occurence) {
|
|
|
1055 |
if (!isset($utilisateur_mc[$occurence['utilisateur']][$occurence['mot_cle_general']])) {
|
|
|
1056 |
$utilisateur_mc[$occurence['utilisateur']][$occurence['mot_cle_general']] = $occurence['mot_cle_utilisateur'];
|
1003 |
jpm |
1057 |
}
|
938 |
jpm |
1058 |
}
|
1003 |
jpm |
1059 |
|
938 |
jpm |
1060 |
foreach ($utilisateur_mc as $utilisateur => $mots_cles_utilisateur) {
|
|
|
1061 |
if (count($mots_cles_utilisateur) == count($mots_cles['motsCles'])) {
|
|
|
1062 |
$where_mots_cles_utilisateur = array();
|
|
|
1063 |
foreach ($mots_cles_utilisateur as $mot_cle) {
|
|
|
1064 |
$where_mots_cles_utilisateur[] = sprintf($tpl_where_mc, $mot_cle);
|
|
|
1065 |
}
|
|
|
1066 |
$where_mots_cles_utilisateur = implode(' AND ', $where_mots_cles_utilisateur);
|
|
|
1067 |
$utilisateur = $this->bdd->quote($utilisateur);
|
|
|
1068 |
$requete_projet[] = sprintf($tpl_where, $where_mots_cles_utilisateur, $utilisateur);
|
|
|
1069 |
}
|
|
|
1070 |
}
|
487 |
jpm |
1071 |
}
|
|
|
1072 |
} else {
|
|
|
1073 |
$this->messages[] = "Aucune observation ne correspond à ce mot clé.";
|
|
|
1074 |
}
|
1003 |
jpm |
1075 |
|
487 |
jpm |
1076 |
$sql = implode(" \nOR ", $requete_projet);
|
938 |
jpm |
1077 |
//$this->debug[] = $sql;
|
487 |
jpm |
1078 |
return $sql;
|
840 |
jpm |
1079 |
}
|
1003 |
jpm |
1080 |
|
938 |
jpm |
1081 |
/**
|
|
|
1082 |
* Traitement de $tag pour construction du filtre dans la requête
|
|
|
1083 |
*/
|
|
|
1084 |
private function getSqlWhereMotsClesImages($mots_cles_encodes) {
|
|
|
1085 |
$where_mots_cles_images = array();
|
|
|
1086 |
foreach ($mots_cles_encodes as $mot_cle_encode) {
|
|
|
1087 |
$where_mots_cles_images[] = "cmc_id_mot_cle_general = $mot_cle_encode";
|
|
|
1088 |
}
|
|
|
1089 |
$where_mots_cles_images = implode(' OR ', $where_mots_cles_images);
|
|
|
1090 |
return $where_mots_cles_images;
|
|
|
1091 |
}
|
1003 |
jpm |
1092 |
|
940 |
jpm |
1093 |
private function decomposerParametreTag($tags) {
|
938 |
jpm |
1094 |
$mots_cles = array('type' => null, 'motsCles' => null, 'motsClesEncodesProteges' => null);
|
|
|
1095 |
if (preg_match('/.+OU.+/', $tags)) {
|
|
|
1096 |
$mots_cles['type'] = 'OR';
|
|
|
1097 |
$mots_cles['motsCles'] = explode('OU', $tags);
|
|
|
1098 |
} else if (preg_match('/.+ET.+/', $tags)) {
|
|
|
1099 |
$mots_cles['type'] = 'AND';
|
|
|
1100 |
$mots_cles['motsCles'] = explode('ET', $tags);
|
|
|
1101 |
} else {
|
|
|
1102 |
$mots_cles['motsCles'][] = $tags;
|
|
|
1103 |
}
|
1003 |
jpm |
1104 |
|
938 |
jpm |
1105 |
foreach ($mots_cles['motsCles'] as $mot) {
|
|
|
1106 |
$mots_cles['motsClesEncodesProteges'][] = $this->bdd->quote($this->encoderMotCle($mot));
|
|
|
1107 |
}
|
|
|
1108 |
$this->debug[] = $mots_cles;
|
|
|
1109 |
return $mots_cles;
|
|
|
1110 |
}
|
1003 |
jpm |
1111 |
|
981 |
jpm |
1112 |
private function decomposerLatLng($coord) {
|
|
|
1113 |
$lat_lng = array();
|
|
|
1114 |
if (isset($coord)) {
|
|
|
1115 |
list($lat, $lng) = explode('|', $coord);
|
|
|
1116 |
$lat_lng = array('lat' => $lat, 'lng' => $lng);
|
|
|
1117 |
}
|
|
|
1118 |
return $lat_lng;
|
|
|
1119 |
}
|
1003 |
jpm |
1120 |
|
940 |
jpm |
1121 |
private function decomposerParametreStation() {
|
938 |
jpm |
1122 |
$station_infos = array();
|
|
|
1123 |
if (isset($this->parametres['station'])) {
|
|
|
1124 |
$station = $this->parametres['station'];
|
|
|
1125 |
$this->debug[] = $station;
|
|
|
1126 |
list($type, $coord) = explode(':', $station);
|
981 |
jpm |
1127 |
list($lat, $lng) = explode('|', $coord);
|
1003 |
jpm |
1128 |
|
954 |
jpm |
1129 |
$station_infos = array('type' => $type, 'lat' => $lat, 'lng' => $lng);
|
938 |
jpm |
1130 |
}
|
|
|
1131 |
return $station_infos;
|
|
|
1132 |
}
|
1003 |
jpm |
1133 |
|
940 |
jpm |
1134 |
private function decomposerParametreDate() {
|
|
|
1135 |
$date_infos = array();
|
|
|
1136 |
if (isset($this->parametres['date'])) {
|
|
|
1137 |
$date = $this->parametres['date'];
|
|
|
1138 |
if (strpos($date, ':')) {
|
|
|
1139 |
list($type, $date) = explode(':', $date);
|
|
|
1140 |
} else {
|
|
|
1141 |
$type = 'observation';
|
|
|
1142 |
}
|
1003 |
jpm |
1143 |
|
940 |
jpm |
1144 |
$date = str_replace('/', '-', $date);
|
|
|
1145 |
if (preg_match('/(^[0-9]{2})-([0-9]{2})-([0-9]{4}$)/', $date, $matches)) {
|
|
|
1146 |
$date = $matches[3].'-'.$matches[2].'-'.$matches[1];
|
|
|
1147 |
}
|
1003 |
jpm |
1148 |
|
940 |
jpm |
1149 |
$date_infos = array($type, $date);
|
|
|
1150 |
}
|
|
|
1151 |
return $date_infos;
|
|
|
1152 |
}
|
1003 |
jpm |
1153 |
|
940 |
jpm |
1154 |
private function decomposerParametreTaxon() {
|
|
|
1155 |
$nom_infos = array();
|
|
|
1156 |
if (isset($this->parametres['taxon'])) {
|
|
|
1157 |
$taxon = $this->parametres['taxon'];
|
|
|
1158 |
if (strpos($taxon, ':')) {
|
|
|
1159 |
$nom_infos = explode(':', $taxon);
|
|
|
1160 |
} else {
|
|
|
1161 |
$nom_infos = array('retenu', $taxon);
|
|
|
1162 |
}
|
|
|
1163 |
}
|
|
|
1164 |
return $nom_infos;
|
|
|
1165 |
}
|
1003 |
jpm |
1166 |
|
940 |
jpm |
1167 |
private function decomposerParametreCommentaire() {
|
|
|
1168 |
$commentaire_infos = array();
|
|
|
1169 |
if (isset($this->parametres['commentaire'])) {
|
|
|
1170 |
$commentaire = $this->parametres['commentaire'];
|
|
|
1171 |
if (strpos($commentaire, ':')) {
|
|
|
1172 |
$commentaire_infos = explode(':', $commentaire);
|
|
|
1173 |
} else {
|
|
|
1174 |
$commentaire_infos = array('observation', $commentaire);
|
|
|
1175 |
}
|
|
|
1176 |
}
|
|
|
1177 |
return $commentaire_infos;
|
|
|
1178 |
}
|
416 |
aurelien |
1179 |
}
|