Subversion Repositories eFlore/Projets.eflore-projets

Rev

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

Rev 505 Rev 507
1
<?php
1
<?php
2
/**
2
/**
3
* Classe GraphiquesBaseflor.php transforme les données écologiques de la table baseflor
3
* Classe GraphiquesBaseflor.php transforme les données écologiques de la table baseflor
4
*  en graphique svg
4
*  en graphique svg
5
*  graphiques/#typegraphique/#bdnt.nn:#num_nomen --> renvoie un graphique avec les données connues
5
*  graphiques/#typegraphique/#bdnt.nn:#num_nomen --> renvoie un graphique avec les données connues
6
*
6
*
7
*
7
*
8
* @package eflore-projets
8
* @package eflore-projets
9
* @author Jean-Pascal MILCENT <jpm@tela-botanica.org>
9
* @author Jean-Pascal MILCENT <jpm@tela-botanica.org>
10
* @author Mathilde SALTHUN-LASSALLE <mathilde@tela-botanica.org>
10
* @author Mathilde SALTHUN-LASSALLE <mathilde@tela-botanica.org>
11
* @license GPL v3 <http://www.gnu.org/licenses/gpl.txt>
11
* @license GPL v3 <http://www.gnu.org/licenses/gpl.txt>
12
* @license CECILL v2 <http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt>
12
* @license CECILL v2 <http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt>
13
* @version 1.0
13
* @version 1.0
14
* @copyright 1999-2011 Tela Botanica (accueil@tela-botanica.org)
14
* @copyright 1999-2011 Tela Botanica (accueil@tela-botanica.org)
15
*/
15
*/
16
 
16
 
