Subversion Repositories eFlore/Applications.cel

Compare Revisions

Ignore whitespace Rev 1621 → Rev 1622

/trunk/jrest/services/CelWidgetMapPoint.php
90,38 → 90,43
}
 
public function getTout($params) {
$emplacements = null;
 
$emplacements = null;
$concatenation_id = "CONCAT(IFNULL(latitude,''),IFNULL(longitude,''), IFNULL(wgs84_latitude,''),IFNULL(wgs84_longitude,'')) ";
 
$requete = 'SELECT ce_zone_geo, zone_geo, station, '.
' mots_cles_texte, latitude, wgs84_latitude, longitude, wgs84_longitude, '.
" $concatenation_id AS id_coord ".
'FROM cel_obs AS co '.
' LEFT JOIN cel_zones_geo AS l '.
' ON (l.nom = co.zone_geo AND l.id_zone_geo = co.ce_zone_geo) '.
"WHERE transmission = '1' ".
" AND (".
$this->construireWhereRectangleStationOR()." OR ".
$this->construireWhereRectangleCommuneOR().") ".
$this->construireWhereDept().
$this->construireWhereCommune().
$this->construireWhereUtilisateur().
$this->construireWhereNumTaxonAvecSousTaxons().
$this->construireWhereNomTaxon().
$this->construireWhereReferentiel().
$this->construireWhereDate().
$this->construireWhereCommentaire().
$this->construireWherePhotosSeulement().
$this->construireWhereProjet().
$this->construireWhereTag().
$this->construireWhereNombreDeJours().
' GROUP BY id_coord';
 
$requete = 'SELECT ce_zone_geo, zone_geo, station, '.
"mots_cles_texte, ".
"latitude, ".
"wgs84_latitude, ".
"longitude, ".
"wgs84_longitude, ".
$concatenation_id." as id_coord ".
'FROM cel_obs AS co '.
' LEFT JOIN cel_zones_geo AS l '.
' ON (l.nom = co.zone_geo AND l.id_zone_geo = co.ce_zone_geo) '.
"WHERE transmission = '1' ".
" AND (".
$this->construireWhereRectangleStationOR()." OR ".
$this->construireWhereRectangleCommuneOR().") ".
$this->construireWhereDept().
$this->construireWhereCommune().
$this->construireWhereUtilisateur().
$this->construireWhereNumTaxonAvecSousTaxons().
$this->construireWhereNomTaxon().
$this->construireWhereReferentiel().
$this->construireWhereDate().
$this->construireWhereCommentaire().
$this->construireWherePhotosSeulement().
$this->construireWhereProjet().
$this->construireWhereTag().
$this->construireWhereNombreDeJours().
' GROUP BY id_coord';
$resultats_emplacements = $this->executerRequete($requete);
$emplacements = $this->traiterEmplacements($resultats_emplacements, $this->compterObservations($params));
return $emplacements;
}
 
