Subversion Repositories eFlore/Applications.moissonnage

Compare Revisions

Ignore whitespace Rev 31 → Rev 27

/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/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;
}
}
 
?>
/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/configurations/config_baznat.ini
File deleted
\ No newline at end of file
/trunk/services/configurations/config_sophy.ini
9,7 → 9,6
; URL de base des services de ce projet
url_service="{ref:url_base}service:moissonnage:0.1/sophy"
 
referentiel_source = 'bdtfx';
 
[meta-donnees]
dureecache = 3600
/trunk/services/configurations/config.defaut.ini
77,17 → 77,11
carte.zoom_minimal = 3
carte.zoom_maximal = 18
zoom_maximal_maillage = 13
seuil_maillage = 250
seuil_maillage = 500
 
; valeurs des rangs au niveau de la classification des taxons
rang.genre = 180
rang.famille = 220
rang.espece = 290
rang.sous_espece = 320
 
; +------------------------------------------------------------------------------------------------------+
; Autres informations
sources_dispo = "floradata,sophy,baznat"
sources_dispo = "floradata,sophy"
source_defaut = "floradata"
services_dispo = "stations,observations"
referentiels_dispo = "bdtfx_v1_01,bdtxa_v1_00"
/trunk/services/bibliotheque/Referentiel.php
31,19 → 31,24
*
*/
 
define("RANG_FAMILLE", 180);
 
 
 
