

|
|
FreeData_NWS CFML Custom TagDownload | Revision History | Usage | Other Resources This ColdFusion 4.1+ CFML custom tag uses CFHTTP to retrieve weather reports (posted hourly) from the National Weather Service's Interactive Weather Information Network.
|
| State | The two letter state code of the state you're retrieving a report for. |
| City | The city whose report you'd like. This must be copied exactly from the Interactive Weather Information Network. |
| VarPrefix | This value will be prepended to all variables returned from the tag. Defaults to "NWS_". Useful for running multiple queries on the same template. |
| NoDataVal | The value that will be used in place of any null returns. Defaults to "XXX". Commonly used for values like "Gust Speed" that aren't standard for every report. If the value of "WeatherFailed" equals "N" every value, excepting report time will be set to the NoDataVal |
| DumpResults | If "Y" displays the results of the tag in table, defaults to "N". Good for quick checks and checking variable names. |
This tag outputs 12 data items describing the current weather conditions. This chart describes the variables returned. Note that the prefix "NWS_" will be replaced with the value from the VarPrefix attribute if present.
| NWS_ReportTime: | The time that the weather report was generated. Note that if the "state" attribute is correct, but the "city" attribute doesn't exist this variable will still have a valid return. |
| NWS_SkyCondShrt: | This is the short or "raw" version of the sky condition. Some examples: "DRIZZLE" or "LGHT RAIN" |
| NWS_SkyCond: | This is an attempt to create a "friendly" version of the sky condition. Some examples: "Drizzle" or "Light Rain". If a the tag can't create a friendly version the SkyCondShrt value is used. |
| NWS_Temp: | The Temperature (in Fahrenheit). |
| NWS_DewPT: | The Dew Point (in Fahrenheit). |
| NWS_Humidity: | The Humidity (Percent). |
| NWS_WindDir: | The "full" wind direction: "North", "South-East", etc. |
| NWS_WindDirShrt: | The abbreviated wind direction: "NE", "S", etc. |
| NWS_WindSpeed: | The Wind Speed (either "Calm" or number indicating miles-per-hour). |
| NWS_GustSpeed: | The wind's gust speed. Not always available. |
| NWS_Pressure: | The pressure (barometric inches). |
| NWS_PressureActivity: | The pressure activity: "Rising","Falling", or "Steady" |
In addition the tag also outputs the following:
| NWS_VarNames: | A comma-delimited string containing the variable names of the weather report. Can be used to programatically output the report results. |
| NWS_WeatherFailed: | "N" if the return is a valid report, "Y" if the return is not valid. |
The following example retrieves the weather report for Boston, MA, shows help, and displays the results.
<cfmodule template="FreeData_NWS.cfm" State="MA" City="BOSTON" VarPrefix="NWS_" NoDataVal="000" DumpResults="Y" Help="Y">
This example loops over the "VarName" list and displays the values (Note that the prefix "NWS_" may be changed at runtime).
<cfloop List="#NWS_VarNames#" index="Item">
<cfoutput>
#Item#: #Evaluate("Caller.#Item#")#
</cfoutput>
<br>
</cfloop>
Example Tag Output
back to top
This is a sample of the tag's output when retrieving a weather report for Boston, MA:
Weather for BOSTON, MA: NWS_WeatherFailed N NWS_ReportTime JAN 9, 1999 12:00AM NWS_SkyCondShrt DRIZZLE NWS_SkyCond Drizzle NWS_Temp 34 NWS_DewPT 34 NWS_Humidity 100 NWS_WindDir West NWS_WindDirShrt W NWS_WindSpeed 6 NWS_GustSpeed 000 NWS_Pressure 30.01 NWS_PressureActivity Falling
Other Resources
back to top
Other resources to help you make the most of this component including code walkthroughs and supporting systems and external web links.