private function afficherRequeteFormatee($requete) {
$requete = str_replace(')',')<br />',$requete);
$requete = str_replace('(',' <br /> (',$requete);
133,25 → 138,25
 
private function compterObservations($params) {
$requete = 'SELECT COUNT(*) as nb '.
'FROM cel_obs AS co '.
' LEFT JOIN cel_zones_geo AS l '.
' ON (l.nom = co.zone_geo AND l.id_zone_geo = co.ce_zone_geo) '.
"WHERE transmission = '1' ".
" AND (".
$this->construireWhereRectangleStationOR()." OR ".
$this->construireWhereRectangleCommuneOR().") ".
$this->construireWhereDept().
$this->construireWhereCommune().
$this->construireWhereUtilisateur().
$this->construireWhereNumTaxonAvecSousTaxons().
$this->construireWhereNomTaxon().
$this->construireWhereReferentiel().
$this->construireWhereDate().
$this->construireWhereCommentaire().
$this->construireWherePhotosSeulement().
$this->construireWhereProjet().
$this->construireWhereTag().
$this->construireWhereNombreDeJours();
'FROM cel_obs AS co '.
' LEFT JOIN cel_zones_geo AS l '.
' ON (l.nom = co.zone_geo AND l.id_zone_geo = co.ce_zone_geo) '.
"WHERE transmission = '1' ".
" AND (".
$this->construireWhereRectangleStationOR()." OR ".
$this->construireWhereRectangleCommuneOR().") ".
$this->construireWhereDept().
$this->construireWhereCommune().
$this->construireWhereUtilisateur().
$this->construireWhereNumTaxonAvecSousTaxons().
$this->construireWhereNomTaxon().
$this->construireWhereReferentiel().
$this->construireWhereDate().
$this->construireWhereCommentaire().
$this->construireWherePhotosSeulement().
$this->construireWhereProjet().
$this->construireWhereTag().
$this->construireWhereNombreDeJours();
 
$resultats_nb_obs = $this->executerRequete($requete);
return $resultats_nb_obs[0]['nb'];
244,7 → 249,7
if (isset($this->parametres['ne']) && $this->parametres['sw'] && ! $this->etreNull($this->parametres['ne']) && ! $this->etreNull($this->parametres['ne']) && ! $this->etreNull($this->parametres['sw'])) {
$ne = $this->decomposerLatLng($this->parametres['ne']);
$sw = $this->decomposerLatLng($this->parametres['sw']);
$marqueurs['points'] = CartoGroupage::creerGroupesQuadtree($points, $ne['lat'], $ne['lng'], $sw['lat'], $sw['lng'], $zoom);
$marqueurs['points'] = CartoGroupage::creerGroupesQuadtree(&$points, $ne['lat'], $ne['lng'], $sw['lat'], $sw['lng'], $zoom);
} else {
$marqueurs['points'] = $points;
}
299,14 → 304,14
}
return $sensible;
}
 
private function communeEstDemandee() {
$station_infos = $this->decomposerParametreStation();
$commune_demandee = true;
if ($station_infos['type'] == self::MARQUEUR_STATION) {
$station_infos = $this->decomposerParametreStation();
$commune_demandee = true;
if($station_infos['type'] == self::MARQUEUR_STATION) {
$commune_demandee = false;
}
return $commune_demandee;
}
return $commune_demandee;
}
 
