Subversion Repositories eFlore/Applications.moissonnage

Compare Revisions

Ignore whitespace Rev 31 → Rev 30

/trunk/services/modules/0.1/commun/Commun.php
12,25 → 12,27
public function consulter($ressources, $parametres) {
$this->recupererRessourcesEtParametres($ressources, $parametres);
$retour = null;
try {
if (!$this->verifierExistenceSourcesDonnees()) {
$message = "Source de donnees indisponible";
throw new Exception($message, RestServeur::HTTP_CODE_RESSOURCE_INTROUVABLE);
} else {
$this->chargerNomSource();
$this->verifierParametres();
if ($this->ressources[0] == 'mailles') {
$retour = $this->recupererMaillage();
} else {
$this->chargerNomSource();
$this->chargerNomService();
$retour = $this->executerServicePourSource();
}
$this->chargerNomService();
$objetTraitement = new $this->nomService($this->parametresRecherche);
$methode = $this->genererNomMethodeAExecuter();
$retour = $objetTraitement->$methode();
}
} catch (Exception $erreur) {
$retour = $erreur;
}
return $retour;
}
39,6 → 41,15
$this->parametres = $parametres;
}
private function chargerNomService() {
$this->nomService = ucfirst($this->parametres['source']) . 'Formateur';
Projets::chargerConfigurationSource($this->parametres['source']);
}
private function genererNomMethodeAExecuter() {
return 'recuperer' . ucfirst($this->ressources[0]);
}
private function verifierExistenceSourcesDonnees() {
$sourcesDisponibles = explode(',', Config::get('sources_dispo'));
$estDisponible = false;
53,6 → 64,14
return $estDisponible;
}
private function chargerNomSource() {
if (isset($this->parametres['source'])) {
$this->nomSource = $this->parametres['source'];
} else {
$this->nomSource = Config::get('source_defaut');
}
}
private function verifierParametres() {
$this->verificateur = new VerificateurParametres($this->parametres);
$this->verificateur->verifierParametres();
67,36 → 86,7
$this->parametresRecherche = $this->verificateur->renvoyerResultatVerification();
}
private function chargerNomSource() {
if (isset($this->parametres['source'])) {
$this->nomSource = $this->parametres['source'];
} else {
$this->nomSource = Config::get('source_defaut');
}
}
private function chargerNomService() {
$this->nomService = ucfirst($this->parametres['source']) . 'Formateur';
Projets::chargerConfigurationSource($this->parametres['source']);
}
private function recupererMaillage() {
$maillage = new Maillage($this->parametresRecherche->bbox, $this->parametresRecherche->zoom);
$maillage->genererMaillesVides();
$formateurJSON = new FormateurJson();
return $formateurJSON->formaterMaillesVides($maillage->formaterSortie(true));
}
private function executerServicePourSource() {
$objetTraitement = new $this->nomService($this->parametresRecherche);
$methode = $this->genererNomMethodeAExecuter();
return $objetTraitement->$methode();
}
private function genererNomMethodeAExecuter() {
return 'recuperer' . ucfirst($this->ressources[0]);
}
}
 
