1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99
|
<?php
// **************************************************************
// * LIEUX *
// * COORDONNEES GEOGRAPHIQUES *
// **************************************************************
// COORDONNEES - LONGITUDE/LATITUDE : Degres -> Decimales
function lieu_coord_DegreToDecimal($Degre,$Minute,$Seconde,$Direction) {
// latitude : $Direction = 1 (N) ou -1 (S)
// longitude : $Direction = 1 (E) ou -1 (W)
// -------------
require_once($_SERVER['DOCUMENT_ROOT'].'/_connexion/_connexion.php');
include($_SERVER['DOCUMENT_ROOT'].'/fonctions/config_generale.php');
// -------------
$coord_Decimales = $Degre + ($Minute/60) + ($Seconde/3600);
if($Direction=='S' || $Direction=='W') {
$coord_Decimales = $coord_Decimales*(-1);
}
// -------------
return $coord_Decimales;
}
// COORDONNEES - LONGITUDE/LATITUDE : Decimales -> Degres
function lieu_coord_DecimalToDegre($coord_Decimale) {
$coord_Decimale = str_replace(',','.',$coord_Decimale); // (remplace virgule par point)
if(is_numeric($coord_Decimale))
{
// Degre : $coord_Degres[0]
// Minute : $coord_Degres[1]
// Seconde $coord_Degres[2]
// Direction : $coord_Degres[3] (1 ou -1)
// -------------
require_once($_SERVER['DOCUMENT_ROOT'].'/_connexion/_connexion.php');
include($_SERVER['DOCUMENT_ROOT'].'/fonctions/config_generale.php');
// -------------
// Direction
if($coord_Decimale<0) {
$coord_Degres[3] = -1;
$coord_DecimaleTemp = $coord_Decimale * (-1);
} else {
$coord_Degres[3] = 1;
$coord_DecimaleTemp = $coord_Decimale;
}
// -------------
// Degres
$coord_Degres[0] = floor($coord_DecimaleTemp);
// -------------
// Minutes
$coord_DecimaleTemp = 60.0 * ($coord_DecimaleTemp - $coord_Degres[0]);
$coord_Degres[1] = floor($coord_DecimaleTemp);
// -------------
// Secondes
$coord_DecimaleTemp = 60.0 * ($coord_DecimaleTemp - $coord_Degres[1]);
$coord_Degres[2] = floor($coord_DecimaleTemp);
// -------------
return $coord_Degres; // (array)
}
}
// COORDONNEES - LONGITUDE/LATITUDE : Decimales -> Degres° Minute' Seconde" Direction
function lieu_coord_DecimalToDMSD($coord_Decimale, $coord_type) {
// $coord_type = 'lon' (longitude) ou 'lat' (latitude)
$coord_Decimale = str_replace(',','.',$coord_Decimale); // (remplace virgule par point)
if(is_numeric($coord_Decimale))
{
require_once($_SERVER['DOCUMENT_ROOT'].'/_connexion/_connexion.php');
include($_SERVER['DOCUMENT_ROOT'].'/fonctions/config_generale.php');
// -------------
$coord_Degres = lieu_coord_DecimalToDegre($coord_Decimale);
$coord_Deg = $coord_Degres[0];
$coord_Min = $coord_Degres[1];
$coord_Sec = $coord_Degres[2];
$coord_Dir = $coord_Degres[3];
$coord_DMSD = $coord_Deg.'° '.$coord_Min.'\' '.$coord_Sec.'" ';
if($coord_type == 'lat') {
if($coord_Dir==1) { $coord_DMSD .= 'N'; }
else { $coord_DMSD .= 'S'; }
} elseif($coord_type == 'lon') {
if($coord_Dir==1) { $coord_DMSD .= 'E'; }
else { $coord_DMSD .= 'W'; }
}
// -------------
return $coord_DMSD;
}
}
// COORDONNEES - LONGITUDE/LATITUDE : Decimales -> Radians
function lieu_coord_DecimalToRadian($coord_Decimale) {
$coord_Decimale = str_replace(',','.',$coord_Decimale); // (remplace virgule par point)
if(is_numeric($coord_Decimale))
{
// -------------
require_once($_SERVER['DOCUMENT_ROOT'].'/_connexion/_connexion.php');
include($_SERVER['DOCUMENT_ROOT'].'/fonctions/config_generale.php');
// -------------
$coord_Radians = $coord_Decimale * pi() / 180;
// -------------
return $coord_Radians;
}
}
// **************************************************************
?> |
Partager