geocoding and tilelayer tests are working also on setup, add support for photon

This commit is contained in:
sedum
2022-12-06 00:03:53 +01:00
parent c096a616ba
commit f6ea3be746
11 changed files with 192 additions and 117 deletions

View File

@@ -6,6 +6,7 @@ const exportController = require('./export')
const log = require('../../log')
const { Op, where, col, fn, cast } = require('sequelize')
const NOMINATIM_URL = 'https://nominatim.openstreetmap.org/search'
const PHOTON_URL = 'https://photon.komoot.io/api/'
const axios = require('axios')
module.exports = {
@@ -76,15 +77,13 @@ module.exports = {
async _nominatim (req, res) {
const details = req.params.place_details
const countrycodes = res.locals.settings.geocoding_countrycodes
const geocoding_provider = res.locals.settings.geocoding_provider
const countrycodes = res.locals.settings.geocoding_countrycodes || ''
const geocoding_provider = res.locals.settings.geocoding_provider || NOMINATIM_URL
// ?limit=3&format=json&namedetails=1&addressdetails=1&q=
console.log(countrycodes)
console.log(geocoding_provider)
const ret = await axios.get(`${res.locals.settings.geocoding_provider}`, {
const ret = await axios.get(`${geocoding_provider}`, {
params: {
countrycodes: countrycodes || '',
countrycodes: countrycodes,
q: details,
limit: 3,
format: 'json',
@@ -93,9 +92,25 @@ module.exports = {
},
headers: { 'User-Agent': 'gancio 1.6.0' }
})
console.log(countrycodes)
console.log(ret)
// console.log(ret)
return res.json(ret.data)
},
async _photon (req, res) {
const details = req.params.place_details
const geocoding_provider = res.locals.settings.geocoding_provider || PHOTON_URL
const ret = await axios.get(`${geocoding_provider}`, {
params: {
q: details,
limit: 3,
},
headers: { 'User-Agent': 'gancio 1.6.0' }
})
// console.log(ret)
return res.json(ret.data)
},

View File

@@ -30,6 +30,7 @@ const defaultSettings = {
allow_recurrent_event: false,
recurrent_event_visible: false,
allow_geolocation: true,
geocoding_provider_type: 'Nominatim',
geocoding_provider: 'https://nominatim.openstreetmap.org/',
geocoding_countrycodes: [],
tilelayer_provider: 'https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png',