Subversion Repositories eFlore/Projets.eflore-projets

Rev

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

Rev 464 Rev 503
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 (isset($this->ressources) && !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
 
33
 
34
				switch ($retour[1]) {
34
				switch ($retour[1]) {
35
					case 'bdtfx' :
35
					case 'bdtfx' :
36
						$this->requete_condition[]= "num_nomen = ".$retour[2]." AND bdnt = 'bdtfx' ";
36
						$this->requete_condition[]= "num_nomen = ".$retour[2]." AND bdnt = 'bdtfx' ";
37
						break;
37
						break;
38
					case  'bdafx' :
38
					case  'bdafx' :
39
						$this->requete_condition[] = "num_nomen = ".$retour[2]." AND bdnt = 'bdafx' ";
39
						$this->requete_condition[] = "num_nomen = ".$retour[2]." AND bdnt = 'bdafx' ";
40
						break;
40
						break;
41
					case  'bdbfx' :
41
					case  'bdbfx' :
42
						$this->requete_condition[] = "num_nomen = ".$retour[2]." AND bdnt = 'bdbfx' ";
42
						$this->requete_condition[] = "num_nomen = ".$retour[2]." AND bdnt = 'bdbfx' ";
43
						break;
43
						break;
44
					default :
44
					default :
45
						$e = 'Erreur dans l\'url de votre requête : </br> La ressource " '
45
						$e = 'Erreur dans l\'url de votre requête : </br> La ressource " '
46
					.$retour[1].' " n\'existe pas.';
46
					.$retour[1].' " n\'existe pas.';
47
					throw new Exception( $e, RestServeur::HTTP_CODE_MAUVAISE_REQUETE);
47
					throw new Exception( $e, RestServeur::HTTP_CODE_MAUVAISE_REQUETE);
48
					break;
48
					break;
49
				}
49
				}
50
	
50
	
51
			}else {
51
			}else {
52
				$e = 'Erreur dans l\'url de votre requête : </br> La ressource  n\'existe pas.';
52
				$e = 'Erreur dans l\'url de votre requête : </br> La ressource '.$retour[1].' n\'existe pas.';
53
				throw new Exception( $e, RestServeur::HTTP_CODE_MAUVAISE_REQUETE);
53
				throw new Exception( $e, RestServeur::HTTP_CODE_MAUVAISE_REQUETE);
54
			}
54
			}
55
		} else {
55
		} else {
56
			throw new Exception( "Erreur dans l\'url de votre requête :".
56
			throw new Exception( "Erreur dans l\'url de votre requête :".
57
						"preciser le référentiel et le numéro nomenclatural sous la forme {bdnt}.nn:{nn}.",
57
						"preciser le référentiel et le numéro nomenclatural sous la forme {bdnt}.nn:{nn}.",
58
			RestServeur::HTTP_CODE_MAUVAISE_REQUETE);
58
			RestServeur::HTTP_CODE_MAUVAISE_REQUETE);
59
		}
59
		}
60
	
60
	
61
	}
61
	}
62
	
62
	
63
	
63
	
64
	
64
	
65
	public function traiterTypeGraphique(){
65
	public function traiterTypeGraphique(){
66
		if (isset($this->ressources) && !empty($this->ressources[0])) {
66
		if (!empty($this->ressources[0])) {
67
			switch ($this->ressources[0]) {
67
			switch ($this->ressources[0]) {
68
				case  'climat' :
68
				case  'climat' :
69
					$this->requete_champs = ' ve_lumiere , ve_temperature, ve_continentalite, ve_humidite_atmos' ;
69
					$this->requete_champs = ' ve_lumiere , ve_temperature, ve_continentalite, ve_humidite_atmos' ;
70
					$this->nomGraphique= 'climat';
70
					$this->nomGraphique= 'climat';
71
					break;
71
					break;
72
				case 'sol' :
72
				case 'sol' :
73
					$this->requete_champs = ' ve_humidite_edaph , ve_reaction_sol, ve_nutriments_sol, ve_salinite,'
73
					$this->requete_champs = ' ve_humidite_edaph , ve_reaction_sol, ve_nutriments_sol, ve_salinite,'
74
					.'ve_texture_sol, ve_mat_org_sol' ;
74
					.'ve_texture_sol, ve_mat_org_sol' ;
75
					$this->nomGraphique = 'sol';
75
					$this->nomGraphique = 'sol';
76
					break;
76
					break;
77
				default :
77
				default :
78
					$e = 'Erreur dans l\'url de votre requête : </br> La ressource " '
78
					$e = "Erreur dans l\'url de votre requête :".
79
				.$retour[1].' " n\'existe pas.';
79
				"</br> precisez le graphique -> \"sol\" ou \"climat\".";
80
				throw new Exception($e, RestServeur::HTTP_CODE_MAUVAISE_REQUETE);
80
				throw new Exception($e, RestServeur::HTTP_CODE_MAUVAISE_REQUETE);
81
				break;
81
				break;
82
			}
82
			}
83
		}else {
83
		}else {
84
			throw new Exception("Erreur dans l\'url de votre requête :".
84
			throw new Exception("Erreur dans l\'url de votre requête :".
85
				"</br> precisez le graphique -> \"sol\" ou \"climat\".", RestServeur::HTTP_CODE_MAUVAISE_REQUETE);
85
				"</br> precisez le graphique -> \"sol\" ou \"climat\".", RestServeur::HTTP_CODE_MAUVAISE_REQUETE);
86
		}
86
		}
87
	}
87
	}
