class AIXM::Component::Geometry
Geometries define a 3D airspace horizontally.
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.add_segment(AIXM.point or AIXM.arc or AIXM.border or AIXM.circle)
@example Built by passing elements to the initializer
geometry = AIXM.geometry( AIXM.point(...), AIXM.point(...) )
@example Built by adding segments
geometry = AIXM.geometry geometry.add_segment(AIXM.point(...))
@see gitlab.com/openflightmaps/ofmx/wikis/Airspace#avx-border-vertex
Public Class Methods
new(*segments)
click to toggle source
# File lib/aixm/component/geometry.rb 49 def initialize(*segments) 50 segments.each { add_segment(_1) } 51 end
Public Instance Methods
circle?()
click to toggle source
@return [Boolean] Circle
shaped geometry?
# File lib/aixm/component/geometry.rb 76 def circle? 77 segments.size == 1 && 78 segments.first.is_a?(AIXM::Component::Geometry::Circle) 79 end
closed?()
click to toggle source
@return [Boolean] whether the geometry is closed
# File lib/aixm/component/geometry.rb 59 def closed? 60 point? || circle? || polygon? 61 end
inspect()
click to toggle source
@return [String]
# File lib/aixm/component/geometry.rb 54 def inspect 55 %Q(#<#{self.class} segments=#{segments.count.inspect}>) 56 end
point?()
click to toggle source
@return [Boolean] Single point geometry?
# File lib/aixm/component/geometry.rb 70 def point? 71 segments.size == 1 && 72 segments.first.is_a?(AIXM::Component::Geometry::Point) 73 end
polygon?()
click to toggle source
@return [Boolean] Polygon shaped geometry?
# File lib/aixm/component/geometry.rb 82 def polygon? 83 segments.size >= 3 && 84 !segments.any? { _1.is_a?(AIXM::Component::Geometry::Circle) } && 85 segments.last.is_a?(AIXM::Component::Geometry::Point) && 86 segments.first.xy == segments.last.xy 87 end
to_xml()
click to toggle source
@return [String] AIXM
or OFMX markup
# File lib/aixm/component/geometry.rb 64 def to_xml 65 fail(GeometryError.new("geometry is not closed", self)) unless closed? 66 segments.map { _1.to_xml }.join 67 end