Subversion Repositories eFlore/Projets.eflore-projets

Compare Revisions

Ignore whitespace Rev 313 → Rev 314

/trunk/services/modules/0.1/eflore/cartes/GeneralFormateur.php
New file
0,0 → 1,300
<?php
class GeneralFormateur {
public $dest_map = array();
public $img = array();
public function __construct($parametres, $info) {
$this->param = $parametres;
$this->info = $info;
}
public function img() {
$qualite = 90;
imagejpeg($this->img['general'], Config::get('cache.stockageChemin').$this->dest_map['general'], $qualite);
}
//+----------------------------------------------------------------------------------------------------------------+
// Méthodes d'accès aux objets du Framework
/**
* Méthode de connection à la base de données sur demande.
* Tous les services web n'ont pas besoin de s'y connecter.
*/
protected function getBdd() {
if (! isset($this->Bdd)) {
$this->Bdd = new Bdd();
}
return $this->Bdd;
}
public function definirCouleurs() {
// green
$couleur['green'] = imagecolorallocate($this->img['general'], 0, 255, 0);
// red
$couleur['red'] = imagecolorallocate($this->img['general'], 255, 0, 0);
// blue
$couleur['blue'] = imagecolorallocate($this->img['general'], 0, 0, 255);
// purple
$couleur['purple'] = imagecolorallocate($this->img['general'], 255, 0, 255);
// black
$couleur['black'] = imagecolorallocate($this->img['general'], 0, 0, 0);
return $couleur;
}
public function initialiserImage() {
// Nom du fichier image en sortie
$this->cheminCartesBase = Config::get('Cartes.chemin');
$this->dest_map['general'] = 'nt'.$this->info['nt'].'_'.$this->info['src_map'];
$this->img['general'] = imagecreatefromjpeg($this->cheminCartesBase.$this->info['src_map']);
}
public function chargerDonnees() {
// Recherche nom correspondant au numero nomenclatural en cours (pour etablir le lien avec les donnees moissonnes).
// R�cuperation donn�e inventaire
/*
* Les donnees issues du carnet en ligne sont recuperes directement, sans passer par le mecanisme de moissonage car :
* - pour l'instant le service de moissonage n'est pas automatise et donc il y a un decalage dans l'affichage des donnees transmises
* - la table contenant les donnees moissonees ne reprend pas tous les champs necessaires a l'exploitation par eflore (notamment pas de code localite, pas d'identifiant libre)
*
* A terme, utilser vraiment le moissonage, y compris pour les donnees issues du CEL, en utilisant ABCD et en modifiant le programme d'harvesting.
*/
$queryCel = "SELECT 'cel' as collection_code, location, id_location, date_observation, ".
" coord_y as y_utm, coord_x as x_utm, ref_geo as sector, identifiant FROM tb_cel.cel_inventory ".
"WHERE num_taxon = '".$this->info['nt']."' ".
" AND transmission = 1";
$inventoriesCel = $this->getBdd()->recupererTous($queryCel);
// Recuperation des donnees de moissonage
// Collection code = 'flore' (Cenlr)
$queryCenlr = "SELECT collection_code, locality as location, county as id_location, ".
" STR_TO_DATE(concat(year, '/',month, '/',day), '%Y/%m/%d') as date_observation, latitude as y_utm , ".
" longitude as x_utm , max_altitude as sector, collector_name as identifiant ".
"FROM tb_hit_indexation.raw_occurrence_record ".
"WHERE scientific_name = ".$this->getBdd()->proteger($this->info['nom']).
" AND collection_code = 'flore' ".
" AND (deleted IS NULL OR deleted = '0000-00-00 00:00:00')";
$inventoriesCenlr = $this->getBdd()->recupererTous($queryCenlr);
// Collection code = 'FLORE - VAR' (Cbnmed)
/*$queryCbnmed = "SELECT collection_code, locality as location, county as id_location, ".
" STR_TO_DATE(concat(ifnull(year,0),'/', ifnull(month,0), '/',ifnull(day,0)), '%Y/%m/%d') as date_observation, ".
" latitude as y_utm , longitude as x_utm , max_altitude as sector, collector_name as identifiant ".
"FROM tb_hit_indexation.raw_occurrence_record ".
"WHERE scientific_name = ".$this->getBdd()->proteger($this->info['nom']).
" AND collection_code='FLORE - VAR' ".
" AND (deleted IS NULL OR deleted = '0000-00-00 00:00:00')";
$inventoriesCbnmed = $this->getBdd()->recupererTous($queryCbnmed);*/
// Collection code = 'sophy'
$querySophy = "SELECT 'sophy' as collection_code, lieu_station_nom as location, lieu_commune_code_insee as id_location, ".
" observation_date as date_observation, lieu_station_utm_est as x_utm , ".
" lieu_station_utm_nord as y_utm , lieu_station_utm_zone as sector, observateur_nom_complet as identifiant ".
"FROM sophy_tapir ".
"WHERE nom_scientifique_complet = ".$this->getBdd()->proteger($this->info['nom_ss_auteur']);
$inventoriesSophy = $this->getBdd()->recupererTous($querySophy);
return array_merge($inventoriesCel, $inventoriesCenlr, $inventoriesSophy); //$inventoriesCbnmed,
}
 
public function dessinerPoint($text, $merge, $couleurs) {
$usemap['general'] = '';
foreach ($text as $coord => $origines ) {
foreach ($origines as $origine => $maptext ) {
$maptext = preg_replace("/\"/", "\'", $maptext);
list($x,$y) = explode('|', $coord);
$tpl_area = '<area shape="%s" alt="" class="tooltip" coords="%s" title="%s"/>';
$rayon = 2;
$type = 'circle';
$coords = "$x,$y,5";
$on_mouseover = "this.ttBgColor='#99C242';this.ttFontColor='#000000';this.T_OFFSETX=-200;this.T_OFFSETY=-50;this.T_STICKY=1;return escape('$maptext')";
if (isset($merge[$coord]) && $merge[$coord]) {
imagefilledrectangle($this->img['general'], ($x - $rayon), ($y - $rayon), ($x + $rayon), ($y + $rayon), $couleurs['black']);
} elseif (isset ($text[$coord]['cel']) && ($text[$coord]['cel'])) {
imagefilledrectangle($this->img['general'], ($x - $rayon), ($y - $rayon), ($x + $rayon), ($y + $rayon), $couleurs['green']);
} elseif (isset ($text[$coord]['flore']) && ($text[$coord]['flore'])) {
imagefilledrectangle($this->img['general'], ($x - $rayon), ($y - $rayon), ($x + $rayon), ($y + $rayon), $couleurs['red']);
}/* elseif (isset ($text[$coord]['FLORE - VAR']) && ($text[$coord]['FLORE - VAR'])) {
imagefilledrectangle($this->img['general'], ($x - $rayon), ($y - $rayon), ($x + $rayon), ($y + $rayon), $couleurs['blue']);
}*/ elseif (isset ($text[$coord]['sophy']) && ($text[$coord]['sophy'])) {
imagefilledrectangle($this->img['general'], ($x - $rayon), ($y - $rayon), ($x + $rayon), ($y + $rayon), $couleurs['purple']);
}
$usemap['general'] = $usemap['general'].sprintf($tpl_area, $type, $coords, $maptext);
}
}
return $usemap;
}
public function formaterCartes($usemap) {
$retour = "<img src=\"".(Config::get('Cartes.cel_dst').$this->dest_map['general'])."\" style=\"border:none; cursor:crosshair\" alt=\"\" usemap=\"#themap\" /><br />\n";
$retour .= "<map name=\"themap\" id=\"themap\">";
$retour .= $usemap['general'];
$retour .= "</map>";
return $retour;
}
public function formaterCarteMiniature($retour, $usemap) {
$retour['image'] = Config::get('Cartes.cel_dst').$this->dest_map['general'];
$retour['map'] = $usemap['general'];
if (isset($this->param['retour']) && $this->param['retour'] == 'htm') {
$retour['image'] = "<img src=\"".$retour['image']."\" style=\"border:none; cursor:crosshair\""
."alt=\"\" usemap=\"#themap\"></img><br />\n";
$retour['map'] = "<map name=\"themap\" id=\"themap\">".$retour['map']."</map>";
}
return $retour;
}
//+----------------------------------------------------------------------------------------------------------------+
// sous fonction de calculer répartition
public function chercherVille($inventory, $tab_code_insee = array()) {
$location_protege = $this->getBdd()->proteger($inventory['location']);
$id_location_protege = '"'.$inventory['id_location'].'"';
$utm = array();
if ($inventory['collection_code'] == 'FLORE - VAR') {
if (isset($tab_code_insee[$location_protege])) {
$utm = array(0 => $tab_code_insee[$location_protege]);
}
} elseif ($inventory['collection_code'] == 'sophy') {
if (strpos($inventory['id_location'], '20') === 0) {
$a = str_replace('20', '2A', $inventory['id_location']);
if (isset($tab_code_insee[$a])) {
$utm = array(0 => $tab_code_insee[$a]);
} else {
$b = str_replace('20', '2B', $inventory['id_location']);
if (isset($tab_code_insee[$b])) {
$utm = array(0 => $tab_code_insee[$b]);
}
}
} elseif (isset($tab_code_insee[$inventory['id_location']])) {
$utm = array(0 => $tab_code_insee[$inventory['id_location']]);
} elseif (strpos($inventory['id_location'], '000') === 2) {
$code = $this->getBdd()->proteger(str_replace('000', '', $inventory['id_location']));
$requete = "SELECT chef_lieu ".
"FROM tb_eflore.insee_d_v2011 ".
"WHERE dep = $code ";
$resultat = $this->getBdd()->recupererTous($requete);
if ($resultat != array() && isset($tab_code_insee[$resultat[0]['chef_lieu']])) {
$utm = $tab_code_insee[$resultat[0]['chef_lieu']];
}
}
} else {
if ($inventory['id_location'] != 'null') {
if (isset($tab_code_insee[$id_location_protege])) {
$utm = array(0 => $tab_code_insee[$id_location_protege]);
} else {
$requete = "SELECT * ".
"FROM tb_cel.locations ".
"WHERE name LIKE $location_protege ".
" AND code = $id_location_protege ";
$resultat = $this->getBdd()->recupererTous($requete);
$utm = $resultat;
}
} else {
$requete = "SELECT * FROM tb_cel.locations WHERE name LIKE $location_protege ";
$utm = $this->getBdd()->recupererTous($requete);
}
}
return $utm;
}
 
public function formerCommentaire($utm, $inventory) {
$comment = '';
if ($inventory['date_observation'] != '0000-00-00 00:00:00') {
$comment .= $this->formerDate($inventory);
}
if ($inventory['collection_code'] == 'cel') {
list($identifiant) = explode("@", $inventory['identifiant']);
$comment .= " par ".$identifiant."@...";
} else {
$comment .= " par ".utf8_decode($inventory['identifiant']);
}
return $comment;
}
public function formerDate($inventory) {
if ($inventory['collection_code'] == 'sophy') {
$date = ', en '.$inventory['date_observation'];
} else {
list($year, $month, $day) = explode ('-',$inventory['date_observation']);
list($day) = explode (' ',$day);
if ($month == '00') {
$date = ', en '.$year;
} else {
$date = ', le '.$day.'/'.$month.'/'.$year;
}
}
return $date;
}
/*
* Stockage commentaire associe a un point :
*
* Param :
* @text : texte cumule
* @merge : indicateur de commentaire fusionne
* @name : commune associee
* @comment : commentaire
* @origine : origine de la donnee
*
*
* TODO : rendre cette fonction independante des valeurs d'origine passee en parametre
*/
public function stockerCommentaire($text, $merge, $name, $comment, $origine, $x, $y) {
if ($origine == 'cel') {
$prefix = 'CEL : ';
} elseif ($origine == 'flore') {
$prefix = 'CEN LR : ';
} /*elseif ($origine == 'FLORE - VAR') {
$prefix = 'CBN MED : ';
}*/ elseif ($origine == 'sophy') {
$prefix = 'SOPHY : ';
}
// Cumul toute origine :
if (isset($text[$x.'|'.$y]['tout']) && ($text[$x.'|'.$y])) {
$text[$x.'|'.$y]['tout'] = $text[$x.'|'.$y]['tout'].'<br>'.$prefix.$name.$comment;
} else {
// Nouveau commentaire
$text[$x.'|'.$y]['tout']=$prefix.$name.$comment;
}
// Deja present pour cette origine ? on ajoute
if (isset ($text[$x.'|'.$y][$origine]) && ($text[$x.'|'.$y][$origine])) {
$text[$x.'|'.$y][$origine] = $text[$x.'|'.$y][$origine].'<br>'.$name.$comment;
} else { // Nouveau commentaire
$text[$x.'|'.$y][$origine] = $name.$comment;
}
// Detection superposition de donnee
if ($origine == 'cel') {
if ((isset ($text[$x.'|'.$y]['sophy']) && ($text[$x.'|'.$y]['sophy'])) || (isset ($text[$x.'|'.$y]['flore']) && ($text[$x.'|'.$y]['flore']))
|| (isset ($text[$x.'|'.$y]['FLORE - VAR']) && ($text[$x.'|'.$y]['FLORE - VAR']))) {
$merge[$x.'|'.$y]=true;
}
} elseif ($origine == 'flore') {
if ((isset ($text[$x.'|'.$y]['sophy']) && ($text[$x.'|'.$y]['sophy'])) ||(isset ($text[$x.'|'.$y]['cel']) && ($text[$x.'|'.$y]['cel'])) ||
(isset ($text[$x.'|'.$y]['FLORE - VAR']) && ($text[$x.'|'.$y]['FLORE - VAR']))) {
$merge[$x.'|'.$y]=true;
}
} elseif ($origine == 'FLORE - VAR') {
if ((isset ($text[$x.'|'.$y]['sophy']) && ($text[$x.'|'.$y]['sophy'])) || (isset ($text[$x.'|'.$y]['cel']) && ($text[$x.'|'.$y]['cel'])) ||
(isset ($text[$x.'|'.$y]['flore']) && ($text[$x.'|'.$y]['flore']))) {
$merge[$x.'|'.$y]=true;
}
} elseif ($origine == 'sophy') {
if ((isset ($text[$x.'|'.$y]['cel']) && ($text[$x.'|'.$y]['cel'])) || (isset ($text[$x.'|'.$y]['flore']) && ($text[$x.'|'.$y]['flore'])||
(isset ($text[$x.'|'.$y]['FLORE - VAR']) && ($text[$x.'|'.$y]['FLORE - VAR'])))) {
$merge[$x.'|'.$y]=true;
}
}
return array($text, $merge);
}
}
?>
/trunk/services/modules/0.1/eflore/cartes/Formateur.php
New file
0,0 → 1,30
<?php
interface Formateur {
public function __construct($parametres, $info);
public function initialiserImage();
public function chargerDonnees();
public function dessinerPoint($text, $merge, $couleurs);
public function formaterCartes($usemap);
//+----------------------------------------------------------------------------------------------------------------+
// sous fonction de calculer répartition
public function chercherVille($inventory, $tab_code_insee = array());
public function formerCommentaire($utm, $inventory);
public function formerDate($inventory);
/*
* Stockage commentaire associe a un point :
*
* Param :
* @text : texte cumule
* @merge : indicateur de commentaire fusionne
* @name : commune associee
* @comment : commentaire
* @origine : origine de la donnee
*
*
* TODO : rendre cette fonction independante des valeurs d'origine passee en parametre
*/
public function stockerCommentaire($text, $merge, $name, $comment, $origine, $x, $y);
 
}
?>
/trunk/services/modules/0.1/eflore/cartes/SophyFormateur.php
New file
0,0 → 1,166
<?php
class SophyFormateur implements Formateur {
public $dest_map = array();
public $img = array();
public function __construct($parametres, $info) {
$this->param = $parametres;
$this->info = $info;
}
public function img() {
$qualite = 90;
imagejpeg($this->img['sophy'], Config::get('cache.stockageChemin').$this->dest_map['sophy'], $qualite);
}
//+----------------------------------------------------------------------------------------------------------------+
// Méthodes d'accès aux objets du Framework
/**
* Méthode de connection à la base de données sur demande.
* Tous les services web n'ont pas besoin de s'y connecter.
*/
protected function getBdd() {
if (! isset($this->Bdd)) {
$this->Bdd = new Bdd();
}
return $this->Bdd;
}
public function definirCouleurs() {
// purple
$couleur['purple'] = imagecolorallocate($this->img['sophy'], 255, 0, 255);
return $couleur;
}
public function initialiserImage() {
// Nom du fichier image en sortie
$this->cheminCartesBase = Config::get('Cartes.chemin');
$this->dest_map['sophy'] = 'sophy_nt'.$this->info['nt'].'_'.$this->info['src_map'];
$this->img['sophy'] = imagecreatefromjpeg($this->cheminCartesBase.$this->info['src_map']);
}
public function chargerDonnees() {
// Collection code = 'sophy'
$querySophy = "SELECT 'sophy' as collection_code, lieu_station_nom as location, lieu_commune_code_insee as id_location, ".
" observation_date as date_observation, lieu_station_utm_est as x_utm , ".
" lieu_station_utm_nord as y_utm , lieu_station_utm_zone as sector, observateur_nom_complet as identifiant ".
"FROM sophy_tapir ".
"WHERE nom_scientifique_complet = ".$this->getBdd()->proteger($this->info['nom_ss_auteur']).
" AND lieu_commune_code_insee != '' group by `nom_scientifique_complet`,`lieu_commune_code_insee`, `lieu_station_nom`";
$inventoriesSophy = $this->getBdd()->recupererTous($querySophy);
return $inventoriesSophy;
}
 
public function dessinerPoint($text, $merge, $couleurs) {
$usemap['sophy'] = '';
foreach ($text as $coord => $origines ) {
foreach ($origines as $origine => $maptext ) {
$maptext = preg_replace("/\"/", "\'", $maptext);
list($x,$y) = explode('|', $coord);
$tpl_area = '<area shape="%s" alt="" class="tooltip" coords="%s" title="%s"/>';
$rayon = 2;
$type = 'circle';
$coords = "$x,$y,5";
$on_mouseover = "this.ttBgColor='#99C242';this.ttFontColor='#000000';this.T_OFFSETX=-200;this.T_OFFSETY=-50;this.T_STICKY=1;return escape('$maptext')";
imagefilledrectangle($this->img['sophy'], ($x - $rayon), ($y - $rayon), ($x + $rayon), ($y + $rayon), $couleurs['purple']);
$coords = ($x - $rayon).','.($y - $rayon).','.($x + $rayon).','.($y + $rayon);
$usemap['sophy'] = $usemap['sophy'].sprintf($tpl_area, 'rect', $coords, $maptext);
}
}
return $usemap;
}
public function formaterCartes($usemap) {
$retour= "<img src=\"".(Config::get('Cartes.cel_dst').$this->dest_map['sophy'])."\" style=\"border:none; cursor:crosshair\" alt=\"\" usemap=\"#themapsophy\"></img><br />\n";
$retour.= "<map name=\"themapsophy\" id=\"themapsophy\">";
$retour.= $usemap['sophy'];
$retour.= "</map>";
return $retour;
}
 
//+----------------------------------------------------------------------------------------------------------------+
// sous fonction de calculer répartition
public function chercherVille($inventory, $tab_code_insee = array()) {
$utm = '';
if (strpos($inventory['id_location'], '20') === 0) {
$a = str_replace('20', '2A', $inventory['id_location']);
if (isset($tab_code_insee[$a])) {
$utm = array(0 => $tab_code_insee[$a]);
} else {
$b = str_replace('20', '2B', $inventory['id_location']);
if (isset($tab_code_insee[$b])) {
$utm = array(0 => $tab_code_insee[$b]);
}
}
} elseif (isset($tab_code_insee[$inventory['id_location']])) {
$utm = array(0 => $tab_code_insee[$inventory['id_location']]);
} elseif (strpos($inventory['id_location'], '000') === 2) {
$code = $this->getBdd()->proteger(str_replace('000', '', $inventory['id_location']));
$requete = "SELECT chef_lieu ".
"FROM tb_eflore.insee_d_v2011 ".
"WHERE dep = $code ";
$resultat = $this->getBdd()->recupererTous($requete);
if ($resultat != array() && isset($tab_code_insee[$resultat[0]['chef_lieu']])) {
$utm = $tab_code_insee[$resultat[0]['chef_lieu']];
}
}
return $utm;
}
 
public function formerCommentaire($utm, $inventory) {
$comment = '';
if ($inventory['date_observation'] != '0000-00-00 00:00:00') {
$comment .= $this->formerDate($inventory);
}
$comment .= " par ".utf8_decode($inventory['identifiant']);
return $comment;
}
public function formerDate($inventory) {
$date = ', en '.$inventory['date_observation'];
return $date;
}
/*
* Stockage commentaire associe a un point :
*
* Param :
* @text : texte cumule
* @merge : indicateur de commentaire fusionne
* @name : commune associee
* @comment : commentaire
* @origine : origine de la donnee
*
*
* TODO : rendre cette fonction independante des valeurs d'origine passee en parametre
*/
public function stockerCommentaire($text, $merge, $name, $comment, $origine, $x, $y) {
$prefix = 'SOPHY : ';
// Deja present pour cette origine ? on ajoute
if (isset ($text[$x.'|'.$y][$origine]) && ($text[$x.'|'.$y][$origine])) {
$text[$x.'|'.$y][$origine] = $text[$x.'|'.$y][$origine].'<br>'.$name.$comment;
} else { // Nouveau commentaire
$text[$x.'|'.$y][$origine] = $name.$comment;
}
if ((isset ($text[$x.'|'.$y]['cel']) && ($text[$x.'|'.$y]['cel'])) || (isset ($text[$x.'|'.$y]['flore']) && ($text[$x.'|'.$y]['flore'])||
(isset ($text[$x.'|'.$y]['FLORE - VAR']) && ($text[$x.'|'.$y]['FLORE - VAR'])))) {
$merge[$x.'|'.$y]=true;
}
return array($text, $merge);
}
 
 
}
?>
/trunk/services/modules/0.1/eflore/cartes/CelFormateur.php
New file
0,0 → 1,183
<?php
class CelFormateur implements Formateur {
public $dest_map = array();
public $img = array();
public function __construct($parametres, $info) {
$this->param = $parametres;
$this->info = $info;
}
public function img() {
$qualite = 90;
imagejpeg($this->img['cel'], Config::get('cache.stockageChemin').$this->dest_map['cel'], $qualite);
}
//+----------------------------------------------------------------------------------------------------------------+
// Méthodes d'accès aux objets du Framework
/**
* Méthode de connection à la base de données sur demande.
* Tous les services web n'ont pas besoin de s'y connecter.
*/
protected function getBdd() {
if (! isset($this->Bdd)) {
$this->Bdd = new Bdd();
}
return $this->Bdd;
}
public function definirCouleurs() {
// green
$couleurs['green'] = imagecolorallocate($this->img['cel'], 0, 255, 0);
return $couleurs;
}
public function initialiserImage() {
// Nom du fichier image en sortie
$this->cheminCartesBase = Config::get('Cartes.chemin');
$this->dest_map['cel'] = 'cel_nt'.$this->info['nt'].'_'.$this->info['src_map'];
$this->img['cel'] = imagecreatefromjpeg($this->cheminCartesBase.$this->info['src_map']);
}
public function chargerDonnees() {
// Recherche nom correspondant au numero nomenclatural en cours (pour etablir le lien avec les donnees moissonnes).
// R�cuperation donn�e inventaire
/*
* Les donnees issues du carnet en ligne sont recuperes directement, sans passer par le mecanisme de moissonage car :
* - pour l'instant le service de moissonage n'est pas automatise et donc il y a un decalage dans l'affichage des donnees transmises
* - la table contenant les donnees moissonees ne reprend pas tous les champs necessaires a l'exploitation par eflore (notamment pas de code localite, pas d'identifiant libre)
*
* A terme, utilser vraiment le moissonage, y compris pour les donnees issues du CEL, en utilisant ABCD et en modifiant le programme d'harvesting.
*/
$queryCel = "SELECT 'cel' as collection_code, location, id_location, date_observation, ".
" coord_y as y_utm, coord_x as x_utm, ref_geo as sector, identifiant FROM tb_cel.cel_inventory ".
"WHERE num_taxon = '".$this->info['nt']."' ".
" AND transmission = 1";
$inventoriesCel = $this->getBdd()->recupererTous($queryCel);
return $inventoriesCel;
}
 
public function dessinerPoint($text, $merge, $couleurs) {
$usemap['cel'] = '';
foreach ($text as $coord => $origines ) {
foreach ($origines as $origine => $maptext ) {
$maptext = preg_replace("/\"/", "\'", $maptext);
list($x,$y) = explode('|', $coord);
$tpl_area = '<area shape="%s" alt="" class="tooltip" coords="%s" title="%s"/>';
$rayon = 2;
$type = 'circle';
$coords = "$x,$y,5";
$on_mouseover = "this.ttBgColor='#99C242';this.ttFontColor='#000000';this.T_OFFSETX=-200;this.T_OFFSETY=-50;this.T_STICKY=1;return escape('$maptext')";
imagefilledrectangle($this->img['cel'], ($x - $rayon), ($y - $rayon), ($x + $rayon), ($y + $rayon), $couleurs['green']);
$coords = ($x - $rayon).','.($y - $rayon).','.($x + $rayon).','.($y + $rayon);
$usemap['cel'] = $usemap['cel'].sprintf($tpl_area, 'rect', $coords, $maptext);
}
}
return $usemap;
}
public function formaterCartes($usemap) {
$retour= "<img src=\"".(Config::get('Cartes.cel_dst').$this->dest_map['cel'])."\" style=\"border:none; cursor:crosshair\" alt=\"\" usemap=\"#themapcel\"></img><br />\n";
$retour.= "<map name=\"themapcel\" id=\"themapcel\">";
$retour.= $usemap['cel'];
$retour.= "</map>";
return $retour;
}
 
//+----------------------------------------------------------------------------------------------------------------+
// sous fonction de calculer répartition
public function chercherVille($inventory, $tab_code_insee = array()) {
$location_protege = $this->getBdd()->proteger($inventory['location']);
$id_location_protege = $this->getBdd()->proteger($inventory['id_location']);
$utm = array();
if ($inventory['id_location'] != 'null') {
if (isset($tab_code_insee) & in_array($inventory['id_location'], $tab_code_insee)) {
$utm = array(0 => $this->tab_code_insee[$id_location_protege]);
} else {
$requete = "SELECT * ".
"FROM tb_cel.locations ".
"WHERE name LIKE $location_protege ".
" AND code = $id_location_protege ";
$resultat = $this->getBdd()->recupererTous($requete);
$utm = $resultat;
}
} else {
$requete = "SELECT * FROM tb_cel.locations WHERE name LIKE $location_protege ";
$utm = $this->getBdd()->recupererTous($requete);
}
return $utm;
}
 
public function formerCommentaire($utm, $inventory) {
$comment = '';
if ($inventory['date_observation'] != '0000-00-00 00:00:00') {
$comment .= $this->formerDate($inventory);
}
list($identifiant) = explode("@", $inventory['identifiant']);
$comment .= " par ".$identifiant."@...";
return $comment;
}
public function formerDate($inventory) {
list($year, $month, $day) = explode ('-',$inventory['date_observation']);
list($day) = explode (' ',$day);
if ($month == '00') {
$date = ', en '.$year;
} else {
$date = ', le '.$day.'/'.$month.'/'.$year;
}
return $date;
}
/*
* Stockage commentaire associe a un point :
*
* Param :
* @text : texte cumule
* @merge : indicateur de commentaire fusionne
* @name : commune associee
* @comment : commentaire
* @origine : origine de la donnee
*
*
* TODO : rendre cette fonction independante des valeurs d'origine passee en parametre
*/
public function stockerCommentaire($text, $merge, $name, $comment, $origine, $x, $y) {
$prefix = 'CEL : ';
// Cumul toute origine :
if (isset($text[$x.'|'.$y]['tout']) && ($text[$x.'|'.$y])) {
$text[$x.'|'.$y]['tout'] = $text[$x.'|'.$y]['tout'].'<br>'.$prefix.$name.$comment;
} else {
// Nouveau commentaire
$text[$x.'|'.$y]['tout']=$prefix.$name.$comment;
}
// Deja present pour cette origine ? on ajoute
if (isset ($text[$x.'|'.$y][$origine]) && ($text[$x.'|'.$y][$origine])) {
$text[$x.'|'.$y][$origine] = $text[$x.'|'.$y][$origine].'<br>'.$name.$comment;
} else { // Nouveau commentaire
$text[$x.'|'.$y][$origine] = $name.$comment;
}
// Detection superposition de donnee
if ((isset ($text[$x.'|'.$y]['sophy']) && ($text[$x.'|'.$y]['sophy'])) || (isset ($text[$x.'|'.$y]['flore']) && ($text[$x.'|'.$y]['flore']))
|| (isset ($text[$x.'|'.$y]['FLORE - VAR']) && ($text[$x.'|'.$y]['FLORE - VAR']))) {
$merge[$x.'|'.$y]=true;
}
return array($text, $merge);
}
 
 
}
?>
/trunk/services/modules/0.1/eflore/cartes/CenlrFormateur.php
New file
0,0 → 1,142
<?php
class CenlrFormateur implements Formateur {
public $dest_map = array();
public $img = array();
public function __construct($parametres, $info) {
$this->param = $parametres;
$this->info = $info;
}
public function img() {
$qualite = 90;
imagejpeg($this->img['cenlr'], Config::get('cache.stockageChemin').$this->dest_map['cenlr'], $qualite);
}
//+----------------------------------------------------------------------------------------------------------------+
// Méthodes d'accès aux objets du Framework
/**
* Méthode de connection à la base de données sur demande.
* Tous les services web n'ont pas besoin de s'y connecter.
*/
protected function getBdd() {
if (! isset($this->Bdd)) {
$this->Bdd = new Bdd();
}
return $this->Bdd;
}
public function definirCouleurs() {
// green
$couleur['green'] = imagecolorallocate($this->img['cenlr'], 0, 255, 0);
// red
$couleur['red'] = imagecolorallocate($this->img['cenlr'], 255, 0, 0);
// blue
$couleur['blue'] = imagecolorallocate($this->img['cenlr'], 0, 0, 255);
// purple
$couleur['purple'] = imagecolorallocate($this->img['cenlr'], 255, 0, 255);
// black
$couleur['black'] = imagecolorallocate($this->img['cenlr'], 0, 0, 0);
return $couleur;
}
public function initialiserImage() {
// Nom du fichier image en sortie
$this->cheminCartesBase = Config::get('Cartes.chemin');
$this->dest_map['cenlr'] = 'cenlr_nt'.$this->info['nt'].'_'.$this->info['src_map'];
$this->img['cenlr'] = imagecreatefromjpeg($this->cheminCartesBase.$this->info['src_map']);
}
public function chargerDonnees() {
// Collection code = 'flore' (Cenlr)
$queryCenlr = "SELECT collection_code, locality as location, county as id_location, ".
" STR_TO_DATE(concat(year, '/',month, '/',day), '%Y/%m/%d') as date_observation, latitude as y_utm , ".
" longitude as x_utm , max_altitude as sector, collector_name as identifiant ".
"FROM tb_hit_indexation.raw_occurrence_record ".
"WHERE scientific_name = ".$this->getBdd()->proteger($this->info['nom']).
" AND collection_code = 'flore' ".
" AND (deleted IS NULL OR deleted = '0000-00-00 00:00:00')";
$inventoriesCenlr = $this->getBdd()->recupererTous($queryCenlr);
return $inventoriesCenlr;
}
 
public function dessinerPoint($text, $merge, $couleurs) {
$usemap['cenlr'] = '';
foreach ($text as $coord => $origines ) {
foreach ($origines as $origine => $maptext ) {
$maptext = preg_replace("/\"/", "\'", $maptext);
list($x,$y) = explode('|', $coord);
$tpl_area = '<area shape="%s" alt="" class="tooltip" coords="%s" title="%s"/>';
$rayon = 2;
$type = 'circle';
$coords = "$x,$y,5";
$on_mouseover = "this.ttBgColor='#99C242';this.ttFontColor='#000000';this.T_OFFSETX=-200;this.T_OFFSETY=-50;this.T_STICKY=1;return escape('$maptext')";
imagefilledellipse($this->img['cenlr'], $x, $y, 7, 7, $couleurs['red']);
$usemap['cenlr'] = $usemap['cenlr'].sprintf($tpl_area, $type, $coords, $maptext);
}
}
return $usemap;
}
public function formaterCartes($usemap) {
$retour = "<img src=\"".(Config::get('Cartes.cel_dst').$this->dest_map['cenlr'])."\" style=\"border:none; cursor:crosshair\" alt=\"\" usemap=\"#themapcenlr\"></img><br />\n";
$retour .= "<map name=\"themapcenlr\" id=\"themapcenlr\">";
$retour .= $usemap['cenlr'];
$retour .= "</map>";
 
return $retour;
}
//+----------------------------------------------------------------------------------------------------------------+
// sous fonction de calculer répartition
public function chercherVille($inventory, $tab_code_insee = array()) {
return $utm = '';
}
 
public function formerCommentaire($utm, $inventory) {
$comment = '';
if ($inventory['date_observation'] != '0000-00-00 00:00:00') {
$comment .= $this->formerDate($inventory);
}
$comment .= " par ".utf8_decode($inventory['identifiant']);
return $comment;
}
public function formerDate($inventory) {
list($year, $month, $day) = explode ('-',$inventory['date_observation']);
list($day) = explode (' ',$day);
if ($month == '00') {
$date = ', en '.$year;
} else {
$date = ', le '.$day.'/'.$month.'/'.$year;
}
return $date;
}
public function stockerCommentaire($text, $merge, $name, $comment, $origine, $x, $y) {
$prefix = 'CEN LR : ';
// Deja present pour cette origine ? on ajoute
if (isset ($text[$x.'|'.$y][$origine]) && ($text[$x.'|'.$y][$origine])) {
$text[$x.'|'.$y][$origine] = $text[$x.'|'.$y][$origine].'<br>'.$name.$comment;
} else { // Nouveau commentaire
$text[$x.'|'.$y][$origine] = $name.$comment;
}
// Detection superposition de donnee
if ((isset ($text[$x.'|'.$y]['sophy']) && ($text[$x.'|'.$y]['sophy'])) ||(isset ($text[$x.'|'.$y]['cel']) && ($text[$x.'|'.$y]['cel'])) ||
(isset ($text[$x.'|'.$y]['FLORE - VAR']) && ($text[$x.'|'.$y]['FLORE - VAR']))) {
$merge[$x.'|'.$y]=true;
}
return array($text, $merge);
}
 
 
}
?>
/trunk/services/modules/0.1/eflore/cartes/CbnmedFormateur.php
New file
0,0 → 1,159
<?php
class CbnmedFormateur implements Formateur {
public $dest_map = array();
public $img = array();
public function __construct($parametres, $info) {
$this->param = $parametres;
$this->info = $info;
}
public function img() {
$qualite = 90;
imagejpeg($this->img['cbnmed'], Config::get('cache.stockageChemin').$this->dest_map['cbnmed'], $qualite);
}
//+----------------------------------------------------------------------------------------------------------------+
// Méthodes d'accès aux objets du Framework
/**
* Méthode de connection à la base de données sur demande.
* Tous les services web n'ont pas besoin de s'y connecter.
*/
protected function getBdd() {
if (! isset($this->Bdd)) {
$this->Bdd = new Bdd();
}
return $this->Bdd;
}
public function definirCouleurs() {
// green
$couleur['green'] = imagecolorallocate($this->img['cbnmed'], 0, 255, 0);
// red
$couleur['red'] = imagecolorallocate($this->img['cbnmed'], 255, 0, 0);
// blue
$couleur['blue'] = imagecolorallocate($this->img['cbnmed'], 0, 0, 255);
// purple
$couleur['purple'] = imagecolorallocate($this->img['cbnmed'], 255, 0, 255);
// black
$couleur['black'] = imagecolorallocate($this->img['cbnmed'], 0, 0, 0);
return $couleur;
}
public function initialiserImage() {
// Nom du fichier image en sortie
$this->cheminCartesBase = Config::get('Cartes.chemin');
$this->dest_map['cbnmed'] = 'cbnmed_nt'.$this->info['nt'].'_'.$this->info['src_map'];
$this->img['cbnmed'] = imagecreatefromjpeg($this->cheminCartesBase.$this->info['src_map']);
}
public function chargerDonnees() {
// Recherche nom correspondant au numero nomenclatural en cours (pour etablir le lien avec les donnees moissonnes).
// Collection code = 'FLORE - VAR' (Cbnmed)
$queryCbnmed = "SELECT collection_code, locality as id_location, county as location, ".
" STR_TO_DATE(concat(ifnull(year,0),'/', ifnull(month,0), '/',ifnull(day,0)), '%Y/%m/%d') as date_observation, ".
" latitude as y_utm , longitude as x_utm , max_altitude as sector, collector_name as identifiant ".
"FROM tb_hit_indexation.raw_occurrence_record ".
"WHERE scientific_name = ".$this->getBdd()->proteger($this->info['nom']).
" AND collection_code='FLORE - VAR' ".
" AND (deleted IS NULL OR deleted = '0000-00-00 00:00:00')";
$inventoriesCbnmed = $this->getBdd()->recupererTous($queryCbnmed);
return $inventoriesCbnmed;
}
 
public function dessinerPoint($text, $merge, $couleurs) {
$usemap['cbnmed'] = '';
foreach ($text as $coord => $origines ) {
foreach ($origines as $origine => $maptext ) {
$maptext = preg_replace("/\"/", "\'", $maptext);
list($x,$y) = explode('|', $coord);
$tpl_area = '<area shape="%s" alt="" class="tooltip" coords="%s" title="%s"/>';
$rayon = 2;
$type = 'circle';
$coords = "$x,$y,5";
$on_mouseover = "this.ttBgColor='#99C242';this.ttFontColor='#000000';this.T_OFFSETX=-200;this.T_OFFSETY=-50;this.T_STICKY=1;return escape('$maptext')";
imagefilledellipse($this->img['cbnmed'], $x, $y, 7, 7, $couleurs['blue']);
$usemap['cbnmed'] = $usemap['cbnmed'].sprintf($tpl_area, $type, $coords, $maptext);
}
}
return $usemap;
}
public function formaterCartes($usemap) {
$retour= "<img src=\"".(Config::get('Cartes.cel_dst').$this->dest_map['cbnmed'])."\" style=\"border:none; cursor:crosshair\" alt=\"\" usemap=\"#themapcbnmed\"></img><br />\n";
$retour.= "<map name=\"themapcbnmed\" id=\"themapcbnmed\">";
$retour.= $usemap['cbnmed'];
$retour.= "</map>";
 
return $retour;
}
 
//+----------------------------------------------------------------------------------------------------------------+
// sous fonction de calculer répartition
public function chercherVille($inventory, $tab_code_insee = array()) {
$location_protege = $this->getBdd()->proteger($inventory['location']);
$id_location_protege = $this->getBdd()->proteger($inventory['id_location']);
$utm = '';
if (isset($tab_code_insee[$id_location_protege])) {
$utm = array(0 => $tab_code_insee[$id_location_protege]);
} else {
$requete = "SELECT * ".
"FROM tb_cel.locations ".
"WHERE insee_code = $id_location_protege ";
$utm = $this->getBdd()->recupererTous($requete);
}
return $utm;
}
 
public function formerCommentaire($utm, $inventory) {
$comment = '';
if ($inventory['date_observation'] != '0000-00-00 00:00:00') {
$comment .= $this->formerDate($inventory);
}
$comment .= " par ".utf8_decode($inventory['identifiant']);
return $comment;
}
public function formerDate($inventory) {
list($year, $month, $day) = explode ('-',$inventory['date_observation']);
list($day) = explode (' ',$day);
if ($month == '00') {
$date = ', en '.$year;
} else {
$date = ', le '.$day.'/'.$month.'/'.$year;
}
return $date;
}
public function stockerCommentaire($text, $merge, $name, $comment, $origine, $x, $y) {
$prefix = 'CBN MED : ';
// Deja present pour cette origine ? on ajoute
if (isset ($text[$x.'|'.$y][$origine]) && ($text[$x.'|'.$y][$origine])) {
$text[$x.'|'.$y][$origine] = $text[$x.'|'.$y][$origine].'<br>'.$name.$comment;
} else { // Nouveau commentaire
$text[$x.'|'.$y][$origine] = $name.$comment;
}
// Detection superposition de donnee
if ((isset ($text[$x.'|'.$y]['sophy']) && ($text[$x.'|'.$y]['sophy'])) || (isset ($text[$x.'|'.$y]['cel']) && ($text[$x.'|'.$y]['cel'])) ||
(isset ($text[$x.'|'.$y]['flore']) && ($text[$x.'|'.$y]['flore']))) {
$merge[$x.'|'.$y]=true;
}
return array($text, $merge);
}
 
 
}
?>
/trunk/services/modules/0.1/eflore/Cartes.php
53,534 → 53,195
 
