Subversion Repositories eFlore/Projets.eflore-projets

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
727 alex 1
<?php
2
 
3
final class DonneesMoissonnage extends SourceDonnees {
4
 
5
	public function __construct($limitesCarte, $taxon, $source) {
6
		parent::__construct($limitesCarte, $taxon, $source);
7
	}
8
 
9
	final public function recupererStations() {
10
		$bdd = new Bdd();
11
		$bdd->requeter("USE ".Config::get('bdd_nom'));
12
		$requete =
13
		"SELECT Floor(lieu_station_latitude*10)/10 AS lat, Floor(lieu_station_longitude*10)/10 AS lng, ".
14
		"COUNT(guid) AS nb_observations FROM {$this->source}_tapir WHERE ".$this->construireWhereTaxon()." ".
15
		"AND lieu_station_longitude BETWEEN ".$this->limitesCarte['ouest']." AND ".$this->limitesCarte['est']." ".
16
		"AND lieu_station_latitude BETWEEN ".$this->limitesCarte['sud']." AND ".$this->limitesCarte['nord']." ".
17
		"GROUP BY Floor(lieu_station_latitude*10)/10, Floor(lieu_station_longitude*10)/10 ".
18
		"ORDER BY lat DESC, lng ASC";
19
		//echo $requete.'<br>';
20
		return $bdd->recupererTous($requete);
21
	}
22
 
23
	final protected function construireWhereTaxon() {
24
		$nomRang = $this->obtenirNomRang();
25
		$criteres = array();
26
		$criteres[] = "nom_scientifique_complet LIKE ".$this->bdd->proteger($this->taxon['nom_sci']."%");
27
		if ($nomRang == 'espece') {
28
			$sousTaxons = $this->recupererSynonymesEtSousEspeces();
29
			foreach ($sousTaxons as $sousTaxon) {
30
				$criteres[] = "nom_scientifique_complet LIKE ".$this->bdd->proteger($sousTaxon['nom_sci']."%");
31
			}
32
		} elseif ($nomRang == 'famille') {
33
			$sousTaxons = $this->recupererGenres();
34
			foreach ($sousTaxons as $sousTaxon) {
35
				$criteres[] = "nom_scientifique_complet LIKE ".$this->bdd->proteger($sousTaxon['nom_sci']."%");
36
			}
37
		}
38
		return "(".implode(' OR ',array_unique($criteres)).")";
39
	}
40
 
41
}
42
 
43
?>