Subversion Repositories eFlore/Applications.cel

Compare Revisions

Ignore whitespace Rev 1582 → Rev 1585

/trunk/jrest/services/CelWidgetMapPoint.php
90,43 → 90,38
}
 
public function getTout($params) {
$emplacements = null;
$concatenation_id = "CONCAT(IFNULL(latitude,''),IFNULL(longitude,''), IFNULL(wgs84_latitude,''),IFNULL(wgs84_longitude,'')) ";
 
$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);
138,25 → 133,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'];
249,7 → 244,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;
}
304,14 → 299,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;
}
 
/**
322,27 → 317,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 '.
'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()';
446,7 → 441,7
}
return $observations;
}
 
private function ajouterAuteursAuxObs($observations) {
$observateurs = $this->recupererUtilisateursIdentite(array_keys($observations['observateurs']));
unset($observations['observateurs']);
478,25 → 473,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;
544,7 → 539,7
}
return $sql;
}
 
private function construireWhereCoordonneesSansSensibles() {
$sql = '(';
// Récupération des coordonnées depuis l'id station
618,7 → 613,7
}
return $sql;
}
 
private function construireWhereReferentiel() {
$sql = '';
extract($this->parametres);
837,12 → 832,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;
}
881,7 → 876,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.','.
931,12 → 926,12
')'.
' OR mots_cles_texte LIKE "%sensible%"'.
') ';
 
}
return $sql;
}
 
 
private function construireWherePhotosSeulement() {
$sql = '';
if (isset($this->parametres['photos']) && $this->parametres['photos'] == 1) {
956,8 → 951,8
}
return $sql;
}
 
 
private function construireWhereNumTaxon() {
$sql = '';
// Récupération des coordonnées depuis l'id station
968,7 → 963,7
}
return $sql;
}
 
private function construireWhereNumTaxonAvecSousTaxons() {
$sql = '';
// Récupération des coordonnées depuis l'id station
989,7 → 984,7
}
return $sql;
}
 
private function obtenirSousTaxons($nt) {
$referentiel = 'bdtfx';
if($this->parametres['referentiel'] && $this->parametres['referentiel'] != "" && $this->parametres['referentiel'] != '*') {
1013,7 → 1008,7
}
return $sql;
}
 
/**
* Traitement de $projet pour construction du filtre dans la requête
*/
1024,7 → 1019,7
}
return $sql;
}
 
private function construireWhereTag() {
$sql = '';
extract($this->parametres);
1034,7 → 1029,7
}
return $sql;
}
 
private function construireWhereNombreDeJours() {
$sql = null;
extract($this->parametres);
1043,7 → 1038,7
}
return $sql;
}
 
/**
* Traitement de $tag pour construction du filtre dans la requête
*/
1072,10 → 1067,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'];
1087,13 → 1082,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é.";
}
1103,7 → 1098,7
}
return $sql;
}
 
/**
* Traitement de $tag pour construction du filtre dans la requête
*/
1115,7 → 1110,7
//$this->debug[] = $sql;
return $sql;
}
 
/**
* Traitement de $tag pour construction du filtre dans la requête
*/
1127,9 → 1122,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';
1140,7 → 1135,7
} else {
$mots_cles['motsCles'][] = $tags;
}
 
foreach ($mots_cles['motsCles'] as $mot) {
$mots_cles['motsClesEncodesProteges'][] = $this->bdd->quote('%'.$mot.'%');
}
/trunk/jrest/lib/CartoGroupage.php
1,10 → 1,9
<?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;
12,13 → 11,13
private static $pasZoomMaxClustering = 0.05;
private static $profondeurMin = 0;
private static $profondeurMax = 8;
 
private static $pasCorrectionCentre = null;
private static $coefficientReductionPas = null;
private static $coefficientReductionPas = null;
private static $coefficientProfondeurMax = null;
 
