mirror of
				https://github.com/immich-app/immich.git
				synced 2025-10-31 10:37:11 -04:00 
			
		
		
		
	fix: read longitude and latitude when reverse geocoding is off (#17558)
This commit is contained in:
		
							parent
							
								
									7562088fac
								
							
						
					
					
						commit
						8b00578c7b
					
				| @ -263,6 +263,35 @@ describe(MetadataService.name, () => { | |||||||
|       }); |       }); | ||||||
|     }); |     }); | ||||||
| 
 | 
 | ||||||
|  |     it('should not delete latituide and longitude without reverse geocode', async () => { | ||||||
|  |       // regression test for issue 17511
 | ||||||
|  |       mocks.asset.getByIds.mockResolvedValue([assetStub.withLocation]); | ||||||
|  |       mocks.systemMetadata.get.mockResolvedValue({ reverseGeocoding: { enabled: false } }); | ||||||
|  |       mocks.storage.stat.mockResolvedValue({ | ||||||
|  |         size: 123_456, | ||||||
|  |         mtime: assetStub.withLocation.fileModifiedAt, | ||||||
|  |         mtimeMs: assetStub.withLocation.fileModifiedAt.valueOf(), | ||||||
|  |         birthtimeMs: assetStub.withLocation.fileCreatedAt.valueOf(), | ||||||
|  |       } as Stats); | ||||||
|  |       mockReadTags({ | ||||||
|  |         GPSLatitude: assetStub.withLocation.exifInfo!.latitude!, | ||||||
|  |         GPSLongitude: assetStub.withLocation.exifInfo!.longitude!, | ||||||
|  |       }); | ||||||
|  | 
 | ||||||
|  |       await sut.handleMetadataExtraction({ id: assetStub.image.id }); | ||||||
|  |       expect(mocks.asset.getByIds).toHaveBeenCalledWith([assetStub.image.id], { faces: { person: false } }); | ||||||
|  |       expect(mocks.asset.upsertExif).toHaveBeenCalledWith( | ||||||
|  |         expect.objectContaining({ city: null, state: null, country: null }), | ||||||
|  |       ); | ||||||
|  |       expect(mocks.asset.update).toHaveBeenCalledWith({ | ||||||
|  |         id: assetStub.withLocation.id, | ||||||
|  |         duration: null, | ||||||
|  |         fileCreatedAt: assetStub.withLocation.fileCreatedAt, | ||||||
|  |         fileModifiedAt: assetStub.withLocation.fileModifiedAt, | ||||||
|  |         localDateTime: new Date('2023-02-22T05:06:29.716Z'), | ||||||
|  |       }); | ||||||
|  |     }); | ||||||
|  | 
 | ||||||
|     it('should apply reverse geocoding', async () => { |     it('should apply reverse geocoding', async () => { | ||||||
|       mocks.asset.getByIds.mockResolvedValue([assetStub.withLocation]); |       mocks.asset.getByIds.mockResolvedValue([assetStub.withLocation]); | ||||||
|       mocks.systemMetadata.get.mockResolvedValue({ reverseGeocoding: { enabled: true } }); |       mocks.systemMetadata.get.mockResolvedValue({ reverseGeocoding: { enabled: true } }); | ||||||
|  | |||||||
| @ -200,15 +200,15 @@ export class MetadataService extends BaseService { | |||||||
|     const dates = this.getDates(asset, exifTags, stats); |     const dates = this.getDates(asset, exifTags, stats); | ||||||
| 
 | 
 | ||||||
|     const { width, height } = this.getImageDimensions(exifTags); |     const { width, height } = this.getImageDimensions(exifTags); | ||||||
|     let geo: ReverseGeocodeResult, latitude: number | null, longitude: number | null; |     let geo: ReverseGeocodeResult = { country: null, state: null, city: null }, | ||||||
|     if (reverseGeocoding.enabled && this.hasGeo(exifTags)) { |       latitude: number | null = null, | ||||||
|  |       longitude: number | null = null; | ||||||
|  |     if (this.hasGeo(exifTags)) { | ||||||
|       latitude = exifTags.GPSLatitude; |       latitude = exifTags.GPSLatitude; | ||||||
|       longitude = exifTags.GPSLongitude; |       longitude = exifTags.GPSLongitude; | ||||||
|  |       if (reverseGeocoding.enabled) { | ||||||
|         geo = await this.mapRepository.reverseGeocode({ latitude, longitude }); |         geo = await this.mapRepository.reverseGeocode({ latitude, longitude }); | ||||||
|     } else { |       } | ||||||
|       latitude = null; |  | ||||||
|       longitude = null; |  | ||||||
|       geo = { country: null, state: null, city: null }; |  | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     const exifData: Insertable<Exif> = { |     const exifData: Insertable<Exif> = { | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user