31,20 → 31,25 |
*/ |
class Carto extends WidgetCommun { |
const DS = DIRECTORY_SEPARATOR; |
const SERVICE_DEFAUT = 'carte-defaut'; |
const SERVICE_CARTO_NOM = 'CelWidgetMap'; |
const SERVICE_CARTO_ACTION_DEFAUT = 'carte-defaut'; |
|
private $carte = null; |
private $utilisateur = null; |
private $projet = null; |
private $dept = null; |
private $num_taxon = null; |
private $station = null; |
private $format = null;// Format des obs pour les stations (tableau/liste) |
|
/** |
* Méthode appelée par défaut pour charger ce widget. |
*/ |
public function executer() { |
$retour = null; |
extract($this->parametres); |
$this->extraireParametres(); |
|
if (!isset($carte)) { |
$carte = self::SERVICE_DEFAUT; |
} |
|
$methode = $this->traiterNomMethodeExecuter($carte); |
$methode = $this->traiterNomMethodeExecuter($this->carte); |
if (method_exists($this, $methode)) { |
$retour = $this->$methode(); |
} else { |
60,6 → 65,17 |
$this->envoyer($html); |
} |
} |
|
public function extraireParametres() { |
extract($this->parametres); |
$this->carte = (isset($carte) ? $carte : self::SERVICE_CARTO_ACTION_DEFAUT); |
$this->utilisateur = (isset($utilisateur) ? $utilisateur : '*'); |
$this->projet = (isset($projet) ? $projet : '*'); |
$this->dept = (isset($dept) ? $dept : '*'); |
$this->num_taxon = (isset($num_taxon) ? $num_taxon : '*'); |
$this->station = (isset($station) ? $station : null); |
$this->format = (isset($format) ? $format : null); |
} |
|
/** |
* Carte par défaut |
66,56 → 82,67 |
*/ |
public function executerCarteDefaut() { |
$widget = null; |
extract($this->parametres); |
$utilisateur = (isset($utilisateur) ? $utilisateur : '*'); |
$projet = (isset($projet) ? $projet : '*'); |
$dept = (isset($dept) ? $dept : '*'); |
$num_taxon = (isset($num_taxon) ? $num_taxon : '*'); |
|
// Création url données json |
$url_cel_carto = sprintf($this->config['chemins']['baseURLServicesCelTpl'], 'CelWidgetMap'); |
$url_json = "$url_cel_carto/carte-defaut-json/$utilisateur/$projet/$dept/$num_taxon"; |
|
$url_json = $this->contruireUrlServiceCarto('carte-defaut-json'); |
$url_base = sprintf($this->config['chemins']['baseURLAbsoluDyn'], ''); |
|
// Création des infos du widget |
$widget['donnees']['url_cel_carto'] = $url_cel_carto; |
$widget['donnees']['url_cel_carto'] = $this->contruireUrlServiceCarto(); |
$widget['donnees']['url_json'] = $url_json; |
$widget['donnees']['url_base'] = $url_base; |
$widget['donnees']['jquery_version'] = '1.4.4'; |
$widget['donnees']['utilisateur'] = $utilisateur; |
$widget['donnees']['projet'] = $projet; |
$widget['donnees']['dept'] = $dept; |
$widget['donnees']['num_taxon'] = $num_taxon; |
$widget['donnees']['utilisateur'] = $this->utilisateur; |
$widget['donnees']['projet'] = $this->projet; |
$widget['donnees']['dept'] = $this->dept; |
$widget['donnees']['num_taxon'] = $this->num_taxon; |
$widget['donnees']['taxons'] = $this->chargerTaxons(); |
if ($num_taxon != '*') { |
if ($this->num_taxon != '*') { |
$taxon_courrant = current($widget['donnees']['taxons']); |
$widget['donnees']['taxon_nom'] = $taxon_courrant['nom']; |
} |
$widget['squelette'] = 'carte_defaut'; |
|
if (isset($dept)) { |
if (isset($this->dept)) { |
// si on veut afficher les limites départemmentales on va compter et chercher les noms de fichiers |
$fichiersKml = $this->chercherFichierKml($dept); |
$fichiersKml = $this->chercherFichierKml(); |
$urls = null; |
foreach ($fichiersKml as $kml => $dossier){ |
$url_limites_communales = sprintf($this->config['carto']['limitesCommunaleUrlTpl'], $dossier, $kml); |
$widget['donnees']['url_limites_communales'][] = $url_limites_communales; |
$urls[] = $url_limites_communales; |
} |
$widget['donnees']['url_limites_communales'] = json_encode($urls); |
} |
|
return $widget; |
} |
|
private function contruireUrlServiceCarto($action = null) { |
// Création url données json |
$url = sprintf($this->config['chemins']['baseURLServicesCelTpl'], self::SERVICE_CARTO_NOM); |
if ($action) { |
$url .= "/$action"; |
|
$parametres_retenus = array(); |
$parametres_a_tester = array('station', 'utilisateur', 'projet', 'dept', 'num_taxon'); |
foreach ($parametres_a_tester as $param) { |
if ($this->$param != null && $this->$param != '*') { |
$parametres_retenus[$param] = $this->$param; |
} |
} |
if (count($parametres_retenus) > 0) { |
$parametres_url = array(); |
foreach ($parametres_retenus as $cle => $valeur) { |
$parametres_url[] = $cle.'='.$valeur; |
} |
$url .= '?'.implode('&', $parametres_url); |
} |
} |
$this->debug[] = $url; |
// Prendre en compte param "station" |
return $url; |
} |
|
private function chargerTaxons() { |
extract($this->parametres); |
$utilisateur = (isset($utilisateur) ? $utilisateur : '*'); |
$projet = (isset($projet) ? $projet : '*'); |
$dept = (isset($dept) ? $dept : '*'); |
$num_taxon = (isset($num_taxon) ? $num_taxon : '*'); |
|
// Récupération des données au format Json |
$service = "CelWidgetMap/taxons/$utilisateur/$projet/$dept/$num_taxon"; |
$url = sprintf($this->config['chemins']['baseURLServicesCelTpl'], $service); |
$url = $this->contruireUrlServiceCarto('taxons'); |
$json = $this->getDao()->consulter($url); |
$donnees = json_decode($json); |
|
142,9 → 169,9 |
return $taxons; |
} |
|
private function chercherFichierKml($dept){ |
private function chercherFichierKml(){ |
$chemins = explode(',', $this->config['carto']['communesKmzChemin']); |
$departements = explode(',', $dept);// plrs code de départements peuvent être demandés séparés par des virgules |
$departements = explode(',', $this->dept);// plrs code de départements peuvent être demandés séparés par des virgules |
$departements_trouves = array(); |
$fichiers = array(); |
foreach ($chemins as $dossier_chemin) { |
175,9 → 202,7 |
*/ |
public function executerObservations() { |
$widget = null; |
extract($this->parametres); |
|
$observations = $this->chargerObservation($station); |
$observations = $this->chargerObservation(); |
|
// Création des infos du widget |
if (isset($observations['commune'])) { |
198,21 → 223,14 |
} |
|
$widget['donnees']['observations'] = $observations; |
$widget['donnees']['station_id'] = $station; |
$widget['donnees']['station_id'] = $this->station; |
|
return $widget; |
} |
|
private function chargerObservation($station) { |
extract($this->parametres); |
$utilisateur = (isset($utilisateur) ? $utilisateur : '*'); |
$projet = (isset($projet) ? $projet : '*'); |
$dept = (isset($dept) ? $dept : '*'); |
$num_taxon = (isset($num_taxon) ? $num_taxon : '*'); |
|
private function chargerObservation() { |
// Récupération des données au format Json |
$service = "CelWidgetMap/observations/$station/$utilisateur/$projet/$dept/$num_taxon"; |
$url = sprintf($this->config['chemins']['baseURLServicesCelTpl'], $service); |
$url = $this->contruireUrlServiceCarto('observations'); |
$json = $this->getDao()->consulter($url); |
$donnees = json_decode($json); |
|
254,10 → 272,9 |
} |
|
private function choisirFormatSortie($observations_nbre) { |
extract($this->parametres); |
$sortie = 'obs_tableau'; |
if (isset($format) && $format != '*') { |
$sortie = ($format == 'tableau' ) ? 'obs_tableau' : 'obs_liste'; |
if (isset($this->format) && $this->format != '*') { |
$sortie = ($this->format == 'tableau' ) ? 'obs_tableau' : 'obs_liste'; |
} else { |
$sortie = ($observations_nbre > 4) ? 'obs_tableau' : 'obs_liste'; |
} |
268,6 → 285,7 |
// Récupération des données au format Json |
$service = 'CelImage/liste-ids?obsId='.implode(',', $obs_ids); |
$url = sprintf($this->config['chemins']['baseURLServicesCelTpl'], $service); |
$this->debug[] = $url; |
$json = $this->getDao()->consulter($url); |
$donnees = json_decode($json); |
|