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 included from Snippet

#maxLines, #snippet_text

Attributes inherited from Object

#comment, #kml_id

Instance Method Summary collapse

Methods inherited from Container

#<<, #features=

Methods inherited from Feature

add_author, #hide, #show, #styles_to_kml, #timespan, #timespan=, #timestamp, #timestamp=

Methods included from Snippet

#snippet_to_kml

Methods inherited from Object

#change

Constructor Details

#initialize(options = {}) ⇒ Document

Returns a new instance of Document.



772
773
774
775
776
777
# File 'lib/kamelopard/classes.rb', line 772

def initialize(options = {})
    @doc_tours = []
    @doc_folders = []
    @doc_styles = []
    super
end

Instance Attribute Details

#doc_foldersObject

Returns the value of attribute doc_folders.



770
771
772
# File 'lib/kamelopard/classes.rb', line 770

def doc_folders
  @doc_folders
end

#doc_stylesObject

Returns the value of attribute doc_styles.



770
771
772
# File 'lib/kamelopard/classes.rb', line 770

def doc_styles
  @doc_styles
end

#doc_toursObject

Returns the value of attribute doc_tours.



770
771
772
# File 'lib/kamelopard/classes.rb', line 770

def doc_tours
  @doc_tours
end

#flyto_modeObject

Returns the value of attribute flyto_mode.



770
771
772
# File 'lib/kamelopard/classes.rb', line 770

def flyto_mode
  @flyto_mode
end

#uses_xalObject

Returns the value of attribute uses_xal.



770
771
772
# File 'lib/kamelopard/classes.rb', line 770

def uses_xal
  @uses_xal
end

Instance Method Details

#folderObject

Returns the current Folder object



786
787
788
789
790
791
# File 'lib/kamelopard/classes.rb', line 786

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

#get_kml_documentObject



793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
# File 'lib/kamelopard/classes.rb', line 793

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

#to_kmlObject



811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
# File 'lib/kamelopard/classes.rb', line 811

def to_kml
    d = XML::Node.new 'Document'
    super d

    # Print styles first
    @doc_styles.map do |a| d << a.to_kml unless a.attached? end

    # then folders
    @doc_folders.map do |a|
        a.to_kml(d) unless a.has_parent?
    end

    # then tours
    @doc_tours.map do |a| a.to_kml(d) end

    d
end

#tourObject

Returns the current Tour object



780
781
782
783
# File 'lib/kamelopard/classes.rb', line 780

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