Subversion Repositories eFlore/Applications.moissonnage

Rev

Rev 7 | Rev 31 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
7 delphine 1
// Javascript Document
2
 
3
 
28 alex 4
// ==============================================================
7 delphine 5
//  FONCTIONS ADDITIONNELLES POUR GERER LES URLS
28 alex 6
function convertirEnParametresUrl(objet) {
7 delphine 7
	var parametresUrl = '';
8
	for (attribut in objet) {
9
		if (typeof(objet[attribut]) == 'function' || typeof(objet[attribut]) == 'undefined' ||
10
			objet[attribut] == null)
11
			continue;
12
		parametresUrl += (parametresUrl == '' ? '' : '&') + attribut + "=" + objet[attribut].toString();
13
	}
14
	return parametresUrl;
15
};
16
 
28 alex 17
function estParametreDansUrl(nomParametre) {
18
	var estDansUrl = false;
7 delphine 19
	var listeParametres = location.search.substring(1).split("&");
20
	for (var index = 0; index < listeParametres.length; index ++) {
21
		var split = listeParametres[index].split("=");
22
		if (split[0] == nomParametre) {
28 alex 23
			estDansUrl = true;
7 delphine 24
		}
25
	}
28 alex 26
	return estDansUrl;
7 delphine 27
};
28
 
28 alex 29
// =============================================================
7 delphine 30
 
31
 
32
 
33
var map = null,
28 alex 34
optionsCoucheOSM = {
35
	attribution: 'Map data &copy; <a href="http://openstreetmap.org">OpenStreetMap</a> contributors,'
36
	+ ' <a href="http://creativecommons.org/licenses/by-sa/2.0/">CC-BY-SA</a>',
37
	maxZoom: 18
38
},
39
optionsCoucheGoogle = {
40
	attribution: 'Map data &copy;' + new Date().getFullYear() + ' <a href="http://maps.google.com">Google</a>',
41
	maxZoom: 18
42
},
43
coucheOSM = new L.TileLayer("http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png",
44
	optionsCoucheOSM),
45
couchePlanGoogle = new L.TileLayer("http://mt1.google.com/vt/lyrs=m&x={x}&y={y}&z={z}",
46
	optionsCoucheGoogle),
47
coucheSatelliteGoogle = new L.TileLayer("http://mt1.google.com/vt/lyrs=y&x={x}&y={y}&z={z}",
48
	optionsCoucheGoogle),
7 delphine 49
optionsCarte = {
50
	center : new L.LatLng(46, 2),
51
	zoom : 6,
52
	minZoom : 3,
28 alex 53
	maxBounds : [[-85.051129, -180], [85.051129, 180]],
54
	layers : [couchePlanGoogle]
7 delphine 55
},
28 alex 56
legende = null,
57
infoBulle = null;
7 delphine 58
 
59
var coucheSites = new L.FeatureGroup(),
60
overlays = [];
61
 
62
var requeteChargementPoints = null,
28 alex 63
doitRafraichirCarte = true,
7 delphine 64
timer = null,
65
url = '';
66
 
67
 
68
 
69
 
70
$(document).ready(function() {
71
	initialiserWidget();
72
});
73
 
74
function initialiserWidget() {
75
	initialiserCarte();
76
	initialiserListeners();
77
	initialiserPanneauControle();
78
	chargerLimitesCommunales();
28 alex 79
	if (!estParametreDansUrl('source')) {
7 delphine 80
		initialiserSources();
81
	}
82
	programmerRafraichissementCarte();
83
}
84
 
85
$(window).resize(function() {
86
	dimensionnerCarte();
28 alex 87
	if (infoBulle != null) {
88
		redimensionnerPopup();
89
	}
7 delphine 90
});
91
 
92
 
93
function dimensionnerCarte() {
94
	$('#map').height($(window).height());
95
	$('#map').width($(window).width());
96
}
97
 
98
function initialiserCarte() {
99
	dimensionnerCarte();
100
	map = L.map('map', optionsCarte);
101
	coucheSites.addTo(map);
102
	coucheOSM.addTo(map);
103
	couchePlanGoogle.addTo(map);
104
	coucheSatelliteGoogle.addTo(map);
105
	var echelle = new L.Control.Scale({
106
		maxWidth : 100,
107
		metric : true,
108
		imperial : false,
109
		updateWhenIdle : true
110
	});
111
	map.addControl(echelle);
112
}
113
function initialiserListeners() {
28 alex 114
	map.on('moveend', surChangementVueSurCarte);
115
	map.on('zoomend', surChangementVueSurCarte);
7 delphine 116
	map.on('popupclose', function(e) {
117
		masquerInfoBulle();
28 alex 118
		programmerRafraichissementCarte();
7 delphine 119
	});
120
}
121
 
