Class: VORuby::ADQL::Box

Inherits:
Shape show all
Defined in:
lib/voruby/adql/adql.rb,
lib/voruby/adql/transforms.rb

Overview

Box shape. The box is defined by a center and a size

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(ra, dec, dra, ddec, system = 'J2000') ⇒ Box

Returns a new instance of Box.



1744
1745
1746
1747
1748
1749
1750
1751
# File 'lib/voruby/adql/adql.rb', line 1744

def initialize(ra, dec, dra, ddec, system='J2000')
  self.ra = ra
  self.dec = dec
  self.dra = dra#deltha RA
  self.ddec = ddec#deltha DEC
  self.system = system
  self.shape = 'BOX'
end

Instance Attribute Details

#ddecObject

Returns the value of attribute ddec.



1742
1743
1744
# File 'lib/voruby/adql/adql.rb', line 1742

def ddec
  @ddec
end

#decObject

Returns the value of attribute dec.



1742
1743
1744
# File 'lib/voruby/adql/adql.rb', line 1742

def dec
  @dec
end

#draObject

Returns the value of attribute dra.



1742
1743
1744
# File 'lib/voruby/adql/adql.rb', line 1742

def dra
  @dra
end

#raObject

Returns the value of attribute ra.



1742
1743
1744
# File 'lib/voruby/adql/adql.rb', line 1742

def ra
  @ra
end

#shapeObject

Returns the value of attribute shape.



1742
1743
1744
# File 'lib/voruby/adql/adql.rb', line 1742

def shape
  @shape
end

#systemObject

Returns the value of attribute system.



1742
1743
1744
# File 'lib/voruby/adql/adql.rb', line 1742

def system
  @system
end

Class Method Details

.create_new_object(attributes) ⇒ Object



1834
1835
1836
1837
1838
1839
1840
1841
# File 'lib/voruby/adql/adql.rb', line 1834

def self.create_new_object(attributes)
  ra = RealType.new(attributes['ra'])
  dec = RealType.new(attributes['dec'])
  dra = RealType.new(attributes['dra'])
  ddec = RealType.new(attributes['ddec'])

  return Box.new(ra, dec, dra, ddec)
end

.from_xml(node) ⇒ Object



1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
# File 'lib/voruby/adql/adql.rb', line 1818

def self.from_xml(node)
  unit = node.attributes['unit'] || 'deg'

  center = REXML::XPath.first(node, 'reg:Center').text
  ra_s, dec_s = center.split(/\s+/)
  ra = RealType.new(ra_s.to_f)
  dec = RealType.new(dec_s.to_f)

  size = REXML::XPath.first(node, 'reg:Size').text
  dra_s, ddec_s = size.split(/\s+/)
  dra = RealType.new(dra_s.to_f)
  ddec = RealType.new(ddec_s.to_f)

  return Box.new(ra, dec, dra, ddec)
end

Instance Method Details

#match_attributtes(attributes) ⇒ Object



1843
1844
1845
1846
1847
1848
1849
# File 'lib/voruby/adql/adql.rb', line 1843

def match_attributtes(attributes)
  return true if self.ra.value == attributes['ra'] and
      self.dec.value == attributes['dec'] and
      self.dra.value == attributes['dra'] and
      self.ddec.value == attributes['ddec']
  return false
end

#to_adqlsObject



341
342
343
344
345
# File 'lib/voruby/adql/transforms.rb', line 341

def to_adqls
  "#{self.shape.to_adqls} #{self.system.to_adqls} " +
  "#{self.ra.to_adqls} #{self.dec.to_adqls} " +
  "#{self.dra.to_adqls} #{self.ddec.to_adqls}"
end

#to_adqlxObject



347
348
349
350
351
352
# File 'lib/voruby/adql/transforms.rb', line 347

def to_adqlx
  box = "xsi:type=\"reg:boxType\">\n"
  box << "<reg:Center>#{self.ra.value} #{self.dec.value}</reg:Center>\n"
  box << "<reg:Size>#{self.dra.value} #{self.ddec.value}</reg:Size>\n"
  return box
end

#to_sObject



1813
1814
1815
1816
# File 'lib/voruby/adql/adql.rb', line 1813

def to_s
  "{shape=#{self.shape},system=#{self.system},ra=#{self.ra}," +
  "dec=#{self.dec},dra=#{self.dra},ddec=#{self.ddec}}"
end