Class: SlippyTilesScorer::Cluster
- Inherits:
-
Object
- Object
- SlippyTilesScorer::Cluster
- Defined in:
- lib/slippy_tiles_scorer/cluster.rb
Overview
finds clusters in a collection/tiles_x_y of points (x, y)
Instance Attribute Summary collapse
-
#tiles_x_y ⇒ Object
Returns the value of attribute tiles_x_y.
Instance Method Summary collapse
-
#clusters ⇒ Hash
The clusters and the tiles in the clusters.
-
#initialize(tiles_x_y: Set.new) ⇒ Cluster
constructor
A new instance of Cluster.
Constructor Details
#initialize(tiles_x_y: Set.new) ⇒ Cluster
Returns a new instance of Cluster.
10 11 12 13 14 15 |
# File 'lib/slippy_tiles_scorer/cluster.rb', line 10 def initialize(tiles_x_y: Set.new) @tiles_x_y = tiles_x_y @cluster_tiles = Set.new @visited = {} @clusters = [] end |
Instance Attribute Details
#tiles_x_y ⇒ Object
Returns the value of attribute tiles_x_y.
8 9 10 |
# File 'lib/slippy_tiles_scorer/cluster.rb', line 8 def tiles_x_y @tiles_x_y end |
Instance Method Details
#clusters ⇒ Hash
Returns The clusters and the tiles in the clusters.
18 19 20 21 22 23 24 25 26 |
# File 'lib/slippy_tiles_scorer/cluster.rb', line 18 def clusters @tiles_x_y.each do |i| next if visited?(i[0], i[1]) visit!(i[0], i[1]) find_cluster_around(i) end { clusters: @clusters, cluster_tiles: @cluster_tiles } end |