continue refactor of geocoding services, improved locale, fixes on mapEdit

This commit is contained in:
sedum 2023-02-20 07:05:21 +01:00
parent 7522e811fa
commit 8efeda085a
11 changed files with 117 additions and 1100 deletions

View file

@ -54,7 +54,9 @@ export default {
}); });
setTimeout(() => { setTimeout(() => {
this.$refs.map.mapObject.invalidateSize(); if (this.$refs.map && this.$refs.map.mapObject ) {
this.$refs.map.mapObject.invalidateSize();
}
}, 200); }, 200);
} }
} }

View file

@ -28,7 +28,7 @@ v-row.mb-4
v-combobox.mr-4(v-model="virtualLocations" v-if="settings.allow_event_only_online && value.name === 'online'" v-combobox.mr-4(v-model="virtualLocations" v-if="settings.allow_event_only_online && value.name === 'online'"
:prepend-icon='mdiLink' :prepend-icon='mdiLink'
:hint="$t('event.online_locations_help')" :hint="$t('event.online_locations_help')"
:label="$t('event.online_event_urls')" :label="$t('event.online_locations_url')"
clearable chips small-chips multiple deletable-chips hide-no-data hide-selected persistent-hint clearable chips small-chips multiple deletable-chips hide-no-data hide-selected persistent-hint
:delimiters="[',', ';', '; ']" :delimiters="[',', ';', '; ']"
:items="virtualLocations" :items="virtualLocations"
@ -55,7 +55,7 @@ v-row.mb-4
v-dialog(v-model='whereInputAdvancedDialog' :key="whereAdvancedId" destroy-on-close max-width='700px' :fullscreen='$vuetify.breakpoint.xsOnly' dense) v-dialog(v-model='whereInputAdvancedDialog' :key="whereAdvancedId" destroy-on-close max-width='700px' :fullscreen='$vuetify.breakpoint.xsOnly' dense)
WhereInputAdvanced(ref='whereAdvanced' :place.sync='value' :event='event' @close='whereInputAdvancedDialog = false && this.$refs.address.blur()' WhereInputAdvanced(ref='whereAdvanced' :place.sync='value' :event='event' @close='whereInputAdvancedDialog = false && this.$refs.address.blur()'
:virtualLocations.sync="virtualLocations" :virtualLocations.sync="virtualLocations"
:online_event_only_value.sync='online_event_only' :event_only_online_value.sync='event_only_online'
@update:onlineEvent="changeOnlineEvent" @update:onlineEvent="changeOnlineEvent"
@update:virtualLocations="selectLocations" @update:virtualLocations="selectLocations"
) )
@ -86,7 +86,7 @@ export default {
whereInputAdvancedDialog: false, whereInputAdvancedDialog: false,
hideWhereInputAdvancedDialogButton: !$store.state.settings.allow_event_also_online && !$store.state.settings.allow_geolocation, hideWhereInputAdvancedDialogButton: !$store.state.settings.allow_event_also_online && !$store.state.settings.allow_geolocation,
virtualLocations: this.event.locations || [], virtualLocations: this.event.locations || [],
online_event_only: (this.value.name === 'online') ? true : false, event_only_online: (this.value.name === 'online') ? true : false,
whereAdvancedId: 1 whereAdvancedId: 1
} }
}, },
@ -135,7 +135,7 @@ export default {
}, 200), }, 200),
selectPlace (p) { selectPlace (p) {
// force online events under place: online address: online // force online events under place: online address: online
this.online_event_only = false this.event_only_online = false
this.place.isNew = false this.place.isNew = false
this.whereAdvancedId++ this.whereAdvancedId++
@ -150,7 +150,7 @@ export default {
} }
this.place.id = p.id this.place.id = p.id
if (this.settings.allow_event_only_online && this.place.name === 'online') { if (this.settings.allow_event_only_online && this.place.name === 'online') {
this.online_event_only = true this.event_only_online = true
} }
this.disableAddress = true this.disableAddress = true
} else { // this is a new place } else { // this is a new place
@ -184,6 +184,10 @@ export default {
}, },
selectLocations () { selectLocations () {
this.event.locations = [] this.event.locations = []
// Insert up to 3 online location: the main one and 2 fallback
if (this.virtualLocations && this.virtualLocations.length > 3) {
this.$nextTick(() => this.virtualLocations.pop())
}
this.virtualLocations && this.virtualLocations.forEach((item, i) => { this.virtualLocations && this.virtualLocations.forEach((item, i) => {
if (!item.startsWith('http')) { if (!item.startsWith('http')) {
this.virtualLocations[i] = `https://${item}` this.virtualLocations[i] = `https://${item}`
@ -192,10 +196,10 @@ export default {
}) })
}, },
changeOnlineEvent(v) { changeOnlineEvent(v) {
this.online_event_only = v this.event_only_online = v
// console.log(this.online_event_only) // console.log(this.event_only_online)
if (this.online_event_only) { this.place.name = this.place.address = 'online' } if (this.event_only_online) { this.place.name = this.place.address = 'online' }
if (!this.online_event_only) { this.place.name = this.place.address = '' } if (!this.event_only_online) { this.place.name = this.place.address = '' }
this.place.latitude = null this.place.latitude = null
this.place.longitude = null this.place.longitude = null

View file

@ -4,11 +4,11 @@ v-card
v-card-subtitle {{ $t('event.where_advanced_options_description') }} v-card-subtitle {{ $t('event.where_advanced_options_description') }}
v-card-text(v-if='settings.allow_event_also_online') v-card-text(v-if='settings.allow_event_also_online')
v-switch.mt-0.mb-4(v-model='online_event_only_update' v-switch.mt-0.mb-4(v-model='event_only_online_update'
v-if='settings.allow_event_only_online' v-if='settings.allow_event_only_online'
persistent-hint persistent-hint
:label="$t('event.event_only_online_label')" :label="$t('event.event_only_online_label')"
:hint="$t('event.online_event_only_help')") :hint="$t('event.event_only_online_help')")
v-combobox.mt-0.mb-0.mr-4.my-5(v-model="virtualLocations_update" v-combobox.mt-0.mb-0.mr-4.my-5(v-model="virtualLocations_update"
v-if="place.name !== 'online' && settings.allow_event_also_online" v-if="place.name !== 'online' && settings.allow_event_also_online"
@ -69,19 +69,19 @@ v-card
</template> </template>
<script> <script>
import { mdiMap, mdiLatitude, mdiLongitude, mdiCog, mdiLink, mdiCloseCircle, mdiMapMarker, mdiMapSearch, mdiRoadVariant, mdiHome, mdiCityVariant } from '@mdi/js' import { mdiMap, mdiLatitude, mdiLongitude, mdiCog, mdiLink, mdiCloseCircle, mdiMapMarker,
mdiMapSearch, mdiRoadVariant, mdiHome, mdiCityVariant } from '@mdi/js'
import { mapState } from 'vuex' import { mapState } from 'vuex'
import debounce from 'lodash/debounce' import debounce from 'lodash/debounce'
import get from 'lodash/get' import get from 'lodash/get'
import nominatim from '../server/services/geocoding/nominatim' import geolocation from '../server/helpers/geolocation/index'
import photon from '../server/services/geocoding/photon'
export default { export default {
name: 'WhereInputAdvanced', name: 'WhereInputAdvanced',
props: { props: {
place: { type: Object, default: () => ({}) }, place: { type: Object, default: () => ({}) },
event: { type: Object, default: () => null }, event: { type: Object, default: () => null },
online_event_only_value: { type: Boolean, default: false }, event_only_online_value: { type: Boolean, default: false },
virtualLocations: { type: Array, default: [] } virtualLocations: { type: Array, default: [] }
}, },
components: { components: {
@ -93,33 +93,25 @@ export default {
mdiMapMarker, mdiMapSearch, mdiRoadVariant, mdiHome, mdiCityVariant, mdiMapMarker, mdiMapSearch, mdiRoadVariant, mdiHome, mdiCityVariant,
showOnline: $store.state.settings.allow_event_also_online, showOnline: $store.state.settings.allow_event_also_online,
showGeocoded: $store.state.settings.allow_geolocation && this.place.isNew, showGeocoded: $store.state.settings.allow_geolocation && this.place.isNew,
online_event_only: this.place.name === 'online', event_only_online: this.place.name === 'online',
mapEdit: 1, mapEdit: 1,
addressList: [], addressList: [],
loading: false, loading: false,
nominatim_osm_type: { iconsMapper: {
way: mdiRoadVariant, 'mdiHome': mdiHome,
house: mdiHome, 'mdiRoadVariant': mdiRoadVariant,
node: mdiMapMarker, 'mdiMapMarker': mdiMapMarker,
relation: mdiCityVariant, 'mdiCityVariant': mdiCityVariant
},
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', geocoding_provider_type: $store.state.settings.geocoding_provider_type || 'Nominatim',
nominatimProvider: nominatim, currentGeocodingProvider: geolocation.getGeocodingProvider($store.state.settings.geocoding_provider_type),
photonProvider: photon,
prevAddress: '' prevAddress: ''
} }
}, },
computed: { computed: {
...mapState(['settings']), ...mapState(['settings']),
online_event_only_update: { event_only_online_update: {
get () { return this.online_event_only_value }, get () { return this.event_only_online_value },
set (value) { set (value) {
this.$emit('update:onlineEvent', value) this.$emit('update:onlineEvent', value)
this.close() this.close()
@ -137,17 +129,8 @@ export default {
this.$emit('close') this.$emit('close')
}, },
loadCoordinatesResultIcon(item) { loadCoordinatesResultIcon(item) {
if (this.geocoding_provider_type == "Nominatim") { let icon = this.currentGeocodingProvider.loadResultIcon(item)
if ( this.nominatim_class.includes(item.class)) { return this.iconsMapper[icon]
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]
}
}, },
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()
@ -155,14 +138,7 @@ export default {
if (searchCoordinates.length) { if (searchCoordinates.length) {
this.loading = true this.loading = true
const ret = await this.$axios.$get(`placeOSM/${this.geocoding_provider_type}/${searchCoordinates}`) const ret = await this.$axios.$get(`placeOSM/${this.geocoding_provider_type}/${searchCoordinates}`)
this.addressList = this.currentGeocodingProvider.mapQueryResults(ret)
// this.geocoding_provider.mapQueryResults(ret)
if (this.geocoding_provider_type == "Nominatim") {
this.addressList = nominatim.mapQueryResults(ret)
} else if (this.geocoding_provider_type == "Photon") {
this.addressList = photon.mapQueryResults(ret)
}
this.loading = false this.loading = false
} }
}, 1000), }, 1000),

View file

@ -60,7 +60,7 @@ v-card
</template> </template>
<script> <script>
import { mapActions, mapState } from 'vuex' import { mapActions, mapState } from 'vuex'
import { isoCountries } from '../../server/helpers/geolocation' import { isoCountries } from '../../server/helpers/geolocation/isoCountries'
import { mdiChevronDown } from '@mdi/js' import { mdiChevronDown } from '@mdi/js'
// import Map from '~/components/Map' // import Map from '~/components/Map'
import "leaflet/dist/leaflet.css" import "leaflet/dist/leaflet.css"

View file

@ -19,13 +19,13 @@ v-container
v-model='place.name' v-model='place.name'
:placeholder='$t("common.name")') :placeholder='$t("common.name")')
v-text-field( v-text-field(ref='address'
:rules="[ v => $validators.required('common.address')(v)]" :rules="[ v => $validators.required('common.address')(v)]"
:label="$t('common.address')" :label="$t('common.address')"
v-model='place.address' v-model='place.address'
persistent-hint) persistent-hint)
v-combobox.mt-0.mb-4(ref='geocodedAddress' v-combobox.mt-0.mb-4(ref='geocodedAddress' v-model='place.geocodedAddress'
v-if="(settings.allow_geolocation && place.name !== 'online')" v-if="(settings.allow_geolocation && place.name !== 'online')"
:disabled="!(settings.allow_geolocation && place.name !== 'online')" :disabled="!(settings.allow_geolocation && place.name !== 'online')"
:prepend-icon='mdiMapSearch' :prepend-icon='mdiMapSearch'
@ -42,6 +42,7 @@ v-container
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-list-item-content(two-line v-if='item') v-list-item-content(two-line v-if='item')
v-list-item-title(v-text='item.name') v-list-item-title(v-text='item.name')
v-list-item-subtitle(v-text='`${item.address}`') v-list-item-subtitle(v-text='`${item.address}`')
@ -87,13 +88,11 @@ v-container
</template> </template>
<script> <script>
import { mdiPencil, mdiChevronLeft, mdiChevronRight, mdiMagnify, mdiEye, mdiMapSearch, mdiChevronDown, import { mdiPencil, mdiChevronLeft, mdiChevronRight, mdiChevronDown, mdiMagnify, mdiEye, mdiMapMarker,
mdiLatitude, mdiLongitude } from '@mdi/js' mdiLatitude, mdiLongitude, mdiMapSearch, mdiRoadVariant, mdiHome, mdiCityVariant } from '@mdi/js'
import { mapState } from 'vuex' import { mapState } from 'vuex'
import debounce from 'lodash/debounce' import debounce from 'lodash/debounce'
import nominatim from '../../server/services/geocoding/nominatim' import geolocation from '../../server/helpers/geolocation/index'
import photon from '../../server/services/geocoding/photon'
// import geolocation from '../../server/helpers/geolocation/index'
export default { export default {
components: { components: {
@ -101,8 +100,8 @@ export default {
}, },
data( {$store} ) { data( {$store} ) {
return { return {
mdiPencil, mdiChevronRight, mdiChevronLeft, mdiMagnify, mdiEye, mdiMapSearch, mdiChevronDown, mdiPencil, mdiChevronRight, mdiChevronLeft, mdiChevronDown, mdiMagnify, mdiEye, mdiMapMarker,
mdiLatitude, mdiLongitude, mdiLatitude, mdiLongitude, mdiMapSearch, mdiRoadVariant, mdiHome, mdiCityVariant,
loading: false, loading: false,
dialog: false, dialog: false,
valid: false, valid: false,
@ -118,16 +117,19 @@ export default {
{ 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', geocoding_provider_type: $store.state.settings.geocoding_provider_type || 'Nominatim',
nominatimProvider: nominatim, currentGeocodingProvider: geolocation.getGeocodingProvider($store.state.settings.geocoding_provider_type),
photonProvider: photon prevAddress: '',
iconsMapper: {
'mdiHome': mdiHome,
'mdiRoadVariant': mdiRoadVariant,
'mdiMapMarker': mdiMapMarker,
'mdiCityVariant': mdiCityVariant
},
} }
}, },
async fetch() { async fetch() {
this.places = await this.$axios.$get('/places') this.places = await this.$axios.$get('/places')
}, },
mounted() {
// this.currentGeocodingProvider = geolocation.getGeocodingProvider(this.settings.geocoding_provider_type)
},
computed: { computed: {
...mapState(['settings']), ...mapState(['settings']),
}, },
@ -136,6 +138,7 @@ export default {
this.place.name = item.name this.place.name = item.name
this.place.address = item.address this.place.address = item.address
if (this.settings.allow_geolocation) { if (this.settings.allow_geolocation) {
this.prevAddress = ''
this.place.geocodedAddress = '' this.place.geocodedAddress = ''
this.mapEdit++ this.mapEdit++
this.place.latitude = item.latitude this.place.latitude = item.latitude
@ -153,19 +156,23 @@ export default {
this.dialog = false this.dialog = false
}, },
selectAddress (v) { selectAddress (v) {
let currentAddress = this.place.address
if (!v) { return } if (!v) { return }
if (typeof v === 'object') { if (typeof v === 'object') {
this.place.latitude = v.lat this.place.latitude = v.lat
this.place.longitude = v.lon this.place.longitude = v.lon
this.place.geocodedAddress = v.address
this.place.address = v.address this.place.address = v.address
if (this.settings.allow_geolocation) { if (currentAddress === this.prevAddress) {
this.place.geocodedAddress = v.address console.log('here')
this.place.address = currentAddress
} }
} else { } else {
this.place.address = v this.place.address = v
this.place.latitude = this.place.longitude = null this.place.latitude = this.place.longitude = null
} }
this.$emit('input', { ...this.place }) this.$emit('input', { ...this.place })
this.prevAddress = this.geocodedAddress
}, },
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()
@ -174,14 +181,14 @@ export default {
if (searchCoordinates.length) { if (searchCoordinates.length) {
this.loading = true this.loading = true
const ret = await this.$axios.$get(`placeOSM/${this.geocoding_provider_type}/${searchCoordinates}`) const ret = await this.$axios.$get(`placeOSM/${this.geocoding_provider_type}/${searchCoordinates}`)
if (this.geocoding_provider_type == "Nominatim") { this.addressList = this.currentGeocodingProvider.mapQueryResults(ret)
this.addressList = nominatim.mapQueryResults(ret)
} else if (this.geocoding_provider_type == "Photon") {
this.addressList = photon.mapQueryResults(ret)
}
this.loading = false this.loading = false
} }
}, 1000) }, 1000),
loadCoordinatesResultIcon(item) {
let icon = this.currentGeocodingProvider.loadResultIcon(item)
return this.iconsMapper[icon]
},
} }
} }
</script> </script>

View file

@ -184,13 +184,12 @@
"download_flyer": "Download flyer", "download_flyer": "Download flyer",
"where_advanced_options": "Place - Advanced options", "where_advanced_options": "Place - Advanced options",
"where_advanced_options_description": "Define here additional place properties to the event", "where_advanced_options_description": "Define here additional place properties to the event",
"online_event_only": "Online event", "event_only_online": "Online event",
"event_only_online_label": "Event only online", "event_only_online_label": "Event only online",
"online_event_only_help": "For online-only event, the default place name 'online' is applied", "event_only_online_help": "For online-only event, the default place name 'online' is applied",
"online_event_too": "Partecipate remotely", "event_also_online": "Partecipate remotely",
"online_event_label": "Online locations", "online_locations_url": "Online locations",
"online_event_urls": "Online locations", "online_locations_fallback_urls": "Fallback links",
"online_event_fallback_urls": "Fallback links",
"additional_online_locations": "Additional online locations", "additional_online_locations": "Additional online locations",
"additional_online_locations_help": "Online locations, for instance a url to a videconference room", "additional_online_locations_help": "Online locations, for instance a url to a videconference room",
"address_geocoded_disclaimer": "Didn't you found the address or housenumber you are looking for? The <a target=\"_blank\" href=\"https://www.openstreetmap.org/\">OpenStreetMap</a> project is open to contributions. If you have Android, we recommend <a target=\"_blank\" href=\"https://f-droid.org/en/packages/de.westnordost.streetcomplete/\">StreetComplete</a> ", "address_geocoded_disclaimer": "Didn't you found the address or housenumber you are looking for? The <a target=\"_blank\" href=\"https://www.openstreetmap.org/\">OpenStreetMap</a> project is open to contributions. If you have Android, we recommend <a target=\"_blank\" href=\"https://f-droid.org/en/packages/de.westnordost.streetcomplete/\">StreetComplete</a> ",

View file

@ -38,19 +38,19 @@ v-container#event.pa-0.pa-sm-2
//- online events //- online events
v-divider(v-if='onlineSectionEnabled && event.locations && event.locations.length') v-divider(v-if='onlineSectionEnabled && event.locations && event.locations.length')
v-card(v-if='onlineSectionEnabled && event.locations && event.locations.length') v-card-text.text-caption.pb-0(v-if='onlineSectionEnabled && event.locations && event.locations.length'
v-card-text.text-caption.pb-0(v-text="event.place.name === 'online' && $t('event.online_event_only') || $t('event.online_event_too') ") v-text="event.place.name === 'online' && $t('event.event_only_online') || $t('event.event_also_online') ")
v-list-item(target='_blank' :href='`${event.locations[0]}`') v-list-item(target='_blank' :href='`${event.locations[0]}`')
v-list-item-icon v-list-item-icon
v-icon.my-auto(v-text='mdiMonitorAccount') v-icon.my-auto(v-text='mdiMonitorAccount')
v-list-item-content.py-0 v-list-item-content.py-0
v-list-item-title.text-caption(v-text='`${event.locations[0]}`') v-list-item-title.text-caption(v-text='`${event.locations[0]}`')
v-card.pb-2(v-if='onlineSectionEnabled && event.locations && event.locations.length > 1') v-card-text.text-caption.pt-0.pb-0(v-if='onlineSectionEnabled && event.locations && event.locations.length > 1'
v-card-text.text-caption.pt-0.pb-0(v-text="$t('event.online_event_fallback_urls')") v-text="$t('event.online_locations_fallback_urls')")
v-list-item v-list-item
v-list-item-content v-list-item-content
v-chip(v-for='(item, index) in event.locations' v-if="index > 0" target='_blank' :href="`${item}`" v-chip(v-for='(item, index) in event.locations' v-if="index > 0" target='_blank' :href="`${item}`"
v-bind:key="index" small label v-text="`${item}`" outlined ) v-bind:key="index" small label v-text="`${item}`" outlined )
v-divider v-divider
//- info & actions //- info & actions

View file

@ -1,987 +0,0 @@
// Iso conversions
var isoCountries = [
{
"code": "af",
"name": "Afghanistan"
},
{
"code": "ax",
"name": "Aland Islands"
},
{
"code": "al",
"name": "Albania"
},
{
"code": "dz",
"name": "Algeria"
},
{
"code": "as",
"name": "American Samoa"
},
{
"code": "ad",
"name": "Andorra"
},
{
"code": "ao",
"name": "Angola"
},
{
"code": "ai",
"name": "Anguilla"
},
{
"code": "aq",
"name": "Antarctica"
},
{
"code": "ag",
"name": "Antigua And Barbuda"
},
{
"code": "ar",
"name": "Argentina"
},
{
"code": "am",
"name": "Armenia"
},
{
"code": "aw",
"name": "Aruba"
},
{
"code": "au",
"name": "Australia"
},
{
"code": "at",
"name": "Austria"
},
{
"code": "az",
"name": "Azerbaijan"
},
{
"code": "bs",
"name": "Bahamas"
},
{
"code": "bh",
"name": "Bahrain"
},
{
"code": "bd",
"name": "Bangladesh"
},
{
"code": "bb",
"name": "Barbados"
},
{
"code": "by",
"name": "Belarus"
},
{
"code": "be",
"name": "Belgium"
},
{
"code": "bz",
"name": "Belize"
},
{
"code": "bj",
"name": "Benin"
},
{
"code": "bm",
"name": "Bermuda"
},
{
"code": "bt",
"name": "Bhutan"
},
{
"code": "bo",
"name": "Bolivia"
},
{
"code": "ba",
"name": "Bosnia And Herzegovina"
},
{
"code": "bw",
"name": "Botswana"
},
{
"code": "bv",
"name": "Bouvet Island"
},
{
"code": "br",
"name": "Brazil"
},
{
"code": "io",
"name": "British Indian Ocean Territory"
},
{
"code": "bn",
"name": "Brunei Darussalam"
},
{
"code": "bg",
"name": "Bulgaria"
},
{
"code": "bf",
"name": "Burkina Faso"
},
{
"code": "bi",
"name": "Burundi"
},
{
"code": "kh",
"name": "Cambodia"
},
{
"code": "cm",
"name": "Cameroon"
},
{
"code": "ca",
"name": "Canada"
},
{
"code": "cv",
"name": "Cape Verde"
},
{
"code": "ky",
"name": "Cayman Islands"
},
{
"code": "cf",
"name": "Central African Republic"
},
{
"code": "td",
"name": "Chad"
},
{
"code": "cl",
"name": "Chile"
},
{
"code": "cn",
"name": "China"
},
{
"code": "cx",
"name": "Christmas Island"
},
{
"code": "cc",
"name": "Cocos (Keeling) Islands"
},
{
"code": "co",
"name": "Colombia"
},
{
"code": "km",
"name": "Comoros"
},
{
"code": "cg",
"name": "Congo"
},
{
"code": "cd",
"name": "Congo, Democratic Republic"
},
{
"code": "ck",
"name": "Cook Islands"
},
{
"code": "cr",
"name": "Costa Rica"
},
{
"code": "ci",
"name": "Cote D'Ivoire"
},
{
"code": "hr",
"name": "Croatia"
},
{
"code": "cu",
"name": "Cuba"
},
{
"code": "cy",
"name": "Cyprus"
},
{
"code": "cz",
"name": "Czech Republic"
},
{
"code": "dk",
"name": "Denmark"
},
{
"code": "dj",
"name": "Djibouti"
},
{
"code": "dm",
"name": "Dominica"
},
{
"code": "do",
"name": "Dominican Republic"
},
{
"code": "ec",
"name": "Ecuador"
},
{
"code": "eg",
"name": "Egypt"
},
{
"code": "sv",
"name": "El Salvador"
},
{
"code": "gq",
"name": "Equatorial Guinea"
},
{
"code": "er",
"name": "Eritrea"
},
{
"code": "ee",
"name": "Estonia"
},
{
"code": "et",
"name": "Ethiopia"
},
{
"code": "fk",
"name": "Falkland Islands (Malvinas)"
},
{
"code": "fo",
"name": "Faroe Islands"
},
{
"code": "fj",
"name": "Fiji"
},
{
"code": "fi",
"name": "Finland"
},
{
"code": "fr",
"name": "France"
},
{
"code": "gf",
"name": "French Guiana"
},
{
"code": "pf",
"name": "French Polynesia"
},
{
"code": "tf",
"name": "French Southern Territories"
},
{
"code": "ga",
"name": "Gabon"
},
{
"code": "gm",
"name": "Gambia"
},
{
"code": "ge",
"name": "Georgia"
},
{
"code": "de",
"name": "Germany"
},
{
"code": "gh",
"name": "Ghana"
},
{
"code": "gi",
"name": "Gibraltar"
},
{
"code": "gr",
"name": "Greece"
},
{
"code": "gl",
"name": "Greenland"
},
{
"code": "gd",
"name": "Grenada"
},
{
"code": "gp",
"name": "Guadeloupe"
},
{
"code": "gu",
"name": "Guam"
},
{
"code": "gt",
"name": "Guatemala"
},
{
"code": "gg",
"name": "Guernsey"
},
{
"code": "gn",
"name": "Guinea"
},
{
"code": "gw",
"name": "Guinea-Bissau"
},
{
"code": "gy",
"name": "Guyana"
},
{
"code": "ht",
"name": "Haiti"
},
{
"code": "hm",
"name": "Heard Island & Mcdonald Islands"
},
{
"code": "va",
"name": "Holy See (Vatican City State)"
},
{
"code": "hn",
"name": "Honduras"
},
{
"code": "hk",
"name": "Hong Kong"
},
{
"code": "hu",
"name": "Hungary"
},
{
"code": "is",
"name": "Iceland"
},
{
"code": "in",
"name": "India"
},
{
"code": "id",
"name": "Indonesia"
},
{
"code": "ir",
"name": "Iran, Islamic Republic Of"
},
{
"code": "iq",
"name": "Iraq"
},
{
"code": "ie",
"name": "Ireland"
},
{
"code": "im",
"name": "Isle Of Man"
},
{
"code": "il",
"name": "Israel"
},
{
"code": "it",
"name": "Italy"
},
{
"code": "jm",
"name": "Jamaica"
},
{
"code": "jp",
"name": "Japan"
},
{
"code": "je",
"name": "Jersey"
},
{
"code": "jo",
"name": "Jordan"
},
{
"code": "kz",
"name": "Kazakhstan"
},
{
"code": "ke",
"name": "Kenya"
},
{
"code": "ki",
"name": "Kiribati"
},
{
"code": "kr",
"name": "Korea"
},
{
"code": "kw",
"name": "Kuwait"
},
{
"code": "kg",
"name": "Kyrgyzstan"
},
{
"code": "la",
"name": "Lao People's Democratic Republic"
},
{
"code": "lv",
"name": "Latvia"
},
{
"code": "lb",
"name": "Lebanon"
},
{
"code": "ls",
"name": "Lesotho"
},
{
"code": "lr",
"name": "Liberia"
},
{
"code": "ly",
"name": "Libyan Arab Jamahiriya"
},
{
"code": "li",
"name": "Liechtenstein"
},
{
"code": "lt",
"name": "Lithuania"
},
{
"code": "lu",
"name": "Luxembourg"
},
{
"code": "mo",
"name": "Macao"
},
{
"code": "mk",
"name": "Macedonia"
},
{
"code": "mg",
"name": "Madagascar"
},
{
"code": "mw",
"name": "Malawi"
},
{
"code": "my",
"name": "Malaysia"
},
{
"code": "mv",
"name": "Maldives"
},
{
"code": "ml",
"name": "Mali"
},
{
"code": "mt",
"name": "Malta"
},
{
"code": "mh",
"name": "Marshall Islands"
},
{
"code": "mq",
"name": "Martinique"
},
{
"code": "mr",
"name": "Mauritania"
},
{
"code": "mu",
"name": "Mauritius"
},
{
"code": "yt",
"name": "Mayotte"
},
{
"code": "mx",
"name": "Mexico"
},
{
"code": "fm",
"name": "Micronesia, Federated States Of"
},
{
"code": "md",
"name": "Moldova"
},
{
"code": "mc",
"name": "Monaco"
},
{
"code": "mn",
"name": "Mongolia"
},
{
"code": "me",
"name": "Montenegro"
},
{
"code": "ms",
"name": "Montserrat"
},
{
"code": "ma",
"name": "Morocco"
},
{
"code": "mz",
"name": "Mozambique"
},
{
"code": "mm",
"name": "Myanmar"
},
{
"code": "na",
"name": "Namibia"
},
{
"code": "nr",
"name": "Nauru"
},
{
"code": "np",
"name": "Nepal"
},
{
"code": "nl",
"name": "Netherlands"
},
{
"code": "an",
"name": "Netherlands Antilles"
},
{
"code": "nc",
"name": "New Caledonia"
},
{
"code": "nz",
"name": "New Zealand"
},
{
"code": "ni",
"name": "Nicaragua"
},
{
"code": "ne",
"name": "Niger"
},
{
"code": "ng",
"name": "Nigeria"
},
{
"code": "nu",
"name": "Niue"
},
{
"code": "nf",
"name": "Norfolk Island"
},
{
"code": "mp",
"name": "Northern Mariana Islands"
},
{
"code": "no",
"name": "Norway"
},
{
"code": "om",
"name": "Oman"
},
{
"code": "pk",
"name": "Pakistan"
},
{
"code": "pw",
"name": "Palau"
},
{
"code": "ps",
"name": "Palestinian Territory, Occupied"
},
{
"code": "pa",
"name": "Panama"
},
{
"code": "pg",
"name": "Papua New Guinea"
},
{
"code": "py",
"name": "Paraguay"
},
{
"code": "pe",
"name": "Peru"
},
{
"code": "ph",
"name": "Philippines"
},
{
"code": "pn",
"name": "Pitcairn"
},
{
"code": "pl",
"name": "Poland"
},
{
"code": "pt",
"name": "Portugal"
},
{
"code": "pr",
"name": "Puerto Rico"
},
{
"code": "qa",
"name": "Qatar"
},
{
"code": "re",
"name": "Reunion"
},
{
"code": "ro",
"name": "Romania"
},
{
"code": "ru",
"name": "Russian Federation"
},
{
"code": "rw",
"name": "Rwanda"
},
{
"code": "bl",
"name": "Saint Barthelemy"
},
{
"code": "sh",
"name": "Saint Helena"
},
{
"code": "kn",
"name": "Saint Kitts And Nevis"
},
{
"code": "lc",
"name": "Saint Lucia"
},
{
"code": "mf",
"name": "Saint Martin"
},
{
"code": "pm",
"name": "Saint Pierre And Miquelon"
},
{
"code": "vc",
"name": "Saint Vincent And Grenadines"
},
{
"code": "ws",
"name": "Samoa"
},
{
"code": "sm",
"name": "San Marino"
},
{
"code": "st",
"name": "Sao Tome And Principe"
},
{
"code": "sa",
"name": "Saudi Arabia"
},
{
"code": "sn",
"name": "Senegal"
},
{
"code": "rs",
"name": "Serbia"
},
{
"code": "sc",
"name": "Seychelles"
},
{
"code": "sl",
"name": "Sierra Leone"
},
{
"code": "sg",
"name": "Singapore"
},
{
"code": "sk",
"name": "Slovakia"
},
{
"code": "si",
"name": "Slovenia"
},
{
"code": "sb",
"name": "Solomon Islands"
},
{
"code": "so",
"name": "Somalia"
},
{
"code": "za",
"name": "South Africa"
},
{
"code": "gs",
"name": "South Georgia And Sandwich Isl."
},
{
"code": "es",
"name": "Spain"
},
{
"code": "lk",
"name": "Sri Lanka"
},
{
"code": "sd",
"name": "Sudan"
},
{
"code": "sr",
"name": "Suriname"
},
{
"code": "sj",
"name": "Svalbard And Jan Mayen"
},
{
"code": "sz",
"name": "Swaziland"
},
{
"code": "se",
"name": "Sweden"
},
{
"code": "ch",
"name": "Switzerland"
},
{
"code": "sy",
"name": "Syrian Arab Republic"
},
{
"code": "tw",
"name": "Taiwan"
},
{
"code": "tj",
"name": "Tajikistan"
},
{
"code": "tz",
"name": "Tanzania"
},
{
"code": "th",
"name": "Thailand"
},
{
"code": "tl",
"name": "Timor-Leste"
},
{
"code": "tg",
"name": "Togo"
},
{
"code": "tk",
"name": "Tokelau"
},
{
"code": "to",
"name": "Tonga"
},
{
"code": "tt",
"name": "Trinidad And Tobago"
},
{
"code": "tn",
"name": "Tunisia"
},
{
"code": "tr",
"name": "Turkey"
},
{
"code": "tm",
"name": "Turkmenistan"
},
{
"code": "tc",
"name": "Turks And Caicos Islands"
},
{
"code": "tv",
"name": "Tuvalu"
},
{
"code": "ug",
"name": "Uganda"
},
{
"code": "ua",
"name": "Ukraine"
},
{
"code": "ae",
"name": "United Arab Emirates"
},
{
"code": "gb",
"name": "United Kingdom"
},
{
"code": "us",
"name": "United States"
},
{
"code": "um",
"name": "United States Outlying Islands"
},
{
"code": "uy",
"name": "Uruguay"
},
{
"code": "uz",
"name": "Uzbekistan"
},
{
"code": "vu",
"name": "Vanuatu"
},
{
"code": "ve",
"name": "Venezuela"
},
{
"code": "vn",
"name": "Viet Nam"
},
{
"code": "vg",
"name": "Virgin Islands, British"
},
{
"code": "vi",
"name": "Virgin Islands, U.S."
},
{
"code": "wf",
"name": "Wallis And Futuna"
},
{
"code": "eh",
"name": "Western Sahara"
},
{
"code": "ye",
"name": "Yemen"
},
{
"code": "zm",
"name": "Zambia"
},
{
"code": "zw",
"name": "Zimbabwe"
}
]
module.exports = { isoCountries }

View file

@ -1,17 +1,18 @@
const isoCountries = require('./isoCountries')
const nominatim = require('../../../server/services/geocoding/nominatim') const nominatim = require('../../../server/services/geocoding/nominatim')
const photon = require('../../../server/services/geocoding/photon') const photon = require('../../../server/services/geocoding/photon')
// const geocodingProviders = [ nominatim, photon ] const geocodingProviders = [ nominatim, photon ]
// const geolocation = { const geolocation = {
// getGeocodingProvider(providerName) { getGeocodingProvider(providerName) {
// geocodingProviders.forEach((item) => { let geocodingProvider
// if (item.commonName === settings.geocoding_provider_type) { geocodingProviders.forEach((item) => {
// return item if (item.commonName === providerName) {
// } geocodingProvider = item
// }) }
// } })
// } return geocodingProvider
}
}
// module.exports = geolocation module.exports = geolocation

View file

@ -24,7 +24,7 @@ const nominatim = {
} }
}, },
/* /**
* Icons to nominatim `osm_type` and `class` conversion * Icons to nominatim `osm_type` and `class` conversion
*/ */
searchIcons_nominatim_osm_type: { searchIcons_nominatim_osm_type: {
@ -33,10 +33,18 @@ const nominatim = {
node: 'mdiMapMarker', node: 'mdiMapMarker',
relation: 'mdiCityVariant', relation: 'mdiCityVariant',
}, },
searchIcons_nominatim_class: { searchIcons_nominatim_class: ['place', 'amenity', 'shop', 'tourism', 'leisure', 'building'],
mdiHome: ['place', 'amenity', 'shop', 'tourism', 'leisure', 'building']
loadResultIcon (item) {
if (this.searchIcons_nominatim_class.includes(item.class)) {
return 'mdiHome'
}
return this.searchIcons_nominatim_osm_type[item.type]
}, },
/**
* Map results from provider
*/
filterNameFromAddress: ['place', 'amenity', 'shop', 'tourism', 'leisure', 'building'], filterNameFromAddress: ['place', 'amenity', 'shop', 'tourism', 'leisure', 'building'],
mapQueryResults (ret, addressList = []) { mapQueryResults (ret, addressList = []) {

View file

@ -18,7 +18,7 @@ const photon = {
} }
}, },
/* /**
* Icons to nominatim `osm_type` and `class` conversion * Icons to nominatim `osm_type` and `class` conversion
*/ */
searchIcons_nominatim_osm_type: { searchIcons_nominatim_osm_type: {
@ -26,11 +26,18 @@ const photon = {
'N': 'mdiMapMarker', 'N': 'mdiMapMarker',
'R': 'mdiCityVariant', 'R': 'mdiCityVariant',
}, },
searchIcons_nominatim_class: { searchIcons_nominatim_class: ['amenity', 'shop', 'tourism', 'leisure', 'building'],
mdiHome: ['amenity', 'shop', 'tourism', 'leisure', 'building'],
loadResultIcon (item) {
if (this.searchIcons_nominatim_class.includes(item.class)) {
return 'mdiHome'
}
return this.searchIcons_nominatim_osm_type[item.type]
}, },
/**
* Map results from provider
*/
fullAddressMapping: ['housenumber', 'street', 'locality', 'district', 'city', 'county', 'state', 'postcode', 'country'], fullAddressMapping: ['housenumber', 'street', 'locality', 'district', 'city', 'county', 'state', 'postcode', 'country'],
mapQueryResults(ret, addressList = []) { mapQueryResults(ret, addressList = []) {