11,7 → 11,7 |
<form id="addr" action="#" method="get" onsubmit="return showAddress(this);" style="float:left;"> |
<ul style="list-style-type:none;margin:0;padding:0;"> |
<li> |
<label for="lieu">Selectionnez la commune la plus proche de votre station :</label> |
<label for="lieu">Selectionnez la commune la plus proche de votre station :</label> |
<input id="lieu" type="text" size="30" name="lieu" value=""/> |
<input type="submit" value="Localiser" /> |
</li> |
27,23 → 27,23 |
<?php |
|
//Récupération des stations existantes |
|
|
//FONCTIONNEMENT_TESTE_ET_OK |
|
|
|
|
// les stations de l'observateur : |
|
|
$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"); |
|
|
|
|
|
|
$nb_requete_stations = @mysql_num_rows($requete_stations); |
|
|
|
|
|
|
|
|
|
|
|
$stations=array(); |
|
|
51,7 → 51,7 |
echo "</br>\n"; |
echo "<b>Vos stations enregistrées (Cliquez sur le nom de la station pour ajouter de nouvelles espèces) :</b> <br>"; |
|
|
|
?> |
<form name="form_station" method="post" action="<?= $url_page ?>"> |
<input type="hidden" name="etape" value="<?= $etape ?>"> |
58,115 → 58,112 |
<input type="hidden" name="<?= $provenance ?>" value="1"> |
<input type="hidden" name="<?= $provenance ?>etape" value="<?= $etape ?>"> |
<?php |
|
|
echo "<table id='tabstations'>"; |
|
|
|
|
|
|
if ($nb_requete_stations > 0) { |
|
|
// Liste des stations |
|
|
|
// Liste des stations |
|
$MOIS_EN_COURS = '09'; |
$MOIS_RENTREE = '09'; // FIXME : quelle difference avec la variable precedente ? |
$mois = date('m'); |
$annee = date('Y'); |
|
|
//$annee=$annee+1; |
/* |
/* |
if ($mois > $MOIS_RENTREE) { |
$annee = $annee+1; |
} |
*/ |
|
|
while ($station = mysql_fetch_assoc($requete_stations)) { |
|
|
|
|
$stations [] = $station; |
echo "<tr>"; |
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>"; |
|
|
|
|
|
|
// echo "<td>".$station['STATION_LATITUDE']."</td>"; |
//echo "<td>".$station['STATION_LONGITUDE']."</td>"; |
//echo "<td>".$station['STATION_ALTITUDE']."</td>"; |
//echo "<td>"."<input type=\"submit\" class=\"submit\" name=\"".$station['STATION_ID']."\" value=\"Choisir cette station\"></td>"; |
|
|
// A t-on des mesures associe a cette station ? Si oui on ne peut pas la modifier ni supprimer |
|
|
$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']); |
$nb_requete_mesure = mysql_num_rows($requete_mesure); |
|
|
$obs_existe=false; |
|
if ($nb_requete_mesure == 0) { // Pas de mesure on peut modifier |
echo "<td>"."<input type=\"submit\" class=\"submit\" name=\"".$station['STATION_ID']."\" value=\"Modifier\"></td>"; |
|
if ($nb_requete_mesure == 0) { // Pas de mesure on peut modifier |
echo "<td>"."<input type=\"submit\" class=\"submit\" name=\"".$station['STATION_ID']."\" value=\"Modifier\"></td>"; |
} |
else { |
$obs_existe=true; |
echo "<td></td>"; |
} |
|
|
echo "</tr>"; |
|
|
|
|
|
$requete_obs_annee = mysql_query("select distinct SEQUENCE.SEQUENCE_ID, ESPECE_NOM_VERNACULAIRE, STATION_NOM from SEQUENCE,ESPECE,STATION,MESURE ". |
"where ESPECE.ESPECE_ID=SEQUENCE.ESPECE_ID". |
" and MESURE.SEQUENCE_ID=SEQUENCE.SEQUENCE_ID". |
" and SEQUENCE.PARTICIPANT_ID=".$_SESSION['participant']. |
" and STATION.STATION_ID=". $station['STATION_ID'] . |
" and STATION.STATION_ID=SEQUENCE.STATION_ID". |
" AND MESURE_DATE!='0000-00-00' and MESURE_DATE>'".($annee-1).($mois)."-01'". |
" and MESURE_DATE<'".($annee).($mois)."-01'". |
" and STATION.STATION_ID=SEQUENCE.STATION_ID". |
" AND MESURE_DATE!='0000-00-00' and MESURE_DATE>'".($annee-2).'-'.($mois)."-01'". |
" and MESURE_DATE<'".($annee).'-'.($mois)."-01'". |
" order by STATION_NOM, ESPECE_NOM_VERNACULAIRE"); |
|
$nb_requete_obs_annee = mysql_num_rows($requete_obs_annee); |
|
|
|
$nb_requete_obs_annee = mysql_num_rows($requete_obs_annee); |
|
if (($nb_requete_obs_annee == 0) && ($obs_existe)) { |
echo "<tr>"; |
echo "<td>Observations archivées </td>"; |
echo "</tr>"; |
|
|
} |
|
|
while ($obs = mysql_fetch_assoc($requete_obs_annee)) { |
echo "<tr>"; |
echo "<td>Espèce : <a title=\"Ajouter/modifier des observations\" href=\"".$url_page."&sequence_id=".$obs['SEQUENCE_ID']."\">".$obs['ESPECE_NOM_VERNACULAIRE']."</a></td>"; |
echo "</tr>"; |
} |
|
|
echo "<tr>"; |
echo "</tr>"; |
echo "<tr>"; |
echo "</tr>"; |
|
|
} |
|
|
|
|
|
|
// On retient la premiere station pour centrage |
|
|
$init_lat=$stations[0]['STATION_LATITUDE']; |
$init_lon=$stations[0]['STATION_LONGITUDE']; |
|
|
|
|
} |
else { |
|
|
// Pas de stations : affichage centre carte france |
// FONCTIONNEMENT_TESTE_ET_OK |
|
|
|
|
$init_lat=45.545; |
$init_lon=3.249722; |
|
|
echo "<td><strong>Pas de station enregistrée</strong></td>"; |
echo "<td></td>"; |
echo "<td></td>"; |
174,23 → 171,23 |
echo "<td></td>"; |
echo "<td></td>"; |
echo "</tr>"; |
|
|
|
|
|
|
} |
|
|
echo "</table>"; |
echo "</form>"; |
|
|
|
|
|
|
|
|
//$espece_encours=$obs[1]; |
$commune_encours=$obs[2]; |
|
|
|
|
|
/***** Selection des stations *****/ |
|
//Affichage des éventuelles erreurs |
209,10 → 206,10 |
<input id="ll_altitude" name="ll_altitude" type="hidden" value="" /> |
<input id="form_coordonnee_valider" name="valid_station" class="submit" type="hidden" value="Poursuivre" /> |
<input type="hidden" name="etape" value="3"> |
<input type="hidden" name="provenance" value="<?= $provenance ?>"> |
<input type="hidden" name="provenance" value="<?= $provenance ?>"> |
</li> |
</ul> |
|
|
</form> |
|
|
232,7 → 229,7 |
<?php |
} |
|
|
|
// Centrage initial : premiere station ou ville d'inscription |
|
echo "<script type=\"text/javascript\">"; |
239,15 → 236,15 |
echo "\n//<![CDATA[\n"; |
echo "var init_lat = ".$init_lat.";\n"; |
echo "var init_long = ".$init_lon.";\n"; |
|
|
?> |
|
|
var largeur_carte = 690; |
var haureur_retrait = 330; |
|
|
var init_zoom = 10; |
|
|
// Contient la carte GoogleMap |
var map; |
// Contient l'utilitaire permettant de trouver une adresse. |
291,10 → 288,10 |
map.enableScrollWheelZoom(); |
// Zoom avec le double clic de la souris |
map.enableDoubleClickZoom(); |
|
|
// Création du GéoCoder |
EfGeocoder = new GClientGeocoder() ; |
|
|
// Icone station enregistrees (vert) |
icon = new GIcon(); |
icon.image = "http://www.google.com/mapfiles/ms/micons/green-dot.png"; |
304,8 → 301,8 |
icon.iconAnchor = new GPoint(16, 34); |
// Pour affichage infobulle |
icon.infoWindowAnchor = new GPoint(5,1); |
|
|
|
// Icone nouvelle station (rouge) ou station en modification |
Nicon = new GIcon(); |
Nicon.image = "http://www.google.com/mapfiles/ms/micons/red-dot.png"; |
317,8 → 314,8 |
Nicon.infoWindowAnchor = new GPoint(5,1); |
|
|
|
|
|
// Creates a marker at the given point with the given number label |
|
function createMarker(point, text, altitude, envir) { |
327,19 → 324,19 |
GEvent.addListener(marker, "click", function() { |
map.setCenter(marker.getPoint()); |
afficherInfo(marker.getPoint()); |
afficherMasque(marker,text,altitude,envir); |
afficherMasque(marker,text,altitude,envir); |
}); |
return marker; |
} |
|
// Affichage des stations presentes TODO : et si plusieurs stations au meme endroit ? Utiliser cluster ? |
|
// Affichage des stations presentes TODO : et si plusieurs stations au meme endroit ? Utiliser cluster ? |
|
<? foreach($stations as $station) { ?> |
var point = new GLatLng(<?= $station['STATION_LATITUDE'] ?>, <?= $station['STATION_LONGITUDE'] ?>); |
map.addOverlay(createMarker(point, "<?= $station['STATION_NOM'] ?>","<?= $station['STATION_ALTITUDE'] ?>", "<?= $station['ENVIRONNEMENT_NOM'] ?>")); |
<? } ?> |
|
|
|
|
} |
} |
|
381,16 → 378,16 |
GEvent.addListener(addrpnt,'dragend',function() { |
map.setCenter(addrpnt.getPoint()); |
afficherInfo(addrpnt.getPoint()); |
afficherMasque(addrpnt,""); |
|
afficherMasque(addrpnt,""); |
|
}) ; |
|
|
GEvent.addListener(addrpnt, "click", function() { |
map.setCenter(addrpnt.getPoint()); |
afficherInfo(addrpnt.getPoint()); |
afficherMasque(addrpnt,""); |
afficherMasque(addrpnt,""); |
}); |
|
|
afficherInfo(position); |
} |
|
397,22 → 394,22 |
// Masque de mise a jour station : |
|
function afficherMasque(position,nom,altitude,envir) { |
|
|
// On recupere les données du formulaire (caché) , notamment pour traiter simplement l'appel asynchrone de recup altitude |
|
|
var html = "<table>"; |
if (nom.length>0) { |
html = html + "<tr><td>Station :</td> <td>" + nom + "</td> </tr>"; |
|
|
|
|
|
|
|
|
html = html + "<tr><td>Environnement :</td> <td>" + envir + "</td> </tr>"; |
|
|
html = html + "</td></tr>"; |
|
|
|
|
|
|
} |
else { |
html = html + "<tr><td>Station</td> <td><input type='text' id='nom_station' value=''/> </td> </tr>"; |
422,18 → 419,18 |
|
html = html + "<tr><td>Environnement :</td>"; |
html = html + "<td><select id='environnement_id' name='environnement'>"; |
|
|
<? while ($env = mysql_fetch_row($requete_environnement)) { ?> |
html = html + "<option value='<?= $env[0] ?>'><?= $env[1] ?>"; |
<? } ?> |
|
|
html = html + "</select></td></tr>"; |
|
} |
|
|
|
|
|
} |
|
|
|
|
html = html + "<tr><td>Latitude :</td> <td>" +document.getElementById('ll_latitude').value + "</td> </tr>" ; |
html = html + "<tr><td>Latitude :</td> <td>" +document.getElementById('ll_latitude').value + "</td> </tr>" ; |
html = html + "<tr><td>Longitude :</td> <td>" + document.getElementById('ll_longitude').value + "</td> </tr>"; |
446,19 → 443,19 |
if (nom.length==0) { |
html = html + "<tr><td></td><td><input type='button' value='Enregistrer' onclick='saveData()'/></td></tr>"; |
} |
|
|
|
|
position.openInfoWindow(html); |
|
|
} |
|
|
// Sauvegarde station |
// Sauvegarde station |
|
// TODO : Retrouver marker depuis lat/lon |
|
function saveData() { |
|
|
var nom_station = escape(document.getElementById("nom_station").value); |
var lat_station = document.getElementById("ll_latitude").value; |
var lon_station = document.getElementById("ll_longitude").value; |
467,7 → 464,7 |
|
var url = "modules/observations/sauvegarde_station.php?nom_station=" + nom_station + "&action=C" + "&lat_station=" + lat_station + |
"&lon_station=" + lon_station + "&environnement_id=" + environnement_id + "&alt_station=" + alt_station + "&participant_id=<?= $_SESSION['participant'] ?>"; |
|
|
GDownloadUrl(url, function(data, responseCode) { |
if (responseCode == 200 && data.length <= 1) { |
window.location = "<?= $url_page ?>"; |
484,7 → 481,7 |
var ellipsoid = 21;// 21 = WGS-84 (voir geo_constants) |
var xtm = 0;// 0 = UTM et 1= MTM |
var Coordonnee = calculer_coordonnee(lati, longi, ellipsoid, xtm); |
|
|
// Nous affichons des informations. |
document.getElementById('ll_latitude').value = Coordonnee.latitude.toFixed(4); |
document.getElementById('ll_longitude').value = Coordonnee.longitude.toFixed(4); |
495,19 → 492,20 |
var script = document.createElement('script'); |
document.body.appendChild(script); |
script.src = 'http://ws.geonames.org/' + "srtm3" + 'JSON?lat=' + lati + '&lng=' + longi + '&callback=GetAltitude'; |
|
|
|
|
} |
|
function GetAltitude(result ) { |
document.getElementById('ll_altitude').value = result.srtm3; |
} |
} |
|
window.onload = load |
window.onunload = GUnload |
|
/* A supprimer ? */ |
|
/* Source : Code provenant du site http://pages.globetrotter.net/roule/utmgoogle.htm |
/* Source : Code provenant du site http://pages.globetrotter.net/roule/utmgoogle.htm |
*/ |
|
var deg2rad = Math.PI / 180; |
527,7 → 525,7 |
* dx: Change in x between "from" and "to" datum. (double) |
* dy: Change in y between "from" and "to" datum. (double) |
* dz: Change in z between "from" and "to" datum. (double) |
* |
* |
* Paramêtres : |
* from : l'objet GeodesiquePosition à transformer (contient latitute, longitude et hauteur) |
* from_a : le demi grand axe (=a) de l'ellipsoïde utilisé pour la position géodésique contenu dans l'objet "from". |
548,22 → 546,22 |
// "a divided by b" |
var adb = 1.0 / (1.0 - from_f); |
var dlat, dlon, dh; |
|
|
var rn = from_a / Math.sqrt (1.0 - from_esq * ssqlat); |
var rm = from_a * (1. - from_esq) / Math.pow ((1.0 - from_esq * ssqlat), 1.5); |
|
|
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); |
|
|
dlon = (-dx * slon + dy * clon) / ((rn + from.h) * clat); |
|
|
dh = (dx * clat * clon) + (dy * clat * slon) + (dz * slat) - (da * (from_a / rn)) + ((df * rn * ssqlat) / adb); |
|
|
// Retour des données sous forme d'objet |
var GeodeticPosition = { lon: from.lon + dlon, |
lat: from.lat + dlat, |
h: from.h + dh |
}; |
|
|
return GeodeticPosition; |
} |
|
600,13 → 598,13 |
ellipsoid_axis[19] = 6378145; ellipsoid_eccen[19] = 0.006694542; // wgs-66 |
ellipsoid_axis[20] = 6378135; ellipsoid_eccen[20] = 0.006694318; // wgs-72 |
ellipsoid_axis[21] = 6378137; ellipsoid_eccen[21] = 0.00669438; //wgs-84 (et NAD83 : pourquoi mis avec WGS84 ?) |
|
|
if (ellipsoid == 0) { |
ellipsoid = 22; |
} |
|
|
--ellipsoid; // table indexed differently |
|
|
if (xtm == 1) { |
// WAS: if (ellipsoid > 22) |
scaleTm = 0.9999; |
659,7 → 657,7 |
var coordm; |
var coords; |
var coordh = 0; |
|
|
if (coordinate.search(/(^ *-|[WOS])/i) >= 0) { |
coordh = -1; |
} |
666,14 → 664,14 |
if (coordinate.search(/(^ *\+|[NE])/i) >= 0) { |
coordh = 1; |
} |
|
|
// if (coordinate.search(/[EW]/i) >= 0 && !type) { type = 'lon'; } |
// if (coordinate.search(/[NS]/i) >= 0 && !type) { type = 'lat'; } |
|
|
coordinate = coordinate.replace(/,/g, '.'); // french commas |
// not sure really needed. |
coordinate = coordinate.replace(/[NESWO+\-]/gi,' '); // add also: °, ', " -- or replace everything that is not a number or a dot |
|
|
// alert("coordinate = " + coordinate); |
if (coordinate.search(/[0-9]/i) < 0) { |
alert("Can't parse input field"); |
712,7 → 710,7 |
// if (parts[2]) { n = n + parseFloat(parts[2])/60; } |
// if (parts[3]) { n = n + parseFloat(parts[3])/3600; } |
} |
|
|
// Retour des données sous forme d'objet |
var Coordonnee = { coordd: coordd, |
coordm: coordm, |
751,25 → 749,25 |
// LEW: have to round here, else could end up with 60 seconds :-) |
var tlat = Math.abs(lat) + 0.5 / 360000; // round up 0.005 seconds (1/100th) |
var tlon = Math.abs(lon) + 0.5 / 360000; |
|
|
var tlatdm = Math.abs(lat) + 0.5 / 60000; // round up 0.0005 minutes (1/1000th) |
var tlondm = Math.abs(lon) + 0.5 / 60000; |
|
|
var deglat = Math.floor(tlat); |
var t = (tlat - deglat) * 60; |
var minlat = Math.floor(t); |
|
|
var minlatdm = Math.floor((tlatdm - Math.floor(tlatdm)) * 60 * 1000) / 1000; |
|
|
var seclat = (t - minlat) * 60; |
seclat = Math.floor(seclat * 100) / 100; // works in js 1.4 |
// seclat = seclat.toFixed(2); // 2 decimal places js 1.5 and later |
|
|
var deglon = Math.floor(tlon); |
|
|
t = (tlon - deglon) * 60; |
var minlon = Math.floor(t); |
|
|
var minlondm = Math.floor((tlondm - Math.floor(tlondm)) * 60 * 1000) / 1000; |
|
var seclon = (t - minlon) * 60; |
791,9 → 789,9 |
lonb = 'W';// 1 = W (west) |
} |
var londms = deglon + "° " + minlon + "' " + seclon + "\""; |
|
|
var chaine_latlon_dms = latdms + ' ' + latb + ' ' + londms + ' ' + lonb; |
|
|
// Retour des données sous forme d'objet |
var LatLongDms = { lat: lat, |
lat_degre: Math.floor(tlatdm), |
868,7 → 866,7 |
alert("Invalid degrees, minutes or seconds"); |
return; |
} |
|
|
var lat = Number(latd); |
lat = lat + Number(latm) / 60; |
lat = lat + Number(lats) / 3600; |
932,7 → 930,7 |
if (lat < 0) { |
northing += 10000000.0; //10000000 meter offset for southern hemisphere |
} |
|
|
// xTM |
// Arrondi au nombre supérieur |
// alert("easting = " + easting); |
956,7 → 954,7 |
// Latitude/Longitude |
var chaine_latlon = lat + ' ' + latb + ' ' + lon + ' ' + lonb; |
var LatLongDms = convertir_en_dms(lat,lon); |
|
|
// Retour des données sous forme d'objet |
var Coordonnee = { xtm: x_tm, |
nord: northing, |