Class: NSWTopo::Labels::Fence

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(segment, buffer: 0, index:) ⇒ Fence

Returns a new instance of Fence.



4
5
6
# File 'lib/nswtopo/layer/labels/fence.rb', line 4

def initialize(segment, buffer: 0, index:)
  @segment, @buffer, @index = segment, buffer, index
end

Instance Attribute Details

#indexObject (readonly)

Returns the value of attribute index.



7
8
9
# File 'lib/nswtopo/layer/labels/fence.rb', line 7

def index
  @index
end

Instance Method Details

#boundsObject



9
10
11
12
13
# File 'lib/nswtopo/layer/labels/fence.rb', line 9

def bounds
  @segment.transpose.map(&:minmax).map do |min, max|
    [min - @buffer, max + @buffer]
  end
end

#conflicts_with?(segment, buffer = 0) ⇒ Boolean

Returns:

  • (Boolean)


15
16
17
# File 'lib/nswtopo/layer/labels/fence.rb', line 15

def conflicts_with?(segment, buffer = 0)
  [@segment, segment].overlap?(@buffer + buffer)
end