From f39b75af5bee168d33652443c271e330726dd4e1 Mon Sep 17 00:00:00 2001 From: Sylvain Briat Date: Thu, 4 Jan 2024 15:37:15 +0100 Subject: [PATCH 1/2] add geocoder configuration --- .env.dist | 20 +++++++++++++++++ src/config/geography.config.ts | 40 ++++++++++++++++++++++++++++++++++ 2 files changed, 60 insertions(+) diff --git a/.env.dist b/.env.dist index 785a04f..fd3cfe2 100644 --- a/.env.dist +++ b/.env.dist @@ -56,6 +56,26 @@ MAX_DETOUR_DURATION_RATIO=0.3 GEOROUTER_TYPE=graphhopper GEOROUTER_URL=http://localhost:8989 +# GEOCODER +# default language +GEOCODER_LANG=fr +# minimal score to consider a result as valid +GEOCODEr_MIN_CONFIDENCE=0.5 +# max number of results per provider (input results) +GEOCODER_MAX_RESULTS_PER_PROVIDER=5 +# max number of results per address type (output results) +GEOCODER_MAX_RESULTS_PER_TYPE=5 +# sanitize results ? +GEOCODER_SANITIZE=true +# consolidate results ? +GEOCODER_CONSOLIDATE=true +# max distance in km between 2 points to consider a duplicate +GEOCODER_PROXIMITY=5 +# population vs distance prioritizer coef +# "boost" population weight for results with a short distance +# => multiply the population by COEF / distance (in km) +GEOCODDER_POPULATION_PRIORITIZER_COEF=100 + # PAGINATION # number of results per page PER_PAGE=10 diff --git a/src/config/geography.config.ts b/src/config/geography.config.ts index d36cada..564a599 100644 --- a/src/config/geography.config.ts +++ b/src/config/geography.config.ts @@ -4,9 +4,49 @@ import { Config } from './config'; export interface GeographyConfig extends Config { georouterType: string; georouterUrl: string; + geocoderLang: string; + geocoderMinConfidence: number; + geocoderMaxResultsPerProvider: number; + geocoderMaxResultsPerType: number; + geocoderSanitize: boolean; + geocoderConsolidate: boolean; + geocoderProximity: number; + geocoderPopulationPrioritizerCoef: number; + geocoderProviders: string[]; + geocoderProvidersFallback: string[]; } export default registerAs('geography', () => ({ georouterType: process.env.GEOROUTER_TYPE ?? 'graphhopper', georouterUrl: process.env.GEOROUTER_URL ?? 'http://localhost:8989', + geocoderLang: process.env.GEOCODER_LANG ?? 'fr', + geocoderMinConfidence: process.env.GEOCODER_MIN_CONFIDENCE + ? parseFloat(process.env.GEOCODER_MIN_CONFIDENCE) + : 0.5, + geocoderMaxResultsPerProvider: process.env.GEOCODER_MAX_RESULTS_PER_PROVIDER + ? parseInt(process.env.GEOCODER_MAX_RESULTS_PER_PROVIDER) + : 5, + geocoderMaxResultsPerType: process.env.GEOCODER_MAX_RESULTS_PER_TYPE + ? parseInt(process.env.GEOCODER_MAX_RESULTS_PER_TYPE) + : 5, + geocoderSanitize: process.env.GEOCODER_SANITIZE + ? process.env.GEOCODER_SANITIZE === 'false' + ? false + : true + : true, + geocoderConsolidate: process.env.GEOCODER_CONSOLIDATE + ? process.env.GEOCODER_CONSOLIDATE === 'false' + ? false + : true + : true, + geocoderProximity: process.env.GEOCODER_PROXIMITY + ? parseInt(process.env.GEOCODER_PROXIMITY) + : 5, + geocoderPopulationPrioritizerCoef: process.env + .GEOCODER_POPULATION_PRIORITIZER_COEF + ? parseInt(process.env.GEOCODER_POPULATION_PRIORITIZER_COEF) + : 100, + geocoderProviders: + process.env.GEOCODER_PROVIDERS ?? 'ADDOK,PELIAS_SEARCH,PELIAS_AUTOCOMPLETE', + geocoderProvidersFallback: process.env.GEOCODER_PROVIDERS_FALLBACK ?? 'GMAPS', })); From 05a992ce7c48f81deba75d39fd76394226b96960 Mon Sep 17 00:00:00 2001 From: Sylvain Briat Date: Thu, 4 Jan 2024 15:38:46 +0100 Subject: [PATCH 2/2] 2.6.0 --- package-lock.json | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/package-lock.json b/package-lock.json index 3d7828a..4244518 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@mobicoop/configuration", - "version": "2.5.3", + "version": "2.6.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@mobicoop/configuration", - "version": "2.5.3", + "version": "2.6.0", "license": "AGPL", "dependencies": { "@grpc/grpc-js": "^1.9.9", diff --git a/package.json b/package.json index c5a9f12..6e58496 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@mobicoop/configuration", - "version": "2.5.3", + "version": "2.6.0", "description": "Mobicoop V3 Configuration Service", "author": "sbriat", "private": true,