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() {
|
|
|
9 |
$qualite = 90;
|
|
|
10 |
imagejpeg($this->img['cenlr'], Config::get('cache.stockageChemin').$this->dest_map['cenlr'], $qualite);
|
|
|
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'];
|
|
|
42 |
$this->img['cenlr'] = imagecreatefromjpeg($this->cheminCartesBase.$this->info['src_map']);
|
|
|
43 |
}
|
|
|
44 |
|
|
|
45 |
public function chargerDonnees() {
|
|
|
46 |
// Collection code = 'flore' (Cenlr)
|
|
|
47 |
$queryCenlr = "SELECT collection_code, locality as location, county as id_location, ".
|
|
|
48 |
" STR_TO_DATE(concat(year, '/',month, '/',day), '%Y/%m/%d') as date_observation, latitude as y_utm , ".
|
|
|
49 |
" longitude as x_utm , max_altitude as sector, collector_name as identifiant ".
|
|
|
50 |
"FROM tb_hit_indexation.raw_occurrence_record ".
|
|
|
51 |
"WHERE scientific_name = ".$this->getBdd()->proteger($this->info['nom']).
|
|
|
52 |
" AND collection_code = 'flore' ".
|
|
|
53 |
" AND (deleted IS NULL OR deleted = '0000-00-00 00:00:00')";
|
|
|
54 |
$inventoriesCenlr = $this->getBdd()->recupererTous($queryCenlr);
|
|
|
55 |
return $inventoriesCenlr;
|
|
|
56 |
}
|
|
|
57 |
|
|
|
58 |
|
|
|
59 |
public function dessinerPoint($text, $merge, $couleurs) {
|
|
|
60 |
$usemap['cenlr'] = '';
|
|
|
61 |
|
|
|
62 |
foreach ($text as $coord => $origines ) {
|
|
|
63 |
foreach ($origines as $origine => $maptext ) {
|
|
|
64 |
$maptext = preg_replace("/\"/", "\'", $maptext);
|
|
|
65 |
|
|
|
66 |
list($x,$y) = explode('|', $coord);
|
|
|
67 |
|
|
|
68 |
$tpl_area = '<area shape="%s" alt="" class="tooltip" coords="%s" title="%s"/>';
|
|
|
69 |
$rayon = 2;
|
|
|
70 |
$type = 'circle';
|
|
|
71 |
$coords = "$x,$y,5";
|
|
|
72 |
$on_mouseover = "this.ttBgColor='#99C242';this.ttFontColor='#000000';this.T_OFFSETX=-200;this.T_OFFSETY=-50;this.T_STICKY=1;return escape('$maptext')";
|
|
|
73 |
|
|
|
74 |
imagefilledellipse($this->img['cenlr'], $x, $y, 7, 7, $couleurs['red']);
|
|
|
75 |
$usemap['cenlr'] = $usemap['cenlr'].sprintf($tpl_area, $type, $coords, $maptext);
|
|
|
76 |
}
|
|
|
77 |
}
|
|
|
78 |
return $usemap;
|
|
|
79 |
}
|
|
|
80 |
|
|
|
81 |
public function formaterCartes($usemap) {
|
315 |
delphine |
82 |
$retour = Config::get('Cartes.cel_dst').$this->dest_map['cenlr'];
|
|
|
83 |
if ($this->info['retour'] == self::MIME_MAP) {
|
|
|
84 |
$retour = "<img src=\"".$retour."\" style=\"border:none; ".
|
|
|
85 |
"cursor:crosshair\" alt=\"\" usemap=\"#themap\" /><br />\n".
|
|
|
86 |
"<map name=\"themap\" id=\"themap\">".utf8_encode($usemap['cenlr'])."</map>";
|
|
|
87 |
}
|
314 |
delphine |
88 |
return $retour;
|
|
|
89 |
}
|
|
|
90 |
|
|
|
91 |
//+----------------------------------------------------------------------------------------------------------------+
|
|
|
92 |
// sous fonction de calculer répartition
|
|
|
93 |
public function chercherVille($inventory, $tab_code_insee = array()) {
|
|
|
94 |
return $utm = '';
|
|
|
95 |
}
|
|
|
96 |
|
|
|
97 |
public function formerCommentaire($utm, $inventory) {
|
|
|
98 |
$comment = '';
|
|
|
99 |
|
|
|
100 |
if ($inventory['date_observation'] != '0000-00-00 00:00:00') {
|
|
|
101 |
$comment .= $this->formerDate($inventory);
|
|
|
102 |
}
|
|
|
103 |
|
|
|
104 |
$comment .= " par ".utf8_decode($inventory['identifiant']);
|
|
|
105 |
return $comment;
|
|
|
106 |
}
|
|
|
107 |
|
|
|
108 |
public function formerDate($inventory) {
|
|
|
109 |
list($year, $month, $day) = explode ('-',$inventory['date_observation']);
|
|
|
110 |
list($day) = explode (' ',$day);
|
|
|
111 |
if ($month == '00') {
|
|
|
112 |
$date = ', en '.$year;
|
|
|
113 |
} else {
|
|
|
114 |
$date = ', le '.$day.'/'.$month.'/'.$year;
|
|
|
115 |
}
|
|
|
116 |
return $date;
|
|
|
117 |
}
|
|
|
118 |
|
|
|
119 |
public function stockerCommentaire($text, $merge, $name, $comment, $origine, $x, $y) {
|
|
|
120 |
$prefix = 'CEN LR : ';
|
|
|
121 |
|
|
|
122 |
// Deja present pour cette origine ? on ajoute
|
|
|
123 |
if (isset ($text[$x.'|'.$y][$origine]) && ($text[$x.'|'.$y][$origine])) {
|
|
|
124 |
$text[$x.'|'.$y][$origine] = $text[$x.'|'.$y][$origine].'<br>'.$name.$comment;
|
|
|
125 |
} else { // Nouveau commentaire
|
|
|
126 |
$text[$x.'|'.$y][$origine] = $name.$comment;
|
|
|
127 |
}
|
|
|
128 |
|
|
|
129 |
|
|
|
130 |
// Detection superposition de donnee
|
|
|
131 |
if ((isset ($text[$x.'|'.$y]['sophy']) && ($text[$x.'|'.$y]['sophy'])) ||(isset ($text[$x.'|'.$y]['cel']) && ($text[$x.'|'.$y]['cel'])) ||
|
|
|
132 |
(isset ($text[$x.'|'.$y]['FLORE - VAR']) && ($text[$x.'|'.$y]['FLORE - VAR']))) {
|
|
|
133 |
$merge[$x.'|'.$y]=true;
|
|
|
134 |
}
|
|
|
135 |
|
|
|
136 |
return array($text, $merge);
|
|
|
137 |
}
|
|
|
138 |
|
|
|
139 |
|
|
|
140 |
|
|
|
141 |
}
|
|
|
142 |
?>
|