Class: VORuby::STC::V1_10::Coords::AstroCoords
- Inherits:
-
AstroCoordsType
- Object
- CoordsType
- AstroCoordsType
- VORuby::STC::V1_10::Coords::AstroCoords
- Includes:
- Coords
- Defined in:
- lib/voruby/stc/1.10/coords.rb
Overview
The coordinate element consists either of a coordinate file or a sequence of time element, spatial coordinate element, velocity element, and redshift element; the spatial and velocity elements may be scalar or vector; it needs to refer to a coordinate system
Instance Attribute Summary
Attributes inherited from AstroCoordsType
#coord_file, #position, #redshift, #spectral, #time, #velocity
Attributes inherited from CoordsType
#coord_system_id, #coordinates
Class Method Summary collapse
Instance Method Summary collapse
Methods included from SerializableToXml
Methods inherited from AstroCoordsType
Methods inherited from CoordsType
Constructor Details
This class inherits a constructor from VORuby::STC::V1_10::Coords::CoordsType
Class Method Details
.from_xml(xml) ⇒ Object
2222 2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 |
# File 'lib/voruby/stc/1.10/coords.rb', line 2222 def self.from_xml(xml) root = element_from(xml) = { :coord_system_id => IdRef.new(root.attributes.get_attribute_ns(obj_ns.uri, 'coord_system_id').value), } [:coordinates] = xml_to_obj(root, Coordinate) time = REXML::XPath.first(root, 'x:Time', {'x' => obj_ns.uri}) [:time] = TimeCoordinate.from_xml(time) if time [:position] = xml_to_obj(root, Position, true) [:velocity] = xml_to_obj(root, Velocity, true) [:spectral] = xml_to_obj(root, Spectral, true) [:redshift] = xml_to_obj(root, Redshift, true) coord_file = REXML::XPath.first(root, 'x:CoordFile', {'x' => obj_ns.uri}) [:coord_file] = AstroCoordsFile.from_xml(coord_file) if coord_file AstroCoords.new() end |
Instance Method Details
#to_xml(name = nil, ns = nil) ⇒ Object
2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 |
# File 'lib/voruby/stc/1.10/coords.rb', line 2205 def to_xml(name=nil, ns=nil) el = element(name, ns) el.attributes["#{obj_ns.prefix}:coord_system_id"] = self.coord_system_id.to_s self.coordinates.each { |c| el.add_element(c.to_xml) } if self.coordinates el.add_element(self.time.to_xml('Time')) if self.time el.add_element(self.position.to_xml) if self.position el.add_element(self.velocity.to_xml) if self.velocity el.add_element(self.spectral.to_xml) if self.spectral el.add_element(self.redshift.to_xml) if self.redshift el.add_element(self.coord_file.to_xml('CoordFile')) if self.coord_file collapse_namespaces(el) el end |