122
function initialiserPanneauControle() {
123
	var baseMaps = {
124
		"OSM" : coucheOSM,
125
		"Plan" : couchePlanGoogle,
126
		"Satellite" : coucheSatelliteGoogle
127
	};
128
 
129
	var overlayMaps = {};
28 alex 130
	if (!estParametreDansUrl('source')) {
7 delphine 131
		for (var index = 0; index < nomSources.length; index ++) {
132
			overlayMaps[nomSources[index]] = new L.LayerGroup();
133
		}
134
	}
135
	L.control.layers(baseMaps, overlayMaps).addTo(map);
28 alex 136
	coucheOSM.bringToBack();
137
	couchePlanGoogle.bringToFront();
138
	coucheSatelliteGoogle.bringToBack();
7 delphine 139
 
140
	// garder par defaut la couche plan google comme selectionnee dans le panel
141
	var selecteursFonds = $('.leaflet-control-layers-base .leaflet-control-layers-selector');
142
	selecteursFonds[0].checked = false;
143
	selecteursFonds[1].checked = true;
144
	selecteursFonds[2].checked = false;
145
}
146
 
28 alex 147
function chargerLimitesCommunales() {
148
	if (urlsLimitesCommunales != null) {
149
		for (var index = 0; index < urlsLimitesCommunales.length; index ++) {
150
			var url = urlsLimitesCommunales[index];
151
			var coucheDepartement = new L.KML(url, {async: true});
152
			coucheDepartement.on("loaded", function(e) {
153
				map.fitBounds(e.target.getBounds());
154
			});
155
			map.addLayer(coucheDepartement);
156
		}
157
	}
158
}
159
 
7 delphine 160
function initialiserSources() {
161
	overlays = $('.leaflet-control-layers-overlays .leaflet-control-layers-selector');
162
	$.each(overlays, function (index, input) {
163
		input.value = sources[index];
164
		input.id = 'overlay' + (index+1);
165
		var lien = '<a href="' + liensVersSources[index] + '" target="_blank">' + nomSources[index] + '</a>';
166
		$('#overlay' + (index+1) + ' ~ span').html(lien);
167
		input.type = 'radio';
168
		input.checked = (sources[index] == source);
169
		input.onchange = function(event) {
170
			// evenement sur selection/deselection overlay dans sa checkbox
171
			changerSource(event.target.value);
172
		}
173
	});
174
}
175
 
28 alex 176
function surChangementVueSurCarte() {
177
	if (doitRafraichirCarte == false) {
178
		doitRafraichirCarte = true;
179
	} else {
180
		programmerRafraichissementCarte();
181
	}
182
}
7 delphine 183
 
184
function programmerRafraichissementCarte() {
185
	if(timer != null) {
186
        window.clearTimeout(timer);
187
    }
188
	if(requeteChargementPoints != null) {
189
		requeteChargementPoints.abort();
190
		requeteChargementPoints = null;
191
	}
192
	timer = window.setTimeout(function() {
193
		supprimerLocalisations();
194
		afficherMessageChargement('stations');
195
		chargerLocalisations();
196
    }, 400);
197
}
198
 
199
 
200
function supprimerLocalisations() {
201
	coucheSites.clearLayers();
202
}
203
 
204
 
205
function changerSource(projetClique) {
28 alex 206
	// deselctionner les autres boutons des controles d'overlays dans le panel
7 delphine 207
	for (var index = 0; index < overlays.length; index ++) {
208
		if (overlays[index].value != projetClique) {
209
			overlays[index].checked = false;
210
		}
211
	}
212
	// afficher les sites dans la carte pour le projet selectionne
213
	if (infoBulle != null) {
214
		masquerInfoBulle();
215
	}
216
	source = projetClique;
217
	programmerRafraichissementCarte();
218
}
219
 
220
 
221
function afficherMessageChargement(element) {
222
	var divTmplElement = 'tpl-chargement-' + element;
223
	$("#zone-chargement").append($("#" + divTmplElement).text());
224
	$("#zone-chargement").css('display', 'block');
225
}
226
 
227
function masquerMessageChargement() {
228
	$("#zone-chargement").css('display', 'none');
229
	$("#zone-chargement").children().remove();
230
}
231
 
232
 
233
// execution d'une requete AJAX
234
function executerAJAX() {
235
	if (requeteEnCours()) {
236
		masquerMessageChargement();
237
		requeteChargementPoints.abort();
238
	}
239
	requeteChargementPoints = $.getJSON(url).complete(function() {
28 alex 240
		fonctionCallback();
7 delphine 241
	});
242
}
243
 
244
function requeteEnCours() {
245
	return (requeteChargementPoints != null && requeteChargementPoints.readyState != 4);
246
}
247
 
28 alex 248
function retourRequeteOK() {
249
	return ((requeteChargementPoints.status == 200 || requeteChargementPoints.status == 304)
250
		|| requeteChargementPoints.status == 0);
251
}
7 delphine 252
 
253
 
28 alex 254
 
7 delphine 255
function chargerLocalisations() {
256
	// generer l'URL du script a interroger sur le serveur
257
	var coordonneesBordure = calculerCoordonneesBordure();
28 alex 258
	var parametres = {
259
		"source" : source,
260
		"num_taxon" : num_taxon,
261
		"referentiel" : referentiel,
262
		"dept" : dept,
263
		"auteur" : auteur,
264
		"bbox" : coordonneesBordure,
265
		"zoom" : map.getZoom()
266
	};
267
	url = urlBase + "stations?" + convertirEnParametresUrl(parametres);
7 delphine 268
 
28 alex 269
	fonctionCallback = traiterDonneesStations;
7 delphine 270
	executerAJAX();
28 alex 271
}
7 delphine 272
 
273
function calculerCoordonneesBordure() {
28 alex 274
	var bordure = map.getBounds();
7 delphine 275
	var ouest = bordure.getSouthWest().lng,
276
		sud = Math.max(bordure.getSouthWest().lat, -85.051129),
277
		est = bordure.getNorthEast().lng,
278
		nord = Math.min(bordure.getNorthEast().lat, 85.051129);
279
	// appliquer les limites possibles de la projection actuellement utilisee aux coordonnees
280
	// longitudes ouest et est de la bbox (permettra d'eviter de renvoyer des messages d'erreur)
281
	if (ouest < -180) {
282
		ouest += 360;
283
	} else if (ouest > 180) {
284
		ouest -= 360;
285
	}
286
	if (est < -180) {
287
		est += 360;
288
	} else if (est > 180) {
289
		est -= 360;
290
	}
291
	return [ouest, sud, est, nord].join(',');
292
}
293
 
28 alex 294
function traiterDonneesStations() {
295
	masquerMessageChargement();
296
 
297
	var texte = requeteChargementPoints.responseText;
298
	if (!retourRequeteOK()) {
299
		alert(texte);
300
	} else {
301
		var donneesJSON = eval("(function(){return " + texte + ";})()");
302
		if (typeof(donneesJSON) != 'undefined' && typeof(donneesJSON.features) != 'undefined') {
303
			ajouterObjets(donneesJSON);
304
		}
305
	}
306
}
7 delphine 307
 
28 alex 308
 
7 delphine 309
function ajouterObjets(data) {
310
	coucheSites.clearLayers();
28 alex 311
	var contientMailles = (data.features[0].properties.typeSite == 'MAILLE');
312
	for (var index = 0; index < data.features.length; index ++) {
313
		switch (data.features[index].properties.typeSite) {
314
			case 'MAILLE'  : ajouterMaille(data.features[index]);
7 delphine 315
				break;
316
			case 'COMMUNE' :
28 alex 317
			case 'STATION' : ajouterPoint(data.features[index]);
7 delphine 318
				break;
319
		}
320
	}
28 alex 321
	if (contientMailles && legende == null) {
7 delphine 322
		afficherLegende();
28 alex 323
	} else if (legende != null) {
7 delphine 324
		masquerLegende();
325
	}
326
}
327
 
328
function ajouterMaille(feature) {
329
	var coordonnees = [];
330
	for (var i = 0; i < feature.geometry.coordinates.length; i++) {
331
		var sommet = new L.LatLng(feature.geometry.coordinates[i][0], feature.geometry.coordinates[i][1]);
332
		coordonnees.push(sommet);
333
	}
334
 
335
	var objet = new L.Polygon(coordonnees, {
336
		color: '#FFFFFF',
337
		opacity : 0.7,
338
		weight: 1,
339
		fillColor : getColor(feature.properties.nombrePoints),
340
		fillOpacity : 0.6
341
	});
342
	objet.typeSite = feature.properties.typeSite;
343
	objet.nombrePoints = feature.properties.nombrePoints;
344
	objet.on('click', clicSurMaille);
345
	coucheSites.addLayer(objet);
346
	// afficher le nombre de points inclus dans la maille
347
	afficherNombreStationsDansMaille(objet);
348
}
349
 
