Class: AIXM::Component::Geometry
- Inherits:
-
AIXM::Component
- Object
- AIXM::Component
- AIXM::Component::Geometry
- Includes:
- AIXM::Concerns::Association
- 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,
lib/aixm/component/geometry/rhumb_line.rb
Overview
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)
Defined Under Namespace
Classes: Arc, Border, Circle, Point, RhumbLine
Instance Attribute Summary
Attributes inherited from AIXM::Component
Instance Method Summary collapse
- #add_segment(segment) ⇒ self
-
#airspace ⇒ AIXM::Feature::Airspace
Airspace the geometry defines.
-
#circle? ⇒ Boolean
Whether a circle shaped geometry.
-
#closed? ⇒ Boolean
Whether the geometry is closed.
-
#initialize(*segments) ⇒ Geometry
constructor
See the cheat sheet for examples on how to create instances of this class.
- #inspect ⇒ String
-
#point? ⇒ Boolean
Whether a single point geometry.
-
#polygon? ⇒ Boolean
Whether a polygon shaped geometry.
-
#segments ⇒ Array<AIXM::Component::Geometry::Point, AIXM::Component::Geometry::RhumbLine AIXM::Component::Geometry::Arc, AIXM::Component::Geometry::Circle, AIXM::Component::Geometry::Border>
Points, rhumb lines, arcs, borders or circle.
Methods included from AIXM::Concerns::Association
Methods included from AIXM::Concerns::HashEquality
Methods included from AIXM::Concerns::XMLBuilder
#build_fragment, #to_uid, #to_xml
Methods included from AIXM::Concerns::Memoize
Constructor Details
#initialize(*segments) ⇒ Geometry
See the cheat sheet for examples on how to create instances of this class.
54 55 56 |
# File 'lib/aixm/component/geometry.rb', line 54 def initialize(*segments) segments.each { add_segment(_1) } end |
Instance Method Details
#add_segment(segment) ⇒ self
46 |
# File 'lib/aixm/component/geometry.rb', line 46 has_many :segments, accept: %i(point rhumb_line arc circle border) |
#airspace ⇒ AIXM::Feature::Airspace
Returns airspace the geometry defines.
50 |
# File 'lib/aixm/component/geometry.rb', line 50 belongs_to :airspace |
#circle? ⇒ Boolean
Whether a circle shaped geometry
81 82 83 84 |
# File 'lib/aixm/component/geometry.rb', line 81 def circle? segments.size == 1 && segments.first.is_a?(AIXM::Component::Geometry::Circle) end |
#closed? ⇒ Boolean
Whether the geometry is closed
66 67 68 |
# File 'lib/aixm/component/geometry.rb', line 66 def closed? point? || circle? || polygon? end |
#inspect ⇒ String
59 60 61 |
# File 'lib/aixm/component/geometry.rb', line 59 def inspect %Q(#<#{self.class} segments=#{segments.count.inspect}>) end |
#point? ⇒ Boolean
Whether a single point geometry
73 74 75 76 |
# File 'lib/aixm/component/geometry.rb', line 73 def point? segments.size == 1 && segments.first.is_a?(AIXM::Component::Geometry::Point) end |
#polygon? ⇒ Boolean
Whether a polygon shaped geometry
89 90 91 92 93 94 |
# File 'lib/aixm/component/geometry.rb', line 89 def polygon? segments.size >= 3 && !segments.any? { _1.is_a?(AIXM::Component::Geometry::Circle) } && segments.last.is_a?(AIXM::Component::Geometry::Point) && segments.first.xy == segments.last.xy end |
#segments ⇒ Array<AIXM::Component::Geometry::Point, AIXM::Component::Geometry::RhumbLine AIXM::Component::Geometry::Arc, AIXM::Component::Geometry::Circle, AIXM::Component::Geometry::Border>
Returns points, rhumb lines, arcs, borders or circle.
46 |
# File 'lib/aixm/component/geometry.rb', line 46 has_many :segments, accept: %i(point rhumb_line arc circle border) |