Subversion Repositories eFlore/Projets.eflore-projets

Rev

Rev 909 | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

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