| Line 72... |
Line 72... |
| 72 |
(isset($num_taxon) ? " AND num_taxon = '$num_taxon' " : '' ).
|
72 |
(isset($num_taxon) ? " AND num_taxon = '$num_taxon' " : '' ).
|
| 73 |
(isset($projet) ? ' AND ('.$this->getSqlWhereProjet($projet).') ' : '' );
|
73 |
(isset($projet) ? ' AND ('.$this->getSqlWhereProjet($projet).') ' : '' );
|
| 74 |
$resultats = $this->executerRequete($requete);
|
74 |
$resultats = $this->executerRequete($requete);
|
| Line 75... |
Line 75... |
| 75 |
|
75 |
|
| 76 |
// Traitement des résultats
|
76 |
// Traitement des résultats
|
| 77 |
$mm = array('min_x' => 0,'max_x' => 0,'min_y' => 0,'max_y' => 0);
|
77 |
$mm = null;
|
| 78 |
$points = array();
|
78 |
$points = array();
|
| - |
|
79 |
foreach ($resultats as $enrg) {
|
| 79 |
foreach ($resultats as $enrg) {
|
80 |
if ($enrg['x_utm'] != null && $enrg['y_utm'] != null) {
|
| 80 |
$convertisseur = new gPoint();
|
81 |
$convertisseur = new gPoint();
|
| 81 |
$convertisseur->setUTM($enrg['x_utm'], $enrg['y_utm'], $enrg['sector']);
|
82 |
$convertisseur->setUTM($enrg['x_utm'], $enrg['y_utm'], $enrg['sector']);
|
| 82 |
$convertisseur->convertTMtoLL();
|
83 |
$convertisseur->convertTMtoLL();
|
| 83 |
$enrg['coord_x'] = $convertisseur->Lat();
|
84 |
$enrg['coord_x'] = $convertisseur->Lat();
|
| 84 |
$enrg['coord_y'] = $convertisseur->Long();
|
85 |
$enrg['coord_y'] = $convertisseur->Long();
|
| 85 |
$enrg['id'] = 'UTM:'.$enrg['x_utm'].'-'.$enrg['y_utm'].'-'.$enrg['sector'];
|
86 |
$enrg['id'] = 'UTM:'.$enrg['x_utm'].'-'.$enrg['y_utm'].'-'.$enrg['sector'];
|
| 86 |
|
87 |
|
| 87 |
$id = $enrg['coord_x'].'-'.$enrg['coord_y'];
|
88 |
$id = $enrg['coord_x'].'-'.$enrg['coord_y'];
|
| 88 |
if (!isset($points[$id])) {
|
89 |
if (!isset($points[$id])) {
|
| 89 |
$points[$id] = $enrg;
|
90 |
$points[$id] = $enrg;
|
| 90 |
$points[$id]['nbre'] = 1;
|
91 |
$points[$id]['nbre'] = 1;
|
| 91 |
} else {
|
92 |
} else {
|
| - |
|
93 |
$points[$id]['nbre']++;
|
| - |
|
94 |
}
|
| - |
|
95 |
|
| - |
|
96 |
// Détermination x et y min et max
|
| - |
|
97 |
if (is_null($mm)) {
|
| - |
|
98 |
$mm = array('min_x' => $enrg['coord_x'],
|
| - |
|
99 |
'max_x' => $enrg['coord_x'],
|
| - |
|
100 |
'min_y' => $enrg['coord_y'],
|
| - |
|
101 |
'max_y' => $enrg['coord_y']);
|
| - |
|
102 |
} else {
|
| - |
|
103 |
$mm['min_x'] = ($mm['min_x'] > $enrg['coord_x']) ? $enrg['coord_x'] : $mm['min_x'];
|
| - |
|
104 |
$mm['min_y'] = ($mm['min_y'] > $enrg['coord_y']) ? $enrg['coord_y'] : $mm['min_y'];
|
| - |
|
105 |
$mm['max_x'] = ($mm['max_x'] < $enrg['coord_x']) ? $enrg['coord_x'] : $mm['max_x'];
|
| - |
|
106 |
$mm['max_y'] = ($mm['max_y'] < $enrg['coord_y']) ? $enrg['coord_y'] : $mm['max_y'];
|
| 92 |
$points[$id]['nbre']++;
|
107 |
}
|
| 93 |
}
|
- |
|
| 94 |
|
- |
|
| 95 |
// Détermination x et y min et max
|
- |
|
| 96 |
$mm['min_x'] = ($mm['min_x'] > $enrg['coord_x']) ? $enrg['coord_x'] : $mm['min_x'];
|
- |
|
| 97 |
$mm['min_y'] = ($mm['min_y'] > $enrg['coord_y']) ? $enrg['coord_y'] : $mm['min_y'];
|
- |
|
| 98 |
$mm['max_x'] = ($mm['max_x'] < $enrg['coord_x']) ? $enrg['coord_x'] : $mm['max_x'];
|
- |
|
| 99 |
$mm['max_y'] = ($mm['max_y'] < $enrg['coord_y']) ? $enrg['coord_y'] : $mm['max_y'];
|
108 |
}
|
| 100 |
}
|
- |
|
| 101 |
|
- |
|
| 102 |
// Post-traitement des résultats
|
- |
|
| 103 |
$x_moyen = str_replace(',', '.', ($mm['max_x'] - $mm['min_x']));
|
- |
|
| 104 |
$y_moyen = str_replace(',', '.', ($mm['max_y'] - $mm['min_y']));
|
109 |
}
|
| Line 105... |
Line 110... |
| 105 |
$points = array_values($points);
|
110 |
$points = array_values($points);
|
| 106 |
|
111 |
|
| 107 |
// Création des infos du widget
|
112 |
// Création des infos du widget
|
| Line 108... |
Line 113... |
| 108 |
$json['type'] = (isset($this->formatRetour)) ? $this->formatRetour : 'json';
|
113 |
$json['type'] = (isset($this->formatRetour)) ? $this->formatRetour : 'json';
|
| 109 |
$json['variable_js'] = 'obs';
|
114 |
$json['variable_js'] = 'obs';
|
| 110 |
|
115 |
|
| 111 |
$json['donnees']['points'] = $points;
|
116 |
$json['donnees']['points'] = $points;
|
| Line 112... |
Line 117... |
| 112 |
$json['donnees']['nombre'] = count($points);
|
117 |
$json['donnees']['nombre'] = count($points);
|
| 113 |
$json['donnees']['centre_x'] = $x_moyen;
|
118 |
$json['donnees']['centre_x'] = $mm['min_x'].'-'.$mm['max_x'];
|
| 114 |
$json['donnees']['centre_y'] = $y_moyen;
|
119 |
$json['donnees']['centre_y'] = $mm['min_y'].'-'.$mm['max_y'];
|
| Line 167... |
Line 172... |
| 167 |
$mm['min_x'] = ($mm['min_x'] > $enrg['coord_x']) ? $enrg['coord_x'] : $mm['min_x'];
|
172 |
$mm['min_x'] = ($mm['min_x'] > $enrg['coord_x']) ? $enrg['coord_x'] : $mm['min_x'];
|
| 168 |
$mm['min_y'] = ($mm['min_y'] > $enrg['coord_y']) ? $enrg['coord_y'] : $mm['min_y'];
|
173 |
$mm['min_y'] = ($mm['min_y'] > $enrg['coord_y']) ? $enrg['coord_y'] : $mm['min_y'];
|
| 169 |
$mm['max_x'] = ($mm['max_x'] < $enrg['coord_x']) ? $enrg['coord_x'] : $mm['max_x'];
|
174 |
$mm['max_x'] = ($mm['max_x'] < $enrg['coord_x']) ? $enrg['coord_x'] : $mm['max_x'];
|
| 170 |
$mm['max_y'] = ($mm['max_y'] < $enrg['coord_y']) ? $enrg['coord_y'] : $mm['max_y'];
|
175 |
$mm['max_y'] = ($mm['max_y'] < $enrg['coord_y']) ? $enrg['coord_y'] : $mm['max_y'];
|
| 171 |
}
|
176 |
}
|
| 172 |
|
- |
|
| 173 |
// Post-traitement des résultats
|
- |
|
| 174 |
$x_moyen = str_replace(',', '.', ($mm['max_x'] - $mm['min_x']));
|
- |
|
| 175 |
$y_moyen = str_replace(',', '.', ($mm['max_y'] - $mm['min_y']));
|
- |
|
| 176 |
$points = array_values($points);
|
177 |
$points = array_values($points);
|
| Line 177... |
Line 178... |
| 177 |
|
178 |
|
| 178 |
// Création des infos du widget
|
179 |
// Création des infos du widget
|
| 179 |
$json['type'] = 'json';
|
180 |
$json['type'] = 'json';
|
| 180 |
$json['variable_js'] = 'obs';
|
181 |
$json['variable_js'] = 'obs';
|
| 181 |
$json['donnees']['points'] = $points;
|
182 |
$json['donnees']['points'] = $points;
|
| 182 |
$json['donnees']['nombre'] = count($points);
|
183 |
$json['donnees']['nombre'] = count($points);
|
| 183 |
$json['donnees']['centre_x'] = $x_moyen;
|
184 |
$json['donnees']['centre_x'] = $mm['min_x'].'-'.$mm['max_x'];
|
| 184 |
$json['donnees']['centre_y'] = $y_moyen;
|
185 |
$json['donnees']['centre_y'] = $mm['min_y'].'-'.$mm['max_y'];
|
| Line 185... |
Line 186... |
| 185 |
}
|
186 |
}
|
| 186 |
|
187 |
|
| 187 |
//echo '<pre>'.print_r($json, true).'</pre>';
|
188 |
//echo '<pre>'.print_r($json, true).'</pre>';
|
| Line 254... |
Line 255... |
| 254 |
' ON (l.name = i.location AND l.code = i.id_location) '.
|
255 |
' ON (l.name = i.location AND l.code = i.id_location) '.
|
| 255 |
"WHERE transmission = '1' ".
|
256 |
"WHERE transmission = '1' ".
|
| 256 |
(isset($utilisateur) ? " AND identifiant = '$utilisateur' " : '').
|
257 |
(isset($utilisateur) ? " AND identifiant = '$utilisateur' " : '').
|
| 257 |
(isset($dept) ? " AND l.insee_code LIKE '$dept%' " : '').
|
258 |
(isset($dept) ? " AND l.insee_code LIKE '$dept%' " : '').
|
| 258 |
(isset($num_taxon) ? " AND num_taxon = '$num_taxon' " : '' ).
|
259 |
(isset($num_taxon) ? " AND num_taxon = '$num_taxon' " : '' ).
|
| 259 |
((isset($projet) && $projet_sql != '') ? " AND ($projet_sql) " : '' );
|
260 |
((isset($projet) && $projet_sql != '') ? " AND ($projet_sql) " : '' ).
|
| - |
|
261 |
'ORDER BY nom_ret ASC ';
|
| 260 |
//$this->debug[] = $requete;
|
262 |
//$this->debug[] = $requete;
|
| Line 261... |
Line 263... |
| 261 |
|
263 |
|
| Line 262... |
Line 264... |
| 262 |
$resultats = $this->executerRequete($requete);
|
264 |
$resultats = $this->executerRequete($requete);
|