Subversion Repositories eFlore/Applications.cel

Compare Revisions

Ignore whitespace Rev 1137 → Rev 1138

/branches/v1.5-cisaille/jrest/services/CelWidgetMapPoint.php
143,45 → 143,23
 
public function getTout($params) {
 
$emplacements = null;
$coordonnees_nulles = "coord_x = '000null' OR coord_x = '' ".
" OR coord_y = '000null' OR coord_y = ''";
$coordonnees_non_nulles = "coord_x != '000null' AND coord_x != '' ".
" AND coord_y != '000null' AND coord_y != ''";
$coordonnees_non_nulles_pas_sensible = "(".$coordonnees_non_nulles." AND mots_cles_texte NOT LIKE '%sensible%')";
$emplacements = null;
$concatenation_id = 'CONCAT(coord_x,coord_y, wgs84_latitude,wgs84_longitude) ';
$requete = 'SELECT DISTINCT *, location AS nom, '.
"IF (".$coordonnees_non_nulles_pas_sensible.", ".
"'stations', ".
"'communes' ".
") as type_emplacement, ".
"IF (".$coordonnees_non_nulles_pas_sensible.", ".
"mots_cles_texte, ".
"coord_x, ".
"wgs84_latitude ".
") as lat, ".
"IF (".$coordonnees_non_nulles_pas_sensible.", ".
"wgs84_latitude, ".
"coord_y, ".
"wgs84_longitude ".
") as lng, ".
"IF (".$coordonnees_non_nulles_pas_sensible.", ".
'CONCAT("'.self::MARQUEUR_STATION.':",coord_x,"|",coord_y), '.
'CONCAT("'.self::MARQUEUR_COMMUNE.':",wgs84_latitude,"|",wgs84_longitude) '.
") as id ".
"wgs84_longitude, ".
$concatenation_id." as id_coord ".
'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().' AND ' : '').
"(".$coordonnees_nulles.")".
")".
" ) ".
") ".
$this->construireWhereRectangleStationOR()." OR ".
$this->construireWhereRectangleCommuneOR().") ".
$this->construireWhereDept().
$this->construireWhereCommune().
$this->construireWhereUtilisateur().
190,8 → 168,7
$this->construireWhereDate().
$this->construireWhereCommentaire().
$this->construireWhereProjet().
$this->construireWhereTag().' LIMIT 0,20000';
$this->construireWhereTag().' GROUP BY id_coord';
$resultats_emplacements = $this->executerRequete($requete);
$emplacements = $this->traiterEmplacements($resultats_emplacements, $this->compterObservations($params));
return $emplacements;
212,17 → 189,9
' 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%' ".
")".
" ) ".
") ".
" AND ".
"(".$this->construireWhereRectangleStationOR()." OR ".
$this->construireWhereRectangleCommuneOR().
$this->construireWhereDept().
$this->construireWhereCommune().
$this->construireWhereUtilisateur().
254,7 → 223,7
// 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();
// les bornes servent à centrer la carte dans le cas ou l'on demande des paramètres précis
$marqueurs['stats']['coordmax'] = CartoGroupage::getBornes();
$marqueurs['stats']['stations'] = $nb_elements['stations'];
$marqueurs['stats']['communes'] = $nb_elements['communes'];
397,6 → 366,7
" ON (l.name = i.location AND l.code = i.id_location) ".
"WHERE transmission = '1' ".
((!$this->etreNull($this->parametres['commune'])) ? $this->construireWhereCommuneSansCoordonneesAvecSensibles() : $this->construireWhereCoordonneesSansSensibles()).
$this->construireWhereDept().
$this->construireWhereUtilisateur().
$this->construireWhereNumTaxon().
$this->construireWhereNomTaxon().
406,7 → 376,6
$this->construireWhereTag().
'ORDER BY nom_sel ASC '.
"LIMIT {$this->start},{$this->limit} ";
 
$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);
616,7 → 585,7
$sql = " AND (coord_x = $lat AND coord_y = $lng) ";
}
}
$sql .= ' AND mots_cles_texte NOT LIKE %sensible%';
$sql .= ' AND mots_cles_texte NOT LIKE "%sensible%" ';
return $sql;
}
 
