Jump to content


Submitter

SUPPORT TOPIC File Information

  • Submitted: Oct 19 2009 11:59 AM
  • Last Updated: Oct 20 2009 10:30 AM
  • File Size: 228.43K
  • Views: 2852
  • Downloads: 50
  • Author: 123
  • Contact: PM me

Previous Versions

  • 20 Oct 2009 Download Module: Environment Canada Weather
  • 20 Oct 2009 Download Module: Environment Canada Weather
  • 19 Oct 2009 Download Module: Environment Canada Weather

Download Module: Environment Canada Weather

- - - - -



Environment Canada Weather Module

This Module acquires weather data from Environment Canada's Forecast Data (XML) and displays it in Premise Browser.  It shows the current weather, seven-day forecast, historical (almanac), an animated weather map (sourced from the Weather Channel), sunrise/set, and moonrise/set.  Use of this module indicates acceptance of Environment Canada's Terms and Conditions (http://www.msc-smc.e...d3_site_XML.txt).

Installation
Install the EnvironmentCanada weather icons.
  • Create the following folder: c:\Program Files\Premise\SYS\web\Images\WeatherOffice.
  • Copy all EnvironmentCanada weather icons (GIF files) to the new folder.
Install the database file.
  • Copy "WeatherOffice.mdb" to: c:\Program Files\Premise\SYS\schema\modules.
Install the WeatherOffice CSS file.
  • Copy "weatheroffice.css" to c:\Program Files\Premise\SYS\web.
  • Navigate to c:\Program Files\Premise\SYS\web.
  • Copy "global.css" to "global_ORIGINAL.css" (i.e. make a backup)
  • Right-click "global.css", select Properties, disable Read-only , and click OK.
  • Using Notepad, open global.css and add the following to the top of the file (i.e. make it the new first line):
    @import url("weatheroffice.css");
  • Save the file and exit Notepad.
  • Right-click "global.css", select Properties, enable Read-only, and click OK.
Restart Premise's web server so that it reloads all CSS data.
  • Ensure you are running Builder on the Premise Server machine.
  • In Builder's Shortcut bar, click WebServer.
  • In the Properties window, locate the Status property.
  • Disable it, pause a few seconds, then enable it.
Import the Modules.
  • Using Builder's main menu, click File > Import, select Globals.xdo and click OK.
  • Repeat the previous step for EnvironmentCanada.xdo.
Add a WeatherOffice object to Premise Home.
  • In Builder's Shortcut bar, click Home.
  • In the Explorer window, right-click Home and select New > WeatherOffice.
  • In the Properties window, locate the City property.
  • Select the desired City.
  • Click the Update property.
  • The Status field will display "Acquiring weather data ...".

Customization
The Module contains a list of major Canadian cities.  If your home town is not in the list, you can append it provided that Environment Canada has Forecast Data for it.

Find your city in the following list: http://dd.weatheroff...st_e_towns.html
Each city has a unique eight-character code consisting of the letter "s" followed by seven digits. For example, Montreal's code is "s0000635" and you only need the significant digits.  For example, it is "635" for Montreal, "458 for Toronto ("s0000458"), and "47" for Calgary ("s0000047").
You may need to modify the city's name so that it complies with Visual Basic's naming rules for variables.  For the purposes of this Module, the city's name should consist of nothing more than letters, hyphens, and underscores. It must not contain accented characters, apostophes, parentheses, punctuation, and it cannot start with a numeric value (so "100 Mile House" must be converted to "OneHundredMileHouse").  Here are a few conversion examples:
"Saint John's" -> "SaintJohn_s"
"St. Catharines" -> "StCatharines"
"St. Peter's" -> "StPeters"
"Rivière-du-Loup" -> "Riviere-du-Loup"
"Ottawa (Kanata - Orléans)" -> "Ottawa_Kanata-Orleans"

Let's assume the home town is "Kananaskis (Nakiska Ridgetop)" in Alberta (AB) whose code is "s0000263".  We convert this to "Kannaskis_NakiskaRidgetop" with a code of "263".
  • In Builder, click Modules in the Shortcut bar.
  • Navigate to Modules/EnvironmentCanada/Classes/CityList
  • You can right-click CityList and select New > Enum or simply modify the existing "Saint-Hyacinthe_QC" entry.
  • Set the Name property must be in the following format: "CityName_ProvinceCode".  Our example entry will be: "Kannaskis_NakiskaRidgetop_AB".
  • Set the DisplayName property must be in the following format: "CityName ProvinceCode". Our example entry will be: "Kannaskis_NakiskaRidgetop AB".
  • Set the Value property to: 263.
  • For cosmetic purposes, you can drag "Kannaskis_NakiskaRidgetop_AB" and drop it after "Halifax_NS" so that the city list is in sorted order.

If you wish to change the displayed data's appearance, you'll need to edit "WeatherOffice.css".  You'll need to understand Cascading Style Sheets (CSS) in order to make any sense of the file.

Notes
Environment Canada's Forecast Data is in XML format and provides a large amount of detailed weather data (far more than its RSS feed).  Environment Canada's web-site uses a set of 44 icons to represent over 300 weather conditions.  However, the Forecast Data does not specify the icon to use in order to visually represent the weather conditions.  For example the icon for "Sunny" is "00.gif" but Forecast Data does not specify this information.  In addition, there is no master cross-reference list indicating the correspondence between forecast and icon.

"WeatherOffice.mdb" is a cross-reference list I've built by observing the daily weather and the icons used on Environment Canada's web-site.  The list is incomplete and not a perfect match with EC's web-site.  There are several weather conditions that I've never observed so I don't know which icon should be used.  In addition, EC employs heuristics to select the best icon to represent the weather conditions.  For example, it the forecast is Rain but with a chance of thundershowers then they will not simply choose the "rain" icon but will use the "rain with lightning bolt" icon.  However, the threshold for this choice is not published so I don't when they will/will not choose the "thunderbolt" version.  As a result, this Module simply uses the "rain" icon even if there is a chance of thundershowers.

If this Module encounters a known weather condition (listed in WeatherOffice.mdb), say "Chance of drizzle mixed with freezing drizzle", but does not know the correct icon, it will display a custom icon "100.gif" which is simply an exclamation mark.  You'll have to go to Environment Canada's web-site, look at the seven-day forecast, right-click the icon they are currently using to represent the weather condition and read the corresponding number. For example, it is "08" for "Chance of flurries".  in this case, let's say it is "28". You'd edit the Icon table in WeatherOffice.mdb, locate "Chance of drizzle mixed with freezing drizzle" and replace "100" in the Code field with "28".  This is how I arrived at the existing entries in WeatherOffice.mdb (you're welcome!).  Some icons are used exclusively for depicting the weather at night.  This is handled by checking the "IsNight" field in the database.

If this Module encounters an unknown weather condition (not listed in WeatherOffice.mdb), say "Chance of frozen flying squirrels", it will display custom icon "99.gif" which is a question mark.  You'll probably never see this icon (maybe).

The Forecast Data also provides Weather Watches whose details are not in the XML feed. Fortunately, it does provide a URL to a details page but in HTML, not XML, format.  The Module follows the URL to the HTML page, extracts the relevant Weather Watch information and displays it in Premise Browser below the seven-day forecast.  Be aware that extracting the Weather Watch details from the HTML page can fail if Environment Canada alters the page's formatting (this has happened).

Environment Canada has changed Forecast Data twice in the past year.  It has increased it from a five to seven day forecast and changed the URL of the XML feed.  Be aware that other changes in the future can cause problems for the Module.

ADDENDUM
Version 1.2 employs a more sophisticated means of extracting the details of a Weather Warning. It should prove to be more reliable because it can handle several HTML Heading tags (i.e. h1 through h9).






  • 172 Total Files
  • 8 Total Categories
  • 28 Total Authors
  • 32816 Total Downloads
  • SysEventBroker_with_AV Latest File
  • chucklyons Latest Submitter

0 user(s) are online (in the past 15 minutes)

0 members, 0 guests, 0 anonymous users