350
function afficherNombreStationsDansMaille(maille) {
28 alex 351
	// comme la div qui contiendra la valeur du nombre de stations va se placer dans la page
352
	// au centre de la maille (et qui va servir de point d'ancrage pour le bord gauche par defaut)
353
	// il est necessaire de creer un decalage vers la gauche en fonction du nombre de chiffres
354
	var decalage = calculerDecalagePositionnementNombre(maille.nombrePoints);
7 delphine 355
	var sudMaille    = maille._originalPoints[0].y,
356
		ouestMaille  = maille._originalPoints[0].x,
357
		nordMaille   = maille._originalPoints[2].y,
358
		estMaille    = maille._originalPoints[2].x,
28 alex 359
		centreMaille = new L.Point((ouestMaille+estMaille)/2 - decalage, (sudMaille+nordMaille)/2);
7 delphine 360
	var divIcon = new L.divIcon({
361
		className : "nombre-sites",
362
		html : maille.nombrePoints
363
	});
364
	var marqueurDiv = new L.Marker(map.layerPointToLatLng(centreMaille), {
365
		icon : divIcon,
366
		maille : maille.getBounds()
367
	});
368
	marqueurDiv.on('click', clicSurMaille);
369
	coucheSites.addLayer(marqueurDiv);
370
}
371
 
28 alex 372
function calculerDecalagePositionnementNombre(nombrePoints) {
373
	var recul = 0;
374
	if (nombrePoints >= 10000) {
375
		recul = 14;
376
	} else if (nombrePoints >= 1000) {
377
		recul = 9;
378
	} else if (nombrePoints >= 100) {
379
		recul = 5;
380
	}
381
	return recul;
382
}
383
 
7 delphine 384
function clicSurMaille(event) {
385
	if (event.target._zIndex != null) {
386
		map.fitBounds(event.target.options.maille)
387
	} else {
388
		map.fitBounds(event.target.getBounds());
389
	}
390
}
391
 
28 alex 392
// generer la couleur a afficher pour les mailles
393
function getColor(nombrePoints) {
394
	var couleur = {'bleu': 231, 'vert': 224, 'rouge': 64},
395
		seuils = [1, 10, 50 ,100, 500, 1000, 2500],
396
		pas = 26,
397
		position = 0;
398
	for (var index = 1; index < seuils.length-1 && nombrePoints >= seuils[index]; index ++) {
399
		position ++;
7 delphine 400
	}
28 alex 401
	couleur.vert -= position*pas;
402
	return 'rgb('+couleur.bleu+','+couleur.vert+','+couleur.rouge+')';
403
 
404
	/*var codeHexa = 'rgb(231,224,64)';
405
	if (nombrePoints >= 2500) {
406
		codeHexa =  'rgb(231,68,64)';
407
	} else if (nombrePoints >= 1000) {
408
		codeHexa =  'rgb(231,94,64)';
409
	} else if (nombrePoints >= 500) {
410
		codeHexa =  'rgb(231,120,64)';
411
	} else if (nombrePoints >= 100) {
412
		codeHexa =  'rgb(231,146,64)';
413
	} else if (nombrePoints >= 50) {
414
		codeHexa =  'rgb(231,172,64)';
415
	} else if (nombrePoints >= 10) {
416
		codeHexa =  'rgb(231,198,64)';
417
	}
418
	return codeHexa;*/
7 delphine 419
}
420
 
421
 
422
function ajouterPoint(feature) {
28 alex 423
	var iconePoint = new L.Icon({ iconUrl : pointImageUrl,   iconSize : [16, 16] }),
424
		iconeCommune   = new L.Icon({ iconUrl : communeImageUrl, iconSize : [24, 32] }),
7 delphine 425
		icone = (feature.properties.typeSite == 'STATION') ? iconePoint : iconeCommune,
28 alex 426
		point = new L.LatLng(feature.geometry.coordinates[0], feature.geometry.coordinates[1]),
7 delphine 427
		marker = new L.Marker(point, {
28 alex 428
			icon : icone,
429
			type : feature.properties.typeSite,
430
			title : feature.properties.nom
431
		}).addTo(map);
432
	marker.on('click', surClicMarqueur);
7 delphine 433
	coucheSites.addLayer(marker);
434
}
435
 
