]> Raphaël G. Git Repositories - packbundle/commitdiff
Fix deprecated implicit conversion from float to int loses precision message
authorRaphaël Gertz <git@rapsys.eu>
Fri, 10 Nov 2023 14:43:42 +0000 (15:43 +0100)
committerRaphaël Gertz <git@rapsys.eu>
Fri, 10 Nov 2023 14:51:42 +0000 (15:51 +0100)
Util/MapUtil.php

index 9bd8acd9e14e3eabaa705dc7888eda25ac203f6f..62e6b30dfd7bc4c9e72cfc55202b8113b7dcf256 100644 (file)
@@ -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');