Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var stringLocation=location+" ";
- var arrayLocations=stringLocation.split(",");
- var lat=arrayLocations[0];
- var long=arrayLocations[1];
- var params = {
- url: "http://api.openweathermap.org/data/2.5/forecast?lat="+lat+"&lon="+long+
- "&units=imperial" +"&type=accurate&mode=xml" /* STRING */,
- timeout: 160 /* NUMBER */
- };
- // result: XML
- var xmlPage = Resources["ContentLoaderFunctions"].LoadXML(params);
- var params = {
- infoTableName : "InfoTable",
- dataShapeName : "OpenWeatherFeed"
- };
- // CreateInfoTableFromDataShape(infoTableName:STRING("InfoTable"), dataShapeName:STRING):INFOTABLE(YahooWeatherFeed)
- var result = Resources["InfoTableFunctions"].CreateInfoTableFromDataShape(params);
- var from_today_value=xmlPage.forecast.time[0].@from.substring(0,10);
- logger.warn("from_today_value= "+from_today_value);
- for each (var item in xmlPage.forecast.time) {
- var row = new Object();
- var from_current_value=item.@from.substring(0,10);
- if(from_current_value!=from_today_value){
- row.WindDirection = item.windDirection.@name;
- row.WindSpeed=item.windSpeed.@mps;
- row.WeatherTemp=parseFloat(item.temperature.@value);
- row.WeatherHumidity=parseFloat(item.humidity.@value);
- row.From=item.@from;
- row.To=item.@to;
- row.Title=xmlPage.location.name+" "+xmlPage.location.country;
- row.Precipitation=(item.precipitation.@type+" "+item.precipitation.@value)==" "?"No Precipitation":item.precipitation.@type;
- result.AddRow(row);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment