314 |
delphine |
1 |
<?php
|
|
|
2 |
class CenlrFormateur implements Formateur {
|
|
|
3 |
public $dest_map = array();
|
|
|
4 |
public $img = array();
|
315 |
delphine |
5 |
public function __construct($info) {
|
314 |
delphine |
6 |
$this->info = $info;
|
|
|
7 |
}
|
|
|
8 |
public function img() {
|
320 |
aurelien |
9 |
$qualite = 9;
|
|
|
10 |
imagepng($this->img['cenlr'], Config::get('cache.stockageChemin').$this->dest_map['cenlr'], $qualite);
|
314 |
delphine |
11 |
}
|
|
|
12 |
//+----------------------------------------------------------------------------------------------------------------+
|
|
|
13 |
// Méthodes d'accès aux objets du Framework
|
|
|
14 |
/**
|
|
|
15 |
* Méthode de connection à la base de données sur demande.
|
|
|
16 |
* Tous les services web n'ont pas besoin de s'y connecter.
|
|
|
17 |
*/
|
|
|
18 |
protected function getBdd() {
|
|
|
19 |
if (! isset($this->Bdd)) {
|
|
|
20 |
$this->Bdd = new Bdd();
|
|
|
21 |
}
|
|
|
22 |
return $this->Bdd;
|
|
|
23 |
}
|
|
|
24 |
|
|
|
25 |
public function definirCouleurs() {
|
|
|
26 |
// green
|
|
|
27 |
$couleur['green'] = imagecolorallocate($this->img['cenlr'], 0, 255, 0);
|
|
|
28 |
// red
|
|
|
29 |
$couleur['red'] = imagecolorallocate($this->img['cenlr'], 255, 0, 0);
|
|
|
30 |
// blue
|
|
|
31 |
$couleur['blue'] = imagecolorallocate($this->img['cenlr'], 0, 0, 255);
|
|
|
32 |
// purple
|
|
|
33 |
$couleur['purple'] = imagecolorallocate($this->img['cenlr'], 255, 0, 255);
|
|
|
34 |
// black
|
|
|
35 |
$couleur['black'] = imagecolorallocate($this->img['cenlr'], 0, 0, 0);
|
|
|
36 |
return $couleur;
|
|
|
37 |
}
|
|
|
38 |
public function initialiserImage() {
|
|
|
39 |
// Nom du fichier image en sortie
|
|
|
40 |
$this->cheminCartesBase = Config::get('Cartes.chemin');
|
|
|
41 |
$this->dest_map['cenlr'] = 'cenlr_nt'.$this->info['nt'].'_'.$this->info['src_map'];
|
320 |
aurelien |
42 |
$this->img['cenlr'] = imagecreatefrompng($this->cheminCartesBase.$this->info['src_map']);
|
314 |
delphine |
43 |
}
|
|
|
44 |
|
362 |
delphine |
45 |
public function testerParametresProjets() {
|
|
|
46 |
$test = true;
|
|
|
47 |
if ($this->info['nom'] == '') {
|
|
|
48 |
$test = false;
|
|
|
49 |
}
|
|
|
50 |
return $test;
|
|
|
51 |
}
|
|
|
52 |
|
314 |
delphine |
53 |
public function chargerDonnees() {
|
|
|
54 |
// Collection code = 'flore' (Cenlr)
|
|
|
55 |
$queryCenlr = "SELECT collection_code, locality as location, county as id_location, ".
|
|
|
56 |
" STR_TO_DATE(concat(year, '/',month, '/',day), '%Y/%m/%d') as date_observation, latitude as y_utm , ".
|
|
|
57 |
" longitude as x_utm , max_altitude as sector, collector_name as identifiant ".
|
|
|
58 |
"FROM tb_hit_indexation.raw_occurrence_record ".
|
|
|
59 |
"WHERE scientific_name = ".$this->getBdd()->proteger($this->info['nom']).
|
|
|
60 |
" AND collection_code = 'flore' ".
|
|
|
61 |
" AND (deleted IS NULL OR deleted = '0000-00-00 00:00:00')";
|
|
|
62 |
$inventoriesCenlr = $this->getBdd()->recupererTous($queryCenlr);
|
|
|
63 |
return $inventoriesCenlr;
|
|
|
64 |
}
|
|
|
65 |
|
|
|
66 |
|
|
|
67 |
public function dessinerPoint($text, $merge, $couleurs) {
|
|
|
68 |
$usemap['cenlr'] = '';
|
|
|
69 |
|
|
|
70 |
foreach ($text as $coord => $origines ) {
|
|
|
71 |
foreach ($origines as $origine => $maptext ) {
|
|
|
72 |
$maptext = preg_replace("/\"/", "\'", $maptext);
|
|
|
73 |
|
|
|
74 |
list($x,$y) = explode('|', $coord);
|
|
|
75 |
|
|
|
76 |
$tpl_area = '<area shape="%s" alt="" class="tooltip" coords="%s" title="%s"/>';
|
|
|
77 |
$rayon = 2;
|
|
|
78 |
$type = 'circle';
|
|
|
79 |
$coords = "$x,$y,5";
|
|
|
80 |
$on_mouseover = "this.ttBgColor='#99C242';this.ttFontColor='#000000';this.T_OFFSETX=-200;this.T_OFFSETY=-50;this.T_STICKY=1;return escape('$maptext')";
|
|
|
81 |
|
|
|
82 |
imagefilledellipse($this->img['cenlr'], $x, $y, 7, 7, $couleurs['red']);
|
|
|
83 |
$usemap['cenlr'] = $usemap['cenlr'].sprintf($tpl_area, $type, $coords, $maptext);
|
|
|
84 |
}
|
|
|
85 |
}
|
|
|
86 |
return $usemap;
|
|
|
87 |
}
|
|
|
88 |
|
|
|
89 |
public function formaterCartes($usemap) {
|
315 |
delphine |
90 |
$retour = Config::get('Cartes.cel_dst').$this->dest_map['cenlr'];
|
|
|
91 |
if ($this->info['retour'] == self::MIME_MAP) {
|
|
|
92 |
$retour = "<img src=\"".$retour."\" style=\"border:none; ".
|
|
|
93 |
"cursor:crosshair\" alt=\"\" usemap=\"#themap\" /><br />\n".
|
|
|
94 |
"<map name=\"themap\" id=\"themap\">".utf8_encode($usemap['cenlr'])."</map>";
|
|
|
95 |
}
|
314 |
delphine |
96 |
return $retour;
|
|
|
97 |
}
|
|
|
98 |
|
|
|
99 |
//+----------------------------------------------------------------------------------------------------------------+
|
|
|
100 |
// sous fonction de calculer répartition
|
|
|
101 |
public function chercherVille($inventory, $tab_code_insee = array()) {
|
|
|
102 |
return $utm = '';
|
|
|
103 |
}
|
|
|
104 |
|
|
|
105 |
public function formerCommentaire($utm, $inventory) {
|
|
|
106 |
$comment = '';
|
|
|
107 |
|
|
|
108 |
if ($inventory['date_observation'] != '0000-00-00 00:00:00') {
|
|
|
109 |
$comment .= $this->formerDate($inventory);
|
|
|
110 |
}
|
|
|
111 |
|
|
|
112 |
$comment .= " par ".utf8_decode($inventory['identifiant']);
|
|
|
113 |
return $comment;
|
|
|
114 |
}
|
|
|
115 |
|
|
|
116 |
public function formerDate($inventory) {
|
|
|
117 |
list($year, $month, $day) = explode ('-',$inventory['date_observation']);
|
|
|
118 |
list($day) = explode (' ',$day);
|
|
|
119 |
if ($month == '00') {
|
|
|
120 |
$date = ', en '.$year;
|
|
|
121 |
} else {
|
|
|
122 |
$date = ', le '.$day.'/'.$month.'/'.$year;
|
|
|
123 |
}
|
|
|
124 |
return $date;
|
|
|
125 |
}
|
|
|
126 |
|
|
|
127 |
public function stockerCommentaire($text, $merge, $name, $comment, $origine, $x, $y) {
|
|
|
128 |
$prefix = 'CEN LR : ';
|
|
|
129 |
|
|
|
130 |
// Deja present pour cette origine ? on ajoute
|
|
|
131 |
if (isset ($text[$x.'|'.$y][$origine]) && ($text[$x.'|'.$y][$origine])) {
|
|
|
132 |
$text[$x.'|'.$y][$origine] = $text[$x.'|'.$y][$origine].'<br>'.$name.$comment;
|
|
|
133 |
} else { // Nouveau commentaire
|
|
|
134 |
$text[$x.'|'.$y][$origine] = $name.$comment;
|
|
|
135 |
}
|
|
|
136 |
|
|
|
137 |
|
|
|
138 |
// Detection superposition de donnee
|
|
|
139 |
if ((isset ($text[$x.'|'.$y]['sophy']) && ($text[$x.'|'.$y]['sophy'])) ||(isset ($text[$x.'|'.$y]['cel']) && ($text[$x.'|'.$y]['cel'])) ||
|
|
|
140 |
(isset ($text[$x.'|'.$y]['FLORE - VAR']) && ($text[$x.'|'.$y]['FLORE - VAR']))) {
|
|
|
141 |
$merge[$x.'|'.$y]=true;
|
|
|
142 |
}
|
|
|
143 |
|
|
|
144 |
return array($text, $merge);
|
|
|
145 |
}
|
|
|
146 |
|
|
|
147 |
|
|
|
148 |
|
|
|
149 |
}
|
|
|
150 |
?>
|