Fix bug with Weather Underground queries
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
var http = require( "http" ),
|
var http = require( "http" ),
|
||||||
SunCalc = require( "suncalc" ),
|
SunCalc = require( "suncalc" ),
|
||||||
// parseXML = require( "xml2js" ).parseString,
|
parseXML = require( "xml2js" ).parseString,
|
||||||
Cache = require( "../models/Cache" ),
|
Cache = require( "../models/Cache" ),
|
||||||
|
|
||||||
// Define regex filters to match against location
|
// Define regex filters to match against location
|
||||||
@@ -19,7 +19,6 @@ function getPWSCoordinates( location, weatherUndergroundKey, callback ) {
|
|||||||
|
|
||||||
httpRequest( url, function( data ) {
|
httpRequest( url, function( data ) {
|
||||||
data = JSON.parse( data );
|
data = JSON.parse( data );
|
||||||
|
|
||||||
if ( typeof data === "object" && data.current_observation && data.current_observation.observation_location ) {
|
if ( typeof data === "object" && data.current_observation && data.current_observation.observation_location ) {
|
||||||
callback( [ data.current_observation.observation_location.latitude,
|
callback( [ data.current_observation.observation_location.latitude,
|
||||||
data.current_observation.observation_location.longitude ] );
|
data.current_observation.observation_location.longitude ] );
|
||||||
@@ -60,7 +59,7 @@ function getWeatherUndergroundData( location, weatherUndergroundKey, callback )
|
|||||||
|
|
||||||
// Generate URL using The Weather Company API v1 in Imperial units
|
// Generate URL using The Weather Company API v1 in Imperial units
|
||||||
var url = "http://api.wunderground.com/api/" + weatherUndergroundKey +
|
var url = "http://api.wunderground.com/api/" + weatherUndergroundKey +
|
||||||
"/yesterday/conditions/q/" + location + ".json";
|
"/yesterday/conditions/q/" + encodeURIComponent( location ) + ".json";
|
||||||
|
|
||||||
// Perform the HTTP request to retrieve the weather data
|
// Perform the HTTP request to retrieve the weather data
|
||||||
httpRequest( url, function( data ) {
|
httpRequest( url, function( data ) {
|
||||||
@@ -487,18 +486,6 @@ function ipToInt( ip ) {
|
|||||||
return ( ( ( ( ( ( +ip[0] ) * 256 ) + ( +ip[1] ) ) * 256 ) + ( +ip[2] ) ) * 256 ) + ( +ip[3] );
|
return ( ( ( ( ( ( +ip[0] ) * 256 ) + ( +ip[1] ) ) * 256 ) + ( +ip[2] ) ) * 256 ) + ( +ip[3] );
|
||||||
}
|
}
|
||||||
|
|
||||||
function f2c( temp ) {
|
|
||||||
return ( temp - 32 ) * 5 / 9;
|
|
||||||
}
|
|
||||||
|
|
||||||
function mm2in( x ) {
|
|
||||||
return x * 0.03937008;
|
|
||||||
}
|
|
||||||
|
|
||||||
function ft2m( x ) {
|
|
||||||
return x * 0.3048;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Resolves the Month / Day / Year of a Date object
|
// Resolves the Month / Day / Year of a Date object
|
||||||
function toUSDate( date ) {
|
function toUSDate( date ) {
|
||||||
return ( date.getMonth() + 1 ) + "/" + date.getDate() + "/" + date.getFullYear();
|
return ( date.getMonth() + 1 ) + "/" + date.getDate() + "/" + date.getFullYear();
|
||||||
|
|||||||
Reference in New Issue
Block a user