Subversion Repositories eFlore/Applications.cel

Compare Revisions

Regard whitespace Rev 1031 → Rev 1032

/trunk/widget/modules/carto/squelettes/scripts/carto.js
4,7 → 4,7
var DEBUG = false;
var communeImageUrl = 'http://www.tela-botanica.org/commun/icones/carto/commune.png';
var pointImageUrl = 'http://www.tela-botanica.org/commun/icones/carto/point2.png';
var groupeImageUrlTpl = 'http://localhost/cel-jrest/CelWidgetMap/icone-groupe?type={type}&nbre={nbre}'
var groupeImageUrlTpl = 'http://localhost/jrest/CelWidgetMap/icone-groupe?type={type}&nbre={nbre}'
var pointsOrigine = null;
var boundsOrigine = null;
var markerClusterer = null;
62,7 → 62,8
initialiserInfoBulle();
initialiserFormulaireContact();
chargerLimitesCommunales();
rafraichirCarte();
attribuerListenerCarte();
programmerRafraichissementCarte();
}
 
/*+--------------------------------------------------------------------------------------------------------+*/
140,21 → 141,24
}
var listener = null;
var timer = null;
function rafraichirCarte() {
function attribuerListenerCarte() {
listener = google.maps.event.addListener(map, 'bounds_changed', function(){
programmerRafraichissementCarte();
});
listener = google.maps.event.addListener(map, 'zoom_changed', function(){
programmerRafraichissementCarte();
});
}
function programmerRafraichissementCarte() {
if(timer != null) {
window.clearTimeout(timer);
}
timer = window.setTimeout(function() {
var zoom = map.getZoom();
var NELatLng = map.getBounds().getNorthEast().lat()+'|'+map.getBounds().getNorthEast().lng();
var SWLatLng = map.getBounds().getSouthWest().lat()+'|'+map.getBounds().getSouthWest().lng();
chargerMarqueurs(zoom, NELatLng, SWLatLng);
}, 300);
});
}, 400);
}
 
