Merge des modifications sur l'ancien webservice
This commit is contained in:
commit
a560b47d9c
@ -3775,6 +3775,10 @@ print_r($tabUpdate,true).EOL
|
||||
$repClient='aggm mederic ';
|
||||
$ficClient='surveillanceBodacc_SURBODPRDFTSCRR';
|
||||
$numAbo=$ref='';
|
||||
} elseif (strtolower($login)=='cpcambr13' || strtolower($login)=='cpcambr14') {
|
||||
$repClient='cpcam des bouches du rhône';
|
||||
$ficClient='diffusionBodacc_DIFBODPRDMAICPCAM13';
|
||||
$numAbo=$ref='';
|
||||
} else {
|
||||
$repClient='cnasea';
|
||||
$ficClient='surveillanceBodacc_SURBODTSTFTSCNASEA';
|
||||
|
@ -15,7 +15,7 @@ $tabEvenInsee=array(
|
||||
'iFF'=>'Fermeture de l\'établissement entraînant la fermeture de l\'entreprise',
|
||||
'iTC'=>'Création de l\'établissement dans le cadre d\'un transfert',
|
||||
'iTR'=>'Réactivation de l\'établissement dans le cadre d\'un transfert',
|
||||
'iTO'=>'Modification simple ou de moyens de production sur l\'établissement dans le cadre d\'un transfert',
|
||||
'iT0'=>'Modification simple ou de moyens de production sur l\'établissement dans le cadre d\'un transfert',
|
||||
'iTA'=>'Activation économique de l\'établissement par adjonction de moyens de production dans le cadre d\'un transfert',
|
||||
'iTD'=>'Désactivation économique de l\'établissement par suppression de moyens de production dans le cadre d\'un transfert',
|
||||
'iTF'=>'Fermeture de l\'établissement dans le cadre d\'un transfert',
|
||||
@ -33,7 +33,7 @@ $tabEvenInsee=array(
|
||||
'iMNP'=>'Etablissement présumé fermé (retour de courrier en NPAI)',
|
||||
// Décret n°2010-1042 du 01/09/2010 relatif à l'inscription au registre du commerce et des sociétés et au répertoire national mentionné à l'article R. 123-220 du code de commerce
|
||||
// Codification provisoire à changer dans l'attente de l'INSEE
|
||||
'iRCS'=>'Suppression du SIREN suite au refus d\'inscription au Registre du Commerce et des Sociétés',
|
||||
'i810'=>'Suppression du SIREN suite au refus d\'inscription au Registre du Commerce et des Sociétés', // Anciennement iRCS
|
||||
// Nouveaux évènements Sirene3 de la quotidienne Insee
|
||||
'i110'=>'Création de l\'entreprise',
|
||||
'i120'=>'Réactivation de l\'entreprise',
|
||||
@ -2079,6 +2079,7 @@ public function rechercheDirOld($nom, $prenom='', $fonction='', $dateNaiss='', $
|
||||
fclose($fp);
|
||||
$tab['latitude']=$mMap->latitudeDec;
|
||||
$tab['longitude']=$mMap->longitudeDec;
|
||||
$tab['altitude']=$mMap->altitude;
|
||||
$tab['precis']=$mMap->precision;
|
||||
$timer['geoCodage']=microtime(true);
|
||||
|
||||
@ -2367,6 +2368,7 @@ print_r($tabTmp, true));
|
||||
|
||||
'GeoLat'=>$tab['latitude'],
|
||||
'GeoLon'=>$tab['longitude'],
|
||||
'GeoAlt'=>$tab['altitude'],
|
||||
'GeoPrecis'=>$tab['precis'],
|
||||
|
||||
'TvaNumero'=>$vatNumber,
|
||||
@ -5699,9 +5701,9 @@ ORDER BY a.dateJugement DESC".EOL.EOL.print_r($collecte,true));*/
|
||||
public function getSiretAssoc($siren, $nic, $lien=0) {
|
||||
$tabRet=array();
|
||||
$ret=$this->iDbInsee->select('insee_even',
|
||||
'insSIREN, insNIC, insDATEVE, insEVE, insAPET700, insSIEGE, insLIBCOM, insL1_NOMEN, insL2_COMP, insL4_VOIE, insL3_CADR, insL5_DISP, insL6_POST, insCODPOS, insL7_ETRG, insDEPCOM, insCODEVOIE, insNICTRAN, insSIRETPS, insDATEMAJ, idFlux, insSIRETASS, insEVE, insDESTINAT, insTYPETAB, insORIGINE',
|
||||
"insSIREN=$siren AND insNIC<>$nic AND insEVE IN ('510','520','530','540') AND insDATEMAJ IN (
|
||||
SELECT insDATEMAJ FROM insee_even WHERE insSIREN=$siren AND insNIC=$nic AND insEVE IN ('510','520','530','540') )", false, MYSQL_ASSOC);
|
||||
'insSIREN, insNIC, insDATEVE, insEVE, insAPET700, insSIEGE, insLIBCOM, insL1_NOMEN, insL2_COMP, insL4_VOIE, insL3_CADR, insL5_DISP, insL6_POST, insCODPOS, insL7_ETRG, insDEPCOM, insCODEVOIE, insNICTRAN, insSIRETPS, insDATEMAJ, idFlux, insSIRETASS, insDESTINAT, insTYPETAB, insORIGINE, insTRAN, insNOMEN, insENSEIGNE, insNUMVOIE, insINDREP, insTYPVOIE, insLIBVOIE',
|
||||
"insSIREN=$siren AND insNIC<>$nic AND (insEVE IN ('510','520','530','540') OR insEVE LIKE 'T%') AND insDATEMAJ IN (
|
||||
SELECT insDATEMAJ FROM insee_even WHERE insSIREN=$siren AND insNIC=$nic AND (insEVE IN ('510','520','530','540') OR insEVE LIKE 'T%') )", false, MYSQL_ASSOC);
|
||||
foreach ($ret as $iRet=>$tabEve) {
|
||||
switch($tabEve['insTYPETAB']*1) {
|
||||
case 8:
|
||||
@ -5719,22 +5721,32 @@ ORDER BY a.dateJugement DESC".EOL.EOL.print_r($collecte,true));*/
|
||||
$typeLien='suc';
|
||||
break;
|
||||
default:
|
||||
if ($lien<>0) continue;
|
||||
$typeLien='ind';
|
||||
break;
|
||||
switch($tabEve['insTRAN']) {
|
||||
case 'D': if ($lien==1) continue; $typeLien='pre'; break(2);
|
||||
case 'A': if ($lien==-1) continue; $typeLien='suc'; break(2);
|
||||
default : if ($lien<>0) continue; $typeLien='ind'; break;
|
||||
}
|
||||
}
|
||||
|
||||
$adr1=$tabEve['insL1_NOMEN'];
|
||||
if ($adr1==NULL) $adr1=$tabEve['insNOMEN'];
|
||||
$adr2=$tabEve['insL2_COMP'];
|
||||
if ($adr2==NULL) $adr2=$tabEve['insENSEIGNE'];
|
||||
$adr4=$tabEve['insL4_VOIE'];
|
||||
if ($adr4==NULL) $adr4=preg_replace('/ +/',' ', $tabEve['insNUMVOIE'].' '.$tabEve['insINDREP'].' '.$tabEve['insTYPVOIE'].' '.$tabEve['insLIBVOIE']);
|
||||
|
||||
$tabRet[$typeLien]=array('siren' => $tabEve['insSIREN'],
|
||||
'nic' => $tabEve['insNIC'],
|
||||
'apeEtab' => $tabEve['insAPET700'],
|
||||
'codeEve' => $tabEve['insEVE'],
|
||||
'dateEve' => $tabEve['insDATEVE'],
|
||||
'adrL1' => $tabEve['insL1_NOMEN'],
|
||||
'adrL2' => $tabEve['insL2_COMP'],
|
||||
'adrL3' => prepareString($tabEve['insL3_CADR']),
|
||||
'adrL4' => $tabEve['insL4_VOIE'],
|
||||
'adrL5' => $tabEve['insL5_DISP'],
|
||||
'adrL6' => $tabEve['insL6_POST'],
|
||||
'adrL7' => $tabEve['insL7_ETRG'],
|
||||
'adrL1' => trim($adr1),
|
||||
'adrL2' => trim($adr2),
|
||||
'adrL3' => trim(prepareString($tabEve['insL3_CADR'])),
|
||||
'adrL4' => trim($adr4),
|
||||
'adrL5' => trim($tabEve['insL5_DISP']),
|
||||
'adrL6' => trim($tabEve['insL6_POST']),
|
||||
'adrL7' => trim($tabEve['insL7_ETRG']),
|
||||
'depCom' => $tabEve['insDEPCOM'],
|
||||
'rivoli' => $tabEve['insCODEVOIE'],
|
||||
'siege' => $tabEve['insSIEGE'],
|
||||
|
@ -138,8 +138,13 @@ class MArtisanat {
|
||||
$this->libErreur='Erreur Siren $sirenLu<>$siren !';
|
||||
return false;
|
||||
}
|
||||
} elseif (preg_match('/<span class="rouge">aucune entreprise ne correspond à vos critères de recherche<\/span>/Uis', $this->body, $matches)) {
|
||||
$this->libErreur='Erreur Artisan absent de la base Artisanat !';
|
||||
// die($this->body);
|
||||
return false;
|
||||
} else {
|
||||
$this->libErreur='Erreur Siren absent dans la page !';
|
||||
// die($this->body);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -24,28 +24,42 @@ function dec2dms($dec) {
|
||||
return $d.'°'.$m."'".$s.'"';
|
||||
}
|
||||
|
||||
/**/
|
||||
function ALG0001($phi,$e) {
|
||||
$temp = ( 1 - ( $e * sin( $phi ) ) ) / ( 1 + ( $e * sin( $phi ) ) );
|
||||
$L = log ( tan ( (pi()/4) + ($phi/2) ) * pow ($temp, ($e/2) ));
|
||||
return $L;
|
||||
}
|
||||
|
||||
|
||||
/** Calcul de la latitude à partir de la latitude isométrique
|
||||
**/
|
||||
function ALG0002($L,$e,$epsilon) {
|
||||
$phi[0] = 2 * atan(exp($L)) - (pi()/2);
|
||||
$phi[0] = 2 * atan(exp($L)) - (pi()/2);
|
||||
|
||||
$i=0;
|
||||
do
|
||||
{
|
||||
$i++;
|
||||
$temp = ( 1 + ( $e * sin( $phi[$i-1] ) ) ) / ( 1 - ( $e * sin( $phi[$i-1] ) ) );
|
||||
$phi[$i] = 2 * atan ( pow ($temp, ($e/2)) * exp ($L) ) - pi()/2;
|
||||
}
|
||||
while (abs($phi[$i] - $phi[$i - 1]) >= $epsilon);
|
||||
$i=0;
|
||||
do {
|
||||
$i++;
|
||||
$temp = ( 1 + ( $e * sin( $phi[$i-1] ) ) ) / ( 1 - ( $e * sin( $phi[$i-1] ) ) );
|
||||
$phi[$i] = 2 * atan ( pow ($temp, ($e/2)) * exp ($L) ) - pi()/2;
|
||||
}
|
||||
while (abs($phi[$i] - $phi[$i - 1]) >= $epsilon);
|
||||
|
||||
return $phi[$i];
|
||||
return $phi[$i];
|
||||
}
|
||||
|
||||
/** Transformation de coordonnées en projection conique conforme de Lambert, en coordonnées géographiques
|
||||
** @param double $X Coordonnée X en projection conique conforme de Lambert du point
|
||||
** @param double $Y Coordonnée Y en projection conique conforme de Lambert du point
|
||||
** @param double $n Exposant de la projection
|
||||
** @param double $c Constante de la projection
|
||||
** @param double $Xs Coordonnée Xs en projection du pôle
|
||||
** @param double $Ys Coordonnée Ys en projection du pôle
|
||||
** @param double $lambdac Longitude de l'origine par rapport au méridien origine
|
||||
** @param double $e Première excentricité de l'ellipsoïde
|
||||
** @param double $epsilon Tolérance de convergence
|
||||
** @return array lambda Longitude par rapport au méridien origine
|
||||
** phi Latitude
|
||||
**/
|
||||
function ALG0004($X,$Y,$n,$c,$Xs,$Ys,$lambdac,$e,$epsilon) {
|
||||
$R = sqrt( pow(($X - $Xs),2) + pow(($Y - $Ys),2) );
|
||||
$gamma = atan(($X - $Xs)/($Ys - $Y));
|
||||
@ -62,6 +76,9 @@ function ALG0004($X,$Y,$n,$c,$Xs,$Ys,$lambdac,$e,$epsilon) {
|
||||
return $coords;
|
||||
}
|
||||
|
||||
/** Transformation des coordonnées géographiques ellipsoïdales en coordonnées cartésiennes
|
||||
**
|
||||
**/
|
||||
function ALG0009($lambda,$phi,$he,$a,$e) {
|
||||
$N = ALG0021($phi,$a,$e);
|
||||
|
||||
@ -78,7 +95,7 @@ function ALG0009($lambda,$phi,$he,$a,$e) {
|
||||
return $coords;
|
||||
}
|
||||
|
||||
|
||||
/**/
|
||||
function ALG0012($X,$Y,$Z,$a,$e,$epsilon) {
|
||||
$lambda = atan ($Y/$X);
|
||||
|
||||
@ -105,14 +122,29 @@ function ALG0012($X,$Y,$Z,$a,$e,$epsilon) {
|
||||
return $coords;
|
||||
}
|
||||
|
||||
/** Transformation d'un jeu de 7 paramètres entre 2 systèmes géodésiques
|
||||
** @param double $Tx Translation suivant l'axe des X (de 1 vers 2)
|
||||
** @param double $Ty Translation suivant l'axe des Y (de 1 vers 2)
|
||||
** @param double $Tz Translation suivant l'axe des Z (de 1 vers 2)
|
||||
** @param double $D Facteur d'échelle de 1 vers 2
|
||||
** @param double $Rx Angle de rotation autour de l'axe des X en radian (de 1 vers 2)
|
||||
** @param double $Ry Angle de rotation autour de l'axe des Y en radian (de 1 vers 2)
|
||||
** @param double $Rz Angle de rotation autour de l'axe des Z en radian (de 1 vers 2)
|
||||
** @param double $U Vecteur de coordonnées cartésiennes tridimensionnelles dans le système 1 : U=(Ux,Uy,Uz)
|
||||
** @return array Vecteur de coordonnées cartésiennes tridimensionnelles dans le système 2, V=(Vx,Vy,Vz)
|
||||
*/
|
||||
function ALG0013($Tx,$Ty,$Tz,$D,$Rx,$Ry,$Rz,$U) {
|
||||
$V['X'] = $Tx + $U['X'] * (1 + $D) + $U['Z'] * $Ry - $U['Y'] * $Rz;
|
||||
$V['Y'] = $Ty + $U['Y'] * (1 + $D) + $U['X'] * $Rz - $U['Z'] * $Rx;
|
||||
$V['Z'] = $Tz + $U['Z'] * (1 + $D) + $U['Y'] * $Rx - $U['X'] * $Ry;
|
||||
|
||||
return $V;
|
||||
$V=array();
|
||||
$V['X'] = $Tx + $U['X'] * (1 + $D) + $U['Z'] * $Ry - $U['Y'] * $Rz;
|
||||
$V['Y'] = $Ty + $U['Y'] * (1 + $D) + $U['X'] * $Rz - $U['Z'] * $Rx;
|
||||
$V['Z'] = $Tz + $U['Z'] * (1 + $D) + $U['Y'] * $Rx - $U['X'] * $Ry;
|
||||
return $V;
|
||||
}
|
||||
|
||||
/** Détermination des paramètres de calcul d'une projection Lambert conique
|
||||
** dans le cas tangent, avec ou sans facteur d'échelle en fonction des paramètres de définition usuels
|
||||
** @return array n, C, lambdac, Xs, Ys
|
||||
**/
|
||||
function ALG0019($lambda0,$phi0,$k0,$X0,$Y0,$a,$e) {
|
||||
$lambdac = $lambda0;
|
||||
$n = sin($phi0);
|
||||
@ -131,103 +163,99 @@ function ALG0019($lambda0,$phi0,$k0,$X0,$Y0,$a,$e) {
|
||||
|
||||
}
|
||||
|
||||
/** Calcul de la grande normale de l'ellipsoïde
|
||||
** @param double $phi Latitude
|
||||
** @param double $a Demi-grand axe de l'ellipsoïde
|
||||
** @param double $e Première excentricité de l'ellipsoïde
|
||||
** @return double
|
||||
**/
|
||||
function ALG0021($phi,$a,$e) {
|
||||
$N = $a/sqrt( 1 - $e * $e * sin($phi) * sin($phi) );
|
||||
return $N;
|
||||
|
||||
$N = $a/sqrt( 1 - $e * $e * sin($phi) * sin($phi) );
|
||||
return $N;
|
||||
}
|
||||
|
||||
/** Calcul des constantes d'une projection Lambert conique conforme dans le cas sécant
|
||||
** @param double $lambda0 Longitude origine en radian par rapport au méridien origine
|
||||
** @param double $phi0 Latitude origine
|
||||
** @param double $X0 Coordonnée X en projection du point origine
|
||||
** @param double $Y0 Coordonnée Y en projection du point origine
|
||||
** @param double $phi1 Latitude en radian du 1er parallèle automécoïque
|
||||
** @param double $phi2 Latitude en radian du 2ème parallèle automécoïque
|
||||
** @param double $a Demi-grand axe de l'ellipsoïde
|
||||
** @param double $e Première excentricité de l'ellipsoïde
|
||||
** @return array n, C, lambdac, Xs, Ys
|
||||
**/
|
||||
function ALG0054($lambda0,$phi0,$X0,$Y0,$phi1,$phi2,$a,$e) {
|
||||
$lambdac = $lambda0;
|
||||
$n = ( (log( (ALG0021($phi2,$a,$e)*cos($phi2))/(ALG0021($phi1,$a,$e)*cos($phi1)) ))/(ALG0001($phi1,$e) - ALG0001($phi2,$e) ));
|
||||
$C = ((ALG0021($phi1,$a,$e)* cos($phi1))/$n) * exp($n * ALG0001($phi1,$e));
|
||||
|
||||
|
||||
if ($phi0 == (pi()/2))
|
||||
{
|
||||
if ($phi0 == (pi()/2)) {
|
||||
$Xs = $X0;
|
||||
$Ys = $Y0;
|
||||
} else {
|
||||
$Xs = $X0;
|
||||
$Ys = $Y0 + $C * exp(-1 * $n * ALG0001($phi0,$e));
|
||||
}
|
||||
else
|
||||
{
|
||||
echo ('coucou');
|
||||
$Xs = $X0;
|
||||
$Ys = $Y0 + $C * exp(-1 * $n * ALG0001($phi0,$e));
|
||||
}
|
||||
|
||||
$tab ['e'] = $e;
|
||||
$tab ['n'] = $n;
|
||||
$tab ['C'] = $C;
|
||||
$tab ['lambdac'] = $lambdac;
|
||||
$tab ['Xs'] = $Xs;
|
||||
$tab ['Ys'] = $Ys;
|
||||
|
||||
$tab=array( 'e' => $e,
|
||||
'n' => $n,
|
||||
'C' => $C,
|
||||
'lambdac' => $lambdac,
|
||||
'Xs'=> $Xs,
|
||||
'Ys'=> $Ys);
|
||||
return $tab;
|
||||
|
||||
}
|
||||
|
||||
function Lambert2WGS84($X,$Y,$orig='LIIe') {
|
||||
function Lambert2WGS84($X,$Y,$orig='L93') {
|
||||
$epsilon = 0.00000000001;
|
||||
|
||||
switch ($orig)
|
||||
{
|
||||
case 'LII' :
|
||||
$n = 0.7289686274;
|
||||
$c = 11745793.39;
|
||||
$Xs = 600000;
|
||||
$Ys = 6199695.768;
|
||||
$lambdac = 0.04079234433; // pour greenwich
|
||||
$lambdac = 0.04079234433; // pour greenwich
|
||||
$e = 0.08248325676; // première excentricité de l ellipsoïde Clarke 1880 français
|
||||
$he = 100;
|
||||
$a = 6378249.2; // demi-grand axe de l'ellipsoide
|
||||
|
||||
$e = 0.08248325676; //(première excentricité de l ellipsoïde Clarke 1880 français)
|
||||
$Tx = -168;
|
||||
$Ty = -60;
|
||||
$Tz = +320;
|
||||
$D = 0;
|
||||
$Rx = $Ry = $Rz = 0;
|
||||
|
||||
$he = 100;
|
||||
$a = 6378249.2;
|
||||
|
||||
$Tx = -168;
|
||||
$Ty = -60;
|
||||
$Tz = +320;
|
||||
$D = 0;
|
||||
$Rx = $Ry = $Rz = 0;
|
||||
break;
|
||||
|
||||
case 'L93' :
|
||||
$n = 0.7256077650;
|
||||
$c = 11745255.426;
|
||||
$Xs = 700000;
|
||||
$Ys = 12655612.050;
|
||||
$lambdac = 0.04079234433; // pour greenwich
|
||||
|
||||
$e = 0.08248325676; //(première excentricité de l ellipsoïde Clarke 1880 français)
|
||||
|
||||
$he = 100;
|
||||
$a = 6378249.2;
|
||||
|
||||
$Tx = -168;
|
||||
$Ty = -60;
|
||||
$Tz = +320;
|
||||
$D = 0;
|
||||
$Rx = $Ry = $Rz = 0;
|
||||
break;
|
||||
|
||||
case 'LIIe' :
|
||||
default:
|
||||
$n = 0.7289686274;
|
||||
$c = 11745793.39;
|
||||
$Xs = 600000;
|
||||
$Ys = 8199695.768;
|
||||
$lambdac = 0.04079234433; // pour greenwich
|
||||
|
||||
$e = 0.08248325676; //(première excentricité de l ellipsoïde Clarke 1880 français)
|
||||
|
||||
$he = 100;
|
||||
$a = 6378249.2;
|
||||
|
||||
$Tx = -168;
|
||||
$Ty = -60;
|
||||
$Tz = +320;
|
||||
$D = 0;
|
||||
$Rx = $Ry = $Rz = 0;
|
||||
break;
|
||||
$orig=strtoupper($orig);
|
||||
switch ($orig) {
|
||||
case 'LI':
|
||||
case 'L1': $n = 0.7604059656;
|
||||
$c = 11603796.98;
|
||||
$Xs = 600000;
|
||||
$Ys = 5657616.674;
|
||||
break;
|
||||
case 'LII':
|
||||
case 'LIIE':
|
||||
case 'L2E':
|
||||
case 'L2': $n = 0.7289686274;
|
||||
$c = 11745793.39;
|
||||
$Xs = 600000;
|
||||
if ($orig=='L2E' || $orig=='LIIE')
|
||||
$Ys = 8199695.768;
|
||||
else $Ys = 6199695.768;
|
||||
break;
|
||||
case 'LIII':
|
||||
case 'L3': $n = 0.6959127966;
|
||||
$c = 11947992.52;
|
||||
$Xs = 600000;
|
||||
$Ys = 6791905.085;
|
||||
break;
|
||||
case 'LIV':
|
||||
case 'L4': $n = 0.6712679322;
|
||||
$c = 12136281.99;
|
||||
$Xs = 234.358;
|
||||
$Ys = 7239161.542;
|
||||
break;
|
||||
case 'L93':
|
||||
default: $n = 0.7256077650;
|
||||
$c = 11745255.426;
|
||||
$Xs = 700000;
|
||||
$Ys = 12655612.050;
|
||||
break;
|
||||
}
|
||||
|
||||
$coords = ALG0004($X,$Y,$n,$c,$Xs,$Ys,$lambdac,$e,$epsilon);
|
||||
@ -381,6 +409,84 @@ print_r(Lambert2WGS84(591647.56,2426659.65));
|
||||
print_r(geos2lambert(48.838245134184 ,2.2227849815878));
|
||||
**/
|
||||
|
||||
/** The point-in-polygon algorythm allows you to programmatically check if a particular point is inside a polygon or outside of it. A common way to tackle the problem is to count how many times a line drawn from the point (in any direction) intersects with the polygon boundary. If they intersect an even number of times, then the point is outside.
|
||||
I used that approach in this PHP code, which doesn't contain detailed comments yet. A few people asked if I could post it anyway, so there it is... I'll try to add some more comment as soon as I have some spare time.
|
||||
|
||||
The returned values are:
|
||||
"vertex" if the point sits exactly on a vertex AND you left true as the value for $pointOnVertex.
|
||||
"boundary" if the point sits on the boundary. If $pointOnVertex is false, then "boundary" is also returned if the point is on a vertex.
|
||||
"inside" if the point is inside the polygon.
|
||||
"outside" if, you guessed it, the point is outside of the polygon.
|
||||
*/
|
||||
class pointLocation {
|
||||
|
||||
var $pointOnVertex = true; // Check if the point sits exactly on one of the vertices
|
||||
|
||||
function pointLocation() {
|
||||
}
|
||||
|
||||
function pointInPolygon($point, $polygon, $pointOnVertex = true) {
|
||||
$this->pointOnVertex = $pointOnVertex;
|
||||
|
||||
// Transform string coordinates into arrays with x and y values
|
||||
$point = $this->pointStringToCoordinates($point);
|
||||
$vertices = array();
|
||||
foreach ($polygon as $vertex) {
|
||||
$vertices[] = $this->pointStringToCoordinates($vertex);
|
||||
}
|
||||
//print_r($vertices);
|
||||
//die();
|
||||
// Check if the point sits exactly on a vertex
|
||||
if ($this->pointOnVertex == true && $this->pointOnVertex($point, $vertices) == true) {
|
||||
return "vertex";
|
||||
}
|
||||
|
||||
// Check if the point is inside the polygon or on the boundary
|
||||
$intersections = 0;
|
||||
$vertices_count = count($vertices);
|
||||
echo "vertices_count=$vertices_count".EOL;
|
||||
|
||||
for ($i=1; $i < $vertices_count; $i++) {
|
||||
$vertex1 = $vertices[$i-1];
|
||||
$vertex2 = $vertices[$i];
|
||||
if ($vertex1['y'] == $vertex2['y'] && $vertex1['y'] == $point['y'] && $point['x'] > min($vertex1['x'], $vertex2['x']) && $point['x'] < max($vertex1['x'], $vertex2['x'])) {
|
||||
// Check if point is on an horizontal polygon boundary
|
||||
return "boundary";
|
||||
}
|
||||
if ($point['y'] > min($vertex1['y'], $vertex2['y']) && $point['y'] <= max($vertex1['y'], $vertex2['y']) && $point['x'] <= max($vertex1['x'], $vertex2['x']) && $vertex1['y'] != $vertex2['y']) {
|
||||
$xinters = ($point['y'] - $vertex1['y']) * ($vertex2['x'] - $vertex1['x']) / ($vertex2['y'] - $vertex1['y']) + $vertex1['x'];
|
||||
if ($xinters == $point['x']) {
|
||||
// Check if point is on the polygon boundary (other than horizontal)
|
||||
return "boundary";
|
||||
}
|
||||
if ($vertex1['x'] == $vertex2['x'] || $point['x'] <= $xinters) {
|
||||
$intersections++;
|
||||
}
|
||||
}
|
||||
}
|
||||
// If the number of edges we passed through is even, then it's in the polygon.
|
||||
echo "intersections=$intersections".EOL;
|
||||
if ($intersections % 2 != 0) {
|
||||
return "inside";
|
||||
} else {
|
||||
return "outside";
|
||||
}
|
||||
}
|
||||
|
||||
function pointOnVertex($point, $vertices) {
|
||||
foreach($vertices as $vertex) {
|
||||
if ($point == $vertex) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function pointStringToCoordinates($pointString) {
|
||||
$coordinates = explode(' ', $pointString);
|
||||
return array('x'=>$coordinates[0], 'y'=>$coordinates[1]);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class MMap {
|
||||
|
||||
@ -400,6 +506,9 @@ class MMap {
|
||||
public $latitudeDeg= 0; // Latitude en Dégrés
|
||||
public $longitudeDec= 0; // Longitude en Décimal
|
||||
public $longitudeDeg= 0; // Longitude en Dégrés
|
||||
public $altitude = NULL; // Altitude en mètres
|
||||
public $l93x = NULL; // Lambert 93, coordonnée X
|
||||
public $l93y = NULL; // Lambert 93, coordonnée Y
|
||||
|
||||
public $precision = 0;
|
||||
public $adresseValidee='';
|
||||
@ -607,7 +716,7 @@ API keybing = 56D6CBA671C986D3EA11B1B48F97507BE9B46999
|
||||
$this->codeRetourG=@getTextInHtml($this->body, '<Status>', '<code>', '/code>');
|
||||
$this->precision=@getTextInHtml($this->body, '<AddressDetails Accuracy', '="', '" ');
|
||||
|
||||
$this->adresseValidee=strtoupper(str_replace(''', "'", htmlspecialchars_decode(@getTextInHtml($this->body, '<Placemark', '<address>', '</address>'),ENT_QUOTES)));
|
||||
$this->adresseValidee=strtoupper(utf8_decode(str_replace(''', "'", htmlspecialchars_decode(@getTextInHtml($this->body, '<Placemark', '<address>', '</address>'),ENT_QUOTES))));
|
||||
$strTmp=@getTextInHtml($this->body, '<Point><coordinates>', '<coordinates>', '</coordinates>');
|
||||
$tabTmp=explode(',', $strTmp);
|
||||
$this->latitudeDec=@$tabTmp[1];
|
||||
@ -640,19 +749,49 @@ API keybing = 56D6CBA671C986D3EA11B1B48F97507BE9B46999
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/** Géocodage d'une adresse
|
||||
** 0 Unknown location. (Since 2.59)
|
||||
1 Country level accuracy. (Since 2.59)
|
||||
2 Region (state, province, prefecture, etc.) level accuracy. (Since 2.59)
|
||||
3 Sub-region (county, municipality, etc.) level accuracy. (Since 2.59)
|
||||
4 Town (city, village) level accuracy. (Since 2.59)
|
||||
5 Post code (zip code) level accuracy. (Since 2.59)
|
||||
6 Street level accuracy. (Since 2.59)
|
||||
7 Intersection level accuracy. (Since 2.59)
|
||||
8 Address level accuracy. (Since 2.59)
|
||||
**/
|
||||
function geoCodeAdresse($adrNum, $adrIndRep, $adrTypeVoieCourt, $adrTypeVoieLong, $adrLibVoie, $cp, $ville='', $pays='France', $codeRivoli='') {
|
||||
$iDb=new WDB();
|
||||
$tabRep=array();
|
||||
$adresse=addslashes(trim(preg_replace('/ +/',' ', "$adrNum $adrIndRep $adrTypeVoieLong $adrLibVoie")));
|
||||
$ville=addslashes($ville);
|
||||
$ret=$iDb->select( 'zonageXY', 'lat, lon, precis, adresseValidee, dateInsert', "address='$adresse' AND adr_cp='$cp' AND adr_ville='$ville'",false, MYSQL_ASSOC);
|
||||
$ret=$iDb->select( 'zonageXY', 'lat, lon, l93_x, l93_y, alt, precis, adresseValidee, dateInsert', "address='$adresse' AND adr_cp='$cp' AND adr_ville='$ville'",false, MYSQL_ASSOC);
|
||||
if (count($ret)>0) {
|
||||
$zonage=$ret[0];
|
||||
$this->precision=$zonage['precis']*1;
|
||||
$this->adresseValidee=strtoupper($zonage['adresseValidee']);
|
||||
$this->latitudeDec=$zonage['lat']*1;
|
||||
$this->longitudeDec=$zonage['lon']*1;
|
||||
$this->l93x=$zonage['l93_x'];
|
||||
$this->l93y=$zonage['l93_y'];
|
||||
$this->altitude=$zonage['alt'];
|
||||
if ($this->altitude==NULL && $this->precision>5) {
|
||||
$alt=$this->getAltitude($this->latitudeDec,$this->longitudeDec);
|
||||
$this->altitude=$alt['alt'];
|
||||
}
|
||||
if ($this->l93x==NULL && $this->precision>5) {
|
||||
$tmp=geos2lambert93($this->latitudeDec,$this->longitudeDec);
|
||||
$this->l93x=$tmp['x_93'];
|
||||
$this->l93y=$tmp['y_93'];
|
||||
}
|
||||
if ($this->altitude<>NULL || $this->l93x<>NULL) {
|
||||
$tabUpdate=array( 'alt'=>$this->altitude,
|
||||
'l93_x'=>$this->l93x,
|
||||
'l93_y'=>$this->l93y);
|
||||
//'dateUpdate'=>DATETIME,
|
||||
$iDb->update('zonageXY', $tabUpdate, "address='$adresse' AND adr_cp='$cp' AND adr_ville='$ville'");
|
||||
}
|
||||
|
||||
$this->latitudeDeg=dec2dms($this->latitudeDec);
|
||||
$this->longitudeDeg=dec2dms($this->longitudeDec);
|
||||
$this->enCache=true;
|
||||
@ -677,13 +816,22 @@ API keybing = 56D6CBA671C986D3EA11B1B48F97507BE9B46999
|
||||
die("Code Rivoli non géré : '$codeRivoli'".EOL);
|
||||
|
||||
$retG=$this->geoCodeAdrCpVilleG($adresse, $cp, $ville, $pays);
|
||||
/* if ($this->codeRetourG==620 || $this->precision==0)
|
||||
if ($this->codeRetourG==620)
|
||||
$retY=$this->geoCodeAdrCpVilleY("$adresse, $cp $ville");*/
|
||||
if ($this->codeRetourG==620 || $this->precision==0)
|
||||
/*if ($this->codeRetourG==620)
|
||||
$retY=$this->geoCodeAdrCpVilleY("$adresse, $cp $ville");
|
||||
|
||||
if ($this->codeRetourY==620 || $this->codeRetourY==503 || $this->precision==0)
|
||||
if ($this->codeRetourY==620 || $this->codeRetourY==503 || $this->precision==0)*/
|
||||
$retM=$this->geoCodeAdrCpVilleM($adresse, $cp, $ville, $pays);
|
||||
|
||||
// On récupère l'altitude
|
||||
if ($this->precision>5) {
|
||||
$alt=$this->getAltitude($this->latitudeDec,$this->longitudeDec);
|
||||
$this->altitude=$alt['alt'];
|
||||
}
|
||||
$tmp=geos2lambert93($this->latitudeDec,$this->longitudeDec);
|
||||
$this->l93x=$tmp['x_93'];
|
||||
$this->l93y=$tmp['y_93'];
|
||||
|
||||
if ($retG || $retY || $retM) {
|
||||
$adresse=stripslashes(strtoupper(trim(preg_replace('/ +/',' ', "$adrNum $adrIndRep $adrTypeVoieLong $adrLibVoie"))));
|
||||
$ville=stripslashes($ville);
|
||||
@ -698,6 +846,9 @@ API keybing = 56D6CBA671C986D3EA11B1B48F97507BE9B46999
|
||||
'adresseValidee'=>$this->adresseValidee,
|
||||
'lat'=>$this->latitudeDec,
|
||||
'lon'=>$this->longitudeDec,
|
||||
'l93_x'=>$this->l93x,
|
||||
'l93_y'=>$this->l93y,
|
||||
'alt'=>$this->altitude,
|
||||
'precis'=>$this->precision,
|
||||
'source'=>$this->geocodeur,
|
||||
'dateInsert'=>DATETIME,
|
||||
@ -716,9 +867,6 @@ API keybing = 56D6CBA671C986D3EA11B1B48F97507BE9B46999
|
||||
$ligne="Erreur : $adrNum, $adrIndRep, $adrTypeVoieCourt, $adrTypeVoieLong, $adrLibVoie, $cp, $ville, $pays, $codeRivoli, ".$this->body;
|
||||
}
|
||||
}
|
||||
/*$fp=fopen(LOG_PATH.'/accesGMap.log', 'a');
|
||||
fwrite($fp,$ligne.EOL);
|
||||
fclose($fp);*/
|
||||
}
|
||||
/* if (latnorth == 'S') latdir='-'
|
||||
if (lonwest == 'W') longdir='-'
|
||||
@ -732,19 +880,27 @@ API keybing = 56D6CBA671C986D3EA11B1B48F97507BE9B46999
|
||||
if (gmx < 0) gmx=gmx+Math.pow(2,32)*/
|
||||
|
||||
|
||||
/** Retourne la distance en kilomètres entre 2 points à la surface de la terre
|
||||
** Calcul effectué avec la sphère « GRS80 » de rayon R = 6378,187 km
|
||||
** Autre sphère possible : « Picard » de rayon R = 6371,598 km
|
||||
/** Retourne la distance en kilomètres entre 2 coordonnées GPS à la surface de la terre
|
||||
**
|
||||
** @param double $latA Latitude du point A en décimal
|
||||
** @param double $lonA Longitude du point A en décimal
|
||||
** @param double $latB Latitude du point B en décimal
|
||||
** @param double $lonB Longitude du point B en décimal
|
||||
** @param double $latA Latitude du point A en décimal
|
||||
** @param double $lonA Longitude du point A en décimal
|
||||
** @param double $latB Latitude du point B en décimal
|
||||
** @param double $lonB Longitude du point B en décimal
|
||||
** @param string $sphere Type de sphère
|
||||
** @return unknown
|
||||
**/
|
||||
function distance($latA=0, $lonA=0, $latB=0, $lonB=0) {
|
||||
//s(AB) = arc cos (sinjA sinjB + cos jA cosjB cosdl)
|
||||
// avec dl = lB - lA
|
||||
function distance($latA=0, $lonA=0, $latB=0, $lonB=0, $sphere='GRS80') {
|
||||
switch ($sphere) {
|
||||
case 'HAYFORD': $R=6378.388; // Demi grand axe ou Rayon de la sphère International Hayford 1909 en Kms
|
||||
$f=1/297; // Aplatissement
|
||||
break;
|
||||
case 'PICARD': $R=6371.598; // Demi grand axe ou Rayon de la sphère Picard en Kms
|
||||
break;
|
||||
case 'GRS80':
|
||||
default: $R=6378.137; // Demi grand axe ou Rayon de la sphère GRS80 en Kms
|
||||
$f=1/298.257222101;
|
||||
break;
|
||||
}
|
||||
$a=pi()/180;
|
||||
$e=$latA*$a;
|
||||
$f=$lonA*$a;
|
||||
@ -753,26 +909,100 @@ function distance($latA=0, $lonA=0, $latB=0, $lonB=0) {
|
||||
|
||||
$j=acos(cos($e)*cos($g)*cos($f)*cos($h) + cos($e)*sin($f)*cos($g)*sin($h) + sin($e)*sin($g));
|
||||
|
||||
return round(6378.187*$j,3); // div par 1.852 ==> résultat en miles nautiques
|
||||
return round($R*$j,3); // div par 1.852 ==> résultat en miles nautiques
|
||||
}
|
||||
/*function distance(lat_a, lon_a, lat_b, lon_b)
|
||||
{
|
||||
a = Math.PI / 180;
|
||||
lat1 = lat_a * a;
|
||||
lat2 = lat_b * a;
|
||||
lon1 = lon_a * a;
|
||||
lon2 = lon_b * a;
|
||||
|
||||
t1 = Math.sin(lat1) * Math.sin(lat2);
|
||||
t2 = Math.cos(lat1) * Math.cos(lat2);
|
||||
t3 = Math.cos(lon1 - lon2);
|
||||
t4 = t2 * t3;
|
||||
t5 = t1 + t4;
|
||||
rad_dist = Math.atan(-t5/Math.sqrt(-t5 * t5 +1)) + 2 * Math.atan(1);
|
||||
|
||||
return (rad_dist * 3437.74677 * 1.1508) * 1.6093470878864446;
|
||||
/** Retourne la distance en mètres entre 2 points sur une surface plane
|
||||
** @param double $x1 Coordonnée X du point 1 en décimal
|
||||
** @param double $y1 Coordonnée Y du point 1 en décimal
|
||||
** @param double $x2 Coordonnée X du point 2 en décimal
|
||||
** @param double $y2 Coordonnée Y du point 2 en décimal
|
||||
** @return double
|
||||
**/
|
||||
function distanceLambert($x1,$y1,$x2,$y2) {
|
||||
return sqrt ( pow($x1-$x2,2) + (pow($y1-$y2,2) ) );
|
||||
}
|
||||
|
||||
/** Retourne l'altitude en mètres d'un point GPS. Shuttle Radar Topography Mission (SRTM) elevation data (resolution 90mx90m)
|
||||
** @url http://ws.geonames.org/export/web-services.html
|
||||
** @param double $tabLatLon Latitude du point ou Tableau de Points avec latitudes longitudes array('lat'=>x,'lon'=>y)
|
||||
** @param double $lon Longitude ou false si tableau
|
||||
** @return double
|
||||
**/
|
||||
function getAltitude($tabLatLon,$lon=false) {
|
||||
if ($lon) {
|
||||
/*Elevation - SRTM3
|
||||
Shuttle Radar Topography Mission (SRTM) elevation data. SRTM consisted of a specially modified radar system that flew onboard the Space Shuttle Endeavour during an 11-day mission in February of 2000. The dataset covers land areas between 60 degrees north and 56 degrees south.
|
||||
This web service is using SRTM3 data with data points located every 3-arc-second (approximately 90 meters) on a latitude/longitude grid. Documentation : Nasa
|
||||
|
||||
Webservice Type : REST
|
||||
Url : api.geonames.org/srtm3?
|
||||
Parameters : lat,lng;
|
||||
sample area: ca 90m x 90m Result : a single number giving the elevation in meters according to srtm3, ocean areas have been masked as "no data" and have been assigned a value of -32768
|
||||
Example http://api.geonames.org/srtm3?lat=50.01&lng=10.2&username=demo
|
||||
|
||||
This service is also available in XML and JSON format :api.geonames.org/srtm3XML?lat=50.01&lng=10.2&username=demo api.geonames.org/srtm3JSON?lat=50.01&lng=10.2&username=demo
|
||||
|
||||
The text version of the service also accepts a list of lat/lng for the parameters 'lats' and 'lngs'. On the free server the number of points per call is limited to 20, for the premium service the limit is 2000:
|
||||
*/
|
||||
$url="http://ws.geonames.org/srtm3?lat=$tabLatLon&lng=$lon";
|
||||
$page=getUrl($url, '', '', '', false, '', '', 3);
|
||||
$alt=trim($page['body']);
|
||||
if (preg_match('/the (.*) limit of (.*) credits(.*) has been exceeded\. Please throttle your requests or use the commercial service/Uis', $alt, $matches)) {
|
||||
$alt=NULL;
|
||||
} elseif ($page['code']<>200 || $alt==-32768) {
|
||||
if ($page['code']<>200) echo '==========================>'. $page['code']. '<=================================='.EOL;
|
||||
$alt=NULL;
|
||||
}
|
||||
return array('lat'=>$tabLatLon,'lon'=>$lon,'alt'=>$alt);
|
||||
} else {
|
||||
$LatLon='';
|
||||
$Lats='';
|
||||
$Lons='';
|
||||
foreach ($tabLatLon as $i=>$latlon) {
|
||||
$lat=$latlon['lat'];
|
||||
$lon2=$latlon['lon'];
|
||||
if ($i>0) {
|
||||
$LatLon.="%0D%0A";
|
||||
$Lats.=',';
|
||||
$Lons.=',';
|
||||
}
|
||||
$LatLon.="$lat%2C$lon2";
|
||||
$Lats.=$lat;
|
||||
$Lons.=$lon;
|
||||
}
|
||||
// http://api.geonames.org/srtm3?lats=50.01,51.01&lngs=10.2,11.2&username=demo
|
||||
/* $url="http://api.geonames.org/srtm3?lats=$Lats&lng=$Lons&username=demo";
|
||||
$page=getUrl($url, '', '', '', false, '', '', 3);
|
||||
$alt=trim($page['body']);
|
||||
die($alt);
|
||||
if ($page['code']<>200 || $alt==-32768) {
|
||||
if ($page['code']<>200) echo '==========================>'. $page['code']. '<=================================='.EOL;
|
||||
$alt=NULL;
|
||||
}
|
||||
return array('lat'=>$tabLatLon,'lon'=>$lon,'alt'=>$alt);
|
||||
*/
|
||||
}
|
||||
|
||||
$url='http://www.fredorando.fr/Pages/altitude.php';
|
||||
$post=array('LatLon'=>$LatLon,'qui'=>'');
|
||||
$page=getUrl($url, '', $post, '', false, '', '', 3);
|
||||
$body=$page['body'];
|
||||
$tabRet=false;
|
||||
if (preg_match('/<BODY>\s+IP\:(?:.*)<br\/>\s+url\:(?:.*)<br\/>(?:.*)<br\/>(?:.*)<br\/>(.*)<br\/>(?:.*)<a href="http/Uis', $body, $matches)) {
|
||||
$tabRet=array();
|
||||
$tabTmp=explode('<br />', $matches[1]);
|
||||
foreach($tabTmp as $i=>$ret) {
|
||||
$ret2=explode(',',trim($ret));
|
||||
$alt=$ret2[2];
|
||||
if ($alt==-32768) $alt=NULL;
|
||||
$tabRet[$i]=@array('lat'=>$ret2[0],'lon'=>$ret2[1],'alt'=>$alt);
|
||||
}
|
||||
unset($tabRet[$i]);
|
||||
}
|
||||
if ($lon) return $tabRet[0];
|
||||
return $tabRet;
|
||||
}
|
||||
|
||||
}
|
||||
if ( !function_exists('json_decode') ){
|
||||
|
Loading…
Reference in New Issue
Block a user