Subversion Repositories eFlore/Applications.cel

Rev

Rev 2459 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 2459 Rev 2460
Line 1... Line 1...
1
<?php
1
<?php
-
 
2
// declare(encoding='UTF-8');
-
 
3
/**
-
 
4
 * Classe de groupage des obs par quadtree pour la carto.
-
 
5
 *
-
 
6
 * @internal   Mininum PHP version : 5.2
-
 
7
 * @category   CEL
-
 
8
 * @package    Services
-
 
9
 * @subpackage Bibliothèques
-
 
10
 * @version    0.1
-
 
11
 * @author     Mathias CHOUET <mathias@tela-botanica.org>
-
 
12
 * @author     Jean-Pascal MILCENT <jpm@tela-botanica.org>
-
 
13
 * @author     Aurelien PERONNET <aurelien@tela-botanica.org>
-
 
14
 * @license    GPL v3 <http://www.gnu.org/licenses/gpl.txt>
-
 
15
 * @license    CECILL v2 <http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt>
-
 
16
 * @copyright  1999-2014 Tela Botanica <accueil@tela-botanica.org>
-
 
17
 */
2
class CartoGroupage {
18
class CartoGroupage {
3
	const MARQUEUR_GROUPE = 'GROUPE';
19
	const MARQUEUR_GROUPE = 'GROUPE';
4
	const MARQUEUR_COMMUNE = 'COMMUNE';
20
	const MARQUEUR_COMMUNE = 'COMMUNE';
5
	const MARQUEUR_STATION = 'STATION';
21
	const MARQUEUR_STATION = 'STATION';
Line 34... Line 50...
34
	  Quatres cadrans sont considérés par le quad tree
50
	  Quatres cadrans sont considérés par le quad tree
35
	  * = centre de la fenetre
51
	  * = centre de la fenetre
36
	 */
52
	 */
37
	public static function creerGroupesQuadtree(&$markers, $neLat, $neLng, $swLat, $swLng, $zoom = 3) {
53
	public static function creerGroupesQuadtree(&$markers, $neLat, $neLng, $swLat, $swLng, $zoom = 3) {
38
		if (count($markers) > self::$seuilClusterisation) {
54
		if (count($markers) > self::$seuilClusterisation) {
39
 
-
 
40
			self::calculerProfondeurMax($zoom);
55
			self::calculerProfondeurMax($zoom);
41
			self::calculerPasCorrectionCentre($zoom);
56
			self::calculerPasCorrectionCentre($zoom);
Line 42... Line 57...
42
 
57
 
43
			$noeudRacine = array('nbrePoints' => count($markers), 'points' => $markers);
58
			$noeudRacine = array('nbrePoints' => count($markers), 'points' => $markers);
44
			self::attribuerAuCadran($noeudRacine, $neLat, $neLng, $swLat, $swLng);
-
 
45
 
59
			self::attribuerAuCadran($noeudRacine, $neLat, $neLng, $swLat, $swLng);
46
		} else {
60
		} else {
47
			foreach($markers as &$marker) {
61
			foreach ($markers as &$marker) {
48
				if(!self::estUnPointAExclure($marker)) {
62
				if (!self::estUnPointAExclure($marker)) {
49
					$emplacement = self::formaterPointPourAjout($marker);
63
					$emplacement = self::formaterPointPourAjout($marker);
50
					self::mettreAJourBornes($marker);
64
					self::mettreAJourBornes($marker);
51
					$points = array($marker);
65
					$points = array($marker);
52
					$noeudSimple = array('points' => $points, 'nbrePoints' => 1);
66
					$noeudSimple = array('points' => $points, 'nbrePoints' => 1);
Line 58... Line 72...
58
		}
72
		}
59
		return self::$listeNoeudsSelectionnes;
73
		return self::$listeNoeudsSelectionnes;
60
	}
74
	}
Line 61... Line 75...
61
 
75
 
62
	private function calculerCoefficientReductionPas() {
76
	private function calculerCoefficientReductionPas() {
63
		if(self::$coefficientReductionPas == null) {
77
		if (self::$coefficientReductionPas == null) {
64
			self::$coefficientReductionPas = (self::$pasZoomMaxClustering - self::$pasZoomDefaut)/(self::$zoomMaxClustering - self::$zoomDefaut);
78
			self::$coefficientReductionPas = (self::$pasZoomMaxClustering - self::$pasZoomDefaut)/(self::$zoomMaxClustering - self::$zoomDefaut);
65
		}
-
 
66
 
79
		}
67
		return self::$coefficientReductionPas;
80
		return self::$coefficientReductionPas;
Line 68... Line 81...
68
	}
81
	}
69
 
82
 
70
	private function calculerPasCorrectionCentre($zoom) {
83
	private function calculerPasCorrectionCentre($zoom) {
Line 71... Line 84...
71
		self::$pasCorrectionCentre = ($zoom - self::$zoomDefaut) * self::calculerCoefficientReductionPas() + self::$pasZoomDefaut;
84
		self::$pasCorrectionCentre = ($zoom - self::$zoomDefaut) * self::calculerCoefficientReductionPas() + self::$pasZoomDefaut;
72
	}
85
	}
73
 
86
 
74
	private function calculerCoefficientProfondeurMax() {
87
	private function calculerCoefficientProfondeurMax() {
75
		if(self::$coefficientProfondeurMax == null) {
-
 
76
			self::$coefficientProfondeurMax = (self::$profondeurMax - self::$profondeurMin)/(self::$zoomMaxClustering - self::$zoomDefaut);
88
		if (self::$coefficientProfondeurMax == null) {
77
		}
89
			self::$coefficientProfondeurMax = (self::$profondeurMax - self::$profondeurMin)/(self::$zoomMaxClustering - self::$zoomDefaut);
Line 78... Line 90...
78
 
90
		}
79
		return self::$coefficientProfondeurMax;
91
		return self::$coefficientProfondeurMax;
80
	}
92
	}
81
 
93
 
82
	private function calculerProfondeurMax($zoom) {
94
	private function calculerProfondeurMax($zoom) {
83
		if($zoom > self::$zoomDefaut) {
95
		if ($zoom > self::$zoomDefaut) {
84
			self::$profondeurMax = round(($zoom - self::$zoomDefaut) * self::calculerCoefficientProfondeurMax() + self::$profondeurMin,0);
96
			self::$profondeurMax = round(($zoom - self::$zoomDefaut) * self::calculerCoefficientProfondeurMax() + self::$profondeurMin,0);
Line 156... Line 168...
156
		return $coord_nulles;
168
		return $coord_nulles;
157
	}
169
	}
Line 158... Line 170...
158
 
170
 
159
	private static function coordonneesSontNulles(&$point) {
171
	private static function coordonneesSontNulles(&$point) {
160
		$coord_nulles = ($point['latitude'] == '000null' ||
172
		$coord_nulles = ($point['latitude'] == '000null' ||
161
				$point['latitude'] == 0 ||
173
			$point['latitude'] == 0 ||
162
				$point['latitude'] == '' ||
174
			$point['latitude'] == '' ||
163
				$point['longitude'] == '000null' ||
175
			$point['longitude'] == '000null' ||
164
				$point['longitude'] == 0 ||
176
			$point['longitude'] == 0 ||
165
				$point['longitude'] == '');
177
			$point['longitude'] == '');
166
		return $coord_nulles;
178
		return $coord_nulles;
Line 167... Line 179...
167
	}
179
	}
168
 
180
 
169
	private static function estSensible(&$point) {
181
	private static function estSensible(&$point) {
170
		$sensible = isset($point['mots_cles_texte']) && substr_count(strtolower($point['mots_cles_texte']), 'sensible') != 0;
182
		$sensible = isset($point['mots_cles_texte']) && substr_count(strtolower($point['mots_cles_texte']), 'sensible') != 0;
Line 171... Line 183...
171
		return $sensible;
183
		return $sensible;
172
	}
184
	}
173
 
185
 
174
	private static function formaterNomStation(&$point, $type_emplacement) {
186
	private static function formaterNomStation(&$point, $type_emplacement) {
175
		$station = '';
187
		$station = '';
176
		if($type_emplacement == 'stations' && $point['station'] != '' && $point['station'] != '000null') {
188
		if ($type_emplacement == 'stations' && $point['station'] != '' && $point['station'] != '000null') {
177
			$station = $point['station'];
189
			$station = $point['station'];
178
		} else {
190
		} else {
Line 188... Line 200...
188
		$zone_geo = strlen($zone_geo) >= 2 ? substr($zone_geo, 0, 2) : $zone_geo;
200
		$zone_geo = strlen($zone_geo) >= 2 ? substr($zone_geo, 0, 2) : $zone_geo;
189
		return $zone_geo;
201
		return $zone_geo;
190
	}
202
	}
Line 191... Line 203...
191
 
203
 
192
	private static function formaterPointPourAjout(&$point) {
204
	private static function formaterPointPourAjout(&$point) {
193
		if(isset($point['type_emplacement'])) {
205
		if (isset($point['type_emplacement'])) {
194
			return $point['type_emplacement'];
206
			return $point['type_emplacement'];
Line 195... Line 207...
195
		}
207
		}
196
 
208
 
197
		if(self::coordonneesSontNulles($point) || self::estSensible($point)) {
209
		if (self::coordonneesSontNulles($point) || self::estSensible($point)) {
198
			$point_allege = array();
210
			$point_allege = array();
199
			$point_allege['id'] = self::MARQUEUR_COMMUNE.':'.$point['wgs84_latitude'].'|'.$point['wgs84_longitude'];
211
			$point_allege['id'] = self::MARQUEUR_COMMUNE.':'.$point['wgs84_latitude'].'|'.$point['wgs84_longitude'];
200
			$point_allege['type_emplacement'] = 'communes';
212
			$point_allege['type_emplacement'] = 'communes';
Line 213... Line 225...
213
			$point_allege['lng'] = (float)$point['longitude'];
225
			$point_allege['lng'] = (float)$point['longitude'];
214
			$point_allege['zonegeo'] = $point['ce_zone_geo'];
226
			$point_allege['zonegeo'] = $point['ce_zone_geo'];
Line 215... Line 227...
215
 
227
 
216
			$point = $point_allege;
228
			$point = $point_allege;
217
		}
-
 
218
 
229
		}
219
		return $point['type_emplacement'];
230
		return $point['type_emplacement'];
Line 220... Line 231...
220
	}
231
	}
221
 
232
 
Line 257... Line 268...
257
			$groupe = $noeud['points'][0];
268
			$groupe = $noeud['points'][0];
258
		}
269
		}
259
		return $groupe;
270
		return $groupe;
260
	}
271
	}
Line 261... Line -...
261
 
-
 
262
 
272
 
263
	private static function estUnParentFeuilles(&$noeud) {
273
	private static function estUnParentFeuilles(&$noeud) {
264
		return  self::estUneFeuille($noeud['A']) &&
274
		return  self::estUneFeuille($noeud['A']) &&
265
				self::estUneFeuille($noeud['B']) &&
275
				self::estUneFeuille($noeud['B']) &&
266
				self::estUneFeuille($noeud['C']) &&
276
				self::estUneFeuille($noeud['C']) &&
Line 272... Line 282...
272
		(!isset($noeud['A']) || $noeud['A'] == null) &&
282
		(!isset($noeud['A']) || $noeud['A'] == null) &&
273
		(!isset($noeud['B']) || $noeud['B'] == null) &&
283
		(!isset($noeud['B']) || $noeud['B'] == null) &&
274
		(!isset($noeud['C']) || $noeud['C'] == null) &&
284
		(!isset($noeud['C']) || $noeud['C'] == null) &&
275
		(!isset($noeud['D']) || $noeud['D'] == null);
285
		(!isset($noeud['D']) || $noeud['D'] == null);
276
	}
286
	}
277
}
-
 
278
?>
-
 
279
287
}
-
 
288
280
289