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

@@ -46,7 +46,7 @@ v-row.mb-4
:items="addressList" :items="addressList"
:hint="$t('event.address_description' + (settings.allow_geolocation && '_osm'))") :hint="$t('event.address_description' + (settings.allow_geolocation && '_osm'))")
template(v-slot:message="{message, key}") template(v-slot:message="{message, key}")
span(v-html='message' :key="key") span(v-html='message' :key="key")
template(v-slot:item="{ item, attrs, on }") template(v-slot:item="{ item, attrs, on }")
v-list-item(v-bind='attrs' v-on='on') v-list-item(v-bind='attrs' v-on='on')
v-icon.pr-4(v-text='loadCoordinatesResultIcon(item)') v-icon.pr-4(v-text='loadCoordinatesResultIcon(item)')
@@ -76,7 +76,7 @@ export default {
props: { props: {
value: { type: Object, default: () => ({}) } value: { type: Object, default: () => ({}) }
}, },
data () { data ( {$store} ) {
return { return {
mdiMap, mdiMapMarker, mdiPlus, mdiMapSearch, mdiLatitude, mdiLongitude, mdiRoadVariant, mdiHome, mdiCityVariant, mdiMap, mdiMapMarker, mdiPlus, mdiMapSearch, mdiLatitude, mdiLongitude, mdiRoadVariant, mdiHome, mdiCityVariant,
place: { }, place: { },
@@ -91,7 +91,14 @@ export default {
node: mdiMapMarker, node: mdiMapMarker,
relation: mdiCityVariant, relation: mdiCityVariant,
}, },
nominatim_class: ['amenity', 'shop', 'tourism', 'leisure', 'building'] nominatim_class: ['amenity', 'shop', 'tourism', 'leisure', 'building'],
photon_osm_key: ['amenity', 'shop', 'tourism', 'leisure', 'building'],
photon_osm_type: {
'W': mdiRoadVariant,
'N': mdiMapMarker,
'R': mdiCityVariant,
},
geocoding_provider_type: $store.state.settings.geocoding_provider_type || 'Nominatim'
} }
}, },
computed: { computed: {
@@ -126,10 +133,17 @@ export default {
} }
}, 100), }, 100),
loadCoordinatesResultIcon(item) { loadCoordinatesResultIcon(item) {
if ( this.nominatim_class.includes(item.class)) { if (this.geocoding_provider_type == "Nominatim") {
return this.mdiHome if ( this.nominatim_class.includes(item.class)) {
return this.mdiHome
}
return this.nominatim_osm_type[item.type]
} else if (this.geocoding_provider_type == "Photon") {
if ( this.photon_osm_key.includes(item.class)) {
return this.mdiHome
}
return this.photon_osm_type[item.type]
} }
return this.nominatim_osm_type[item.type]
}, },
selectPlace (p) { selectPlace (p) {
if (!p) { return } if (!p) { return }
@@ -220,22 +234,55 @@ export default {
if (searchCoordinates.length) { if (searchCoordinates.length) {
this.loading = true this.loading = true
const ret = await this.$axios.$get(`placeNominatim/${searchCoordinates}`) const ret = await this.$axios.$get(`placeOSM/${this.geocoding_provider_type}/${searchCoordinates}`)
if (ret && ret.length) { if (this.geocoding_provider_type == "Nominatim") {
this.addressList = ret.map(v => { if (ret && ret.length) {
const name = get(v.namedetails, 'alt_name', get(v.namedetails, 'name')) this.addressList = ret.map(v => {
const address = v.display_name ? v.display_name.replace(name, '').replace(/^, ?/, '') : '' const name = get(v.namedetails, 'alt_name', get(v.namedetails, 'name'))
return { const address = v.display_name ? v.display_name.replace(name, '').replace(/^, ?/, '') : ''
class: v.class, return {
type: v.osm_type, class: v.class,
lat: v.lat, type: v.osm_type,
lon: v.lon, lat: v.lat,
name, lon: v.lon,
address name,
} address
}) }
} else { })
this.addressList = [] } else {
this.addressList = []
}
} else if (this.geocoding_provider_type == "Photon") {
let photon_properties = ['housenumber', 'street', 'district', 'city', 'county', 'state', 'postcode', 'country']
if (ret) {
this.addressList = ret.features.map(v => {
let pre_name = v.properties.name || v.properties.street || ''
let pre_address = ''
photon_properties.forEach((item, i) => {
let last = i == (photon_properties.length - 1)
if (v.properties[item] && !last) {
pre_address += v.properties[item]+', '
} else if (v.properties[item]) {
pre_address += v.properties[item]
}
});
let name = pre_name
let address = pre_address
return {
class: v.properties.osm_key,
type: v.properties.osm_type,
lat: v.geometry.coordinates[1],
lon: v.geometry.coordinates[0],
name,
address
}
})
} else {
this.addressList = []
}
} }
this.loading = false this.loading = false
} }

View File

@@ -1,9 +1,17 @@
<template lang="pug"> <template lang="pug">
v-card v-card
v-card-title Geolocation settings v-card-title Geolocation and Map settings
v-card-text v-card-text
p.mb-8(v-html="$t('admin.geolocation_description')") p.mb-6(v-html="$t('admin.geolocation_description')")
v-form(v-model='isValid')
v-form
v-autocomplete.mb-4(v-model='geocoding_provider_type'
@blur="save('geocoding_provider_type', geocoding_provider_type )"
:label="$t('admin.geocoding_provider_type')"
:hint="$t('admin.geocoding_provider_type_help')"
persistent-hint
:items="geocoding_provider_type_items"
:placeholder="geocoding_provider_type_default")
v-text-field.mb-4(v-model='geocoding_provider' v-text-field.mb-4(v-model='geocoding_provider'
@blur="save('geocoding_provider', geocoding_provider )" @blur="save('geocoding_provider', geocoding_provider )"
@@ -12,11 +20,11 @@ v-card
persistent-hint persistent-hint
:placeholder="geocoding_provider_default") :placeholder="geocoding_provider_default")
v-autocomplete.mb-4(v-model='geocoding_countrycodes' v-autocomplete.mb-6(v-model="geocoding_countrycodes" :disabled="geocoding_provider_type != null || geocoding_provider_type != 'Nominatim'"
@blur="save('geocoding_countrycodes', geocoding_countrycodes )" @blur="save('geocoding_countrycodes', geocoding_countrycodes )"
:label="$t('admin.geocoding_countrycodes')" :label="$t('admin.geocoding_countrycodes')"
chips multiple persistent-hint :items="countries"
:items='countries' multiple chips small-chips persistent-hint
item-value="code" item-value="code"
item-text="name" item-text="name"
:hint="$t('admin.geocoding_countrycodes_help')") :hint="$t('admin.geocoding_countrycodes_help')")
@@ -31,15 +39,14 @@ v-card
v-text-field(v-model='tilelayer_provider_attribution' v-text-field(v-model='tilelayer_provider_attribution'
@blur="save('tilelayer_provider_attribution', tilelayer_provider_attribution )" @blur="save('tilelayer_provider_attribution', tilelayer_provider_attribution )"
:label="$t('admin.tilelayer_provider_attribution')" :label="$t('admin.tilelayer_provider_attribution')"
placeholder="map data © OpenStreetMap contributors under ODbL") :placeholder="tilelayer_provider_attribution_default")
clientOnly div(id="leaflet-map-preview" max-height='10px')
div.h-8.w-8(id="leaflet-map")
v-card-actions v-card-actions
v-spacer v-spacer
v-btn(color='primary' @click='testGeocodingProvider' :loading='testGeocodingLoading' outlined) {{$t('admin.geocoding_test_button')}} v-btn(color='primary' @click='testGeocodingProvider' :loading='testGeocodingLoading' outlined ) {{$t('admin.geocoding_test_button')}}
v-btn(color='primary' @click='testTileLayerProvider' :loading='testTileLayerLoading' outlined :disabled="false" ) {{$t('admin.tilelayer_test_button')}} v-btn(color='primary' @click='testTileLayerProvider' :loading='testTileLayerLoading' outlined ) {{$t('admin.tilelayer_test_button')}}
v-btn(color='warning' @click="done" outlined) {{$t("common.ok")}} v-btn(color='warning' @click="done" outlined) {{$t("common.ok")}}
</template> </template>
@@ -49,20 +56,26 @@ import { isoCountries } from '../../server/helpers/geolocation'
import "leaflet/dist/leaflet.css" import "leaflet/dist/leaflet.css"
export default { export default {
props: {
setup: { type: Boolean, default: false }
},
data ({ $store }) { data ({ $store }) {
return { return {
isValid: false,
loading: false, loading: false,
testGeocodingLoading: false, testGeocodingLoading: false,
testTileLayerLoading: false, testTileLayerLoading: false,
geocoding_provider_type_items: ['Nominatim', 'Photon'],
geocoding_provider_type: $store.state.settings.geocoding_provider_type || '',
geocoding_provider_type_default: 'Nominatim',
geocoding_provider: $store.state.settings.geocoding_provider || '', geocoding_provider: $store.state.settings.geocoding_provider || '',
geocoding_provider_default: "https://nominatim.openstreetmap.org/" , geocoding_provider_default: "https://nominatim.openstreetmap.org/search" ,
geocoding_countrycodes: $store.state.settings.geocoding_countrycodes || [], geocoding_countrycodes: $store.state.settings.geocoding_countrycodes || [],
tilelayer_provider: $store.state.settings.tilelayer_provider || '', tilelayer_provider: $store.state.settings.tilelayer_provider || '',
tilelayer_provider_default: 'https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png',
tilelayer_provider_attribution: $store.state.settings.tilelayer_provider_attribution || '', tilelayer_provider_attribution: $store.state.settings.tilelayer_provider_attribution || '',
tilelayer_provider_default: "https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png", tilelayer_provider_attribution_default: '<a target=\'_blank\' href=\"http://osm.org/copyright\">OpenStreetMap</a> contributors',
countries: isoCountries, countries: isoCountries,
mapTest: {}, mapPreviewTest: null,
} }
}, },
created() { created() {
@@ -70,69 +83,49 @@ export default {
const L = require('leaflet') const L = require('leaflet')
} }
}, },
computed: { computed: mapState(['settings', 'events']),
...mapState(['settings', 'events']),
},
methods: { methods: {
...mapActions(['setSetting']), ...mapActions(['setSetting']),
async testGeocodingProvider () { async testGeocodingProvider () {
this.testGeocodingLoading = true this.testGeocodingLoading = true
const geocodingProviderTest = this.geocoding_provider || this.geocoding_provider_default
const geocodingSoftwareTest = this.geocoding_provider_type || this.geocoding_provider_type_default
const geocodingQuery = 'building'
try { try {
const geolocation = await this.$axios.$get(`${this.geocoding_provider}search`, {timeout: 3000, params: {format: 'json', q: 'building', limit: 1}}) if (geocodingSoftwareTest === 'Nominatim') {
this.$root.$message(this.$t('admin.geocoding_test_success', { service_name: this.geocoding_provider }), { color: 'success' }) const geolocation = await this.$axios.$get(`${geocodingProviderTest}`, {timeout: 3000, params: {q: `${geocodingQuery}`, format: 'json', limit: 1 }} )
} else if (geocodingSoftwareTest === 'Photon') {
const geolocation = await this.$axios.$get(`${geocodingProviderTest}`, {timeout: 3000, params: {q: `${geocodingQuery}`, limit: 1}} )
}
this.$root.$message(this.$t('admin.geocoding_test_success', { service_name: geocodingProviderTest }), { color: 'success' })
} catch (e) { } catch (e) {
// console.error(e) this.$root.$message(this.$t('admin.tilelayer_test_error', { service_name: geocodingProviderTest }), { color: 'error' })
this.$root.$message(e, { color: 'error' })
} }
this.testGeocodingLoading = false this.testGeocodingLoading = false
}, },
async testTileLayerProvider () { async testTileLayerProvider () {
this.testTileLayerLoading = true this.testTileLayerLoading = true
try { const tileThis = this
// clean const tileLayerTest = this.tilelayer_provider || this.tilelayer_provider_default
// if (this.mapTest !== null) { const tileLayerAttributionTest = this.tilelayer_provider_attribution || this.tilelayer_provider_attribution_default
// this.mapTest.off();
// this.mapTest.remove();
// }
// init tilelayer
this.mapTest = L.map("leaflet-map").setView([40,40],10);
this.tileLayer = L.tileLayer(`${this.tilelayer_provider}`, {attribution: `${this.tilelayer_provider_attribution}`})
const tileLayer = await this.tileLayer.addTo(this.mapTest)
// init tilelayer
this.tileLayer.on('loading', function (event) { if (this.mapPreviewTest == null) {
console.log(event) this.mapPreviewTest = L.map("leaflet-map-preview").setView([40,40],10);
// this.mapTest.fireEvent('dataloading', event);
});
// this.tileLayer.on('load', function (event) {
// // this.mapTest.fireEvent('dataload', event);
// });
// this.tileLayer.on('tileerror', function(error, tile) {
// console.log(error);
// console.log(tile);
// });
//
// this.tileLayer.on('tileabort', this.tileLayer.remove())
//
this.mapTest.off()
this.mapTest.remove()
// mapTest.on('dataload', handler)
// function handler(event) {
// if (mapTest && mapTest.remove) {
// mapTest.off();
// mapTest.remove();
// }
// }
} catch (e) {
console.error(e)
this.$root.$message(e.response && e.response.data, { color: 'error' })
} }
this.tileLayer = L.tileLayer(`${tileLayerTest}`, {attribution: `${tileLayerAttributionTest}`})
this.tileLayer.addTo(this.mapPreviewTest)
// tilelayer events inherited from gridlayer https://leafletjs.com/reference.html#gridlayer
this.tileLayer.on('tileload', function (event) {
tileThis.tileLayerTestSucess(event, tileLayerTest)
});
this.tileLayer.on('tileerror', function(error, tile) {
tileThis.tileLayerTestError(event, tileLayerTest)
tileThis.tileLayer = null
});
this.testTileLayerLoading = false this.testTileLayerLoading = false
}, },
save (key, value) { save (key, value) {
@@ -143,15 +136,22 @@ export default {
done () { done () {
this.$emit('close') this.$emit('close')
}, },
handlerLoad(event) { geocodingTestError(event, tileLayerTest) {
// this.mapTest.fireEvent('dataload', (event) => { this.$root.$message(this.$t('admin.geocoding_test_error', { service_name: geocodingTest }), { color: 'error' })
this.$root.$message(this.$t('admin.tilelayer_test_success', { service_name: this.tilelayer_provider }), { color: 'success' }) },
if (this.mapTest !== null) { tileLayerTestSucess(event, tileLayerTest) {
this.mapTest.off(); this.$root.$message(this.$t('admin.tilelayer_test_success', { service_name: tileLayerTest }), { color: 'success' })
this.mapTest.remove(); },
} tileLayerTestError(event, tileLayerTest) {
this.$root.$message(this.$t('admin.tilelayer_test_error', { service_name: tileLayerTest }), { color: 'error' })
} }
} }
} }
</script> </script>
<style>
#leaflet-map-preview {
height: 6rem;
}
</style>

View File

@@ -84,7 +84,8 @@ export default {
{ value: 'address', text: this.$t('common.address') }, { value: 'address', text: this.$t('common.address') },
{ value: 'map', text: 'Map' }, { value: 'map', text: 'Map' },
{ value: 'actions', text: this.$t('common.actions'), align: 'right' } { value: 'actions', text: this.$t('common.actions'), align: 'right' }
] ],
geocoding_provider_type: $store.state.settings.geocoding_provider_type || 'Nominatim'
} }
}, },
async fetch() { async fetch() {
@@ -124,7 +125,7 @@ export default {
this.place.latitude = this.place.longitude = null this.place.latitude = this.place.longitude = null
} }
this.$emit('input', { ...this.place }) this.$emit('input', { ...this.place })
}, },
searchAddress: debounce(async function(ev) { searchAddress: debounce(async function(ev) {
const pre_searchCoordinates = ev.target.value.trim().toLowerCase() const pre_searchCoordinates = ev.target.value.trim().toLowerCase()
// allow pasting coordinates lat/lon and lat,lon // allow pasting coordinates lat/lon and lat,lon
@@ -159,7 +160,7 @@ export default {
if (searchCoordinates.length) { if (searchCoordinates.length) {
this.loading = true this.loading = true
const ret = await this.$axios.$get(`placeNominatim/${searchCoordinates}`) const ret = await this.$axios.$get(`placeOSM/${this.geocoding_provider_type}/${searchCoordinates}`)
if (ret && ret.length) { if (ret && ret.length) {
this.addressList = ret.map(v => { this.addressList = ret.map(v => {
const name = get(v.namedetails, 'alt_name', get(v.namedetails, 'name')) const name = get(v.namedetails, 'alt_name', get(v.namedetails, 'name'))
@@ -176,7 +177,7 @@ export default {
} }
this.loading = false this.loading = false
} }
}, 300) }, 300)
} }
} }
</script> </script>

View File

@@ -54,20 +54,19 @@ v-container
v-dialog(v-model='showSMTP' destroy-on-close max-width='700px' :fullscreen='$vuetify.breakpoint.xsOnly') v-dialog(v-model='showSMTP' destroy-on-close max-width='700px' :fullscreen='$vuetify.breakpoint.xsOnly')
SMTP(@close='showSMTP = false') SMTP(@close='showSMTP = false')
v-card-actions v-card-actions
v-btn(text @click='showSMTP=true') v-btn(text @click='showSMTP=true')
<v-icon v-if='!settings.admin_email' color='error' class="mr-2" v-text='mdiAlert'></v-icon> {{$t('admin.show_smtp_setup')}} <v-icon v-if='!settings.admin_email' color='error' class="mr-2" v-text='mdiAlert'></v-icon> {{$t('admin.show_smtp_setup')}}
v-btn(text @click='$emit("complete")' color='primary' v-if='setup') {{$t('common.next')}}
v-icon(v-text='mdiArrowRight')
v-dialog(v-model='showGeolocationConfigs' destroy-on-close max-width='700px' :fullscreen='$vuetify.breakpoint.xsOnly') v-dialog(v-model='showGeolocationConfigs' destroy-on-close max-width='700px' :fullscreen='$vuetify.breakpoint.xsOnly')
Geolocation(@close='showGeolocationConfigs = false') Geolocation(setup, @close='showGeolocationConfigs = false')
v-card-actions v-card-actions
v-btn(text @click='showGeolocationConfigs=true') v-btn(text @click='showGeolocationConfigs=true')
<v-icon v-if='!settings.admin_email' color='primary' class="mr-2" v-text='mdiMap'></v-icon> {{$t('admin.show_geolocation_setup')}} <v-icon v-if='!settings.admin_email' color='primary' class="mr-2" v-text='mdiMap'></v-icon> {{$t('admin.show_geolocation_setup')}}
v-btn(text @click='$emit("complete")' color='primary' v-if='setup') {{$t('common.next')}}
v-icon(v-text='mdiArrowRight')
</template> </template>
<script> <script>
import SMTP from './SMTP.vue' import SMTP from './SMTP.vue'

View File

@@ -270,18 +270,23 @@
"known_users": "Known users", "known_users": "Known users",
"created_at": "Created at", "created_at": "Created at",
"show_geolocation_setup": "Geolocation and map settings", "show_geolocation_setup": "Geolocation and map settings",
"geolocation_description": "<b>Define a provider for geocoding service</b>. Currently, among those listed in the <a href=\"https://wiki.openstreetmap.org/wiki/Nominatim#Alternatives_.2F_Third-party_providers\">wiki of OpenStreetMap</a>, there is support for software <b>Nominatim</b> and <b>Photon</b>.<br>You can use one of the related official demos by copying the link in the 'Geocoding provider' field:<ul><li>https://nominatim.openstreetmap.org/ <a href=\"https://operations.osmfoundation.org/policies/nominatim/\"> [TermsofService]</a></li><li>https://photon.komoot.io/api/ <a href=\"https://photon.komoot.io/\"> [TermsofService]</a></li></ul><b>Define a provider for map layers.</b><br>You can find a list of them here: <a href=\"https://leaflet-extras.github.io/leaflet-providers/preview/\">https://leaflet-extras.github.io/leaflet-providers/preview/</a>", "geolocation_description": "<b>1. Define a provider for geocoding service</b>.<br>Currently, among those listed in the <a href=\"https://wiki.openstreetmap.org/wiki/Nominatim#Alternatives_.2F_Third-party_providers\">wiki of OpenStreetMap</a>, there is support for software <a href=\"https://github.com/osm-search/Nominatim\">Nominatim</a> and <a href=\"https://github.com/komoot/photon\">Photon</a>.<br>You can use one of the related official demos by copying the link in the 'Geocoding provider' field:<ul><li>https://nominatim.openstreetmap.org/ <a href=\"https://operations.osmfoundation.org/policies/nominatim/\"> [Terms of Service]</a></li><li>https://photon.komoot.io/api/ <a href=\"https://photon.komoot.io/\"> [Terms of Service]</a></li></ul><br><b>2. Define a provider for map layers.</b><br>You can find a list of them here: <a href=\"https://leaflet-extras.github.io/leaflet-providers/preview/\">https://leaflet-extras.github.io/leaflet-providers/preview/</a>",
"geocoding_provider_type": "Geocoding software",
"geocoding_provider_type_help": "The default software is Nominatim",
"geocoding_provider": "Geocoding provider", "geocoding_provider": "Geocoding provider",
"geocoding_provider_help": "The default provider is Nominatim", "geocoding_provider_help": "The default provider is Nominatim",
"geocoding_countrycodes": "Country codes", "geocoding_countrycodes": "Country codes",
"geocoding_countrycodes_help": "Allows you to set a filter to searches based on area codes", "geocoding_countrycodes_help": "Allows you to set a filter to searches based on area codes",
"geocoding_test_button": "Test geocoding", "geocoding_test_button": "Test geocoding",
"geocoding_test_success": "The service {service_name} is available", "geocoding_test_success": "The service {service_name} is available",
"geocoding_test_success": "The geocoding service at {service_name} is working",
"geocoding_test_error": "The geocoding service is not reachable at {service_name}",
"tilelayer_provider": "Tilelayer provider", "tilelayer_provider": "Tilelayer provider",
"tilelayer_provider_help": "The default provider is OpenStreetMap", "tilelayer_provider_help": "The default provider is OpenStreetMap",
"tilelayer_provider_attribution": "Attribution", "tilelayer_provider_attribution": "Attribution",
"tilelayer_test_button": "Test tilelayer", "tilelayer_test_button": "Test tilelayer",
"tilelayer_test_success": "The service {service_name} is available" "tilelayer_test_success": "The tilelayer service at {service_name} is working",
"tilelayer_test_error": "The tilelayer service is not reachable at {service_name}"
}, },
"auth": { "auth": {
"not_confirmed": "Not confirmed yet…", "not_confirmed": "Not confirmed yet…",

View File

@@ -259,18 +259,22 @@
"hide_calendar": "Nascondi calendario", "hide_calendar": "Nascondi calendario",
"default_images": "Immagini preimpostate", "default_images": "Immagini preimpostate",
"show_geolocation_setup": "Impostazioni geolocalizzazione e mappa", "show_geolocation_setup": "Impostazioni geolocalizzazione e mappa",
"geolocation_description": "<b>Definisci un fornitore per il servizio di georeferenziazione (geocodifica)</b>. Al momento, tra quelli elencati nella <a href=\"https://wiki.openstreetmap.org/wiki/Nominatim#Alternatives_.2F_Third-party_providers\">wiki di OpenStreetMap</a>, è presente il supporto per i software <b>Nominatim</b> e <b>Photon</b>.<br>Puoi utilizzare una delle relative demo ufficiali copiandone il link nel campo 'Fornitore georeferenziazione':<ul><li>https://nominatim.openstreetmap.org/ <a href=\"https://operations.osmfoundation.org/policies/nominatim/\"> [TermsofService]</a></li><li>https://photon.komoot.io/api/ <a href=\"https://photon.komoot.io/\"> [TermsofService]</a></li></ul><b>Definisci un fornitore di layers per la mappa.</b><br>Qui puoi trovarne una lista: <a href=\"https://leaflet-extras.github.io/leaflet-providers/preview/\">https://leaflet-extras.github.io/leaflet-providers/preview/</a>", "geolocation_description": "<b>1. Definisci un fornitore per il servizio di georeferenziazione (geocodifica)</b>.<br>Al momento, tra quelli elencati nella <a href=\"https://wiki.openstreetmap.org/wiki/Nominatim#Alternatives_.2F_Third-party_providers\">wiki di OpenStreetMap</a>, è presente il supporto per i software <a href=\"https://github.com/osm-search/Nominatim\">Nominatim</a> e <a href=\"https://github.com/komoot/photon\">Photon</a>.<br>Puoi utilizzare una delle relative demo ufficiali copiandone il link nel campo 'Fornitore georeferenziazione':<ul><li>https://nominatim.openstreetmap.org/ <a href=\"https://operations.osmfoundation.org/policies/nominatim/\"> [Terms of Service]</a></li><li>https://photon.komoot.io/api/ <a href=\"https://photon.komoot.io/\"> [Terms of Service]</a></li></ul><br><b>2. Definisci un fornitore di layers per la mappa.</b><br>Qui puoi trovarne una lista: <a href=\"https://leaflet-extras.github.io/leaflet-providers/preview/\">https://leaflet-extras.github.io/leaflet-providers/preview/</a>",
"geocoding_provider_type": "Software fornitore georeferenziazione",
"geocoding_provider_type_help": "Il software di default è Nominatim",
"geocoding_provider": "Fornitore georeferenziazione", "geocoding_provider": "Fornitore georeferenziazione",
"geocoding_provider_help": "Il fornitore di default è Nominatim", "geocoding_provider_help": "Il fornitore di default è Nominatim",
"geocoding_countrycodes": "Codici territoriali", "geocoding_countrycodes": "Codici territoriali",
"geocoding_countrycodes_help": "Permette di impostare un filtro alle ricerche basato su codici territori nazionali", "geocoding_countrycodes_help": "Permette di impostare un filtro alle ricerche basato su codici territori nazionali",
"geocoding_test_button": "Test geocoding", "geocoding_test_button": "Test geocoding",
"geocoding_test_success": "Il servizio {service_name} è raggiungibile", "geocoding_test_success": "Il servizio di geocoding all'indirizzo {service_name} sta funzionando",
"geocoding_test_error": "Il servizio non è raggiungibile all'indirizzo: {service_name}",
"tilelayer_provider": "Fornitore tilelayer", "tilelayer_provider": "Fornitore tilelayer",
"tilelayer_provider_help": "Il fornitore di default è OpenStreetMap", "tilelayer_provider_help": "Il fornitore di default è OpenStreetMap",
"tilelayer_provider_attribution": "Attribuzione", "tilelayer_provider_attribution": "Attribuzione",
"tilelayer_test_button": "Test tilelayer", "tilelayer_test_button": "Test tilelayer",
"tilelayer_test_success": "Il servizio {service_name} è raggiungibile" "tilelayer_test_success": "Il servizio di tilelayer all'indirizzo {service_name} sta funzionando",
"tilelayer_test_error": "Il servizio non è raggiungibile all'indirizzo: {service_name}"
}, },
"auth": { "auth": {
"not_confirmed": "Non ancora confermato…", "not_confirmed": "Non ancora confermato…",

View File

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

View File

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

View File

@@ -165,7 +165,8 @@ if (config.status !== 'READY') {
api.get('/place/all', isAdmin, placeController.getAll) api.get('/place/all', isAdmin, placeController.getAll)
api.get('/place/:placeName', cors, placeController.getEvents) api.get('/place/:placeName', cors, placeController.getEvents)
api.get('/place', cors, placeController.search) api.get('/place', cors, placeController.search)
api.get('/placeNominatim/:place_details', cors, placeController._nominatim) api.get('/placeOSM/Nominatim/:place_details', cors, placeController._nominatim)
api.get('/placeOSM/Photon/:place_details', cors, placeController._photon)
api.put('/place', isAdmin, placeController.updatePlace) api.put('/place', isAdmin, placeController.updatePlace)
api.get('/tag', cors, tagController.search) api.get('/tag', cors, tagController.search)

View File

@@ -92,6 +92,7 @@ module.exports = {
hide_thumbs: settings.hide_thumbs, hide_thumbs: settings.hide_thumbs,
hide_calendar: settings.hide_calendar, hide_calendar: settings.hide_calendar,
allow_geolocation: settings.allow_geolocation, allow_geolocation: settings.allow_geolocation,
geocoding_provider_type: settings.geocoding_provider_type,
geocoding_provider: settings.geocoding_provider, geocoding_provider: settings.geocoding_provider,
geocoding_countrycodes: settings.geocoding_countrycodes, geocoding_countrycodes: settings.geocoding_countrycodes,
tilelayer_provider: settings.tilelayer_provider, tilelayer_provider: settings.tilelayer_provider,

View File

@@ -9,6 +9,7 @@ export const state = () => ({
allow_recurrent_event: true, allow_recurrent_event: true,
recurrent_event_visible: false, recurrent_event_visible: false,
allow_geolocation: false, allow_geolocation: false,
geocoding_provider_type: '',
geocoding_provider: '', geocoding_provider: '',
geocoding_countrycodes: [], geocoding_countrycodes: [],
tilelayer_provider: '', tilelayer_provider: '',