function collecterBorduresEtChargerMarqueurs() {
164,12 → 168,15
var premierChargement = true;
var marqueurs = new Array();
function chargerMarqueurs(zoom, NELatLng, SWLatLng) {
google.maps.event.removeListener(listener);
var url = stationsUrl+
'&zoom='+zoom+
'&ne='+NELatLng+
'&sw='+SWLatLng;
if(infoBulleOuverte) {
return;
}
$.getJSON(url, function(data) {
$.each(marqueurs, function(index, marqueur) {
179,28 → 186,12
stations = data;
afficherTitreCarte();
/*if(premierChargement) {
var bounds = new google.maps.LatLngBounds();
}*/
$.each(stations.points, function (index, station) {
/*if(premierChargement) {
var maLatLng = null;
maLatLng = new google.maps.LatLng(station['lat'], station['lng']);
bounds.extend(maLatLng);
}*/
if(station != null) {
marqueurs.push(creerMarqueur(station));
}
});
/*if(premierChargement) {
map.fitBounds(bounds);
premierChargement = false;
}*/
rafraichirCarte();
});
}
 
220,7 → 211,7
return marqueur;
}
 
function rafraichirCarteSauv() {
function programmerRafraichissementCarteSauv() {
var points = [];
var bounds = new google.maps.LatLngBounds();
295,13 → 286,12
}
}
 
function surClickMarqueur() {
function surClickMarqueur(event) {
pointClique = this;
infoBulle.open(map, this);
//centrerInfoBulle();
actualiserPagineur();
afficherInfoBulle();
chargerObs(0, 0);
programmerRafraichissementCarte();
}
 
function surClickGroupe() {
352,7 → 342,7
 
/*+--------------------------------------------------------------------------------------------------------+*/
// INFO BULLE
 
var infoBulleOuverte = false;
function initialiserInfoBulle() {
google.maps.event.addListener(infoBulle, 'domready', initialiserContenuInfoBulle);
google.maps.event.addListener(infoBulle, 'closeclick', surFermetureInfoBulle);
360,7 → 350,8
}
 
function surFermetureInfoBulle() {
//deplacerCarteSurPointClique();
infoBulleOuverte = false;
programmerRafraichissementCarte();
}
 
function centrerInfoBulle() {
376,6 → 367,7
var largeur = definirLargeurInfoBulle();
obsHtml = obsHtml.replace(/\{largeur\}/, largeur);
infoBulle.setContent(obsHtml);
infoBulleOuverte = true;
}
 
function definirLargeurInfoBulle() {
821,7 → 813,6
stations = stationsFiltrees;
nt = ntAFiltrer;
$('#taxon-'+nt).addClass('taxon-actif');
rafraichirCarte();
});
}
};
/trunk/jrest/services/CelWidgetMap.php
71,7 → 71,7
extract($this->parametres);
 
//TODO: changer ceci pour une adresse indiquée dans un fichier de config
$img = imagecreatefrompng("/home/jpm/web/serveur/commun/icones/carto/groupe/g$type.png");
$img = imagecreatefrompng("/home/aurelien/web/cel_GWT2/widget/documents/icones/carto/groupe/g$type.png");
 
$noir = imagecolorallocate($img, 0, 0, 0);
$texte = (String) $nbre;
/trunk/jrest/lib/CartoGroupage.php
1,7 → 1,7
<?php
class CartoGroupage {
 
private static $seuilClusterisation = 100;
private static $seuilClusterisation = 200;
private static $zoomDefaut = 3;
private static $zoomMaxClustering = 12;
private static $pasZoomDefaut = 1;
35,13 → 35,14
*/
public static function creerGroupesQuadtree(&$markers, $neLat, $neLng, $swLat, $swLng, $zoom = 3) {
if (count($markers) > self::$seuilClusterisation) {
self::calculerProfondeurMax($zoom);
self::calculerPasCorrectionCentre($zoom);
 
$noeudRacine = array('nbrePoints' => count($markers), 'points' => $markers);
self::attribuerAuCadran($noeudRacine, $neLat, $neLng, $swLat, $swLng);
} else {
 
foreach($markers as $marker) {
$points = array($marker);
$noeudSimple = array('points' => $points, 'nbrePoints' => 1);
74,8 → 75,7
 
private function calculerProfondeurMax($zoom) {
if($zoom > self::$zoomDefaut) {
//self::$profondeurMax = round(($zoom - self::$zoomDefaut) * self::calculerCoefficientProfondeurMax() + self::$profondeurMin,0);
self::$profondeurMax = $zoom-1;
self::$profondeurMax = round(($zoom - self::$zoomDefaut) * self::calculerCoefficientProfondeurMax() + self::$profondeurMin,0);
} else {
self::$profondeurMax = 1;
}
95,14 → 95,14
* @param int $profondeur profondeur courante de l'arbre
*/
private static function attribuerAuCadran(&$noeud, $neLat, $neLng, $swLat, $swLng, $profondeur = 0) {
$latCentre = round((($neLat+$swLat)/2)/self::$pasCorrectionCentre,0)*self::$pasCorrectionCentre;
$lngCentre = round((($neLng+$swLng)/2)/self::$pasCorrectionCentre,0)*self::$pasCorrectionCentre;
 
foreach ($noeud['points'] as &$point) {
self::$nbElements['observations']++;
if (isset($point['type_emplacement'])) {
self::$nbElements[$point['type_emplacement']]++;
}
$emplacement = isset($point['type_emplacement']) ? $point['type_emplacement'] : self::obtenirTypeEmplacementParId(&$point);
self::$nbElements[$emplacement]++;
unset($point['type_emplacement']);
$cadran = self::obtenirCadranPourPoint($latCentre, $lngCentre, $point);
self::ajouterFils($noeud,$cadran,$point);
111,10 → 111,10
$profondeur++;
 
if ($profondeur <= self::$profondeurMax) {
(isset($noeud['A'])) ? self::attribuerAuCadran($noeud['A'], $neLat, $lngCentre , $latCentre, $swLng, $profondeur) : '';
(isset($noeud['B'])) ? self::attribuerAuCadran($noeud['B'], $neLat, $neLng, $latCentre, $lngCentre, $profondeur) : '';
(isset($noeud['C'])) ? self::attribuerAuCadran($noeud['C'], $latCentre, $neLng, $swLat, $lngCentre, $profondeur) : '';
(isset($noeud['D'])) ? self::attribuerAuCadran($noeud['D'], $latCentre, $lngCentre, $swLat, $swLng, $profondeur) : '';
(isset($noeud['A']) && $noeud['A'] != null) ? self::attribuerAuCadran($noeud['A'], $neLat, $lngCentre , $latCentre, $swLng, $profondeur) : '';
(isset($noeud['B']) && $noeud['B'] != null) ? self::attribuerAuCadran($noeud['B'], $neLat, $neLng, $latCentre, $lngCentre, $profondeur) : '';
(isset($noeud['C']) && $noeud['C'] != null) ? self::attribuerAuCadran($noeud['C'], $latCentre, $neLng, $swLat, $lngCentre, $profondeur) : '';
(isset($noeud['D']) && $noeud['D'] != null) ? self::attribuerAuCadran($noeud['D'], $latCentre, $lngCentre, $swLat, $swLng, $profondeur) : '';
}
 
if(self::estUnParentFeuilles($noeud)) {
122,6 → 122,19
}
}
 
private static function obtenirTypeEmplacementParId($point) {
$tableau_point_id = explode(':',$point['id'],2);
switch($tableau_point_id[0]) {
case 'STATION':
$type_emplacement = 'stations';
break;
case 'COMMUNE':
$type_emplacement = 'communes';
break;
}
return $type_emplacement;
}
private function obtenirCadranPourPoint($latCentre,$lngCentre, &$point) {
if ($point['lng'] < $lngCentre) {
if ($point['lat'] > $latCentre) {
140,16 → 153,13
}
 
private static function ajouterFils(&$noeud, $cadran, &$point) {
$fils = array('points' => array(), 'nbrePoints' => 0, 'latMoyenne' => 0, 'lngMoyenne' => 0);
if (isset($noeud[$cadran])) {
$fils = $noeud[$cadran];
if(!isset($noeud[$cadran])) {
$noeud[$cadran] = array('points' => array(),'nbrePoints' => 0, 'latMoyenne' => 0, 'lngMoyenne' => 0);
}
 
$fils['points'][] = $point;
$fils['nbrePoints']++;
$fils['latMoyenne'] += $point['lat'];
$fils['lngMoyenne'] += $point['lng'];
$noeud[$cadran] = $fils;
$noeud[$cadran]['points'][] = $point;
$noeud[$cadran]['nbrePoints']++;
$noeud[$cadran]['latMoyenne'] += $point['lat'];
$noeud[$cadran]['lngMoyenne'] += $point['lng'];
}
 
private static function ajouterGroupeOuPoint(&$noeud) {
173,7 → 183,11
}
 
private static function estUneFeuille(&$noeud) {
return $noeud == null || (!isset($noeud['A']) && !isset($noeud['B']) && !isset($noeud['C']) && !isset($noeud['D']));
return $noeud == null ||
(!isset($noeud['A']) || $noeud['A'] == null) &&
(!isset($noeud['B']) || $noeud['B'] == null) &&
(!isset($noeud['C']) || $noeud['C'] == null) &&
(!isset($noeud['D']) || $noeud['D'] == null);
}
}
?>