Subversion Repositories eFlore/Projets.eflore-projets

Rev

Rev 308 | Go to most recent revision | Details | Last modification | View Log | RSS feed

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