private static $nbElements = array('stations' => 0,'communes' => 0, 'points' => 0);
private static $listeNoeudsSelectionnes = array();
private static $listeNoeudsSelectionnes = array();
private static $bornesMax = array('latMin' => null, 'lngMin' => null, 'latMax' => null, 'lngMax' => null);
private static $id_traites = array();
/*
31,24 → 30,24
| D | C |
| | |
+---------+---------+
 
Quatres cadrans sont considérés par le quad tree
* = centre de la fenetre
* = centre de la fenetre
*/
public static function creerGroupesQuadtree(&$markers, $neLat, $neLng, $swLat, $swLng, $zoom = 3) {
if(count($markers) > self::$seuilClusterisation) {
if (count($markers) > self::$seuilClusterisation) {
 
self::calculerProfondeurMax($zoom);
self::calculerPasCorrectionCentre($zoom);
 
$noeudRacine = array('nbrePoints' => count($markers), 'points' => $markers);
self::attribuerAuCadran($noeudRacine, $neLat, $neLng, $swLat, $swLng);
self::attribuerAuCadran($noeudRacine, $neLat, $neLng, $swLat, $swLng);
 
} else {
foreach($markers as &$marker) {
foreach($markers as &$marker) {
if(!self::estUnPointAExclure($marker)) {
$emplacement = self::formaterPointPourAjout(&$marker);
self::mettreAJourBornes(&$marker);
$emplacement = self::formaterPointPourAjout($marker);
self::mettreAJourBornes($marker);
$points = array($marker);
$noeudSimple = array('points' => $points, 'nbrePoints' => 1);
self::$nbElements[$emplacement]++;
59,72 → 58,70
}
return self::$listeNoeudsSelectionnes;
}
 
private function calculerCoefficientReductionPas() {
if(self::$coefficientReductionPas == null) {
self::$coefficientReductionPas = (self::$pasZoomMaxClustering - self::$pasZoomDefaut)/(self::$zoomMaxClustering - self::$zoomDefaut);
}
 
return self::$coefficientReductionPas;
}
 
private function calculerPasCorrectionCentre($zoom) {
self::$pasCorrectionCentre = ($zoom - self::$zoomDefaut) * self::calculerCoefficientReductionPas() + self::$pasZoomDefaut;
}
 
private function calculerCoefficientProfondeurMax() {
if(self::$coefficientProfondeurMax == null) {
self::$coefficientProfondeurMax = (self::$profondeurMax - self::$profondeurMin)/(self::$zoomMaxClustering - self::$zoomDefaut);
}
 
return self::$coefficientProfondeurMax;
}
private function calculerProfondeurMax($zoom) {
if($zoom > self::$zoomDefaut) {
 
private function calculerProfondeurMax($zoom) {
if($zoom > self::$zoomDefaut) {
self::$profondeurMax = round(($zoom - self::$zoomDefaut) * self::calculerCoefficientProfondeurMax() + self::$profondeurMin,0);
} else {
self::$profondeurMax = 1;
}
}
 
public static function getNbElements() {
return self::$nbElements;
}
 
public static function mettreAJourBornes(&$point) {
if(!is_numeric($point['lat']) || abs($point['lat']) > 90) return;
if(!is_numeric($point['lng']) || abs($point['lng']) > 180) return;
if (!is_numeric($point['lat']) || abs($point['lat']) > 90) return;
if (!is_numeric($point['lng']) || abs($point['lng']) > 180) return;
 
self::$bornesMax['latMin'] = ($point['lat'] < self::$bornesMax['latMin'] || self::$bornesMax['latMin'] == null) ? $point['lat'] : self::$bornesMax['latMin'] ;
self::$bornesMax['lngMin'] = ($point['lng'] < self::$bornesMax['lngMin'] || self::$bornesMax['lngMin'] == null) ? $point['lng'] : self::$bornesMax['lngMin'] ;
self::$bornesMax['latMax'] = ($point['lat'] > self::$bornesMax['latMax'] || self::$bornesMax['latMax'] == null) ? $point['lat'] : self::$bornesMax['latMax'] ;
self::$bornesMax['lngMax'] = ($point['lng'] > self::$bornesMax['lngMax'] || self::$bornesMax['lngMax'] == null) ? $point['lng'] : self::$bornesMax['lngMax'] ;
}
 
public static function getBornes() {
return self::$bornesMax;
}
 
/**
*
*
* @param mixed $noeud Le noeud à traiter par le quadtree
* @param float $neLat Latitude du coin nord est de la fenetre
* @param float $neLng Longitude du coin nord est de la fenetre
* @param float $swLat Latitude du coin sud ouest de la fenetre
* @param float $swLng Longitude du coin sud ouest de la fenetre
* @param float $neLat Latitude du coin nord est de la fenetre
* @param float $neLng Longitude du coin nord est de la fenetre
* @param float $swLat Latitude du coin sud ouest de la fenetre
* @param float $swLng Longitude du coin sud ouest de la fenetre
* @param int $profondeur profondeur courante de l'arbre
*/
private static function attribuerAuCadran(&$noeud, $neLat, $neLng, $swLat, $swLng, $profondeur = 0) {
$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);
$emplacement = self::formaterPointPourAjout($point);
self::mettreAJourBornes($point);
$cadran = self::obtenirCadranPourPoint($latCentre, $lngCentre, $point);
self::ajouterFils($noeud,$cadran,$point);
self::$nbElements[$emplacement]++;
131,9 → 128,9
}
self::$nbElements['points']++;
}
 
$profondeur++;
 
if($profondeur <= self::$profondeurMax) {
(isset($noeud['A']) && $noeud['A'] != null) ? self::attribuerAuCadran($noeud['A'], $neLat, $lngCentre , $latCentre, $swLng, $profondeur) : '';
(isset($noeud['B']) && $noeud['B'] != null) ? self::attribuerAuCadran($noeud['B'], $neLat, $neLng, $latCentre, $lngCentre, $profondeur) : '';
140,17 → 137,17
(isset($noeud['C']) && $noeud['C'] != null) ? self::attribuerAuCadran($noeud['C'], $latCentre, $neLng, $swLat, $lngCentre, $profondeur) : '';
(isset($noeud['D']) && $noeud['D'] != null) ? self::attribuerAuCadran($noeud['D'], $latCentre, $lngCentre, $swLat, $swLng, $profondeur) : '';
}
 
if(self::estUnParentFeuilles($noeud)) {
self::$listeNoeudsSelectionnes[] = self::ajouterGroupeOuPoint($noeud);
}
}
 
private static function estUnPointAExclure(&$point) {
return self::estSensible($point) &&
return self::estSensible($point) &&
self::coordonneesCommuneSontNulles($point);
}
 
private static function coordonneesCommuneSontNulles(&$point) {
$coord_nulles = ($point['wgs84_latitude'] == null ||
$point['wgs84_latitude'] == '' ||
158,9 → 155,8
$point['wgs84_longitude'] == '');
return $coord_nulles;
}
 
private static function coordonneesSontNulles(&$point) {
$coord_nulles = ($point['latitude'] == '000null' ||
$point['latitude'] == 0 ||
$point['latitude'] == '' ||
169,36 → 165,35
$point['longitude'] == '');
return $coord_nulles;
}
 
private static function estSensible(&$point) {
$sensible = isset($point['mots_cles_texte']) && substr_count(strtolower($point['mots_cles_texte']), 'sensible') != 0;
return $sensible;
}
 
private static function formaterNomStation(&$point, $type_emplacement) {
$station = '';
if($type_emplacement == 'stations' && $point['station'] != '' && $point['station'] != '000null') {
$station = $point['station'];
} else {
$id_zone_geo = $point['ce_zone_geo'];
$id_zone_geo = $point['ce_zone_geo'];
$station = $point['zone_geo'].(($id_zone_geo != '' && $id_zone_geo != '000null') ? ' ('.self::formaterNomZoneGeo($id_zone_geo).')' : '');
}
 
return $station;
}
 
private static function formaterNomZoneGeo($zone_geo) {
$zone_geo = str_replace('INSEE-C:', '', $zone_geo);
$zone_geo = strlen($zone_geo) >= 2 ? substr($zone_geo, 0, 2) : $zone_geo;
return $zone_geo;
}
 
private static function formaterPointPourAjout(&$point) {
if(isset($point['type_emplacement'])) {
return $point['type_emplacement'];
}
 
if(self::coordonneesSontNulles($point) || self::estSensible($point)) {
$point_allege = array();
$point_allege['id'] = self::MARQUEUR_COMMUNE.':'.$point['wgs84_latitude'].'|'.$point['wgs84_longitude'];
206,7 → 201,7
$point_allege['nom'] = self::formaterNomStation($point, 'communes');
$point_allege['lat'] = (float)$point['wgs84_latitude'];
$point_allege['lng'] = (float)$point['wgs84_longitude'];
 
$point = $point_allege;
} else {
$point_allege = array();
215,13 → 210,13
$point_allege['nom'] = self::formaterNomStation($point, 'stations');
$point_allege['lat'] = (float)$point['latitude'];
$point_allege['lng'] = (float)$point['longitude'];
 
$point = $point_allege;
}
 
return $point['type_emplacement'];
}
 
private function obtenirCadranPourPoint($latCentre,$lngCentre, &$point) {
if ($point['lng'] < $lngCentre) {
if ($point['lat'] > $latCentre) {
235,20 → 230,20
} else {
$cadran = 'C';
}
}
}
return $cadran;
}
 
private static function ajouterFils(&$noeud, $cadran, &$point) {
if(!isset($noeud[$cadran])) {
$noeud[$cadran] = array('points' => array(),'nbrePoints' => 0, 'latMoyenne' => 0, 'lngMoyenne' => 0);
}
}
$noeud[$cadran]['points'][] = $point;
$noeud[$cadran]['nbrePoints']++;
$noeud[$cadran]['latMoyenne'] += $point['lat'];
$noeud[$cadran]['lngMoyenne'] += $point['lng'];
}
 
private static function ajouterGroupeOuPoint(&$noeud) {
$groupe = array();
if ($noeud['nbrePoints'] > 1 && isset($noeud['latMoyenne']) && isset($noeud['lngMoyenne'])) {
261,20 → 256,20
}
return $groupe;
}
 
 
private static function estUnParentFeuilles(&$noeud) {
return self::estUneFeuille($noeud['A']) &&
self::estUneFeuille($noeud['B']) &&
self::estUneFeuille($noeud['C']) &&
return self::estUneFeuille($noeud['A']) &&
self::estUneFeuille($noeud['B']) &&
self::estUneFeuille($noeud['C']) &&
self::estUneFeuille($noeud['D']);
}
private static function estUneFeuille(&$noeud) {
return $noeud == null ||
(!isset($noeud['A']) || $noeud['A'] == null) &&
(!isset($noeud['B']) || $noeud['B'] == null) &&
(!isset($noeud['C']) || $noeud['C'] == null) &&
 
private static function estUneFeuille(&$noeud) {
return $noeud == null ||
(!isset($noeud['A']) || $noeud['A'] == null) &&
(!isset($noeud['B']) || $noeud['B'] == null) &&
(!isset($noeud['C']) || $noeud['C'] == null) &&
(!isset($noeud['D']) || $noeud['D'] == null);
}
}