From b7bf17ee9dfb2b9260bc12821ba55d18b58955bd Mon Sep 17 00:00:00 2001 From: Samer Albahra Date: Fri, 3 Jul 2015 13:56:06 -0500 Subject: [PATCH] Add fallback coordinates if none are provided by observation location --- routes/weather.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/routes/weather.js b/routes/weather.js index 5c2f4ec..ed1b6b8 100644 --- a/routes/weather.js +++ b/routes/weather.js @@ -71,8 +71,8 @@ function getWeatherUndergroundData( location, weatherUndergroundKey, callback ) // Calculate sunrise and sunset since Weather Underground does not provide it sunData = SunCalc.getTimes( data.current_observation.local_epoch * 1000, - data.current_observation.observation_location.latitude, - data.current_observation.observation_location.longitude ); + data.current_observation.observation_location.latitude || data.current_observation.display_location.latitude, + data.current_observation.observation_location.longitude || data.current_observation.display_location.longitude ); sunData.sunrise.setUTCMinutes( sunData.sunrise.getUTCMinutes() + tzOffset ); sunData.sunset.setUTCMinutes( sunData.sunset.getUTCMinutes() + tzOffset );