mirror of
https://github.com/immich-app/immich.git
synced 2025-03-01 15:11:21 +01:00
* fix(server): Does not assign lat/lon if they are at 0,0 #2991 * Adds migration file to fix null island rows * Removed down migration * Leave empty down function
This commit is contained in:
parent
079aa13edb
commit
f1b8a7ab54
4 changed files with 44 additions and 4 deletions
|
@ -0,0 +1,13 @@
|
||||||
|
import { MigrationInterface, QueryRunner } from "typeorm"
|
||||||
|
|
||||||
|
export class FixGPSNullIsland1692057328660 implements MigrationInterface {
|
||||||
|
|
||||||
|
public async up(queryRunner: QueryRunner): Promise<void> {
|
||||||
|
await queryRunner.query(`UPDATE "exif" SET latitude = NULL, longitude = NULL WHERE latitude = 0 AND longitude = 0;`);
|
||||||
|
}
|
||||||
|
|
||||||
|
public async down(): Promise<void> {
|
||||||
|
// Setting lat,lon to 0 not necessary
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -308,8 +308,16 @@ export class MetadataExtractionProcessor {
|
||||||
|
|
||||||
const latitude = getExifProperty('GPSLatitude');
|
const latitude = getExifProperty('GPSLatitude');
|
||||||
const longitude = getExifProperty('GPSLongitude');
|
const longitude = getExifProperty('GPSLongitude');
|
||||||
newExif.latitude = latitude !== null ? parseLatitude(latitude) : null;
|
const lat = parseLatitude(latitude);
|
||||||
newExif.longitude = longitude !== null ? parseLongitude(longitude) : null;
|
const lon = parseLongitude(longitude);
|
||||||
|
|
||||||
|
if (lat === 0 && lon === 0) {
|
||||||
|
this.logger.warn(`Latitude & Longitude were on Null Island (${lat},${lon}), not assigning coordinates`);
|
||||||
|
} else {
|
||||||
|
newExif.latitude = lat;
|
||||||
|
newExif.longitude = lon;
|
||||||
|
}
|
||||||
|
|
||||||
if (getExifProperty('MotionPhoto')) {
|
if (getExifProperty('MotionPhoto')) {
|
||||||
// Seen on more recent Pixel phones: starting as early as Pixel 4a, possibly earlier.
|
// Seen on more recent Pixel phones: starting as early as Pixel 4a, possibly earlier.
|
||||||
const rawDirectory = getExifProperty('Directory');
|
const rawDirectory = getExifProperty('Directory');
|
||||||
|
|
|
@ -23,6 +23,12 @@ describe('parsing latitude from string input', () => {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('parsing latitude from null input', () => {
|
||||||
|
it('returns null for null input', () => {
|
||||||
|
expect(parseLatitude(null)).toBeNull();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
describe('parsing longitude from string input', () => {
|
describe('parsing longitude from string input', () => {
|
||||||
it('returns null for invalid inputs', () => {
|
it('returns null for invalid inputs', () => {
|
||||||
expect(parseLongitude('')).toBeNull();
|
expect(parseLongitude('')).toBeNull();
|
||||||
|
@ -44,3 +50,9 @@ describe('parsing longitude from string input', () => {
|
||||||
expect(parseLongitude('-0.0')).toBeCloseTo(-0.0);
|
expect(parseLongitude('-0.0')).toBeCloseTo(-0.0);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('parsing longitude from null input', () => {
|
||||||
|
it('returns null for null input', () => {
|
||||||
|
expect(parseLongitude(null)).toBeNull();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
|
@ -1,6 +1,9 @@
|
||||||
import { isNumberInRange } from '../numbers';
|
import { isNumberInRange } from '../numbers';
|
||||||
|
|
||||||
export function parseLatitude(input: string | number): number | null {
|
export function parseLatitude(input: string | number | null): number | null {
|
||||||
|
if (input === null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
const latitude = typeof input === 'string' ? Number.parseFloat(input) : input;
|
const latitude = typeof input === 'string' ? Number.parseFloat(input) : input;
|
||||||
|
|
||||||
if (isNumberInRange(latitude, -90, 90)) {
|
if (isNumberInRange(latitude, -90, 90)) {
|
||||||
|
@ -9,7 +12,11 @@ export function parseLatitude(input: string | number): number | null {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function parseLongitude(input: string | number): number | null {
|
export function parseLongitude(input: string | number | null): number | null {
|
||||||
|
if (input === null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
const longitude = typeof input === 'string' ? Number.parseFloat(input) : input;
|
const longitude = typeof input === 'string' ? Number.parseFloat(input) : input;
|
||||||
|
|
||||||
if (isNumberInRange(longitude, -180, 180)) {
|
if (isNumberInRange(longitude, -180, 180)) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue