X-Git-Url: https://git.openstreetmap.org./nominatim-ui.git/blobdiff_plain/b2d1e2a271b3f2157987908bb284be14732a747b..2a34127a122a0d415a1cabb8de8e80a91b3dc017:/src/lib/helpers.js diff --git a/src/lib/helpers.js b/src/lib/helpers.js index dfe4ced..c95dbe9 100644 --- a/src/lib/helpers.js +++ b/src/lib/helpers.js @@ -13,6 +13,15 @@ export function formatOSMType(sType, bExcludeExternal) { return ''; } +// https://www.openstreetmap.org/relation/123 => ['R', 123] +// w123 => ['W', 123] +export function identifyLinkInQuery(query) { + if (!query) return undefined; + const m = query.match(/\/(relation|way|node)\/(\d+)/) || query.match(/^([nwr])(\d+)$/i); + if (!m) return undefined; + return [m[1][0].toUpperCase(), Number(m[2])]; +} + export function osmLink(aPlace) { if (!aPlace.osm_type) return ''; var sOSMType = formatOSMType(aPlace.osm_type, false); @@ -127,16 +136,13 @@ export function zoomLevels() { /* 9 */ '', /* 10 */ 'City', /* 11 */ '', - /* 12 */ 'Town / Village', - /* 13 */ '', - /* 14 */ 'Suburb', - /* 15 */ '', - /* 16 */ 'Street', - /* 17 */ '', - /* 18 */ 'Building', - /* 19 */ '', - /* 20 */ '', - /* 21 */ '' + /* 12 */ 'Town / Borough', + /* 13 */ 'Village / Suburb', + /* 14 */ 'Neighbourhood', + /* 15 */ 'Locality', + /* 16 */ 'Major Street', + /* 17 */ 'Minor Street', + /* 18 */ 'Building' ]; return aZoomLevels; }