Class: Contrek::Concurrent::Merger
Instance Attribute Summary collapse
Attributes included from Poolable
#number_of_threads
Attributes inherited from Finder
#maximum_width, #options
Instance Method Summary
collapse
Methods included from Poolable
#enqueue!, #wait!
Methods inherited from Finder
#transpose?
Constructor Details
#initialize(options: {}) ⇒ Merger
Returns a new instance of Merger.
9
10
11
12
13
14
15
16
17
18
19
|
# File 'lib/contrek/finder/concurrent/merger.rb', line 9
def initialize(options: {})
@initialize_time = 0
@current_x = 0
@tiles = Queue.new
@whole_tile = nil
@user_options = options
@options = {unsafe_mode: false}.merge(@user_options)
unless safe?
warn "[Contrek WARNING] Processing tile with 'unsafe_mode: true'. Incompatible result options might lead to unexpected vector geometry."
end
end
|
Instance Attribute Details
#tiles ⇒ Object
Returns the value of attribute tiles.
6
7
8
|
# File 'lib/contrek/finder/concurrent/merger.rb', line 6
def tiles
@tiles
end
|
Instance Method Details
#add_tile(result) ⇒ Object
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
# File 'lib/contrek/finder/concurrent/merger.rb', line 21
def add_tile(result)
@height ||= result.metadata[:height]
raise ArgumentError, "All results must have the same height" if @height != result.metadata[:height] && safe?
@options[:versus] ||= result.metadata[:versus]
raise ArgumentError, "All results must have the same versus option" if @options[:versus] != result.metadata[:versus] && safe?
if safe? && result.metadata[:options].key?(:compress)
if (result.metadata[:options][:compress].keys - [:uniq, :linear]).any?
raise ArgumentError, "Result with not supported postprocessing compression mode"
end
end
end_x = @current_x + result.metadata[:width]
tile = Tile.new(
finder: self,
start_x: @current_x,
end_x: end_x,
name: @tiles.size.to_s
)
tile.assign_raw_polygons!(result[:polygons])
@tiles << tile
@maximum_width = end_x
@current_x = end_x - 1
end
|
#process_info ⇒ Object
51
52
53
54
|
# File 'lib/contrek/finder/concurrent/merger.rb', line 51
def process_info
process_tiles!(nil, height: @height)
super
end
|
#safe? ⇒ Boolean
47
48
49
|
# File 'lib/contrek/finder/concurrent/merger.rb', line 47
def safe?
!@options[:unsafe_mode]
end
|