Skip to content

Commit

Permalink
Merge pull request #76 from fleetbase/hotfix/distance-matrix-definition
Browse files Browse the repository at this point in the history
hotfix: `DistanceMatrix` definition
  • Loading branch information
roncodes authored Feb 15, 2024
2 parents 2703d5c + 53caa42 commit b9d0b40
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
2 changes: 1 addition & 1 deletion extension.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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"
Expand Down
4 changes: 2 additions & 2 deletions server/src/Support/DistanceMatrix.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
6 changes: 3 additions & 3 deletions server/src/Support/Utils.php
Original file line number Diff line number Diff line change
Expand Up @@ -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(
[
Expand Down Expand Up @@ -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);
}
Expand Down

0 comments on commit b9d0b40

Please sign in to comment.