From bc713d038034fde4152fdbefb9b12be8243cd10e Mon Sep 17 00:00:00 2001 From: Samer Albahra Date: Fri, 3 Jul 2015 16:05:03 -0500 Subject: [PATCH] Fix bug with Weather Underground queries --- routes/weather.js | 17 ++--------------- 1 file changed, 2 insertions(+), 15 deletions(-) diff --git a/routes/weather.js b/routes/weather.js index cf2e0e2..b295327 100644 --- a/routes/weather.js +++ b/routes/weather.js @@ -1,6 +1,6 @@ var http = require( "http" ), SunCalc = require( "suncalc" ), -// parseXML = require( "xml2js" ).parseString, + parseXML = require( "xml2js" ).parseString, Cache = require( "../models/Cache" ), // Define regex filters to match against location @@ -19,7 +19,6 @@ function getPWSCoordinates( location, weatherUndergroundKey, callback ) { httpRequest( url, function( data ) { data = JSON.parse( data ); - if ( typeof data === "object" && data.current_observation && data.current_observation.observation_location ) { callback( [ data.current_observation.observation_location.latitude, 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 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 httpRequest( url, function( data ) { @@ -487,18 +486,6 @@ function ipToInt( ip ) { 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 function toUSDate( date ) { return ( date.getMonth() + 1 ) + "/" + date.getDate() + "/" + date.getFullYear();