1
0
Fork 0
mirror of https://github.com/immich-app/immich.git synced 2025-01-04 02:46:47 +01:00

Merge pull request #793 from immich-app/fix/update-reverse-geocoder

Update local-reverse-geocoder to 0.12.5
This commit is contained in:
Alex 2022-10-08 15:40:42 -05:00 committed by GitHub
commit 5fc82dfaa2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 31 additions and 21 deletions

View file

@ -39,20 +39,20 @@ function geocoderLookup(points: { latitude: number; longitude: number }[]) {
// eslint-disable-next-line @typescript-eslint/ban-ts-comment // eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore // @ts-ignore
geocoder.lookUp(points, 1, (err, addresses) => { geocoder.lookUp(points, 1, (err, addresses) => {
resolve(addresses[0][0]); resolve(addresses[0][0] as GeoData);
}); });
}); });
} }
const geocodingPrecisionLevels = ['cities15000', 'cities5000', 'cities1000', 'cities500']; const geocodingPrecisionLevels = ['cities15000', 'cities5000', 'cities1000', 'cities500'];
export interface AdminCode { export type AdminCode = {
name: string; name: string;
asciiName: string; asciiName: string;
geoNameId: string; geoNameId: string;
} };
export interface GeoData { export type GeoData = {
geoNameId: string; geoNameId: string;
name: string; name: string;
asciiName: string; asciiName: string;
@ -63,8 +63,8 @@ export interface GeoData {
featureCode: string; featureCode: string;
countryCode: string; countryCode: string;
cc2?: any; cc2?: any;
admin1Code?: AdminCode; admin1Code?: AdminCode | string;
admin2Code?: AdminCode; admin2Code?: AdminCode | string;
admin3Code?: any; admin3Code?: any;
admin4Code?: any; admin4Code?: any;
population: string; population: string;
@ -73,7 +73,7 @@ export interface GeoData {
timezone: string; timezone: string;
modificationDate: string; modificationDate: string;
distance: number; distance: number;
} };
@Processor(QueueNameEnum.METADATA_EXTRACTION) @Processor(QueueNameEnum.METADATA_EXTRACTION)
export class MetadataExtractionProcessor { export class MetadataExtractionProcessor {
@ -123,10 +123,22 @@ export class MetadataExtractionProcessor {
const city = geoCodeInfo.name; const city = geoCodeInfo.name;
let state = ''; let state = '';
if (geoCodeInfo.admin2Code?.name) state += geoCodeInfo.admin2Code.name;
if (geoCodeInfo.admin1Code?.name) { if (geoCodeInfo.admin2Code) {
if (geoCodeInfo.admin2Code?.name) state += ', '; const adminCode2 = geoCodeInfo.admin2Code as AdminCode;
state += geoCodeInfo.admin1Code.name; state += adminCode2.name;
}
if (geoCodeInfo.admin1Code) {
const adminCode1 = geoCodeInfo.admin1Code as AdminCode;
if (geoCodeInfo.admin2Code) {
const adminCode2 = geoCodeInfo.admin2Code as AdminCode;
if (adminCode2.name) {
state += ', ';
}
}
state += adminCode1.name;
} }
return { country, state, city }; return { country, state, city };

View file

@ -36,7 +36,7 @@
"geo-tz": "^7.0.2", "geo-tz": "^7.0.2",
"i18n-iso-countries": "^7.5.0", "i18n-iso-countries": "^7.5.0",
"joi": "^17.5.0", "joi": "^17.5.0",
"local-reverse-geocoder": "^0.12.2", "local-reverse-geocoder": "^0.12.5",
"lodash": "^4.17.21", "lodash": "^4.17.21",
"luxon": "^3.0.3", "luxon": "^3.0.3",
"passport": "^0.6.0", "passport": "^0.6.0",
@ -7661,12 +7661,11 @@
} }
}, },
"node_modules/local-reverse-geocoder": { "node_modules/local-reverse-geocoder": {
"version": "0.12.2", "version": "0.12.5",
"resolved": "https://registry.npmjs.org/local-reverse-geocoder/-/local-reverse-geocoder-0.12.2.tgz", "resolved": "https://registry.npmjs.org/local-reverse-geocoder/-/local-reverse-geocoder-0.12.5.tgz",
"integrity": "sha512-kTSvDxGTuJoqx619jmHFoGCqFpBi0PPwyd7PDOLZCyo8mMEwJSMx713+ksOCihGpzUfO3hcclE7z/T43sY/IaA==", "integrity": "sha512-FaH8+T29K9PQRiiqYlt+M9Qvq9GlSnWEnX0FTDXgPrNzQ9SWWYGEvO5uODwAD6sep9z19u/K/+Z3cw4AGVW97Q==",
"dependencies": { "dependencies": {
"async": "^3.2.4", "async": "^3.2.4",
"cors": "^2.8.5",
"csv-parse": "^5.3.0", "csv-parse": "^5.3.0",
"debug": "^4.3.4", "debug": "^4.3.4",
"kdt": "^0.1.0", "kdt": "^0.1.0",
@ -17109,12 +17108,11 @@
"dev": true "dev": true
}, },
"local-reverse-geocoder": { "local-reverse-geocoder": {
"version": "0.12.2", "version": "0.12.5",
"resolved": "https://registry.npmjs.org/local-reverse-geocoder/-/local-reverse-geocoder-0.12.2.tgz", "resolved": "https://registry.npmjs.org/local-reverse-geocoder/-/local-reverse-geocoder-0.12.5.tgz",
"integrity": "sha512-kTSvDxGTuJoqx619jmHFoGCqFpBi0PPwyd7PDOLZCyo8mMEwJSMx713+ksOCihGpzUfO3hcclE7z/T43sY/IaA==", "integrity": "sha512-FaH8+T29K9PQRiiqYlt+M9Qvq9GlSnWEnX0FTDXgPrNzQ9SWWYGEvO5uODwAD6sep9z19u/K/+Z3cw4AGVW97Q==",
"requires": { "requires": {
"async": "^3.2.4", "async": "^3.2.4",
"cors": "^2.8.5",
"csv-parse": "^5.3.0", "csv-parse": "^5.3.0",
"debug": "^4.3.4", "debug": "^4.3.4",
"kdt": "^0.1.0", "kdt": "^0.1.0",

View file

@ -55,7 +55,7 @@
"geo-tz": "^7.0.2", "geo-tz": "^7.0.2",
"i18n-iso-countries": "^7.5.0", "i18n-iso-countries": "^7.5.0",
"joi": "^17.5.0", "joi": "^17.5.0",
"local-reverse-geocoder": "^0.12.2", "local-reverse-geocoder": "^0.12.5",
"lodash": "^4.17.21", "lodash": "^4.17.21",
"luxon": "^3.0.3", "luxon": "^3.0.3",
"passport": "^0.6.0", "passport": "^0.6.0",