Class: Kamelopard::Document

Inherits:
Container show all
Includes:
Singleton
Defined in:
lib/kamelopard/classes.rb

Overview

Represents KML’s Document class. This is a Singleton object; Kamelopard scripts can (for now) manage only one Document at a time.

Instance Attribute Summary collapse

Attributes inherited from Feature

#abstractView, #addressDetails, #atom_author, #atom_link, #description, #extendedData, #metadata, #name, #open, #phoneNumber, #region, #snippet, #styleSelector, #styleUrl, #styles, #timeprimitive, #visibility

Attributes inherited from Object

#comment, #id

Instance Method Summary collapse

Methods inherited from Container

#<<

Methods inherited from Feature

add_author, #styles_to_kml, #timespan, #timespan=, #timestamp, #timestamp=

Constructor Details

#initializeDocument

Returns a new instance of Document.



716
717
718
719
720
721
# File 'lib/kamelopard/classes.rb', line 716

def initialize
    super
    @tours = []
    @folders = []
    @styles = []
end

Instance Attribute Details

#flyto_modeObject

Returns the value of attribute flyto_mode.



714
715
716
# File 'lib/kamelopard/classes.rb', line 714

def flyto_mode
  @flyto_mode
end

#foldersObject

Returns the value of attribute folders.



714
715
716
# File 'lib/kamelopard/classes.rb', line 714

def folders
  @folders
end

#toursObject

Returns the value of attribute tours.



714
715
716
# File 'lib/kamelopard/classes.rb', line 714

def tours
  @tours
end

#uses_xalObject

Returns the value of attribute uses_xal.



714
715
716
# File 'lib/kamelopard/classes.rb', line 714

def uses_xal
  @uses_xal
end

Instance Method Details

#folderObject

Returns the current Folder object



730
731
732
733
734
735
# File 'lib/kamelopard/classes.rb', line 730

def folder
    if @folders.size == 0 then
        Folder.new
    end
    @folders.last
end

#get_kml_documentObject

def styles_to_kml(elem = nil)

end


740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
# File 'lib/kamelopard/classes.rb', line 740

def get_kml_document
    k = REXML::Document.new
    k << REXML::XMLDecl.default
    r = REXML::Element.new('kml')
    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.elements << self.to_kml
    k << r
    k
end

#to_kmlObject



757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
# File 'lib/kamelopard/classes.rb', line 757

def to_kml
    d = REXML::Element.new 'Document'
    super(d)

    # Print styles first
    @styles.map do |a| a.to_kml(d) 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

#tourObject

Returns the current Tour object



724
725
726
727
# File 'lib/kamelopard/classes.rb', line 724

def tour
    @tours << Tour.new if @tours.length == 0
    @tours.last
end