Amélioration géocodage
This commit is contained in:
parent
34eef2cdab
commit
d47f37913e
@ -1454,7 +1454,7 @@ class Saisie extends Scores_Ws_Server
|
||||
}
|
||||
}
|
||||
// --- End of Mathematic control
|
||||
|
||||
|
||||
if ( $step == 'onlycheck' ) {
|
||||
return 1;
|
||||
}
|
||||
@ -2617,7 +2617,7 @@ class Saisie extends Scores_Ws_Server
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set geocode from web application
|
||||
* @param string $companyId
|
||||
@ -2633,7 +2633,7 @@ class Saisie extends Scores_Ws_Server
|
||||
{
|
||||
$this->authenticate();
|
||||
$siren = null;
|
||||
|
||||
|
||||
// --- Identifiant SD : source + id
|
||||
if ($type === null) {
|
||||
|
||||
@ -2648,7 +2648,7 @@ class Saisie extends Scores_Ws_Server
|
||||
else {
|
||||
throw new SoapFault('ERR', 'Type identifiant inconnu.');
|
||||
}
|
||||
|
||||
|
||||
// --- Lecture de l'adresse
|
||||
try {
|
||||
$etablissementM = new Application_Model_JoEtablissements();
|
||||
@ -2672,20 +2672,20 @@ class Saisie extends Scores_Ws_Server
|
||||
if ($result === null) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
// --- Result from database
|
||||
$AdresseNum = $result->adr_num;
|
||||
$AdresseTypeVoie = $result->adr_typeVoie;
|
||||
$AdresseLibVoie = $result->adr_libVoie;
|
||||
$AdresseCP = $result->adr_cp;
|
||||
$AdresseVille = $result->adr_ville;
|
||||
|
||||
|
||||
$insee = new MInsee();
|
||||
$AdresseTypeVoieLong = $insee->getCodeVoie($AdresseTypeVoie);
|
||||
|
||||
$AdresseTypeVoieLong = strtoupper($insee->getCodeVoie($AdresseTypeVoie));
|
||||
|
||||
// --- Format adress
|
||||
$adressPrimary = trim(preg_replace('/ +/',' ', "$AdresseNum $AdresseTypeVoieLong $AdresseLibVoie"));
|
||||
|
||||
|
||||
// --- Code Rivoli
|
||||
$codeRivoli = '';
|
||||
try {
|
||||
@ -2713,7 +2713,7 @@ class Saisie extends Scores_Ws_Server
|
||||
$codeRivoli = $result->ADR_DEP.$result->ADR_COM.$result->CODEVOIE;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// --- Prepare geocoding
|
||||
try {
|
||||
$zonageM = new Application_Model_JoZonageXY();
|
||||
@ -2734,12 +2734,15 @@ class Saisie extends Scores_Ws_Server
|
||||
} else {
|
||||
$tableModif = 'update';
|
||||
}
|
||||
|
||||
|
||||
$output = 0;
|
||||
$data = json_decode($data);
|
||||
if (!empty($data->lat) && !empty($data->lng)) {
|
||||
$precision = 0;
|
||||
$dataGeocode = array();
|
||||
|
||||
// --- Source Google
|
||||
if ( strtolower($data->source) == 'google' ) {
|
||||
$precision = 0;
|
||||
switch($data->precis) {
|
||||
/**
|
||||
* Precise geocode for which we have location information accurate down to street address precision.
|
||||
@ -2767,7 +2770,7 @@ class Saisie extends Scores_Ws_Server
|
||||
$precision = 4;
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
require_once 'Metier/partenaires/classMMap.php';
|
||||
$lambert = geos2lambert93($data->lat, $data->lng);
|
||||
$dataGeocode = array(
|
||||
@ -2779,7 +2782,7 @@ class Saisie extends Scores_Ws_Server
|
||||
'adrTypeVoie' => $AdresseTypeVoie,
|
||||
'adrLibVoie' => $AdresseLibVoie,
|
||||
'rivoli' => $codeRivoli,
|
||||
'adresseValidee' => $data->address,
|
||||
'adresseValidee' => urldecode($data->address),
|
||||
'lat' => $data->lat,
|
||||
'lon' => $data->lng,
|
||||
'l93_x' => $lambert['x_93'],
|
||||
@ -2790,23 +2793,52 @@ class Saisie extends Scores_Ws_Server
|
||||
);
|
||||
}
|
||||
|
||||
try {
|
||||
if ($tableModif == 'insert') {
|
||||
$dataGeocode['dateInsert'] = date('YmdHis');
|
||||
$output = $zonageM->insert($dataGeocode);
|
||||
} else {
|
||||
$output = $zonageM->update($dataGeocode, array('address=?'=>$adressPrimary));
|
||||
if (count($dataGeocode) > 0) {
|
||||
try {
|
||||
if ($tableModif == 'insert') {
|
||||
$dataGeocode['dateInsert'] = date('YmdHis');
|
||||
$output = $zonageM->insert($dataGeocode);
|
||||
} else {
|
||||
$output = $zonageM->update($dataGeocode, array(
|
||||
'address=?' => $adressPrimary,
|
||||
'adr_cp=?' => $AdresseCP,
|
||||
'adr_ville=?' => $AdresseVille,
|
||||
));
|
||||
}
|
||||
} catch (Zend_Db_Exception $e) {
|
||||
if ($this->User->idClient==1) {
|
||||
throw new SoapFault('ERR', $e->getMessage());
|
||||
} else {
|
||||
throw new SoapFault('ERR', "Application error");
|
||||
}
|
||||
}
|
||||
} catch (Zend_Db_Exception $e) {
|
||||
if ($this->User->idClient==1) {
|
||||
throw new SoapFault('ERR', $e->getMessage());
|
||||
} else {
|
||||
throw new SoapFault('ERR', "Application error");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return $output;
|
||||
}
|
||||
|
||||
protected function getLienUser($id, $type = null)
|
||||
{
|
||||
$this->authenticate();
|
||||
//InsertId
|
||||
//InsertUser
|
||||
//InsertDate
|
||||
//UpdateId
|
||||
//UpdateUser
|
||||
//UpdateDate
|
||||
}
|
||||
|
||||
protected function getLienRefUser($id, $type = null)
|
||||
{
|
||||
$this->authenticate();
|
||||
|
||||
//InsertId
|
||||
//InsertUser
|
||||
//InsertDate
|
||||
//UpdateId
|
||||
//UpdateUser
|
||||
//UpdateDate
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user