Remove Open Weather Map dependency
This commit is contained in:
@@ -217,20 +217,8 @@ function getYesterdayWeatherData( location, callback ) {
|
|||||||
} );
|
} );
|
||||||
}
|
}
|
||||||
|
|
||||||
// Retrieve weather data from Open Weather Map
|
// Calculate timezone and sun rise/set information
|
||||||
function getOWMWeatherData( location, callback ) {
|
function getTimeData( 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 );
|
|
||||||
|
|
||||||
timezoner.getTimeZone(
|
timezoner.getTimeZone(
|
||||||
location[ 0 ],
|
location[ 0 ],
|
||||||
location[ 1 ],
|
location[ 1 ],
|
||||||
@@ -250,30 +238,13 @@ function getOWMWeatherData( location, callback ) {
|
|||||||
var weather = {
|
var weather = {
|
||||||
timezone: timezone,
|
timezone: timezone,
|
||||||
sunrise: ( sunData.sunrise.getUTCHours() * 60 + sunData.sunrise.getUTCMinutes() ),
|
sunrise: ( sunData.sunrise.getUTCHours() * 60 + sunData.sunrise.getUTCMinutes() ),
|
||||||
sunset: ( sunData.sunset.getUTCHours() * 60 + sunData.sunset.getUTCMinutes() ),
|
sunset: ( sunData.sunset.getUTCHours() * 60 + sunData.sunset.getUTCMinutes() )
|
||||||
temp: parseInt( data.main.temp ),
|
|
||||||
humidity: parseInt( data.main.humidity ),
|
|
||||||
wind: parseInt( data.wind.speed )
|
|
||||||
};
|
};
|
||||||
|
|
||||||
getCache( {
|
callback( weather );
|
||||||
key: "yesterdayHumidity",
|
|
||||||
location: location,
|
|
||||||
weather: weather,
|
|
||||||
callback: callback
|
|
||||||
} );
|
|
||||||
|
|
||||||
updateCache( location, weather );
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
} catch ( err ) {
|
|
||||||
|
|
||||||
// Otherwise indicate the request failed
|
|
||||||
callback( false );
|
|
||||||
}
|
|
||||||
} );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Retrieve cached record for a given location
|
// Retrieve cached record for a given location
|
||||||
|
|||||||
Reference in New Issue
Block a user