Class: Amanzi::SLD::Document

Inherits:
XML::Document show all
Includes:
Logger
Defined in:
lib/amanzi/sld.rb

Instance Attribute Summary collapse

Attributes inherited from XML::Element

#attributes, #children, #depth, #namespace

Instance Method Summary collapse

Methods included from Logger

#puts

Methods inherited from XML::Document

#add_singleton_elements, #comment, #singleton_elements, #singleton_method, #to_s, #to_xml

Methods inherited from XML::Element

#<<, #[]=, #add_child, #attribute_text, camelize, #comment, #contents, #indent, #insert, #insert_child, #make_child, #ns, #tag, #to_s, #to_xml

Constructor Details

#initialize(name, options = {}) ⇒ Document

Returns a new instance of Document.



42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/amanzi/sld.rb', line 42

def initialize(name,options={})
  super 'StyledLayerDescriptor'
  self['version'] = '1.0.0'
  self['xmlns'] = "http://www.opengis.net/sld"
  self['xmlns:ogc'] ="http://www.opengis.net/ogc"
  self['xmlns:xlink'] = "http://www.w3.org/1999/xlink"
  self['xmlns:xsi'] = "http://www.w3.org/2001/XMLSchema-instance"
  self['xsi:schemaLocation'] = "http://www.opengis.net/sld http://schemas.opengis.net/sld/1.0.0/StyledLayerDescriptor.xsd"
  add_singleton_elements ['named_layer','user_style']
  singleton_method(:named_layer).insert_child(0,'Name') << name
  singleton_method(:user_style).insert_child(0,'Name') << name
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(symbol, *args, &block) ⇒ Object

Pass any unknown methods down to user_style



55
56
57
58
59
# File 'lib/amanzi/sld.rb', line 55

def method_missing(symbol,*args,&block)
  puts "Looking for SLD document method: #{symbol}"
  singleton_method(symbol,*args,&block) ||
  singleton_method(:user_style).send(symbol, *args, &block)
end

Instance Attribute Details

#geometry_propertyObject (readonly)

Returns the value of attribute geometry_property.



41
42
43
# File 'lib/amanzi/sld.rb', line 41

def geometry_property
  @geometry_property
end

#nameObject (readonly)

Returns the value of attribute name.



41
42
43
# File 'lib/amanzi/sld.rb', line 41

def name
  @name
end

#sld_nameObject (readonly)

Returns the value of attribute sld_name.



41
42
43
# File 'lib/amanzi/sld.rb', line 41

def sld_name
  @sld_name
end

#style_nameObject (readonly)

Returns the value of attribute style_name.



41
42
43
# File 'lib/amanzi/sld.rb', line 41

def style_name
  @style_name
end

Instance Method Details

#add_line_symbolizer(options = {}, *args, &block) ⇒ Object



60
61
62
# File 'lib/amanzi/sld.rb', line 60

def add_line_symbolizer(options={},*args,&block)
  RuleBuilder.new(self.feature_type_style.rule).add_line_symbolizer(options,*args,&block)
end

#add_polygon_symbolizer(options = {}, *args, &block) ⇒ Object



63
64
65
# File 'lib/amanzi/sld.rb', line 63

def add_polygon_symbolizer(options={},*args,&block)
  RuleBuilder.new(self.feature_type_style.rule).add_polygon_symbolizer(options,*args,&block)
end

#add_rule(options = {}) ⇒ Object



69
70
71
72
73
74
75
76
# File 'lib/amanzi/sld.rb', line 69

def add_rule(options={})
  puts "Adding a generic rule: #{options.inspect}"
  self.feature_type_style do |fs|
    rule_builder = RuleBuilder.new(rule)
    yield rule_builder if(block_given?)
    rule_builder
  end
end

#add_text_symbolizer(options = {}, *args, &block) ⇒ Object



66
67
68
# File 'lib/amanzi/sld.rb', line 66

def add_text_symbolizer(options={},*args,&block)
  RuleBuilder.new(self.feature_type_style.rule).add_text_symbolizer(options,*args,&block)
end