Class: Kamelopard::Feature

Inherits:
Object
  • Object
show all
Includes:
Snippet
Defined in:
lib/kamelopard/classes.rb

Overview

Abstract class corresponding to KML's Feature object. – XXX Make this support alternate namespaces ++

Direct Known Subclasses

Container, NetworkLink, Overlay, Placemark

Instance Attribute Summary collapse

Attributes included from Snippet

#maxLines, #snippet_text

Attributes inherited from Object

#comment, #kml_id, #master_only

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Snippet

#snippet_to_kml

Methods inherited from Object

#_alternate_to_kml, #change, #master_only?, parse

Constructor Details

#initialize(name = nil, options = {}) ⇒ Feature

Returns a new instance of Feature.


891
892
893
894
895
896
897
# File 'lib/kamelopard/classes.rb', line 891

def initialize (name = nil, options = {})
    @visibility = true
    @open = false
    @styles = []
    super options
    @name = name unless name.nil?
end

Instance Attribute Details

#abstractViewObject

Returns the value of attribute abstractView


884
885
886
# File 'lib/kamelopard/classes.rb', line 884

def abstractView
  @abstractView
end

#addressDetailsObject

Returns the value of attribute addressDetails


887
888
889
# File 'lib/kamelopard/classes.rb', line 887

def addressDetails
  @addressDetails
end

#atom_authorObject

Returns the value of attribute atom_author


884
885
886
# File 'lib/kamelopard/classes.rb', line 884

def atom_author
  @atom_author
end

Returns the value of attribute atom_link


884
885
886
# File 'lib/kamelopard/classes.rb', line 884

def atom_link
  @atom_link
end

#descriptionObject

Returns the value of attribute description


887
888
889
# File 'lib/kamelopard/classes.rb', line 887

def description
  @description
end

#extendedDataObject

Returns the value of attribute extendedData


887
888
889
# File 'lib/kamelopard/classes.rb', line 887

def extendedData
  @extendedData
end

#metadataObject

Returns the value of attribute metadata


884
885
886
# File 'lib/kamelopard/classes.rb', line 884

def 
  @metadata
end

#nameObject

Returns the value of attribute name


884
885
886
# File 'lib/kamelopard/classes.rb', line 884

def name
  @name
end

#openObject

Returns the value of attribute open


884
885
886
# File 'lib/kamelopard/classes.rb', line 884

def open
  @open
end

#phoneNumberObject

Returns the value of attribute phoneNumber


884
885
886
# File 'lib/kamelopard/classes.rb', line 884

def phoneNumber
  @phoneNumber
end

#regionObject

Returns the value of attribute region


884
885
886
# File 'lib/kamelopard/classes.rb', line 884

def region
  @region
end

#snippetObject (readonly)

Returns the value of attribute snippet


887
888
889
# File 'lib/kamelopard/classes.rb', line 887

def snippet
  @snippet
end

#stylesObject

Returns the value of attribute styles


884
885
886
# File 'lib/kamelopard/classes.rb', line 884

def styles
  @styles
end

#styleSelectorObject

Returns the value of attribute styleSelector


884
885
886
# File 'lib/kamelopard/classes.rb', line 884

def styleSelector
  @styleSelector
end

#styleUrlObject

Returns the value of attribute styleUrl


884
885
886
# File 'lib/kamelopard/classes.rb', line 884

def styleUrl
  @styleUrl
end

#timeprimitiveObject

Returns the value of attribute timeprimitive


884
885
886
# File 'lib/kamelopard/classes.rb', line 884

def timeprimitive
  @timeprimitive
end

#visibilityObject

Returns the value of attribute visibility


884
885
886
# File 'lib/kamelopard/classes.rb', line 884

def visibility
  @visibility
end

Class Method Details

.add_author(o, a) ⇒ Object


972
973
974
975
976
977
978
# File 'lib/kamelopard/classes.rb', line 972

def self.add_author(o, a)
    e = XML::Node.new 'atom:name'
    e << a.to_s
    f = XML::Node.new 'atom:author'
    f << e
    o << f
end

Instance Method Details

#extended_data_to_kml(elem) ⇒ Object


1007
1008
1009
1010
1011
1012
1013
1014
# File 'lib/kamelopard/classes.rb', line 1007

def extended_data_to_kml(elem)
    v = XML::Node.new 'ExtendedData'
    @extendedData.each do |f|
        v << f.to_kml
    end
    elem << v unless elem.nil?
    v
end

#hideObject

Hides the object. Note that this governs only whether the object is initially visible or invisible; to show or hide the feature dynamically during a tour, use an AnimatedUpdate object


926
927
928
# File 'lib/kamelopard/classes.rb', line 926

def hide
    @visibility = false
end

#showObject

Shows the object. See note for hide() method


931
932
933
# File 'lib/kamelopard/classes.rb', line 931

def show
    @visibility = true
end

#styles_to_kml(elem) ⇒ Object


1016
1017
1018
1019
1020
1021
1022
# File 'lib/kamelopard/classes.rb', line 1016

def styles_to_kml(elem)
    # XXX Remove this
    raise "done here" if elem.class == Array
    @styles.each do |a|
        a.to_kml(elem) # unless a.attached?
    end
end

#timespanObject


939
940
941
# File 'lib/kamelopard/classes.rb', line 939

def timespan
    @timeprimitive
end

#timespan=(t) ⇒ Object


947
948
949
# File 'lib/kamelopard/classes.rb', line 947

def timespan=(t)
    @timeprimitive = t
end

#timestampObject


935
936
937
# File 'lib/kamelopard/classes.rb', line 935

def timestamp
    @timeprimitive
end

#timestamp=(t) ⇒ Object


943
944
945
# File 'lib/kamelopard/classes.rb', line 943

def timestamp=(t)
    @timeprimitive = t
end

#to_kml(elem = nil) {|elem| ... } ⇒ Object

Yields:

  • (elem)

980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
# File 'lib/kamelopard/classes.rb', line 980

def to_kml(elem = nil)
    elem = XML::Node.new 'Feature' if elem.nil?
    super elem
    Kamelopard.kml_array(elem, [
            [@name, 'name'],
            [(@visibility.nil? || @visibility) ? 1 : 0, 'visibility'],
            [(! @open.nil? && @open) ? 1 : 0, 'open'],
            [@atom_author, lambda { |o| Feature.add_author(o, @atom_author) }],
            [@atom_link, 'atom:link'],
            [@address, 'address'],
            [@addressDetails, 'xal:AddressDetails'],
            [@phoneNumber, 'phoneNumber'],
            [@description, 'description'],
            [@styleUrl, 'styleUrl'],
            [@styleSelector, lambda { |o| @styleSelector.to_kml(o) }],
            [@metadata, 'Metadata' ]
        ])
    styles_to_kml(elem)
    snippet_to_kml(elem) unless @snippet_text.nil?
    extended_data_to_kml(elem) unless @extendedData.nil?
    @abstractView.to_kml(elem) unless @abstractView.nil?
    @timeprimitive.to_kml(elem) unless @timeprimitive.nil?
    @region.to_kml(elem) unless @region.nil?
    yield(elem) if block_given?
    elem
end