Sha256: 7cfa387fddd3a869551842841a26dd9fb93df0140d7cad6eacaa3dabb35c8dc0

Contents?: true

Size: 1.22 KB

Versions: 2

Compression:

Stored size: 1.22 KB

Contents

using AIXM::Refinements

module AIXM
  module Component
    class Geometry

      # Points are defined by {#xy} coordinates.
      #
      # ===Cheat Sheet in Pseudo Code:
      #   point = AIXM.point(
      #     xy: AIXM.xy
      #   )
      #
      # @see https://gitlab.com/openflightmaps/ofmx/wikis/Airspace#point
      class Point
        include AIXM::Association

        # @!method geometry
        #   @return [AIXM::Component::Geometry] geometry the arc belongs to
        belongs_to :geometry, as: :segment

        # @return [AIXM::XY] (starting) point
        attr_reader :xy

        def initialize(xy:)
          self.xy = xy
        end

        # @return [String]
        def inspect
          %Q(#<#{self.class} xy="#{xy}">)
        end

        def xy=(value)
          fail(ArgumentError, "invalid xy") unless value.is_a? AIXM::XY
          @xy = value
        end

        # @return [String] AIXM or OFMX markup
        def to_xml
          builder = Builder::XmlMarkup.new(indent: 2)
          builder.Avx do |avx|
            avx.codeType('GRC')
            avx.geoLat(xy.lat(AIXM.schema))
            avx.geoLong(xy.long(AIXM.schema))
            avx.codeDatum('WGE')
          end
        end
      end

    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
aixm-0.3.11 lib/aixm/component/geometry/point.rb
aixm-0.3.10 lib/aixm/component/geometry/point.rb