From 3c77290a0a19f0dadac25e0485d45542c919a044 Mon Sep 17 00:00:00 2001 From: Aaron Parecki Date: Tue, 16 Oct 2018 15:40:00 +0200 Subject: [PATCH] better error check for geocoding --- compass/app/Jobs/TripComplete.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/compass/app/Jobs/TripComplete.php b/compass/app/Jobs/TripComplete.php index 210db0d..9f90923 100644 --- a/compass/app/Jobs/TripComplete.php +++ b/compass/app/Jobs/TripComplete.php @@ -37,7 +37,7 @@ class TripComplete extends Job implements SelfHandling, ShouldQueue // Don't run the web hooks for manually created trips if(isset($this->_data['properties']['end_location'])) { $urls = preg_split('/\s+/', $db->ping_urls); - + // Build a trip object that looks like the active trip format from Overland $trip = [ 'trip' => [ @@ -133,7 +133,7 @@ class TripComplete extends Job implements SelfHandling, ShouldQueue ]; Log::info('Looking up start location'); $start = self::geocode($startAdr['properties']['latitude'], $startAdr['properties']['longitude']); - if($start) { + if($start && property_exists($start, 'locality')) { $startAdr['properties']['locality'] = $start->locality; $startAdr['properties']['region'] = $start->region; $startAdr['properties']['country'] = $start->country; @@ -154,7 +154,7 @@ class TripComplete extends Job implements SelfHandling, ShouldQueue ]; Log::info('Looking up end location'); $end = self::geocode($endAdr['properties']['latitude'], $endAdr['properties']['longitude']); - if($end) { + if($end && property_exists($end, 'locality')) { $endAdr['properties']['locality'] = $end->locality; $endAdr['properties']['region'] = $end->region; $endAdr['properties']['country'] = $end->country;