Subversion Repositories eFlore/Projets.eflore-projets

Rev

Rev 988 | Details | Compare with Previous | Last modification | View Log | RSS feed

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