Subversion Repositories eFlore/Projets.eflore-projets

Rev

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

Rev Author Line No. Line
314 delphine 1
<?php
2
class CenlrFormateur implements Formateur {
3
	public $dest_map = array();
4
	public $img = array();
5
	public function __construct($parametres, $info) {
6
		$this->param = $parametres;
7
		$this->info = $info;
8
	}
9
	public function img() {
10
		$qualite = 90;
11
		imagejpeg($this->img['cenlr'], Config::get('cache.stockageChemin').$this->dest_map['cenlr'], $qualite);
12
	}
13
	//+----------------------------------------------------------------------------------------------------------------+
14
	// Méthodes d'accès aux objets du Framework
15
	/**
16
	* Méthode de connection à la base de données sur demande.
17
	* Tous les services web n'ont pas besoin de s'y connecter.
18
	*/
19
	protected function getBdd() {
20
	if (! isset($this->Bdd)) {
21
	$this->Bdd = new Bdd();
22
	}
23
	return $this->Bdd;
24
	}
25
 
26
	public function definirCouleurs() {
27
	// green
28
	$couleur['green'] = imagecolorallocate($this->img['cenlr'], 0, 255, 0);
29
	// red
30
	$couleur['red'] = imagecolorallocate($this->img['cenlr'], 255, 0, 0);
31
	// blue
32
	$couleur['blue'] = imagecolorallocate($this->img['cenlr'], 0, 0, 255);
33
	// purple
34
	$couleur['purple'] = imagecolorallocate($this->img['cenlr'], 255, 0, 255);
35
	// black
36
	$couleur['black'] = imagecolorallocate($this->img['cenlr'], 0, 0, 0);
37
	return $couleur;
38
	}
39
	public function initialiserImage() {
40
		// Nom du fichier image en sortie
41
		$this->cheminCartesBase = Config::get('Cartes.chemin');
42
		$this->dest_map['cenlr'] = 'cenlr_nt'.$this->info['nt'].'_'.$this->info['src_map'];
43
		$this->img['cenlr'] = imagecreatefromjpeg($this->cheminCartesBase.$this->info['src_map']);
44
	}
45
 
46
	public function chargerDonnees() {
47
		// Collection code = 'flore' (Cenlr)
48
		$queryCenlr = "SELECT collection_code, locality as location, county as id_location, ".
49
							"	STR_TO_DATE(concat(year, '/',month, '/',day), '%Y/%m/%d') as date_observation, latitude as y_utm , ".
50
					    	"	longitude as x_utm , max_altitude as sector,  collector_name as identifiant ".
51
							"FROM tb_hit_indexation.raw_occurrence_record ".
52
							"WHERE scientific_name = ".$this->getBdd()->proteger($this->info['nom']).
53
							"	AND collection_code = 'flore' ".
54
							"	AND (deleted IS NULL OR deleted = '0000-00-00 00:00:00')";
55
		$inventoriesCenlr = $this->getBdd()->recupererTous($queryCenlr);
56
		return $inventoriesCenlr;
57
	}
58
 
59
 
60
	public function dessinerPoint($text, $merge, $couleurs) {
61
		$usemap['cenlr'] = '';
62
 
63
		foreach ($text as $coord => $origines ) {
64
			foreach ($origines as $origine => $maptext ) {
65
				$maptext = preg_replace("/\"/", "\'", $maptext);
66
 
67
				list($x,$y) = explode('|', $coord);
68
 
69
				$tpl_area = '<area shape="%s" alt="" class="tooltip" coords="%s" title="%s"/>';
70
				$rayon = 2;
71
				$type = 'circle';
72
				$coords = "$x,$y,5";
73
				$on_mouseover = "this.ttBgColor='#99C242';this.ttFontColor='#000000';this.T_OFFSETX=-200;this.T_OFFSETY=-50;this.T_STICKY=1;return escape('$maptext')";
74
 
75
				imagefilledellipse($this->img['cenlr'], $x, $y, 7, 7, $couleurs['red']);
76
				$usemap['cenlr'] = $usemap['cenlr'].sprintf($tpl_area, $type, $coords, $maptext);
77
			}
78
		}
79
		return $usemap;
80
	}
81
 
82
	public function formaterCartes($usemap) {
83
		$retour =  "<img src=\"".(Config::get('Cartes.cel_dst').$this->dest_map['cenlr'])."\" style=\"border:none; cursor:crosshair\" alt=\"\" usemap=\"#themapcenlr\"></img><br />\n";
84
		$retour .=  "<map name=\"themapcenlr\" id=\"themapcenlr\">";
85
		$retour .=  $usemap['cenlr'];
86
		$retour .=  "</map>";
87
 
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
?>