Class: AIXM::L
Overview
Geographical line with optional profile
Each line point is an OStruct which can be queried for its coordinates with .xy or its optional elevation with .z
Instance Attribute Summary collapse
-
#line_points ⇒ Array<OStruct>
readonly
Array of line points.
Instance Method Summary collapse
- #==(other) ⇒ Object
-
#add_line_point(xy:, z: nil) ⇒ self
Add a line point to the line.
-
#initialize(xy: nil, z: nil) ⇒ L
constructor
See the overview for examples.
- #inspect ⇒ String
-
#line? ⇒ Boolean
Whether there are enough line points to define a line.
-
#to_s ⇒ String
Human readable representation.
Constructor Details
Instance Attribute Details
#line_points ⇒ Array<OStruct> (readonly)
Array of line points
19 20 21 |
# File 'lib/aixm/l.rb', line 19 def line_points @line_points end |
Instance Method Details
#==(other) ⇒ Object
57 58 59 |
# File 'lib/aixm/l.rb', line 57 def ==(other) self.class === other && to_s == other.to_s end |
#add_line_point(xy:, z: nil) ⇒ self
Add a line point to the line
42 43 44 45 46 47 |
# File 'lib/aixm/l.rb', line 42 def add_line_point(xy:, z: nil) fail(ArgumentError, "invalid xy") unless xy.instance_of?(AIXM::XY) fail(ArgumentError, "invalid z") unless !z || z.instance_of?(AIXM::Z) line_points << OpenStruct.new(xy: xy, z: z) self end |
#inspect ⇒ String
28 29 30 |
# File 'lib/aixm/l.rb', line 28 def inspect %Q(#<#{self.class} #{to_s}>) end |
#line? ⇒ Boolean
Whether there are enough line points to define a line
52 53 54 |
# File 'lib/aixm/l.rb', line 52 def line? line_points.count >= 2 end |
#to_s ⇒ String
33 34 35 |
# File 'lib/aixm/l.rb', line 33 def to_s line_points.map { _1.to_h.values.map(&:to_s).join(' ') }.join(', ') end |