?>
/trunk/services/modules/0.1/sources/BaznatFormateur.php
File deleted
\ No newline at end of file
/trunk/services/modules/0.1/sources/Formateur.php
File deleted
\ No newline at end of file
/trunk/services/modules/0.1/sources/FloradataFormateur.php
43,8 → 43,10
}
public function recupererStations() {
// recuperer les informations au niveau de la base de donnees
$requeteSql = $this->construireRequeteStations();
$stations = $this->getBdd()->recupererTous($requeteSql);
$zoomMaxMaillage = Config::get('zoom_maximal_maillage');
$seuilMaillage = Config::get('seuil_maillage');
$zoom = $this->criteresRecherche->zoom;
51,11 → 53,14
$bbox = $this->criteresRecherche->bbox;
// TODO: gérer une notion d'échelle plutot que de zoom (pour les clients SIG)
if (count($stations) > $seuilMaillage && intval($zoom)<= $zoomMaxMaillage) {
// partitionnement des donnees en mailles
$maillage = new Maillage($bbox, $zoom);
$maillage->genererMaillesVides();
$maillage->ajouterPoints($stations);
$stations = $maillage->formaterSortie();
}
// mettre en forme les informations au format JSON
$formateurJSON = new FormateurJson('floradata');
$donneesFormatees = $formateurJSON->formaterStations($stations);
return $donneesFormatees;
62,9 → 67,12
}
public function recupererObservations() {
// recuperer les informations sur les stations repondant a ces parametres
$requeteSql = $this->construireRequeteObservations();
$observations = $this->getBdd()->recupererTous($requeteSql);
$nomSite = $this->obtenirNomStation();
// mettre en forme les informations au format JSON
$formateurJSON = new FormateurJson('floradata');
$donneesFormatees = $formateurJSON->formaterObservations($observations, $nomSite);
return $donneesFormatees;
85,27 → 93,21
}
private function construireRequeteStations() {
$bbox = $this->criteresRecherche->bbox;
$selectTypeSite =
"IF(".
"(longitude IS NULL OR latitude IS NULL) ".
"OR (longitude=0 AND latitude=0) ".
"OR (mots_cles_texte LIKE '%sensible%') ".
"OR NOT (".
"longitude BETWEEN ".$bbox['ouest']." AND ".$bbox['est']." ".
"AND latitude BETWEEN ".$bbox['sud']." AND ".$bbox['nord'].
")".
"OR (longitude=999.99999 AND latitude=999.99999)".
", 'COMMUNE', 'STATION'".
")";
$requete =
"SELECT COUNT(id_observation) AS observations, ce_zone_geo, zone_geo, station, ".
"longitude, latitude, nom AS nom_commune,wgs84_longitude AS lng_commune, ".
"wgs84_latitude AS lat_commune, ".$selectTypeSite." AS type_site ".
"FROM cel_obs LEFT JOIN cel_zones_geo cz ON ce_zone_geo=id_zone_geo ".
"WHERE transmission=1 ".
'SELECT ce_zone_geo, zone_geo, station, longitude, latitude, nom AS "nom_commune",'.
'wgs84_longitude AS "lng_commune", wgs84_latitude AS "lat_commune", '.
$selectTypeSite.' AS "type_site" '.
'FROM cel_obs LEFT JOIN cel_zones_geo cz ON ce_zone_geo=id_zone_geo '.
'WHERE transmission=1 '.
$this->construireWhereDepartement().' '.
$this->construireWhereAuteur().' '.
$this->construireWhereDate().' '.
$this->construireWhereReferentiel().' '.
$this->construireWhereTaxon().' '.
$this->construireWhereCoordonneesBbox().' '.
116,12 → 118,11
private function construireRequeteObservations() {
$requete =
"SELECT id_observation AS id_obs, nom_ret_nn AS nn, nom_ret AS nomSci, ".
"Date(date_observation) AS date, milieu AS lieu, nom_referentiel, ".
"Date(date_transmission) AS date, milieu AS lieu, nom_referentiel, ".
"Concat(prenom_utilisateur, ' ', nom_utilisateur) AS observateur, ce_utilisateur AS observateurId ".
"FROM cel_obs WHERE transmission=1 ".
$this->construireWhereAuteur().' '.
$this->construireWhereReferentiel().' '.
$this->construireWhereDate().' '.
$this->construireWhereTaxon().' '.
$this->construireWhereCoordonneesPoint().' '.
"ORDER BY nom_ret, date, observateur";
128,55 → 129,22
return $requete;
}
protected function construireWhereTaxon() {
private function construireWhereTaxon() {
$sql = '';
if (isset($this->criteresRecherche->taxon)) {
$taxons = $this->criteresRecherche->taxon;
$criteres = array();
foreach ($taxons as $taxon) {
$nomRang = $this->getNomRang($taxon);
if ($nomRang == 'genre') {
$criteres[] = "famille=".$this->getBdd()->proteger($taxon['nom']);
} else {
$criteres[] = "nom_ret LIKE ".$this->getBdd()->proteger($taxon['nom']."%");
if ($nomRang == 'espece') {
$criteres = array_merge($criteres, $this->concatenerTaxonsSousEspeces($taxon));
}
}
$taxon = $this->criteresRecherche->taxon;
$criteres = "nom_ret LIKE ".$this->getBdd()->proteger($taxon['nom']."%");
$referentiel = new Referentiel($this->criteresRecherche->referentiel, $this->criteresRecherche->taxon);
$sousTaxons = $referentiel->recupererSousTaxons();
foreach ($sousTaxons as $sousTaxon) {
$criteres .= " OR nom_ret LIKE ".$this->getBdd()->proteger($taxon['nom']."%");
}
$sql = "AND (".implode(' OR ',array_unique($criteres)).")";
$sql = "AND ($criteres)";
}
return $sql;
}
protected function getNomRang($taxon) {
$nomsRangs = array('famille', 'genre', 'espece', 'sous_espece');
for ($index = 0; $index < count($nomsRangs)
&& Config::get("rang.".$nomsRangs[$index]) != $taxon['rang']; $index ++);
$position = $index == count($nomsRangs) ? count($nomsRangs)-1 : $index;
return $nomsRangs[$position];
}
protected function concatenerTaxonsSousEspeces($taxon) {
$referentiel = new Referentiel($this->criteresRecherche->referentiel, $taxon);
$sousTaxons = $referentiel->recupererTaxonsSousEspeces();
$criteres = array();
foreach ($sousTaxons as $sousTaxon) {
$criteres[] = "nom_ret LIKE ".$this->getBdd()->proteger($sousTaxon['nom']."%");
}
return $criteres;
}
protected function concatenerTaxonsFamilles($taxon) {
$referentiel = new Referentiel($this->criteresRecherche->referentiel, $taxon);
$sousTaxons = $referentiel->recupererTaxonsFamilles();
$criteres = array();
foreach ($sousTaxons as $sousTaxon) {
$criteres[] = "nom_ret LIKE ".$this->getBdd()->proteger($sousTaxon['nom']."%");
}
return $criteres;
}
private function construireWhereReferentiel() {
$sql = '';
if (isset($this->criteresRecherche->referentiel) && !isset($this->criteresRecherche->taxon)) {
208,49 → 176,15
return $sql;
}
private function construireWhereDate() {
$sql = '';
if (isset($this->criteresRecherche->nbJours)) {
$nbJours = $this->criteresRecherche->nbJours;
$sql = "AND (Datediff(Curdate(), date_creation)<={$nbJours})";
} else {
$sql = $this->construireWhereDateDebutEtFin();
}
return $sql;
}
private function construireWhereDateDebutEtFin() {
$sql = '';
$dateDebut = isset($this->criteresRecherche->dateDebut) ? $this->criteresRecherche->dateDebut : null;
$dateFin = isset($this->criteresRecherche->dateFin) ? $this->criteresRecherche->dateFin : null;
if (!is_null($dateDebut) || !is_null($dateFin)) {
$dateFin = !is_null($dateFin) ? $dateFin : date('Y-m-d');
$condition = '';
if ($dateDebut == $dateFin) {
$condition = "Date(date_observation)=".$this->getBdd()->proteger($dateDebut);
} elseif (is_null($dateFin)) {
$condition = "Date(date_observation)>=".$this->getBdd()->proteger($dateDebut);
} elseif (is_null($dateDebut)) {
$condition = "Date(date_observation)<=".$this->getBdd()->proteger($dateFin);
} else {
$condition = "Date(date_observation) BETWEEN ".$this->getBdd()->proteger($dateDebut)." ".
"AND ".$this->getBdd()->proteger($dateFin);
}
$sql = "AND ($condition)";
}
return $sql;
}
private function construireWhereCoordonneesBbox() {
$bbox = $this->criteresRecherche->bbox;
$sql =
"AND (".
"(".
"latitude BETWEEN ".$bbox['sud']." AND ".$bbox['nord']." ".
"AND longitude BETWEEN ".$bbox['ouest']." AND ".$bbox['est'].
"longitude BETWEEN ".$bbox['ouest']." AND ".$bbox['est']." ".
"AND latitude BETWEEN ".$bbox['sud']." AND ".$bbox['nord']." ".
"AND (wgs84_longitude IS NULL OR wgs84_latitude IS NULL)".
") OR (".
"((longitude IS NULL OR latitude IS NULL) OR (longitude=0 AND latitude=0) ".
"OR (longitude>180 AND latitude>90)) AND ".
"wgs84_longitude BETWEEN ".$bbox['ouest']." AND ". $bbox['est']." ".
"AND wgs84_latitude BETWEEN ".$bbox['sud']." AND ".$bbox['nord'].
")".
259,18 → 193,12
}
private function construireWhereCoordonneesPoint() {
$longitude = $this->criteresRecherche->longitude;
$latitude = $this->criteresRecherche->latitude;
$condition = "(longitude=".$longitude." AND latitude=".$latitude." ".
"AND (mots_cles_texte IS NULL OR mots_cles_texte NOT LIKE '%sensible%'))";
if ($this->criteresRecherche->typeSite == 'commune') {
$commune = $this->obtenirCoordonneesCommune();
$condition .=
" OR (".
"((longitude IS NULL OR latitude IS NULL) OR (longitude=0 AND latitude=0) ".
"OR (longitude>180 AND latitude>90)) ".
"AND ce_zone_geo=".$this->getBdd()->proteger($commune['id_zone_geo']).
")";
$commune = $this->obtenirCoordonneesCommune();
$condition = "(longitude=".$this->criteresRecherche->longitude." ".
"AND latitude=".$this->criteresRecherche->latitude.")";
if (!is_null($commune)) {
$condition .= " OR (longitude IS NULL AND latitude IS NULL AND ce_zone_geo=".
$this->getBdd()->proteger($commune['id_zone_geo']).")";
}
return "AND ($condition)";
}
/trunk/services/modules/0.1/sources/SophyFormateur.php
30,25 → 30,96
*
*/
 
class SophyFormateur extends Formateur {
class SophyFormateur {
private $criteresRecherche;
private $bdd;
public function __construct($criteresRecherche) {
$this->criteresRecherche = $criteresRecherche;
}
public function recupererStations() {
$stations = array();
$nombreStations = $this->obtenirNombreStationsDansBbox();
$seuilMaillage = Config::get('seuil_maillage');
$nombreParametresNonSpatiaux = $this->calculerNombreCriteresNonSpatiaux();
if ($nombreStations >= $seuilMaillage && $nombreParametresNonSpatiaux == 0) {
// pas besoin de rechercher les stations correspondant a ces criteres
// recuperer les mailles se trouvant dans l'espace de recherche demande
$stations = $this->recupererMaillesDansBbox();
} else {
$requeteSql = $this->construireRequeteStations();
$stations = $this->getBdd()->recupererTous($requeteSql);
$zoom = $this->criteresRecherche->zoom;
$zoomMaxMaillage = Config::get('zoom_maximal_maillage');
if ($zoom <= $zoomMaxMaillage && count($stations) >= $seuilMaillage) {
// generer un maillage a partir des stations recuperees dans la base de donnees
$maillage = new Maillage($this->criteresRecherche->bbox, $zoom, 'sophy');
$maillage->genererMaillesVides();
$maillage->ajouterPoints($stations);
$stations = $maillage->formaterSortie();
}
}
// mettre en forme les informations au format JSON
$formateurJSON = new FormateurJson('sophy');
$donneesFormatees = $formateurJSON->formaterStations($stations);
return $donneesFormatees;
}
public function recupererObservations() {
$requeteSql = $this->construireRequeteObservations();
$observations = $this->getBdd()->recupererTous($requeteSql);
$this->recupererNumeroNomenclaturauxTaxons($observations);
$nomStation = $this->obtenirNomsStationsSurPoint();
$formateurJSON = new FormateurJson('sophy');
$donneesFormatees = $formateurJSON->formaterObservations($observations, $nomStation);
return $donneesFormatees;
}
private function calculerNombreCriteresNonSpatiaux() {
$nombreParametresNonSpatiaux = 0;
$criteresSpatiaux = array('zoom', 'bbox', 'longitude', 'latitude');
foreach ($this->criteresRecherche as $nomCritere => $valeur) {
if (!in_array($nomCritere, $criteresSpatiaux)) {
$nombreParametresNonSpatiaux ++;
}
}
return $nombreParametresNonSpatiaux;
}
 
protected function construireRequeteStations() {
 
 
// ------------------------------------------------------------------------ //
// Fonctions de construction des criteres de recherches pour la requete SQL //
// ------------------------------------------------------------------------ //
private function getBdd() {
if (!isset($this->bdd)) {
$this->bdd = new Bdd();
}
$this->bdd->requeter("USE ".Config::get('bdd_nom'));
return $this->bdd;
}
private function construireRequeteStations() {
$requete =
"SELECT COUNT(guid) AS observations, lieu_station_nom AS nom, lieu_station_latitude AS latitude, ".
"lieu_station_longitude AS longitude, 'STATION' AS type_site, lieu_commune_code_insee AS code_insee ".
"SELECT DISTINCT lieu_station_nom AS nom, lieu_station_latitude AS latitude, ".
"lieu_station_longitude AS longitude, 'STATION' AS type_site ".
"FROM sophy_tapir WHERE 1 ".
$this->construireWhereDepartement().' '.
$this->construireWhereAuteur().' '.
$this->construireWhereDate().' '.
$this->construireWhereReferentiel().' '.
$this->construireWhereTaxon().' '.
$this->construireWhereCoordonneesBbox().' '.
"GROUP BY lieu_station_longitude, lieu_station_latitude";
"GROUP BY lieu_station_latitude, lieu_station_longitude";
return $requete;
}
protected function construireRequeteObservations() {
private function construireRequeteObservations() {
$requete =
"SELECT observation_id AS id_obs, nom_scientifique_complet AS nomSci, ".
"observation_date AS date, lieu_station_nom AS lieu, observateur_nom_complet AS observateur ".
55,7 → 126,6
"FROM sophy_tapir WHERE 1 ".
$this->construireWhereAuteur().' '.
$this->construireWhereReferentiel().' '.
$this->construireWhereDate().' '.
$this->construireWhereTaxon().' '.
$this->construireWhereCoordonneesPoint().' '.
"ORDER BY nom_scientifique_complet, date, observateur";
62,66 → 132,34
return $requete;
}
protected function construireWhereTaxon() {
private function construireWhereTaxon() {
$sql = '';
if (isset($this->criteresRecherche->taxon)) {
$taxons = $this->criteresRecherche->taxon;
$criteres = array();
foreach ($taxons as $taxon) {
$nomRang = $this->getNomRang($taxon);
$criteres[] = "nom_scientifique_complet LIKE ".$this->getBdd()->proteger($taxon['nom']."%");
if ($nomRang == 'espece') {
$criteres = array_merge($criteres, $this->concatenerTaxonsSousEspeces($taxon));
} elseif ($nomRang == 'genre') {
$criteres = array_merge($criteres, $this->concatenerTaxonsFamilles($taxon));
}
$taxon = $this->criteresRecherche->taxon;
$criteres = "nom_scientifique_complet LIKE ".$this->getBdd()->proteger($taxon['nom']."%");
$referentiel = new Referentiel($this->criteresRecherche->referentiel, $this->criteresRecherche->taxon);
$sousTaxons = $referentiel->recupererSousTaxons();
foreach ($sousTaxons as $sousTaxon) {
$criteres .= " OR nom_scientifique_complet LIKE ".$this->getBdd()->proteger($taxon['nom']."%");
}
$sql = "AND (".implode(' OR ',array_unique($criteres)).")";
$sql = "AND ($criteres)";
}
return $sql;
}
protected function concatenerTaxonsSousEspeces($taxon) {
$referentiel = new Referentiel($this->criteresRecherche->referentiel, $taxon);
$sousTaxons = $referentiel->recupererTaxonsSousEspeces();
$criteres = array();
foreach ($sousTaxons as $sousTaxon) {
$criteres[] = "nom_scientifique_complet LIKE ".$this->getBdd()->proteger($sousTaxon['nom']."%");
}
return $criteres;
}
protected function concatenerTaxonsFamilles($taxon) {
$referentiel = new Referentiel($this->criteresRecherche->referentiel, $taxon);
$sousTaxons = $referentiel->recupererTaxonsFamilles();
$criteres = array();
foreach ($sousTaxons as $sousTaxon) {
$criteres[] = "nom_scientifique_complet LIKE ".$this->getBdd()->proteger($sousTaxon['nom']."%");
}
return $criteres;
}
// TODO : completer le corps des methodes construire where pour referentiel et departement
protected function construireWhereReferentiel() {
private function construireWhereReferentiel() {
$sql = '';
return $sql;
}
protected function construireWhereDepartement() {
private function construireWhereDepartement() {
$sql = '';
if (isset($this->criteresRecherche->departement)) {
$valeurs_a_proteger = $this->criteresRecherche->departement;
foreach ($valeurs_a_proteger as $valeur) {
$aProteger = $this->getBdd()->proteger($valeur . '%');
$valeurs_protegees[] = "lieu_commune_code_insee LIKE {$aProteger}";
}
$valeurs = implode(' OR ', $valeurs_protegees);
$sql = "AND ($valeurs)";
}
return $sql;
}
protected function construireWhereAuteur() {
private function construireWhereAuteur() {
$sql = '';
if (isset($this->criteresRecherche->auteur)) {
$auteur = $this->getBdd()->proteger($this->criteresRecherche->auteur);
129,30 → 167,8
}
return $sql;
}
 
protected function construireWhereDate() {
$sql = '';
$dateDebut = isset($this->criteresRecherche->dateDebut) ? $this->criteresRecherche->dateDebut : null;
$dateFin = isset($this->criteresRecherche->dateFin) ? $this->criteresRecherche->dateFin : null;
if (!is_null($dateDebut) || !is_null($dateFin)) {
$dateDebut = !is_null($dateDebut) ? substr($dateDebut, 0, 4) : null;
$dateFin = !is_null($dateFin) ? substr($dateFin, 0, 4) : date('Y');
$condition = '';
if ($dateDebut == $dateFin) {
$condition = "observation_date=".$dateDebut;
} elseif (is_null($dateFin)) {
$condition = "observation_date>=".$dateDebut;
} elseif (is_null($dateDebut)) {
$condition = "observation_date<=".$dateFin;
} else {
$condition = "observation_date BETWEEN ".$dateDebut." AND ".$dateFin;
}
$sql = "AND ($condition)";
}
return $sql;
}
protected function construireWhereCoordonneesBbox() {
private function construireWhereCoordonneesBbox() {
$bbox = $this->criteresRecherche->bbox;
$sql = "AND lieu_station_longitude BETWEEN ".$bbox['ouest']." AND ".$bbox['est']." ".
"AND lieu_station_latitude BETWEEN ".$bbox['sud']." AND ".$bbox['nord'];
159,13 → 175,13
return $sql;
}
protected function construireWhereCoordonneesPoint() {
private function construireWhereCoordonneesPoint() {
$sql = "AND lieu_station_latitude=".$this->criteresRecherche->latitude." ".
"AND lieu_station_longitude=".$this->criteresRecherche->longitude;
return $sql;
}
protected function obtenirNomsStationsSurPoint() {
private function obtenirNomsStationsSurPoint() {
$requete = "SELECT DISTINCTROW lieu_station_nom FROM sophy_tapir WHERE 1 ".
$this->construireWhereTaxon().' '.
$this->construireWhereCoordonneesPoint();
177,7 → 193,7
return implode(', ', $nomsStations);
}
protected function obtenirNombreStationsDansBbox() {
private function obtenirNombreStationsDansBbox() {
$bbox = $this->criteresRecherche->bbox;
$zoom = $this->criteresRecherche->zoom;
$requete =
188,23 → 204,60
return $resultat['total_points'];
}
protected function recupererMaillesDansBbox() {
private function recupererMaillesDansBbox() {
$bbox = $this->criteresRecherche->bbox;
$zoom = $this->criteresRecherche->zoom;
$requete =
"SELECT limite_sud AS latitudeSud, limite_ouest AS longitudeOuest, limite_est AS longitudeEst, ".
"limite_nord AS latitudeNord, nombre_sites, nombre_observations FROM mailles_sophy ".
"WHERE zoom=".$zoom." AND limite_sud<=".$bbox['nord']." ".
"SELECT zoom, position_latitude, position_longitude, limite_sud AS sud, limite_ouest AS ouest, ".
"limite_nord AS nord, limite_est AS est, nombre_sites AS points, 'MAILLE' AS type_site ".
"FROM mailles_sophy WHERE zoom=".$zoom." AND limite_sud<=".$bbox['nord']." ".
"AND limite_nord>=".$bbox['sud']." AND limite_ouest<=". $bbox['est']." ".
"AND limite_est>=".$bbox['ouest'];
$mailles = $this->getBdd()->recupererTous($requete, Bdd::MODE_OBJET);
// placer les totaux des nombres de stations dans des mailles vides
$maillage = new Maillage($this->criteresRecherche->bbox, $zoom, $this->nomSource);
$maillage->genererMaillesVides();
$maillage->ajouterMailles($mailles);
return $maillage->formaterSortie();
return $this->getBdd()->recupererTous($requete);
}
private function recupererNumeroNomenclaturauxTaxons(& $observations) {
for ($index = 0; $index < count($observations); $index ++) {
$taxon = isset($this->criteresRecherche->taxon) ? $this->criteresRecherche->taxon : null;
if (is_null($taxon) && strlen(trim($observations[$index]['nomSci'])) > 0) {
if (isset($this->criteresRecherche->taxon)) {
$taxon = $this->rechercherTaxonDansReferentiel($observations[$index]['nomSci'],
$this->criteresRecherche->referentiel);
} else {
$taxon = $this->obtenirNumeroTaxon($observations[$index]['nomSci']);
}
}
if (!is_null($taxon)) {
$observations[$index]['nn'] = $taxon['nn'];
$observations[$index]['num_referentiel'] = $taxon['referentiel'];
} else {
$observations[$index]['nn'] = '';
}
}
}
private function rechercherTaxonDansReferentiel($nomScientifique, $nomReferentiel) {
$referentiel = new Referentiel($nomReferentiel);
$taxon = $referentiel->obtenirNumeroNomenclatural($nomScientifique);
return $taxon;
}
private function obtenirNumeroTaxon($nomScientifique) {
$taxonTrouve = null;
$listeReferentiels = Referentiel::recupererListeReferentielsDisponibles();
foreach ($listeReferentiels as $nomReferentiel) {
$taxon = $this->rechercherTaxonDansReferentiel($nomScientifique, $nomReferentiel);
if (!is_null($taxon)) {
$taxonTrouve = $taxon;
break;
}
}
return $taxonTrouve;
}
}
 
?>