Class: VORuby::STC::V1_30::RegionType

Inherits:
SpatialIntervalType show all
Defined in:
lib/voruby/stc/1.30/stc.rb

Overview

Abstract region type; a Region is a Shape or the result of a Region Operation involving one or more Regions.

Instance Attribute Summary collapse

Attributes inherited from SpatialIntervalType

#epoch, #unit

Attributes inherited from CoordIntervalType

#fill_factor, #frame_id, #hi_include, #lo_include

Attributes included from STCReference

#id, #idref, #ucd, #xlink_href, #xlink_type

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from SpatialIntervalType

spatial_interval_from_xml

Methods inherited from CoordIntervalType

coord_interval_from_xml, #hi_include?, #lo_include?

Methods inherited from STCBaseType

stc_base_from_xml

Methods included from STCReference

#stc_reference_eq, stc_reference_from_xml, #stc_reference_to_xml

Methods included from SerializableToXml

#element

Constructor Details

#initialize(area, lo_include = true, hi_include = true, options = {}) ⇒ RegionType

Returns a new instance of RegionType.



5212
5213
5214
5215
# File 'lib/voruby/stc/1.30/stc.rb', line 5212

def initialize(area, lo_include=true, hi_include=true, options={})
  self.area = area
  super(lo_include, hi_include, options)
end

Instance Attribute Details

#areaObject

Returns the value of attribute area.



5210
5211
5212
# File 'lib/voruby/stc/1.30/stc.rb', line 5210

def area
  @area
end

#coord_system_idObject

Returns the value of attribute coord_system_id.



5210
5211
5212
# File 'lib/voruby/stc/1.30/stc.rb', line 5210

def coord_system_id
  @coord_system_id
end

#noteObject

Returns the value of attribute note.



5210
5211
5212
# File 'lib/voruby/stc/1.30/stc.rb', line 5210

def note
  @note
end

Class Method Details

.from_xml(xml) ⇒ Object



5271
5272
5273
5274
# File 'lib/voruby/stc/1.30/stc.rb', line 5271

def self.from_xml(xml)
  root = element_from(xml)
  self.new(*region_from_xml(xml))
end

.region_from_xml(root) ⇒ Object



5252
5253
5254
5255
5256
5257
5258
5259
5260
5261
5262
5263
5264
5265
5266
5267
5268
5269
# File 'lib/voruby/stc/1.30/stc.rb', line 5252

def self.region_from_xml(root)
  lo_include, hi_include, options = SpatialIntervalType.spatial_interval_from_xml(root)
  
  area = REXML::XPath.first(root, 'x:Area', {'x' => obj_ns.uri})
  
  note = root.attributes.get_attribute_ns(obj_ns.uri, 'note')
  options[:note] = note ? note.value : nil
  
  coord_system_id = root.attributes.get_attribute_ns(obj_ns.uri, 'coord_system_id')
  options[:coord_system_id] = coord_system_id ? IdRef.new(coord_system_id.value) : nil
  
  [
    area ? RegionAreaType.from_xml(area) : nil,
    lo_include,
    hi_include,
    options
  ]
end

Instance Method Details

#==(r) ⇒ Object



5234
5235
5236
5237
5238
5239
# File 'lib/voruby/stc/1.30/stc.rb', line 5234

def ==(r)
  super(r) and
  self.area == r.area and
  self.note == r.note and
  self.coord_system_id == r.coord_system_id
end

#to_xml(name = nil) ⇒ Object



5241
5242
5243
5244
5245
5246
5247
5248
5249
5250
# File 'lib/voruby/stc/1.30/stc.rb', line 5241

def to_xml(name=nil)
  el = super(name)
  
  el.add_element(self.area.to_xml('Area')) if self.area
  el.attributes["#{obj_ns.prefix}:note"] = self.note if self.note
  el.attributes["#{obj_ns.prefix}:coord_system_id"] = self.coord_system_id.to_s if self.coord_system_id
  
  collapse_namespaces(el)
  el 
end