Insert db in classMMap contructor

This commit is contained in:
Michael RICOIS 2014-05-27 13:18:02 +00:00
parent e225e6c336
commit 14d4dd99a4
2 changed files with 15 additions and 9 deletions

View File

@ -521,7 +521,13 @@ class MMap {
private $apiKeyY='klII0gzV34Ho2TCsN3XiXeh4No033AifxMeDXfFXj8TDCXO3WAtOLj9c74VsV45HcII-';
private $apiKeyC='ae5216123e414fcd84b8ca9a0f43a68c';
function __construct($accesDist=true) {// $adresse, $cp, $ville, $pays='France') {
function __construct($accesDist=true, $db = null)
{
if ( $db === null ) {
$this->iDb = new WDB();
} else {
$this->iDb = $db;
}
$this->accesDist=$accesDist;
}
@ -541,8 +547,8 @@ GeoCodingHandler.ashx?addr=
<wsdl:import namespace="http://dev.virtualearth.net/webservices/v1/imagery/contracts" location="http://dev.virtualearth.net/webservices/v1/metadata/imageryservice/imageryservice1.wsdl" />
API keybing = 56D6CBA671C986D3EA11B1B48F97507BE9B46999
*/
public function geoCodeAdrCpVilleM($adresse,$cp,$ville,$pays='') {
public function geoCodeAdrCpVilleM($adresse,$cp,$ville,$pays='')
{
if ($pays=='') $pays='France';
if (preg_match('/^([0-9]{1,4} )(.*)$/', $adresse, $matches)) {
$adresseVoie=trim($matches[2]);
@ -941,12 +947,12 @@ API keybing = 56D6CBA671C986D3EA11B1B48F97507BE9B46999
8 Address level accuracy. (Since 2.59)
9 Address level accuracy +++
**/
function geoCodeAdresse($adrNum, $adrIndRep, $adrTypeVoieCourt, $adrTypeVoieLong, $adrLibVoie, $cp, $ville='', $pays='France', $codeRivoli='') {
$iDb=new WDB();
function geoCodeAdresse($adrNum, $adrIndRep, $adrTypeVoieCourt, $adrTypeVoieLong, $adrLibVoie, $cp, $ville='', $pays='France', $codeRivoli='')
{
$tabRep=array();
$adresse=addslashes(trim(preg_replace('/ +/',' ', "$adrNum $adrIndRep $adrTypeVoieLong $adrLibVoie")));
$ville=addslashes($ville);
$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);
$ret=$this->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;
@ -972,7 +978,7 @@ API keybing = 56D6CBA671C986D3EA11B1B48F97507BE9B46999
'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->iDb->update('zonageXY', $tabUpdate, "address='$adresse' AND adr_cp='$cp' AND adr_ville='$ville'");
}
$this->latitudeDeg=dec2dms($this->latitudeDec);
@ -1045,7 +1051,7 @@ API keybing = 56D6CBA671C986D3EA11B1B48F97507BE9B46999
if ($this->latitudeDec<>0 && $this->longitudeDec<>0 && $this->precision>0) {
// print_r($tabInsert);
//echo ($this->latitudeDec.EOL.$this->longitudeDec.EOL);
$iDb->insert('zonageXY', $tabInsert);
$this->iDb->insert('zonageXY', $tabInsert);
/*if (mysql_errno()>0) echo mysql_error().die(EOL);*/
} else {
$this->precision=$this->latitudeDec=$this->longitudeDec=0;

View File

@ -1468,7 +1468,7 @@ function GPSData($siren, $nic, $values = false)
if (count($result)>0) {
$MInsee = new MInsee($iDb);
$etab = $result[0];
$mMap=new MMap(false);
$mMap=new MMap(false, $iDb);
$mMap->geoCodeAdresse(
$etab['adr_num']
,'',