reinit whereinputadvanced in /add , and init only/also online mechanism, various fixes: admin edit place; bug in nominatim display_name when place in certain nominatim_class, init refactor geocoding related code in services/geocoding/provider; init MapEdit component

This commit is contained in:
sedum
2023-02-17 00:23:35 +01:00
parent 6aceaba7f7
commit 79ebec9116
21 changed files with 1558 additions and 255 deletions

View File

@@ -1,5 +1,6 @@
const cache = require('memory-cache')
const providerCache = new cache.Cache()
const get = require('lodash/get')
const nominatim = {
commonName: 'Nominatim',
@@ -23,6 +24,39 @@ const nominatim = {
}
},
/*
* Icons to nominatim `osm_type` and `class` conversion
*/
searchIcons_nominatim_osm_type: {
way: 'mdiRoadVariant',
house: 'mdiHome',
node: 'mdiMapMarker',
relation: 'mdiCityVariant',
},
searchIcons_nominatim_class: {
mdiHome: ['place', 'amenity', 'shop', 'tourism', 'leisure', 'building']
},
filterNameFromAddress: ['place', 'amenity', 'shop', 'tourism', 'leisure', 'building'],
mapQueryResults (ret, addressList = []) {
if (ret && ret.length) {
addressList = ret.map(v => {
const name = get(v.namedetails, 'alt_name', get(v.namedetails, 'name'))
const address = this.filterNameFromAddress.includes(v.class) ? v.display_name.replace(name, '').replace(/^, ?/, '') : v.display_name.replace(/^, ?/, '')
return {
class: v.class,
type: v.osm_type,
lat: v.lat,
lon: v.lon,
name,
address
}
})
}
return addressList
}
}
module.exports = nominatim

View File

@@ -16,6 +16,51 @@ const photon = {
q: details,
limit: 3,
}
},
/*
* Icons to nominatim `osm_type` and `class` conversion
*/
searchIcons_nominatim_osm_type: {
'W': 'mdiRoadVariant',
'N': 'mdiMapMarker',
'R': 'mdiCityVariant',
},
searchIcons_nominatim_class: {
mdiHome: ['amenity', 'shop', 'tourism', 'leisure', 'building'],
},
fullAddressMapping: ['housenumber', 'street', 'locality', 'district', 'city', 'county', 'state', 'postcode', 'country'],
mapQueryResults(ret, addressList = []) {
if (ret) {
addressList = ret.features.map(v => {
let pre_name = v.properties.name || v.properties.street || ''
let pre_address = ''
this.fullAddressMapping.forEach((item, i) => {
let last = i == (this.fullAddressMapping.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
}
})
}
return addressList
}
}