Class: AIXM::Component::Geometry

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Includes:
Enumerable
Defined in:
lib/aixm/component/geometry.rb,
lib/aixm/component/geometry/arc.rb,
lib/aixm/component/geometry/point.rb,
lib/aixm/component/geometry/border.rb,
lib/aixm/component/geometry/circle.rb

Overview

Geometries define a 3D airspace horizontally. It's either exactly one circle or at least three points, arcs and borders (the last of which has to be a point with the same coordinates as the first).

For a geometry to be valid, it must be comprised of either:

  • exactly one point

  • exactly one circle

  • at least three points, arcs or borders (the last of which a point with identical coordinates as the first)

Cheat Sheet in Pseudo Code:

geometry = AIXM.geometry
geometry << AIXM.point or AIXM.arc or AIXM.border or AIXM.circle

Examples:

Built by passing elements to the initializer

geometry = AIXM.geometry(
  AIXM.point(...),
  AIXM.point(...)
)

Built by adding elements

geometry = AIXM.geometry
geometry << AIXM.point(...)
geometry.concat [AIXM.point(...), AIXM.point(...), ...]

See Also:

Defined Under Namespace

Classes: Arc, Border, Circle, Point

Instance Method Summary collapse

Constructor Details

#initialize(*segments) ⇒ Geometry


44
45
46
# File 'lib/aixm/component/geometry.rb', line 44

def initialize(*segments)
  @result_array = segments
end

Instance Method Details

#<<Array


42
# File 'lib/aixm/component/geometry.rb', line 42

def_delegators :@result_array, :each, :<<, :concat

#closed?Boolean


62
63
64
# File 'lib/aixm/component/geometry.rb', line 62

def closed?
  point? || circle? || polygon?
end

#concatArray


42
# File 'lib/aixm/component/geometry.rb', line 42

def_delegators :@result_array, :each, :<<, :concat

#eachEnumerator


42
# File 'lib/aixm/component/geometry.rb', line 42

def_delegators :@result_array, :each, :<<, :concat

#inspectString


49
50
51
# File 'lib/aixm/component/geometry.rb', line 49

def inspect
  %Q(#<#{self.class} segments=#{segments.count.inspect}>)
end

#segmentsArray<AIXM::Component::Geometry::Point, AIXM::Component::Geometry::Arc, AIXM::Component::Geometry::Border, AIXM::Component::Geometry::Circle>


57
58
59
# File 'lib/aixm/component/geometry.rb', line 57

def segments
  @result_array
end

#to_xmlString


67
68
69
70
# File 'lib/aixm/component/geometry.rb', line 67

def to_xml
  fail(GeometryError.new("geometry is not closed", self)) unless closed?
  @result_array.map { |h| h.to_xml }.join
end