From 9c30b152245bf5725dba84a5176291d40fdd0d0b Mon Sep 17 00:00:00 2001 From: "Ronald A. Richardson" Date: Fri, 16 Feb 2024 02:58:29 +0700 Subject: [PATCH 1/2] Fixes deprecation error/warning which occurs in some environments `Implicit conversion from float x to int loses precision` when creating a `DistanceMatrix` object --- server/src/Support/DistanceMatrix.php | 4 ++-- server/src/Support/Utils.php | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/server/src/Support/DistanceMatrix.php b/server/src/Support/DistanceMatrix.php index 2ec0e528..0bd3ec61 100644 --- a/server/src/Support/DistanceMatrix.php +++ b/server/src/Support/DistanceMatrix.php @@ -17,9 +17,9 @@ class DistanceMatrix { public ?float $distance; - public ?int $time; + public ?float $time; - public function __construct(?float $distance, ?int $time) + public function __construct(?float $distance, ?float $time) { $this->distance = $distance; $this->time = $time; diff --git a/server/src/Support/Utils.php b/server/src/Support/Utils.php index 03404d24..1ceb8f3f 100644 --- a/server/src/Support/Utils.php +++ b/server/src/Support/Utils.php @@ -783,8 +783,8 @@ function ($destination) { ] )->json(); - $distance = data_get($response, 'rows.0.elements.0.distance.value'); - $time = data_get($response, 'rows.0.elements.0.duration.value'); + $distance = (float) data_get($response, 'rows.0.elements.0.distance.value', 0); + $time = (float) data_get($response, 'rows.0.elements.0.duration.value', 0); $result = static::createObject( [ @@ -812,7 +812,7 @@ public static function calculateDrivingDistanceAndTime($origin, $destination): D $destination = static::getPointFromMixed($destination); $distance = Utils::vincentyGreatCircleDistance($origin, $destination); - $time = round($distance / 100) * self::DRIVING_TIME_MULTIPLIER; + $time = (float) round($distance / 100) * self::DRIVING_TIME_MULTIPLIER; return new DistanceMatrix($distance, $time); } From 53caa428caa6efbc67a96feb7916498d1b2a98c2 Mon Sep 17 00:00:00 2001 From: "Ronald A. Richardson" Date: Fri, 16 Feb 2024 02:59:25 +0700 Subject: [PATCH 2/2] bump version for hotfix --- composer.json | 2 +- extension.json | 2 +- package.json | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/composer.json b/composer.json index d71f4a70..91fa24dd 100644 --- a/composer.json +++ b/composer.json @@ -1,6 +1,6 @@ { "name": "fleetbase/fleetops-api", - "version": "0.4.10", + "version": "0.4.11", "description": "Fleet & Transport Management Extension for Fleetbase", "keywords": [ "fleetbase-extension", diff --git a/extension.json b/extension.json index f0ad12c6..2acd0a74 100644 --- a/extension.json +++ b/extension.json @@ -1,6 +1,6 @@ { "name": "Fleet-Ops", - "version": "0.4.10", + "version": "0.4.11", "description": "Fleet & Transport Management Extension for Fleetbase", "repository": "https://github.com/fleetbase/fleetops", "license": "MIT", diff --git a/package.json b/package.json index c00fd5d8..d10f2153 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@fleetbase/fleetops-engine", - "version": "0.4.10", + "version": "0.4.11", "description": "Fleet & Transport Management Extension for Fleetbase", "fleetbase": { "route": "fleet-ops"