class Referentiel {
private $nomComplet;
private $nomCourt;
private $taxon;
private $bdd = null;
private $nomsChampsBdtfx = array('nn' => 'num_nom_retenu', 'nt' => 'num_taxonomique', 'ns' => 'nom_sci');
private $nomsChampsBdtxa = array('nn' => 'num_nom_retenu', 'nt' => 'num_tax', 'ns' => 'nom_sci');
private $champs;
public function __construct($nomReferentiel, $taxon = null) {
$this->nomComplet = $nomReferentiel;
$this->nomCourt = current(explode('_', $nomReferentiel));
53,7 → 58,9
}
$this->taxon = $taxon;
}
public function renvoyerNomCompletReferentiel() {
return $this->nomComplet;
}
62,16 → 69,15
return $this->taxon;
}
public function chargerTaxon($typeNumero, $numTaxon) {
public function chargerTaxon($numTaxon) {
$taxon = null;
// verifier que le numero de taxon soit bien une chaine de caracteres composee uniquement
// que de nombres entiers avant de construire la requete SQL a executer
if (preg_match('/^\d+$/', $numTaxon) == 1) {
$champWhere = $typeNumero == 'nt' ? $this->champs['nt']: 'num_nom';
$requete =
"SELECT ".$this->champs['nn']." AS nn, ".$this->champs['nt']." AS nt, ".
$this->champs['ns']." AS nom, rang FROM ".$this->nomComplet." WHERE ".
$champWhere."={$numTaxon} AND num_nom=".$this->champs['nn']." ".
$this->champs['nt']."={$numTaxon} AND num_nom=".$this->champs['nn']." ".
"ORDER BY rang, If(num_nom=".$this->champs['nn'].", 0, 1) LIMIT 0, 1";
$taxon = $this->getBdd()->recuperer($requete);
if ($taxon == false) {
83,21 → 89,10
$this->taxon = $taxon;
}
private function getBdd() {
if (is_null($this->bdd)) {
$this->bdd = new Bdd();
}
$nomBdd = Config::get('bdd_eflore');
if (is_null($nomBdd)) {
$nomBdd = Config::get('bdd_nom');
}
$this->bdd->requeter("USE ".$nomBdd);
return $this->bdd;
}
public function recupererTaxonsSousEspeces($listeNn = null) {
public function recupererSousTaxons($listeNn = null) {
$sousTaxons = array();
if (!is_null($this->taxon) && $this->taxon['rang'] == Config::get('rang.espece')) {
if (!is_null($this->taxon) && $this->taxon['rang'] >= RANG_FAMILLE) {
if (is_null($listeNn)) {
$listeNn = $this->taxon['nn'];
}
114,24 → 109,28
}
// recherche de sous taxons au niveau inferieur (parcours recursif de la methode)
if (count($resultats) > 0) {
$sousTaxons = array_merge($sousTaxons, $this->recupererTaxonsSousEspeces($nouvelleListeNn));
$sousTaxons = array_merge($sousTaxons, $this->recupererSousTaxons($nouvelleListeNn));
}
}
return $sousTaxons;
}
public function recupererTaxonsFamilles() {
$sousTaxons = array();
if (!is_null($this->taxon) && $this->taxon['rang'] == Config::get('rang.genre')) {
$requete =
"SELECT ".$this->champs['nn']." AS nn, ".$this->champs['nt']." AS nt, ".
$this->champs['ns']." AS nom, rang FROM ".$this->nomComplet." WHERE ".
"num_tax_sup=".$this->taxon['nn']." AND num_nom=".$this->champs['nn'];
$sousTaxons = $this->getBdd()->recupererTous($requete);
private function getBdd() {
if (is_null($this->bdd)) {
$this->bdd = new Bdd();
}
return $sousTaxons;
$nomBdd = Config::get('bdd_eflore');
if (is_null($nomBdd)) {
$nomBdd = Config::get('bdd_nom');
}
$this->bdd->requeter("USE ".$nomBdd);
return $this->bdd;
}
public static function recupererListeReferentielsDisponibles() {
$tableau = array();
$tableauPartiel = explode(',', Config::get('referentiels_dispo'));
/trunk/services/bibliotheque/Maillage.php
10,7 → 10,7
private $indexLatitude;
private $mailles;
private $bdd = null;
private $bdd = null;
66,7 → 66,6
") ORDER BY axe, position";
$indexMailles = $this->getBdd()->recupererTous($requete);
foreach ($indexMailles as $index) {
if ($index['axe'] == 'lng') {
$this->indexLongitude[$index['position']] = array($index['debut'], $index['fin']);
90,7 → 89,7
public function ajouterPoints(& $points) {
foreach ($points as $point) {
foreach ($points as $index => $point) {
list($longitude, $latitude) = $this->obtenirCoordonneesPoint($point);
list($indexLongitude, $indexLatitude) = $this->rechercherIndexMaille($longitude, $latitude);
$this->mailles[$indexLatitude][$indexLongitude]->ajouterPoint($point);
97,15 → 96,6
}
}
public function ajouterMailles(& $mailles) {
foreach ($mailles as $maille) {
$longitude = ($maille->longitudeOuest + $maille->longitudeEst) / 2;
$latitude = ($maille->latitudeSud + $maille->latitudeNord) / 2;
list($indexLongitude, $indexLatitude) = $this->rechercherIndexMaille($longitude, $latitude);
$this->mailles[$indexLatitude][$indexLongitude]->combinerMailles($maille);
}
}
private function obtenirCoordonneesPoint($point) {
$longitude = 0;
$latitude = 0;
133,31 → 123,107
return array($indexLongitude, $indexLatitude);
}
 
public function formaterSortie($toutesLesMailles = false) {
public function formaterSortie() {
$mailles_resume = array();
foreach ($this->mailles as $ligne) {
foreach ($ligne as $maille) {
$nombrePoints = $maille->getNombrePoints();
if ($nombrePoints > 0 || $toutesLesMailles) {
if ($nombrePoints == 0)
continue;
$mailles_resume[] = array(
'zoom' => $this->zoom,
'sud' => $maille->getLatitudeSud(),
'ouest' => $maille->getLongitudeOuest(),
'nord' => $maille->getLatitudeNord(),
'est' => $maille->getLongitudeEst(),
'points' => $nombrePoints,
'type_site' => 'MAILLE'
);
}
}
if (count($mailles_resume) == 0 || count($mailles_resume[0]) == 0)
return array();
return $mailles_resume;
}
public function formaterPourInsertionBdd() {
$mailles_resume = array();
foreach ($this->mailles as $ligne) {
foreach ($ligne as $maille) {
if ($maille->getNombrePoints() > 0) {
$mailles_resume[] = array(
'zoom' => $this->zoom,
'sud' => $maille->getLatitudeSud(),
'ouest' => $maille->getLongitudeOuest(),
'nord' => $maille->getLatitudeNord(),
'est' => $maille->getLongitudeEst(),
'points' => $nombrePoints,
'observations' => $maille->getNombreObservations(),
'type_site' => 'MAILLE'
'zoom' => $this->zoom,
'sud' => $maille->getLatitudeSud(),
'ouest' => $maille->getLongitudeOuest(),
'nord' => $maille->getLatitudeNord(),
'est' => $maille->getLongitudeEst(),
'indexLat' => $maille->getIndexLatitude(),
'indexLng' => $maille->getIndexLongitude(),
'points' => $maille->getNombrePoints()
);
}
}
}
if (count($mailles_resume) == 0 || count($mailles_resume[0]) == 0)
if (count($mailles_resume[0]) == 0)
return array();
return $mailles_resume;
}
 
public function zoomer() {
$this->zoom += 1;
}
// redecoupage des mailles en 4 (fonction quadtree)
// TODO : revoir le fonctionnement de cette methode (pour utilisation par les scripts uniquement)
public function redecouperMailles() {
$bdd = new Bdd();
while (count($this->indexLatitude) > 0) {
array_pop($this->indexLatitude);
}
while (count($this->indexLongitude) > 0) {
array_pop($this->indexLongitude);
}
$mailles = $this->resumePourInsertionBdd();
while (count($this->mailles) > 0) {
array_pop($this->mailles);
}
foreach ($mailles as $maille) {
$indexLat = 2 * $maille['indexLat'];
$indexLng = 2 * $maille['indexLng'];
// rechercher les nouvelles coordonnees des mailles au niveau de zoom inferieur
$requete = "SELECT axe,position,debut,fin FROM mailles_index WHERE zoom=". $this->zoom ." AND ((axe='lat'"
. " AND (position={$indexLat} OR position=" . ($indexLat+1) . ")) OR (axe='lng' AND"
. " (position={$indexLng} OR position=" . ($indexLng+1) . "))) ORDER BY If(axe='lat',0,1)";
$resultats = $bdd->recupererTous($requete);
$this->indexLatitude[$indexLat] = array($resultats[0]['debut'], $resultats[0]['fin']);
$this->indexLatitude[$indexLat+1] = array($resultats[1]['debut'], $resultats[1]['fin']);
$this->indexLongitude[$indexLng] = array($resultats[2]['debut'], $resultats[2]['fin']);
$this->indexLongitude[$indexLng+1] = array($resultats[3]['debut'], $resultats[3]['fin']);
}
ksort($this->indexLatitude);
ksort($this->indexLongitude);
// creer et ajouter les nouvelles mailles a partir des nouveaux index
foreach ($this->indexLatitude as $indexLat => $intervalleLat) {
$ligne = array();
foreach ($this->indexLongitude as $indexLng => $intervalleLng) {
$ligne[] = new Maille($intervalleLat[0], $intervalleLng[0], $intervalleLat[1],
$intervalleLng[1], $indexLat, $indexLng);
}
$this->mailles[] = $ligne;
}
 
}
public function getNombreMailles() {
return count($this->mailles);
}
}
 
?>
/trunk/services/bibliotheque/VerificateurParametres.php
22,7 → 22,6
* On va verifier la disponibilite du referentiel pour ce service
*
* - num_taxon : numero taxonomique d'une espece
* - nn : numero nomenclatural d'une espece
* On va rechercher sa presence dans les referentiels disponibles
* (les informations principales sur ce taxon seront renvoyees)
*
31,13 → 30,6
*
* - auteur : l'auteur de l'observation
*
* - type_site : pour les observations, le type de point correspondant a la station cliquee
* (STATION ou COMMUNE). Cela indique le niveau de precision ramene aux coordonnees des observations
*
* - date_debut et date_fin : intervalle de dates d'observation. On verifie que ce sont des dates valides
* et que date_debut <= date_fin. Le programme peut accepter la presence d'un seul de ces deux
* parametres : soit une date de debut, soit une date de fin
*
* La fonction principale de verification des parametres va parcourir tous les parametres, et verifier
* pour chacun d'eux la validite de leurs valeurs. Dans le cas ou une valeur anormale est detectee
* ou qu'elle se trouve en dehors de l'intervalle des resultats acceptes, une liste de messages d'erreur
63,7 → 55,6
private $parametres = array();
private $validation = null;
private $erreurs = array();
private $dateTraitee = false;
private $bboxMonde = null;
102,22 → 93,6
break;
case 'num_taxon' : $this->traiterParametreTaxon($valeur);
break;
case 'nn' : $this->traiterParametreNomenclatural($valeur);
break;
case 'type_site' : $this->traiterParametreTypeSite($valeur);
break;
case 'nb_jours' : $this->traiterParametreNbJours($valeur);
break;
case 'date_debut' :
case 'date_fin' : {
$dateDebut = isset($this->parametres['date_debut']) ? $this->parametres['date_debut'] : null;
$dateFin = isset($this->parametres['date_fin']) ? $this->parametres['date_fin'] : null;
if (!$this->dateTraitee) {
$this->traiterParametresDate($dateDebut, $dateFin);
$this->dateTraitee = true;
}
break;
}
// autres parametres ==> les ignorer
default : break;
}
232,9 → 207,7
private function estUnCodeDepartementValide($departement) {
// expression reguliere pour verifier que c'est un nombre entier a 2 ou 3 chiffres
$estUnDepartementValide = true;
if ($departement == '2A' || $departement == '2B') {
$estUnDepartementValide = true;
} elseif (preg_match('/^\d{2,3}$/', $departement) != 1) {
if (preg_match('/^\d{2,3}$/', $departement) != 1) {
$estUnDepartementValide = false;
} else {
if ((intval($departement) < 1 || intval($departement) > 95)
241,7 → 214,7
&& (intval($departement) < 971 || intval($departement) > 978)) {
$estUnDepartementValide = false;
}
}
}
return $estUnDepartementValide;
}
251,10 → 224,6
}
}
private function traiterParametreTypeSite($typeSite) {
$this->validation->typeSite = strtolower(trim($typeSite));
}
private function traiterParametreReferentiel($referentiel) {
if (!isset($this->validation->referentiel) && $referentiel != '*') {
$referentielAUtiliser = $this->affecterNomCompletReferentiel($referentiel);
282,51 → 251,29
private function traiterParametreTaxon($numeroTaxon) {
if ($numeroTaxon != '*') {
$listeTaxons = explode(',', $numeroTaxon);
foreach ($listeTaxons as $nt) {
$taxon = null;
if (isset($this->validation->referentiel)) {
$taxon = $this->renvoyerTaxonDansReferentiel($nt, 'nt', $this->validation->referentiel);
} else {
$taxon = $this->rechercherTaxonDansReferentiels($nt, 'nt');
}
if (is_null($taxon)) {
$message = "Le numéro de taxon n'a pas permis de retrouver le taxon associé.";
$this->ajouterErreur($message);
} else {
$this->ajouterTaxonAListe($taxon);
$this->validation->referentiel = $taxon['referentiel'];
}
$taxon = null;
if (isset($this->validation->referentiel)) {
$taxon = $this->renvoyerTaxonDansReferentiel($numeroTaxon, $this->validation->referentiel);
} else {
// parcours de tous les referentiels jusqu'a retrouver le taxon dans sa liste
$taxon = $this->rechercherTaxonDansReferentiels($numeroTaxon);
}
}
}
private function traiterParametreNomenclatural($numeroNomenclatural) {
if ($numeroNomenclatural != '*') {
$listeTaxons = explode(',', $numeroNomenclatural);
foreach ($listeTaxons as $nn) {
$taxon = null;
if (isset($this->validation->referentiel)) {
$taxon = $this->renvoyerTaxonDansReferentiel($nn, 'nn', $this->validation->referentiel);
} else {
$taxon = $this->rechercherTaxonDansReferentiels($nn, 'nn');
}
if (is_null($taxon)) {
$message = "Le numéro nomenclatural n'a pas permis de retrouver le taxon associé.";
$this->ajouterErreur($message);
} else {
$this->ajouterTaxonAListe($taxon);
$this->validation->referentiel = $taxon['referentiel'];
}
if (is_null($taxon)) {
$message = "Le numéro de taxon n'a pas permis de retrouver le taxon associé.";
$this->ajouterErreur($message);
} else {
$this->validation->taxon = $taxon;
$this->validation->referentiel = $taxon['referentiel'];
}
}
}
private function rechercherTaxonDansReferentiels($numeroTaxon, $typeNumero) {
private function rechercherTaxonDansReferentiels($numeroTaxon) {
$taxon = null;
$listeReferentiels = Referentiel::recupererListeReferentielsDisponibles();
foreach ($listeReferentiels as $nomReferentiel) {
$taxon = $this->renvoyerTaxonDansReferentiel($numeroTaxon, $typeNumero, $nomReferentiel);
$taxon = $this->renvoyerTaxonDansReferentiel($numeroTaxon, $nomReferentiel);
if (!is_null($taxon)) {
break;
}
334,69 → 281,13
return $taxon;
}
private function renvoyerTaxonDansReferentiel($numeroTaxon, $typeNumero, $nomReferentiel) {
private function renvoyerTaxonDansReferentiel($numeroTaxon, $nomReferentiel) {
$referentiel = new Referentiel($nomReferentiel);
$referentiel->chargerTaxon($typeNumero, $numeroTaxon);
$referentiel->chargerTaxon($numeroTaxon);
$taxon = $referentiel->renvoyerTaxon();
return $taxon;
}
private function ajouterTaxonAListe($taxon) {
if (!isset($this->validation->taxon)) {
$this->validation->taxon = array($taxon);
} elseif (!in_array($taxon, $this->validation->taxon)) {
$this->validation->taxon[] = $taxon;
}
}
private function traiterParametresDate($dateDebut, $dateFin) {
$statutValidite = $this->verifierValiditeDate($dateDebut, 'début')
+ $this->verifierValiditeDate($dateFin, 'fin');
if ($statutValidite == 2) {
if (!is_null($dateDebut) && !is_null($dateFin) && $dateDebut > $dateFin) {
$message = "Intervalle de dates incorrect : date de fin avant la date de début";
$this->ajouterErreur($message);
} else {
$this->validation->dateDebut = $dateDebut;
$this->validation->dateFin = $dateFin;
}
}
}
private function verifierValiditeDate(& $date, $position) {
$statutValidite = is_null($date) ? 1 : 0;
$moisParDefaut = $position == 'début' ? 1 : 12;
$jourParDefaut = $position == 'début' ? 1 : 31;
if (!is_null($date)) {
$split = explode("-", $date);
$annee = intval($split[0]);
$mois = isset($split[1]) ? intval($split[1]) : $moisParDefaut;
$jour = isset($split[2]) ? intval($split[2]) : $jourParDefaut;
if (!$this->estDateValide($jour, $mois, $annee)) {
$message = "Date de {$position} saisie non valide";
$this->ajouterErreur($message);
} else {
$date = $annee."-".(($mois<10)?"0".$mois:$mois)."-".(($jour<10)?"0".$jour:$jour);
$dateDuJour = date('Y-m-d');
if ($date > $dateDuJour) {
$message = "La date de {$position} saisie postérieure à la date du jour : {$dateDuJour}";
$this->ajouterErreur($message);
} else {
$statutValidite = 1;
}
}
}
return $statutValidite;
}
private function estDateValide($jour, $mois, $annee) {
$estBissextile = (($annee % 4 == 0 && $annee % 100 != 0) || ($annee % 400 == 0));
$dureeFevrier = $estBissextile ? 29 : 28;
$dureeMois = array(1 => 31, 2 => $dureeFevrier, 3 => 31, 4 => 30, 5 => 31, 6 => 30, 7 => 31,
8 => 31, 9 => 30, 10 => 31, 11 => 30, 12 => 31);
return ($annee >= 1900 && $mois >= 1 && $mois <= 12 && $jour >= 1 && $jour <= $dureeMois[$mois]);
}
private function verifierPresenceParametreSpatial() {
$presenceParametreSpatial = false;
if (isset($this->parametres['bbox'])
409,16 → 300,6
}
}
private function traiterParametreNbJours($nbJours) {
// verifier que c'est un nombre entier positif (avec expression reguliere)
if (preg_match('/^\d+$/', $nbJours) != 1) {
$message = "La valeur passée pour le nombre de jours doit être un entier positif.";
$this->ajouterErreur($message);
} elseif ($nbJours > 0) {
$this->validation->nbJours = intval($nbJours);
}
}
}
 
?>
/trunk/services/bibliotheque/FormateurJson.php
5,7 → 5,7
private $sourceDonnees;
public function __construct($source = '') {
public function __construct($source) {
$this->sourceDonnees = $source;
}
14,24 → 14,23
$objetJSON = new StdClass();
$objetJSON->type = "FeatureCollection";
$objetJSON->stats = new StdClass();
$objetJSON->stats->source = $this->sourceDonnees;
$objetJSON->stats->formeDonnees = '';
if (count($stations) > 0) {
$objetJSON->stats->formeDonnees = ($stations[0]['type_site'] == 'MAILLE') ? 'maille' : 'point';
}
$objetJSON->stats->sites = 0;
$objetJSON->stats->observations = 0;
$objetJSON->stats->communes = 0;
$objetJSON->stats->stations = 0;
$objetJSON->features = array();
foreach ($stations as $station) {
$stationJSON = NULL;
// construction d'un objet feature adapte a la structure des donnees spatiales
if ($station['type_site'] == 'MAILLE') {
$stationJSON = $this->formaterMaille($station);
$objetJSON->stats->sites += $station['points'];
} else {
$objetJSON->stats->sites ++;
if ($station['type_site'] == 'STATION') {
$objetJSON->stats->communes ++;
} else {
$objetJSON->stats->stations ++;
}
$stationJSON = $this->formaterPoint($station);
}
$objetJSON->stats->observations += $station['observations'];
if (!is_null($stationJSON)) {
$objetJSON->features[] = $stationJSON;
}
45,7 → 44,6
$json->geometry = new StdClass();
$json->properties = new StdClass();
$json->geometry->type = "Point";
$json->properties->source = $this->sourceDonnees;
$json->properties->typeSite = $station['type_site'];
if ($this->sourceDonnees == 'floradata' && $station['type_site'] == 'COMMUNE') {
$json->geometry->coordinates = array($station['lat_commune'], $station['lng_commune']);
56,6 → 54,7
if ($this->sourceDonnees == 'floradata') {
$json->properties->nom = $this->construireNomStationFloradata($station);
} else {
$station['code_insee'] = '';
$codeDepartement = $this->extraireCodeDepartement($station['code_insee']);
$json->properties->nom = trim($station['nom'])." ({$codeDepartement})";
}
72,7 → 71,7
if (strlen($nom) == 0) {
$nom = 'station sans nom, '.trim($station['zone_geo']);
}
$nom .= " ({$codeDepartement})";
$nom .= " ({$codeDepartement})";;
}
return $nom;
}
88,6 → 87,9
private function formaterMaille($maille) {
if ($maille['points'] == 0) {
return null;
}
$json = new StdClass();
$json->type = "Feature";
$json->geometry = new StdClass();
100,8 → 102,7
array(floatval($maille['sud']), floatval($maille['ouest']))
);
$json->properties = new StdClass();
$json->properties->source = $this->sourceDonnees;
$json->properties->typeSite = 'MAILLE';
$json->properties->typeSite = $maille['type_site'];
$json->properties->nombrePoints = $maille['points'];
return $json;
}
135,20 → 136,6
return $url;
}
public function formaterMaillesVides($mailles) {
$objetJSON = new StdClass();
$objetJSON->type = "FeatureCollection";
$objetJSON->stats = new StdClass();
$objetJSON->stats->source = '';
$objetJSON->stats->formeDonnees = 'maille';
$objetJSON->stats->sites = 0;
$objetJSON->features = array();
foreach ($mailles as $maille) {
$objetJSON->features[] = $this->formaterMaille($maille);
}
return $objetJSON;
}
}
 
?>
/trunk/services/bibliotheque/Maille.php
10,9 → 10,7
private $indexLongitude;
private $points = array();
private $nombrePoints;
private $observations = array();
private $nombreObservations;
private $nombrePoints = 0;
public function __construct($sud, $ouest, $nord, $est, $indexLat, $indexLng) {
24,11 → 22,9
$this->indexLongitude = $indexLng;
}
public function ajouterPoint($point) {
public function ajouterPoint(& $point) {
$this->points[] = $point;
$this->nombrePoints ++;
$this->observations[] = $point['observations'];
$this->nombreObservations += $point['observations'];
}
public function getLatitudeNord() {
55,31 → 51,18
return $this->indexLongitude;
}
public function getPoints() {
return $this->points;
}
public function getNombrePoints() {
return $this->nombrePoints;
}
public function getObservations() {
return $this->observations;
public function getPoint($index = 0) {
return (!isset($this->points[$index])) ? NULL : $this->points[$index];
}
public function getNombreObservations() {
return $this->nombreObservations;
}
 
public function totalNonNul() {
return count($this->points) > 0;
return !is_null($this->nombrePoints);
}
public function combinerMailles(& $maille) {
$this->nombrePoints += $maille->nombre_sites;
$this->nombreObservations += $maille->nombre_observations;
}
}
 
?>