2023-01-21 01:18:16 +01:00
|
|
|
const cache = require('memory-cache')
|
|
|
|
const providerCache = new cache.Cache()
|
2023-01-19 12:06:23 +01:00
|
|
|
|
2023-01-21 01:18:16 +01:00
|
|
|
const nominatim = {
|
2023-01-19 12:06:23 +01:00
|
|
|
commonName: 'Nominatim',
|
|
|
|
DEFAULT_ENDPOINT: 'https://nominatim.openstreetmap.org/search',
|
|
|
|
endpoint: (req, res) => {
|
2023-01-21 01:18:16 +01:00
|
|
|
return res.locals.settings.geocoding_provider || nominatim.DEFAULT_ENDPOINT
|
2023-01-19 12:06:23 +01:00
|
|
|
},
|
2023-01-21 01:18:16 +01:00
|
|
|
cache: providerCache,
|
2023-01-19 12:06:23 +01:00
|
|
|
|
|
|
|
getParams (req, res) {
|
|
|
|
const countrycodes = res.locals.settings.geocoding_countrycodes || []
|
|
|
|
const details = req.params.place_details
|
|
|
|
|
|
|
|
return {
|
|
|
|
countrycodes: countrycodes.join(','),
|
|
|
|
q: details,
|
|
|
|
limit: 3,
|
|
|
|
format: 'json',
|
|
|
|
addressdetails: 1,
|
|
|
|
namedetails: 1,
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2023-01-21 01:18:16 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
module.exports = nominatim
|