Skip to content

Commit

Permalink
bugfix: fixed some php warnings and google geocode api error info
Browse files Browse the repository at this point in the history
  • Loading branch information
chilek committed Feb 16, 2023
1 parent dbbe61a commit baa5d57
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
5 changes: 2 additions & 3 deletions bin/lms-gps.php
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ function array_provider_filter($provider)
$locations = $DB->GetAll(
"SELECT
t.id, va.location, va.city_id, va.street_id, va.house, ls.name AS state_name,
ld.name AS distict_name, lb.name AS borough_name,
ld.name AS district_name, lb.name AS borough_name,
va.city AS city_name,
va.zip AS zip,
c.name AS country_name,
Expand Down Expand Up @@ -289,8 +289,7 @@ function array_provider_filter($provider)
break;
} else {
if (!$quiet) {
echo 'google: #' . $row['id'] . " - ERROR - Accuracy: " . $res['accuracy']
. " (lat.: " . $res['latitude'] . " long.: " . $res['longitude'] . ")" . PHP_EOL;
echo 'google: #' . $row['id'] . " - ERROR: " . $res['status'] . ' (' . $res['error'] . ')' . PHP_EOL;
}
}
if (empty($google_api_key)) {
Expand Down
7 changes: 4 additions & 3 deletions lib/common.php
Original file line number Diff line number Diff line change
Expand Up @@ -1449,10 +1449,11 @@ function geocode($location)
}

$page = json_decode($res, true);
$latitude = str_replace(',', '.', $page["results"][0]["geometry"]["location"]["lat"]);
$longitude = str_replace(',', '.', $page["results"][0]["geometry"]["location"]["lng"]);

$latitude = empty($page['results']) ? null : str_replace(',', '.', $page["results"][0]["geometry"]["location"]["lat"]);
$longitude = empty($page['results']) ? null : str_replace(',', '.', $page["results"][0]["geometry"]["location"]["lng"]);
$accuracy = empty($page['results']) ? null : $page["results"][0]["geometry"]["location_type"];
$status = $page["status"];
$accuracy = $page["results"][0]["geometry"]["location_type"];
return array(
'status' => $status,
'error' => isset($page['error_message']) ? $page['error_message'] : '',
Expand Down

0 comments on commit baa5d57

Please sign in to comment.