23,9 → 23,7 |
*/ |
// TODO : supprimer le TRIM quand les obs seront reliées correctements aux localisations (sur le code INSEE par exemple) |
class CelWidgetMap extends Cel { |
const MARQUEUR_GROUPE = 'GROUPE'; |
const MARQUEUR_COMMUNE = 'COMMUNE'; |
const MARQUEUR_STATION = 'STATION'; |
|
/** |
* Méthode appelée avec une requête de type GET. |
*/ |
32,7 → 30,6 |
public function getElement($ressources) { |
$retour = null; |
extract($this->parametres); |
//Chronometre::chrono("Avant groupage"); |
|
$action = array_shift($ressources); |
if (isset($action)) { |
46,19 → 43,14 |
$this->messages[] = "Vous devez indiquer le type de ressource."; |
} |
|
//Chronometre::chrono("Apres traitement"); |
//echo Chronometre::afficherChrono(); |
if (is_null($retour)) { |
$info = 'Un problème est survenu : '.print_r($this->messages, true); |
$this->envoyer($info); |
} else if (isset($retour['type']) && $retour['type'] == 'jsonVar') { |
} else if ($retour['type'] == 'jsonVar') { |
|
$this->envoyerJsonVar($retour['variable_js'], $retour['donnees']); |
} else if (isset($retour['type']) && $retour['type'] == 'jsonP') { |
} else if ($retour['type'] == 'jsonP') { |
$this->envoyerJsonp($retour['donnees']); |
} else if (isset($retour['type']) && $retour['type'] == 'png') { |
header("Content-type: image/png"); |
imagepng($retour['img']); |
imagedestroy($retour['img']); |
} else { |
$this->envoyerJson($retour); |
} |
65,42 → 57,15 |
} |
|
/** |
* Les icones des groupes de stations |
*/ |
public function getIconeGroupe($params) { |
extract($this->parametres); |
|
$chemin_marqueur = sprintf($this->config['settings']['cheminCelMarkerObsTpl'], $type); |
$img = imagecreatefrompng($chemin_marqueur); |
|
$noir = imagecolorallocate($img, 0, 0, 0); |
$texte = (String) $nbre; |
$x = (imagesx($img) - 6.0 * strlen($texte)) / 2; |
$y = (imagesy($img) - 16) / 2; |
|
imagestring($img, 3, $x, $y, $texte, $noir); |
|
imagealphablending($img, false); |
imagesavealpha($img, true); |
|
return array('type' => 'png', 'img' => $img); |
} |
|
/** |
* Les stations de la carte par défaut |
*/ |
public function getStations($params) { |
$stations = null; |
$requete = 'SELECT wgs84_latitude AS lat, wgs84_longitude AS lng, location AS nom '. |
$json = null; |
$requete = 'SELECT sector, x_utm, y_utm, wgs84_latitude AS coord_x, wgs84_longitude AS coord_y '. |
'FROM cel_inventory AS i '. |
' LEFT JOIN locations AS l '. |
' ON (l.name = i.location AND l.code = i.id_location) '. |
"WHERE transmission = '1' ". |
" AND (( ". |
" (coord_x = '' OR coord_x IS NULL OR coord_x = '000null') ". |
" AND (coord_y = '' OR coord_y IS NULL OR coord_y = '000null') ". |
" ) OR mots_cles_texte LIKE '%sensible%') ". |
$this->construireWhereRectangleCommune(). |
$this->construireWhereDept(). |
$this->construireWhereCommune(). |
$this->construireWhereUtilisateur(). |
110,229 → 75,24 |
$this->construireWhereCommentaire(). |
$this->construireWhereProjet(). |
$this->construireWhereTag(); |
//die($requete); |
$resultats = $this->requeter($requete); |
|
$resultats_communes = $this->requeter($requete); |
// Traitement des résultats |
$obs_nbre = $this->traiterNbreObs($resultats); |
$stations = $this->traiterStations($resultats); |
|
$requete = 'SELECT coord_x AS lat, coord_y AS lng, location AS nom '. |
'FROM cel_inventory AS i '. |
' LEFT JOIN locations AS l '. |
' ON (l.name = i.location AND l.code = i.id_location) '. |
"WHERE transmission = '1' ". |
" AND coord_x != '' AND coord_x IS NOT NULL AND coord_x != '000null' ". |
" AND coord_y != '' AND coord_y IS NOT NULL AND coord_y != '000null' ". |
" AND (mots_cles_texte IS NULL OR mots_cles_texte NOT LIKE '%sensible%') ". |
$this->construireWhereRectangleStation(). |
$this->construireWhereDept(). |
$this->construireWhereCommune(). |
$this->construireWhereUtilisateur(). |
$this->construireWhereNumTaxon(). |
$this->construireWhereNomTaxon(). |
$this->construireWhereDate(). |
$this->construireWhereCommentaire(). |
$this->construireWhereProjet(). |
$this->construireWhereTag(); |
// Création des infos du widget |
$json['donnees']['points'] = $stations; |
$json['donnees']['stats']['communes'] = count($stations); |
$json['donnees']['stats']['observations'] = $obs_nbre; |
|
$resultats_stations = $this->requeter($requete); |
$stations = $this->traiterStations($resultats_communes, $resultats_stations); |
$json['type'] = (isset($this->formatRetour)) ? $this->formatRetour : 'jsonVar'; |
$json['variable_js'] = 'stations'; |
|
return $stations; |
return $json; |
} |
|
public function getTout($params) { |
|
$emplacements = null; |
$requete = 'SELECT DISTINCT location AS nom, '. |
"IF ((coord_x != '000null' AND coord_x != '' ". |
" AND coord_y != '000null' AND coord_y != ''), ". |
"'stations', ". |
"'communes' ". |
") as type_emplacement, ". |
"IF ((coord_x != '000null' AND coord_x != '' ". |
" AND coord_y != '000null' AND coord_y != ''), ". |
"coord_x, ". |
"wgs84_latitude ". |
") as lat, ". |
"IF ((coord_x != '000null' AND coord_x != '' ". |
" AND coord_y != '000null' AND coord_y != ''), ". |
"coord_y, ". |
"wgs84_longitude ". |
") as lng, ". |
"IF ((coord_x != '000null' AND coord_x != '' ". |
" AND coord_y != '000null' AND coord_y != ''), ". |
'CONCAT("'.self::MARQUEUR_STATION.':",coord_x,"|",coord_y), '. |
'CONCAT("'.self::MARQUEUR_COMMUNE.':",wgs84_latitude,"|",wgs84_longitude) '. |
") as id ". |
'FROM cel_inventory AS i '. |
' LEFT JOIN locations AS l '. |
' ON (l.name = i.location AND l.code = i.id_location) '. |
"WHERE transmission = '1' ". |
" AND (". |
"(".($this->construireWhereRectangleStationOR() != null ? $this->construireWhereRectangleStationOR().' AND ' : ''). |
" (mots_cles_texte IS NULL OR mots_cles_texte NOT LIKE '%sensible%') ". |
")". |
" OR ". |
" ( ". |
"(".($this->construireWhereRectangleCommuneOR() != null ? $this->construireWhereRectangleCommuneOR().' Or ' : ''). |
" mots_cles_texte LIKE '%sensible%' ". |
")". |
" ) ". |
") ". |
$this->construireWhereDept(). |
$this->construireWhereCommune(). |
$this->construireWhereUtilisateur(). |
$this->construireWhereNumTaxon(). |
$this->construireWhereNomTaxon(). |
$this->construireWhereDate(). |
$this->construireWhereCommentaire(). |
$this->construireWhereProjet(). |
$this->construireWhereTag(); |
|
$resultats_emplacements = $this->executerRequete($requete); |
$emplacements = $this->traiterEmplacements($resultats_emplacements, $this->compterObservations($params)); |
|
return $emplacements; |
} |
|
private $nb_obs = 0; |
|
private function compterObservations($params) { |
$requete = 'SELECT COUNT(*) AS nb '. |
'FROM cel_inventory AS i '. |
' LEFT JOIN locations AS l '. |
' ON (l.name = i.location AND l.code = i.id_location) '. |
"WHERE transmission = '1' ". |
" AND (". |
"(".($this->construireWhereRectangleStationOR() != null ? $this->construireWhereRectangleStationOR().' AND ' : ''). |
" (mots_cles_texte IS NULL OR mots_cles_texte NOT LIKE '%sensible%') ". |
")". |
" OR ". |
" ( ". |
"(".($this->construireWhereRectangleCommuneOR() != null ? $this->construireWhereRectangleCommuneOR().' Or ' : ''). |
" mots_cles_texte LIKE '%sensible%' ". |
")". |
" ) ". |
") ". |
$this->construireWhereDept(). |
$this->construireWhereCommune(). |
$this->construireWhereUtilisateur(). |
$this->construireWhereNumTaxon(). |
$this->construireWhereNomTaxon(). |
$this->construireWhereDate(). |
$this->construireWhereCommentaire(). |
$this->construireWhereProjet(). |
$this->construireWhereTag(); |
|
$resultats_nb_obs = $this->executerRequete($requete); |
return $resultats_nb_obs[0]['nb']; |
} |
|
private function traiterEmplacements(&$emplacements, $nb_total_observation) { |
$zoom = (int) array_key_exists('zoom', $this->parametres) ? $this->parametres['zoom'] : 11; |
$distance = (int) array_key_exists('distance', $this->parametres) ? $this->parametres['distance'] : 20; |
|
$marqueurs = array( |
'stats' => array('stations' => 0, 'communes' => 0, 'observations' => 0), |
'points' => null |
); |
|
if (! $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($emplacements, $ne['lat'], $ne['lng'], $sw['lat'], $sw['lng'], $zoom); |
|
// laisser la classe cartoGroupage compter les élements simplifie le comptage |
// et permet de ne pas reparser le tableau pour compter les différents éléments |
$nb_elements = CartoGroupage::getNbElements(); |
|
$marqueurs['stats']['stations'] = $nb_elements['stations']; |
$marqueurs['stats']['communes'] = $nb_elements['communes']; |
$marqueurs['stats']['observations'] = (int)$nb_total_observation; |
} else { |
$marqueurs['points'] = $emplacements; |
} |
|
return $marqueurs; |
} |
|
private function traiterStations($communes, $stations) { |
$zoom = (int) array_key_exists('zoom', $this->parametres) ? $this->parametres['zoom'] : 11; |
$distance = (int) array_key_exists('distance', $this->parametres) ? $this->parametres['distance'] : 20; |
|
$marqueurs = array( |
'stats' => array('stations' => 0, 'communes' => 0, 'observations' => 0), |
'points' => null |
); |
$marqueurs['stats']['observations'] = $this->traiterNbreObs($communes) + $this->traiterNbreObs($stations); |
|
$points = array(); |
if ($communes !== false) { |
foreach ($communes as $commune) { |
if (is_numeric($commune['lat']) && is_numeric($commune['lng'])) { |
extract($commune); |
$id = self::MARQUEUR_COMMUNE.':'.$lat.'|'.$lng; |
//$this->definirLatLngMaxMin($marqueurs, $lat, $lng); |
$lata = round($lat, 5); |
$lnga = round($lng, 5); |
|
if (!isset($points[$id])) { |
$points[$id]['id'] = $id; |
$points[$id]['nom'] = $nom; |
$points[$id]['lat'] = $lata; |
$points[$id]['lng'] = $lnga; |
$points[$id]['nbre'] = 1; |
$marqueurs['stats']['communes']++; |
} else { |
$points[$id]['nbre']++; |
} |
} |
} |
} |
if ($stations !== false) { |
foreach ($stations as $station) { |
if (is_numeric($station['lat']) && is_numeric($station['lng'])) { |
extract($station); |
$id = self::MARQUEUR_STATION.':'.$lat.'|'.$lng; |
//$this->definirLatLngMaxMin($marqueurs, $lat, $lng); |
$lata = round($lat, 5); |
$lnga = round($lng, 5); |
$nom = $this->etreNull($nom) ? $lata.','.$lnga : $nom; |
|
if (!isset($points[$id])) { |
$points[$id]['id'] = $id; |
$points[$id]['nom'] = $nom; |
$points[$id]['lat'] = $lata; |
$points[$id]['lng'] = $lnga; |
$points[$id]['nbre'] = 1; |
$marqueurs['stats']['stations']++; |
} else { |
$points[$id]['nbre']++; |
} |
} |
} |
} |
|
if (! $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); |
} else { |
$marqueurs['points'] = $points; |
} |
//$marqueurs['stats']['latDiff'] = abs($marqueurs['stats']['latMin'] - $marqueurs['stats']['latMax']); |
//$marqueurs['stats']['lngDiff'] = abs($marqueurs['stats']['lngMin'] - $marqueurs['stats']['lngMax']); |
|
return $marqueurs; |
} |
|
private function definirLatLngMaxMin(&$marqueurs, $lat, $lng) { |
if ($lat != null && $lng != null) { |
$marqueurs['stats']['latMin'] = $marqueurs['stats']['latMin'] > $lat ? $lat : $marqueurs['stats']['latMin']; |
$marqueurs['stats']['lngMin'] = $marqueurs['stats']['lngMin'] > $lng ? $lng : $marqueurs['stats']['lngMin']; |
$marqueurs['stats']['latMax'] = $marqueurs['stats']['latMax'] < $lat ? $lat : $marqueurs['stats']['latMax']; |
$marqueurs['stats']['lngMax'] = $marqueurs['stats']['lngMax'] < $lng ? $lng : $marqueurs['stats']['lngMax']; |
} |
} |
|
private function traiterNbreObs($resultats) { |
$obs_nbre = 0; |
if ($resultats !== false) { |
341,33 → 101,27 |
return $obs_nbre; |
} |
|
private function verifierLatLng($lat, $lng) { |
$ok_lat = $this->etreLatitude($lat) ? true : false; |
$ok_lng = $this->etreLongitude($lng) ? true : false; |
$ok = $ok_lat && $ok_lng; |
return $ok; |
private function traiterStations($resultats) { |
$stations = array(); |
if ($resultats !== false) { |
foreach ($resultats as $enrg) { |
if ($enrg['coord_x'] != null && $enrg['coord_y'] != null) { |
$id = $enrg['coord_x'].'-'.$enrg['coord_y']; |
if (!isset($stations[$id])) { |
$enrg['id'] = 'UTM:'.$enrg['x_utm'].'-'.$enrg['y_utm'].'-'.$enrg['sector']; |
unset($enrg['x_utm']); |
unset($enrg['y_utm']); |
unset($enrg['sector']); |
$stations[$id] = $enrg; |
$stations[$id]['nbre'] = 1; |
} else { |
$stations[$id]['nbre']++; |
} |
|
private function etreLatitude($lat) { |
$ok = false; |
//$format = preg_match('/^[-]?[0-9]+(?:[.][0-9]+|)$/', $lat) ? true : false; |
$ok = ($lat >= -90 && $lat <= 90) ? true : false; |
return $ok; |
} |
|
private function etreLongitude($lng) { |
$ok = false; |
//$format = preg_match('/^[-]?[0-9]+(?:[.][0-9]+|)$/', $lng) ? true : false; |
$ok = ($lng >= -180 && $lng <= 180) ? true : false; |
return $ok; |
} |
|
private function etreObsSensible($tags) { |
$sensible = true; |
if (stristr($tags, 'sensible') === FALSE) { |
$sensible = false; |
$stations = array_values($stations); |
} |
return $sensible; |
return $stations; |
} |
|
/** |
384,7 → 138,7 |
' LEFT JOIN locations AS l '. |
" ON (l.name = i.location AND l.code = i.id_location) ". |
"WHERE transmission = '1' ". |
((!$this->etreNull($this->parametres['commune'])) ? $this->construireWhereCommuneSansCoordonnees() : $this->construireWhereCoordonnees()). |
$this->construireWhereCoordonnees(). |
$this->construireWhereUtilisateur(). |
$this->construireWhereNumTaxon(). |
$this->construireWhereNomTaxon(). |
394,8 → 148,9 |
$this->construireWhereTag(). |
'ORDER BY nom_sel ASC '. |
"LIMIT {$this->start},{$this->limit} "; |
//die($requete); |
$resultats = $this->requeter($requete, self::SQL_RETOUR_COMPLET, self::SQL_MODE_OBJET); |
|
$resultats = $this->requeter($requete, self::SQL_RETOUR_COMPLET, self::SQL_MODE_OBJET); |
$requete = 'SELECT FOUND_ROWS()'; |
$total = (int) $this->requeter($requete, self::SQL_RETOUR_COLONNE); |
} |
405,7 → 160,6 |
$observations = $this->ajouterImagesAuxObs($observations); |
$observations = $this->ajouterAuteursAuxObs($observations); |
$observations = $this->supprimerIdDesObs($observations); |
|
return $observations; |
} |
|
488,11 → 242,9 |
private function ajouterImagesAuxObs($observations) { |
$images = $this->chargerImages(array_keys($observations['observations'])); |
foreach ($observations['observations'] as $id => $infos) { |
if(isset($images[$id])) { |
$infos['images'] = $images[$id]; |
$observations['observations'][$id] = $infos; |
} |
} |
return $observations; |
} |
|
538,7 → 290,7 |
$this->construireWhereDate(). |
$this->construireWhereCommentaire(). |
$this->construireWhereProjet(). |
$this->construireWhereTag(). |
$this->construireWhereTag(); |
'ORDER BY nom_ret ASC '. |
"LIMIT {$this->start},{$this->limit} "; |
//$this->debug[] = $requete; |
576,14 → 328,17 |
// Récupération des coordonnées depuis l'id station |
extract($this->decomposerParametreStation()); |
if (isset($type)) { |
if ($type == self::MARQUEUR_COMMUNE) { |
$lat = $this->proteger($lat); |
$lng = $this->proteger($lng); |
$sql = " AND (ROUND(wgs84_latitude,5) = ROUND($lat,5) AND ROUND(wgs84_longitude,5) = ROUND($lng,5)) "; |
} else if ($type == self::MARQUEUR_STATION) { |
$lat = $this->proteger($lat); |
$lng = $this->proteger($lng); |
$sql = " AND (coord_x = $lat AND coord_y = $lng) "; |
if ($type == 'UTM') { |
$secteur = $this->proteger($secteur); |
$x_utm = $this->proteger($x_utm); |
$y_utm = $this->proteger($y_utm); |
|
$sql = " AND (sector = $secteur AND x_utm = $x_utm AND y_utm = $y_utm ) "; |
} else if ($type == 'LngLat') { |
$coord_x = $this->proteger($coord_x); |
$coord_y = $this->proteger($coord_y); |
|
$sql = " AND (coord_x = $coord_x AND coord_y = $coord_y ) "; |
} |
} |
return $sql; |
814,97 → 569,11 |
return $sql; |
} |
|
private function construireWhereRectangleStation() { |
$sql = ''; |
if (! $this->etreNull($this->parametres['ne']) && ! $this->etreNull($this->parametres['sw'])) { |
$ne = $this->decomposerLatLng($this->parametres['ne']); |
$sw = $this->decomposerLatLng($this->parametres['sw']); |
|
$latMin = $sw['lat']; |
$lngMin = $sw['lng']; |
|
$latMax = $ne['lat']; |
$lngMax = $ne['lng']; |
|
// ATTENTION : coord_x correspond bien à la LATITUDE! |
$sql = " AND (coord_x != 0 AND coord_y != 0) ". |
" AND coord_x > $latMin ". |
" AND coord_x < $latMax ". |
" AND coord_y > $lngMin ". |
" AND coord_y < $lngMax "; |
} |
return $sql; |
} |
|
private function construireWhereRectangleStationOR() { |
$sql = ''; |
if (! $this->etreNull($this->parametres['ne']) && ! $this->etreNull($this->parametres['sw'])) { |
$ne = $this->decomposerLatLng($this->parametres['ne']); |
$sw = $this->decomposerLatLng($this->parametres['sw']); |
|
$latMin = $sw['lat']; |
$lngMin = $sw['lng']; |
|
$latMax = $ne['lat']; |
$lngMax = $ne['lng']; |
|
// ATTENTION : coord_x correspond bien à la LATITUDE! |
$sql = "( (coord_x != 0 AND coord_y != 0) ". |
" AND coord_x > $latMin ". |
" AND coord_x < $latMax ". |
" AND coord_y > $lngMin ". |
" AND coord_y < $lngMax )"; |
} |
return $sql; |
} |
|
private function construireWhereRectangleCommune() { |
$sql = ''; |
if (! $this->etreNull($this->parametres['ne']) && ! $this->etreNull($this->parametres['sw'])) { |
$ne = $this->decomposerLatLng($this->parametres['ne']); |
$sw = $this->decomposerLatLng($this->parametres['sw']); |
|
$latMin = $sw['lat']; |
$lngMin = $sw['lng']; |
|
$latMax = $ne['lat']; |
$lngMax = $ne['lng']; |
|
$sql = "AND wgs84_longitude != 0 AND wgs84_latitude != 0 ". |
" AND wgs84_latitude > $latMin ". |
" AND wgs84_latitude < $latMax ". |
" AND wgs84_longitude > $lngMin ". |
" AND wgs84_longitude < $lngMax "; |
} |
return $sql; |
} |
|
private function construireWhereRectangleCommuneOR() { |
$sql = ''; |
if (! $this->etreNull($this->parametres['ne']) && ! $this->etreNull($this->parametres['sw'])) { |
$ne = $this->decomposerLatLng($this->parametres['ne']); |
$sw = $this->decomposerLatLng($this->parametres['sw']); |
|
$latMin = $sw['lat']; |
$lngMin = $sw['lng']; |
|
$latMax = $ne['lat']; |
$lngMax = $ne['lng']; |
|
$sql = "( wgs84_longitude != 0 AND wgs84_latitude != 0 ". |
" AND wgs84_latitude > $latMin ". |
" AND wgs84_latitude < $latMax ". |
" AND wgs84_longitude > $lngMin ". |
" AND wgs84_longitude < $lngMax )"; |
} |
return $sql; |
} |
|
private function construireWhereDept() { |
$sql = ''; |
// Récupération des coordonnées depuis l'id station |
extract($this->parametres); |
if (!$this->etreNull($dept)) { |
if (isset($dept) && !$this->etreNull($dept)) { |
$dept = $this->traiterValeursMultiples($dept); |
$sql = " AND code IN ($dept) "; |
} |
915,7 → 584,7 |
$sql = ''; |
// Récupération des coordonnées depuis l'id station |
extract($this->parametres); |
if (!$this->etreNull($commune)) { |
if (isset($commune) && !$this->etreNull($commune)) { |
$commune = $this->proteger($commune); |
$sql = " AND location LIKE $commune "; |
} |
922,24 → 591,12 |
return $sql; |
} |
|
private function construireWhereCommuneSansCoordonnees() { |
$sql = ''; |
// Récupération des coordonnées depuis l'id station |
extract($this->parametres); |
if (!$this->etreNull($commune)) { |
$commune = $this->proteger($commune); |
$sql = " AND location LIKE $commune "; |
$sql .= " AND ((coord_x = '000null' OR coord_x = '') ". |
" AND (coord_y = '000null' OR coord_y = '')) "; |
} |
return $sql; |
} |
|
private function construireWhereUtilisateur() { |
$sql = ''; |
// Récupération des coordonnées depuis l'id station |
extract($this->parametres); |
if (!$this->etreNull($utilisateur)) { |
if (isset($utilisateur) && !$this->etreNull($utilisateur)) { |
$utilisateur = $this->proteger($utilisateur); |
$sql = " AND identifiant = $utilisateur "; |
} |
950,7 → 607,7 |
$sql = ''; |
// Récupération des coordonnées depuis l'id station |
extract($this->parametres); |
if (!$this->etreNull($num_taxon)) { |
if (isset($num_taxon) && !$this->etreNull($num_taxon)) { |
$num_taxon = $this->proteger($num_taxon); |
$sql = " AND num_taxon = $num_taxon "; |
} |
961,7 → 618,7 |
$sql = ''; |
// Récupération des coordonnées depuis l'id station |
extract($this->parametres); |
$projet_sql = $this->getSqlWhereProjet($projet); |
$projet_sql = isset($projet) ? $this->getSqlWhereProjet($projet) : null; |
if (!$this->etreNull($projet_sql)) { |
$sql = " AND ($projet_sql) "; |
} |
973,7 → 630,7 |
*/ |
private function getSqlWhereProjet($projet) { |
$sql = null; |
if (! $this->etreNull($projet)) { |
if (isset($projet) && !$this->etreNull($projet)) { |
$mot_cle_encode = $this->bdd->quote($this->encoderMotCle($projet)); |
|
// Construction de la requête |
1004,7 → 661,7 |
$sql = ''; |
// Récupération des coordonnées depuis l'id station |
extract($this->parametres); |
$tag_sql = $this->getSqlWhereObsAvecImagesTaguees($tag); |
$tag_sql = isset($tag) ? $this->getSqlWhereObsAvecImagesTaguees($tag) : null; |
if (!$this->etreNull($tag_sql)) { |
$sql = " AND ($tag_sql) "; |
} |
1016,7 → 673,7 |
*/ |
private function getSqlWhereObsAvecImagesTaguees($tag) { |
$sql = null; |
if (! $this->etreNull($tag)) { |
if (isset($tag) && !$this->etreNull($tag)) { |
$tag_sql = $this->getSqlWhereMotsCles($tag); |
// Construction de la requête |
$requete = 'SELECT DISTINCT coi_ce_observation AS ordre, coi_ce_utilisateur AS utilisateur '. |
1155,30 → 812,27 |
return $mots_cles; |
} |
|
private function decomposerLatLng($coord) { |
$lat_lng = array(); |
if (isset($coord)) { |
list($lat, $lng) = explode('|', $coord); |
$lat_lng = array('lat' => $lat, 'lng' => $lng); |
} |
return $lat_lng; |
} |
|
private function decomposerParametreStation() { |
$station_infos = array(); |
if (isset($this->parametres['station'])) { |
$station = $this->parametres['station']; |
$this->debug[] = $station; |
@list($type, $coord) = explode(':', $station); |
@list($lat, $lng) = explode('|', $coord); |
list($type, $coord) = explode(':', $station); |
|
$station_infos = array('type' => $type, 'lat' => $lat, 'lng' => $lng); |
if ($type == 'UTM') { |
list($x_utm, $y_utm, $secteur) = explode('-', $coord); |
$station_infos = array('x_utm' => $x_utm, 'y_utm' => $y_utm, 'secteur' => $secteur); |
} else if ($type == 'LngLat') { |
list($coord_y, $coord_x) = explode('-', $coord); |
$station_infos = array('coord_y' => $coord_y, 'coord_x' => $coord_x); |
} |
$station_infos['type'] = $type; |
} |
return $station_infos; |
} |
|
private function decomposerParametreDate() { |
$date_infos = array(); |
$date_infos = array(null,null); |
if (isset($this->parametres['date'])) { |
$date = $this->parametres['date']; |
if (strpos($date, ':')) { |
1198,7 → 852,7 |
} |
|
private function decomposerParametreTaxon() { |
$nom_infos = array(); |
$nom_infos = array(null, null); |
if (isset($this->parametres['taxon'])) { |
$taxon = $this->parametres['taxon']; |
if (strpos($taxon, ':')) { |
1211,7 → 865,7 |
} |
|
private function decomposerParametreCommentaire() { |
$commentaire_infos = array(); |
$commentaire_infos = array(null, null); |
if (isset($this->parametres['commentaire'])) { |
$commentaire = $this->parametres['commentaire']; |
if (strpos($commentaire, ':')) { |