Class: Kamelopard::Document
- Defined in:
- lib/kamelopard/classes.rb
Overview
Represents KML’s Document class.
Instance Attribute Summary collapse
-
#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
-
#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(options = {}) ⇒ Document
constructor
A new instance of Document.
-
#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?
Constructor Details
#initialize(options = {}) ⇒ Document
Returns a new instance of Document.
1001 1002 1003 1004 1005 1006 1007 1008 1009 |
# File 'lib/kamelopard/classes.rb', line 1001 def initialize( = {}) @tours = [] @folders = [] @vsr_actions = [] @master_mode = false Kamelopard.log(:info, 'Document', "Adding myself to the document holder") DocumentHolder.instance << self super end |
Instance Attribute Details
#flyto_mode ⇒ Object
Returns the value of attribute flyto_mode.
994 995 996 |
# File 'lib/kamelopard/classes.rb', line 994 def flyto_mode @flyto_mode end |
#folders ⇒ Object
Returns the value of attribute folders.
994 995 996 |
# File 'lib/kamelopard/classes.rb', line 994 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.
999 1000 1001 |
# File 'lib/kamelopard/classes.rb', line 999 def master_mode @master_mode end |
#tours ⇒ Object
Returns the value of attribute tours.
994 995 996 |
# File 'lib/kamelopard/classes.rb', line 994 def tours @tours end |
#uses_xal ⇒ Object
Returns the value of attribute uses_xal.
994 995 996 |
# File 'lib/kamelopard/classes.rb', line 994 def uses_xal @uses_xal end |
#vsr_actions ⇒ Object
Returns the value of attribute vsr_actions.
994 995 996 |
# File 'lib/kamelopard/classes.rb', line 994 def vsr_actions @vsr_actions end |
Instance Method Details
#folder ⇒ Object
Returns the current Folder object
1029 1030 1031 1032 1033 1034 |
# File 'lib/kamelopard/classes.rb', line 1029 def folder if @folders.size == 0 then Folder.new end @folders.last end |
#get_actions ⇒ Object
Returns viewsyncrelay actions as a hash
1012 1013 1014 1015 1016 |
# File 'lib/kamelopard/classes.rb', line 1012 def get_actions { 'actions' => @vsr_actions.collect { |a| a.to_hash } } end |
#get_actions_yaml ⇒ Object
1018 1019 1020 |
# File 'lib/kamelopard/classes.rb', line 1018 def get_actions_yaml get_actions.to_yaml end |
#get_kml_document ⇒ Object
1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 |
# File 'lib/kamelopard/classes.rb', line 1083 def get_kml_document k = XML::Document.new # XXX fix this #k << XML::XMLDecl.default k.root = XML::Node.new('kml') r = k.root if @uses_xal then r.attributes['xmlns:xal'] = "urn:oasis:names:tc:ciq:xsdschema:xAL:2.0" end # 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' r << self.to_kml k 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
1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 |
# File 'lib/kamelopard/classes.rb', line 1039 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
1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 |
# File 'lib/kamelopard/classes.rb', line 1101 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 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 |