Line 1... |
Line 1... |
1 |
<?php
|
1 |
<?php
|
2 |
class CartoGroupage {
|
2 |
class CartoGroupage {
|
3 |
|
- |
|
4 |
const MARQUEUR_GROUPE = 'GROUPE';
|
3 |
const MARQUEUR_GROUPE = 'GROUPE';
|
5 |
const MARQUEUR_COMMUNE = 'COMMUNE';
|
4 |
const MARQUEUR_COMMUNE = 'COMMUNE';
|
6 |
const MARQUEUR_STATION = 'STATION';
|
5 |
const MARQUEUR_STATION = 'STATION';
|
7 |
|
6 |
|
8 |
private static $seuilClusterisation = 200;
|
7 |
private static $seuilClusterisation = 200;
|
9 |
private static $zoomDefaut = 3;
|
8 |
private static $zoomDefaut = 3;
|
10 |
private static $zoomMaxClustering = 12;
|
9 |
private static $zoomMaxClustering = 12;
|
11 |
private static $pasZoomDefaut = 1;
|
10 |
private static $pasZoomDefaut = 1;
|
12 |
private static $pasZoomMaxClustering = 0.05;
|
11 |
private static $pasZoomMaxClustering = 0.05;
|
13 |
private static $profondeurMin = 0;
|
12 |
private static $profondeurMin = 0;
|
14 |
private static $profondeurMax = 8;
|
13 |
private static $profondeurMax = 8;
|
15 |
|
14 |
|
16 |
private static $pasCorrectionCentre = null;
|
15 |
private static $pasCorrectionCentre = null;
|
17 |
private static $coefficientReductionPas = null;
|
16 |
private static $coefficientReductionPas = null;
|
18 |
private static $coefficientProfondeurMax = null;
|
17 |
private static $coefficientProfondeurMax = null;
|
19 |
|
18 |
|
20 |
private static $nbElements = array('stations' => 0,'communes' => 0, 'points' => 0);
|
19 |
private static $nbElements = array('stations' => 0,'communes' => 0, 'points' => 0);
|
21 |
private static $listeNoeudsSelectionnes = array();
|
20 |
private static $listeNoeudsSelectionnes = array();
|
22 |
private static $bornesMax = array('latMin' => null, 'lngMin' => null, 'latMax' => null, 'lngMax' => null);
|
21 |
private static $bornesMax = array('latMin' => null, 'lngMin' => null, 'latMax' => null, 'lngMax' => null);
|
23 |
private static $id_traites = array();
|
22 |
private static $id_traites = array();
|
24 |
/*
|
23 |
/*
|
25 |
+---------+---------+
|
24 |
+---------+---------+
|
26 |
| | |
|
25 |
| | |
|
Line 29... |
Line 28... |
29 |
+---------*---------+
|
28 |
+---------*---------+
|
30 |
| | |
|
29 |
| | |
|
31 |
| D | C |
|
30 |
| D | C |
|
32 |
| | |
|
31 |
| | |
|
33 |
+---------+---------+
|
32 |
+---------+---------+
|
34 |
|
33 |
|
35 |
Quatres cadrans sont considérés par le quad tree
|
34 |
Quatres cadrans sont considérés par le quad tree
|
36 |
* = centre de la fenetre
|
35 |
* = centre de la fenetre
|
37 |
*/
|
36 |
*/
|
38 |
public static function creerGroupesQuadtree(&$markers, $neLat, $neLng, $swLat, $swLng, $zoom = 3) {
|
37 |
public static function creerGroupesQuadtree(&$markers, $neLat, $neLng, $swLat, $swLng, $zoom = 3) {
|
39 |
if(count($markers) > self::$seuilClusterisation) {
|
38 |
if (count($markers) > self::$seuilClusterisation) {
|
40 |
|
39 |
|
41 |
self::calculerProfondeurMax($zoom);
|
40 |
self::calculerProfondeurMax($zoom);
|
42 |
self::calculerPasCorrectionCentre($zoom);
|
41 |
self::calculerPasCorrectionCentre($zoom);
|
Line 43... |
Line 42... |
43 |
|
42 |
|
44 |
$noeudRacine = array('nbrePoints' => count($markers), 'points' => $markers);
|
43 |
$noeudRacine = array('nbrePoints' => count($markers), 'points' => $markers);
|
45 |
self::attribuerAuCadran($noeudRacine, $neLat, $neLng, $swLat, $swLng);
|
44 |
self::attribuerAuCadran($noeudRacine, $neLat, $neLng, $swLat, $swLng);
|
46 |
|
45 |
|
47 |
} else {
|
46 |
} else {
|
48 |
foreach($markers as &$marker) {
|
47 |
foreach($markers as &$marker) {
|
49 |
if(!self::estUnPointAExclure($marker)) {
|
48 |
if(!self::estUnPointAExclure($marker)) {
|
50 |
$emplacement = self::formaterPointPourAjout(&$marker);
|
49 |
$emplacement = self::formaterPointPourAjout($marker);
|
51 |
self::mettreAJourBornes(&$marker);
|
50 |
self::mettreAJourBornes($marker);
|
52 |
$points = array($marker);
|
51 |
$points = array($marker);
|
53 |
$noeudSimple = array('points' => $points, 'nbrePoints' => 1);
|
52 |
$noeudSimple = array('points' => $points, 'nbrePoints' => 1);
|
54 |
self::$nbElements[$emplacement]++;
|
53 |
self::$nbElements[$emplacement]++;
|
55 |
self::$listeNoeudsSelectionnes[] = self::ajouterGroupeOuPoint($noeudSimple);
|
54 |
self::$listeNoeudsSelectionnes[] = self::ajouterGroupeOuPoint($noeudSimple);
|
56 |
}
|
55 |
}
|
57 |
self::$nbElements['points']++;
|
56 |
self::$nbElements['points']++;
|
58 |
}
|
57 |
}
|
59 |
}
|
58 |
}
|
60 |
return self::$listeNoeudsSelectionnes;
|
59 |
return self::$listeNoeudsSelectionnes;
|
61 |
}
|
60 |
}
|
62 |
|
61 |
|
63 |
private function calculerCoefficientReductionPas() {
|
62 |
private function calculerCoefficientReductionPas() {
|
64 |
if(self::$coefficientReductionPas == null) {
|
63 |
if(self::$coefficientReductionPas == null) {
|
65 |
self::$coefficientReductionPas = (self::$pasZoomMaxClustering - self::$pasZoomDefaut)/(self::$zoomMaxClustering - self::$zoomDefaut);
|
64 |
self::$coefficientReductionPas = (self::$pasZoomMaxClustering - self::$pasZoomDefaut)/(self::$zoomMaxClustering - self::$zoomDefaut);
|
66 |
}
|
65 |
}
|
67 |
|
66 |
|
68 |
return self::$coefficientReductionPas;
|
67 |
return self::$coefficientReductionPas;
|
69 |
}
|
68 |
}
|
70 |
|
69 |
|
71 |
private function calculerPasCorrectionCentre($zoom) {
|
70 |
private function calculerPasCorrectionCentre($zoom) {
|
72 |
self::$pasCorrectionCentre = ($zoom - self::$zoomDefaut) * self::calculerCoefficientReductionPas() + self::$pasZoomDefaut;
|
71 |
self::$pasCorrectionCentre = ($zoom - self::$zoomDefaut) * self::calculerCoefficientReductionPas() + self::$pasZoomDefaut;
|
73 |
}
|
72 |
}
|
74 |
|
73 |
|
75 |
private function calculerCoefficientProfondeurMax() {
|
74 |
private function calculerCoefficientProfondeurMax() {
|
76 |
if(self::$coefficientProfondeurMax == null) {
|
75 |
if(self::$coefficientProfondeurMax == null) {
|
77 |
self::$coefficientProfondeurMax = (self::$profondeurMax - self::$profondeurMin)/(self::$zoomMaxClustering - self::$zoomDefaut);
|
76 |
self::$coefficientProfondeurMax = (self::$profondeurMax - self::$profondeurMin)/(self::$zoomMaxClustering - self::$zoomDefaut);
|
78 |
}
|
77 |
}
|
79 |
|
78 |
|
80 |
return self::$coefficientProfondeurMax;
|
79 |
return self::$coefficientProfondeurMax;
|
81 |
}
|
80 |
}
|
82 |
|
81 |
|
83 |
private function calculerProfondeurMax($zoom) {
|
82 |
private function calculerProfondeurMax($zoom) {
|
84 |
if($zoom > self::$zoomDefaut) {
|
83 |
if($zoom > self::$zoomDefaut) {
|
85 |
self::$profondeurMax = round(($zoom - self::$zoomDefaut) * self::calculerCoefficientProfondeurMax() + self::$profondeurMin,0);
|
84 |
self::$profondeurMax = round(($zoom - self::$zoomDefaut) * self::calculerCoefficientProfondeurMax() + self::$profondeurMin,0);
|
86 |
} else {
|
85 |
} else {
|
87 |
self::$profondeurMax = 1;
|
86 |
self::$profondeurMax = 1;
|
88 |
}
|
87 |
}
|
89 |
}
|
88 |
}
|
90 |
|
89 |
|
91 |
public static function getNbElements() {
|
90 |
public static function getNbElements() {
|
92 |
return self::$nbElements;
|
91 |
return self::$nbElements;
|
93 |
}
|
92 |
}
|
94 |
|
93 |
|
95 |
public static function mettreAJourBornes(&$point) {
|
- |
|
96 |
|
94 |
public static function mettreAJourBornes(&$point) {
|
97 |
if(!is_numeric($point['lat']) || abs($point['lat']) > 90) return;
|
95 |
if (!is_numeric($point['lat']) || abs($point['lat']) > 90) return;
|
98 |
if(!is_numeric($point['lng']) || abs($point['lng']) > 180) return;
|
96 |
if (!is_numeric($point['lng']) || abs($point['lng']) > 180) return;
|
99 |
|
97 |
|
100 |
self::$bornesMax['latMin'] = ($point['lat'] < self::$bornesMax['latMin'] || self::$bornesMax['latMin'] == null) ? $point['lat'] : self::$bornesMax['latMin'] ;
|
98 |
self::$bornesMax['latMin'] = ($point['lat'] < self::$bornesMax['latMin'] || self::$bornesMax['latMin'] == null) ? $point['lat'] : self::$bornesMax['latMin'] ;
|
101 |
self::$bornesMax['lngMin'] = ($point['lng'] < self::$bornesMax['lngMin'] || self::$bornesMax['lngMin'] == null) ? $point['lng'] : self::$bornesMax['lngMin'] ;
|
99 |
self::$bornesMax['lngMin'] = ($point['lng'] < self::$bornesMax['lngMin'] || self::$bornesMax['lngMin'] == null) ? $point['lng'] : self::$bornesMax['lngMin'] ;
|
102 |
self::$bornesMax['latMax'] = ($point['lat'] > self::$bornesMax['latMax'] || self::$bornesMax['latMax'] == null) ? $point['lat'] : self::$bornesMax['latMax'] ;
|
100 |
self::$bornesMax['latMax'] = ($point['lat'] > self::$bornesMax['latMax'] || self::$bornesMax['latMax'] == null) ? $point['lat'] : self::$bornesMax['latMax'] ;
|
103 |
self::$bornesMax['lngMax'] = ($point['lng'] > self::$bornesMax['lngMax'] || self::$bornesMax['lngMax'] == null) ? $point['lng'] : self::$bornesMax['lngMax'] ;
|
101 |
self::$bornesMax['lngMax'] = ($point['lng'] > self::$bornesMax['lngMax'] || self::$bornesMax['lngMax'] == null) ? $point['lng'] : self::$bornesMax['lngMax'] ;
|
104 |
}
|
102 |
}
|
105 |
|
103 |
|
106 |
public static function getBornes() {
|
104 |
public static function getBornes() {
|
107 |
return self::$bornesMax;
|
105 |
return self::$bornesMax;
|
108 |
}
|
106 |
}
|
109 |
|
107 |
|
110 |
/**
|
108 |
/**
|
111 |
*
|
109 |
*
|
112 |
* @param mixed $noeud Le noeud à traiter par le quadtree
|
110 |
* @param mixed $noeud Le noeud à traiter par le quadtree
|
113 |
* @param float $neLat Latitude du coin nord est de la fenetre
|
111 |
* @param float $neLat Latitude du coin nord est de la fenetre
|
114 |
* @param float $neLng Longitude du coin nord est de la fenetre
|
112 |
* @param float $neLng Longitude du coin nord est de la fenetre
|
115 |
* @param float $swLat Latitude du coin sud ouest de la fenetre
|
113 |
* @param float $swLat Latitude du coin sud ouest de la fenetre
|
116 |
* @param float $swLng Longitude du coin sud ouest de la fenetre
|
114 |
* @param float $swLng Longitude du coin sud ouest de la fenetre
|
117 |
* @param int $profondeur profondeur courante de l'arbre
|
115 |
* @param int $profondeur profondeur courante de l'arbre
|
118 |
*/
|
116 |
*/
|
119 |
private static function attribuerAuCadran(&$noeud, $neLat, $neLng, $swLat, $swLng, $profondeur = 0) {
|
- |
|
120 |
|
117 |
private static function attribuerAuCadran(&$noeud, $neLat, $neLng, $swLat, $swLng, $profondeur = 0) {
|
121 |
$latCentre = round((($neLat+$swLat)/2)/self::$pasCorrectionCentre,0)*self::$pasCorrectionCentre;
|
118 |
$latCentre = round((($neLat+$swLat)/2)/self::$pasCorrectionCentre,0)*self::$pasCorrectionCentre;
|
122 |
$lngCentre = round((($neLng+$swLng)/2)/self::$pasCorrectionCentre,0)*self::$pasCorrectionCentre;
|
119 |
$lngCentre = round((($neLng+$swLng)/2)/self::$pasCorrectionCentre,0)*self::$pasCorrectionCentre;
|
123 |
|
120 |
|
124 |
foreach ($noeud['points'] as &$point) {
|
121 |
foreach ($noeud['points'] as &$point) {
|
125 |
if(!self::estUnPointAExclure($point)) {
|
122 |
if(!self::estUnPointAExclure($point)) {
|
126 |
$emplacement = self::formaterPointPourAjout(&$point);
|
123 |
$emplacement = self::formaterPointPourAjout($point);
|
127 |
self::mettreAJourBornes(&$point);
|
124 |
self::mettreAJourBornes($point);
|
128 |
$cadran = self::obtenirCadranPourPoint($latCentre, $lngCentre, $point);
|
125 |
$cadran = self::obtenirCadranPourPoint($latCentre, $lngCentre, $point);
|
129 |
self::ajouterFils($noeud,$cadran,$point);
|
126 |
self::ajouterFils($noeud,$cadran,$point);
|
130 |
self::$nbElements[$emplacement]++;
|
127 |
self::$nbElements[$emplacement]++;
|
131 |
}
|
128 |
}
|
132 |
self::$nbElements['points']++;
|
129 |
self::$nbElements['points']++;
|
133 |
}
|
130 |
}
|
134 |
|
131 |
|
135 |
$profondeur++;
|
132 |
$profondeur++;
|
136 |
|
133 |
|
137 |
if($profondeur <= self::$profondeurMax) {
|
134 |
if($profondeur <= self::$profondeurMax) {
|
138 |
(isset($noeud['A']) && $noeud['A'] != null) ? self::attribuerAuCadran($noeud['A'], $neLat, $lngCentre , $latCentre, $swLng, $profondeur) : '';
|
135 |
(isset($noeud['A']) && $noeud['A'] != null) ? self::attribuerAuCadran($noeud['A'], $neLat, $lngCentre , $latCentre, $swLng, $profondeur) : '';
|
139 |
(isset($noeud['B']) && $noeud['B'] != null) ? self::attribuerAuCadran($noeud['B'], $neLat, $neLng, $latCentre, $lngCentre, $profondeur) : '';
|
136 |
(isset($noeud['B']) && $noeud['B'] != null) ? self::attribuerAuCadran($noeud['B'], $neLat, $neLng, $latCentre, $lngCentre, $profondeur) : '';
|
140 |
(isset($noeud['C']) && $noeud['C'] != null) ? self::attribuerAuCadran($noeud['C'], $latCentre, $neLng, $swLat, $lngCentre, $profondeur) : '';
|
137 |
(isset($noeud['C']) && $noeud['C'] != null) ? self::attribuerAuCadran($noeud['C'], $latCentre, $neLng, $swLat, $lngCentre, $profondeur) : '';
|
141 |
(isset($noeud['D']) && $noeud['D'] != null) ? self::attribuerAuCadran($noeud['D'], $latCentre, $lngCentre, $swLat, $swLng, $profondeur) : '';
|
138 |
(isset($noeud['D']) && $noeud['D'] != null) ? self::attribuerAuCadran($noeud['D'], $latCentre, $lngCentre, $swLat, $swLng, $profondeur) : '';
|
142 |
}
|
139 |
}
|
143 |
|
140 |
|
144 |
if(self::estUnParentFeuilles($noeud)) {
|
141 |
if(self::estUnParentFeuilles($noeud)) {
|
145 |
self::$listeNoeudsSelectionnes[] = self::ajouterGroupeOuPoint($noeud);
|
142 |
self::$listeNoeudsSelectionnes[] = self::ajouterGroupeOuPoint($noeud);
|
146 |
}
|
143 |
}
|
147 |
}
|
144 |
}
|
148 |
|
145 |
|
149 |
private static function estUnPointAExclure(&$point) {
|
146 |
private static function estUnPointAExclure(&$point) {
|
150 |
return self::estSensible($point) &&
|
147 |
return self::estSensible($point) &&
|
151 |
self::coordonneesCommuneSontNulles($point);
|
148 |
self::coordonneesCommuneSontNulles($point);
|
152 |
}
|
149 |
}
|
153 |
|
150 |
|
154 |
private static function coordonneesCommuneSontNulles(&$point) {
|
151 |
private static function coordonneesCommuneSontNulles(&$point) {
|
155 |
$coord_nulles = ($point['wgs84_latitude'] == null ||
|
152 |
$coord_nulles = ($point['wgs84_latitude'] == null ||
|
156 |
$point['wgs84_latitude'] == '' ||
|
153 |
$point['wgs84_latitude'] == '' ||
|
157 |
$point['wgs84_longitude'] == null ||
|
154 |
$point['wgs84_longitude'] == null ||
|
158 |
$point['wgs84_longitude'] == '');
|
155 |
$point['wgs84_longitude'] == '');
|
159 |
return $coord_nulles;
|
156 |
return $coord_nulles;
|
160 |
}
|
157 |
}
|
161 |
|
158 |
|
162 |
private static function coordonneesSontNulles(&$point) {
|
- |
|
163 |
|
159 |
private static function coordonneesSontNulles(&$point) {
|
164 |
$coord_nulles = ($point['latitude'] == '000null' ||
|
160 |
$coord_nulles = ($point['latitude'] == '000null' ||
|
165 |
$point['latitude'] == 0 ||
|
161 |
$point['latitude'] == 0 ||
|
166 |
$point['latitude'] == '' ||
|
162 |
$point['latitude'] == '' ||
|
167 |
$point['longitude'] == '000null' ||
|
163 |
$point['longitude'] == '000null' ||
|
168 |
$point['longitude'] == 0 ||
|
164 |
$point['longitude'] == 0 ||
|
169 |
$point['longitude'] == '');
|
165 |
$point['longitude'] == '');
|
170 |
return $coord_nulles;
|
166 |
return $coord_nulles;
|
171 |
}
|
167 |
}
|
172 |
|
168 |
|
173 |
private static function estSensible(&$point) {
|
169 |
private static function estSensible(&$point) {
|
174 |
$sensible = isset($point['mots_cles_texte']) && substr_count(strtolower($point['mots_cles_texte']), 'sensible') != 0;
|
170 |
$sensible = isset($point['mots_cles_texte']) && substr_count(strtolower($point['mots_cles_texte']), 'sensible') != 0;
|
175 |
return $sensible;
|
171 |
return $sensible;
|
176 |
}
|
172 |
}
|
177 |
|
173 |
|
178 |
private static function formaterNomStation(&$point, $type_emplacement) {
|
174 |
private static function formaterNomStation(&$point, $type_emplacement) {
|
179 |
$station = '';
|
175 |
$station = '';
|
180 |
if($type_emplacement == 'stations' && $point['station'] != '' && $point['station'] != '000null') {
|
176 |
if($type_emplacement == 'stations' && $point['station'] != '' && $point['station'] != '000null') {
|
181 |
$station = $point['station'];
|
177 |
$station = $point['station'];
|
182 |
} else {
|
178 |
} else {
|
183 |
$id_zone_geo = $point['ce_zone_geo'];
|
179 |
$id_zone_geo = $point['ce_zone_geo'];
|
184 |
$station = $point['zone_geo'].(($id_zone_geo != '' && $id_zone_geo != '000null') ? ' ('.self::formaterNomZoneGeo($id_zone_geo).')' : '');
|
180 |
$station = $point['zone_geo'].(($id_zone_geo != '' && $id_zone_geo != '000null') ? ' ('.self::formaterNomZoneGeo($id_zone_geo).')' : '');
|
185 |
}
|
181 |
}
|
186 |
|
182 |
|
187 |
return $station;
|
183 |
return $station;
|
188 |
}
|
184 |
}
|
189 |
|
185 |
|
190 |
private static function formaterNomZoneGeo($zone_geo) {
|
186 |
private static function formaterNomZoneGeo($zone_geo) {
|
191 |
$zone_geo = str_replace('INSEE-C:', '', $zone_geo);
|
187 |
$zone_geo = str_replace('INSEE-C:', '', $zone_geo);
|
192 |
$zone_geo = strlen($zone_geo) >= 2 ? substr($zone_geo, 0, 2) : $zone_geo;
|
188 |
$zone_geo = strlen($zone_geo) >= 2 ? substr($zone_geo, 0, 2) : $zone_geo;
|
193 |
return $zone_geo;
|
189 |
return $zone_geo;
|
194 |
}
|
190 |
}
|
195 |
|
191 |
|
196 |
private static function formaterPointPourAjout(&$point) {
|
- |
|
197 |
|
192 |
private static function formaterPointPourAjout(&$point) {
|
198 |
if(isset($point['type_emplacement'])) {
|
193 |
if(isset($point['type_emplacement'])) {
|
199 |
return $point['type_emplacement'];
|
194 |
return $point['type_emplacement'];
|
200 |
}
|
195 |
}
|
201 |
|
196 |
|
202 |
if(self::coordonneesSontNulles($point) || self::estSensible($point)) {
|
197 |
if(self::coordonneesSontNulles($point) || self::estSensible($point)) {
|
203 |
$point_allege = array();
|
198 |
$point_allege = array();
|
204 |
$point_allege['id'] = self::MARQUEUR_COMMUNE.':'.$point['wgs84_latitude'].'|'.$point['wgs84_longitude'];
|
199 |
$point_allege['id'] = self::MARQUEUR_COMMUNE.':'.$point['wgs84_latitude'].'|'.$point['wgs84_longitude'];
|
205 |
$point_allege['type_emplacement'] = 'communes';
|
200 |
$point_allege['type_emplacement'] = 'communes';
|
206 |
$point_allege['nom'] = self::formaterNomStation($point, 'communes');
|
201 |
$point_allege['nom'] = self::formaterNomStation($point, 'communes');
|
207 |
$point_allege['lat'] = (float)$point['wgs84_latitude'];
|
202 |
$point_allege['lat'] = (float)$point['wgs84_latitude'];
|
208 |
$point_allege['lng'] = (float)$point['wgs84_longitude'];
|
203 |
$point_allege['lng'] = (float)$point['wgs84_longitude'];
|
209 |
|
204 |
|
210 |
$point = $point_allege;
|
205 |
$point = $point_allege;
|
211 |
} else {
|
206 |
} else {
|
212 |
$point_allege = array();
|
207 |
$point_allege = array();
|
213 |
$point_allege['id'] = self::MARQUEUR_STATION.':'.$point['latitude'].'|'.$point['longitude'];
|
208 |
$point_allege['id'] = self::MARQUEUR_STATION.':'.$point['latitude'].'|'.$point['longitude'];
|
214 |
$point_allege['type_emplacement'] = 'stations';
|
209 |
$point_allege['type_emplacement'] = 'stations';
|
215 |
$point_allege['nom'] = self::formaterNomStation($point, 'stations');
|
210 |
$point_allege['nom'] = self::formaterNomStation($point, 'stations');
|
216 |
$point_allege['lat'] = (float)$point['latitude'];
|
211 |
$point_allege['lat'] = (float)$point['latitude'];
|
217 |
$point_allege['lng'] = (float)$point['longitude'];
|
212 |
$point_allege['lng'] = (float)$point['longitude'];
|
218 |
|
213 |
|
219 |
$point = $point_allege;
|
214 |
$point = $point_allege;
|
220 |
}
|
215 |
}
|
221 |
|
216 |
|
222 |
return $point['type_emplacement'];
|
217 |
return $point['type_emplacement'];
|
223 |
}
|
218 |
}
|
224 |
|
219 |
|
225 |
private function obtenirCadranPourPoint($latCentre,$lngCentre, &$point) {
|
220 |
private function obtenirCadranPourPoint($latCentre,$lngCentre, &$point) {
|
226 |
if ($point['lng'] < $lngCentre) {
|
221 |
if ($point['lng'] < $lngCentre) {
|
227 |
if ($point['lat'] > $latCentre) {
|
222 |
if ($point['lat'] > $latCentre) {
|
228 |
$cadran = 'A';
|
223 |
$cadran = 'A';
|
Line 233... |
Line 228... |
233 |
if ($point['lat'] > $latCentre) {
|
228 |
if ($point['lat'] > $latCentre) {
|
234 |
$cadran = 'B';
|
229 |
$cadran = 'B';
|
235 |
} else {
|
230 |
} else {
|
236 |
$cadran = 'C';
|
231 |
$cadran = 'C';
|
237 |
}
|
232 |
}
|
238 |
}
|
233 |
}
|
239 |
return $cadran;
|
234 |
return $cadran;
|
240 |
}
|
235 |
}
|
241 |
|
236 |
|
242 |
private static function ajouterFils(&$noeud, $cadran, &$point) {
|
237 |
private static function ajouterFils(&$noeud, $cadran, &$point) {
|
243 |
if(!isset($noeud[$cadran])) {
|
238 |
if(!isset($noeud[$cadran])) {
|
244 |
$noeud[$cadran] = array('points' => array(),'nbrePoints' => 0, 'latMoyenne' => 0, 'lngMoyenne' => 0);
|
239 |
$noeud[$cadran] = array('points' => array(),'nbrePoints' => 0, 'latMoyenne' => 0, 'lngMoyenne' => 0);
|
245 |
}
|
240 |
}
|
246 |
$noeud[$cadran]['points'][] = $point;
|
241 |
$noeud[$cadran]['points'][] = $point;
|
247 |
$noeud[$cadran]['nbrePoints']++;
|
242 |
$noeud[$cadran]['nbrePoints']++;
|
248 |
$noeud[$cadran]['latMoyenne'] += $point['lat'];
|
243 |
$noeud[$cadran]['latMoyenne'] += $point['lat'];
|
249 |
$noeud[$cadran]['lngMoyenne'] += $point['lng'];
|
244 |
$noeud[$cadran]['lngMoyenne'] += $point['lng'];
|
250 |
}
|
245 |
}
|
251 |
|
246 |
|
252 |
private static function ajouterGroupeOuPoint(&$noeud) {
|
247 |
private static function ajouterGroupeOuPoint(&$noeud) {
|
253 |
$groupe = array();
|
248 |
$groupe = array();
|
254 |
if ($noeud['nbrePoints'] > 1 && isset($noeud['latMoyenne']) && isset($noeud['lngMoyenne'])) {
|
249 |
if ($noeud['nbrePoints'] > 1 && isset($noeud['latMoyenne']) && isset($noeud['lngMoyenne'])) {
|
255 |
$groupe['lat'] = $noeud['latMoyenne']/$noeud['nbrePoints'];
|
250 |
$groupe['lat'] = $noeud['latMoyenne']/$noeud['nbrePoints'];
|
256 |
$groupe['lng'] = $noeud['lngMoyenne']/$noeud['nbrePoints'];
|
251 |
$groupe['lng'] = $noeud['lngMoyenne']/$noeud['nbrePoints'];
|
Line 259... |
Line 254... |
259 |
} else {
|
254 |
} else {
|
260 |
$groupe = $noeud['points'][0];
|
255 |
$groupe = $noeud['points'][0];
|
261 |
}
|
256 |
}
|
262 |
return $groupe;
|
257 |
return $groupe;
|
263 |
}
|
258 |
}
|
264 |
|
259 |
|
265 |
|
260 |
|
266 |
private static function estUnParentFeuilles(&$noeud) {
|
261 |
private static function estUnParentFeuilles(&$noeud) {
|
267 |
return self::estUneFeuille($noeud['A']) &&
|
262 |
return self::estUneFeuille($noeud['A']) &&
|
268 |
self::estUneFeuille($noeud['B']) &&
|
263 |
self::estUneFeuille($noeud['B']) &&
|
269 |
self::estUneFeuille($noeud['C']) &&
|
264 |
self::estUneFeuille($noeud['C']) &&
|
270 |
self::estUneFeuille($noeud['D']);
|
265 |
self::estUneFeuille($noeud['D']);
|
271 |
}
|
266 |
}
|
272 |
|
267 |
|
273 |
private static function estUneFeuille(&$noeud) {
|
268 |
private static function estUneFeuille(&$noeud) {
|
274 |
return $noeud == null ||
|
269 |
return $noeud == null ||
|
275 |
(!isset($noeud['A']) || $noeud['A'] == null) &&
|
270 |
(!isset($noeud['A']) || $noeud['A'] == null) &&
|
276 |
(!isset($noeud['B']) || $noeud['B'] == null) &&
|
271 |
(!isset($noeud['B']) || $noeud['B'] == null) &&
|
277 |
(!isset($noeud['C']) || $noeud['C'] == null) &&
|
272 |
(!isset($noeud['C']) || $noeud['C'] == null) &&
|
278 |
(!isset($noeud['D']) || $noeud['D'] == null);
|
273 |
(!isset($noeud['D']) || $noeud['D'] == null);
|
279 |
}
|
274 |
}
|
280 |
}
|
275 |
}
|
281 |
?>
|
276 |
?>
|
282 |
|
277 |
|