Class: NSWTopo::Labels::Barriers
- Inherits:
-
Object
- Object
- NSWTopo::Labels::Barriers
- Extended by:
- Forwardable
- Defined in:
- lib/nswtopo/layer/labels/barriers.rb
Instance Method Summary collapse
-
#initialize ⇒ Barriers
constructor
A new instance of Barriers.
- #to_proc ⇒ Object
Constructor Details
#initialize ⇒ Barriers
Returns a new instance of Barriers.
4 5 6 |
# File 'lib/nswtopo/layer/labels/barriers.rb', line 4 def initialize @barriers, @cache = [], Hash[] end |
Instance Method Details
#to_proc ⇒ Object
11 12 13 14 15 16 17 18 19 20 |
# File 'lib/nswtopo/layer/labels/barriers.rb', line 11 def to_proc @index ||= RTree.load(@barriers.flat_map(&:explode), &:bounds) @proc ||= lambda do |label_hull, buffer| @cache[[buffer, label_hull.coordinates]] ||= @index.search(label_hull.bounds, buffer).with_object Set[] do |, | next if === .source next unless ConvexHulls.overlap?(, label_hull, buffer) << .source end end end |