Class: NSWTopo::Labels::Barrier

Inherits:
Object
  • Object
show all
Defined in:
lib/nswtopo/layer/labels/barrier.rb

Defined Under Namespace

Classes: Segment

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(feature, buffer) ⇒ Barrier

Returns a new instance of Barrier.



18
19
20
# File 'lib/nswtopo/layer/labels/barrier.rb', line 18

def initialize(feature, buffer)
  @feature, @buffer = feature, buffer
end

Instance Attribute Details

#bufferObject (readonly)

Returns the value of attribute buffer.



21
22
23
# File 'lib/nswtopo/layer/labels/barrier.rb', line 21

def buffer
  @buffer
end

Instance Method Details

#segmentsObject



23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/nswtopo/layer/labels/barrier.rb', line 23

def segments
  case @feature
  when GeoJSON::Point
    [[@feature.coordinates] * 2]
  when GeoJSON::LineString
    @feature.coordinates.segments
  when GeoJSON::Polygon
    @feature.coordinates.flat_map do |coordinates|
      coordinates.segments
    end
  end.map do |segment|
    Segment.new segment, self
  end
end