Now trimming decimal gps values to not be truncated in database
This commit is contained in:
@@ -154,8 +154,10 @@ class AddressHelper
|
||||
$ort_name = $this->db->escape(trim($building->address->city));
|
||||
$plz_name = $this->db->escape(trim($building->address->zipCode));
|
||||
|
||||
$lat = $building->address->latitude;
|
||||
$long = $building->address->longitude;
|
||||
$lat = ($building->address->latitude) ? $this->truncateFloat($building->address->latitude, 14) : null;
|
||||
$long = ($building->address->longitude) ? $this->truncateFloat($building->address->longitude, 14) : null;
|
||||
//$lat = $building->address->latitude;
|
||||
//$long = $building->address->longitude;
|
||||
$unit_count = $building->homesCount;
|
||||
$lot_num = $building->address->lotNumber;
|
||||
$fcp_name = false;
|
||||
@@ -324,7 +326,7 @@ class AddressHelper
|
||||
"hausnummer" => $hausnummer_name,
|
||||
"zusatz" => ($addresszusatz) ? $addresszusatz : null,
|
||||
"grund_nr" => ($lot_num) ? $lot_num : null,
|
||||
"gps_lat" => $lat,
|
||||
"gps_lat" => (float)$lat,
|
||||
"gps_long" => $long,
|
||||
"unit_count" => ($unit_count) ? $unit_count : 1,
|
||||
"freigabe" => $this->netzgebiet->freigabe,
|
||||
@@ -527,10 +529,26 @@ class AddressHelper
|
||||
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)
|
||||
{
|
||||
$logtext = trim($text);
|
||||
$this->find_address_error = $logtext;
|
||||
echo $logtext . "\n";
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user