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