Subversion Repositories eFlore/Projets.eflore-projets

Rev

Rev 314 | Rev 320 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

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