Fixed a bug where points from Immich and Photoprism did not have lonlat attribute set. #1318

This commit is contained in:
Eugene Burmakin 2025-06-08 16:41:01 +02:00
parent 8f4c10240e
commit 3426f2d66b
8 changed files with 35 additions and 15 deletions

View file

@ -1 +1 @@
0.27.4
0.27.5

View file

@ -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. ⚠️

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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
}
]