mirror of
https://github.com/Freika/dawarich.git
synced 2026-01-11 09:41:40 -05:00
Fix missing var
This commit is contained in:
parent
689b8cb0f1
commit
2b1f6d66bc
1 changed files with 4 additions and 19 deletions
|
|
@ -33,12 +33,8 @@ module LocationSearch
|
||||||
end
|
end
|
||||||
|
|
||||||
def normalize_geocoding_results(results)
|
def normalize_geocoding_results(results)
|
||||||
normalized_results = []
|
normalized_results = results.map do |result|
|
||||||
|
{
|
||||||
results.each do |result|
|
|
||||||
next unless valid_result?(result)
|
|
||||||
|
|
||||||
normalized_result = {
|
|
||||||
lat: result.latitude.to_f,
|
lat: result.latitude.to_f,
|
||||||
lon: result.longitude.to_f,
|
lon: result.longitude.to_f,
|
||||||
name: result.address&.split(',')&.first || 'Unknown location',
|
name: result.address&.split(',')&.first || 'Unknown location',
|
||||||
|
|
@ -50,22 +46,11 @@ module LocationSearch
|
||||||
importance: result.data&.dig('importance')
|
importance: result.data&.dig('importance')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
normalized_results << normalized_result
|
|
||||||
end
|
end
|
||||||
|
|
||||||
deduplicate_results(normalized_results)
|
deduplicate_results(normalized_results)
|
||||||
end
|
end
|
||||||
|
|
||||||
def valid_result?(result)
|
|
||||||
result.present? &&
|
|
||||||
result.latitude.present? &&
|
|
||||||
result.longitude.present? &&
|
|
||||||
result.latitude.to_f.abs <= 90 &&
|
|
||||||
result.longitude.to_f.abs <= 180
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
def deduplicate_results(results)
|
def deduplicate_results(results)
|
||||||
deduplicated = []
|
deduplicated = []
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue