diff --git a/bin/lms-gps.php b/bin/lms-gps.php index 64865a0f9b..928ff3d0ef 100755 --- a/bin/lms-gps.php +++ b/bin/lms-gps.php @@ -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, @@ -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)) { diff --git a/lib/common.php b/lib/common.php index 498e98f082..c85b77d1f9 100644 --- a/lib/common.php +++ b/lib/common.php @@ -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'] : '',