class Cartes {
private $tab_code_insee = array();
private $src_map;
public $src_map;
private $cartesFormateur = null;
public function consulter($ressources, $param) {
// Initialisation des variables
$this->ressources = $ressources;
$this->param = $param;
$this->traiterParametres();
// Initialisation des variables
$tab_retour = array();
$this->creerFormateur();
$this->cartesFormateur->initialiserImage();
$inventories = $this->cartesFormateur->chargerDonnees();
$retour = '';
if (is_array($inventories) && $inventories !== array()){
// Connection referentiel communes
$this->chargerVille();
list($text, $merge) = $this->calculerRepartition($inventories);
// D�finition des couleurs des points
$couleurs = $this->cartesFormateur->definirCouleurs();
if ($text) {
$usemap = $this->cartesFormateur->dessinerPoint($text, $merge, $couleurs);
}
if (isset($usemap)) {
$this->cartesFormateur->img();
if ($this->info['miniature'] !== 'min') {
$retour = $this->cartesFormateur->formaterCartes($usemap);
} else { // miniature
$retour = $this->cartesFormateur->formaterCarteMiniature($retour, $usemap);
}
}
} else {
$retour = $this->formaterCarteVide();
}
if ($retour == '') {
$retour = $this->formaterCarteVide();
}
$tab_retour['contenu_page'] = $this->calculerRepartition($this->info);
print_r($this->calculerRepartition($this->info));
print_r($retour);
}
public function creerFormateur(){
$projet = ucwords($this->param['projet']);
$Classe = $projet.'Formateur';
$chemin = dirname(__FILE__).DS.'cartes'.DS;
$cheminClasse = $chemin.$Classe.'.php';
$cheminInterface = $chemin.'Formateur.php';
if (file_exists($cheminInterface)) {
include_once $cheminInterface;
if (file_exists($cheminClasse)) {
include_once $cheminClasse;
$this->cartesFormateur = new $Classe($this->param, $this->info);
} else {
$message = "La classe '$Classe' est introuvable.";Debug::printr($message);
throw new Exception($message);
}
}
}
private function traiterParametres() {
if ($this->param['retour.format'] == 'min') {
$this->src_map = 'france_utm_miniature.jpg';
$this->info['miniature'] = (isset($this->param['retour.format'])) ? $this->param['retour.format'] : false;
if ($this->info['miniature'] == 'min') {
$this->info['src_map'] = 'france_utm_miniature.jpg';
} else {
$this->src_map = 'france_utm_600x564.jpg';
$this->info['src_map'] = 'france_utm_600x564.jpg';
}
// +-----------------------------------------------------------------------------------------------------------+
// Ajout du code du r�f�rentiel
$this->info['referentiel'] = 'bdtfx';
// +-----------------------------------------------------------------------------------------------------------+
$projets = array('cenlr', 'cel', 'cbnmed', 'sophy');
if (isset($this->param['projet'])) {
if (!in_array($this->param['projet'], $projets)) {
$this->param['projet'] = 'general';
}
} else {
$this->param['projet'] = 'general';
}
// R�cup�ration d'infos g�n�rales
/*$this->info['nn'] = 141;
$this->info['nt'] = 8522;
$this->info['nom'] = 'Acer campestre L.';
$this->info['nom_ss_auteur'] = 'Acer campestre';*/
// donnees exemple nn = 141; nt = 8522; nom = 'Acer campestre L.'; nom_ss_auteur = 'Acer campestre';
$this->info['nn'] = $this->param['masque.nn'];
$this->info['nt'] = $this->param['masque.nt'];
$this->info['nom'] = $this->param['masque.ns'].' '.$this->param['masque.au'];
$this->info['nom_ss_auteur'] = $this->param['masque.ns'];
$this->info['miniature'] = $this->param['retour.format'];
}
private function calculerRepartition($param) {
private function chargerVille() {
$requete = "SELECT * FROM tb_cel.locations";
$villes = $this->getBdd()->recupererTous($requete);
foreach ($villes as $ville) {
$this->tab_code_insee[$ville['insee_code']] = $ville;
}
}
private function calculerRepartition($inventories) {
$text = '';
// Lecture commentaires embarqu�s dans la page
$jpg_txt = file_get_contents(Config::get('Cartes.chemin').str_replace('jpg', 'txt', $this->src_map));
// Recuperation du positionnement de la carte
$jpg_txt = file_get_contents(Config::get('Cartes.chemin').str_replace('jpg', 'txt', $this->info['src_map']));
parse_str($jpg_txt);
// Rappel : Pixel : O,0 en haut gauche
// "Resolution" calculer à partir du fichier $jpg_txt par fuseau
$p['31T'] = ($X231T - $X131T) / ($X231TUTM - $X131TUTM);
$p['32T'] = ($X231T - $X131T ) / ($X231TUTM - $X131TUTM);
$p['30T'] = ($X231T - $X131T ) / ($X231TUTM - $X131TUTM);
// X Coin inferieur gauche en Pixel
//$Px_echelle_X1['31T'] = 0;
$Px_echelle_X1['31T'] = $X131T;
// Y Coin inferieur gauche en Pixel
//$Px_echelle_Y1['31T'] = 539;
$Px_echelle_Y1['31T'] = $Y131T;
// Pour calcul Resolution
// X Coin inferieur droit en Pixel
//$Px_echelle_X2['31T'] = 805;
$Px_echelle_X2['31T'] = $X231T;
// Y Coin inferieur droit en Pixel
//$Px_echelle_Y2['31T'] = 539;
$Px_echelle_Y2['31T'] = $Y231T;
// X Coin inferieur gauche en UTM
//$M_UTM_X1['31T'] = 300092;
$M_UTM_X1['31T'] = $X131TUTM;
// Y Coin inferieur gauche en UTM
//$M_UTM_Y1['31T'] = 4536867;
$M_UTM_Y1['31T'] = $Y131TUTM;
// Pour calcul "resolution"
// X Coin inferieur droit en UTM
//$M_UTM_X2['31T'] = 105371; //
$M_UTM_X2['31T'] = $X231TUTM;
// Y Coin inferieur droit en UTM
//$M_UTM_Y2['31T'] = 5042332;
$M_UTM_Y2['31T'] = $Y231TUTM;
// "Resolution"
$p['31T'] = ($Px_echelle_X2['31T'] - $Px_echelle_X1['31T']) / ($M_UTM_X2['31T'] - $M_UTM_X1['31T']);
// Fuseau 32T :
// Pixel : O,0 en haut gauche
// X Coin inferieur gauche en Pixel
//$Px_echelle_X1['32T'] = 483;
$Px_echelle_X1['32T'] = $X132T;
// Y Coin inferieur gauche en Pixel
//$Px_echelle_Y1['32T'] = 536;
$Px_echelle_Y1['32T'] = $Y132T;
// X Coin inferieur droit en Pixel
//$Px_echelle_X2['32T'] = 805;
$Px_echelle_X2['32T'] = $X232T;
// Y Coin inferieur droit en Pixel
//$Px_echelle_Y2['32T'] = 536;
$Px_echelle_Y2['32T'] = $Y232T;
// X Coin inferieur gauche en UTM
//$M_UTM_X1['32T'] = 247615;
$M_UTM_X1['32T'] = $X132TUTM;
// Y Coin inferieur gauche en UTM
//$M_UTM_Y1['32T'] = 4540000;
$M_UTM_Y1['32T'] = $Y132TUTM;
//$angle3132;
// "Resolution"
$p['32T'] = ($Px_echelle_X2['31T'] - $Px_echelle_X1['31T'] ) / ($M_UTM_X2['31T'] - $M_UTM_X1['31T']);
// Fuseau 30T :
// X Coin inferieur gauche en Pixel
//$Px_echelle_X1['30T'] = 483;
$Px_echelle_X1['30T'] = $X130T;
// Y Coin inferieur gauche en Pixel
//$Px_echelle_Y1['30T'] = 536;
$Px_echelle_Y1['30T'] = $Y130T;
// X Coin inferieur droit en Pixel
//$Px_echelle_X2['30T'] = 805;
$Px_echelle_X2['30T'] = $X230T;
// Y Coin inferieur droit en Pixel
//$Px_echelle_Y2['30T'] = 536;
$Px_echelle_Y2['30T'] = $Y230T;
// X Coin inferieur gauche en UTM
//$M_UTM_X1['30T'] = 247615;
$M_UTM_X1['30T'] = $X130TUTM;
// Y Coin inferieur gauche en UTM
//$M_UTM_Y1['30T'] = 4540000;
$M_UTM_Y1['30T'] = $Y130TUTM;
// angle
//$a = 356.0; // (-4 degre)
// "Resolution"
$p['30T'] = ($Px_echelle_X2['31T'] - $Px_echelle_X1['31T'] ) / ($M_UTM_X2['31T'] - $M_UTM_X1['31T']);
// Nom du fichier image en sortie
$this->cheminCartesBase = Config::get('Cartes.chemin');
$dest_map = 'nt'.$this->info['nt'].'_'.$this->src_map;
$dest_map_cel = 'cel_nt'.$this->info['nt'].'_'.$this->src_map;
$dest_map_cenlr = 'cenlr_nt'.$this->info['nt'].'_'.$this->src_map;
$dest_map_cbnmed = 'cbnmed_nt'.$this->info['nt'].'_'.$this->src_map;
$dest_map_sophy = 'sophy_nt'.$this->info['nt'].'_'.$this->src_map;
$img = imagecreatefromjpeg($this->cheminCartesBase.$this->src_map);
$img_cel = imagecreatefromjpeg($this->cheminCartesBase.$this->src_map);
$img_cenlr = imagecreatefromjpeg($this->cheminCartesBase.$this->src_map);
$img_cbnmed = imagecreatefromjpeg($this->cheminCartesBase.$this->src_map);
$img_sophy = imagecreatefromjpeg($this->cheminCartesBase.$this->src_map);
$retour = '<a name="topmap"></a>';
/*
* Les donnees issues du carnet en ligne sont recuperes directement, sans passer par le mecanisme de moissonage car :
* - pour l'instant le service de moissonage n'est pas automatise et donc il y a un decalage dans l'affichage des donnees transmises
* - la table contenant les donnees moissonees ne reprend pas tous les champs necessaires a l'exploitation par eflore (notamment pas de code localite, pas d'identifiant libre)
*
* A terme, utilser vraiment le moissonage, y compris pour les donnees issues du CEL, en utilisant ABCD et en modifiant le programme d'harvesting.
*/
$inventories = $this->recupererDonnees();
if (is_array($inventories)){
// D�finition des couleurs des points
// green
$green = imagecolorallocate($img, 0, 255, 0);
// red
$red = imagecolorallocate($img, 255, 0, 0);
// blue
$blue = imagecolorallocate($img, 0, 0, 255);
// purple
$purple = imagecolorallocate($img, 255, 0, 255);
// black
$black = imagecolorallocate($img, 0, 0, 0);
$i = 0;
$text = array();
$merge = array();
// Connection referentiel communes
$this->chargerVille();
foreach ($inventories as $inventory){
// On ne tient pas compte des coordonn�es x, y , positionnement en fonction de la commune uniquement
$location_protege = $this->getBdd()->proteger($inventory['location']);
$id_location_protege = $this->getBdd()->proteger($inventory['id_location']);
if ($inventory['collection_code'] == 'FLORE - VAR') {
if (isset($this->tab_code_insee[$location_protege])) {
$utm = array(0 => $this->tab_code_insee[$location_protege]);
}
} elseif ($inventory['collection_code'] == 'sophy') {
if (isset($this->tab_code_insee[$id_location_protege])) {
$utm = array(0 => $this->tab_code_insee[$id_location_protege]);
}
} else {
if ($inventory['id_location'] != 'null') {
$requete = "SELECT * ".
"FROM tb_cel.locations ".
"WHERE name LIKE $location_protege ".
" AND code = $id_location_protege ";
$utm = $this->getBdd()->recupererTous($requete);
} else {
$requete = "SELECT * FROM tb_cel.locations WHERE name LIKE $location_protege ";
$utm = $this->getBdd()->recupererTous($requete);
}
}
// Ultime tentative
if (!$utm) {
$requete = "SELECT * FROM tb_cel.locations WHERE name LIKE $location_protege ";
$utm = $this->getBdd()->recupererTous($requete);
}
$text = array();
$merge = array();
foreach ($inventories as $inventory){
$utm = $this->cartesFormateur->chercherVille($inventory, $this->tab_code_insee);
// Ultime tentative
if (!$utm) {
$requete = "SELECT * FROM tb_cel.locations WHERE name LIKE ".$this->getBdd()->proteger($inventory['location']);
$utm = $this->getBdd()->recupererTous($requete);
}
 
// Si des doublons sur la commune : pas d'affichage , il vaut mieux ne rien afficher que d'afficher des erreurs.
if (sizeof($utm) == 1) {
// Si des doublons sur la commune : pas d'affichage , il vaut mieux ne rien afficher que d'afficher des erreurs.
if (sizeof($utm) == 1) {
$utm = $utm[0];
$utm = $utm[0];
// On centre le point au milieu de la maille 10x10 par defaut ...
$utm = $this->chercherCentreMaille($utm);
// On centre le point au milieu de la maille 10x10 par defaut ...
$pad = str_repeat ('0' ,(7 - strlen( $utm['x_utm'])));
$utm['x_utm'] = $pad.$utm['x_utm'];
$pad = str_repeat ('0' ,(7 - strlen( $utm['y_utm'])));
$utm['y_utm'] = $pad.$utm['y_utm'];
$utm['x_utm'] = substr($utm['x_utm'] ,0,3);
$utm['x_utm'] = $utm['x_utm'].'5000';
$utm['y_utm'] = substr($utm['y_utm'] ,0,3);
$utm['y_utm'] = $utm['y_utm'].'5000';
// Calcul coordonnes x, y sur l'image
if ($utm['sector']=='31T') {// Fuseau 31 T
$x = (($utm['x_utm'] - $X131TUTM) * $p['31T'] ) + $X131T;
$y = $Y231T - (($utm['y_utm'] - $Y131TUTM) * $p['31T'] );
} elseif ($utm['sector'] == '32T') {// Fuseau 32 T : une rotation + translation est appliqu�e
$cosa = cos(deg2rad($angle3132));
$sina = sin(deg2rad($angle3132));
$xp = (($utm['x_utm'] - $X132TUTM) * $cosa) + (($utm['y_utm']- $Y132TUTM) * $sina);
$yp = (-($utm['x_utm'] - $X132TUTM)* $sina) + (($utm['y_utm'] - $Y132TUTM) * $cosa);
$x = ($xp * $p['32T'] ) + $X132T;
$y = $Y232T-($yp * $p['32T'] );
} elseif ($utm['sector'] == '30T') {// Fuseau 30 T : une rotation + translation est appliqu�e
$cosa = cos(deg2rad($angle3031));
$sina = sin(deg2rad($angle3031));
$xp = (($utm['x_utm'] - $X130TUTM) * $cosa) + (($utm['y_utm'] - $Y130TUTM) * $sina);
$yp = (-($utm['x_utm'] - $X130TUTM) * $sina) + (($utm['y_utm'] - $Y130TUTM) * $cosa);
$x = ($xp * $p['30T'] ) + $X130T;
$y = $Y230T - ($yp * $p['30T'] );
}
$x = round($x);
$y = round($y);
// Calcul coordonnes x, y sur l'image
// Fuseau 31 T
if ($utm['sector']=='31T') {
$x = (($utm['x_utm'] - $M_UTM_X1['31T']) * $p['31T'] ) + $Px_echelle_X1['31T'];
$y = $Px_echelle_Y2['31T'] - (($utm['y_utm'] - $M_UTM_Y1['31T']) * $p['31T'] );
} elseif ($utm['sector'] == '32T') {// Fuseau 32 T : une rotation + translation est appliqu�e
$cosa = cos(deg2rad($angle3132));
$sina = sin(deg2rad($angle3132));
$xp = (($utm['x_utm'] - $M_UTM_X1['32T']) * $cosa) + (($utm['y_utm']- $M_UTM_Y1['32T']) * $sina);
$yp = (-($utm['x_utm'] - $M_UTM_X1['32T'])* $sina) + (($utm['y_utm'] - $M_UTM_Y1['32T']) * $cosa);
$x = ($xp * $p['32T'] ) + $Px_echelle_X1['32T'];
$y = $Px_echelle_Y2['32T']-($yp * $p['32T'] );
} elseif ($utm['sector'] == '30T') {// Fuseau 30 T : une rotation + translation est appliqu�e
$cosa = cos(deg2rad($angle3031));
$sina = sin(deg2rad($angle3031));
$xp = (($utm['x_utm'] - $M_UTM_X1['30T']) * $cosa) + (($utm['y_utm'] - $M_UTM_Y1['30T']) * $sina);
$yp = (-($utm['x_utm'] - $M_UTM_X1['30T']) * $sina) + (($utm['y_utm'] - $M_UTM_Y1['30T']) * $cosa);
$x = ($xp * $p['30T'] ) + $Px_echelle_X1['30T'];
$y = $Px_echelle_Y2['30T'] - ($yp * $p['30T'] );
}
$x = round($x);
$y = round($y);
$comment = '';
if ($utm['name'] != null) {
$name = utf8_decode($utm['name']);
}
if ($inventory['date_observation'] != '0000-00-00 00:00:00') {
if ($inventory['collection_code'] == 'sophy') {
$comment .= ', en '.$inventory['date_observation'];
} else {
list($year, $month, $day) = explode ('-',$inventory['date_observation']);
list($day) = explode (' ',$day);
if ($month == '00') {
$comment .= ', en '.$year;
} else {
$comment .= ', le '.$day.'/'.$month.'/'.$year;
}
}
}
if ($inventory['collection_code'] == 'cel') {
list($identifiant) = explode("@", $inventory['identifiant']);
$comment .= " par ".$identifiant."@...";
} else {
$comment .= " par ".utf8_decode($inventory['identifiant']);
}
// On stocke les commentaires pour affichage dans les tooltips
// Commentaire deja pr�sent ? : on ajoute � la suite
list($text, $merge) = $this->stockerCommentaire($text, $merge, $name, $comment, $inventory['collection_code'],$x,$y);
if ($utm['name'] != null) {
$name = utf8_decode($utm['name']);
}
$i++;
$comment = $this->cartesFormateur->formerCommentaire($utm, $inventory);
// On stocke les commentaires pour affichage dans les tooltips
// Commentaire deja pr�sent ? : on ajoute � la suite
list($text, $merge) = $this->cartesFormateur->stockerCommentaire($text, $merge, $name, $comment, $inventory['collection_code'],$x,$y);
}
//print_r($text);
}
$usemap = '';
$usemap_cel = '';
$usemap_cenlr = '';
$usemap_cbnmed = '';
$usemap_sophy = '';
if ($text) {
foreach ($text as $coord => $origines ) {
foreach ($origines as $origine => $maptext ) {
$maptext = preg_replace("/\"/", "\'", $maptext);
list($x,$y) = explode('|', $coord);
$tpl_area = '<area shape="%s" alt="" class="tooltip" coords="%s" title="%s"/>';
$rayon = 2;
$type = 'circle';
$coords = "$x,$y,5";
$on_mouseover = "this.ttBgColor='#99C242';this.ttFontColor='#000000';this.T_OFFSETX=-200;this.T_OFFSETY=-50;this.T_STICKY=1;return escape('$maptext')";
return array($text, $merge);
}
 
switch ($origine) {
case 'FLORE - VAR': // cbnmed
imagefilledellipse($img_cbnmed, $x, $y, 7, 7, $blue);
$usemap_cbnmed = $usemap_cbnmed.sprintf($tpl_area, $type, $coords, $maptext);
break;
case 'cel':
imagefilledrectangle($img_cel, ($x - $rayon), ($y - $rayon), ($x + $rayon), ($y + $rayon), $green);
$coords = ($x - $rayon).','.($y - $rayon).','.($x + $rayon).','.($y + $rayon);
$usemap_cel = $usemap_cel.sprintf($tpl_area, 'rect', $coords, $maptext);
break;
case 'flore': // cenlr
imagefilledellipse($img_cenlr, $x, $y, 7, 7, $red);
$usemap_cenlr = $usemap_cenlr.sprintf($tpl_area, $type, $coords, $maptext);
break;
case 'sophy':
imagefilledrectangle($img_sophy, ($x - $rayon), ($y - $rayon), ($x + $rayon), ($y + $rayon), $purple);
$coords = ($x - $rayon).','.($y - $rayon).','.($x + $rayon).','.($y + $rayon);
$usemap_sophy = $usemap_sophy.sprintf($tpl_area, 'rect', $coords, $maptext);
break;
case 'tout':
if (isset($merge[$coord]) && $merge[$coord]) {
imagefilledrectangle($img, ($x - $rayon), ($y - $rayon), ($x + $rayon), ($y + $rayon), $black);
} elseif (isset ($text[$coord]['cel']) && ($text[$coord]['cel'])) {
imagefilledrectangle($img, ($x - $rayon), ($y - $rayon), ($x + $rayon), ($y + $rayon), $green);
} elseif (isset ($text[$coord]['flore']) && ($text[$coord]['flore'])) {
imagefilledrectangle($img, ($x - $rayon), ($y - $rayon), ($x + $rayon), ($y + $rayon), $red);
} elseif (isset ($text[$coord]['FLORE - VAR']) && ($text[$coord]['FLORE - VAR'])) {
imagefilledrectangle($img, ($x - $rayon), ($y - $rayon), ($x + $rayon), ($y + $rayon), $blue);
} elseif (isset ($text[$coord]['sophy']) && ($text[$coord]['sophy'])) {
imagefilledrectangle($img, ($x - $rayon), ($y - $rayon), ($x + $rayon), ($y + $rayon), $purple);
}
$usemap = $usemap.sprintf($tpl_area, $type, $coords, $maptext);
break;
}
//imagestring($img, 1, $x, $y, 7, 7, "hello", $fill);
// pas de double quote dans le texte
}
}
}
//imageinterlace($img,1);
$qualite = 90;
imagejpeg($img, Config::get('cache.stockageChemin').$dest_map, $qualite);
imagejpeg($img_cel, Config::get('cache.stockageChemin').$dest_map_cel, $qualite);
imagejpeg($img_cenlr, Config::get('cache.stockageChemin').$dest_map_cenlr, $qualite);
imagejpeg($img_cbnmed, Config::get('cache.stockageChemin').$dest_map_cbnmed, $qualite);
imagejpeg($img_sophy, Config::get('cache.stockageChemin').$dest_map_sophy, $qualite);
//imagedestroy($img);
$retour = '';
if ($this->info['miniature'] !== 'min') {
$retour.="<div id=\"descriptions\">";
$retour.="<h2 id=\"titre_description_general\">Donn&eacute;es disponibles : </h2>";
$retour.= "<div id=\"description_defaut\" class=\"description\">";
$retour.= "<h3 style='display:none'><span class=\"affichage\">Toutes observations</span></h3>";
$retour.= "<div id =\"cartowikimap\" style=\"position:relative;\">";
$retour.= "<img src=\"".(Config::get('Cartes.cel_dst').$dest_map)."\" style=\"border:none; cursor:crosshair\" alt=\"\" usemap=\"#themap\" /><br />\n";
$retour.= "<map name=\"themap\" id=\"themap\">";
$retour.= $usemap;
$retour.= "</map>";
$retour.= "</map>";
$retour.= "</div>";
$retour.= "</div>";
$retour.= "<div id=\"description_1\" class=\"description\">";
$retour.= "<h3 style='display:none;background-color:rgb(0,255,0);color:black;'><span class=\"affichage\">Observations issues du Carnet en ligne</span></h3>";
$retour.= "<div id =\"cartowikimap\" style=\"position:relative;\">";
$retour.= "<img src=\"".(Config::get('Cartes.cel_dst').$dest_map_cel)."\" style=\"border:none; cursor:crosshair\" alt=\"\" usemap=\"#themapcel\"></img><br />\n";
$retour.= "<map name=\"themapcel\" id=\"themapcel\">";
$retour.= $usemap_cel;
$retour.= "</map>";
$retour.= "</div>";
$retour.= "</div>";
$retour.= "<div id=\"description_2\" class=\"description\">";
$retour.= "<h3 style='display:none;background-color:rgb(255,0,0);color:white;'><span class=\"affichage\">Prospection flore du CEN LR</span></h3>";
$retour.= "<div id =\"cartowikimapcenlr\" style=\"position:relative;\">";
$retour.= "<img src=\"".(Config::get('Cartes.cel_dst').$dest_map_cenlr)."\" style=\"border:none; cursor:crosshair\" alt=\"\" usemap=\"#themapcenlr\"></img><br />\n";
$retour.= "<map name=\"themapcenlr\" id=\"themapcenlr\">";
$retour.= $usemap_cenlr;
$retour.= "</map>";
$retour.= "</div>";
$retour.= "</div>";
$retour.= "<div id=\"description_3\" class=\"description\">";
$retour.= "<h3 style='display:none;background-color:rgb(0,0,255);color:white;'><span class=\"affichage\">Flore Silene</span></h3>";
$retour.= "<div id =\"cartowikimapcbnmed\" style=\"position:relative;\">";
$retour.= "<img src=\"".(Config::get('Cartes.cel_dst').$dest_map_cbnmed)."\" style=\"border:none; cursor:crosshair\" alt=\"\" usemap=\"#themapcbnmed\"></img><br />\n";
$retour.= "<map name=\"themapcbnmed\" id=\"themapcbnmed\">";
$retour.= $usemap_cbnmed;
$retour.= "</map>";
$retour.= "</div>";
$retour.= "</div>";
$retour.= "<div id=\"description_4\" class=\"description\">";
$retour.= "<h3 style='display:none;background-color:rgb(255,0,255);color:white;'><span class=\"affichage\">Observations issues de la base SOPHY</span></h3>";
$retour.= "<div id =\"cartowikimapsophy\" style=\"position:relative;\">";
$retour.= "<img src=\"".(Config::get('Cartes.cel_dst').$dest_map_sophy)."\" style=\"border:none; cursor:crosshair\" alt=\"\" usemap=\"#themapsophy\"></img><br />\n";
$retour.= "<map name=\"themapsophy\" id=\"themapsophy\">";
$retour.= $usemap_sophy;
$retour.= "</map>";
$retour.= "</div>";
$retour.= "</div>";
 
$retour.= "</div>";
} else { // miniature
$retour.= "<div id =\"cartowikimap\" style=\"position:relative;\">";
//$retour.= "<a href=".$param['url_onglet_cel'].">"; //lien vers grande image
$retour.= "<img src=\"".(Config::get('Cartes.cel_dst').$dest_map)."\" style=\"border:none; cursor:crosshair\" alt=\"\" usemap=\"#themap\"></img><br />\n";
//$retour.= "</a>";
$retour.= "<map name=\"themap\" id=\"themap\">";
$retour.= $usemap;
$retour.= "</map>";
$retour.= "</div>";
}
} else {
$retour.= "<map name=\"themap\" id=\"themap\">";
$retour.= "<img src=\"".Config.get('cartes.chemin').$this->src_map."\" style=\"border:none; cursor:crosshair\" alt=\"\" />\n";
$retour.= "</map>";
}
private function formaterCarteVide() {
$this->cheminCartesBase = Config::get('Cartes.chemin');
$dest_map['vide'] = 'vide_'.$this->info['src_map'];
$img['vide'] = imagecreatefromjpeg($this->cheminCartesBase.$this->info['src_map']);
imagejpeg($img['vide'], Config::get('cache.stockageChemin').$dest_map['vide'], 90);
$retour = "<img src=\"".Config::get('cel_dst').$dest_map['vide']."\" style=\"border:none; cursor:crosshair\" alt=\"\" />\n";
return $retour;
}
 
 
/*
* Stockage commentaire associe a un point :
*
* Param :
* @text : texte cumule
* @merge : indicateur de commentaire fusionne
* @name : commune associee
* @comment : commentaire
* @origine : origine de la donnee
*
*
* TODO : rendre cette fonction independante des valeurs d'origine passee en parametre
*/
private function stockerCommentaire($text, $merge, $name, $comment, $origine, $x, $y) {
if ($origine == 'cel') {
$prefix = 'CEL : ';
} elseif ($origine == 'flore') {
$prefix = 'CEN LR : ';
} elseif ($origine == 'FLORE - VAR') {
$prefix = 'CBN MED : ';
} elseif ($origine == 'sophy') {
$prefix = 'SOPHY : ';
}
// Cumul toute origine :
if (isset($text[$x.'|'.$y]['tout']) && ($text[$x.'|'.$y])) {
$text[$x.'|'.$y]['tout'] = $text[$x.'|'.$y]['tout'].'<br>'.$prefix.$name.$comment;
} else {
// Nouveau commentaire
$text[$x.'|'.$y]['tout']=$prefix.$name.$comment;
}
// Deja present pour cette origine ? on ajoute
if (isset ($text[$x.'|'.$y][$origine]) && ($text[$x.'|'.$y][$origine])) {
$text[$x.'|'.$y][$origine] = $text[$x.'|'.$y][$origine].'<br>'.$name.$comment;
} else { // Nouveau commentaire
$text[$x.'|'.$y][$origine] = $name.$comment;
}
// Detection superposition de donnee
if ($origine == 'cel') {
if ((isset ($text[$x.'|'.$y]['sophy']) && ($text[$x.'|'.$y]['sophy'])) || (isset ($text[$x.'|'.$y]['flore']) && ($text[$x.'|'.$y]['flore']))
|| (isset ($text[$x.'|'.$y]['FLORE - VAR']) && ($text[$x.'|'.$y]['FLORE - VAR']))) {
$merge[$x.'|'.$y]=true;
}
} elseif ($origine == 'flore') {
if ((isset ($text[$x.'|'.$y]['sophy']) && ($text[$x.'|'.$y]['sophy'])) ||(isset ($text[$x.'|'.$y]['cel']) && ($text[$x.'|'.$y]['cel'])) ||
(isset ($text[$x.'|'.$y]['FLORE - VAR']) && ($text[$x.'|'.$y]['FLORE - VAR']))) {
$merge[$x.'|'.$y]=true;
}
} elseif ($origine == 'FLORE - VAR') {
if ((isset ($text[$x.'|'.$y]['sophy']) && ($text[$x.'|'.$y]['sophy'])) || (isset ($text[$x.'|'.$y]['cel']) && ($text[$x.'|'.$y]['cel'])) ||
(isset ($text[$x.'|'.$y]['flore']) && ($text[$x.'|'.$y]['flore']))) {
$merge[$x.'|'.$y]=true;
}
} elseif ($origine == 'sophy') {
if ((isset ($text[$x.'|'.$y]['cel']) && ($text[$x.'|'.$y]['cel'])) || (isset ($text[$x.'|'.$y]['flore']) && ($text[$x.'|'.$y]['flore'])||
(isset ($text[$x.'|'.$y]['FLORE - VAR']) && ($text[$x.'|'.$y]['FLORE - VAR'])))) {
$merge[$x.'|'.$y]=true;
}
}
return array($text, $merge);
//+----------------------------------------------------------------------------------------------------------------+
// sous fonction de calculer répartition
private function chercherCentreMaille($utm) {
$pad = str_repeat ('0' ,(7 - strlen( $utm['x_utm'])));
$utm['x_utm'] = $pad.$utm['x_utm'];
$pad = str_repeat ('0' ,(7 - strlen( $utm['y_utm'])));
$utm['y_utm'] = $pad.$utm['y_utm'];
$utm['x_utm'] = substr($utm['x_utm'] ,0,3);
$utm['x_utm'] = $utm['x_utm'].'5000';
$utm['y_utm'] = substr($utm['y_utm'] ,0,3);
$utm['y_utm'] = $utm['y_utm'].'5000';
return $utm;
}
 
//+------------------------------------------------------------------------------------------------------+
//+----------------------------------------------------------------------------------------------------------------+
// Méthodes d'accès aux objets du Framework
/**
* Méthode de connection à la base de données sur demande.
587,62 → 248,13
* Tous les services web n'ont pas besoin de s'y connecter.
*/
protected function getBdd() {
if (! isset($this->Bdd)) {
$this->Bdd = new Bdd();
}
if (! isset($this->Bdd)) {
$this->Bdd = new Bdd();
}
return $this->Bdd;
}
private function chargerVille() {
$requete = "SELECT * FROM tb_cel.locations";
$villes = $this->getBdd()->recupererTous($requete);
foreach ($villes as $ville) {
$this->tab_code_insee[$ville['insee_code']] = $ville;
}
}
public function recupererDonnees() {
// Recherche nom correspondant au numero nomenclatural en cours (pour etablir le lien avec les donnees moissonnes).
 
// R�cuperation donn�e inventaire
$queryCel = "SELECT 'cel' as collection_code, location, id_location, date_observation, ".
" coord_y as y_utm, coord_x as x_utm, ref_geo as sector, identifiant FROM tb_cel.cel_inventory ".
"WHERE num_taxon = '".$this->info['nt']."' ".
" AND transmission = 1";
$inventoriesCel = $this->getBdd()->recupererTous($queryCel);
// Recuperation des donnees de moissonage
// Collection code = 'flore' (Cenlr)
$queryCenlr = "SELECT collection_code, locality as location, county as id_location, ".
" STR_TO_DATE(concat(year, '/',month, '/',day), '%Y/%m/%d') as date_observation, latitude as y_utm , ".
" longitude as x_utm , max_altitude as sector, collector_name as identifiant ".
"FROM tb_hit_indexation.raw_occurrence_record ".
"WHERE scientific_name = ".$this->getBdd()->proteger($this->info['nom']).
" AND collection_code = 'flore' ".
" AND deleted IS NULL";
$inventoriesCenlr = $this->getBdd()->recupererTous($queryCenlr);
// Collection code = 'FLORE - VAR' (Cbnmed)
$queryCbnmed = "SELECT collection_code, locality as location, county as id_location, ".
" STR_TO_DATE(concat(ifnull(year,0),'/', ifnull(month,0), '/',ifnull(day,0)), '%Y/%m/%d') as date_observation, ".
" latitude as y_utm , longitude as x_utm , max_altitude as sector, collector_name as identifiant ".
"FROM tb_hit_indexation.raw_occurrence_record ".
"WHERE scientific_name = ".$this->getBdd()->proteger($this->info['nom']).
" AND collection_code='FLORE - VAR' ".
" AND (deleted IS NULL OR deleted = '0000-00-00 00:00:00')";
$inventoriesCbnmed = $this->getBdd()->recupererTous($queryCbnmed);
// Collection code = 'sophy'
$querySophy = "SELECT 'sophy' as collection_code, lieu_station_nom as location, lieu_commune_code_insee as id_location, ".
" observation_date as date_observation, lieu_station_utm_est as x_utm , ".
" lieu_station_utm_nord as y_utm , lieu_station_utm_zone as sector, observateur_nom_complet as identifiant ".
"FROM sophy_tapir ".
"WHERE nom_scientifique_complet = ".$this->getBdd()->proteger($this->info['nom_ss_auteur']);
$inventoriesSophy = $this->getBdd()->recupererTous($querySophy);
return array_merge($inventoriesCel, $inventoriesCenlr, $inventoriesCbnmed, $inventoriesSophy);
}
}
?>