Merge pull request #524 from Freika/fix/map-distance-calculation

Fix map and visits pages
This commit is contained in:
Evgenii Burmakin 2024-12-10 23:12:42 +01:00 committed by GitHub
commit c1955fe6c3
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 9 additions and 3 deletions

View file

@ -1 +1 @@
0.19.4
0.19.5

View file

@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/)
and this project adheres to [Semantic Versioning](http://semver.org/).
# 0.19.5 - 2024-12-10
### Fixed
- Fixed a bug where the map and visits pages were throwing an error due to incorrect approach to distance calculation.
# 0.19.4 - 2024-12-10
⚠️ This release introduces a breaking change. ⚠️

View file

@ -36,7 +36,7 @@ class MapController < ApplicationController
@distance ||= 0
@coordinates.each_cons(2) do
@distance += DistanceCalculator.new([_1[0], _1[1]], [_2[0], _2[1]]).call
@distance += Geocoder::Calculations.distance_between([_1[0], _1[1]], [_2[0], _2[1]])
end
@distance.round(1)

View file

@ -29,7 +29,7 @@ class Visit < ApplicationRecord
return area&.radius if area.present?
radius = points.map do |point|
DistanceCalculator.new(center, [point.latitude, point.longitude]).call
Geocoder::Calculations.distance_between(center, [point.latitude, point.longitude])
end.max
radius && radius >= 15 ? radius : 15