88
 
88
 
89
	
89
	
90
	//+-------------------------- formatage du résultat  -------------------------------------------+
90
	//+-------------------------- formatage du résultat  -------------------------------------------+
91
	
91
	
92
		
92
		
93
	/// ++++ svg +++++ ///
93
	/// ++++ svg +++++ ///
94
	
94
	
95
	public function changerValeursSVG(){
95
	public function changerValeursSVG(){
96
		$Dompath = new DOMXPath($this->dom);
96
		$Dompath = new DOMXPath($this->dom);
97
		foreach ($this->valeurs_en_pourcentage as $cle => $val){
97
		foreach ($this->valeurs_en_pourcentage as $cle => $val){
98
				$val = preg_replace('/,/','.', $val);
98
				$val = preg_replace('/,/','.', $val);
99
				$grad_id = array_search($val,$this->graduations_id);
99
				$grad_id = array_search($val,$this->graduations_id);
100
				$element = $Dompath->query("//*[@id='".$grad_id."']")->item(0);
100
				$element = $Dompath->query("//*[@id='".$grad_id."']")->item(0);
101
				$pos_x = $element->getAttribute('x1');
101
				$pos_x = $element->getAttribute('x1');
102
				$curseur = $Dompath->query("//*[@id='".$cle."']")->item(0);
102
				$curseur = $Dompath->query("//*[@id='".$cle."']")->item(0);
103
				$curseur->setAttribute('cx', $pos_x);
103
				$curseur->setAttribute('cx', $pos_x);
104
				$curseur->setAttribute('class', 'curseur');
104
				$curseur->setAttribute('class', 'curseur');
105
				$this->ajouterInfoAuSurvol($curseur);
105
				$this->ajouterInfoAuSurvol($curseur);
106
				$changement = true;
106
				$changement = true;
107
		}
107
		}
108
		$svg = $this->dom->getElementsByTagName("svg")->item(0);
108
		$svg = $this->dom->getElementsByTagName("svg")->item(0);
109
		$svg->setAttribute('width',$this->largeurSVG);
109
		$svg->setAttribute('width',$this->largeurSVG);
110
	}
110
	}
111
	
111
	
112
	public function ajouterInfoAuSurvol($curseur){
112
	public function ajouterInfoAuSurvol($curseur){
113
		$champs = $curseur->getAttribute('id');
113
		$champs = $curseur->getAttribute('id');
114
		$valeurTexte = $this->recupererOntologies($this->valeurs_champs[$champs], $champs );
114
		$valeurTexte = $this->recupererOntologies($this->valeurs_champs[$champs], $champs );
115
		$valeurTexte = $this->traiterIntermediaires($valeurTexte->nom, $champs, $champs);
115
		$valeurTexte = $this->traiterIntermediaires($valeurTexte->nom, $champs, $champs);
116
		$curseur->setAttribute('title',$this->valeurs_champs[$champs].": ".$valeurTexte );
116
		$curseur->setAttribute('title',$this->valeurs_champs[$champs].": ".$valeurTexte );
117
	}
117
	}
118
 
118
 
119
	
119
	
120
}
120
}
121
?>
121
?>