436
 
437
function afficherLegende() {
438
	legende = new L.Control({position : 'bottomright'});
439
	legende.onAdd = function(map) {
28 alex 440
		return construireContenuHtmlLegende();
7 delphine 441
	};
442
	map.addControl(legende);
443
}
444
 
28 alex 445
function construireContenuHtmlLegende() {
446
	var div = L.DomUtil.create('div', 'info');
447
	div.innerHTML = '<h4>' + titreLegende + '</h4>';
448
	var seuils = [1, 10, 50 ,100, 500, 1000, 2500];
449
	var labels = [];
450
	for (var i = 0; i < seuils.length; i ++) {
451
		div.innerHTML +=
452
			'<div class="legend">'+
453
				'<span style="background:' + getColor(seuils[i] + 1) + '"></span>'+
454
				seuils[i]+ (i + 1 < seuils.length ? '&ndash;' + seuils[i + 1] : '+')+
455
			'</div>';
7 delphine 456
	}
28 alex 457
	return div;
7 delphine 458
}
459
 
28 alex 460
function masquerLegende() {
461
	map.removeControl(legende);
462
	legende = null;
463
}
7 delphine 464
 
465
 
28 alex 466
 
467
function surClicMarqueur(event) {
7 delphine 468
	var latitude = event.target.getLatLng().lat;
469
	var longitude = event.target.getLatLng().lng;
470
	pointClique = event.target;
471
	afficherMessageChargement('observations');
28 alex 472
	var parametres = {
473
		"source" : source,
474
		"num_taxon" : num_taxon,
475
		"referentiel" : referentiel,
476
		"auteur" : auteur,
477
		"longitude" : longitude,
478
		"latitude" : latitude
479
	};
480
	url = urlBase + "observations?" + convertirEnParametresUrl(parametres);
481
	fonctionCallback = traiterDonneesObservations;
482
	executerAJAX();
483
}
484
 
485
function traiterDonneesObservations() {
486
	masquerMessageChargement();
487
	var texte = requeteChargementPoints.responseText;
488
	if (!retourRequeteOK()) {
489
		alert(texte);
490
	} else {
7 delphine 491
 
28 alex 492
		obsJSON = eval("(function(){return " + texte + ";})()");
493
		viderListeObservations();
7 delphine 494
		if (obsJSON.total > 0) {
28 alex 495
			doitRafraichirCarte = false;
496
			map.setView(new L.LatLng(pointClique.getLatLng().lat, pointClique.getLatLng().lng), map.getZoom());
7 delphine 497
			afficherInfoBulle();
498
		} else if (infoBulle != null)  {
499
			masquerInfoBulle();
500
		}
501
	}
502
}
503
 
28 alex 504
function viderListeObservations() {
505
	obsStation = new Array();
506
}
7 delphine 507
 
508
 
28 alex 509
// ====================================================================
510
//  Gestion de l'infobulle
7 delphine 511
 
28 alex 512
var obsJSON = null,
7 delphine 513
	pointClique = null,
514
	obsStation = [],
515
	typeAffichage = "";
516
 
517
function afficherInfoBulle() {
518
	var latitude = pointClique.getLatLng().lat;
519
	var longitude = pointClique.getLatLng().lng;
28 alex 520
	infoBulle = new L.Popup({maxWidth : definirLargeurInfoBulle(), maxHeight : 350});
7 delphine 521
	infoBulle.setLatLng(new L.LatLng(latitude, longitude));
522
	infoBulle.setContent($("#tpl-obs").html());
28 alex 523
	infoBulle.openOn(map);
524
	remplirContenuPopup();
525
}
526
 
527
function definirLargeurInfoBulle() {
528
	var largeurViewPort = $(window).width();
529
	var lageurInfoBulle = null;
530
	if (largeurViewPort < 800) {
531
		largeurInfoBulle = 400;
532
	} else if (largeurViewPort >= 800 && largeurViewPort < 1200) {
533
		largeurInfoBulle = 500;
534
	} else if (largeurViewPort >= 1200) {
535
		largeurInfoBulle = 600;
536
	}
537
	return largeurInfoBulle;
538
}
539
 
540
function redimensionnerPopup() {
541
	$('.leaflet-popup-content*').css('width',  definirLargeurInfoBulle());
542
	$('#info-bulle').css('width',  definirLargeurInfoBulle());
543
}
544
 
