1 |
aurelien |
1 |
<?
|
|
|
2 |
|
|
|
3 |
|
|
|
4 |
if (!isset($_POST['valid_station']) || sizeof($erreurs)>0) {
|
|
|
5 |
|
|
|
6 |
?>
|
|
|
7 |
|
|
|
8 |
Définissez vos stations d'observation :
|
|
|
9 |
|
|
|
10 |
<br>
|
|
|
11 |
<form id="addr" action="#" method="get" onsubmit="return showAddress(this);" style="float:left;">
|
|
|
12 |
<ul style="list-style-type:none;margin:0;padding:0;">
|
|
|
13 |
<li>
|
|
|
14 |
<label for="lieu">Selectionnez la commune la plus proche de votre station :</label>
|
|
|
15 |
<input id="lieu" type="text" size="30" name="lieu" value=""/>
|
|
|
16 |
<input type="submit" value="Localiser" />
|
|
|
17 |
</li>
|
|
|
18 |
<li>
|
|
|
19 |
Ensuite, positionnez la pastille rouge sur votre station et donnez lui un nom.
|
|
|
20 |
</li
|
|
|
21 |
</ul>
|
|
|
22 |
</fieldset>
|
|
|
23 |
</form>
|
|
|
24 |
|
|
|
25 |
<div id="map" style="width:600px;height:400px;border:2px solid grey;margin:10px 0;clear:both;"></div>
|
|
|
26 |
|
|
|
27 |
<?php
|
|
|
28 |
|
|
|
29 |
//Récupération des stations existantes
|
|
|
30 |
|
|
|
31 |
//FONCTIONNEMENT_TESTE_ET_OK
|
|
|
32 |
|
|
|
33 |
|
|
|
34 |
// les stations de l'observateur :
|
|
|
35 |
|
|
|
36 |
$requete_stations = mysql_query("select STATION_ID, STATION_NOM, STATION_LATITUDE, STATION_LONGITUDE, STATION_ALTITUDE, STATION_ENVIRONNEMENT_ID, ENVIRONNEMENT_NOM from STATION, ENVIRONNEMENT where STATION.PARTICIPANT_ID=".$_SESSION['participant']." AND ENVIRONNEMENT_ID=STATION_ENVIRONNEMENT_ID ORDER BY STATION_NOM");
|
|
|
37 |
|
|
|
38 |
|
|
|
39 |
|
|
|
40 |
$nb_requete_stations = @mysql_num_rows($requete_stations);
|
|
|
41 |
|
|
|
42 |
|
|
|
43 |
|
|
|
44 |
|
|
|
45 |
|
|
|
46 |
|
|
|
47 |
$stations=array();
|
|
|
48 |
|
|
|
49 |
|
|
|
50 |
echo "<br>";
|
|
|
51 |
echo "</br>\n";
|
|
|
52 |
echo "<b>Vos stations enregistrées (Cliquez sur le nom de la station pour ajouter de nouvelles espèces) :</b> <br>";
|
|
|
53 |
|
|
|
54 |
|
|
|
55 |
?>
|
|
|
56 |
<form name="form_station" method="post" action="<?= $url_page ?>">
|
|
|
57 |
<input type="hidden" name="etape" value="<?= $etape ?>">
|
|
|
58 |
<input type="hidden" name="<?= $provenance ?>" value="1">
|
|
|
59 |
<input type="hidden" name="<?= $provenance ?>etape" value="<?= $etape ?>">
|
|
|
60 |
<?php
|
|
|
61 |
|
|
|
62 |
echo "<table id='tabstations'>";
|
|
|
63 |
|
|
|
64 |
|
|
|
65 |
|
|
|
66 |
if ($nb_requete_stations > 0) {
|
|
|
67 |
|
|
|
68 |
|
|
|
69 |
// Liste des stations
|
|
|
70 |
|
|
|
71 |
$MOIS_EN_COURS = '09';
|
|
|
72 |
$MOIS_RENTREE = '09'; // FIXME : quelle difference avec la variable precedente ?
|
|
|
73 |
$mois = date('m');
|
|
|
74 |
$annee = date('Y');
|
|
|
75 |
|
|
|
76 |
//$annee=$annee+1;
|
|
|
77 |
/*
|
|
|
78 |
if ($mois > $MOIS_RENTREE) {
|
|
|
79 |
$annee = $annee+1;
|
|
|
80 |
}
|
|
|
81 |
*/
|
|
|
82 |
|
|
|
83 |
while ($station = mysql_fetch_assoc($requete_stations)) {
|
|
|
84 |
|
|
|
85 |
|
|
|
86 |
$stations [] = $station;
|
|
|
87 |
echo "<tr>";
|
|
|
88 |
echo "<td><strong>Station : <a title=\"Ajouter de nouvelles espèces\" href=\"".$url_page."&station_id=".$station['STATION_ID']."\">".$station['STATION_NOM']."</a><strong></td>";
|
|
|
89 |
|
|
|
90 |
|
|
|
91 |
|
|
|
92 |
// echo "<td>".$station['STATION_LATITUDE']."</td>";
|
|
|
93 |
//echo "<td>".$station['STATION_LONGITUDE']."</td>";
|
|
|
94 |
//echo "<td>".$station['STATION_ALTITUDE']."</td>";
|
|
|
95 |
//echo "<td>"."<input type=\"submit\" class=\"submit\" name=\"".$station['STATION_ID']."\" value=\"Choisir cette station\"></td>";
|
|
|
96 |
|
|
|
97 |
// A t-on des mesures associe a cette station ? Si oui on ne peut pas la modifier ni supprimer
|
|
|
98 |
|
|
|
99 |
$requete_mesure = mysql_query("SELECT MESURE.SEQUENCE_ID FROM MESURE,SEQUENCE,STATION where MESURE.SEQUENCE_ID=SEQUENCE.SEQUENCE_ID AND STATION.STATION_ID=SEQUENCE.STATION_ID AND STATION.PARTICIPANT_ID=".$_SESSION['participant']." AND STATION.STATION_ID=".$station['STATION_ID']);
|
|
|
100 |
$nb_requete_mesure = mysql_num_rows($requete_mesure);
|
|
|
101 |
|
|
|
102 |
$obs_existe=false;
|
|
|
103 |
|
|
|
104 |
if ($nb_requete_mesure == 0) { // Pas de mesure on peut modifier
|
|
|
105 |
echo "<td>"."<input type=\"submit\" class=\"submit\" name=\"".$station['STATION_ID']."\" value=\"Modifier\"></td>";
|
|
|
106 |
}
|
|
|
107 |
else {
|
|
|
108 |
$obs_existe=true;
|
|
|
109 |
echo "<td></td>";
|
|
|
110 |
}
|
|
|
111 |
|
|
|
112 |
echo "</tr>";
|
|
|
113 |
|
|
|
114 |
|
|
|
115 |
|
|
|
116 |
|
|
|
117 |
$requete_obs_annee = mysql_query("select distinct SEQUENCE.SEQUENCE_ID, ESPECE_NOM_VERNACULAIRE, STATION_NOM from SEQUENCE,ESPECE,STATION,MESURE ".
|
|
|
118 |
"where ESPECE.ESPECE_ID=SEQUENCE.ESPECE_ID".
|
|
|
119 |
" and MESURE.SEQUENCE_ID=SEQUENCE.SEQUENCE_ID".
|
|
|
120 |
" and SEQUENCE.PARTICIPANT_ID=".$_SESSION['participant'].
|
|
|
121 |
" and STATION.STATION_ID=". $station['STATION_ID'] .
|
|
|
122 |
" and STATION.STATION_ID=SEQUENCE.STATION_ID".
|
|
|
123 |
" AND MESURE_DATE!='0000-00-00' and MESURE_DATE>'".($annee-2).'-'.($mois)."-01'".
|
|
|
124 |
" and MESURE_DATE<'".($annee).'-'.($mois)."-01'".
|
|
|
125 |
" order by STATION_NOM, ESPECE_NOM_VERNACULAIRE");
|
|
|
126 |
|
|
|
127 |
$nb_requete_obs_annee = mysql_num_rows($requete_obs_annee);
|
|
|
128 |
|
|
|
129 |
if (($nb_requete_obs_annee == 0) && ($obs_existe)) {
|
|
|
130 |
echo "<tr>";
|
|
|
131 |
echo "<td>Observations archivées </td>";
|
|
|
132 |
echo "</tr>";
|
|
|
133 |
|
|
|
134 |
}
|
|
|
135 |
|
|
|
136 |
while ($obs = mysql_fetch_assoc($requete_obs_annee)) {
|
|
|
137 |
echo "<tr>";
|
|
|
138 |
echo "<td>Espèce : <a title=\"Ajouter/modifier des observations\" href=\"".$url_page."&sequence_id=".$obs['SEQUENCE_ID']."\">".$obs['ESPECE_NOM_VERNACULAIRE']."</a></td>";
|
|
|
139 |
echo "</tr>";
|
|
|
140 |
}
|
|
|
141 |
|
|
|
142 |
echo "<tr>";
|
|
|
143 |
echo "</tr>";
|
|
|
144 |
echo "<tr>";
|
|
|
145 |
echo "</tr>";
|
|
|
146 |
|
|
|
147 |
}
|
|
|
148 |
|
|
|
149 |
|
|
|
150 |
|
|
|
151 |
// On retient la premiere station pour centrage
|
|
|
152 |
|
|
|
153 |
$init_lat=$stations[0]['STATION_LATITUDE'];
|
|
|
154 |
$init_lon=$stations[0]['STATION_LONGITUDE'];
|
|
|
155 |
|
|
|
156 |
|
|
|
157 |
}
|
|
|
158 |
else {
|
|
|
159 |
|
|
|
160 |
// Pas de stations : affichage centre carte france
|
|
|
161 |
// FONCTIONNEMENT_TESTE_ET_OK
|
|
|
162 |
|
|
|
163 |
|
|
|
164 |
$init_lat=45.545;
|
|
|
165 |
$init_lon=3.249722;
|
|
|
166 |
|
|
|
167 |
echo "<td><strong>Pas de station enregistrée</strong></td>";
|
|
|
168 |
echo "<td></td>";
|
|
|
169 |
echo "<td></td>";
|
|
|
170 |
echo "<td></td>";
|
|
|
171 |
echo "<td></td>";
|
|
|
172 |
echo "<td></td>";
|
|
|
173 |
echo "</tr>";
|
|
|
174 |
|
|
|
175 |
|
|
|
176 |
|
|
|
177 |
}
|
|
|
178 |
|
|
|
179 |
echo "</table>";
|
|
|
180 |
echo "</form>";
|
|
|
181 |
|
|
|
182 |
|
|
|
183 |
|
|
|
184 |
|
|
|
185 |
|
|
|
186 |
//$espece_encours=$obs[1];
|
|
|
187 |
$commune_encours=$obs[2];
|
|
|
188 |
|
|
|
189 |
|
|
|
190 |
|
|
|
191 |
/***** Selection des stations *****/
|
|
|
192 |
|
|
|
193 |
//Affichage des éventuelles erreurs
|
|
|
194 |
afficherErreurs($erreurs);
|
|
|
195 |
|
|
|
196 |
?>
|
|
|
197 |
|
|
|
198 |
|
|
|
199 |
|
|
|
200 |
|
|
|
201 |
<form id="form_coordonnee" action="<?= $url_page ?>" method="post" style="float:left;">
|
|
|
202 |
<input id="ll_latitude" name="ll_latitude" type="hidden" value="" />
|
|
|
203 |
<input id="ll_latitude_dms" name="ll_latitude_dms" type="hidden" value="" />
|
|
|
204 |
<input id="ll_longitude" name="ll_longitude" type="hidden" value="" />
|
|
|
205 |
<input id="ll_longitude_dms" name="ll_longitude_dms" type="hidden" value="" />
|
|
|
206 |
<input id="ll_altitude" name="ll_altitude" type="hidden" value="" />
|
|
|
207 |
<input id="form_coordonnee_valider" name="valid_station" class="submit" type="hidden" value="Poursuivre" />
|
|
|
208 |
<input type="hidden" name="etape" value="3">
|
|
|
209 |
<input type="hidden" name="provenance" value="<?= $provenance ?>">
|
|
|
210 |
</li>
|
|
|
211 |
</ul>
|
|
|
212 |
|
|
|
213 |
</form>
|
|
|
214 |
|
|
|
215 |
|
|
|
216 |
|
|
|
217 |
<?php
|
|
|
218 |
|
|
|
219 |
include_once 'modules/configuration/car_config.inc.php' ;
|
|
|
220 |
|
|
|
221 |
if (PARTICIPANT_EST_ADULTE) {
|
|
|
222 |
?>
|
|
|
223 |
<script type="text/javascript" src="http://maps.google.com/maps?file=api&v=2&key=ABQIAAAAnm2MSMmwsDuoh7THcVDnlBQH9AL26AfEfaraxwo1G6_adyVjPRRQE4Gx2u7MomK9DJWf9kMLJ9y-ZA" type="text/javascript"></script>
|
|
|
224 |
<?php
|
|
|
225 |
}
|
|
|
226 |
else {
|
|
|
227 |
?>
|
|
|
228 |
<script type="text/javascript" src="http://maps.google.com/maps?file=api&v=2&key=ABQIAAAAFMANWib9GSm7T4W6AN9qzxRmHYqXwt_BUwczny2vFmnHz3sr3BTy_SMRJ-NzWXDUynHHSWQ7_aEZ6Q" type="text/javascript"></script>
|
|
|
229 |
<?php
|
|
|
230 |
}
|
|
|
231 |
|
|
|
232 |
|
|
|
233 |
// Centrage initial : premiere station ou ville d'inscription
|
|
|
234 |
|
|
|
235 |
echo "<script type=\"text/javascript\">";
|
|
|
236 |
echo "\n//<![CDATA[\n";
|
|
|
237 |
echo "var init_lat = ".$init_lat.";\n";
|
|
|
238 |
echo "var init_long = ".$init_lon.";\n";
|
|
|
239 |
|
|
|
240 |
?>
|
|
|
241 |
|
|
|
242 |
|
|
|
243 |
var largeur_carte = 690;
|
|
|
244 |
var haureur_retrait = 330;
|
|
|
245 |
|
|
|
246 |
var init_zoom = 10;
|
|
|
247 |
|
|
|
248 |
// Contient la carte GoogleMap
|
|
|
249 |
var map;
|
|
|
250 |
// Contient l'utilitaire permettant de trouver une adresse.
|
|
|
251 |
var EfGeocoder;
|
|
|
252 |
// Point de l'adresse saisie et à passer au GeoCoder
|
|
|
253 |
var addrpnt;
|
|
|
254 |
// L'icône à afficher sur la carte
|
|
|
255 |
var icon;
|
|
|
256 |
|
|
|
257 |
function load() {
|
|
|
258 |
// Vérification de la compatibilité du navigateur
|
|
|
259 |
if (GBrowserIsCompatible()) {
|
|
|
260 |
// Création de la carte
|
|
|
261 |
map = new GMap2(document.getElementById("map"));
|
|
|
262 |
// Positionnement de la carte
|
|
|
263 |
map.setCenter(new GLatLng(init_lat, init_long), init_zoom);
|
|
|
264 |
// Types de carte disponibles :
|
|
|
265 |
map.addMapType(G_NORMAL_MAP);
|
|
|
266 |
map.addMapType(G_SATELLITE_MAP);
|
|
|
267 |
map.addMapType(G_PHYSICAL_MAP);
|
|
|
268 |
// Bouton pour changer de type de carte (mixte, satellite, plan)
|
|
|
269 |
map.addControl(new GMapTypeControl(1));
|
|
|
270 |
// Définition du type de la carte par défaut
|
|
|
271 |
map.setMapType(G_HYBRID_MAP);
|
|
|
272 |
// Bouton large de déplancement et zoom apparaissant dans le coin haut gauche
|
|
|
273 |
map.addControl(new GLargeMapControl());
|
|
|
274 |
// Pour hierarchiser les types de carte --> pas encore dans la version stable...
|
|
|
275 |
//var mapControl = new GHierarchicalMapTypeControl();
|
|
|
276 |
// Définition des relations des types de menus
|
|
|
277 |
//mapControl.clearRelationships();
|
|
|
278 |
//mapControl.addRelationship(G_SATELLITE_MAP, G_HYBRID_MAP, 'Labels', false);
|
|
|
279 |
// Ajout du controle après avoir spécifié les relations
|
|
|
280 |
//map.addControl(mapControl);
|
|
|
281 |
// Vue d'ensemble apparaissant dans le coin bas droit
|
|
|
282 |
var EfOverViewMap = new GOverviewMapControl();
|
|
|
283 |
map.addControl(EfOverViewMap);
|
|
|
284 |
var mini = EfOverViewMap.getOverviewMap();
|
|
|
285 |
// ?
|
|
|
286 |
map.enableContinuousZoom();
|
|
|
287 |
// Zoom avec la molette de la souris
|
|
|
288 |
map.enableScrollWheelZoom();
|
|
|
289 |
// Zoom avec le double clic de la souris
|
|
|
290 |
map.enableDoubleClickZoom();
|
|
|
291 |
|
|
|
292 |
// Création du GéoCoder
|
|
|
293 |
EfGeocoder = new GClientGeocoder() ;
|
|
|
294 |
|
|
|
295 |
// Icone station enregistrees (vert)
|
|
|
296 |
icon = new GIcon();
|
|
|
297 |
icon.image = "http://www.google.com/mapfiles/ms/micons/green-dot.png";
|
|
|
298 |
icon.shadow = "http://www.google.com/mapfiles/shadow50.png";
|
|
|
299 |
icon.iconSize = new GSize(34, 34);
|
|
|
300 |
icon.shadowSize = new GSize(37, 34);
|
|
|
301 |
icon.iconAnchor = new GPoint(16, 34);
|
|
|
302 |
// Pour affichage infobulle
|
|
|
303 |
icon.infoWindowAnchor = new GPoint(5,1);
|
|
|
304 |
|
|
|
305 |
|
|
|
306 |
// Icone nouvelle station (rouge) ou station en modification
|
|
|
307 |
Nicon = new GIcon();
|
|
|
308 |
Nicon.image = "http://www.google.com/mapfiles/ms/micons/red-dot.png";
|
|
|
309 |
Nicon.shadow = "http://www.google.com/mapfiles/shadow50.png";
|
|
|
310 |
Nicon.iconSize = new GSize(34, 34);
|
|
|
311 |
Nicon.shadowSize = new GSize(37, 34);
|
|
|
312 |
Nicon.iconAnchor = new GPoint(16, 34);
|
|
|
313 |
// Pour affichage infobulle
|
|
|
314 |
Nicon.infoWindowAnchor = new GPoint(5,1);
|
|
|
315 |
|
|
|
316 |
|
|
|
317 |
|
|
|
318 |
|
|
|
319 |
// Creates a marker at the given point with the given number label
|
|
|
320 |
|
|
|
321 |
function createMarker(point, text, altitude, envir) {
|
|
|
322 |
var marker = new GMarker(point,icon);
|
|
|
323 |
var html = text;
|
|
|
324 |
GEvent.addListener(marker, "click", function() {
|
|
|
325 |
map.setCenter(marker.getPoint());
|
|
|
326 |
afficherInfo(marker.getPoint());
|
|
|
327 |
afficherMasque(marker,text,altitude,envir);
|
|
|
328 |
});
|
|
|
329 |
return marker;
|
|
|
330 |
}
|
|
|
331 |
|
|
|
332 |
// Affichage des stations presentes TODO : et si plusieurs stations au meme endroit ? Utiliser cluster ?
|
|
|
333 |
|
|
|
334 |
<? foreach($stations as $station) { ?>
|
|
|
335 |
var point = new GLatLng(<?= $station['STATION_LATITUDE'] ?>, <?= $station['STATION_LONGITUDE'] ?>);
|
|
|
336 |
map.addOverlay(createMarker(point, "<?= $station['STATION_NOM'] ?>","<?= $station['STATION_ALTITUDE'] ?>", "<?= $station['ENVIRONNEMENT_NOM'] ?>"));
|
|
|
337 |
<? } ?>
|
|
|
338 |
|
|
|
339 |
|
|
|
340 |
}
|
|
|
341 |
}
|
|
|
342 |
|
|
|
343 |
|
|
|
344 |
|
|
|
345 |
function showAddress(form) {
|
|
|
346 |
if (form.lieu.value != '') {
|
|
|
347 |
var lieu = form.lieu.value;
|
|
|
348 |
EfGeocoder.getLatLng(lieu, function(position) {
|
|
|
349 |
if (!position) {
|
|
|
350 |
alert('Le lieu "'+lieu+'" est introuvable! Veuillez essayer un autre nom.')
|
|
|
351 |
} else {
|
|
|
352 |
placerMarkeur(position);
|
|
|
353 |
map.setCenter(position, 14) ;
|
|
|
354 |
}
|
|
|
355 |
// Vidage du champ du formulaire
|
|
|
356 |
form.lieu.value = '';
|
|
|
357 |
});
|
|
|
358 |
} else {
|
|
|
359 |
var position = new GLatLng(form.lati.value, form.longi.value);
|
|
|
360 |
placerMarkeur(position);
|
|
|
361 |
map.setCenter(position, 14);
|
|
|
362 |
// Vidage des champs du formulaire
|
|
|
363 |
form.lati.value = '';
|
|
|
364 |
form.longi.value = '';
|
|
|
365 |
}
|
|
|
366 |
return false;
|
|
|
367 |
}
|
|
|
368 |
|
|
|
369 |
// Ajout d'un nouveau marqueur dragable , depuis le geocodage uniquement (blocage du clic depuis la carte)
|
|
|
370 |
|
|
|
371 |
function placerMarkeur(position) {
|
|
|
372 |
if (addrpnt) {
|
|
|
373 |
map.removeOverlay(addrpnt);
|
|
|
374 |
}
|
|
|
375 |
addrpnt = new GMarker(position, {icon: Nicon, draggable: true, title: 'Click sur la carte!'}) ;
|
|
|
376 |
addrpnt.enableDragging() ;
|
|
|
377 |
map.addOverlay(addrpnt) ;
|
|
|
378 |
GEvent.addListener(addrpnt,'dragend',function() {
|
|
|
379 |
map.setCenter(addrpnt.getPoint());
|
|
|
380 |
afficherInfo(addrpnt.getPoint());
|
|
|
381 |
afficherMasque(addrpnt,"");
|
|
|
382 |
|
|
|
383 |
}) ;
|
|
|
384 |
|
|
|
385 |
GEvent.addListener(addrpnt, "click", function() {
|
|
|
386 |
map.setCenter(addrpnt.getPoint());
|
|
|
387 |
afficherInfo(addrpnt.getPoint());
|
|
|
388 |
afficherMasque(addrpnt,"");
|
|
|
389 |
});
|
|
|
390 |
|
|
|
391 |
afficherInfo(position);
|
|
|
392 |
}
|
|
|
393 |
|
|
|
394 |
// Masque de mise a jour station :
|
|
|
395 |
|
|
|
396 |
function afficherMasque(position,nom,altitude,envir) {
|
|
|
397 |
|
|
|
398 |
// On recupere les données du formulaire (caché) , notamment pour traiter simplement l'appel asynchrone de recup altitude
|
|
|
399 |
|
|
|
400 |
var html = "<table>";
|
|
|
401 |
if (nom.length>0) {
|
|
|
402 |
html = html + "<tr><td>Station :</td> <td>" + nom + "</td> </tr>";
|
|
|
403 |
|
|
|
404 |
|
|
|
405 |
|
|
|
406 |
|
|
|
407 |
html = html + "<tr><td>Environnement :</td> <td>" + envir + "</td> </tr>";
|
|
|
408 |
|
|
|
409 |
html = html + "</td></tr>";
|
|
|
410 |
|
|
|
411 |
|
|
|
412 |
|
|
|
413 |
}
|
|
|
414 |
else {
|
|
|
415 |
html = html + "<tr><td>Station</td> <td><input type='text' id='nom_station' value=''/> </td> </tr>";
|
|
|
416 |
<?
|
|
|
417 |
$requete_environnement = mysql_query("select ENVIRONNEMENT_ID, ENVIRONNEMENT_NOM from ENVIRONNEMENT");
|
|
|
418 |
?>
|
|
|
419 |
|
|
|
420 |
html = html + "<tr><td>Environnement :</td>";
|
|
|
421 |
html = html + "<td><select id='environnement_id' name='environnement'>";
|
|
|
422 |
|
|
|
423 |
<? while ($env = mysql_fetch_row($requete_environnement)) { ?>
|
|
|
424 |
html = html + "<option value='<?= $env[0] ?>'><?= $env[1] ?>";
|
|
|
425 |
<? } ?>
|
|
|
426 |
|
|
|
427 |
html = html + "</select></td></tr>";
|
|
|
428 |
|
|
|
429 |
}
|
|
|
430 |
|
|
|
431 |
|
|
|
432 |
|
|
|
433 |
|
|
|
434 |
html = html + "<tr><td>Latitude :</td> <td>" +document.getElementById('ll_latitude').value + "</td> </tr>" ;
|
|
|
435 |
html = html + "<tr><td>Latitude :</td> <td>" +document.getElementById('ll_latitude').value + "</td> </tr>" ;
|
|
|
436 |
html = html + "<tr><td>Longitude :</td> <td>" + document.getElementById('ll_longitude').value + "</td> </tr>";
|
|
|
437 |
if (altitude) {
|
|
|
438 |
html = html + "<tr><td>Altitude :</td> <td>" + altitude + "</td> </tr>";
|
|
|
439 |
}
|
|
|
440 |
else {
|
|
|
441 |
html = html + "<tr><td>Altitude :</td> <td>" + document.getElementById('ll_altitude').value + "</td> </tr>";
|
|
|
442 |
}
|
|
|
443 |
if (nom.length==0) {
|
|
|
444 |
html = html + "<tr><td></td><td><input type='button' value='Enregistrer' onclick='saveData()'/></td></tr>";
|
|
|
445 |
}
|
|
|
446 |
|
|
|
447 |
|
|
|
448 |
position.openInfoWindow(html);
|
|
|
449 |
|
|
|
450 |
}
|
|
|
451 |
|
|
|
452 |
|
|
|
453 |
// Sauvegarde station
|
|
|
454 |
|
|
|
455 |
// TODO : Retrouver marker depuis lat/lon
|
|
|
456 |
|
|
|
457 |
function saveData() {
|
|
|
458 |
|
|
|
459 |
var nom_station = escape(document.getElementById("nom_station").value);
|
|
|
460 |
var lat_station = document.getElementById("ll_latitude").value;
|
|
|
461 |
var lon_station = document.getElementById("ll_longitude").value;
|
|
|
462 |
var alt_station = document.getElementById("ll_altitude").value;
|
|
|
463 |
var environnement_id = document.getElementById("environnement_id").value;
|
|
|
464 |
|
|
|
465 |
var url = "modules/observations/sauvegarde_station.php?nom_station=" + nom_station + "&action=C" + "&lat_station=" + lat_station +
|
|
|
466 |
"&lon_station=" + lon_station + "&environnement_id=" + environnement_id + "&alt_station=" + alt_station + "&participant_id=<?= $_SESSION['participant'] ?>";
|
|
|
467 |
|
|
|
468 |
GDownloadUrl(url, function(data, responseCode) {
|
|
|
469 |
if (responseCode == 200 && data.length <= 1) {
|
|
|
470 |
window.location = "<?= $url_page ?>";
|
|
|
471 |
}
|
|
|
472 |
});
|
|
|
473 |
}
|
|
|
474 |
|
|
|
475 |
function afficherInfo(position) {
|
|
|
476 |
var form = document.getElementById('form_coordonnee');
|
|
|
477 |
afficherCoordonnees(position.lat().toString(), position.lng().toString());
|
|
|
478 |
}
|
|
|
479 |
|
|
|
480 |
function afficherCoordonnees(lati, longi) {
|
|
|
481 |
var ellipsoid = 21;// 21 = WGS-84 (voir geo_constants)
|
|
|
482 |
var xtm = 0;// 0 = UTM et 1= MTM
|
|
|
483 |
var Coordonnee = calculer_coordonnee(lati, longi, ellipsoid, xtm);
|
|
|
484 |
|
|
|
485 |
// Nous affichons des informations.
|
|
|
486 |
document.getElementById('ll_latitude').value = Coordonnee.latitude.toFixed(4);
|
|
|
487 |
document.getElementById('ll_longitude').value = Coordonnee.longitude.toFixed(4);
|
|
|
488 |
document.getElementById('ll_latitude_dms').value = Coordonnee.latitude_dms;
|
|
|
489 |
document.getElementById('ll_longitude_dms').value = Coordonnee.longitude_dms;
|
|
|
490 |
|
|
|
491 |
// Calcul altitude
|
|
|
492 |
var script = document.createElement('script');
|
|
|
493 |
document.body.appendChild(script);
|
|
|
494 |
script.src = 'http://ws.geonames.org/' + "srtm3" + 'JSON?lat=' + lati + '&lng=' + longi + '&callback=GetAltitude';
|
|
|
495 |
|
|
|
496 |
|
|
|
497 |
}
|
|
|
498 |
|
|
|
499 |
function GetAltitude(result ) {
|
|
|
500 |
document.getElementById('ll_altitude').value = result.srtm3;
|
|
|
501 |
}
|
|
|
502 |
|
|
|
503 |
window.onload = load
|
|
|
504 |
window.onunload = GUnload
|
|
|
505 |
|
|
|
506 |
/* A supprimer ? */
|
|
|
507 |
|
|
|
508 |
/* Source : Code provenant du site http://pages.globetrotter.net/roule/utmgoogle.htm
|
|
|
509 |
*/
|
|
|
510 |
|
|
|
511 |
var deg2rad = Math.PI / 180;
|
|
|
512 |
|
|
|
513 |
/*
|
|
|
514 |
* Fonction de transformation de coordonnées géographiques entre ellipsoide.
|
|
|
515 |
* Source : http://home.hiwaay.net/~taylorc/bookshelf/math-science/geodesy/datum/transform/molodensky/
|
|
|
516 |
* Licence : "The source code in the listing below may be copied and reused without restriction, but it is offered AS-IS with NO WARRANTY."
|
|
|
517 |
*
|
|
|
518 |
* Parameters:
|
|
|
519 |
* from: The geodetic position to be translated. (objet : GeodeticPosition)
|
|
|
520 |
* from_a: The semi-major axis of the "from" ellipsoid. (double)
|
|
|
521 |
* from_f: Flattening of the "from" ellipsoid. (double)
|
|
|
522 |
* from_esq: Eccentricity-squared of the "from" ellipsoid. (double)
|
|
|
523 |
* da: Change in semi-major axis length (meters); "to" minus "from"
|
|
|
524 |
* df: Change in flattening; "to" minus "from" (double)
|
|
|
525 |
* dx: Change in x between "from" and "to" datum. (double)
|
|
|
526 |
* dy: Change in y between "from" and "to" datum. (double)
|
|
|
527 |
* dz: Change in z between "from" and "to" datum. (double)
|
|
|
528 |
*
|
|
|
529 |
* Paramêtres :
|
|
|
530 |
* from : l'objet GeodesiquePosition à transformer (contient latitute, longitude et hauteur)
|
|
|
531 |
* from_a : le demi grand axe (=a) de l'ellipsoïde utilisé pour la position géodésique contenu dans l'objet "from".
|
|
|
532 |
* from_f : l'applatissement (=f) = 1/valeur... de l'ellipsoïde de l'objet "from"
|
|
|
533 |
* from_esq : l'excentricité au carré de l'ellipsoïde de l'objet "from"
|
|
|
534 |
* da : différence de demi grand axe (en metres) entre l'ellipsoïde "to" et "from".
|
|
|
535 |
* df : différence d'applatissement entre l'ellipsoïde "to" et "from".
|
|
|
536 |
* dx : différence pour l'axe x entre l'ellipsoïde "to" et "from".
|
|
|
537 |
* dy : différence pour l'axe y entre l'ellipsoïde "to" et "from".
|
|
|
538 |
* dz : différence pour l'axe z entre l'ellipsoïde "to" et "from".
|
|
|
539 |
*/
|
|
|
540 |
function transform(from, from_a, from_f, from_esq, da, df, dx, dy, dz) {
|
|
|
541 |
var slat = Math.sin (from.lat);
|
|
|
542 |
var clat = Math.cos (from.lat);
|
|
|
543 |
var slon = Math.sin (from.lon);
|
|
|
544 |
var clon = Math.cos (from.lon);
|
|
|
545 |
var ssqlat = slat * slat;
|
|
|
546 |
// "a divided by b"
|
|
|
547 |
var adb = 1.0 / (1.0 - from_f);
|
|
|
548 |
var dlat, dlon, dh;
|
|
|
549 |
|
|
|
550 |
var rn = from_a / Math.sqrt (1.0 - from_esq * ssqlat);
|
|
|
551 |
var rm = from_a * (1. - from_esq) / Math.pow ((1.0 - from_esq * ssqlat), 1.5);
|
|
|
552 |
|
|
|
553 |
dlat = (((((-dx * slat * clon - dy * slat * slon) + dz * clat) + (da * ((rn * from_esq * slat * clat) / from_a))) + (df * (rm * adb + rn / adb) * slat * clat))) / (rm + from.h);
|
|
|
554 |
|
|
|
555 |
dlon = (-dx * slon + dy * clon) / ((rn + from.h) * clat);
|
|
|
556 |
|
|
|
557 |
dh = (dx * clat * clon) + (dy * clat * slon) + (dz * slat) - (da * (from_a / rn)) + ((df * rn * ssqlat) / adb);
|
|
|
558 |
|
|
|
559 |
// Retour des données sous forme d'objet
|
|
|
560 |
var GeodeticPosition = { lon: from.lon + dlon,
|
|
|
561 |
lat: from.lat + dlat,
|
|
|
562 |
h: from.h + dh
|
|
|
563 |
};
|
|
|
564 |
|
|
|
565 |
return GeodeticPosition;
|
|
|
566 |
}
|
|
|
567 |
|
|
|
568 |
function test_transform() {
|
|
|
569 |
var PositionNtf = { lon: 7.7372, lat: 48.6, h: 0 };
|
|
|
570 |
var PositionWGS84 = transform(PositionNtf, 6378249.2, 0.00340755, 0.0068034881, -112.2, 0.00005474, -168, -60, 320);
|
|
|
571 |
alert('Longitude : ' + PositionWGS84.lon + 'Latitude : ' + PositionWGS84.lat + 'Hauteur : ' + PositionWGS84.h);
|
|
|
572 |
}
|
|
|
573 |
|
|
|
574 |
// Indiquer l'ellipsoid par son index dans le table et pour le xtm mettre 0 pour l'UTM et 1 pour le MTM (?)
|
|
|
575 |
function geo_constants(ellipsoid, xtm) {
|
|
|
576 |
// returns ellipsoid values
|
|
|
577 |
ellipsoid_axis = new Array(); // valeur du demi grand axe (a) de l'ellipsoïde
|
|
|
578 |
ellipsoid_eccen = new Array(); // valeur de l'excentricité au carré (e²) de l'ellipsoïde
|
|
|
579 |
ellipsoid_axis[0] = 6377563.396; ellipsoid_eccen[0] = 0.00667054; //airy
|
|
|
580 |
ellipsoid_axis[1] = 6377340.189; ellipsoid_eccen[1] = 0.00667054; // mod airy
|
|
|
581 |
ellipsoid_axis[2] = 6378160; ellipsoid_eccen[2] = 0.006694542; //aust national
|
|
|
582 |
ellipsoid_axis[3] = 6377397.155; ellipsoid_eccen[3] = 0.006674372; //bessel 1841
|
|
|
583 |
ellipsoid_axis[4] = 6378206.4; ellipsoid_eccen[4] = 0.006768658; //clarke 1866 == NAD 27 (TBC)
|
|
|
584 |
ellipsoid_axis[5] = 6378249.145; ellipsoid_eccen[5] = 0.006803511; //clarke 1880
|
|
|
585 |
ellipsoid_axis[6] = 6377276.345; ellipsoid_eccen[6] = 0.00637847; //everest
|
|
|
586 |
ellipsoid_axis[7] = 6377304.063; ellipsoid_eccen[7] = 0.006637847; // mod everest
|
|
|
587 |
ellipsoid_axis[8] = 6378166; ellipsoid_eccen[8] = 0.006693422; //fischer 1960
|
|
|
588 |
ellipsoid_axis[9] = 6378150; ellipsoid_eccen[9] = 0.006693422; //fischer 1968
|
|
|
589 |
ellipsoid_axis[10] = 6378155; ellipsoid_eccen[10] = 0.006693422; // mod fischer
|
|
|
590 |
ellipsoid_axis[11] = 6378160; ellipsoid_eccen[11] = 0.006694605; //grs 1967
|
|
|
591 |
ellipsoid_axis[12] = 6378137; ellipsoid_eccen[12] = 0.00669438; // grs 1980
|
|
|
592 |
ellipsoid_axis[13] = 6378200; ellipsoid_eccen[13] = 0.006693422; // helmert 1906
|
|
|
593 |
ellipsoid_axis[14] = 6378270; ellipsoid_eccen[14] = 0.006693422; // hough
|
|
|
594 |
ellipsoid_axis[15] = 6378388; ellipsoid_eccen[15] = 0.00672267; // int24
|
|
|
595 |
ellipsoid_axis[16] = 6378245; ellipsoid_eccen[16] = 0.006693422; // krassovsky
|
|
|
596 |
ellipsoid_axis[17] = 6378160; ellipsoid_eccen[17] = 0.006694542; // s america
|
|
|
597 |
ellipsoid_axis[18] = 6378165; ellipsoid_eccen[18] = 0.006693422; // wgs-60
|
|
|
598 |
ellipsoid_axis[19] = 6378145; ellipsoid_eccen[19] = 0.006694542; // wgs-66
|
|
|
599 |
ellipsoid_axis[20] = 6378135; ellipsoid_eccen[20] = 0.006694318; // wgs-72
|
|
|
600 |
ellipsoid_axis[21] = 6378137; ellipsoid_eccen[21] = 0.00669438; //wgs-84 (et NAD83 : pourquoi mis avec WGS84 ?)
|
|
|
601 |
|
|
|
602 |
if (ellipsoid == 0) {
|
|
|
603 |
ellipsoid = 22;
|
|
|
604 |
}
|
|
|
605 |
|
|
|
606 |
--ellipsoid; // table indexed differently
|
|
|
607 |
|
|
|
608 |
if (xtm == 1) {
|
|
|
609 |
// WAS: if (ellipsoid > 22)
|
|
|
610 |
scaleTm = 0.9999;
|
|
|
611 |
eastingOrg = 304800.;
|
|
|
612 |
} else {
|
|
|
613 |
scaleTm = 0.9996;
|
|
|
614 |
eastingOrg = 500000.;
|
|
|
615 |
}
|
|
|
616 |
|
|
|
617 |
// Retour des données sous forme d'objet
|
|
|
618 |
var ellipsoid = { axis: ellipsoid_axis[ellipsoid],
|
|
|
619 |
eccentricity: ellipsoid_eccen[ellipsoid],
|
|
|
620 |
eastingOrg: eastingOrg,
|
|
|
621 |
scaleTm: scaleTm
|
|
|
622 |
};
|
|
|
623 |
return ellipsoid;
|
|
|
624 |
}
|
|
|
625 |
|
|
|
626 |
/**This routine determines the correct UTM letter designator for the given latitude
|
|
|
627 |
* returns 'Z' if latitude is outside the UTM limits of 84N to 80S
|
|
|
628 |
*/
|
|
|
629 |
function get_zoneletter(lat) {
|
|
|
630 |
var zoneletter;
|
|
|
631 |
if ((84 >= lat) && (lat >= 72)) zoneletter = 'X';
|
|
|
632 |
else if ((72 > lat) && (lat >= 64)) zoneletter = 'W';
|
|
|
633 |
else if ((64 > lat) && (lat >= 56)) zoneletter = 'V';
|
|
|
634 |
else if ((56 > lat) && (lat >= 48)) zoneletter = 'U';
|
|
|
635 |
else if ((48 > lat) && (lat >= 40)) zoneletter = 'T';
|
|
|
636 |
else if ((40 > lat) && (lat >= 32)) zoneletter = 'S';
|
|
|
637 |
else if ((32 > lat) && (lat >= 24)) zoneletter = 'R';
|
|
|
638 |
else if ((24 > lat) && (lat >= 16)) zoneletter = 'Q';
|
|
|
639 |
else if ((16 > lat) && (lat >= 8)) zoneletter = 'P';
|
|
|
640 |
else if (( 8 > lat) && (lat >= 0)) zoneletter = 'N';
|
|
|
641 |
else if (( 0 > lat) && (lat >= -8)) zoneletter = 'M';
|
|
|
642 |
else if ((-8> lat) && (lat >= -16)) zoneletter = 'L';
|
|
|
643 |
else if ((-16 > lat) && (lat >= -24)) zoneletter = 'K';
|
|
|
644 |
else if ((-24 > lat) && (lat >= -32)) zoneletter = 'J';
|
|
|
645 |
else if ((-32 > lat) && (lat >= -40)) zoneletter = 'H';
|
|
|
646 |
else if ((-40 > lat) && (lat >= -48)) zoneletter = 'G';
|
|
|
647 |
else if ((-48 > lat) && (lat >= -56)) zoneletter = 'F';
|
|
|
648 |
else if ((-56 > lat) && (lat >= -64)) zoneletter = 'E';
|
|
|
649 |
else if ((-64 > lat) && (lat >= -72)) zoneletter = 'D';
|
|
|
650 |
else if ((-72 > lat) && (lat >= -80)) zoneletter = 'C';
|
|
|
651 |
else zoneletter = chr(32 + 66); //This is here as an error flag to show that the Latitude is outside the UTM limits
|
|
|
652 |
return zoneletter;
|
|
|
653 |
}
|
|
|
654 |
|
|
|
655 |
function parseCoordinate(coordinate, type, format, spaced) {
|
|
|
656 |
var coordd;
|
|
|
657 |
var coordm;
|
|
|
658 |
var coords;
|
|
|
659 |
var coordh = 0;
|
|
|
660 |
|
|
|
661 |
if (coordinate.search(/(^ *-|[WOS])/i) >= 0) {
|
|
|
662 |
coordh = -1;
|
|
|
663 |
}
|
|
|
664 |
if (coordinate.search(/(^ *\+|[NE])/i) >= 0) {
|
|
|
665 |
coordh = 1;
|
|
|
666 |
}
|
|
|
667 |
|
|
|
668 |
// if (coordinate.search(/[EW]/i) >= 0 && !type) { type = 'lon'; }
|
|
|
669 |
// if (coordinate.search(/[NS]/i) >= 0 && !type) { type = 'lat'; }
|
|
|
670 |
|
|
|
671 |
coordinate = coordinate.replace(/,/g, '.'); // french commas
|
|
|
672 |
// not sure really needed.
|
|
|
673 |
coordinate = coordinate.replace(/[NESWO+\-]/gi,' '); // add also: °, ', " -- or replace everything that is not a number or a dot
|
|
|
674 |
|
|
|
675 |
// alert("coordinate = " + coordinate);
|
|
|
676 |
if (coordinate.search(/[0-9]/i) < 0) {
|
|
|
677 |
alert("Can't parse input field");
|
|
|
678 |
coordd = "";
|
|
|
679 |
return;
|
|
|
680 |
}
|
|
|
681 |
|
|
|
682 |
// http://www.gpsvisualizer.com/calculators
|
|
|
683 |
// http://www.javascriptkit.com/javatutors/redev2.shtml
|
|
|
684 |
var parts = coordinate.match(/([0-9\.\-]+)[^0-9\.]*([0-9\.]+)?[^0-9\.]*([0-9\.]+)?/);
|
|
|
685 |
// / (one or more) /
|
|
|
686 |
// ([0-9\.\-]+) digits, dot or -, one set
|
|
|
687 |
// [^0-9\.]* separator
|
|
|
688 |
// ([0-9\.]+)? digits, dot, zero or one set
|
|
|
689 |
// [^0-9\.]* separator
|
|
|
690 |
// ([0-9\.]+)? digits, dot, zero or one set
|
|
|
691 |
|
|
|
692 |
// *: 0|more +: 1|more ?: 0|1 http://www.javascriptkit.com/javatutors/redev2.shtml
|
|
|
693 |
if (!parts[1]) {
|
|
|
694 |
alert("Can't parse input field");
|
|
|
695 |
coordd = '';
|
|
|
696 |
return;
|
|
|
697 |
} else {
|
|
|
698 |
coordd = parts[1];
|
|
|
699 |
if (parts[2]) {
|
|
|
700 |
coordm = parts[2];
|
|
|
701 |
} else {
|
|
|
702 |
coordm = 0;
|
|
|
703 |
}
|
|
|
704 |
if (parts[3]) {
|
|
|
705 |
coords = parts[3];
|
|
|
706 |
} else {
|
|
|
707 |
coords = 0;
|
|
|
708 |
}
|
|
|
709 |
// n = parseFloat(parts[1]);
|
|
|
710 |
// if (parts[2]) { n = n + parseFloat(parts[2])/60; }
|
|
|
711 |
// if (parts[3]) { n = n + parseFloat(parts[3])/3600; }
|
|
|
712 |
}
|
|
|
713 |
|
|
|
714 |
// Retour des données sous forme d'objet
|
|
|
715 |
var Coordonnee = { coordd: coordd,
|
|
|
716 |
coordm: coordm,
|
|
|
717 |
coords: coords,
|
|
|
718 |
coordh: coordh
|
|
|
719 |
};
|
|
|
720 |
return Coordonnee;
|
|
|
721 |
}
|
|
|
722 |
|
|
|
723 |
function validate_dms(latd, latm, lats, latb, lonm, lond, lons, lonb) {
|
|
|
724 |
var valid = 1;
|
|
|
725 |
if (Math.abs(Number(latd)) >= 90)
|
|
|
726 |
valid = 0;
|
|
|
727 |
if (Number(latm) >= 60)
|
|
|
728 |
valid = 0;
|
|
|
729 |
if (Number(lats) >= 60)
|
|
|
730 |
valid = 0;
|
|
|
731 |
if (Math.abs(Number(lond)) >= 180)
|
|
|
732 |
valid = 0;
|
|
|
733 |
if (Number(lonm) >= 60)
|
|
|
734 |
valid = 0;
|
|
|
735 |
if (Number(lons) >= 60)
|
|
|
736 |
valid = 0;
|
|
|
737 |
|
|
|
738 |
return(valid);
|
|
|
739 |
}
|
|
|
740 |
|
|
|
741 |
// convert decimal degrees to dms
|
|
|
742 |
function convertir_en_dms(lat, lon) {
|
|
|
743 |
var latbrg = 1;
|
|
|
744 |
var lonbrg = 2;
|
|
|
745 |
if (lat < 0)
|
|
|
746 |
latbrg = 2
|
|
|
747 |
if (lon < 0)
|
|
|
748 |
lonbrg = 1;
|
|
|
749 |
// LEW: have to round here, else could end up with 60 seconds :-)
|
|
|
750 |
var tlat = Math.abs(lat) + 0.5 / 360000; // round up 0.005 seconds (1/100th)
|
|
|
751 |
var tlon = Math.abs(lon) + 0.5 / 360000;
|
|
|
752 |
|
|
|
753 |
var tlatdm = Math.abs(lat) + 0.5 / 60000; // round up 0.0005 minutes (1/1000th)
|
|
|
754 |
var tlondm = Math.abs(lon) + 0.5 / 60000;
|
|
|
755 |
|
|
|
756 |
var deglat = Math.floor(tlat);
|
|
|
757 |
var t = (tlat - deglat) * 60;
|
|
|
758 |
var minlat = Math.floor(t);
|
|
|
759 |
|
|
|
760 |
var minlatdm = Math.floor((tlatdm - Math.floor(tlatdm)) * 60 * 1000) / 1000;
|
|
|
761 |
|
|
|
762 |
var seclat = (t - minlat) * 60;
|
|
|
763 |
seclat = Math.floor(seclat * 100) / 100; // works in js 1.4
|
|
|
764 |
// seclat = seclat.toFixed(2); // 2 decimal places js 1.5 and later
|
|
|
765 |
|
|
|
766 |
var deglon = Math.floor(tlon);
|
|
|
767 |
|
|
|
768 |
t = (tlon - deglon) * 60;
|
|
|
769 |
var minlon = Math.floor(t);
|
|
|
770 |
|
|
|
771 |
var minlondm = Math.floor((tlondm - Math.floor(tlondm)) * 60 * 1000) / 1000;
|
|
|
772 |
|
|
|
773 |
var seclon = (t - minlon) * 60;
|
|
|
774 |
seclon = Math.floor(seclon * 100) / 100; // js 1.4
|
|
|
775 |
// seclon = seclon.toFixed(2); // js 1.5 and later
|
|
|
776 |
|
|
|
777 |
var latb = '';
|
|
|
778 |
if (latbrg > 0) {
|
|
|
779 |
latb = 'N';// 1 = N (nord)
|
|
|
780 |
} else {
|
|
|
781 |
latb = 'S';// 2 = S (sud)
|
|
|
782 |
}
|
|
|
783 |
var latdms = deglat + "° " + minlat + "' " + seclat + "\"";
|
|
|
784 |
|
|
|
785 |
var lonb = '';
|
|
|
786 |
if (lonbrg > 0) {
|
|
|
787 |
lonb = 'E'; // 2 = E (est)
|
|
|
788 |
} else {
|
|
|
789 |
lonb = 'W';// 1 = W (west)
|
|
|
790 |
}
|
|
|
791 |
var londms = deglon + "° " + minlon + "' " + seclon + "\"";
|
|
|
792 |
|
|
|
793 |
var chaine_latlon_dms = latdms + ' ' + latb + ' ' + londms + ' ' + lonb;
|
|
|
794 |
|
|
|
795 |
// Retour des données sous forme d'objet
|
|
|
796 |
var LatLongDms = { lat: lat,
|
|
|
797 |
lat_degre: Math.floor(tlatdm),
|
|
|
798 |
lat_min: minlatdm,
|
|
|
799 |
lat_s: seclat,
|
|
|
800 |
lat_direction:latb,
|
|
|
801 |
lat_dms:latdms,
|
|
|
802 |
lon: lon,
|
|
|
803 |
lon_degre: Math.floor(tlondm),
|
|
|
804 |
lon_min: minlondm,
|
|
|
805 |
lon_s: seclon,
|
|
|
806 |
lon_direction:lonb,
|
|
|
807 |
lon_dms:londms,
|
|
|
808 |
ll_dms:chaine_latlon_dms
|
|
|
809 |
};
|
|
|
810 |
return LatLongDms;
|
|
|
811 |
}
|
|
|
812 |
|
|
|
813 |
function calculer_coordonnee(lati, longi, ellips, xtm) {
|
|
|
814 |
// Récupération de l'ellipsoide
|
|
|
815 |
var ellipsoid = geo_constants(ellips, xtm);
|
|
|
816 |
var axis = ellipsoid.axis;
|
|
|
817 |
var eccent = ellipsoid.eccentricity;
|
|
|
818 |
var scaleTm = ellipsoid.scaleTm;
|
|
|
819 |
var eastingOrg = ellipsoid.eastingOrg;
|
|
|
820 |
|
|
|
821 |
// Nous parsons la latitude saisie
|
|
|
822 |
var CoordonneeLat = parseCoordinate(lati);
|
|
|
823 |
var latb = '';// vide
|
|
|
824 |
if (CoordonneeLat.coordh != 0) {
|
|
|
825 |
if (CoordonneeLat.coordh > 0) {
|
|
|
826 |
latb = 'N';// 1 = N (nord)
|
|
|
827 |
} else {
|
|
|
828 |
latb = 'S';// 2 = S (sud)
|
|
|
829 |
}
|
|
|
830 |
}
|
|
|
831 |
var latd = CoordonneeLat.coordd;
|
|
|
832 |
var latm = CoordonneeLat.coordm;
|
|
|
833 |
var lats = CoordonneeLat.coords;
|
|
|
834 |
|
|
|
835 |
// Nous parsons la longitude saisie
|
|
|
836 |
var CoordonneeLon = parseCoordinate(longi);
|
|
|
837 |
var lonb = '';// vide
|
|
|
838 |
if (CoordonneeLon.coordh != 0) {
|
|
|
839 |
if (CoordonneeLon.coordh > 0) {
|
|
|
840 |
lonb = 'E'; // 2 = E (est)
|
|
|
841 |
} else {
|
|
|
842 |
lonb = 'W';// 1 = W (west)
|
|
|
843 |
}
|
|
|
844 |
}
|
|
|
845 |
var lond = CoordonneeLon.coordd;
|
|
|
846 |
var lonm = CoordonneeLon.coordm;
|
|
|
847 |
var lons = CoordonneeLon.coords;
|
|
|
848 |
|
|
|
849 |
// cope with blank fields
|
|
|
850 |
if (latd == '' || lond == '') {
|
|
|
851 |
alert("Latitude and longitude degrees must be entered");
|
|
|
852 |
return;
|
|
|
853 |
}
|
|
|
854 |
|
|
|
855 |
// Indication de la direction par défaut pour la latitude et la longitude en France
|
|
|
856 |
if (latb == '') {
|
|
|
857 |
latb = 'N';// 1 = N (Nord)
|
|
|
858 |
}
|
|
|
859 |
if (lonb == '') {
|
|
|
860 |
lonb = 'E';// 2 = E (Est)
|
|
|
861 |
}
|
|
|
862 |
|
|
|
863 |
// Validation
|
|
|
864 |
var valid = validate_dms(latd, latm, lats, latb, lonm, lond, lons, lonb);
|
|
|
865 |
if (valid == 0) {
|
|
|
866 |
alert("Invalid degrees, minutes or seconds");
|
|
|
867 |
return;
|
|
|
868 |
}
|
|
|
869 |
|
|
|
870 |
var lat = Number(latd);
|
|
|
871 |
lat = lat + Number(latm) / 60;
|
|
|
872 |
lat = lat + Number(lats) / 3600;
|
|
|
873 |
if (latb == 'S') { // 2 = S
|
|
|
874 |
lat = lat * -1;
|
|
|
875 |
}
|
|
|
876 |
var lon = Number(lond);
|
|
|
877 |
lon = lon + Number(lonm) / 60;
|
|
|
878 |
lon = lon + Number(lons) / 3600;
|
|
|
879 |
if (lonb == 'W') { // 1 = W
|
|
|
880 |
lon = lon * -1;
|
|
|
881 |
}
|
|
|
882 |
|
|
|
883 |
if (lat >= 84 || lat <= -80) {
|
|
|
884 |
alert("UTM latitudes should be between 84N and 80S\nCalculation will proceed anyway as locator will be valid.");
|
|
|
885 |
}
|
|
|
886 |
|
|
|
887 |
var k0 = scaleTm;
|
|
|
888 |
var latrad = lat * deg2rad;
|
|
|
889 |
var longrad = lon * deg2rad;
|
|
|
890 |
var zonenum = Math.floor((lon + 180) / 6) + 1;
|
|
|
891 |
// @dc (180 - (-70.5))/3 - 76
|
|
|
892 |
if (eastingOrg == 304800.) {
|
|
|
893 |
zonenum = Math.floor((180 - lon) / 3) - 76; // MTM, only in Quebec
|
|
|
894 |
if (zonenum < 3 || zonenum > 10) {
|
|
|
895 |
alert("MTM zone numbers only confirmed for 3-10, province of Quebec\nContinuing anyway");
|
|
|
896 |
}
|
|
|
897 |
}
|
|
|
898 |
|
|
|
899 |
if (lat >= 56.0 && lat < 64.0 && lon >= 3.0 && lon < 12.0 ) {
|
|
|
900 |
zonenum = 32;
|
|
|
901 |
}
|
|
|
902 |
// Zones speciales pour Svalbard
|
|
|
903 |
if( lat >= 72.0 && lat < 84.0 ) {
|
|
|
904 |
if (lon >= 0.0 && lon < 9.0 ) zonenum = 31;
|
|
|
905 |
else if ( lon >= 9.0 && lon < 21.0 ) zonenum = 33;
|
|
|
906 |
else if ( lon >= 21.0 && lon < 33.0 ) zonenum = 35;
|
|
|
907 |
else if ( lon >= 33.0 && lon < 42.0 ) zonenum = 37;
|
|
|
908 |
}
|
|
|
909 |
|
|
|
910 |
var lonorig = (zonenum - 1) * 6 - 180 + 3; //+3 puts origin in middle of zone
|
|
|
911 |
// @dc 180 - (7+76) * 3 - 1.5
|
|
|
912 |
if (eastingOrg == 304800.) {
|
|
|
913 |
lonorig = 180 - (zonenum + 76) * 3 - 1.5;
|
|
|
914 |
}
|
|
|
915 |
var lonorigrad = lonorig * deg2rad;
|
|
|
916 |
|
|
|
917 |
//Récupération de la lettre du fuseau xTM
|
|
|
918 |
var letter = get_zoneletter(lat);
|
|
|
919 |
|
|
|
920 |
// Calcul xTM
|
|
|
921 |
var eccPrimeSquared = (eccent) / (1 - eccent);
|
|
|
922 |
var N = axis / Math.sqrt(1 - eccent * Math.sin(latrad) * Math.sin(latrad));
|
|
|
923 |
var T = Math.tan(latrad) * Math.tan(latrad);
|
|
|
924 |
var C = eccPrimeSquared * Math.cos(latrad) * Math.cos(latrad);
|
|
|
925 |
var A = Math.cos(latrad) * (longrad - lonorigrad);
|
|
|
926 |
var M = axis * ((1 - eccent / 4 - 3 * eccent * eccent / 64 - 5 * eccent * eccent * eccent / 256) * latrad - (3 * eccent / 8 + 3 * eccent * eccent / 32 + 45 * eccent * eccent *eccent / 1024) * Math.sin(2 * latrad) + (15 * eccent * eccent / 256 + 45 * eccent * eccent * eccent / 1024) * Math.sin(4 * latrad) - (35 * eccent * eccent * eccent / 3072) * Math.sin(6 * latrad));
|
|
|
927 |
|
|
|
928 |
var easting = (k0 * N * (A + (1 - T + C) * A * A * A / 6 + (5 - 18 * T + T * T + 72 * C - 58 * eccPrimeSquared) * A * A * A * A * A / 120) + eastingOrg);
|
|
|
929 |
var northing = (k0 * (M + N * Math.tan(latrad) * (A * A / 2 + (5 - T + 9 * C + 4 * C * C) * A * A * A * A / 24 + (61 - 58 * T + T * T + 600 * C - 330 * eccPrimeSquared) * A * A * A * A * A * A / 720)));
|
|
|
930 |
if (lat < 0) {
|
|
|
931 |
northing += 10000000.0; //10000000 meter offset for southern hemisphere
|
|
|
932 |
}
|
|
|
933 |
|
|
|
934 |
// xTM
|
|
|
935 |
// Arrondi au nombre supérieur
|
|
|
936 |
// alert("easting = " + easting);
|
|
|
937 |
preciseEasting = easting;
|
|
|
938 |
easting = Math.floor(easting + .5);
|
|
|
939 |
// alert("easting = " + easting);
|
|
|
940 |
// alert("northing = " + northing);
|
|
|
941 |
preciseNorthing = northing;
|
|
|
942 |
northing = Math.floor(northing + .5);
|
|
|
943 |
// alert("northing = " + northing);
|
|
|
944 |
var chaine_xtm = '';
|
|
|
945 |
var x_tm = '';
|
|
|
946 |
if (eastingOrg == 304800.) {
|
|
|
947 |
chaine_xtm = zonenum + ' ' + easting + 'm E ' + northing + 'm N';
|
|
|
948 |
x_tm = 'MTM';
|
|
|
949 |
} else {
|
|
|
950 |
chaine_xtm = zonenum + letter + ' ' + easting + 'm E ' + northing + 'm N';
|
|
|
951 |
x_tm = 'UTM';
|
|
|
952 |
}
|
|
|
953 |
|
|
|
954 |
// Latitude/Longitude
|
|
|
955 |
var chaine_latlon = lat + ' ' + latb + ' ' + lon + ' ' + lonb;
|
|
|
956 |
var LatLongDms = convertir_en_dms(lat,lon);
|
|
|
957 |
|
|
|
958 |
// Retour des données sous forme d'objet
|
|
|
959 |
var Coordonnee = { xtm: x_tm,
|
|
|
960 |
nord: northing,
|
|
|
961 |
est: easting,
|
|
|
962 |
zone_numero: zonenum,
|
|
|
963 |
zone_lettre: letter,
|
|
|
964 |
xtm_chaine: chaine_xtm,
|
|
|
965 |
latitude:lat,
|
|
|
966 |
longitude:lon,
|
|
|
967 |
ll_chaine: chaine_latlon,
|
|
|
968 |
latitude_dms:LatLongDms.lat_dms,
|
|
|
969 |
longitude_dms:LatLongDms.lon_dms,
|
|
|
970 |
ll_chaine_dms: LatLongDms.ll_dms
|
|
|
971 |
};
|
|
|
972 |
return Coordonnee;
|
|
|
973 |
}
|
|
|
974 |
//]]>
|
|
|
975 |
|
|
|
976 |
</script>
|
|
|
977 |
|
|
|
978 |
<?
|
|
|
979 |
}
|
|
|
980 |
?>
|
|
|
981 |
|
|
|
982 |
|