diff --git a/.app_version b/.app_version index 9f222923..69bf493e 100644 --- a/.app_version +++ b/.app_version @@ -1 +1 @@ -0.27.4 +0.27.5 diff --git a/CHANGELOG.md b/CHANGELOG.md index 28337146..edfc06f1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,13 @@ 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.27.5 - 2025-06-08 + +## Fixed + +- Fixed a bug where points from Immich and Photoprism did not have lonlat attribute set. #1318 + + # 0.27.4 - 2025-06-06 ⚠️ This release includes a breaking change. ⚠️ diff --git a/app/services/immich/import_geodata.rb b/app/services/immich/import_geodata.rb index 770a8087..9f9679ee 100644 --- a/app/services/immich/import_geodata.rb +++ b/app/services/immich/import_geodata.rb @@ -53,9 +53,10 @@ class Immich::ImportGeodata def extract_geodata(asset) { - latitude: asset.dig('exifInfo', 'latitude'), - longitude: asset.dig('exifInfo', 'longitude'), - timestamp: Time.zone.parse(asset.dig('exifInfo', 'dateTimeOriginal')).to_i + latitude: asset['exifInfo']['latitude'], + longitude: asset['exifInfo']['longitude'], + lonlat: "SRID=4326;POINT(#{asset['exifInfo']['longitude']} #{asset['exifInfo']['latitude']})", + timestamp: Time.zone.parse(asset['exifInfo']['dateTimeOriginal']).to_i } end diff --git a/app/services/imports/create.rb b/app/services/imports/create.rb index f25d3e56..b7d6bc0d 100644 --- a/app/services/imports/create.rb +++ b/app/services/imports/create.rb @@ -9,7 +9,7 @@ class Imports::Create end def call - parser(import.source).new(import, user.id).call + importer(import.source).new(import, user.id).call schedule_stats_creating(user.id) schedule_visit_suggesting(user.id, import) @@ -20,8 +20,7 @@ class Imports::Create private - def parser(source) - # Bad classes naming by the way, they are not parsers, they are point creators + def importer(source) case source when 'google_semantic_history' then GoogleMaps::SemanticHistoryImporter when 'google_phone_takeout' then GoogleMaps::PhoneTakeoutImporter diff --git a/app/services/photoprism/import_geodata.rb b/app/services/photoprism/import_geodata.rb index 2d0e7a68..c31946c1 100644 --- a/app/services/photoprism/import_geodata.rb +++ b/app/services/photoprism/import_geodata.rb @@ -65,6 +65,7 @@ class Photoprism::ImportGeodata { latitude: asset['Lat'], longitude: asset['Lng'], + lonlat: "SRID=4326;POINT(#{asset['Lng']} #{asset['Lat']})", timestamp: Time.zone.parse(asset['TakenAt']).to_i } end diff --git a/app/services/photos/importer.rb b/app/services/photos/importer.rb index bd39b579..f3ce8fc4 100644 --- a/app/services/photos/importer.rb +++ b/app/services/photos/importer.rb @@ -18,17 +18,25 @@ class Photos::Importer end def create_point(point, index) - return 0 if point['latitude'].blank? || point['longitude'].blank? || point['timestamp'].blank? + return 0 unless valid?(point) return 0 if point_exists?(point, point['timestamp']) Point.create( - lonlat: "POINT(#{point['longitude']} #{point['latitude']})", - timestamp: point['timestamp'], - raw_data: point, - import_id: import.id, + lonlat: point['lonlat'], + longitude: point['longitude'], + latitude: point['latitude'], + timestamp: point['timestamp'].to_i, + raw_data: point, + import_id: import.id, user_id: ) broadcast_import_progress(import, index) end + + def valid?(point) + point['latitude'].present? && + point['longitude'].present? && + point['timestamp'].present? + end end diff --git a/config/initializers/geocoder.rb b/config/initializers/geocoder.rb index adbf4c52..05dff3e1 100644 --- a/config/initializers/geocoder.rb +++ b/config/initializers/geocoder.rb @@ -5,8 +5,9 @@ settings = { units: :km, cache: Geocoder::CacheStore::Generic.new(Rails.cache, {}), always_raise: :all, - use_https: PHOTON_API_USE_HTTPS, - http_headers: { 'User-Agent' => "Dawarich #{APP_VERSION} (https://dawarich.app)" }, + http_headers: { + 'User-Agent' => "Dawarich #{APP_VERSION} (https://dawarich.app)" + }, cache_options: { expiration: 1.day } @@ -14,7 +15,8 @@ settings = { if PHOTON_API_HOST.present? settings[:lookup] = :photon - settings[:photon] = { use_https: PHOTON_API_USE_HTTPS, host: PHOTON_API_HOST } + settings[:use_https] = PHOTON_API_USE_HTTPS + settings[:photon] = { host: PHOTON_API_HOST } settings[:http_headers] = { 'X-Api-Key' => PHOTON_API_KEY } if PHOTON_API_KEY.present? elsif GEOAPIFY_API_KEY.present? settings[:lookup] = :geoapify diff --git a/spec/fixtures/files/immich/geodata.json b/spec/fixtures/files/immich/geodata.json index 73330a4f..793aa59d 100644 --- a/spec/fixtures/files/immich/geodata.json +++ b/spec/fixtures/files/immich/geodata.json @@ -2,11 +2,13 @@ { "latitude": 59.0000, "longitude": 30.0000, + "lonlat": "SRID=4326;POINT(30.0000 59.0000)", "timestamp": 978296400 }, { "latitude": 55.0001, "longitude": 37.0001, + "lonlat": "SRID=4326;POINT(37.0001 55.0001)", "timestamp": 978296400 } ]