mirror of
https://github.com/Freika/dawarich.git
synced 2026-01-11 09:41:40 -05:00
Fix missing hexagons
This commit is contained in:
parent
c756346569
commit
339ba3130e
3 changed files with 7 additions and 5 deletions
|
|
@ -58,7 +58,7 @@ class Stat < ApplicationRecord
|
||||||
|
|
||||||
def hexagons_available?
|
def hexagons_available?
|
||||||
h3_hex_ids.present? &&
|
h3_hex_ids.present? &&
|
||||||
h3_hex_ids.is_a?(Hash) &&
|
(h3_hex_ids.is_a?(Hash) || h3_hex_ids.is_a?(Array)) &&
|
||||||
h3_hex_ids.any?
|
h3_hex_ids.any?
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,7 @@ module Maps
|
||||||
def pre_calculated_centers_available?
|
def pre_calculated_centers_available?
|
||||||
return false if stat&.h3_hex_ids.blank?
|
return false if stat&.h3_hex_ids.blank?
|
||||||
|
|
||||||
stat.h3_hex_ids.is_a?(Hash) && stat.h3_hex_ids.any?
|
stat.h3_hex_ids.is_a?(Array) && stat.h3_hex_ids.any?
|
||||||
end
|
end
|
||||||
|
|
||||||
def build_response_from_centers
|
def build_response_from_centers
|
||||||
|
|
@ -45,8 +45,10 @@ module Maps
|
||||||
|
|
||||||
def build_hexagons_from_h3_ids(hex_ids)
|
def build_hexagons_from_h3_ids(hex_ids)
|
||||||
# Convert stored H3 IDs back to hexagon polygons
|
# Convert stored H3 IDs back to hexagon polygons
|
||||||
hexagon_features = hex_ids.map.with_index do |(h3_index, data), index|
|
# Array format: [[h3_index, point_count, earliest, latest], ...]
|
||||||
build_hexagon_feature_from_h3(h3_index, data, index)
|
hexagon_features = hex_ids.map.with_index do |row, index|
|
||||||
|
h3_index, count, earliest, latest = row
|
||||||
|
build_hexagon_feature_from_h3(h3_index, [count, earliest, latest], index)
|
||||||
end
|
end
|
||||||
|
|
||||||
build_feature_collection(hexagon_features)
|
build_feature_collection(hexagon_features)
|
||||||
|
|
|
||||||
|
|
@ -120,4 +120,4 @@ RSpec.describe Stats::HexagonCalculator do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue