Add osm_id, osm_key, osm_value, osm_type to places

This commit is contained in:
Eugene Burmakin 2025-03-08 19:40:28 +01:00
parent d78482f1bf
commit 43c7e64efb
3 changed files with 20 additions and 3 deletions

View file

@ -31,4 +31,20 @@ class Place < ApplicationRecord
def reverse_geocoded?
geodata.present?
end
def osm_id
geodata['properties']['osm_id']
end
def osm_key
geodata['properties']['osm_key']
end
def osm_value
geodata['properties']['osm_value']
end
def osm_type
geodata['properties']['osm_type']
end
end

View file

@ -5,7 +5,7 @@ module Visits
class Detector
MINIMUM_VISIT_DURATION = 3.minutes
MAXIMUM_VISIT_GAP = 30.minutes
MINIMUM_POINTS_FOR_VISIT = 3
MINIMUM_POINTS_FOR_VISIT = 2
attr_reader :points
@ -57,7 +57,8 @@ module Visits
# Calculate distance from visit center
distance = Geocoder::Calculations.distance_between(
[visit[:center_lat], visit[:center_lon]],
[point.lat, point.lon]
[point.lat, point.lon],
units: :km
)
# Dynamically adjust radius based on visit duration

View file

@ -38,7 +38,7 @@ module Visits
{
main_place: main_place,
suggested_places: all_suggested_places.uniq { |place| place.name }
suggested_places: all_suggested_places.uniq(&:name)
}
end