545
function remplirContenuPopup() {
7 delphine 546
	ajouterTableauTriable("#obs-tableau");
547
	ajouterTitre();
548
	afficherOnglets();
549
	afficherTexteStationId();
550
}
551
 
552
function masquerInfoBulle() {
553
	if (map.hasLayer(infoBulle) && infoBulle != null) {
554
		map.removeLayer(infoBulle);
555
	}
556
	infoBulle = null;
557
}
558
 
559
function ajouterTitre() {
560
	var texteStationTitre = obsJSON.total + ' observation' + (obsJSON.total > 1 ? 's' : '')
561
		+ ' pour ' + (pointClique.options.type=='STATION' ? 'la station : ' : 'la commune : ')
562
		+ pointClique.options.title;
563
	$('#obs-station-titre').text(texteStationTitre);
564
}
565
 
566
function selectionnerOnglet() {
567
	$("#obs-vue-" + typeAffichage).css("display", "block");
568
	$('#obs-tableau-lignes').empty();
569
	$('#obs-liste-lignes').empty();
570
	if (typeAffichage=='liste') {
571
		$("#obs-vue-tableau").css("display", "none");
572
	} else {
573
		$("#obs-vue-liste").css("display", "none");
574
	}
575
}
576
 
577
function ajouterObservationsDansHTML() {
578
	if (obsStation.length==0) {
579
		// premiere execution de la fonction : faire une copie des objets JSON decrivant les observations
580
		for (var index = 0; index < obsJSON.observations.length; index ++) {
581
			obsStation.push(obsJSON.observations[index]);
582
		}
583
	}
584
	// ajouter les observations dans le code HTML
585
	var obsPage = [];
586
	for (var index = 0; index < obsStation.length; index ++) {
587
		obsPage.push(obsStation[index]);
588
	}
589
	$("#tpl-obs-"+typeAffichage).tmpl(obsPage).appendTo("#obs-"+typeAffichage+"-lignes");
590
}
591
 
592
function afficherOnglets() {
593
	var $tabs = $('#obs').tabs();
594
	$('#obs').bind('tabsselect', function(event, ui) {
595
		if (ui.panel.id == 'obs-vue-tableau') {
596
			surClicAffichageTableau();
597
		} else if (ui.panel.id == 'obs-vue-liste') {
598
			surClicAffichageListe();
599
		}
600
	});
601
	if (obsJSON.total > 4) {
602
		surClicAffichageTableau();
603
	} else {
604
		$tabs.tabs('select', "#obs-vue-liste");
605
	}
606
}
607
 
608
function surClicAffichageTableau() {
609
	typeAffichage = 'tableau';
610
	selectionnerOnglet();
611
	ajouterObservationsDansHTML();
612
	mettreAJourTableauTriable("#obs-tableau");
613
}
614
 
615
function surClicAffichageListe() {
616
	typeAffichage = 'liste';
617
	selectionnerOnglet();
618
	ajouterObservationsDansHTML();
619
}
620
 
621
function ajouterTableauTriable(element) {
622
	// add parser through the tablesorter addParser method
623
	$.tablesorter.addParser({
624
		// Définition d'un id unique pour ce parsseur
625
		id: 'date_cel',
626
		is: function(s) {
627
			// doit retourner false si le parsseur n'est pas autodétecté
628
			return /^\s*\d{2}[\/-]\d{2}[\/-]\d{4}\s*$/.test(s);
629
		},
630
		format: function(date) {
631
			// Transformation date jj/mm/aaaa en aaaa/mm/jj
632
			date = date.replace(/^\s*(\d{2})[\/-](\d{2})[\/-](\d{4})\s*$/, "$3/$2/$1");
633
			// Remplace la date par un nombre de millisecondes pour trier numériquement
634
			return $.tablesorter.formatFloat(new Date(date).getTime());
635
		},
636
		// set type, either numeric or text
637
		type: 'numeric'
638
	});
639
	$(element).tablesorter({
640
        headers: {
641
			1: {
642
            	sorter:'date_cel'
643
        	}
644
    	}
645
	});
646
}
647
 
648
function mettreAJourTableauTriable(element) {
649
	$(element).trigger('update');
650
}
651
 
652
function afficherTexteStationId() {
653
	var latitude = pointClique.getLatLng().lat;
654
	var longitude = pointClique.getLatLng().lng;
655
	var texteStationId = pointClique.options.type + ':' + latitude + '|' + longitude;
656
	$('#obs-station-id').text(texteStationId);
657
}