Now getting building coordinates from Google Maps Geocoding
This commit is contained in:
@@ -70,13 +70,13 @@ class BuildingController extends mfBaseController {
|
||||
$data['type_id'] = $r->type_id;
|
||||
$data['status_id'] = ($r->status_id) ? $r->status_id : null;
|
||||
$data['pipeworker_id'] = ($r->pipeworker_id) ? $r->pipeworker_id : null;
|
||||
$data['code'] = $r->code;
|
||||
|
||||
$data['oan_id'] = $r->oan_id;
|
||||
$data['street'] = $r->street;
|
||||
$data['zip'] = $r->zip;
|
||||
$data['city'] = $r->city;
|
||||
$data['gps_lat'] = $r->gps_lat;
|
||||
$data['gps_long'] = $r->gps_long;
|
||||
|
||||
|
||||
$data['contact'] = $r->contact;
|
||||
$data['phone'] = $r->phone;
|
||||
$data['email'] = $r->email;
|
||||
@@ -86,6 +86,13 @@ class BuildingController extends mfBaseController {
|
||||
|
||||
$data['edit_by'] = 1;
|
||||
|
||||
if($this->me->is("Admin")) {
|
||||
if($r->gps_lat) $data['gps_lat'] = $r->gps_lat;
|
||||
if($r->gps_long) $data['gps_long'] = $r->gps_long;
|
||||
if($r->code) $data['code'] = $r->code;
|
||||
if($r->laea) $data['laea'] = $r->laea;
|
||||
}
|
||||
|
||||
if($mode == "add") {
|
||||
$data['status_id'] = 1;
|
||||
$data['create_by'] = 1;
|
||||
@@ -103,6 +110,22 @@ class BuildingController extends mfBaseController {
|
||||
return $this->add();
|
||||
}
|
||||
|
||||
// get GPS location
|
||||
if(!$building->gps_lat && !$building->gps_long) {
|
||||
$search = [
|
||||
'country' => "AT",
|
||||
'city' => $building->city,
|
||||
'zip' => $building->zip,
|
||||
'street' => $building->street
|
||||
];
|
||||
$coords = Gmaps_Geocoding::getCoords($search);
|
||||
if(is_array($coords) && count($coords) == 2) {
|
||||
$building->gps_lat = str_replace(",",".",$coords[0]);
|
||||
$building->gps_long = str_replace(",",".",$coords[1]);
|
||||
$building->save();
|
||||
}
|
||||
}
|
||||
|
||||
// generate object code and LAEA coords
|
||||
if(!$building->code) {
|
||||
$building->code = $building->getNewObjectCode();
|
||||
|
||||
Reference in New Issue
Block a user