Subversion Repositories eFlore/Applications.cel

Compare Revisions

Ignore whitespace Rev 1141 → Rev 1142

/trunk/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;
}
93,10 → 93,14
}
public static function mettreAJourBornes(&$point) {
self::$bornesMax['latMin'] = (is_numeric($point['lat']) && $point['lat'] < self::$bornesMax['latMin'] || self::$bornesMax['latMin'] == null) ? $point['lat'] : self::$bornesMax['latMin'] ;
self::$bornesMax['lngMin'] = (is_numeric($point['lng']) && $point['lng'] < self::$bornesMax['lngMin'] || self::$bornesMax['lngMin'] == null) ? $point['lng'] : self::$bornesMax['lngMin'] ;
self::$bornesMax['latMax'] = (is_numeric($point['lat']) && $point['lat'] > self::$bornesMax['latMax'] || self::$bornesMax['latMax'] == null) ? $point['lat'] : self::$bornesMax['latMax'] ;
self::$bornesMax['lngMax'] = (is_numeric($point['lng']) && $point['lng'] > self::$bornesMax['lngMax'] || self::$bornesMax['lngMax'] == null) ? $point['lng'] : self::$bornesMax['lngMax'] ;
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() {
117,14 → 121,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 → 146,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 → 238,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'];