From 8497d519fc54379d720e62baff2062e66637c330 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Rapha=C3=ABl=20Gertz?= Date: Fri, 10 Nov 2023 15:43:42 +0100 Subject: [PATCH] Fix deprecated implicit conversion from float to int loses precision message --- Util/MapUtil.php | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/Util/MapUtil.php b/Util/MapUtil.php index 9bd8acd..62e6b30 100644 --- a/Util/MapUtil.php +++ b/Util/MapUtil.php @@ -410,13 +410,14 @@ class MapUtil { */ public static function latitudeToSexagesimal(float $latitude): string { //Set degree - $degree = $latitude % 60; + //TODO: see if round or intval is better suited to fix the Deprecated: Implicit conversion from float to int loses precision + $degree = round($latitude) % 60; //Set minute - $minute = ($latitude - $degree) * 60 % 60; + $minute = round(($latitude - $degree) * 60) % 60; //Set second - $second = ($latitude - $degree - $minute / 60) * 3600 % 3600; + $second = round(($latitude - $degree - $minute / 60) * 3600) % 3600; //Return sexagesimal longitude return $degree.'°'.$minute.'\''.$second.'"'.($latitude >= 0 ? 'N' : 'S'); @@ -431,13 +432,14 @@ class MapUtil { */ public static function longitudeToSexagesimal(float $longitude): string { //Set degree - $degree = $longitude % 60; + //TODO: see if round or intval is better suited to fix the Deprecated: Implicit conversion from float to int loses precision + $degree = round($longitude) % 60; //Set minute - $minute = ($longitude - $degree) * 60 % 60; + $minute = round(($longitude - $degree) * 60) % 60; //Set second - $second = ($longitude - $degree - $minute / 60) * 3600 % 3600; + $second = round(($longitude - $degree - $minute / 60) * 3600) % 3600; //Return sexagesimal longitude return $degree.'°'.$minute.'\''.$second.'"'.($longitude >= 0 ? 'E' : 'W'); -- 2.41.1