17
class GraphiquesBaseflor extends CommunGraphiques{
17
class GraphiquesBaseflor extends CommunGraphiques{
18
 
18
 
19
	
19
	
20
	
20
	
21
	
21
	
22
	public function definirTable($version){
22
	public function definirTable($version){
23
		$this->table = Config::get('bdd_table')."_v".$version;
23
		$this->table = Config::get('bdd_table')."_v".$version;
24
	}
24
	}
25
	
25
	
26
 
26
 
27
	
27
	
28
	//+--------------------------traitement ressources ou paramètres  -------------------------------------------+
28
	//+--------------------------traitement ressources ou paramètres  -------------------------------------------+
29
 
29
 
30
	public function traiterReferentieletNum(){
30
	public function traiterReferentieletNum(){
31
		if (!empty($this->ressources[1])) {
31
		if (!empty($this->ressources[1])) {
32
			if(preg_match('/^(.+)\.nn:([0-9]+)$/', $this->ressources[1], $retour) == 1){
32
			if(preg_match('/^(.+)\.nn:([0-9]+)$/', $this->ressources[1], $retour) == 1){
33
 
-
 
34
				switch ($retour[1]) {
33
				switch ($retour[1]) {
35
					case 'bdtfx' :
34
					case 'bdtfx' :
36
						$this->requete_condition[]= "num_nomen = ".$retour[2]." AND bdnt = 'bdtfx' ";
35
						$this->requete_condition[]= "num_nomen = ".$retour[2]." AND bdnt = 'bdtfx' ";
37
						break;
36
						break;
38
					case  'bdafx' :
37
					case  'bdafx' :
39
						$this->requete_condition[] = "num_nomen = ".$retour[2]." AND bdnt = 'bdafx' ";
38
						$this->requete_condition[] = "num_nomen = ".$retour[2]." AND bdnt = 'bdafx' ";
40
						break;
39
						break;
41
					case  'bdbfx' :
40
					case  'bdbfx' :
42
						$this->requete_condition[] = "num_nomen = ".$retour[2]." AND bdnt = 'bdbfx' ";
41
						$this->requete_condition[] = "num_nomen = ".$retour[2]." AND bdnt = 'bdbfx' ";
43
						break;
42
						break;
44
					default :
43
					default :
45
						$e = 'Erreur dans l\'url de votre requête : </br> La ressource " '
-
 
46
					.$retour[1].' " n\'existe pas.';
44
						$e = "Le référentiel {$retour[1]} n'existe pas.";
47
					throw new Exception( $e, RestServeur::HTTP_CODE_MAUVAISE_REQUETE);
45
					throw new Exception( $e, RestServeur::HTTP_CODE_MAUVAISE_REQUETE);
48
					break;
46
					break;
49
				}
47
				}
50
	
-
 
51
			}else {
48
			}else {
52
				$e = 'Erreur dans l\'url de votre requête : </br> La ressource '.$retour[1].' n\'existe pas.';
49
				$e = "Erreur dans l'url de votre requête :".
-
 
50
						" précisez le référentiel et le numéro nomenclatural sous la forme {bdnt}.nn:{nn}.";
53
				throw new Exception( $e, RestServeur::HTTP_CODE_MAUVAISE_REQUETE);
51
				throw new Exception( $e, RestServeur::HTTP_CODE_MAUVAISE_REQUETE);
54
			}
52
			}
55
		} else {
53
		} else {
56
			throw new Exception( "Erreur dans l'url de votre requête :".
54
			throw new Exception( "Erreur dans l'url de votre requête :".
57
						"précisez le référentiel et le numéro nomenclatural sous la forme {bdnt}.nn:{nn}.",
55
						" précisez le référentiel et le numéro nomenclatural sous la forme {bdnt}.nn:{nn}.",
58
			RestServeur::HTTP_CODE_MAUVAISE_REQUETE);
56
			RestServeur::HTTP_CODE_MAUVAISE_REQUETE);
59
		}
57
		}
60
	
-
 
61
	}
58
	}
62
	
59
	
63
	
60
	
64
	
61
	
65
	public function traiterTypeGraphique(){
62
	public function traiterTypeGraphique(){
66
		if (!empty($this->ressources[0])) {
63
		if (!empty($this->ressources[0])) {
67
			switch ($this->ressources[0]) {
64
			switch ($this->ressources[0]) {
68
				case  'climat' :
65
				case  'climat' :
69
					$this->requete_champs = ' ve_lumiere , ve_temperature, ve_continentalite, ve_humidite_atmos' ;
66
					$this->requete_champs = ' ve_lumiere , ve_temperature, ve_continentalite, ve_humidite_atmos' ;
70
					$this->nomGraphique= 'climat';
67
					$this->nomGraphique= 'climat';
71
					break;
68
					break;
72
				case 'sol' :
69
				case 'sol' :
73
					$this->requete_champs = ' ve_humidite_edaph , ve_reaction_sol, ve_nutriments_sol, ve_salinite,'
70
					$this->requete_champs = ' ve_humidite_edaph , ve_reaction_sol, ve_nutriments_sol, ve_salinite,'
74
					.'ve_texture_sol, ve_mat_org_sol' ;
71
					.'ve_texture_sol, ve_mat_org_sol' ;
75
					$this->nomGraphique = 'sol';
72
					$this->nomGraphique = 'sol';
76
					break;
73
					break;
77
				default :
74
				default :
78
					$e = "Erreur dans l'url de votre requête :".
75
					$e = "Erreur dans l'url de votre requête :".
79
				"</br> precisez le graphique -> \"sol\" ou \"climat\".";
76
				"</br> precisez le graphique -> \"sol\" ou \"climat\".";
80
				throw new Exception($e, RestServeur::HTTP_CODE_MAUVAISE_REQUETE);
77
				throw new Exception($e, RestServeur::HTTP_CODE_MAUVAISE_REQUETE);
81
				break;
78
				break;
82
			}
79
			}
83
		}else {
80
		}else {
84
			throw new Exception("Erreur dans l'url de votre requête :".
81
			throw new Exception("Erreur dans l'url de votre requête :".
85
				"</br> precisez le graphique -> \"sol\" ou \"climat\".", RestServeur::HTTP_CODE_MAUVAISE_REQUETE);
82
				"</br> precisez le graphique -> \"sol\" ou \"climat\".", RestServeur::HTTP_CODE_MAUVAISE_REQUETE);
86
		}
83
		}
87
	}
84
	}
88
 
85
 
89
	
86
	
90
	//+-------------------------- formatage du résultat  -------------------------------------------+
87
	//+-------------------------- formatage du résultat  -------------------------------------------+
91
	
88
	
92
		
89
		
93
	/// ++++ svg +++++ ///
90
	/// ++++ svg +++++ ///
94
	
91
	
95
	public function changerValeursSVG(){
92
	public function changerValeursSVG(){
96
		$Dompath = new DOMXPath($this->dom);
93
		$Dompath = new DOMXPath($this->dom);
97
		foreach ($this->valeurs_en_pourcentage as $cle => $val){
94
		foreach ($this->valeurs_en_pourcentage as $cle => $val){
98
				$val = preg_replace('/,/','.', $val);
95
				$val = preg_replace('/,/','.', $val);
99
				$grad_id = array_search($val,$this->graduations_id);
96
				$grad_id = array_search($val,$this->graduations_id);
100
				$element = $Dompath->query("//*[@id='".$grad_id."']")->item(0);
97
				$element = $Dompath->query("//*[@id='".$grad_id."']")->item(0);
101
				$pos_x = $element->getAttribute('x1');
98
				$pos_x = $element->getAttribute('x1');
102
				$curseur = $Dompath->query("//*[@id='".$cle."']")->item(0);
99
				$curseur = $Dompath->query("//*[@id='".$cle."']")->item(0);
103
				$curseur->setAttribute('cx', $pos_x);
100
				$curseur->setAttribute('cx', $pos_x);
104
				$curseur->setAttribute('class', 'curseur');
101
				$curseur->setAttribute('class', 'curseur');
105
				$this->ajouterInfoAuSurvol($curseur);
102
				$this->ajouterInfoAuSurvol($curseur);
106
				$changement = true;
103
				$changement = true;
107
		}
104
		}
108
		$svg = $this->dom->getElementsByTagName("svg")->item(0);
105
		$svg = $this->dom->getElementsByTagName("svg")->item(0);
109
		$svg->setAttribute('width',$this->largeurSVG);
106
		$svg->setAttribute('width',$this->largeurSVG);
110
	}
107
	}
111
	
108
	
112
	public function ajouterInfoAuSurvol($curseur){
109
	public function ajouterInfoAuSurvol($curseur){
113
		$champs = $curseur->getAttribute('id');
110
		$champs = $curseur->getAttribute('id');
114
		$valeurTexte = $this->recupererOntologies($this->valeurs_champs[$champs], $champs );
111
		$valeurTexte = $this->recupererOntologies($this->valeurs_champs[$champs], $champs );
115
		$valeurTexte = $this->traiterIntermediaires($valeurTexte->nom, $champs, $champs);
112
		$valeurTexte = $this->traiterIntermediaires($valeurTexte->nom, $champs, $champs);
116
		$curseur->setAttribute('title',$this->valeurs_champs[$champs].": ".$valeurTexte );
113
		$curseur->setAttribute('title',$this->valeurs_champs[$champs].": ".$valeurTexte );
117
	}
114
	}
118
 
115
 
119
	
116
	
120
}
117
}
121
?>
118
?>