Class: VORuby::STC::V1_10::Region::PolygonType

Inherits:
Shape show all
Defined in:
lib/voruby/stc/1.10/region.rb

Overview

Polygon: one or more vertices; counter-clockwise encircled area is enclosed; cyclical coordinates may exceed 0 and 360 limits if necessary

Direct Known Subclasses

Polygon

Instance Attribute Summary collapse

Attributes inherited from Shape

#coord_system_id, #unit

Attributes inherited from RegionType

#note

Class Method Summary collapse

Instance Method Summary collapse

Methods included from SerializableToXml

#element

Methods inherited from RegionType

#fill_factor, #fill_factor=

Constructor Details

#initialize(options = {}) ⇒ PolygonType

Returns a new instance of PolygonType.



394
395
396
397
# File 'lib/voruby/stc/1.10/region.rb', line 394

def initialize(options={})
  raise_argument_required_error('list of vertexes') if !options.has_key?(:vertices)
  super(options)
end

Instance Attribute Details

#verticesObject

Returns the value of attribute vertices.



390
391
392
# File 'lib/voruby/stc/1.10/region.rb', line 390

def vertices
  @vertices
end

Class Method Details

.from_xml(xml) ⇒ Object



429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
# File 'lib/voruby/stc/1.10/region.rb', line 429

def self.from_xml(xml)
  root = element_from(xml)
  
  fill_factor = root.attributes.get_attribute_ns(obj_ns.uri, 'fill_factor')
  note = root.attributes.get_attribute_ns(obj_ns.uri, 'note')
  unit = root.attributes.get_attribute_ns(obj_ns.uri, 'unit')
  options = {
    :fill_factor => fill_factor ? Float(fill_factor.value) : nil,
    :note => note ? note.value : nil,
    :coord_system_id => IdRef.new(root.attributes.get_attribute_ns(obj_ns.uri, 'coord_system_id').value),
    :unit => unit ? PosUnit.new(unit.value) : nil,
    :vertices => VertexList.new(xml_to_obj(root, Vertex))
  }
  
  self.new(options)
end

.xml_typeObject



392
# File 'lib/voruby/stc/1.10/region.rb', line 392

def self.xml_type; 'polygonType' end

Instance Method Details

#==(p) ⇒ Object



413
414
415
416
# File 'lib/voruby/stc/1.10/region.rb', line 413

def ==(p)
  super(p) and
  self.vertices == p.vertices
end

#to_sObject



425
426
427
# File 'lib/voruby/stc/1.10/region.rb', line 425

def to_s
  "POLYGON #{self.coord_system_id} #{self.vertices.collect{ |v| v.to_s }.join(' ')}"
end

#to_xml(name = nil) ⇒ Object



418
419
420
421
422
423
# File 'lib/voruby/stc/1.10/region.rb', line 418

def to_xml(name=nil)
  el = super(name)
  self.vertices.each { |v| el.add_element(v.to_xml('Vertex')) }
  collapse_namespaces(el)
  el
end