contrek 1.2.8 → 1.2.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.gitignore +2 -1
- data/.rubocop.yml +11 -0
- data/CHANGELOG.md +7 -1
- data/Gemfile +2 -0
- data/Gemfile.lock +1 -1
- data/README.md +1 -1
- data/Rakefile +2 -0
- data/contrek.gemspec +2 -0
- data/ext/cpp_polygon_finder/PolygonFinder/CMakeLists.txt +2 -4
- data/ext/cpp_polygon_finder/PolygonFinder/src/Tests.cpp +108 -1
- data/ext/cpp_polygon_finder/PolygonFinder/src/Tests.h +1 -0
- data/ext/cpp_polygon_finder/PolygonFinder/src/polygon/finder/PolygonFinder.cpp +0 -1
- data/ext/cpp_polygon_finder/PolygonFinder/src/polygon/finder/PolygonFinder.h +70 -297
- data/ext/cpp_polygon_finder/PolygonFinder/src/polygon/finder/concurrent/Finder.h +1 -1
- data/ext/cpp_polygon_finder/PolygonFinder/src/polygon/finder/concurrent/Polyline.cpp +6 -6
- data/ext/cpp_polygon_finder/PolygonFinder/src/polygon/finder/concurrent/Polyline.h +3 -2
- data/ext/cpp_polygon_finder/PolygonFinder/src/polygon/finder/concurrent/StreamingMerger.cpp +114 -0
- data/ext/cpp_polygon_finder/PolygonFinder/src/polygon/finder/concurrent/StreamingMerger.h +41 -0
- data/ext/cpp_polygon_finder/cpp_polygon_finder.cpp +52 -2
- data/ext/cpp_polygon_finder/extconf.rb +2 -0
- data/lib/contrek/bitmaps/bitmap.rb +2 -0
- data/lib/contrek/bitmaps/chunky_bitmap.rb +2 -0
- data/lib/contrek/bitmaps/painting.rb +2 -0
- data/lib/contrek/bitmaps/png_bitmap.rb +2 -0
- data/lib/contrek/bitmaps/raw_bitmap.rb +2 -0
- data/lib/contrek/bitmaps/rgb_color.rb +2 -0
- data/lib/contrek/bitmaps/rgb_cpp_color.rb +2 -0
- data/lib/contrek/bitmaps/sample_generator.rb +2 -0
- data/lib/contrek/cpp/cpp_concurrent_finder.rb +2 -0
- data/lib/contrek/cpp/cpp_concurrent_horizontal_merger.rb +2 -0
- data/lib/contrek/cpp/cpp_concurrent_merger.rb +2 -0
- data/lib/contrek/cpp/cpp_concurrent_streaming_merger.rb +11 -0
- data/lib/contrek/cpp/cpp_concurrent_vertical_merger.rb +2 -0
- data/lib/contrek/cpp/cpp_result.rb +2 -0
- data/lib/contrek/cpp/cpp_tempfile.rb +28 -0
- data/lib/contrek/finder/bounds.rb +2 -0
- data/lib/contrek/finder/concurrent/clipped_polygon_finder.rb +2 -0
- data/lib/contrek/finder/concurrent/cluster.rb +2 -0
- data/lib/contrek/finder/concurrent/cursor.rb +2 -0
- data/lib/contrek/finder/concurrent/end_point.rb +2 -0
- data/lib/contrek/finder/concurrent/fake_cluster.rb +2 -0
- data/lib/contrek/finder/concurrent/finder.rb +2 -0
- data/lib/contrek/finder/concurrent/horizontal_merger.rb +2 -0
- data/lib/contrek/finder/concurrent/hub.rb +2 -0
- data/lib/contrek/finder/concurrent/inner_polyline.rb +2 -0
- data/lib/contrek/finder/concurrent/listable.rb +2 -0
- data/lib/contrek/finder/concurrent/merger.rb +3 -0
- data/lib/contrek/finder/concurrent/part.rb +2 -0
- data/lib/contrek/finder/concurrent/partitionable.rb +2 -0
- data/lib/contrek/finder/concurrent/polyline.rb +2 -0
- data/lib/contrek/finder/concurrent/poolable.rb +2 -0
- data/lib/contrek/finder/concurrent/position.rb +2 -0
- data/lib/contrek/finder/concurrent/queueable.rb +2 -0
- data/lib/contrek/finder/concurrent/sequence.rb +2 -0
- data/lib/contrek/finder/concurrent/shape.rb +2 -0
- data/lib/contrek/finder/concurrent/streaming_merger.rb +89 -0
- data/lib/contrek/finder/concurrent/tile.rb +2 -0
- data/lib/contrek/finder/concurrent/vertical_merger.rb +4 -2
- data/lib/contrek/finder/list.rb +2 -0
- data/lib/contrek/finder/list_entry.rb +2 -0
- data/lib/contrek/finder/listable.rb +2 -0
- data/lib/contrek/finder/lists.rb +2 -0
- data/lib/contrek/finder/node.rb +2 -0
- data/lib/contrek/finder/node_cluster.rb +3 -1
- data/lib/contrek/finder/polygon_finder.rb +2 -0
- data/lib/contrek/finder/result.rb +2 -0
- data/lib/contrek/map/mercator_projection.rb +2 -0
- data/lib/contrek/matchers/matcher.rb +2 -0
- data/lib/contrek/matchers/matcher_hsb.rb +2 -0
- data/lib/contrek/matchers/value_not_matcher.rb +2 -0
- data/lib/contrek/reducers/linear_reducer.rb +2 -0
- data/lib/contrek/reducers/reducer.rb +2 -0
- data/lib/contrek/reducers/uniq_reducer.rb +2 -0
- data/lib/contrek/reducers/visvalingam_reducer.rb +2 -0
- data/lib/contrek/shared/result.rb +2 -0
- data/lib/contrek/version.rb +3 -1
- data/lib/contrek.rb +5 -0
- metadata +11 -5
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Contrek
|
|
4
|
+
module Concurrent
|
|
5
|
+
class StreamingMerger < VerticalMerger
|
|
6
|
+
def initialize(stream_to:, total_width:, total_height:, options: {})
|
|
7
|
+
@stream = stream_to
|
|
8
|
+
@total_width = total_width
|
|
9
|
+
@total_height = total_height
|
|
10
|
+
@moved = 0
|
|
11
|
+
super(options: options)
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def add_tile(result, flush = false)
|
|
15
|
+
super(result)
|
|
16
|
+
|
|
17
|
+
if @tiles.size == 2
|
|
18
|
+
process_tiles!(nil, height: @height)
|
|
19
|
+
@tiles << @whole_tile
|
|
20
|
+
stream_polygons!(@whole_tile, flush)
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def process_info
|
|
25
|
+
result = super
|
|
26
|
+
result.metadata[:groups] = @moved
|
|
27
|
+
result
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
private
|
|
31
|
+
|
|
32
|
+
def stream_polygons!(tile, flush = false)
|
|
33
|
+
ensure_header
|
|
34
|
+
|
|
35
|
+
tile.shapes.select! do |shape|
|
|
36
|
+
bounds = shape.outer_polyline.get_bounds
|
|
37
|
+
if flush || bounds[:max_x] < tile.end_x - 1
|
|
38
|
+
@moved += 1
|
|
39
|
+
stream_raw_polygon(shape)
|
|
40
|
+
false
|
|
41
|
+
else
|
|
42
|
+
true
|
|
43
|
+
end
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
ensure_footer if flush
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
def stream_raw_polygon(shape)
|
|
50
|
+
outer_pts = shape.outer_polyline.raw.map { |p| "#{p[:y]},#{p[:x]}" }.join(" ")
|
|
51
|
+
@stream.write(svg_outer_polygon(outer_pts))
|
|
52
|
+
shape.inner_polylines.map(&:raw).each do |sequence|
|
|
53
|
+
inner_pts = sequence.map { |p| "#{p[:y]},#{p[:x]}" }.join(" ")
|
|
54
|
+
@stream.write(svg_inner_polygon(inner_pts))
|
|
55
|
+
end
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
def ensure_header
|
|
59
|
+
if @stream.pos == 0
|
|
60
|
+
@stream.write(svg_header)
|
|
61
|
+
end
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
def ensure_footer
|
|
65
|
+
@stream.write(svg_footer)
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
def svg_footer
|
|
69
|
+
"</svg>"
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
def svg_header
|
|
73
|
+
"<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"#{@total_width}\" height=\"#{@total_height}\"><style>#{svg_css}</style>"
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
def svg_outer_polygon(outer_pts)
|
|
77
|
+
"<polygon points=\"#{outer_pts}\" class=\"out\"/>"
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
def svg_inner_polygon(inner_pts)
|
|
81
|
+
"<polygon points=\"#{inner_pts}\" class=\"in\"/>"
|
|
82
|
+
end
|
|
83
|
+
|
|
84
|
+
def svg_css
|
|
85
|
+
".out{fill:none;stroke:red;stroke-width:1;}.in{fill:none;stroke:green;stroke-width:1;}.out:hover{stroke:yellow;}"
|
|
86
|
+
end
|
|
87
|
+
end
|
|
88
|
+
end
|
|
89
|
+
end
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
module Contrek
|
|
2
4
|
module Concurrent
|
|
3
5
|
class VerticalMerger < Merger
|
|
@@ -10,8 +12,8 @@ module Contrek
|
|
|
10
12
|
super
|
|
11
13
|
end
|
|
12
14
|
|
|
13
|
-
def process_info
|
|
14
|
-
transpose(super)
|
|
15
|
+
def process_info(flush: false)
|
|
16
|
+
transpose(super())
|
|
15
17
|
end
|
|
16
18
|
|
|
17
19
|
private
|
data/lib/contrek/finder/list.rb
CHANGED
data/lib/contrek/finder/lists.rb
CHANGED
data/lib/contrek/finder/node.rb
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
module Contrek
|
|
2
4
|
module Finder
|
|
3
5
|
class NodeCluster
|
|
@@ -286,7 +288,7 @@ module Contrek
|
|
|
286
288
|
@root_nodes << node
|
|
287
289
|
|
|
288
290
|
if node.y > 0
|
|
289
|
-
# all nodes
|
|
291
|
+
# all nodes until up_node.max_x >= node.min_x
|
|
290
292
|
up_nodes = @vert_nodes[node.y - 1]
|
|
291
293
|
up_nodes_count = up_nodes.size
|
|
292
294
|
if up_nodes_count > 0
|
data/lib/contrek/version.rb
CHANGED
data/lib/contrek.rb
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
require "contrek/version"
|
|
2
4
|
require "contrek/bitmaps/painting"
|
|
3
5
|
require "contrek/bitmaps/bitmap"
|
|
@@ -37,6 +39,7 @@ require "contrek/finder/concurrent/finder"
|
|
|
37
39
|
require "contrek/finder/concurrent/merger"
|
|
38
40
|
require "contrek/finder/concurrent/horizontal_merger"
|
|
39
41
|
require "contrek/finder/concurrent/vertical_merger"
|
|
42
|
+
require "contrek/finder/concurrent/streaming_merger"
|
|
40
43
|
require "contrek/finder/concurrent/cursor"
|
|
41
44
|
require "contrek/map/mercator_projection"
|
|
42
45
|
require "contrek/matchers/matcher"
|
|
@@ -51,6 +54,8 @@ require "contrek/cpp/cpp_concurrent_finder"
|
|
|
51
54
|
require "contrek/cpp/cpp_concurrent_merger"
|
|
52
55
|
require "contrek/cpp/cpp_concurrent_horizontal_merger"
|
|
53
56
|
require "contrek/cpp/cpp_concurrent_vertical_merger"
|
|
57
|
+
require "contrek/cpp/cpp_concurrent_streaming_merger"
|
|
58
|
+
require "contrek/cpp/cpp_tempfile"
|
|
54
59
|
require "contrek/cpp/cpp_result"
|
|
55
60
|
|
|
56
61
|
module Contrek
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: contrek
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.2.
|
|
4
|
+
version: 1.2.9
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Emanuele Cesaroni
|
|
8
|
-
autorequire:
|
|
8
|
+
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2026-06-
|
|
11
|
+
date: 2026-06-13 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: rspec
|
|
@@ -132,6 +132,7 @@ extra_rdoc_files: []
|
|
|
132
132
|
files:
|
|
133
133
|
- ".gitignore"
|
|
134
134
|
- ".rspec"
|
|
135
|
+
- ".rubocop.yml"
|
|
135
136
|
- CHANGELOG.md
|
|
136
137
|
- Gemfile
|
|
137
138
|
- Gemfile.lock
|
|
@@ -215,6 +216,8 @@ files:
|
|
|
215
216
|
- ext/cpp_polygon_finder/PolygonFinder/src/polygon/finder/concurrent/Shape.h
|
|
216
217
|
- ext/cpp_polygon_finder/PolygonFinder/src/polygon/finder/concurrent/ShapePool.cpp
|
|
217
218
|
- ext/cpp_polygon_finder/PolygonFinder/src/polygon/finder/concurrent/ShapePool.h
|
|
219
|
+
- ext/cpp_polygon_finder/PolygonFinder/src/polygon/finder/concurrent/StreamingMerger.cpp
|
|
220
|
+
- ext/cpp_polygon_finder/PolygonFinder/src/polygon/finder/concurrent/StreamingMerger.h
|
|
218
221
|
- ext/cpp_polygon_finder/PolygonFinder/src/polygon/finder/concurrent/Tile.cpp
|
|
219
222
|
- ext/cpp_polygon_finder/PolygonFinder/src/polygon/finder/concurrent/Tile.h
|
|
220
223
|
- ext/cpp_polygon_finder/PolygonFinder/src/polygon/finder/concurrent/VerticalMerger.cpp
|
|
@@ -251,8 +254,10 @@ files:
|
|
|
251
254
|
- lib/contrek/cpp/cpp_concurrent_finder.rb
|
|
252
255
|
- lib/contrek/cpp/cpp_concurrent_horizontal_merger.rb
|
|
253
256
|
- lib/contrek/cpp/cpp_concurrent_merger.rb
|
|
257
|
+
- lib/contrek/cpp/cpp_concurrent_streaming_merger.rb
|
|
254
258
|
- lib/contrek/cpp/cpp_concurrent_vertical_merger.rb
|
|
255
259
|
- lib/contrek/cpp/cpp_result.rb
|
|
260
|
+
- lib/contrek/cpp/cpp_tempfile.rb
|
|
256
261
|
- lib/contrek/finder/bounds.rb
|
|
257
262
|
- lib/contrek/finder/concurrent/clipped_polygon_finder.rb
|
|
258
263
|
- lib/contrek/finder/concurrent/cluster.rb
|
|
@@ -273,6 +278,7 @@ files:
|
|
|
273
278
|
- lib/contrek/finder/concurrent/queueable.rb
|
|
274
279
|
- lib/contrek/finder/concurrent/sequence.rb
|
|
275
280
|
- lib/contrek/finder/concurrent/shape.rb
|
|
281
|
+
- lib/contrek/finder/concurrent/streaming_merger.rb
|
|
276
282
|
- lib/contrek/finder/concurrent/tile.rb
|
|
277
283
|
- lib/contrek/finder/concurrent/vertical_merger.rb
|
|
278
284
|
- lib/contrek/finder/list.rb
|
|
@@ -301,7 +307,7 @@ metadata:
|
|
|
301
307
|
homepage_uri: https://github.com/runout77/contrek
|
|
302
308
|
documentation_uri: https://github.com/runout77/contrek#readme
|
|
303
309
|
changelog_uri: https://github.com/runout77/contrek/blob/main/CHANGELOG.md
|
|
304
|
-
post_install_message:
|
|
310
|
+
post_install_message:
|
|
305
311
|
rdoc_options: []
|
|
306
312
|
require_paths:
|
|
307
313
|
- lib
|
|
@@ -317,7 +323,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
317
323
|
version: '0'
|
|
318
324
|
requirements: []
|
|
319
325
|
rubygems_version: 3.5.22
|
|
320
|
-
signing_key:
|
|
326
|
+
signing_key:
|
|
321
327
|
specification_version: 4
|
|
322
328
|
summary: Fast PNG contour tracing and shape detection for Ruby
|
|
323
329
|
test_files: []
|