Class: NSWTopo::Labels::Barrier::Segment

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(segment, barrier) ⇒ Segment

Returns a new instance of Segment.



5
6
7
8
9
10
# File 'lib/nswtopo/layer/labels/barrier.rb', line 5

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

Instance Attribute Details

#barrierObject (readonly)

Returns the value of attribute barrier.



11
12
13
# File 'lib/nswtopo/layer/labels/barrier.rb', line 11

def barrier
  @barrier
end

#boundsObject (readonly)

Returns the value of attribute bounds.



11
12
13
# File 'lib/nswtopo/layer/labels/barrier.rb', line 11

def bounds
  @bounds
end

Instance Method Details

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

Returns:

  • (Boolean)


13
14
15
# File 'lib/nswtopo/layer/labels/barrier.rb', line 13

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