Class: VORuby::STC::V1_10::STC::CoordAreaType

Inherits:
Object
  • Object
show all
Includes:
SerializableToXml
Defined in:
lib/voruby/stc/1.10/stc.rb

Overview

Generalized coordinate area type

Direct Known Subclasses

AstroCoordAreaType, PixelCoordAreaType

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from SerializableToXml

#element

Constructor Details

#initialize(options = {}) ⇒ CoordAreaType

Returns a new instance of CoordAreaType.



2543
2544
2545
2546
2547
# File 'lib/voruby/stc/1.10/stc.rb', line 2543

def initialize(options={})
  raise_argument_required_error('id') if !options.has_key?(:id)
  raise_argument_required_error('coord system id') if !options.has_key?(:coord_system_id)
  options.each { |key, value| send("#{key}=", value) }
end

Instance Attribute Details

#coord_intervalsObject

Returns the value of attribute coord_intervals.



2539
2540
2541
# File 'lib/voruby/stc/1.10/stc.rb', line 2539

def coord_intervals
  @coord_intervals
end

#coord_system_idObject

Returns the value of attribute coord_system_id.



2539
2540
2541
# File 'lib/voruby/stc/1.10/stc.rb', line 2539

def coord_system_id
  @coord_system_id
end

#idObject

Returns the value of attribute id.



2539
2540
2541
# File 'lib/voruby/stc/1.10/stc.rb', line 2539

def id
  @id
end

#redshift_intervalsObject

Returns the value of attribute redshift_intervals.



2539
2540
2541
# File 'lib/voruby/stc/1.10/stc.rb', line 2539

def redshift_intervals
  @redshift_intervals
end

#spatial_intervalObject

Returns the value of attribute spatial_interval.



2539
2540
2541
# File 'lib/voruby/stc/1.10/stc.rb', line 2539

def spatial_interval
  @spatial_interval
end

#spectral_intervalsObject

Returns the value of attribute spectral_intervals.



2539
2540
2541
# File 'lib/voruby/stc/1.10/stc.rb', line 2539

def spectral_intervals
  @spectral_intervals
end

#time_intervalsObject

Returns the value of attribute time_intervals.



2539
2540
2541
# File 'lib/voruby/stc/1.10/stc.rb', line 2539

def time_intervals
  @time_intervals
end

#vel_intervalsObject

Returns the value of attribute vel_intervals.



2539
2540
2541
# File 'lib/voruby/stc/1.10/stc.rb', line 2539

def vel_intervals
  @vel_intervals
end

Class Method Details

.from_xml(xml) ⇒ Object



2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
# File 'lib/voruby/stc/1.10/stc.rb', line 2640

def self.from_xml(xml)
  root = element_from(xml)
  
  options = {
    :id => Id.new(root.attributes.get_attribute_ns(obj_ns.uri, 'ID').value),
    :coord_system_id => IdRef.new(root.attributes.get_attribute_ns(obj_ns.uri, 'coord_system_id').value)
  }
  
  time_intervals = REXML::XPath.match(root, 'x:TimeInterval', {'x' => obj_ns.uri})
  options[:time_intervals] = TimeIntervalList.new(time_intervals.collect{ |i| TimeIntervalType.from_xml(i) }) if time_intervals
  
  options[:spatial_interval] = xml_to_obj(root, SpatialInterval, true)
  
  options[:vel_intervals] = xml_to_obj(root, VelInterval)
  options[:vel_intervals] = nil if options[:vel_intervals].size == 0
  
  spectral_intervals = REXML::XPath.match(root, 'x:SpectralInterval', {'x' => obj_ns.uri})
  options[:spectral_intervals] = SpectralIntervalList.new(spectral_intervals.collect{ |i| SpectralInterval.from_xml(i) }) if spectral_intervals
  options[:spectral_intervals] = nil if spectral_intervals and options[:spectral_intervals].size == 0
  
  redshift_intervals = REXML::XPath.match(root, 'x:RedshiftInterval', {'x' => obj_ns.uri})
  options[:redshift_intervals] = RedshiftIntervalList.new(redshift_intervals.collect{ |i| RedshiftInterval.from_xml(i) }) if redshift_intervals
  options[:redshift_intervals] = nil if redshift_intervals and options[:redshift_intervals].size == 0
  
  options[:coord_intervals] = xml_to_obj(root, CoordInterval)
  options[:coord_intervals] = nil if options[:coord_intervals].size == 0
  
  self.new(options)
end

Instance Method Details

#==(a) ⇒ Object



2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
# File 'lib/voruby/stc/1.10/stc.rb', line 2612

def ==(a)
  self.time_intervals == a.time_intervals and
  self.spatial_interval == a.spatial_interval and
  self.vel_intervals == a.vel_intervals and
  self.spectral_intervals == a.spectral_intervals and
  self.redshift_intervals == a.redshift_intervals and
  self.coord_intervals == a.coord_intervals and
  self.id == a.id and
  self.coord_system_id == a.coord_system_id
end

#to_xml(name = nil) ⇒ Object



2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
# File 'lib/voruby/stc/1.10/stc.rb', line 2623

def to_xml(name=nil)
  el = element(name)
  
  el.attributes["#{obj_ns.prefix}:ID"] = self.id.to_s
  el.attributes["#{obj_ns.prefix}:coord_system_id"] = self.coord_system_id.to_s
  
  self.time_intervals.each { |i| el.add_element(i.to_xml('TimeInterval')) } if self.time_intervals
  el.add_element(self.spatial_interval.to_xml) if self.spatial_interval
  self.vel_intervals.each { |i| el.add_element(i.to_xml) } if self.vel_intervals
  self.spectral_intervals.each { |i| el.add_element(i.to_xml('SpectralInterval')) } if self.spectral_intervals
  self.redshift_intervals.each { |i| el.add_element(i.to_xml('RedshiftInterval')) } if self.redshift_intervals
  self.coord_intervals.each { |i| el.add_element(i.to_xml) } if self.coord_intervals
  
  collapse_namespaces(el)
  el
end