/branches/v1.5-cisaille/jrest/lib/CartoGroupage.php
1,6 → 1,10
<?php
class CartoGroupage {
 
const MARQUEUR_GROUPE = 'GROUPE';
const MARQUEUR_COMMUNE = 'COMMUNE';
const MARQUEUR_STATION = 'STATION';
private static $seuilClusterisation = 200;
private static $zoomDefaut = 3;
private static $zoomMaxClustering = 12;
14,13 → 18,9
private static $coefficientProfondeurMax = null;
private static $nbElements = array('stations' => 0,'communes' => 0, 'observations' => 0);
 
private static $listeNoeudsSelectionnes = array();
private static $pointsDejaTraites = array();
private static $listeNoeudsSelectionnes = array();
private static $bornesMax = array('latMin' => null, 'lngMin' => null, 'latMax' => null, 'lngMax' => null);
 
private static $id_traites = array();
/*
+---------+---------+
| | |
45,18 → 45,18
self::attribuerAuCadran($noeudRacine, $neLat, $neLng, $swLat, $swLng);
} else {
foreach($markers as $marker) {
self::mettreAJourBornes(&$marker);
$points = array($marker);
$noeudSimple = array('points' => $points, 'nbrePoints' => 1);
foreach($markers as &$marker) {
if(!self::estUnPointAExclure($marker)) {
$emplacement = self::formaterPointPourAjout(&$marker);
self::mettreAJourBornes(&$marker);
$points = array($marker);
$noeudSimple = array('points' => $points, 'nbrePoints' => 1);
self::$nbElements[$emplacement]++;
self::$listeNoeudsSelectionnes[] = self::ajouterGroupeOuPoint($noeudSimple);
}
self::$nbElements['observations']++;
$emplacement = isset($marker['type_emplacement']) ? $marker['type_emplacement'] : self::obtenirTypeEmplacementParId(&$marker);
self::$nbElements[$emplacement]++;
unset($marker['type_emplacement']);
self::$listeNoeudsSelectionnes[] = self::ajouterGroupeOuPoint($noeudSimple);
}
}
return self::$listeNoeudsSelectionnes;
}
117,14 → 117,15
$latCentre = round((($neLat+$swLat)/2)/self::$pasCorrectionCentre,0)*self::$pasCorrectionCentre;
$lngCentre = round((($neLng+$swLng)/2)/self::$pasCorrectionCentre,0)*self::$pasCorrectionCentre;
foreach ($noeud['points'] as &$point) {
foreach ($noeud['points'] as &$point) {
if(!self::estUnPointAExclure($point)) {
$emplacement = self::formaterPointPourAjout(&$point);
self::mettreAJourBornes(&$point);
self::$nbElements['observations']++;
$emplacement = isset($point['type_emplacement']) ? $point['type_emplacement'] : self::obtenirTypeEmplacementParId(&$point);
self::$nbElements[$emplacement]++;
unset($point['type_emplacement']);
$cadran = self::obtenirCadranPourPoint($latCentre, $lngCentre, $point);
self::ajouterFils($noeud,$cadran,$point);
self::$nbElements[$emplacement]++;
}
self::$nbElements['observations']++;
}
$profondeur++;
141,19 → 142,69
}
}
private static function obtenirTypeEmplacementParId($point) {
$tableau_point_id = explode(':',$point['id'],2);
switch($tableau_point_id[0]) {
case 'STATION':
$type_emplacement = 'stations';
break;
case 'COMMUNE':
$type_emplacement = 'communes';
break;
private static function estUnPointAExclure(&$point) {
return self::estSensible($point) &&
self::coordonneesCommuneSontNulles($point);
}
private static function coordonneesCommuneSontNulles(&$point) {
$coord_nulles = ($point['wgs84_latitude'] == null ||
$point['wgs84_latitude'] == '' ||
$point['wgs84_longitude'] == null ||
$point['wgs84_longitude'] == '');
return $coord_nulles;
}
private static function coordonneesSontNulles(&$point) {
$coord_nulles = ($point['coord_x'] == '000null' ||
$point['coord_x'] == '' ||
$point['coord_y'] == '000null' ||
$point['coord_y'] == '');
return $coord_nulles;
}
private static function estSensible(&$point) {
$sensible = isset($point['mots_cles_texte']) && substr_count($point['mots_cles_texte'], 'sensible') != 0;
return $sensible;
}
private static function formaterNomStation(&$point) {
$station = '';
if($point['station'] != '' && $point['station'] != '000null') {
$station = $point['station'];
} else {
$station = $point['location'].(($point['id_location'] != '' && $point['id_location'] != '000null') ? '('.$point['id_location'].')' : '');
}
return $type_emplacement;
return $station;
}
private static function formaterPointPourAjout(&$point) {
if(isset($point['type_emplacement'])) {
return $point['type_emplacement'];
}
if(self::coordonneesSontNulles($point) || self::estSensible($point)) {
$point['id'] = self::MARQUEUR_COMMUNE.':'.$point['wgs84_latitude'].'|'.$point['wgs84_longitude'];
$point['type_emplacement'] = 'communes';
$point['lat'] = (float)$point['wgs84_latitude'];
$point['lng'] = (float)$point['wgs84_longitude'];
} else {
$point_allege = array();
$point_allege['id'] = self::MARQUEUR_STATION.':'.$point['coord_x'].'|'.$point['coord_y'];
$point_allege['type_emplacement'] = 'stations';
$point_allege['nom'] = self::formaterNomStation($point);
$point_allege['lat'] = (float)$point['coord_x'];
$point_allege['lng'] = (float)$point['coord_y'];
$point = $point_allege;
}
return $point['type_emplacement'];
}
private function obtenirCadranPourPoint($latCentre,$lngCentre, &$point) {
if ($point['lng'] < $lngCentre) {
if ($point['lat'] > $latCentre) {
183,7 → 234,7
private static function ajouterGroupeOuPoint(&$noeud) {
$groupe = array();
if ($noeud['nbrePoints'] > 1) {
if ($noeud['nbrePoints'] > 1 && isset($noeud['latMoyenne']) && isset($noeud['lngMoyenne'])) {
$groupe['lat'] = $noeud['latMoyenne']/$noeud['nbrePoints'];
$groupe['lng'] = $noeud['lngMoyenne']/$noeud['nbrePoints'];
$groupe['id'] = 'GROUPE:'.$groupe['lat'].';'.$groupe['lng'];