Remove Open Weather Map dependency

This commit is contained in:
Samer Albahra
2015-11-02 17:14:58 -06:00
parent 175e0d6c10
commit cc549afb69

View File

@@ -217,20 +217,8 @@ function getYesterdayWeatherData( location, callback ) {
} );
}
// Retrieve weather data from Open Weather Map
function getOWMWeatherData( location, callback ) {
// Generate URL using The Weather Company API v1 in Imperial units
var OWM_API_KEY = process.env.OWM_API_KEY,
url = "http://api.openweathermap.org/data/2.5/weather?appid=" + OWM_API_KEY + "&units=imperial&lat=" + location[ 0 ] + "&lon=" + location[ 1 ];
// Perform the HTTP request to retrieve the weather data
httpRequest( url, function( data ) {
try {
data = JSON.parse( data );
// Calculate timezone and sun rise/set information
function getTimeData( location, callback ) {
timezoner.getTimeZone(
location[ 0 ],
location[ 1 ],
@@ -250,30 +238,13 @@ function getOWMWeatherData( location, callback ) {
var weather = {
timezone: timezone,
sunrise: ( sunData.sunrise.getUTCHours() * 60 + sunData.sunrise.getUTCMinutes() ),
sunset: ( sunData.sunset.getUTCHours() * 60 + sunData.sunset.getUTCMinutes() ),
temp: parseInt( data.main.temp ),
humidity: parseInt( data.main.humidity ),
wind: parseInt( data.wind.speed )
sunset: ( sunData.sunset.getUTCHours() * 60 + sunData.sunset.getUTCMinutes() )
};
getCache( {
key: "yesterdayHumidity",
location: location,
weather: weather,
callback: callback
} );
updateCache( location, weather );
callback( weather );
}
}
);
} catch ( err ) {
// Otherwise indicate the request failed
callback( false );
}
} );
}
// Retrieve cached record for a given location