Subversion Repositories eFlore/Applications.cel

Rev

Rev 1142 | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

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