/**
317,27 → 322,27
$total = 0;
if (isset($this->parametres['station']) && !$this->etreNull($this->parametres['station'])) {
$requete = 'SELECT SQL_CALC_FOUND_ROWS id_observation, ce_utilisateur, courriel_utilisateur, nom_utilisateur, prenom_utilisateur, '.
' nom_sel, nom_ret, nom_sel_nn, nom_ret_nn, nt, famille, '.
' lieudit, zone_geo, date_observation, milieu, commentaire, '.
' utm_secteur, utm_x, utm_y, code, date_transmission '.
'FROM cel_obs AS co '.
' LEFT JOIN cel_zones_geo AS l '.
" ON (l.nom = co.zone_geo AND l.id_zone_geo = co.ce_zone_geo) ".
"WHERE transmission = '1' ".
(($this->communeEstDemandee()) ? $this->construireWhereCommuneSansCoordonneesAvecSensibles() : $this->construireWhereCoordonneesSansSensibles()).
$this->construireWhereDept().
$this->construireWhereUtilisateur().
$this->construireWhereNumTaxonAvecSousTaxons().
$this->construireWhereNomTaxon().
$this->construireWhereReferentiel().
$this->construireWhereDate().
$this->construireWhereCommentaire().
$this->construireWherePhotosSeulement().
$this->construireWhereProjet().
$this->construireWhereTag().
$this->construireWhereNombreDeJours().
'ORDER BY nom_sel ASC '.
"LIMIT {$this->start},{$this->limit} ";
' nom_sel, nom_ret, nom_sel_nn, nom_ret_nn, nt, famille, '.
' lieudit, zone_geo, date_observation, milieu, commentaire, '.
' utm_secteur, utm_x, utm_y, code, date_transmission, nom_referentiel '.
'FROM cel_obs AS co '.
' LEFT JOIN cel_zones_geo AS l '.
" ON (l.nom = co.zone_geo AND l.id_zone_geo = co.ce_zone_geo) ".
"WHERE transmission = '1' ".
(($this->communeEstDemandee()) ? $this->construireWhereCommuneSansCoordonneesAvecSensibles() : $this->construireWhereCoordonneesSansSensibles()).
$this->construireWhereDept().
$this->construireWhereUtilisateur().
$this->construireWhereNumTaxonAvecSousTaxons().
$this->construireWhereNomTaxon().
$this->construireWhereReferentiel().
$this->construireWhereDate().
$this->construireWhereCommentaire().
$this->construireWherePhotosSeulement().
$this->construireWhereProjet().
$this->construireWhereTag().
$this->construireWhereNombreDeJours().
'ORDER BY nom_sel ASC '.
"LIMIT {$this->start},{$this->limit} ";
//echo $requete;exit;
$resultats = $this->requeter($requete, self::SQL_RETOUR_COMPLET, self::SQL_MODE_OBJET);
$requete = 'SELECT FOUND_ROWS()';
368,7 → 373,7
$observation['lieu'] = $this->traiterLieu($donnee);
$observation['observateur'] = $donnee->courriel_utilisateur;
$observation['observateurId'] = $donnee->ce_utilisateur;
$observation['urlEflore'] = $this->getUrlEflore($donnee->nom_sel_nn);
$observation['urlEflore'] = $this->getUrlEflore($donnee->nom_referentiel, $donnee->nom_sel_nn);
 
if (isset($donnee->zone_geo)) {
$observations['commune'] = $this->nettoyerTexte($donnee->zone_geo);
383,14 → 388,6
return $observations;
}
 
private function getUrlEflore($nn) {
$urlEflore = null;
if (! $this->etreNull($nn)) {
$urlEflore = sprintf($this->config['settings']['efloreUrlTpl'], $nn, 'illustration');
}
return $urlEflore;
}
 
private function traiterLieu($donnee) {
$lieu = array();
if (!$this->etreNull($donnee->lieudit)) {
441,7 → 438,7
}
return $observations;
}
 
private function ajouterAuteursAuxObs($observations) {
$observateurs = $this->recupererUtilisateursIdentite(array_keys($observations['observateurs']));
unset($observations['observateurs']);
473,25 → 470,25
$json = null;
 
$requete = 'SELECT SQL_CALC_FOUND_ROWS DISTINCT nom_ret, nom_ret_nn, nt, famille '.
'FROM cel_obs AS co '.
' LEFT JOIN cel_zones_geo AS l '.
' ON (l.nom = co.zone_geo AND l.id_zone_geo = co.ce_zone_geo) '.
"WHERE transmission = '1' ".
" AND nom_ret != '' ".
$this->construireWhereDept().
$this->construireWhereCommune().
$this->construireWhereUtilisateur().
$this->construireWhereNumTaxon().
$this->construireWhereNomTaxon().
$this->construireWhereReferentiel().
$this->construireWhereDate().
$this->construireWhereCommentaire().
$this->construireWherePhotosSeulement().
$this->construireWhereProjet().
$this->construireWhereTag().
$this->construireWhereNombreDeJours().
'ORDER BY nom_ret ASC '.
"LIMIT {$this->start},{$this->limit} ";
'FROM cel_obs AS co '.
' LEFT JOIN cel_zones_geo AS l '.
' ON (l.nom = co.zone_geo AND l.id_zone_geo = co.ce_zone_geo) '.
"WHERE transmission = '1' ".
" AND nom_ret != '' ".
$this->construireWhereDept().
$this->construireWhereCommune().
$this->construireWhereUtilisateur().
$this->construireWhereNumTaxon().
$this->construireWhereNomTaxon().
$this->construireWhereReferentiel().
$this->construireWhereDate().
$this->construireWhereCommentaire().
$this->construireWherePhotosSeulement().
$this->construireWhereProjet().
$this->construireWhereTag().
$this->construireWhereNombreDeJours().
'ORDER BY nom_ret ASC '.
"LIMIT {$this->start},{$this->limit} ";
//$this->debug[] = $requete;
$resultats = $this->requeter($requete, self::SQL_RETOUR_COMPLET, self::SQL_MODE_OBJET);
//echo $requete;exit;
539,7 → 536,7
}
return $sql;
}
 
private function construireWhereCoordonneesSansSensibles() {
$sql = '(';
// Récupération des coordonnées depuis l'id station
613,7 → 610,7
}
return $sql;
}
 
private function construireWhereReferentiel() {
$sql = '';
extract($this->parametres);
832,12 → 829,12
$sql = "( (latitude != 0 AND longitude != 0) ".
" AND latitude BETWEEN $latMin AND $latMax ".
" AND longitude BETWEEN $lngMin AND $lngMax )";
 
/*$sql = " MBRWithin(mon_point, GeomFromText('POLYGON((".$latMin.' '.$lngMin.','.
$latMax.' '.$lngMin.','.
$latMax.' '.$lngMax.','.
$latMax.' '.$lngMin.','.
$latMin.' '.$lngMin."))')) "; */
$latMin.' '.$lngMin."))')) "; */
}
return $sql;
}
876,7 → 873,7
$sql = "( wgs84_longitude != 0 AND wgs84_latitude != 0 ".
" AND wgs84_latitude BETWEEN $latMin AND $latMax ".
" AND wgs84_longitude BETWEEN $lngMin AND $lngMax )";
 
