Class: Kamelopard::Document
- Defined in:
- lib/kamelopard/classes.rb
Overview
Represents KML’s Document class.
Instance Attribute Summary collapse
-
#filename ⇒ Object
Returns the value of attribute filename.
-
#flyto_mode ⇒ Object
Returns the value of attribute flyto_mode.
-
#folders ⇒ Object
Returns the value of attribute folders.
-
#master_mode ⇒ Object
Is this KML destined for a master LG node, or a slave? True if this is a master node.
-
#tours ⇒ Object
Returns the value of attribute tours.
-
#uses_xal ⇒ Object
Returns the value of attribute uses_xal.
-
#vsr_actions ⇒ Object
Returns the value of attribute vsr_actions.
Attributes inherited from Feature
#abstractView, #addressDetails, #atom_author, #atom_link, #description, #extendedData, #metadata, #name, #open, #phoneNumber, #region, #snippet, #styleSelector, #styleUrl, #styles, #timeprimitive, #visibility
Attributes included from Snippet
Attributes inherited from Object
#comment, #kml_id, #master_only
Instance Method Summary collapse
- #activate ⇒ Object
-
#folder ⇒ Object
Returns the current Folder object.
-
#get_actions ⇒ Object
Returns viewsyncrelay actions as a hash.
- #get_actions_yaml ⇒ Object
- #get_kml_document ⇒ Object
-
#initialize(name = '', options = {}) ⇒ Document
constructor
A new instance of Document.
- #make_current ⇒ Object
-
#make_tour_index(erb = nil, options = {}) ⇒ Object
Makes a screenoverlay with a balloon containing links to the tours in this document The erb argument contains ERB to populate the description.
- #to_kml ⇒ Object
-
#tour ⇒ Object
Returns the current Tour object.
Methods inherited from Container
Methods inherited from Feature
add_author, #extended_data_to_kml, #hide, #show, #styles_to_kml, #timespan, #timespan=, #timestamp, #timestamp=
Methods included from Snippet
Methods inherited from Object
#_alternate_to_kml, #change, #master_only?, parse
Constructor Details
#initialize(name = '', options = {}) ⇒ Document
Returns a new instance of Document.
1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 |
# File 'lib/kamelopard/classes.rb', line 1113 def initialize(name = '', = {}) @tours = [] @folders = [] @vsr_actions = [] @master_mode = false @filename = 'doc.kml' Kamelopard.log(:info, 'Document', "Adding myself to the document holder") DocumentHolder.instance << self super end |
Instance Attribute Details
#filename ⇒ Object
Returns the value of attribute filename.
1106 1107 1108 |
# File 'lib/kamelopard/classes.rb', line 1106 def filename @filename end |
#flyto_mode ⇒ Object
Returns the value of attribute flyto_mode.
1106 1107 1108 |
# File 'lib/kamelopard/classes.rb', line 1106 def flyto_mode @flyto_mode end |
#folders ⇒ Object
Returns the value of attribute folders.
1106 1107 1108 |
# File 'lib/kamelopard/classes.rb', line 1106 def folders @folders end |
#master_mode ⇒ Object
Is this KML destined for a master LG node, or a slave? True if this is a master node. This defaults to true, so tours that don’t need this function, and tours for non-LG targets, work normally.
1111 1112 1113 |
# File 'lib/kamelopard/classes.rb', line 1111 def master_mode @master_mode end |
#tours ⇒ Object
Returns the value of attribute tours.
1106 1107 1108 |
# File 'lib/kamelopard/classes.rb', line 1106 def tours @tours end |
#uses_xal ⇒ Object
Returns the value of attribute uses_xal.
1106 1107 1108 |
# File 'lib/kamelopard/classes.rb', line 1106 def uses_xal @uses_xal end |
#vsr_actions ⇒ Object
Returns the value of attribute vsr_actions.
1106 1107 1108 |
# File 'lib/kamelopard/classes.rb', line 1106 def vsr_actions @vsr_actions end |
Instance Method Details
#activate ⇒ Object
1128 1129 1130 |
# File 'lib/kamelopard/classes.rb', line 1128 def activate make_current end |
#folder ⇒ Object
Returns the current Folder object
1150 1151 1152 1153 1154 1155 |
# File 'lib/kamelopard/classes.rb', line 1150 def folder if @folders.size == 0 then Folder.new end @folders.last end |
#get_actions ⇒ Object
Returns viewsyncrelay actions as a hash
1133 1134 1135 1136 1137 |
# File 'lib/kamelopard/classes.rb', line 1133 def get_actions { 'actions' => @vsr_actions.collect { |a| a.to_hash } } end |
#get_actions_yaml ⇒ Object
1139 1140 1141 |
# File 'lib/kamelopard/classes.rb', line 1139 def get_actions_yaml get_actions.to_yaml end |
#get_kml_document ⇒ Object
1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 |
# File 'lib/kamelopard/classes.rb', line 1204 def get_kml_document k = XML::Document.new # # XXX Should this be add_namespace instead? # ns_arr = [ # ['', 'http://www.opengis.net/kml/2.2'], # ['gx', 'http://www.google.com/kml/ext/2.2'], # ['kml', 'http://www.opengis.net/kml/2.2'], # ['atom', 'http://www.w3.org/2005/Atom'], # ['test', 'http://test.com'] # ] # ns_arr.each do |a| # nm = 'xmlns' # nm = a[0] if a[0] != '' # k.context.register_namespace(nm, a[1]) # end # XXX fix this #k << XML::XMLDecl.default k.root = XML::Node.new('kml') r = k.root # # XXX Should this be add_namespace instead? # r.attributes['xmlns'] = 'http://www.opengis.net/kml/2.2' # r.attributes['xmlns:gx'] = 'http://www.google.com/kml/ext/2.2' # r.attributes['xmlns:kml'] = 'http://www.opengis.net/kml/2.2' # r.attributes['xmlns:atom'] = 'http://www.w3.org/2005/Atom' ns_values = [ [nil, 'http://www.opengis.net/kml/2.2'], ['gx', 'http://www.google.com/kml/ext/2.2'], ['kml', 'http://www.opengis.net/kml/2.2'], ['atom', 'http://www.w3.org/2005/Atom'], ] if @uses_xal ns_values << ['xal', "urn:oasis:names:tc:ciq:xsdschema:xAL:2.0"] end ns_values.each do |ns| n = XML::Namespace.new(r, ns[0], ns[1]) r.namespaces.namespace = n if ns[0].nil? end r << self.to_kml k end |
#make_current ⇒ Object
1124 1125 1126 |
# File 'lib/kamelopard/classes.rb', line 1124 def make_current Kamelopard::DocumentHolder.instance.set_current self end |
#make_tour_index(erb = nil, options = {}) ⇒ Object
Makes a screenoverlay with a balloon containing links to the tours in this document The erb argument contains ERB to populate the description. It can be left nil The options hash is passed to the ScreenOverlay constructor
1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 |
# File 'lib/kamelopard/classes.rb', line 1160 def make_tour_index(erb = nil, = {}) [:name] ||= 'Tour index' [:screenXY] ||= Kamelopard::XY.new(0.0, 1.0, :fraction, :fraction) [:overlayXY] ||= Kamelopard::XY.new(0.0, 1.0, :fraction, :fraction) s = Kamelopard::ScreenOverlay.new t = ERB.new( erb || %{ <html> <body> <ul><% @tours.each do |t| %> <li><a href="#<%= t.kml_id %>;flyto"><% if t.icon.nil? %><%= t.name %><% else %><img src="<%= t.icon %>" /><% end %></a></li> <% end %></ul> </body> </html> }) s.description = XML::Node.new_cdata t.result(binding) s.balloonVisibility = 1 balloon_au = [0, 1].collect do |v| au = Kamelopard::AnimatedUpdate.new [], :standalone => true a = XML::Node.new 'Change' b = XML::Node.new 'ScreenOverlay' b.attributes['targetId'] = s.kml_id c = XML::Node.new 'gx:balloonVisibility' c << XML::Node.new_text(v.to_s) b << c a << b au << a au end # Handle hiding and displaying the index @tours.each do |t| q = Wait.new(0.1, :standalone => true) t.playlist.unshift balloon_au[0] t.playlist.unshift q t.playlist << balloon_au[1] t.playlist << q end s end |
#to_kml ⇒ Object
1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 |
# File 'lib/kamelopard/classes.rb', line 1248 def to_kml d = XML::Node.new 'Document' super d # Print styles first #! These get printed out in the call to super, in Feature.to_kml() #@styles.map do |a| d << a.to_kml unless a.attached? end # then misc @features.each do |f| next if f.is_a? Folder or f.is_a? Style or f.is_a? Tour f.to_kml d end # then folders @folders.map do |a| a.to_kml(d) unless a.has_parent? end # then tours @tours.map do |a| a.to_kml(d) end d end |