Class: VORuby::STC::V1_30::BoxType
- Inherits:
-
ShapeType
- Object
- STCBaseType
- CoordIntervalType
- SpatialIntervalType
- RegionType
- ShapeType
- VORuby::STC::V1_30::BoxType
- Defined in:
- lib/voruby/stc/1.30/stc.rb
Overview
Box shape: a rectangle defined by its center and size on both dimensions; since it is a polygon, it is redundant, but simple rectangles with great circle sides are awkward to define in spherical coordinates.
Instance Attribute Summary collapse
-
#center ⇒ Object
Returns the value of attribute center.
-
#size ⇒ Object
Returns the value of attribute size.
Attributes inherited from RegionType
#area, #coord_system_id, #note
Attributes inherited from SpatialIntervalType
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
- #==(b) ⇒ Object
-
#initialize(center, size, area = nil, lo_include = true, hi_include = true, options = {}) ⇒ BoxType
constructor
A new instance of BoxType.
- #to_s ⇒ Object
- #to_xml(name = nil) ⇒ Object
Methods inherited from ShapeType
Methods inherited from RegionType
Methods inherited from SpatialIntervalType
Methods inherited from CoordIntervalType
coord_interval_from_xml, #hi_include?, #lo_include?
Methods inherited from STCBaseType
Methods included from STCReference
#stc_reference_eq, stc_reference_from_xml, #stc_reference_to_xml
Methods included from SerializableToXml
Constructor Details
#initialize(center, size, area = nil, lo_include = true, hi_include = true, options = {}) ⇒ BoxType
Returns a new instance of BoxType.
5592 5593 5594 5595 5596 |
# File 'lib/voruby/stc/1.30/stc.rb', line 5592 def initialize(center, size, area=nil, lo_include=true, hi_include=true, ={}) super(area, lo_include, hi_include, ) self.center = center self.size = size end |
Instance Attribute Details
#center ⇒ Object
Returns the value of attribute center.
5590 5591 5592 |
# File 'lib/voruby/stc/1.30/stc.rb', line 5590 def center @center end |
#size ⇒ Object
Returns the value of attribute size.
5590 5591 5592 |
# File 'lib/voruby/stc/1.30/stc.rb', line 5590 def size @size end |
Class Method Details
.from_xml(xml) ⇒ Object
5632 5633 5634 5635 5636 5637 5638 5639 5640 |
# File 'lib/voruby/stc/1.30/stc.rb', line 5632 def self.from_xml(xml) root = element_from(xml) self.new( Double2Type.from_xml(REXML::XPath.first(root, 'x:Center', {'x' => obj_ns.uri})), Double2Type.from_xml(REXML::XPath.first(root, 'x:Size', {'x' => obj_ns.uri})), *ShapeType.shape_from_xml(root) ) end |
Instance Method Details
#==(b) ⇒ Object
5612 5613 5614 5615 5616 |
# File 'lib/voruby/stc/1.30/stc.rb', line 5612 def ==(b) super(b) and self.center == b.center and self.size == b.size end |
#to_s ⇒ Object
5628 5629 5630 |
# File 'lib/voruby/stc/1.30/stc.rb', line 5628 def to_s "BOX #{self.coord_system_id || IdRef.new('J2000')} #{self.center} #{self.size}" end |
#to_xml(name = nil) ⇒ Object
5618 5619 5620 5621 5622 5623 5624 5625 5626 |
# File 'lib/voruby/stc/1.30/stc.rb', line 5618 def to_xml(name=nil) el = super(name) el.add_element(self.center.to_xml('Center')) el.add_element(self.size.to_xml('Size')) collapse_namespaces(el) el end |