Sha256: 5298c4ae2c5a975d2495f1fad7b33da405f0f7c3cbe16bc72020cbb60c7f47c2

Contents?: true

Size: 1.53 KB

Versions: 2

Compression:

Stored size: 1.53 KB

Contents

using AIXM::Refinements

module AIXM
  class Component
    class Geometry

      # Either an individual point or the starting point of a great circle
      # line. 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 this segment belongs to
        belongs_to :geometry, as: :segment

        # (Starting) point
        #
        # @overload xy
        #   @return [AIXM::XY]
        # @overload xy=(value)
        #   @param value [AIXM::XY]
        attr_reader :xy

        # See the {cheat sheet}[AIXM::Component::Geometry::Point] for examples
        # on how to create instances of this class.
        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-1.2.1 lib/aixm/component/geometry/point.rb
aixm-1.2.0 lib/aixm/component/geometry/point.rb