Subversion Repositories eFlore/Applications.cel

Rev

Rev 1585 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

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