| Line 3... |
Line 3... |
| 3 |
* Le web service plantnet récupère toutes les infos de la vue del_plantnet.
|
3 |
* Le web service plantnet récupère toutes les infos de la vue del_plantnet.
|
| 4 |
* Ordonées par date de modification.
|
4 |
* Ordonées par date de modification.
|
| 5 |
* Les images sont regroupées en observations.
|
5 |
* Les images sont regroupées en observations.
|
| 6 |
* Les tags, les votes et les propositions de determinations sont intégrés à l'observation.
|
6 |
* Les tags, les votes et les propositions de determinations sont intégrés à l'observation.
|
| 7 |
*
|
7 |
*
|
| - |
|
8 |
* Paramètres: date.debut et date.fin (unixtime en secondes), navigation.limite (10 par défaut), navigation.depart, ordre (DESC par défaut)
|
| - |
|
9 |
* Ne pas Oublier l'api key dans le header $_SERVER['HTTP_API_KEY']
|
| - |
|
10 |
*
|
| 8 |
* @category DEL
|
11 |
* @category DEL
|
| 9 |
* @package Services
|
12 |
* @package Services
|
| 10 |
* @subpackage Plantnet
|
13 |
* @subpackage Plantnet
|
| 11 |
* @version 0.1
|
14 |
* @version 0.1
|
| 12 |
* @author Mathias CHOUET <mathias@tela-botanica.org>
|
15 |
* @author Mathias CHOUET <mathias@tela-botanica.org>
|
| Line 24... |
Line 27... |
| 24 |
private $navigation;
|
27 |
private $navigation;
|
| 25 |
private $bdd;
|
28 |
private $bdd;
|
| Line 26... |
Line 29... |
| 26 |
|
29 |
|
| 27 |
private $parametres = array();
|
30 |
private $parametres = array();
|
| 28 |
private $ressources = array();
|
31 |
private $ressources = array();
|
| 29 |
private $ordre_defaut = 'asc';
|
32 |
private $ordre_defaut = 'DESC';
|
| 30 |
private $idsObsImg = array();
|
33 |
private $idsObsImg = array();
|
| Line 31... |
Line 34... |
| 31 |
private $infosObsImg = array();
|
34 |
private $infosObsImg = array();
|
| Line 52... |
Line 55... |
| 52 |
// initialiserRessourcesEtParametres()
|
55 |
// initialiserRessourcesEtParametres()
|
| 53 |
$this->ressources = $ressources;
|
56 |
$this->ressources = $ressources;
|
| 54 |
$this->parametres = $parametres;
|
57 |
$this->parametres = $parametres;
|
| Line 55... |
Line 58... |
| 55 |
|
58 |
|
| 56 |
if (!isset($parametres['date.debut'])) {
|
59 |
if (!isset($parametres['date.debut'])) {
|
| 57 |
$this->parametres['date.debut'] = '1900-01-01';
|
60 |
$this->parametres['date.debut'] = '0';
|
| Line 58... |
Line 61... |
| 58 |
}
|
61 |
}
|
| 59 |
|
62 |
|
| 60 |
if (!isset($parametres['date.fin'])) {
|
63 |
if (!isset($parametres['date.fin'])) {
|
| Line 61... |
Line 64... |
| 61 |
$this->parametres['date.fin'] = date('Y-m-d');
|
64 |
$this->parametres['date.fin'] = time();
|
| 62 |
}
|
65 |
}
|
| 63 |
|
66 |
|
| Line 93... |
Line 96... |
| 93 |
/*-------------------------------------------------------------------------------
|
96 |
/*-------------------------------------------------------------------------------
|
| 94 |
CHARGEMENT DES IMAGES
|
97 |
CHARGEMENT DES IMAGES
|
| 95 |
--------------------------------------------------------------------------------*/
|
98 |
--------------------------------------------------------------------------------*/
|
| Line 96... |
Line 99... |
| 96 |
|
99 |
|
| 97 |
private function getIdsObsImg() {
|
100 |
private function getIdsObsImg() {
|
| 98 |
$date_debut = "'{$this->parametres['date.debut']}'";
|
101 |
$date_debut = date('Y-m-d H:i:s', $this->parametres['date.debut']);
|
| 99 |
$date_fin = "'{$this->parametres['date.fin']}'";
|
102 |
$date_fin = date('Y-m-d H:i:s', $this->parametres['date.fin']);
|
| 100 |
$limite = @min(intval($this->parametres['navigation.limite']), 1000);
|
103 |
$limite = @min(intval($this->parametres['navigation.limite']), 1000);
|
| 101 |
$limite = $limite ? $limite : 100; // 0 => 10
|
104 |
$limite = $limite ?: 100; // 0 => 10
|
| 102 |
$depart = intval(@$this->parametres['navigation.depart']);
|
105 |
$depart = intval(@$this->parametres['navigation.depart']);
|
| Line -... |
Line 106... |
| - |
|
106 |
$ordre = $this->parametres['ordre'];
|
| - |
|
107 |
|
| - |
|
108 |
$date_debut = "'{$date_debut}'";
|
| 103 |
$ordre = $this->parametres['ordre'];
|
109 |
$date_fin = "'{$date_fin}'";
|
| 104 |
|
110 |
|
| 105 |
$requete =
|
111 |
$requete =
|
| 106 |
'SELECT SQL_CALC_FOUND_ROWS p.id_observation, p.id_image, '.
|
112 |
'SELECT SQL_CALC_FOUND_ROWS p.id_observation, p.id_image, '.
|
| 107 |
'GROUP_CONCAT(iv.valeur) AS votes, '.
|
113 |
'GROUP_CONCAT(iv.valeur) AS votes, '.
|
| 108 |
'GROUP_CONCAT(DISTINCT tag) AS tags, '.
|
- |
|
| 109 |
'modif_date '.
|
114 |
'GROUP_CONCAT(DISTINCT it.tag) AS del_image_tags, '.
|
| 110 |
|
115 |
'modif_date '.
|
| 111 |
'FROM del_plantnet AS p '.
|
116 |
'FROM del_plantnet AS p '.
|
| 112 |
' JOIN del_observation_modif_date '.
|
117 |
' JOIN del_observation_modif_date '.
|
| 113 |
' ON (p.id_observation = del_observation_modif_date.id_observation '.
|
118 |
' ON (p.id_observation = del_observation_modif_date.id_observation '.
|
| 114 |
' AND modif_date >= '.date('U', strtotime($date_debut)).') '.
|
119 |
' AND modif_date >= '.$date_debut.' '.
|
| 115 |
' AND modif_date <= '.date('U', strtotime($date_fin)).') '.
|
120 |
' AND modif_date <= '.$date_fin.') '.
|
| 116 |
' LEFT JOIN del_image_vote AS iv '.
|
121 |
' LEFT JOIN del_image_vote AS iv '.
|
| 117 |
' ON (id_image = iv.ce_image AND iv.ce_protocole = 3) '.
|
122 |
' ON (id_image = iv.ce_image AND iv.ce_protocole = 3) '.
|
| 118 |
' LEFT JOIN del_image_tag AS it '.
|
123 |
' LEFT JOIN del_image_tag AS it '.
|
| Line 125... |
Line 130... |
| 125 |
'ORDER BY modif_date ' . $ordre . ' '.
|
130 |
'ORDER BY modif_date ' . $ordre . ' '.
|
| 126 |
'LIMIT '.$depart.', '.$limite.
|
131 |
'LIMIT '.$depart.', '.$limite.
|
| 127 |
' -- '.__FILE__.':'.__LINE__;
|
132 |
' -- '.__FILE__.':'.__LINE__;
|
| Line 128... |
Line 133... |
| 128 |
|
133 |
|
| - |
|
134 |
return $this->bdd->recupererTous($requete);
|
| 129 |
return $this->bdd->recupererTous($requete);
|
135 |
// On récupère id_obs, id_image, votes, tags, modif_date
|
| Line 130... |
Line 136... |
| 130 |
}
|
136 |
}
|
| 131 |
|
137 |
|
| 132 |
private function getTotal() {
|
138 |
private function getTotal() {
|
| Line 144... |
Line 150... |
| 144 |
$idsImg[] = $id;
|
150 |
$idsImg[] = $id;
|
| 145 |
}
|
151 |
}
|
| 146 |
$idsImgConcat = implode(',', $idsImg);
|
152 |
$idsImgConcat = implode(',', $idsImg);
|
| Line 147... |
Line 153... |
| 147 |
|
153 |
|
| 148 |
$requete = 'SELECT '.
|
154 |
$requete = 'SELECT '.
|
| 149 |
'p.id_observation, p.id_image, '.
|
155 |
'p.id_observation, p.plantnet_id, p.id_image, '.
|
| 150 |
'cp.id_plantnet, ' .
|
156 |
'cp.plant_net_occurrence_id, ' .
|
| 151 |
'p.nom_sel, '.
|
157 |
'p.nom_sel, p.nom_sel_nn, p.nom_ret, p.nom_ret_nn,'.
|
| 152 |
'p.nom_referentiel, p.nom_ret, p.famille, '.
|
158 |
'p.nom_referentiel, p.famille, '.
|
| 153 |
'p.zone_geo, p.latitude, p.longitude, '.
|
159 |
'p.zone_geo, p.altitude,'.
|
| 154 |
'p.date_observation, p.date_creation, p.date_transmission, '.
|
160 |
'p.date_observation, p.date_created, p.date_published, '.
|
| 155 |
'p.mots_cles_texte, '.
|
161 |
'p.is_wild, p.identiplante_score, p.is_identiplante_validated, p.cel_photo_tag, '.
|
| 156 |
'p.ce_utilisateur, p.prenom_utilisateur, p.nom_utilisateur, p.courriel_utilisateur, '.
|
162 |
'p.ce_utilisateur, p.courriel_utilisateur, '.
|
| 157 |
'p.i_mots_cles_texte AS mots_cles_texte_image, p.nom_original AS nom_image '.
|
163 |
'p.original_name AS nom_image, p.i_date_updated AS image_updated '.
|
| 158 |
'FROM del_plantnet AS p '.
|
164 |
'FROM del_plantnet AS p '.
|
| 159 |
'LEFT JOIN tb_cel.cel_plantnet AS cp ON p.id_observation = cp.id_observation '.
|
165 |
'LEFT JOIN tb_new_cel.pn_tb_pair AS cp ON p.id_observation = cp.occurrence_id '.
|
| 160 |
"WHERE id_image IN ($idsImgConcat) ".
|
166 |
"WHERE id_image IN ($idsImgConcat) ".
|
| 161 |
' -- '.__FILE__.':'.__LINE__;
|
167 |
' -- '.__FILE__.':'.__LINE__;
|
| 162 |
// recuperer les donnees
|
168 |
// recuperer les donnees
|
| Line 188... |
Line 194... |
| 188 |
if (!isset($obs[$idobs])) {
|
194 |
if (!isset($obs[$idobs])) {
|
| 189 |
$obs[$idobs] = array();
|
195 |
$obs[$idobs] = array();
|
| 190 |
}
|
196 |
}
|
| Line 191... |
Line 197... |
| 191 |
|
197 |
|
| 192 |
$obs[$idobs]['id_observation'] = $idobs;
|
198 |
$obs[$idobs]['id_observation'] = $idobs;
|
| 193 |
$obs[$idobs]['id_plantnet'] = $imgdata['id_plantnet'];
|
- |
|
| 194 |
$obs[$idobs]['auteur_id'] = $imgdata['ce_utilisateur'];
|
- |
|
| 195 |
$obs[$idobs]['auteur_prenom'] = $imgdata['prenom_utilisateur'];
|
- |
|
| 196 |
$obs[$idobs]['auteur_nom'] = $imgdata['nom_utilisateur'];
|
199 |
$obs[$idobs]['plantnet_id'] = $imgdata['plantnet_id'];
|
| Line 197... |
Line 200... |
| 197 |
$obs[$idobs]['auteur_courriel'] = $imgdata['courriel_utilisateur'];
|
200 |
$obs[$idobs]['auteur_courriel'] = $imgdata['courriel_utilisateur'];
|
| Line 198... |
Line 201... |
| 198 |
|
201 |
|
| - |
|
202 |
$obs[$idobs]['mots_cles_obs_cel'] = $imgdata['cel_photo_tag'];
|
| - |
|
203 |
|
| 199 |
$obs[$idobs]['mots_cles_obs_cel'] = $this->formaterMotsClesCel($imgdata['mots_cles_texte']);
|
204 |
$obs[$idobs]['date_observation'] = $imgdata['date_observation'];
|
| 200 |
|
205 |
$obs[$idobs]['date_creation'] = $imgdata['date_created'];
|
| 201 |
$obs[$idobs]['date_observation'] = $imgdata['date_observation'];
|
206 |
$obs[$idobs]['date_changement'] = $ids['modif_date'];
|
| - |
|
207 |
$obs[$idobs]['date_publication'] = $imgdata['date_published'];
|
| Line 202... |
Line 208... |
| 202 |
$obs[$idobs]['date_publication'] = $imgdata['date_transmission'];
|
208 |
$obs[$idobs]['is_wild'] = $imgdata['is_wild'];
|
| - |
|
209 |
$obs[$idobs]['identiplante_score'] = $imgdata['identiplante_score'];
|
| 203 |
$obs[$idobs]['date_creation'] = $imgdata['date_creation'];
|
210 |
$obs[$idobs]['is_identiplante_validated'] = $imgdata['is_identiplante_validated'];
|
| 204 |
$obs[$idobs]['date_changement'] = $ids['modif_date'];
|
211 |
|
| 205 |
|
212 |
$obs[$idobs]['nom_sel'] = $imgdata['nom_sel'];
|
| 206 |
$obs[$idobs]['nom_sel'] = $imgdata['nom_sel'];
|
- |
|
| 207 |
$obs[$idobs]['nom_referentiel'] = $imgdata['nom_referentiel'];
|
213 |
$obs[$idobs]['nom_sel_nn'] = $imgdata['nom_sel_nn'];
|
| Line 208... |
Line 214... |
| 208 |
$obs[$idobs]['nom_ret'] = $imgdata['nom_ret'];
|
214 |
$obs[$idobs]['nom_referentiel'] = $imgdata['nom_referentiel'];
|
| 209 |
//$obs[$idobs]['nn'] = $imgdata['nom_ret_nn'];
|
215 |
$obs[$idobs]['nom_ret'] = $imgdata['nom_ret'];
|
| 210 |
//$obs[$idobs]['nt'] = $imgdata['nt'];
|
- |
|
| Line 211... |
Line 216... |
| 211 |
$obs[$idobs]['famille'] = $imgdata['famille'];
|
216 |
$obs[$idobs]['nom_ret_nn'] = $imgdata['nom_ret_nn'];
|
| 212 |
|
217 |
$obs[$idobs]['famille'] = $imgdata['famille'];
|
| 213 |
$obs[$idobs]['zone_geo'] = $imgdata['zone_geo'];
|
218 |
|
| Line 214... |
Line 219... |
| 214 |
$obs[$idobs]['latitude'] = floatval($imgdata['latitude']);
|
219 |
$obs[$idobs]['zone_geo'] = $imgdata['zone_geo'];
|
| 215 |
$obs[$idobs]['longitude'] = floatval($imgdata['longitude']);
|
220 |
$obs[$idobs]['altitude'] = $imgdata['altitude'];
|
| 216 |
|
221 |
|
| - |
|
222 |
if (!isset($obs[$idobs]['images'])) {
|
| 217 |
if (!isset($obs[$idobs]['images'])) {
|
223 |
$obs[$idobs]['images'] = array();
|
| 218 |
$obs[$idobs]['images'] = array();
|
224 |
}
|
| 219 |
}
|
225 |
|
| 220 |
|
226 |
$img_obj = array(
|
| 221 |
$img_obj = array(
|
227 |
'id_image' => $idimg,
|
| 222 |
'id_image' => $idimg,
|
228 |
'nom_image' => $imgdata['nom_image'],
|
| 223 |
'nom_image' => $imgdata['nom_image'],
|
229 |
'image_updated' => $imgdata['image_updated'],
|
| 224 |
'url' => sprintf($imgCelTpl, $idimg, 'O'),
|
230 |
'url' => sprintf($imgCelTpl, $idimg, 'O'),
|
| 225 |
'votes' => array_map('intval', explode(',', $ids['votes'])),
|
231 |
'votes' => array_map('intval', explode(',', $ids['votes'])),
|