/*$sql = " MBRWithin(point_commune, GeomFromText('POLYGON((".$latMin.' '.$lngMin.','.
$latMax.' '.$lngMin.','.
$latMax.' '.$lngMax.','.
926,12 → 923,12
')'.
' OR mots_cles_texte LIKE "%sensible%"'.
') ';
 
}
return $sql;
}
 
 
private function construireWherePhotosSeulement() {
$sql = '';
if (isset($this->parametres['photos']) && $this->parametres['photos'] == 1) {
951,8 → 948,8
}
return $sql;
}
 
 
private function construireWhereNumTaxon() {
$sql = '';
// Récupération des coordonnées depuis l'id station
963,7 → 960,7
}
return $sql;
}
 
private function construireWhereNumTaxonAvecSousTaxons() {
$sql = '';
// Récupération des coordonnées depuis l'id station
984,7 → 981,7
}
return $sql;
}
 
private function obtenirSousTaxons($nt) {
$referentiel = 'bdtfx';
if($this->parametres['referentiel'] && $this->parametres['referentiel'] != "" && $this->parametres['referentiel'] != '*') {
1008,7 → 1005,7
}
return $sql;
}
 
/**
* Traitement de $projet pour construction du filtre dans la requête
*/
1019,7 → 1016,7
}
return $sql;
}
 
private function construireWhereTag() {
$sql = '';
extract($this->parametres);
1029,7 → 1026,7
}
return $sql;
}
 
private function construireWhereNombreDeJours() {
$sql = null;
extract($this->parametres);
1038,7 → 1035,7
}
return $sql;
}
 
/**
* Traitement de $tag pour construction du filtre dans la requête
*/
1067,10 → 1064,10
//$this->debug[] = $requete;
//die($requete);
$elements_tag = $this->executerRequete($requete);
 
$requete_tag = array();
if ($elements_tag != false && count($elements_tag) > 0) {
 
$filtres = array();
foreach ($elements_tag as $occurence) {
$utilisateur = $occurence['utilisateur'];
1082,13 → 1079,13
$filtres[$utilisateur][$id_obs] = $id_obs;
}
}
 
// Pré-construction du where de la requête
$tpl_where = "(id_observation IN (%s))";
foreach ($filtres as $utilisateur => $id_obs) {
$requete_tag[] = sprintf($tpl_where, implode(',', $id_obs));
}
 
} else {
$this->messages[] = "Aucune observation ne possède d'images avec ce mot-clé.";
}
1098,7 → 1095,7
}
return $sql;
}
 
/**
* Traitement de $tag pour construction du filtre dans la requête
*/
1110,7 → 1107,7
//$this->debug[] = $sql;
return $sql;
}
 
/**
* Traitement de $tag pour construction du filtre dans la requête
*/
1122,9 → 1119,9
$where_mots_cles_images = implode(' '.$mots_cles_encodes['type'].' ', $where_mots_cles_images);
return $where_mots_cles_images;
}
 
private function decomposerParametreTag($tags) {
 
$mots_cles = array('type' => null, 'motsCles' => null, 'motsClesEncodesProteges' => null);
if (preg_match('/.+OU.+/', $tags)) {
$mots_cles['type'] = 'OR';
1135,7 → 1132,7
} else {
$mots_cles['motsCles'][] = $tags;
}
 
foreach ($mots_cles['motsCles'] as $mot) {
$mots_cles['motsClesEncodesProteges'][] = $this->bdd->quote('%'.$mot.'%');
}