WIP GWR Umbau mit Netzgebiet und Adressstatus
This commit is contained in:
@@ -13,7 +13,31 @@ class ADBHausnummer extends mfBaseModel {
|
||||
//$this->strasse = new ADBStrasse($this->strasse_id);
|
||||
//$this->plz = new ADBPlz($this->plz_id);
|
||||
}
|
||||
|
||||
/*
|
||||
public static function parseAddresszusatz($text) {
|
||||
$zusatz = "";
|
||||
|
||||
$text = trim($text);
|
||||
if(!$text) return $data;
|
||||
$text = " ".$text;
|
||||
|
||||
$m = [];
|
||||
if(preg_match('/((?:gesch(?:ae|ä)ft|betrieb und wohnungen|paketlogistik|cafe|pavillon|pfarrheim|[^ ]*haus|[^ ]*geb(?:ae|ä)ude|[^ ]*halle)(?:\s+[a-z0-9]+)?)/i', $text, $m)) {
|
||||
$zusatz = $m[1];
|
||||
$text = str_replace($m[0], "", $text);
|
||||
}
|
||||
|
||||
|
||||
|
||||
$text = trim(preg_replace('/\s{2,}/', "", $text));
|
||||
|
||||
if($text) {
|
||||
$data['zusatz'] = $text;
|
||||
}
|
||||
|
||||
|
||||
return $data;
|
||||
}*/
|
||||
|
||||
public function getProperty($name) {
|
||||
if($this->$name == null) {
|
||||
|
||||
@@ -1,11 +1,15 @@
|
||||
<?php
|
||||
|
||||
class ADBHausnummerModel {
|
||||
public $netzgebiet_id;
|
||||
public $extref;
|
||||
public $ortschaft_id;
|
||||
public $plz_id;
|
||||
public $strasse_id;
|
||||
public $kennziffer;
|
||||
public $name;
|
||||
|
||||
public $hausnummer;
|
||||
public $zusatz;
|
||||
public $gps_lat;
|
||||
public $gps_long;
|
||||
|
||||
public $create_by = null;
|
||||
public $edit_by = null;
|
||||
|
||||
51
application/ADBNetzgebiet/ADBNetzgebiet.php
Normal file
51
application/ADBNetzgebiet/ADBNetzgebiet.php
Normal file
@@ -0,0 +1,51 @@
|
||||
<?php
|
||||
|
||||
class ADBNetzgebiet extends mfBaseModel {
|
||||
|
||||
protected function init() {
|
||||
$this->db = FronkDB::singleton(ADDRESSDB_DBHOST, ADDRESSDB_DBUSER, ADDRESSDB_DBPASS, ADDRESSDB_DBNAME);
|
||||
$this->table = "Netzgebiet";
|
||||
}
|
||||
|
||||
public function loadByExtref($extref) {
|
||||
$extref = $this->db->escape(trim($extref));
|
||||
if(!$extref) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$res = $this->db->select("Netzgebiet", "*", "extref='$extref'");
|
||||
if(!$this->db->num_rows($res)) {
|
||||
return false;
|
||||
}
|
||||
$data = $this->db->fetch_object($res);
|
||||
$this->load($data);
|
||||
return true;
|
||||
}
|
||||
|
||||
public function getProperty($name) {
|
||||
if($this->$name == null) {
|
||||
|
||||
if($name == "strasse") {
|
||||
$this->strasse = new ADBStrasse($this->strasse_id);
|
||||
return $this->strasse;
|
||||
}
|
||||
|
||||
if($name == "plz") {
|
||||
$this->plz = new ADBPlz($this->plz_id);
|
||||
return $this->plz;
|
||||
}
|
||||
|
||||
$classname = ucfirst($name);
|
||||
$idfield = $name."_id";
|
||||
$this->$name = new $classname($this->$idfield);
|
||||
|
||||
if($this->$name->id) {
|
||||
return $this->$name;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
return $this->$name;
|
||||
}
|
||||
}
|
||||
@@ -115,8 +115,6 @@ class ADBOrtschaftModel {
|
||||
|
||||
private static function getSqlFilter($filter) {
|
||||
$where = "1=1 ";
|
||||
|
||||
|
||||
|
||||
if(array_key_exists("gemeinde_id", $filter)) {
|
||||
$gemeinde_id = $filter['gemeinde_id'];
|
||||
@@ -137,9 +135,14 @@ class ADBOrtschaftModel {
|
||||
}
|
||||
|
||||
if(array_key_exists("name", $filter)) {
|
||||
$name = FronkDB::singleton()->escape($filter['name']);
|
||||
if($name) {
|
||||
$where .= " AND Ortschaft.`name` = '$name'";
|
||||
if(is_array($filter['name'])) {
|
||||
$name = $filter['name'];
|
||||
$where .= " AND Ortschaft.name IN ('". implode("','", $name)."')";
|
||||
} else {
|
||||
$name = FronkDB::singleton()->escape($filter['name']);
|
||||
if($name) {
|
||||
$where .= " AND Ortschaft.`name` = '$name'";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
<?php
|
||||
|
||||
class ADBPlzModel {
|
||||
public $gemeinde_id;
|
||||
public $plz;
|
||||
public $plzstring;
|
||||
|
||||
|
||||
@@ -1,11 +1,14 @@
|
||||
<?php
|
||||
|
||||
class ADBWohneinheitModel {
|
||||
public $extref;
|
||||
public $hausnummer_id;
|
||||
public $num;
|
||||
public $block;
|
||||
public $stiege;
|
||||
public $stock;
|
||||
public $tuer;
|
||||
public $zusatz;
|
||||
public $nutzung;
|
||||
|
||||
public $create_by = null;
|
||||
|
||||
@@ -9,4 +9,25 @@ class AddressDB {
|
||||
$this->log = mfLoghandler::singleton();
|
||||
}
|
||||
|
||||
|
||||
public function import($input) {
|
||||
$path = __DIR__."/Importer/";
|
||||
$dir = opendir($path);
|
||||
|
||||
while(($file = readdir($dir)) !== false) {
|
||||
if(substr($file, 0, 1) == ".") continue;
|
||||
if(substr($file, -4) != ".php") continue;
|
||||
if(!is_file($path.$file)) continue;
|
||||
|
||||
require_once $path.$file;
|
||||
$classname = "AddressDB_Importer_".ucfirst(substr($file, 0, strlen($file)-4));
|
||||
if(class_exists($classname)) {
|
||||
$importer = new $classname();
|
||||
if($importer->isValid($input)) {
|
||||
return $importer->import();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -13,11 +13,7 @@ class AddressDBController extends mfBaseController {
|
||||
$this->redirect("Dashboard");
|
||||
}
|
||||
}
|
||||
|
||||
protected function importAction($input) {
|
||||
|
||||
}
|
||||
|
||||
|
||||
protected function apiAction() {
|
||||
if(!$this->me->is(["Admin","netowner"])) {
|
||||
$this->redirect("Dashboard");
|
||||
|
||||
@@ -4,12 +4,25 @@ class AddressDB_Importer_Csv {
|
||||
private $db;
|
||||
private $log;
|
||||
|
||||
private $input;
|
||||
|
||||
public function __construct() {
|
||||
$this->db = FronkDB::singleton(ADDRESSDB_DBHOST, ADDRESSDB_DBUSER, ADDRESSDB_DBPASS, ADDRESSDB_DBNAME);
|
||||
$this->log = mfLoghandler::singleton();
|
||||
}
|
||||
|
||||
public function import($input) {
|
||||
public function isValid($input) {
|
||||
if(strlen($input) < 1024 && strpos($input, "\n") === false) {
|
||||
$this->input = $input;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public function import() {
|
||||
echo "importing...\n";exit;
|
||||
$input = $this->input;
|
||||
|
||||
if(!$input) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@ class AddressDB_Importer_Rimo {
|
||||
|
||||
private $campaign;
|
||||
|
||||
public function __construct(Preordercampain $campaign) {
|
||||
public function __construct() {
|
||||
$this->db = FronkDB::singleton(ADDRESSDB_DBHOST, ADDRESSDB_DBUSER, ADDRESSDB_DBPASS, ADDRESSDB_DBNAME);
|
||||
$this->log = mfLoghandler::singleton();
|
||||
}
|
||||
|
||||
@@ -35,8 +35,10 @@ class AddressdbApicontroller extends mfBaseApicontroller {
|
||||
}
|
||||
|
||||
protected function findCity() {
|
||||
// unofficially supporting GET and POST in v1
|
||||
$get = array_merge($this->post, $this->get);
|
||||
|
||||
// search parameter is unofficially deprecated but still supported
|
||||
$search = trim($get['search']);
|
||||
$city = trim($get['city']);
|
||||
$zip = trim($get['zip']);
|
||||
@@ -67,8 +69,10 @@ class AddressdbApicontroller extends mfBaseApicontroller {
|
||||
}
|
||||
|
||||
protected function findZip() {
|
||||
// unofficially supporting GET and POST in v1
|
||||
$get = array_merge($this->post, $this->get);
|
||||
|
||||
// search parameter is unofficially deprecated but still supported
|
||||
$search = trim($get['search']);
|
||||
$zip = trim($get['zip']);
|
||||
|
||||
@@ -93,8 +97,10 @@ class AddressdbApicontroller extends mfBaseApicontroller {
|
||||
}
|
||||
|
||||
protected function findStreet() {
|
||||
// unofficially supporting GET and POST in v1
|
||||
$get = array_merge($this->post, $this->get);
|
||||
|
||||
// search parameter is unofficially deprecated but still supported
|
||||
$search = trim($get['search']);
|
||||
$street = trim($get['street']);
|
||||
$city = trim($get['city']);
|
||||
@@ -129,6 +135,7 @@ class AddressdbApicontroller extends mfBaseApicontroller {
|
||||
}
|
||||
|
||||
protected function find() {
|
||||
// unofficially supporting GET and POST in v1
|
||||
$get = array_merge($this->post, $this->get);
|
||||
|
||||
$search_street = $this->db()->escape(trim($get['street']));
|
||||
|
||||
295
scripts/addressdb_update.php
Executable file
295
scripts/addressdb_update.php
Executable file
@@ -0,0 +1,295 @@
|
||||
#!/usr/bin/php
|
||||
<?php
|
||||
|
||||
//require 'vendor/autoload.php';
|
||||
require("../config/config.php");
|
||||
|
||||
define('FRONKDB_SQLDEBUG',false);
|
||||
error_reporting(E_ALL & ~(E_NOTICE | E_STRICT | E_DEPRECATED));
|
||||
|
||||
require_once(LIBDIR."/mvcfronk/mfRouter/mfRouter.php");
|
||||
require_once(LIBDIR."/mvcfronk/mfBase/mfBaseModel.php");
|
||||
require_once(LIBDIR."/mvcfronk/mfBase/mfBaseController.php");
|
||||
|
||||
$me = new User(1);
|
||||
|
||||
$filename = BASEDIR."/scripts/import/60670-1u2__Premstaetten_FTTxLocations.csv";
|
||||
|
||||
$db = FronkDB::singleton(ADDRESSDB_DBHOST, ADDRESSDB_DBUSER, ADDRESSDB_DBPASS, ADDRESSDB_DBNAME);
|
||||
$log = mfLoghandler::singleton();
|
||||
|
||||
$input = fopen($filename, "r");
|
||||
|
||||
$h_extrefs = [];
|
||||
|
||||
$i = 0;
|
||||
while($csv = fgetcsv($input, 0, ",")) {
|
||||
$i++;
|
||||
if($i == 1) continue;
|
||||
|
||||
|
||||
if(!trim($csv[0])) {
|
||||
continue;
|
||||
} else {
|
||||
//echo implode(", ", $csv)."\n";
|
||||
$gem_kz = trim($csv[1]);
|
||||
$gem_name = trim($csv[0]);
|
||||
//$ort_kz = trim($csv[2]);
|
||||
$plz_name = trim($csv[3]);
|
||||
$ort_name = trim($csv[4]);
|
||||
$strasse_hausnummer = trim($csv[5]);
|
||||
$hausnummer_extref = trim($csv[35]);
|
||||
if(in_array($hausnummer_extref, $h_extrefs)) {
|
||||
die("Hausnummer extref doppelt!\n");
|
||||
}
|
||||
$h_extrefs[] = $hausnummer_extref;
|
||||
|
||||
$lat = trim($csv[17]);
|
||||
$long = trim($csv[18]);
|
||||
|
||||
$netzgebiet_extref = trim($csv[26]);
|
||||
$netzgebiet = new ADBNetzgebiet();
|
||||
$netzgebiet->loadByExtref($netzgebiet_extref);
|
||||
if(!$netzgebiet->id) {
|
||||
die("Netzgebiet nicht gefunden: $netzgebiet_extref\n");
|
||||
}
|
||||
//var_dump($netzgebiet);exit;
|
||||
|
||||
$nutzung = trim($csv[7]);
|
||||
$funktion = trim($csv[9]);
|
||||
if($nutzung != "Greenfield" && $funktion == "Greenfield") {
|
||||
$nutzung = "Greenfield";
|
||||
}
|
||||
|
||||
if(!$strasse_hausnummer) continue;
|
||||
|
||||
//echo "strasse: $strasse\n";
|
||||
//echo "strasse_building: $strasse_building\n";
|
||||
|
||||
$strasse_name = "";
|
||||
$hausnummer_name = "";
|
||||
$addresszusatz = "";
|
||||
|
||||
$m = [];
|
||||
// (?:\s+((?:gesch(?:ae|ä)ft|betrieb und wohnungen|paketlogistik|cafe|pavillon|pfarrheim|[^ ]*haus|[^ ]*geb(?:ae|ä)ude|[^ ]*halle)(?:\s+[a-z0-9]+)?))?
|
||||
if(preg_match('/^(\D+)\s+(\d+[a-z0-9\/&#._-]*)(?:\s+((?:gesch(?:ae|ä)ft|betrieb und wohnungen|stg|paketlogistik|cafe|pavillon|pfarrheim|[^ ]*haus|[^ ]*geb(?:ae|ä)ude|[^ ]*halle)(?:\s+[a-z0-9]+)?))?/i', $strasse_hausnummer, $m)) {
|
||||
$strasse_name = trim($m[1]);
|
||||
$hausnummer_name = trim($m[2]);
|
||||
$addresszusatz = trim($m[3]);
|
||||
} elseif(preg_match('/^(.+)\s+(\d+[a-z0-9\/&#._-]*)(.+)?/i', $strasse_hausnummer, $m)) {
|
||||
$strasse_name = trim($m[1]);
|
||||
$hausnummer_name = trim($m[2]);
|
||||
$addresszusatz = trim($m[3]);
|
||||
} elseif(preg_match('/^(.+)/i', $strasse_hausnummer, $m)) {
|
||||
// ignore GST objects
|
||||
continue;
|
||||
$strasse_name = trim($m[1]);
|
||||
}
|
||||
|
||||
if($strasse_name == "Dr.Karl-Renner-Weg") $strasse_name = "Dr.-Karl-Renner-Weg";
|
||||
if($strasse_name == "Bierbaumer Strasse") $strasse_name = "Bierbaumerstrasse";
|
||||
if($strasse_name == "GST") continue;
|
||||
if(preg_match('/^L\d+/',$strasse_name)) continue;
|
||||
|
||||
/*if($strasse_name == "Hauptstrasse 103 Geschaeft" && $hausnummer_name == "1") {
|
||||
$strasse_name = "Hauptstrasse";
|
||||
$hausnummer_name = "103";
|
||||
$addresszusatz = "Geschaeft 1";
|
||||
}
|
||||
|
||||
if($strasse_name == "Hauptstrasse 131 Stg") {
|
||||
$strasse_name = "Hauptstrasse";
|
||||
$addresszusatz = "Stg $hausnummer_name";
|
||||
$hausnummer_name = "131";
|
||||
}*/
|
||||
|
||||
if(!$strasse_name && !$nutzung == "Greenfield") {
|
||||
die("Unbekanntes Adressformat\n");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
if(!$gem_name || !$plz_name || !$ort_name || !$strasse_name) {
|
||||
die("!! Konnte Adresse nicht parsen\n");
|
||||
}
|
||||
|
||||
if(!$hausnummer_extref) {
|
||||
die("!!! Keine Hausnummer Extref\n");
|
||||
}
|
||||
|
||||
if(!$netzgebiet_extref) {
|
||||
die("!!! Keine Netzgebiet Extref\n");
|
||||
}
|
||||
if($nutzung == "Greenfield") continue;
|
||||
//echo "Netzgebiet extref: \033[1m$netzgebiet_extref\033[0m | Hausnummer extref: \033[1m$hausnummer_extref\033[0m | gem: \033[1m$gem_name\033[0m | plz: \033[1m$plz_name\033[0m | ort: \033[1m$ort_name\033[0m | strasse: \033[1m$strasse_name\033[0m | hausnummer: \033[1m$hausnummer_name\033[0m |";
|
||||
//echo "Zusatz: \033[1m$addresszusatz\033[0m | (\033[1m$nutzung\033[0m)\n";
|
||||
//continue;
|
||||
// find address in AddressDB and update extrefs
|
||||
|
||||
$strasse_name = $db->escape($strasse_name);
|
||||
$hausnummer_name = $db->escape($hausnummer_name);
|
||||
|
||||
$strasse_search = [$strasse_name];
|
||||
|
||||
if(strpos($strasse_name, ' ') !== false) $strasse_search[] = str_replace(' ', '-', $strasse_name);
|
||||
if(strpos($strasse_name, '-') !== false) $strasse_search[] = str_replace('-', ' ', $strasse_name);
|
||||
if(strpos($strasse_name, '.') !== false) $strasse_search[] = str_replace('.', '. ', $strasse_name);
|
||||
if(strpos($strasse_name, '.') !== false) $strasse_search[] = str_replace('.', '.-', $strasse_name);
|
||||
if(strpos($strasse_name, '. ') !== false) $strasse_search[] = str_replace('. ', '.', $strasse_name);
|
||||
if(strpos($strasse_name, '. ') !== false) $strasse_search[] = str_replace('. ', '.-', $strasse_name);
|
||||
if(strpos($strasse_name, '.') !== false) $strasse_search[] = str_replace('.-', '.', $strasse_name);
|
||||
if(strpos($strasse_name, '.') !== false) $strasse_search[] = str_replace('.-', '. ', $strasse_name);
|
||||
|
||||
foreach($strasse_search as $search) {
|
||||
if(strpos($search, 'ß') !== false) $strasse_search[] = str_replace('ß', 'ss', $search);
|
||||
if(strpos($search, 'ä') !== false) $strasse_search[] = str_replace('ä', 'ae', $search);
|
||||
if(strpos($search, 'ö') !== false) $strasse_search[] = str_replace('ö', 'oe', $search);
|
||||
if(strpos($search, 'ü') !== false) $strasse_search[] = str_replace('ü', 'ue', $search);
|
||||
|
||||
if(strpos($search, 'ss') !== false) $strasse_search[] = str_replace('ss', 'ß', $search);
|
||||
if(strpos($search, 'ae') !== false) $strasse_search[] = str_replace('ae', 'ä', $search);
|
||||
if(strpos($search, 'oe') !== false) $strasse_search[] = str_replace('oe', 'ö', $search);
|
||||
if(strpos($search, 'ue') !== false) $strasse_search[] = str_replace('ue', 'ü', $search);
|
||||
}
|
||||
|
||||
|
||||
$sql = "SELECT * FROM view_hausnummer WHERE gemeinde_id = 1 AND strasse IN ('". implode("', '", $strasse_search)."') AND hausnummer='$hausnummer_name'";
|
||||
/*if(preg_match('/^Tobelbader/i',$strasse_name)) {
|
||||
echo "$sql\n";
|
||||
}*/
|
||||
$res = $db->query($sql);
|
||||
|
||||
if(!$db->num_rows($res)) {
|
||||
// adresse nicht gefunden => anlegen
|
||||
|
||||
if($nutzung == "Greenfield") continue;
|
||||
if(!$nutzung || $nutzung == "Transmitting station") continue;
|
||||
|
||||
echo "creating $strasse_name $hausnummer_name $ort_name\n";
|
||||
|
||||
$ort_search = [$ort_name];
|
||||
|
||||
if(strpos($ort_name, 'ß') !== false) $ort_search[] = str_replace('ß', 'ss', $ort_name);
|
||||
if(strpos($ort_name, 'ä') !== false) $ort_search[] = str_replace('ä', 'ae', $ort_name);
|
||||
if(strpos($ort_name, 'ö') !== false) $ort_search[] = str_replace('ö', 'oe', $ort_name);
|
||||
if(strpos($ort_name, 'ü') !== false) $ort_search[] = str_replace('ü', 'ue', $ort_name);
|
||||
|
||||
if(strpos($ort_name, 'ss') !== false) $ort_search[] = str_replace('ss', 'ß', $ort_name);
|
||||
if(strpos($ort_name, 'ae') !== false) $ort_search[] = str_replace('ae', 'ä', $ort_name);
|
||||
if(strpos($ort_name, 'oe') !== false) $ort_search[] = str_replace('oe', 'ö', $ort_name);
|
||||
if(strpos($ort_name, 'ue') !== false) $ort_search[] = str_replace('ue', 'ü', $ort_name);
|
||||
|
||||
$ortschaft = ADBOrtschaftModel::getFirst(['name' => $ort_search]);
|
||||
if(!$ortschaft->id) die("Ortschaft nicht gefunden: $ort_name\n");
|
||||
|
||||
$strasse_id = false;
|
||||
|
||||
$strsql = "SELECT * FROM view_hausnummer WHERE gemeinde_id=1 AND ortschaft IN ('". implode("', '", $ort_search)."') AND strasse IN ('". implode("', '", $strasse_search)."')";
|
||||
echo "$strsql\n";exit;
|
||||
$strres = $db->query($strsql);
|
||||
if(!$db->num_rows($strres)) {
|
||||
echo("Strasse in adressdb nicht gefunden: $strsql\n");
|
||||
|
||||
// create strasse
|
||||
|
||||
$strasse_data = [
|
||||
'ortschaft_id' => $ortschaft->id,
|
||||
'gemeinde_id' => 1,
|
||||
'name' => $strasse_name
|
||||
];
|
||||
$strasse = ADBStrasseModel::create($strasse_data);
|
||||
$strasse_id = $strasse->save();
|
||||
if(!$strasse_id) die("Cannot create strasse: $strasse_name\n");
|
||||
} else {
|
||||
$data = $db->fetch_object($strres);
|
||||
$strasse_id = $data->strasse_id;
|
||||
}
|
||||
|
||||
if(!$strasse_id) {
|
||||
die("keine strasse_id");
|
||||
}
|
||||
|
||||
$plz = ADBPlzModel::getFirst(['plz' => $plz_name]);
|
||||
if(!$plz) die("PLZ nicht gefunden: $plz_name\n");
|
||||
|
||||
$hausnummer_data = [
|
||||
'netzgebiet_id' => $netzgebiet->id,
|
||||
'extref' => $hausnummer_extref,
|
||||
'ortschaft_id' => $ortschaft->id,
|
||||
'plz_id' => $plz->id,
|
||||
'strasse_id' => $strasse_id,
|
||||
'hausnummer' => $hausnummer_name,
|
||||
'zusatz' => $addresszusatz,
|
||||
'gps_lat' => $lat,
|
||||
'gps_long' => $long
|
||||
];
|
||||
|
||||
//var_dump($hausnummer_data);exit;
|
||||
$hausnummer = ADBHausnummerModel::create($hausnummer_data);
|
||||
$hausnummer_id = $hausnummer->save();
|
||||
|
||||
if(!$hausnummer_id) die("Error creating hausnummer");
|
||||
|
||||
} else {
|
||||
$data = $db->fetch_object($res);
|
||||
$hausnummer = new ADBHausnummer($data->hausnummer_id);
|
||||
|
||||
if($hausnummer->netzgebiet_id != $netzgebiet->id) {
|
||||
$hausnummer->netzgebiet_id = $netzgebiet->id;
|
||||
$hausnummer->save();
|
||||
}
|
||||
if($hausnummer->extref != $hausnummer_extref) {
|
||||
$hausnummer->extref = $hausnummer_extref;
|
||||
$hausnummer->save();
|
||||
}
|
||||
$hausnummer->gps_lat = $lat;
|
||||
$hausnummer->gps_long = $long;
|
||||
$hausnummer->save();
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
$data = $db->fetch_object($res);
|
||||
$csv_ort = str_replace(['ß','ä','ö','ü'], ['ss','ae','oe','ue'], $ort_name);
|
||||
$db_ort = str_replace(['ß','ä','ö','ü'], ['ss','ae','oe','ue'], $data->ortschaft);
|
||||
|
||||
// update ortschaft if needed
|
||||
if($csv_ort != $db_ort && $nutzung != "Greenfield") {
|
||||
|
||||
if($strasse_name != "Hauptstrasse" && $hausnummer_name != "133") {
|
||||
|
||||
echo "Netzgebiet extref: \033[1m-------\033[0m | Hausnummer extref: \033[1m--------\033[0m | gem: \033[1m$data->gemeinde\033[0m | plz: \033[1m$data->plz\033[0m | ort: \033[1m$db_ort\033[0m | strasse: \033[1m$data->strasse\033[0m | hausnummer: \033[1m$data->hausnummer\033[0m\n";
|
||||
// find ortschaft
|
||||
|
||||
/*$ortschaft = ADBOrtschaftModel::getFirst(['name' => $ort_name]);
|
||||
if(!$ortschaft) {
|
||||
$ort_data = [];
|
||||
$ort_data['gemeinde_id'] = 1;
|
||||
$ort_data['name'] = $ort_name;
|
||||
$ort_data['plz'] = $plz_name;
|
||||
$ortschaft = ADBOrtschaftModel::create($ort_data);
|
||||
$ortschaft_id = $ortschaft->save();
|
||||
if(!$ortschaft_id) {
|
||||
die("Konnte Ortschaft ($ort_name) nicht erstellen.");
|
||||
}
|
||||
}
|
||||
|
||||
// update ortschaft in hausnummer
|
||||
$hausnummer = new ADBHausnummer($data->hausnummer_id);
|
||||
if(!$hausnummer->id) {
|
||||
die("Hausnummer nicht gefunden für Ort update");
|
||||
}
|
||||
$hausnummer->ortschaft_id = $ortschaft->id;
|
||||
$hausnummer->save();*/
|
||||
}
|
||||
}
|
||||
|
||||
//echo "$data->ortschaft, $data->plz, $data->strasse, $data->hausnummer\n";
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user