Now trimming decimal gps values to not be truncated in database
This commit is contained in:
@@ -107,6 +107,12 @@ class ADBWohneinheit extends mfBaseModel {
|
|||||||
$old_status = new ADBStatus($this->_old_data->status_id);
|
$old_status = new ADBStatus($this->_old_data->status_id);
|
||||||
$new_status = new ADBStatus($this->data->status_id);
|
$new_status = new ADBStatus($this->data->status_id);
|
||||||
$logstr .= "| '$key' => FROM '".$this->_old_data->$key."' TO '".$this->data->$key."' [".$old_status->code." => ".$new_status->code."]";
|
$logstr .= "| '$key' => FROM '".$this->_old_data->$key."' TO '".$this->data->$key."' [".$old_status->code." => ".$new_status->code."]";
|
||||||
|
} elseif($key = "external_data" && $this->_old_data->external_data && $this->external_data) {
|
||||||
|
$old_data = json_decode($this->_old_data->external_data);
|
||||||
|
$new_data = json_decode($this->external_data);
|
||||||
|
if(json_encode($old_data) !== json_encode($new_data)) {
|
||||||
|
$logstr .= "| '$key' => FROM '".$this->_old_data->$key."' TO '".$this->data->$key."'";
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
$logstr .= "| '$key' => FROM '".$this->_old_data->$key."' TO '".$this->data->$key."'";
|
$logstr .= "| '$key' => FROM '".$this->_old_data->$key."' TO '".$this->data->$key."'";
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,39 @@
|
|||||||
|
<?php
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
use Phinx\Migration\AbstractMigration;
|
||||||
|
|
||||||
|
final class AdbIncreaseGpsFloatSize extends AbstractMigration
|
||||||
|
{
|
||||||
|
public function up(): void
|
||||||
|
{
|
||||||
|
if($this->getEnvironment() == "thetool") {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
if($this->getEnvironment() == "addressdb") {
|
||||||
|
$hn = $this->table("Hausnummer");
|
||||||
|
$hn->changeColumn("gps_lat", "decimal", ["null" => true, "default" => null, "precision" => 17, "scale" => 14]);
|
||||||
|
$hn->changeColumn("gps_long", "decimal", ["null" => true, "default" => null, "precision" => 17, "scale" => 14]);
|
||||||
|
$hn->changeColumn("borderpoint_lat", "decimal", ["null" => true, "default" => null, "precision" => 17, "scale" => 14]);
|
||||||
|
$hn->changeColumn("borderpoint_long", "decimal", ["null" => true, "default" => null, "precision" => 17, "scale" => 14]);
|
||||||
|
$hn->update();
|
||||||
|
|
||||||
|
$fcp = $this->table("RimoFcp");
|
||||||
|
$fcp->changeColumn("gps_lat", "decimal", ["null" => true, "default" => null, "precision" => 17, "scale" => 14]);
|
||||||
|
$fcp->changeColumn("gps_long", "decimal", ["null" => true, "default" => null, "precision" => 17, "scale" => 14]);
|
||||||
|
$fcp->update();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function down(): void
|
||||||
|
{
|
||||||
|
if($this->getEnvironment() == "thetool") {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
if($this->getEnvironment() == "addressdb") {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -154,8 +154,10 @@ class AddressHelper
|
|||||||
$ort_name = $this->db->escape(trim($building->address->city));
|
$ort_name = $this->db->escape(trim($building->address->city));
|
||||||
$plz_name = $this->db->escape(trim($building->address->zipCode));
|
$plz_name = $this->db->escape(trim($building->address->zipCode));
|
||||||
|
|
||||||
$lat = $building->address->latitude;
|
$lat = ($building->address->latitude) ? $this->truncateFloat($building->address->latitude, 14) : null;
|
||||||
$long = $building->address->longitude;
|
$long = ($building->address->longitude) ? $this->truncateFloat($building->address->longitude, 14) : null;
|
||||||
|
//$lat = $building->address->latitude;
|
||||||
|
//$long = $building->address->longitude;
|
||||||
$unit_count = $building->homesCount;
|
$unit_count = $building->homesCount;
|
||||||
$lot_num = $building->address->lotNumber;
|
$lot_num = $building->address->lotNumber;
|
||||||
$fcp_name = false;
|
$fcp_name = false;
|
||||||
@@ -324,7 +326,7 @@ class AddressHelper
|
|||||||
"hausnummer" => $hausnummer_name,
|
"hausnummer" => $hausnummer_name,
|
||||||
"zusatz" => ($addresszusatz) ? $addresszusatz : null,
|
"zusatz" => ($addresszusatz) ? $addresszusatz : null,
|
||||||
"grund_nr" => ($lot_num) ? $lot_num : null,
|
"grund_nr" => ($lot_num) ? $lot_num : null,
|
||||||
"gps_lat" => $lat,
|
"gps_lat" => (float)$lat,
|
||||||
"gps_long" => $long,
|
"gps_long" => $long,
|
||||||
"unit_count" => ($unit_count) ? $unit_count : 1,
|
"unit_count" => ($unit_count) ? $unit_count : 1,
|
||||||
"freigabe" => $this->netzgebiet->freigabe,
|
"freigabe" => $this->netzgebiet->freigabe,
|
||||||
@@ -527,10 +529,26 @@ class AddressHelper
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function truncateFloat($number, $digits = 10) {
|
||||||
|
if(!$number) return null;
|
||||||
|
if(!is_numeric($number)) return null;
|
||||||
|
if(strpos($number, ".") === false) return $number;
|
||||||
|
|
||||||
|
list ($num_part, $dec_part) = explode(".", $number);
|
||||||
|
if(strlen($dec_part) > $digits) {
|
||||||
|
$dec_part = substr($dec_part, 0, $digits);
|
||||||
|
}
|
||||||
|
|
||||||
|
$new_number_str = (string)$num_part . "." . (string)$dec_part;
|
||||||
|
return (float)$new_number_str;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
private function logFindAddressError($text)
|
private function logFindAddressError($text)
|
||||||
{
|
{
|
||||||
$logtext = trim($text);
|
$logtext = trim($text);
|
||||||
$this->find_address_error = $logtext;
|
$this->find_address_error = $logtext;
|
||||||
echo $logtext . "\n";
|
echo $logtext . "\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user