303 |
delphine |
1 |
<?php
|
|
|
2 |
/*vim: set expandtab tabstop=4 shiftwidth=4: */
|
|
|
3 |
// +------------------------------------------------------------------------------------------------------+
|
|
|
4 |
// | PHP version 5.1.1 |
|
|
|
5 |
// +------------------------------------------------------------------------------------------------------+
|
|
|
6 |
// | Copyright (C) 2006 Tela Botanica (accueil@tela-botanica.org) |
|
|
|
7 |
// +------------------------------------------------------------------------------------------------------+
|
|
|
8 |
// | This file is part of eFlore-Fiche. |
|
|
|
9 |
// | |
|
|
|
10 |
// | Foobar is free software; you can redistribute it and/or modify |
|
|
|
11 |
// | it under the terms of the GNU General Public License as published by |
|
|
|
12 |
// | the Free Software Foundation; either version 2 of the License, or |
|
|
|
13 |
// | (at your option) any later version. |
|
|
|
14 |
// | |
|
|
|
15 |
// | Foobar is distributed in the hope that it will be useful, |
|
|
|
16 |
// | but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
|
|
17 |
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
|
|
18 |
// | GNU General Public License for more details. |
|
|
|
19 |
// | |
|
|
|
20 |
// | You should have received a copy of the GNU General Public License |
|
|
|
21 |
// | along with Foobar; if not, write to the Free Software |
|
|
|
22 |
// | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|
|
|
23 |
// +------------------------------------------------------------------------------------------------------+
|
|
|
24 |
// CVS : $Id: effi_cel.action.php,v 1.9 2007-11-06 10:54:03 jp_milcent Exp $
|
|
|
25 |
/**
|
|
|
26 |
* Fichier d'action du module eFlore-Fiche : Cel
|
|
|
27 |
*
|
|
|
28 |
* Appel Carnet en ligne
|
|
|
29 |
*
|
|
|
30 |
*
|
|
|
31 |
*@package eFlore
|
|
|
32 |
*@subpackage ef_fiche
|
|
|
33 |
//Auteur original :
|
|
|
34 |
*@author David Delon <dd@clapas.net>
|
|
|
35 |
//Autres auteurs :
|
|
|
36 |
*@author aucun
|
|
|
37 |
*@copyright Tela-Botanica 2000-2006
|
|
|
38 |
*@version $Revision: 1.9 $ $Date: 2007-11-06 10:54:03 $
|
|
|
39 |
// +------------------------------------------------------------------------------------------------------+
|
|
|
40 |
*/
|
|
|
41 |
|
|
|
42 |
// +------------------------------------------------------------------------------------------------------+
|
|
|
43 |
// | ENTETE du PROGRAMME |
|
|
|
44 |
// +------------------------------------------------------------------------------------------------------+
|
|
|
45 |
|
|
|
46 |
// +------------------------------------------------------------------------------------------------------+
|
|
|
47 |
// | CORPS du PROGRAMME |
|
|
|
48 |
// +------------------------------------------------------------------------------------------------------+
|
|
|
49 |
|
|
|
50 |
|
|
|
51 |
|
|
|
52 |
// TODO : CSS specifique (id)
|
|
|
53 |
|
|
|
54 |
class Cartes {
|
|
|
55 |
private $tab_code_insee = array();
|
|
|
56 |
private $src_map;
|
|
|
57 |
|
|
|
58 |
public function consulter($ressources, $param) {
|
308 |
delphine |
59 |
$this->ressources = $ressources;
|
|
|
60 |
$this->param = $param;
|
|
|
61 |
|
|
|
62 |
$this->traiterParametres();
|
303 |
delphine |
63 |
// Initialisation des variables
|
|
|
64 |
$tab_retour = array();
|
308 |
delphine |
65 |
|
|
|
66 |
|
|
|
67 |
$tab_retour['contenu_page'] = $this->calculerRepartition($this->info);
|
|
|
68 |
print_r($this->calculerRepartition($this->info));
|
|
|
69 |
}
|
|
|
70 |
|
|
|
71 |
private function traiterParametres() {
|
|
|
72 |
if ($this->param['retour.format'] == 'min') {
|
303 |
delphine |
73 |
$this->src_map = 'france_utm_miniature.jpg';
|
|
|
74 |
} else {
|
|
|
75 |
$this->src_map = 'france_utm_600x564.jpg';
|
|
|
76 |
}
|
|
|
77 |
// +-----------------------------------------------------------------------------------------------------------+
|
|
|
78 |
// Ajout du code du r�f�rentiel
|
|
|
79 |
$this->info['referentiel'] = 'bdtfx';
|
|
|
80 |
|
|
|
81 |
// +-----------------------------------------------------------------------------------------------------------+
|
|
|
82 |
// R�cup�ration d'infos g�n�rales
|
308 |
delphine |
83 |
/*$this->info['nn'] = 141;
|
303 |
delphine |
84 |
$this->info['nt'] = 8522;
|
|
|
85 |
$this->info['nom'] = 'Acer campestre L.';
|
308 |
delphine |
86 |
$this->info['nom_ss_auteur'] = 'Acer campestre';*/
|
|
|
87 |
$this->info['nn'] = $this->param['masque.nn'];
|
|
|
88 |
$this->info['nt'] = $this->param['masque.nt'];
|
|
|
89 |
$this->info['nom'] = $this->param['masque.ns'].' '.$this->param['masque.au'];
|
|
|
90 |
$this->info['nom_ss_auteur'] = $this->param['masque.ns'];
|
|
|
91 |
$this->info['miniature'] = $this->param['retour.format'];
|
303 |
delphine |
92 |
}
|
|
|
93 |
|
|
|
94 |
private function calculerRepartition($param) {
|
|
|
95 |
$text = '';
|
|
|
96 |
// Lecture commentaires embarqu�s dans la page
|
|
|
97 |
$jpg_txt = file_get_contents(Config::get('Cartes.chemin').str_replace('jpg', 'txt', $this->src_map));
|
|
|
98 |
parse_str($jpg_txt);
|
|
|
99 |
// Rappel : Pixel : O,0 en haut gauche
|
|
|
100 |
|
|
|
101 |
// X Coin inferieur gauche en Pixel
|
|
|
102 |
//$Px_echelle_X1['31T'] = 0;
|
|
|
103 |
$Px_echelle_X1['31T'] = $X131T;
|
|
|
104 |
// Y Coin inferieur gauche en Pixel
|
|
|
105 |
//$Px_echelle_Y1['31T'] = 539;
|
|
|
106 |
$Px_echelle_Y1['31T'] = $Y131T;
|
|
|
107 |
|
|
|
108 |
// Pour calcul Resolution
|
|
|
109 |
// X Coin inferieur droit en Pixel
|
|
|
110 |
//$Px_echelle_X2['31T'] = 805;
|
|
|
111 |
$Px_echelle_X2['31T'] = $X231T;
|
|
|
112 |
// Y Coin inferieur droit en Pixel
|
|
|
113 |
//$Px_echelle_Y2['31T'] = 539;
|
|
|
114 |
$Px_echelle_Y2['31T'] = $Y231T;
|
|
|
115 |
|
|
|
116 |
// X Coin inferieur gauche en UTM
|
|
|
117 |
//$M_UTM_X1['31T'] = 300092;
|
|
|
118 |
$M_UTM_X1['31T'] = $X131TUTM;
|
|
|
119 |
// Y Coin inferieur gauche en UTM
|
|
|
120 |
//$M_UTM_Y1['31T'] = 4536867;
|
|
|
121 |
$M_UTM_Y1['31T'] = $Y131TUTM;
|
|
|
122 |
|
|
|
123 |
// Pour calcul "resolution"
|
|
|
124 |
|
|
|
125 |
// X Coin inferieur droit en UTM
|
|
|
126 |
//$M_UTM_X2['31T'] = 105371; //
|
|
|
127 |
$M_UTM_X2['31T'] = $X231TUTM;
|
|
|
128 |
// Y Coin inferieur droit en UTM
|
|
|
129 |
//$M_UTM_Y2['31T'] = 5042332;
|
|
|
130 |
$M_UTM_Y2['31T'] = $Y231TUTM;
|
|
|
131 |
|
|
|
132 |
// "Resolution"
|
|
|
133 |
$p['31T'] = ($Px_echelle_X2['31T'] - $Px_echelle_X1['31T']) / ($M_UTM_X2['31T'] - $M_UTM_X1['31T']);
|
|
|
134 |
|
|
|
135 |
// Fuseau 32T :
|
|
|
136 |
|
|
|
137 |
// Pixel : O,0 en haut gauche
|
|
|
138 |
|
|
|
139 |
// X Coin inferieur gauche en Pixel
|
|
|
140 |
//$Px_echelle_X1['32T'] = 483;
|
|
|
141 |
$Px_echelle_X1['32T'] = $X132T;
|
|
|
142 |
|
|
|
143 |
// Y Coin inferieur gauche en Pixel
|
|
|
144 |
//$Px_echelle_Y1['32T'] = 536;
|
|
|
145 |
$Px_echelle_Y1['32T'] = $Y132T;
|
|
|
146 |
|
|
|
147 |
// X Coin inferieur droit en Pixel
|
|
|
148 |
//$Px_echelle_X2['32T'] = 805;
|
|
|
149 |
$Px_echelle_X2['32T'] = $X232T;
|
|
|
150 |
// Y Coin inferieur droit en Pixel
|
|
|
151 |
//$Px_echelle_Y2['32T'] = 536;
|
|
|
152 |
$Px_echelle_Y2['32T'] = $Y232T;
|
|
|
153 |
|
|
|
154 |
|
|
|
155 |
// X Coin inferieur gauche en UTM
|
|
|
156 |
//$M_UTM_X1['32T'] = 247615;
|
|
|
157 |
$M_UTM_X1['32T'] = $X132TUTM;
|
|
|
158 |
// Y Coin inferieur gauche en UTM
|
|
|
159 |
//$M_UTM_Y1['32T'] = 4540000;
|
|
|
160 |
$M_UTM_Y1['32T'] = $Y132TUTM;
|
|
|
161 |
|
|
|
162 |
//$angle3132;
|
|
|
163 |
|
|
|
164 |
// "Resolution"
|
|
|
165 |
$p['32T'] = ($Px_echelle_X2['31T'] - $Px_echelle_X1['31T'] ) / ($M_UTM_X2['31T'] - $M_UTM_X1['31T']);
|
|
|
166 |
|
|
|
167 |
// Fuseau 30T :
|
|
|
168 |
|
|
|
169 |
// X Coin inferieur gauche en Pixel
|
|
|
170 |
//$Px_echelle_X1['30T'] = 483;
|
|
|
171 |
$Px_echelle_X1['30T'] = $X130T;
|
|
|
172 |
|
|
|
173 |
// Y Coin inferieur gauche en Pixel
|
|
|
174 |
//$Px_echelle_Y1['30T'] = 536;
|
|
|
175 |
$Px_echelle_Y1['30T'] = $Y130T;
|
|
|
176 |
|
|
|
177 |
// X Coin inferieur droit en Pixel
|
|
|
178 |
//$Px_echelle_X2['30T'] = 805;
|
|
|
179 |
$Px_echelle_X2['30T'] = $X230T;
|
|
|
180 |
// Y Coin inferieur droit en Pixel
|
|
|
181 |
//$Px_echelle_Y2['30T'] = 536;
|
|
|
182 |
$Px_echelle_Y2['30T'] = $Y230T;
|
|
|
183 |
|
|
|
184 |
// X Coin inferieur gauche en UTM
|
|
|
185 |
//$M_UTM_X1['30T'] = 247615;
|
|
|
186 |
$M_UTM_X1['30T'] = $X130TUTM;
|
|
|
187 |
// Y Coin inferieur gauche en UTM
|
|
|
188 |
//$M_UTM_Y1['30T'] = 4540000;
|
|
|
189 |
$M_UTM_Y1['30T'] = $Y130TUTM;
|
|
|
190 |
|
|
|
191 |
// angle
|
|
|
192 |
//$a = 356.0; // (-4 degre)
|
|
|
193 |
|
|
|
194 |
// "Resolution"
|
|
|
195 |
$p['30T'] = ($Px_echelle_X2['31T'] - $Px_echelle_X1['31T'] ) / ($M_UTM_X2['31T'] - $M_UTM_X1['31T']);
|
|
|
196 |
|
|
|
197 |
// Nom du fichier image en sortie
|
|
|
198 |
$this->cheminCartesBase = Config::get('Cartes.chemin');
|
|
|
199 |
$dest_map = 'nt'.$this->info['nt'].'_'.$this->src_map;
|
|
|
200 |
$dest_map_cel = 'cel_nt'.$this->info['nt'].'_'.$this->src_map;
|
|
|
201 |
$dest_map_cenlr = 'cenlr_nt'.$this->info['nt'].'_'.$this->src_map;
|
|
|
202 |
$dest_map_cbnmed = 'cbnmed_nt'.$this->info['nt'].'_'.$this->src_map;
|
|
|
203 |
$dest_map_sophy = 'sophy_nt'.$this->info['nt'].'_'.$this->src_map;
|
|
|
204 |
$img = imagecreatefromjpeg($this->cheminCartesBase.$this->src_map);
|
|
|
205 |
$img_cel = imagecreatefromjpeg($this->cheminCartesBase.$this->src_map);
|
|
|
206 |
$img_cenlr = imagecreatefromjpeg($this->cheminCartesBase.$this->src_map);
|
|
|
207 |
$img_cbnmed = imagecreatefromjpeg($this->cheminCartesBase.$this->src_map);
|
|
|
208 |
$img_sophy = imagecreatefromjpeg($this->cheminCartesBase.$this->src_map);
|
|
|
209 |
|
|
|
210 |
$retour = '<a name="topmap"></a>';
|
|
|
211 |
|
|
|
212 |
/*
|
|
|
213 |
* Les donnees issues du carnet en ligne sont recuperes directement, sans passer par le mecanisme de moissonage car :
|
|
|
214 |
* - pour l'instant le service de moissonage n'est pas automatise et donc il y a un decalage dans l'affichage des donnees transmises
|
|
|
215 |
* - la table contenant les donnees moissonees ne reprend pas tous les champs necessaires a l'exploitation par eflore (notamment pas de code localite, pas d'identifiant libre)
|
|
|
216 |
*
|
|
|
217 |
* A terme, utilser vraiment le moissonage, y compris pour les donnees issues du CEL, en utilisant ABCD et en modifiant le programme d'harvesting.
|
|
|
218 |
*/
|
|
|
219 |
$inventories = $this->recupererDonnees();
|
|
|
220 |
|
|
|
221 |
|
|
|
222 |
|
|
|
223 |
if (is_array($inventories)){
|
|
|
224 |
// D�finition des couleurs des points
|
|
|
225 |
// green
|
|
|
226 |
$green = imagecolorallocate($img, 0, 255, 0);
|
|
|
227 |
// red
|
|
|
228 |
$red = imagecolorallocate($img, 255, 0, 0);
|
|
|
229 |
// blue
|
|
|
230 |
$blue = imagecolorallocate($img, 0, 0, 255);
|
|
|
231 |
// purple
|
|
|
232 |
$purple = imagecolorallocate($img, 255, 0, 255);
|
|
|
233 |
// black
|
|
|
234 |
$black = imagecolorallocate($img, 0, 0, 0);
|
|
|
235 |
|
|
|
236 |
$i = 0;
|
|
|
237 |
$text = array();
|
|
|
238 |
$merge = array();
|
|
|
239 |
|
|
|
240 |
// Connection referentiel communes
|
|
|
241 |
$this->chargerVille();
|
|
|
242 |
|
|
|
243 |
foreach ($inventories as $inventory){
|
|
|
244 |
// On ne tient pas compte des coordonn�es x, y , positionnement en fonction de la commune uniquement
|
|
|
245 |
$location_protege = $this->getBdd()->proteger($inventory['location']);
|
|
|
246 |
$id_location_protege = $this->getBdd()->proteger($inventory['id_location']);
|
|
|
247 |
|
|
|
248 |
if ($inventory['collection_code'] == 'FLORE - VAR') {
|
|
|
249 |
if (isset($this->tab_code_insee[$location_protege])) {
|
|
|
250 |
$utm = array(0 => $this->tab_code_insee[$location_protege]);
|
|
|
251 |
}
|
|
|
252 |
} elseif ($inventory['collection_code'] == 'sophy') {
|
|
|
253 |
if (isset($this->tab_code_insee[$id_location_protege])) {
|
|
|
254 |
$utm = array(0 => $this->tab_code_insee[$id_location_protege]);
|
|
|
255 |
}
|
|
|
256 |
|
|
|
257 |
} else {
|
|
|
258 |
if ($inventory['id_location'] != 'null') {
|
|
|
259 |
$requete = "SELECT * ".
|
|
|
260 |
"FROM tb_cel.locations ".
|
|
|
261 |
"WHERE name LIKE $location_protege ".
|
|
|
262 |
" AND code = $id_location_protege ";
|
|
|
263 |
$utm = $this->getBdd()->recupererTous($requete);
|
|
|
264 |
} else {
|
|
|
265 |
$requete = "SELECT * FROM tb_cel.locations WHERE name LIKE $location_protege ";
|
|
|
266 |
$utm = $this->getBdd()->recupererTous($requete);
|
|
|
267 |
}
|
|
|
268 |
}
|
|
|
269 |
// Ultime tentative
|
|
|
270 |
if (!$utm) {
|
|
|
271 |
$requete = "SELECT * FROM tb_cel.locations WHERE name LIKE $location_protege ";
|
|
|
272 |
$utm = $this->getBdd()->recupererTous($requete);
|
|
|
273 |
}
|
|
|
274 |
|
|
|
275 |
// Si des doublons sur la commune : pas d'affichage , il vaut mieux ne rien afficher que d'afficher des erreurs.
|
|
|
276 |
if (sizeof($utm) == 1) {
|
|
|
277 |
|
|
|
278 |
$utm = $utm[0];
|
|
|
279 |
|
|
|
280 |
// On centre le point au milieu de la maille 10x10 par defaut ...
|
|
|
281 |
$pad = str_repeat ('0' ,(7 - strlen( $utm['x_utm'])));
|
|
|
282 |
$utm['x_utm'] = $pad.$utm['x_utm'];
|
|
|
283 |
|
|
|
284 |
$pad = str_repeat ('0' ,(7 - strlen( $utm['y_utm'])));
|
|
|
285 |
$utm['y_utm'] = $pad.$utm['y_utm'];
|
|
|
286 |
|
|
|
287 |
$utm['x_utm'] = substr($utm['x_utm'] ,0,3);
|
|
|
288 |
$utm['x_utm'] = $utm['x_utm'].'5000';
|
|
|
289 |
|
|
|
290 |
$utm['y_utm'] = substr($utm['y_utm'] ,0,3);
|
|
|
291 |
$utm['y_utm'] = $utm['y_utm'].'5000';
|
|
|
292 |
|
|
|
293 |
|
|
|
294 |
// Calcul coordonnes x, y sur l'image
|
|
|
295 |
// Fuseau 31 T
|
|
|
296 |
if ($utm['sector']=='31T') {
|
|
|
297 |
$x = (($utm['x_utm'] - $M_UTM_X1['31T']) * $p['31T'] ) + $Px_echelle_X1['31T'];
|
|
|
298 |
$y = $Px_echelle_Y2['31T'] - (($utm['y_utm'] - $M_UTM_Y1['31T']) * $p['31T'] );
|
|
|
299 |
} elseif ($utm['sector'] == '32T') {// Fuseau 32 T : une rotation + translation est appliqu�e
|
|
|
300 |
$cosa = cos(deg2rad($angle3132));
|
|
|
301 |
$sina = sin(deg2rad($angle3132));
|
|
|
302 |
|
|
|
303 |
$xp = (($utm['x_utm'] - $M_UTM_X1['32T']) * $cosa) + (($utm['y_utm']- $M_UTM_Y1['32T']) * $sina);
|
|
|
304 |
$yp = (-($utm['x_utm'] - $M_UTM_X1['32T'])* $sina) + (($utm['y_utm'] - $M_UTM_Y1['32T']) * $cosa);
|
|
|
305 |
$x = ($xp * $p['32T'] ) + $Px_echelle_X1['32T'];
|
|
|
306 |
$y = $Px_echelle_Y2['32T']-($yp * $p['32T'] );
|
|
|
307 |
} elseif ($utm['sector'] == '30T') {// Fuseau 30 T : une rotation + translation est appliqu�e
|
|
|
308 |
$cosa = cos(deg2rad($angle3031));
|
|
|
309 |
$sina = sin(deg2rad($angle3031));
|
|
|
310 |
|
|
|
311 |
$xp = (($utm['x_utm'] - $M_UTM_X1['30T']) * $cosa) + (($utm['y_utm'] - $M_UTM_Y1['30T']) * $sina);
|
|
|
312 |
$yp = (-($utm['x_utm'] - $M_UTM_X1['30T']) * $sina) + (($utm['y_utm'] - $M_UTM_Y1['30T']) * $cosa);
|
|
|
313 |
$x = ($xp * $p['30T'] ) + $Px_echelle_X1['30T'];
|
|
|
314 |
$y = $Px_echelle_Y2['30T'] - ($yp * $p['30T'] );
|
|
|
315 |
}
|
|
|
316 |
$x = round($x);
|
|
|
317 |
$y = round($y);
|
|
|
318 |
|
|
|
319 |
$comment = '';
|
|
|
320 |
if ($utm['name'] != null) {
|
|
|
321 |
$name = utf8_decode($utm['name']);
|
|
|
322 |
}
|
|
|
323 |
|
|
|
324 |
if ($inventory['date_observation'] != '0000-00-00 00:00:00') {
|
|
|
325 |
if ($inventory['collection_code'] == 'sophy') {
|
|
|
326 |
$comment .= ', en '.$inventory['date_observation'];
|
|
|
327 |
} else {
|
|
|
328 |
list($year, $month, $day) = explode ('-',$inventory['date_observation']);
|
|
|
329 |
list($day) = explode (' ',$day);
|
|
|
330 |
if ($month == '00') {
|
|
|
331 |
$comment .= ', en '.$year;
|
|
|
332 |
} else {
|
|
|
333 |
$comment .= ', le '.$day.'/'.$month.'/'.$year;
|
|
|
334 |
}
|
|
|
335 |
}
|
|
|
336 |
}
|
|
|
337 |
|
|
|
338 |
if ($inventory['collection_code'] == 'cel') {
|
|
|
339 |
list($identifiant) = explode("@", $inventory['identifiant']);
|
|
|
340 |
$comment .= " par ".$identifiant."@...";
|
|
|
341 |
} else {
|
|
|
342 |
$comment .= " par ".utf8_decode($inventory['identifiant']);
|
|
|
343 |
}
|
|
|
344 |
// On stocke les commentaires pour affichage dans les tooltips
|
|
|
345 |
// Commentaire deja pr�sent ? : on ajoute � la suite
|
|
|
346 |
|
|
|
347 |
list($text, $merge) = $this->stockerCommentaire($text, $merge, $name, $comment, $inventory['collection_code'],$x,$y);
|
|
|
348 |
|
|
|
349 |
|
|
|
350 |
}
|
|
|
351 |
|
|
|
352 |
$i++;
|
|
|
353 |
}
|
|
|
354 |
|
|
|
355 |
//print_r($text);
|
|
|
356 |
|
|
|
357 |
|
|
|
358 |
$usemap = '';
|
|
|
359 |
$usemap_cel = '';
|
|
|
360 |
$usemap_cenlr = '';
|
|
|
361 |
$usemap_cbnmed = '';
|
|
|
362 |
$usemap_sophy = '';
|
|
|
363 |
|
|
|
364 |
if ($text) {
|
|
|
365 |
foreach ($text as $coord => $origines ) {
|
|
|
366 |
foreach ($origines as $origine => $maptext ) {
|
|
|
367 |
$maptext = preg_replace("/\"/", "\'", $maptext);
|
|
|
368 |
|
|
|
369 |
list($x,$y) = explode('|', $coord);
|
|
|
370 |
|
|
|
371 |
$tpl_area = '<area shape="%s" alt="" class="tooltip" coords="%s" title="%s"/>';
|
|
|
372 |
$rayon = 2;
|
|
|
373 |
$type = 'circle';
|
|
|
374 |
$coords = "$x,$y,5";
|
|
|
375 |
$on_mouseover = "this.ttBgColor='#99C242';this.ttFontColor='#000000';this.T_OFFSETX=-200;this.T_OFFSETY=-50;this.T_STICKY=1;return escape('$maptext')";
|
|
|
376 |
|
|
|
377 |
switch ($origine) {
|
|
|
378 |
case 'FLORE - VAR': // cbnmed
|
|
|
379 |
imagefilledellipse($img_cbnmed, $x, $y, 7, 7, $blue);
|
|
|
380 |
$usemap_cbnmed = $usemap_cbnmed.sprintf($tpl_area, $type, $coords, $maptext);
|
|
|
381 |
break;
|
|
|
382 |
case 'cel':
|
|
|
383 |
imagefilledrectangle($img_cel, ($x - $rayon), ($y - $rayon), ($x + $rayon), ($y + $rayon), $green);
|
|
|
384 |
$coords = ($x - $rayon).','.($y - $rayon).','.($x + $rayon).','.($y + $rayon);
|
|
|
385 |
$usemap_cel = $usemap_cel.sprintf($tpl_area, 'rect', $coords, $maptext);
|
|
|
386 |
break;
|
|
|
387 |
case 'flore': // cenlr
|
|
|
388 |
imagefilledellipse($img_cenlr, $x, $y, 7, 7, $red);
|
|
|
389 |
$usemap_cenlr = $usemap_cenlr.sprintf($tpl_area, $type, $coords, $maptext);
|
|
|
390 |
break;
|
|
|
391 |
case 'sophy':
|
|
|
392 |
imagefilledrectangle($img_sophy, ($x - $rayon), ($y - $rayon), ($x + $rayon), ($y + $rayon), $purple);
|
|
|
393 |
$coords = ($x - $rayon).','.($y - $rayon).','.($x + $rayon).','.($y + $rayon);
|
|
|
394 |
$usemap_sophy = $usemap_sophy.sprintf($tpl_area, 'rect', $coords, $maptext);
|
|
|
395 |
break;
|
|
|
396 |
case 'tout':
|
|
|
397 |
if (isset($merge[$coord]) && $merge[$coord]) {
|
|
|
398 |
imagefilledrectangle($img, ($x - $rayon), ($y - $rayon), ($x + $rayon), ($y + $rayon), $black);
|
|
|
399 |
} elseif (isset ($text[$coord]['cel']) && ($text[$coord]['cel'])) {
|
|
|
400 |
imagefilledrectangle($img, ($x - $rayon), ($y - $rayon), ($x + $rayon), ($y + $rayon), $green);
|
|
|
401 |
} elseif (isset ($text[$coord]['flore']) && ($text[$coord]['flore'])) {
|
|
|
402 |
imagefilledrectangle($img, ($x - $rayon), ($y - $rayon), ($x + $rayon), ($y + $rayon), $red);
|
|
|
403 |
} elseif (isset ($text[$coord]['FLORE - VAR']) && ($text[$coord]['FLORE - VAR'])) {
|
|
|
404 |
imagefilledrectangle($img, ($x - $rayon), ($y - $rayon), ($x + $rayon), ($y + $rayon), $blue);
|
|
|
405 |
} elseif (isset ($text[$coord]['sophy']) && ($text[$coord]['sophy'])) {
|
|
|
406 |
imagefilledrectangle($img, ($x - $rayon), ($y - $rayon), ($x + $rayon), ($y + $rayon), $purple);
|
|
|
407 |
}
|
|
|
408 |
$usemap = $usemap.sprintf($tpl_area, $type, $coords, $maptext);
|
|
|
409 |
break;
|
|
|
410 |
|
|
|
411 |
}
|
|
|
412 |
//imagestring($img, 1, $x, $y, 7, 7, "hello", $fill);
|
|
|
413 |
// pas de double quote dans le texte
|
|
|
414 |
}
|
|
|
415 |
}
|
|
|
416 |
}
|
|
|
417 |
|
|
|
418 |
//imageinterlace($img,1);
|
|
|
419 |
$qualite = 90;
|
|
|
420 |
imagejpeg($img, Config::get('cache.stockageChemin').$dest_map, $qualite);
|
|
|
421 |
imagejpeg($img_cel, Config::get('cache.stockageChemin').$dest_map_cel, $qualite);
|
|
|
422 |
imagejpeg($img_cenlr, Config::get('cache.stockageChemin').$dest_map_cenlr, $qualite);
|
|
|
423 |
imagejpeg($img_cbnmed, Config::get('cache.stockageChemin').$dest_map_cbnmed, $qualite);
|
|
|
424 |
imagejpeg($img_sophy, Config::get('cache.stockageChemin').$dest_map_sophy, $qualite);
|
|
|
425 |
|
|
|
426 |
//imagedestroy($img);
|
|
|
427 |
|
|
|
428 |
$retour = '';
|
308 |
delphine |
429 |
if ($this->info['miniature'] !== 'min') {
|
303 |
delphine |
430 |
$retour.="<div id=\"descriptions\">";
|
|
|
431 |
$retour.="<h2 id=\"titre_description_general\">Données disponibles : </h2>";
|
|
|
432 |
$retour.= "<div id=\"description_defaut\" class=\"description\">";
|
|
|
433 |
$retour.= "<h3 style='display:none'><span class=\"affichage\">Toutes observations</span></h3>";
|
|
|
434 |
$retour.= "<div id =\"cartowikimap\" style=\"position:relative;\">";
|
|
|
435 |
$retour.= "<img src=\"".(Config::get('Cartes.cel_dst').$dest_map)."\" style=\"border:none; cursor:crosshair\" alt=\"\" usemap=\"#themap\" /><br />\n";
|
|
|
436 |
$retour.= "<map name=\"themap\" id=\"themap\">";
|
|
|
437 |
$retour.= $usemap;
|
|
|
438 |
$retour.= "</map>";
|
|
|
439 |
$retour.= "</map>";
|
|
|
440 |
|
|
|
441 |
$retour.= "</div>";
|
|
|
442 |
$retour.= "</div>";
|
|
|
443 |
|
|
|
444 |
|
|
|
445 |
$retour.= "<div id=\"description_1\" class=\"description\">";
|
|
|
446 |
$retour.= "<h3 style='display:none;background-color:rgb(0,255,0);color:black;'><span class=\"affichage\">Observations issues du Carnet en ligne</span></h3>";
|
|
|
447 |
$retour.= "<div id =\"cartowikimap\" style=\"position:relative;\">";
|
|
|
448 |
$retour.= "<img src=\"".(Config::get('Cartes.cel_dst').$dest_map_cel)."\" style=\"border:none; cursor:crosshair\" alt=\"\" usemap=\"#themapcel\"></img><br />\n";
|
|
|
449 |
$retour.= "<map name=\"themapcel\" id=\"themapcel\">";
|
|
|
450 |
$retour.= $usemap_cel;
|
|
|
451 |
$retour.= "</map>";
|
|
|
452 |
$retour.= "</div>";
|
|
|
453 |
$retour.= "</div>";
|
|
|
454 |
|
|
|
455 |
|
|
|
456 |
|
|
|
457 |
|
|
|
458 |
$retour.= "<div id=\"description_2\" class=\"description\">";
|
|
|
459 |
|
|
|
460 |
$retour.= "<h3 style='display:none;background-color:rgb(255,0,0);color:white;'><span class=\"affichage\">Prospection flore du CEN LR</span></h3>";
|
|
|
461 |
$retour.= "<div id =\"cartowikimapcenlr\" style=\"position:relative;\">";
|
|
|
462 |
$retour.= "<img src=\"".(Config::get('Cartes.cel_dst').$dest_map_cenlr)."\" style=\"border:none; cursor:crosshair\" alt=\"\" usemap=\"#themapcenlr\"></img><br />\n";
|
|
|
463 |
$retour.= "<map name=\"themapcenlr\" id=\"themapcenlr\">";
|
|
|
464 |
$retour.= $usemap_cenlr;
|
|
|
465 |
$retour.= "</map>";
|
|
|
466 |
$retour.= "</div>";
|
|
|
467 |
$retour.= "</div>";
|
|
|
468 |
|
|
|
469 |
|
|
|
470 |
|
|
|
471 |
$retour.= "<div id=\"description_3\" class=\"description\">";
|
|
|
472 |
|
|
|
473 |
$retour.= "<h3 style='display:none;background-color:rgb(0,0,255);color:white;'><span class=\"affichage\">Flore Silene</span></h3>";
|
|
|
474 |
$retour.= "<div id =\"cartowikimapcbnmed\" style=\"position:relative;\">";
|
|
|
475 |
$retour.= "<img src=\"".(Config::get('Cartes.cel_dst').$dest_map_cbnmed)."\" style=\"border:none; cursor:crosshair\" alt=\"\" usemap=\"#themapcbnmed\"></img><br />\n";
|
|
|
476 |
$retour.= "<map name=\"themapcbnmed\" id=\"themapcbnmed\">";
|
|
|
477 |
$retour.= $usemap_cbnmed;
|
|
|
478 |
$retour.= "</map>";
|
|
|
479 |
$retour.= "</div>";
|
|
|
480 |
$retour.= "</div>";
|
|
|
481 |
|
|
|
482 |
|
|
|
483 |
$retour.= "<div id=\"description_4\" class=\"description\">";
|
|
|
484 |
|
|
|
485 |
$retour.= "<h3 style='display:none;background-color:rgb(255,0,255);color:white;'><span class=\"affichage\">Observations issues de la base SOPHY</span></h3>";
|
|
|
486 |
$retour.= "<div id =\"cartowikimapsophy\" style=\"position:relative;\">";
|
|
|
487 |
$retour.= "<img src=\"".(Config::get('Cartes.cel_dst').$dest_map_sophy)."\" style=\"border:none; cursor:crosshair\" alt=\"\" usemap=\"#themapsophy\"></img><br />\n";
|
|
|
488 |
$retour.= "<map name=\"themapsophy\" id=\"themapsophy\">";
|
|
|
489 |
$retour.= $usemap_sophy;
|
|
|
490 |
$retour.= "</map>";
|
|
|
491 |
$retour.= "</div>";
|
|
|
492 |
$retour.= "</div>";
|
|
|
493 |
|
|
|
494 |
$retour.= "</div>";
|
|
|
495 |
} else { // miniature
|
|
|
496 |
$retour.= "<div id =\"cartowikimap\" style=\"position:relative;\">";
|
|
|
497 |
//$retour.= "<a href=".$param['url_onglet_cel'].">"; //lien vers grande image
|
|
|
498 |
$retour.= "<img src=\"".(Config::get('Cartes.cel_dst').$dest_map)."\" style=\"border:none; cursor:crosshair\" alt=\"\" usemap=\"#themap\"></img><br />\n";
|
|
|
499 |
//$retour.= "</a>";
|
|
|
500 |
$retour.= "<map name=\"themap\" id=\"themap\">";
|
|
|
501 |
$retour.= $usemap;
|
|
|
502 |
$retour.= "</map>";
|
|
|
503 |
$retour.= "</div>";
|
|
|
504 |
}
|
|
|
505 |
} else {
|
|
|
506 |
$retour.= "<map name=\"themap\" id=\"themap\">";
|
|
|
507 |
$retour.= "<img src=\"".Config.get('cartes.chemin').$this->src_map."\" style=\"border:none; cursor:crosshair\" alt=\"\" />\n";
|
|
|
508 |
$retour.= "</map>";
|
|
|
509 |
}
|
|
|
510 |
return $retour;
|
|
|
511 |
}
|
|
|
512 |
|
|
|
513 |
|
|
|
514 |
|
|
|
515 |
/*
|
|
|
516 |
* Stockage commentaire associe a un point :
|
|
|
517 |
*
|
|
|
518 |
* Param :
|
|
|
519 |
* @text : texte cumule
|
|
|
520 |
* @merge : indicateur de commentaire fusionne
|
|
|
521 |
* @name : commune associee
|
|
|
522 |
* @comment : commentaire
|
|
|
523 |
* @origine : origine de la donnee
|
|
|
524 |
*
|
|
|
525 |
*
|
|
|
526 |
* TODO : rendre cette fonction independante des valeurs d'origine passee en parametre
|
|
|
527 |
*/
|
|
|
528 |
private function stockerCommentaire($text, $merge, $name, $comment, $origine, $x, $y) {
|
|
|
529 |
if ($origine == 'cel') {
|
|
|
530 |
$prefix = 'CEL : ';
|
|
|
531 |
} elseif ($origine == 'flore') {
|
|
|
532 |
$prefix = 'CEN LR : ';
|
|
|
533 |
} elseif ($origine == 'FLORE - VAR') {
|
|
|
534 |
$prefix = 'CBN MED : ';
|
|
|
535 |
} elseif ($origine == 'sophy') {
|
|
|
536 |
$prefix = 'SOPHY : ';
|
|
|
537 |
}
|
|
|
538 |
|
|
|
539 |
// Cumul toute origine :
|
|
|
540 |
if (isset($text[$x.'|'.$y]['tout']) && ($text[$x.'|'.$y])) {
|
|
|
541 |
$text[$x.'|'.$y]['tout'] = $text[$x.'|'.$y]['tout'].'<br>'.$prefix.$name.$comment;
|
|
|
542 |
} else {
|
|
|
543 |
// Nouveau commentaire
|
|
|
544 |
$text[$x.'|'.$y]['tout']=$prefix.$name.$comment;
|
|
|
545 |
}
|
|
|
546 |
|
|
|
547 |
// Deja present pour cette origine ? on ajoute
|
|
|
548 |
if (isset ($text[$x.'|'.$y][$origine]) && ($text[$x.'|'.$y][$origine])) {
|
|
|
549 |
$text[$x.'|'.$y][$origine] = $text[$x.'|'.$y][$origine].'<br>'.$name.$comment;
|
|
|
550 |
} else { // Nouveau commentaire
|
|
|
551 |
$text[$x.'|'.$y][$origine] = $name.$comment;
|
|
|
552 |
}
|
|
|
553 |
|
|
|
554 |
|
|
|
555 |
// Detection superposition de donnee
|
|
|
556 |
if ($origine == 'cel') {
|
|
|
557 |
if ((isset ($text[$x.'|'.$y]['sophy']) && ($text[$x.'|'.$y]['sophy'])) || (isset ($text[$x.'|'.$y]['flore']) && ($text[$x.'|'.$y]['flore']))
|
|
|
558 |
|| (isset ($text[$x.'|'.$y]['FLORE - VAR']) && ($text[$x.'|'.$y]['FLORE - VAR']))) {
|
|
|
559 |
$merge[$x.'|'.$y]=true;
|
|
|
560 |
}
|
|
|
561 |
} elseif ($origine == 'flore') {
|
|
|
562 |
if ((isset ($text[$x.'|'.$y]['sophy']) && ($text[$x.'|'.$y]['sophy'])) ||(isset ($text[$x.'|'.$y]['cel']) && ($text[$x.'|'.$y]['cel'])) ||
|
|
|
563 |
(isset ($text[$x.'|'.$y]['FLORE - VAR']) && ($text[$x.'|'.$y]['FLORE - VAR']))) {
|
|
|
564 |
$merge[$x.'|'.$y]=true;
|
|
|
565 |
}
|
|
|
566 |
} elseif ($origine == 'FLORE - VAR') {
|
|
|
567 |
if ((isset ($text[$x.'|'.$y]['sophy']) && ($text[$x.'|'.$y]['sophy'])) || (isset ($text[$x.'|'.$y]['cel']) && ($text[$x.'|'.$y]['cel'])) ||
|
|
|
568 |
(isset ($text[$x.'|'.$y]['flore']) && ($text[$x.'|'.$y]['flore']))) {
|
|
|
569 |
$merge[$x.'|'.$y]=true;
|
|
|
570 |
}
|
|
|
571 |
} elseif ($origine == 'sophy') {
|
|
|
572 |
if ((isset ($text[$x.'|'.$y]['cel']) && ($text[$x.'|'.$y]['cel'])) || (isset ($text[$x.'|'.$y]['flore']) && ($text[$x.'|'.$y]['flore'])||
|
|
|
573 |
(isset ($text[$x.'|'.$y]['FLORE - VAR']) && ($text[$x.'|'.$y]['FLORE - VAR'])))) {
|
|
|
574 |
$merge[$x.'|'.$y]=true;
|
|
|
575 |
}
|
|
|
576 |
}
|
|
|
577 |
|
|
|
578 |
return array($text, $merge);
|
|
|
579 |
}
|
|
|
580 |
|
|
|
581 |
|
|
|
582 |
|
|
|
583 |
//+------------------------------------------------------------------------------------------------------+
|
|
|
584 |
// Méthodes d'accès aux objets du Framework
|
|
|
585 |
/**
|
|
|
586 |
* Méthode de connection à la base de données sur demande.
|
|
|
587 |
* Tous les services web n'ont pas besoin de s'y connecter.
|
|
|
588 |
*/
|
|
|
589 |
protected function getBdd() {
|
|
|
590 |
if (! isset($this->Bdd)) {
|
|
|
591 |
$this->Bdd = new Bdd();
|
|
|
592 |
}
|
|
|
593 |
return $this->Bdd;
|
|
|
594 |
}
|
|
|
595 |
|
|
|
596 |
private function chargerVille() {
|
|
|
597 |
$requete = "SELECT * FROM tb_cel.locations";
|
|
|
598 |
$villes = $this->getBdd()->recupererTous($requete);
|
|
|
599 |
foreach ($villes as $ville) {
|
|
|
600 |
$this->tab_code_insee[$ville['insee_code']] = $ville;
|
|
|
601 |
}
|
|
|
602 |
}
|
|
|
603 |
|
|
|
604 |
public function recupererDonnees() {
|
|
|
605 |
// Recherche nom correspondant au numero nomenclatural en cours (pour etablir le lien avec les donnees moissonnes).
|
|
|
606 |
|
|
|
607 |
// R�cuperation donn�e inventaire
|
|
|
608 |
$queryCel = "SELECT 'cel' as collection_code, location, id_location, date_observation, ".
|
|
|
609 |
" coord_y as y_utm, coord_x as x_utm, ref_geo as sector, identifiant FROM tb_cel.cel_inventory ".
|
|
|
610 |
"WHERE num_taxon = '".$this->info['nt']."' ".
|
|
|
611 |
" AND transmission = 1";
|
|
|
612 |
$inventoriesCel = $this->getBdd()->recupererTous($queryCel);
|
|
|
613 |
|
|
|
614 |
// Recuperation des donnees de moissonage
|
|
|
615 |
// Collection code = 'flore' (Cenlr)
|
|
|
616 |
$queryCenlr = "SELECT collection_code, locality as location, county as id_location, ".
|
|
|
617 |
" STR_TO_DATE(concat(year, '/',month, '/',day), '%Y/%m/%d') as date_observation, latitude as y_utm , ".
|
|
|
618 |
" longitude as x_utm , max_altitude as sector, collector_name as identifiant ".
|
|
|
619 |
"FROM tb_hit_indexation.raw_occurrence_record ".
|
308 |
delphine |
620 |
"WHERE scientific_name = ".$this->getBdd()->proteger($this->info['nom']).
|
303 |
delphine |
621 |
" AND collection_code = 'flore' ".
|
|
|
622 |
" AND deleted IS NULL";
|
|
|
623 |
$inventoriesCenlr = $this->getBdd()->recupererTous($queryCenlr);
|
|
|
624 |
|
|
|
625 |
|
|
|
626 |
// Collection code = 'FLORE - VAR' (Cbnmed)
|
|
|
627 |
$queryCbnmed = "SELECT collection_code, locality as location, county as id_location, ".
|
|
|
628 |
" STR_TO_DATE(concat(ifnull(year,0),'/', ifnull(month,0), '/',ifnull(day,0)), '%Y/%m/%d') as date_observation, ".
|
|
|
629 |
" latitude as y_utm , longitude as x_utm , max_altitude as sector, collector_name as identifiant ".
|
|
|
630 |
"FROM tb_hit_indexation.raw_occurrence_record ".
|
308 |
delphine |
631 |
"WHERE scientific_name = ".$this->getBdd()->proteger($this->info['nom']).
|
303 |
delphine |
632 |
" AND collection_code='FLORE - VAR' ".
|
|
|
633 |
" AND (deleted IS NULL OR deleted = '0000-00-00 00:00:00')";
|
|
|
634 |
$inventoriesCbnmed = $this->getBdd()->recupererTous($queryCbnmed);
|
|
|
635 |
|
|
|
636 |
// Collection code = 'sophy'
|
|
|
637 |
$querySophy = "SELECT 'sophy' as collection_code, lieu_station_nom as location, lieu_commune_code_insee as id_location, ".
|
|
|
638 |
" observation_date as date_observation, lieu_station_utm_est as x_utm , ".
|
|
|
639 |
" lieu_station_utm_nord as y_utm , lieu_station_utm_zone as sector, observateur_nom_complet as identifiant ".
|
|
|
640 |
"FROM sophy_tapir ".
|
308 |
delphine |
641 |
"WHERE nom_scientifique_complet = ".$this->getBdd()->proteger($this->info['nom_ss_auteur']);
|
303 |
delphine |
642 |
$inventoriesSophy = $this->getBdd()->recupererTous($querySophy);
|
|
|
643 |
|
|
|
644 |
return array_merge($inventoriesCel, $inventoriesCenlr, $inventoriesCbnmed, $inventoriesSophy);
|
|
|
645 |
}
|
|
|
646 |
|
|
|
647 |
}
|
|
|
648 |
?>
|