class EnergyPlus::KmlFile
Attributes
data[RW]
Public Class Methods
new(path)
click to toggle source
# File lib/energyplus/KmlFile.rb, line 30 def initialize(path) @path = path @data = [] @region_lu = Hash.new("regions") @region_lu["1_africa_wmo_region_1"] = "Africa, WMO Region 1" @region_lu["2_asia_wmo_region_2"] = "Asia, WMO Region 2" @region_lu["3_south_america_wmo_region_3"] = "South America, WMO Region 3" @region_lu["4_north_and_central_america_wmo_region_4"] = "North and Central America, WMO Region 4" @region_lu["5_southwest_pacific_wmo_region_5"] = "Southwest Pacific Ocean, WMO Region 5" @region_lu["6_europe_wmo_region_6"] = "Europe, WMO Region 6" end
Public Instance Methods
savefile()
click to toggle source
# File lib/energyplus/KmlFile.rb, line 44 def savefile kmlfile = File.new(@path, 'w') kmlxml = Builder::XmlMarkup.new(:target => kmlfile, :indent=>2) #setup the xml/kml file kmlxml.instruct! :xml, :version=>"1.0", :encoding=>"UTF-8" kmlxml.kml("xmlns" => "http://www.opengis.net/kml/2.2") { kmlxml.Document { kmlxml.name "EnergyPlus Weather Data" kmlxml.visibility "0" kmlxml.description { kmlxml.cdata!("<img src=\"kml/ep_header6.png\" width=280><p>Weather data for use with EnergyPlus building energy simulation software (http://www.energyplus.gov).<p>Locations are organized by World Meteorological Organization (WMO) region, country, and state/province. Download individual weather data files through links in each location description.") } kmlxml.LookAt { kmlxml.longitude "-105" kmlxml.latitude "15" kmlxml.altitude "0" kmlxml.range "15000000" kmlxml.tilt "6.880472140100155e-015" kmlxml.heading "4.971764876159099e-015" kmlxml.altitudeMode "relativeToGround" } kmlxml.Style("id" => "weatherlocation_normal") { kmlxml.IconStyle { kmlxml.scale "0.6" kmlxml.Icon { kmlxml.href "kml/E+_logo.png" } } kmlxml.BalloonStyle { kmlxml.text { kmlxml.cdata!("<b><font color=\"#CC0000\" size=\"+3\">$[name]</font></b><br/><font>$[description]</font>") } kmlxml.bgColor "ffffffbb" } } kmlxml.StyleMap("id" => "weatherlocation") { kmlxml.Pair { kmlxml.key "normal" kmlxml.styleUrl "#weatherlocation_normal" } kmlxml.Pair { kmlxml.key "highlight" kmlxml.styleUrl "#weatherlocation_hiliteicon" } } kmlxml.Style("id" => "weatherlocation_hiliteicon") { kmlxml.IconStyle { kmlxml.scale "0.9" kmlxml.Icon { kmlxml.href "kml/E+_logo.png" } kmlxml.hotSpot { kmlxml.x "0.5" kmlxml.y "0.5" kmlxml.xunits "fraction" kmlxml.yunits "fraction" } kmlxml.BalloonStyle { kmlxml.text { kmlxml.cdata!("<b><font color=\"#CC0000\" size=\"+3\">$[name]</font></b> <br/><font>$[description]</font>") } kmlxml.bgColor "ffffffbb" } } } #write out each location #the data is stored in a custom format that is two layers dep using the DataHash.rb #file that Nicholas Long wrote @data.each do |region| kmlxml.Folder { kmlxml.name @region_lu[region.name] kmlxml.visibility "0" kmlxml.description { kmlxml.cdata!("<img src=\"kml/ep_header7.png\" align=right>") } region.data.each do |country| kmlxml.Folder { kmlxml.name country.name kmlxml.visibility "0" country.data.each do |state| if state != "" && state != "-" then kmlxml.Folder { kmlxml.name state.name kmlxml.visibility "0" state.data.each do |weather| weather.toKml(kmlxml) end } else state.data.each do |weather| weather.toKml(kmlxml) end end end } end } end @data.each do |reg| puts reg.name reg.data.each do |reg_data| puts " #{reg_data.name}" reg_data.data.each do |reg_data_2| puts " #{reg_data_2.name}" reg_data_2.data.each do |reg_data_3| puts " #{reg_data_3.path}" end end end end } } end