Test with name suggestion index

This commit is contained in:
Robin van der Linde 2024-04-25 00:56:36 +02:00
parent 00ab3a1b77
commit 6786c8f321
Signed by: Robin-van-der-Linde
GPG key ID: 53956B3252478F0D
7 changed files with 371 additions and 5 deletions

View file

@ -150,7 +150,7 @@
},
"freeform": {
"key": "brand",
"type": "string",
"type": "nsi",
"placeholder": {
"en": "Brand name",
"de": "Markenname",
@ -641,4 +641,4 @@
"enableImproveAccuracy": true,
"enableRelocation": false
}
}
}

223
package-lock.json generated
View file

@ -1,17 +1,18 @@
{
"name": "mapcomplete",
"version": "0.42.0",
"version": "0.42.3",
"lockfileVersion": 2,
"requires": true,
"packages": {
"": {
"name": "mapcomplete",
"version": "0.42.0",
"version": "0.42.3",
"license": "GPL-3.0-or-later",
"dependencies": {
"@comunica/core": "^3.0.1",
"@comunica/query-sparql": "^3.0.1",
"@comunica/query-sparql-link-traversal": "^0.3.0",
"@rapideditor/location-conflation": "^1.3.0",
"@rgossiaux/svelte-headlessui": "^1.0.2",
"@rgossiaux/svelte-heroicons": "^0.1.2",
"@rollup/plugin-typescript": "^11.0.0",
@ -53,6 +54,7 @@
"mangrove-reviews-typescript": "^1.1.0",
"maplibre-gl": "^4.1.1",
"monaco-editor": "^0.46.0",
"name-suggestion-index": "^6.0.20240422",
"nano-markdown": "^1.2.2",
"opening_hours": "^3.6.0",
"osm-auth": "^2.2.0",
@ -129,6 +131,11 @@
"node": ">=0.10.0"
}
},
"node_modules/@aitodotai/json-stringify-pretty-compact": {
"version": "1.3.0",
"resolved": "https://registry.npmjs.org/@aitodotai/json-stringify-pretty-compact/-/json-stringify-pretty-compact-1.3.0.tgz",
"integrity": "sha512-K+whdCBlVjzx8zCK2ZUohGJb5bUOxRpiEAfD1NCUgH0mApdDZD9c7VHXJVzWlt3wfV1X4OFyCRmTqbPd6U87lQ=="
},
"node_modules/@ampproject/remapping": {
"version": "2.2.0",
"dev": true,
@ -4743,6 +4750,14 @@
"@jridgewell/sourcemap-codec": "1.4.14"
}
},
"node_modules/@mapbox/geojson-area": {
"version": "0.2.2",
"resolved": "https://registry.npmjs.org/@mapbox/geojson-area/-/geojson-area-0.2.2.tgz",
"integrity": "sha512-bBqqFn1kIbLBfn7Yq1PzzwVkPYQr9lVUeT8Dhd0NL5n76PBuXzOcuLV7GOSbEB1ia8qWxH4COCvFpziEu/yReA==",
"dependencies": {
"wgs84": "0.0.0"
}
},
"node_modules/@mapbox/geojson-rewind": {
"version": "0.5.2",
"license": "ISC",
@ -4865,6 +4880,33 @@
"url": "https://opencollective.com/parcel"
}
},
"node_modules/@rapideditor/country-coder": {
"version": "5.2.2",
"resolved": "https://registry.npmjs.org/@rapideditor/country-coder/-/country-coder-5.2.2.tgz",
"integrity": "sha512-xGkI+wHX694sFcKKVdy20/uNeHuIiJACnke2vp7LzX22PRPJJv+pcn1OU5nb1urnad275EMfJQR33ayi2hWZOQ==",
"dependencies": {
"which-polygon": "^2.2.1"
},
"engines": {
"node": ">=16.14.0"
}
},
"node_modules/@rapideditor/location-conflation": {
"version": "1.3.0",
"resolved": "https://registry.npmjs.org/@rapideditor/location-conflation/-/location-conflation-1.3.0.tgz",
"integrity": "sha512-h4FAeKNxuqmO7OGTkXN5CS8gbP+/sCyrQdgSMhtjGYwnGaNQoEIypQNRYAqQJxJjgNISvVvunRTvSOOJfSWxSw==",
"dependencies": {
"@aitodotai/json-stringify-pretty-compact": "^1.3.0",
"@mapbox/geojson-area": "^0.2.2",
"@rapideditor/country-coder": "^5.2.1",
"circle-to-polygon": "^2.2.0",
"geojson-precision": "^1.0.0",
"polyclip-ts": "~0.16.3"
},
"engines": {
"node": ">=18"
}
},
"node_modules/@rdfjs/types": {
"version": "1.1.0",
"license": "MIT",
@ -7921,6 +7963,11 @@
"node": ">=8"
}
},
"node_modules/circle-to-polygon": {
"version": "2.2.0",
"resolved": "https://registry.npmjs.org/circle-to-polygon/-/circle-to-polygon-2.2.0.tgz",
"integrity": "sha512-yC9/bw6P0YmV2/oxm4DLrSgrzHhbz9H+vgUScmSFN5KilR/KFGVRbUi9a0mIYPsXK44HvnysVVi/iIysRJVvNw=="
},
"node_modules/cli-truncate": {
"version": "3.1.0",
"license": "MIT",
@ -8708,6 +8755,11 @@
"node": ">=0.8.0"
}
},
"node_modules/diacritics": {
"version": "1.3.0",
"resolved": "https://registry.npmjs.org/diacritics/-/diacritics-1.3.0.tgz",
"integrity": "sha512-wlwEkqcsaxvPJML+rDh/2iS824jbREk6DUMUKkEaSlxdYHeS43cClJtsWglvw2RfeXGm6ohKDqsXteJ5sP5enA=="
},
"node_modules/didyoumean": {
"version": "1.2.2",
"license": "Apache-2.0"
@ -9884,6 +9936,25 @@
"geojson-numeric": "geojson-numeric"
}
},
"node_modules/geojson-precision": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/geojson-precision/-/geojson-precision-1.0.0.tgz",
"integrity": "sha512-lXK9eCxhZQnZSMtz+xcy16H6In9oGbtYg0A92elUX13QtdrIsngrU2w9ZjkKB2GY1TDIJJ22elzcgRAEmyFoXQ==",
"dependencies": {
"commander": "2.19.0"
},
"bin": {
"geojson-precision": "bin/geojson-precision"
},
"engines": {
"node": ">=6.4.0"
}
},
"node_modules/geojson-precision/node_modules/commander": {
"version": "2.19.0",
"resolved": "https://registry.npmjs.org/commander/-/commander-2.19.0.tgz",
"integrity": "sha512-6tvAOO+D6OENvRAh524Dh9jcfKTYDQAqvqezbCW82xj5X0pSrcpxtvRKHLG0yBY6SD7PSDrJaj+0AiOcKVd1Xg=="
},
"node_modules/geojson-random": {
"version": "0.2.2",
"license": "ISC",
@ -11319,6 +11390,11 @@
"node": ">=10"
}
},
"node_modules/lineclip": {
"version": "1.1.5",
"resolved": "https://registry.npmjs.org/lineclip/-/lineclip-1.1.5.tgz",
"integrity": "sha512-KlA/wRSjpKl7tS9iRUdlG72oQ7qZ1IlVbVgHwoO10TBR/4gQ86uhKow6nlzMAJJhjCWKto8OeoAzzIzKSmN25A=="
},
"node_modules/local-pkg": {
"version": "0.4.3",
"license": "MIT",
@ -11915,6 +11991,19 @@
"node": "^12.22.0 || ^14.17.0 || >=16.0.0"
}
},
"node_modules/name-suggestion-index": {
"version": "6.0.20240422",
"resolved": "https://registry.npmjs.org/name-suggestion-index/-/name-suggestion-index-6.0.20240422.tgz",
"integrity": "sha512-NP0QJfCGKkpduNruS6dM8U7uA//EjyH4Kw+lavUWuQxOl0QxhFVF9caMh3UPvDZgqdMOMpyi/z195rjieAAPyQ==",
"dependencies": {
"diacritics": "^1.3.0",
"run-s": "^0.0.0",
"which-polygon": "^2.2.1"
},
"engines": {
"node": ">=18"
}
},
"node_modules/nano-markdown": {
"version": "1.2.2",
"license": "MIT"
@ -12503,6 +12592,15 @@
"version": "1.1.0",
"license": "MIT"
},
"node_modules/polyclip-ts": {
"version": "0.16.5",
"resolved": "https://registry.npmjs.org/polyclip-ts/-/polyclip-ts-0.16.5.tgz",
"integrity": "sha512-ZchnG0zGZReHgEo3EYzEUi6UmfQFFzNnj6AFU+gBm+IJJ4qG9gL4CwjtCV6oi/PittUPpJLiLJxcn/AgrCBO+g==",
"dependencies": {
"bignumber.js": "^9.1.0",
"splaytree-ts": "^1.0.1"
}
},
"node_modules/polygon-clipping": {
"version": "0.15.3",
"license": "MIT",
@ -13941,6 +14039,11 @@
"queue-microtask": "^1.2.2"
}
},
"node_modules/run-s": {
"version": "0.0.0",
"resolved": "https://registry.npmjs.org/run-s/-/run-s-0.0.0.tgz",
"integrity": "sha512-KPDNauF2Tpnm3nG0+0LJuJxwBFrhAdthpM8bVdDvjWQA7pWP7QoNwEl1+dJ7WVJj81AQP/i6kl6JUmAk7tg3Og=="
},
"node_modules/rw": {
"version": "1.3.3",
"license": "BSD-3-Clause"
@ -14560,6 +14663,11 @@
"version": "3.1.1",
"license": "MIT"
},
"node_modules/splaytree-ts": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/splaytree-ts/-/splaytree-ts-1.0.1.tgz",
"integrity": "sha512-B+VzCm33/KEchi/fzT6/3NRHm8k5+Kf37SBQO3meHHS/tK2xBnIm4ZvusQ1wUpHgKMCCqEWgXnwFXAa1nD289g=="
},
"node_modules/split-string": {
"version": "3.1.0",
"license": "MIT",
@ -16502,6 +16610,15 @@
"node": ">= 8"
}
},
"node_modules/which-polygon": {
"version": "2.2.1",
"resolved": "https://registry.npmjs.org/which-polygon/-/which-polygon-2.2.1.tgz",
"integrity": "sha512-RlpWbqz12OMT0r2lEHk7IUPXz0hb1L/ZZsGushB2P2qxuBu1aq1+bcTfsLtfoRBYHsED6ruBMiwFaidvXZfQVw==",
"dependencies": {
"lineclip": "^1.1.5",
"rbush": "^2.0.1"
}
},
"node_modules/which-typed-array": {
"version": "1.1.9",
"dev": true,
@ -16779,6 +16896,11 @@
"version": "1.2.6",
"dev": true
},
"@aitodotai/json-stringify-pretty-compact": {
"version": "1.3.0",
"resolved": "https://registry.npmjs.org/@aitodotai/json-stringify-pretty-compact/-/json-stringify-pretty-compact-1.3.0.tgz",
"integrity": "sha512-K+whdCBlVjzx8zCK2ZUohGJb5bUOxRpiEAfD1NCUgH0mApdDZD9c7VHXJVzWlt3wfV1X4OFyCRmTqbPd6U87lQ=="
},
"@ampproject/remapping": {
"version": "2.2.0",
"dev": true,
@ -20392,6 +20514,14 @@
"@jridgewell/sourcemap-codec": "1.4.14"
}
},
"@mapbox/geojson-area": {
"version": "0.2.2",
"resolved": "https://registry.npmjs.org/@mapbox/geojson-area/-/geojson-area-0.2.2.tgz",
"integrity": "sha512-bBqqFn1kIbLBfn7Yq1PzzwVkPYQr9lVUeT8Dhd0NL5n76PBuXzOcuLV7GOSbEB1ia8qWxH4COCvFpziEu/yReA==",
"requires": {
"wgs84": "0.0.0"
}
},
"@mapbox/geojson-rewind": {
"version": "0.5.2",
"requires": {
@ -20462,6 +20592,27 @@
"version": "2.8.2",
"dev": true
},
"@rapideditor/country-coder": {
"version": "5.2.2",
"resolved": "https://registry.npmjs.org/@rapideditor/country-coder/-/country-coder-5.2.2.tgz",
"integrity": "sha512-xGkI+wHX694sFcKKVdy20/uNeHuIiJACnke2vp7LzX22PRPJJv+pcn1OU5nb1urnad275EMfJQR33ayi2hWZOQ==",
"requires": {
"which-polygon": "^2.2.1"
}
},
"@rapideditor/location-conflation": {
"version": "1.3.0",
"resolved": "https://registry.npmjs.org/@rapideditor/location-conflation/-/location-conflation-1.3.0.tgz",
"integrity": "sha512-h4FAeKNxuqmO7OGTkXN5CS8gbP+/sCyrQdgSMhtjGYwnGaNQoEIypQNRYAqQJxJjgNISvVvunRTvSOOJfSWxSw==",
"requires": {
"@aitodotai/json-stringify-pretty-compact": "^1.3.0",
"@mapbox/geojson-area": "^0.2.2",
"@rapideditor/country-coder": "^5.2.1",
"circle-to-polygon": "^2.2.0",
"geojson-precision": "^1.0.0",
"polyclip-ts": "~0.16.3"
}
},
"@rdfjs/types": {
"version": "1.1.0",
"requires": {
@ -22482,6 +22633,11 @@
"ci-info": {
"version": "3.7.1"
},
"circle-to-polygon": {
"version": "2.2.0",
"resolved": "https://registry.npmjs.org/circle-to-polygon/-/circle-to-polygon-2.2.0.tgz",
"integrity": "sha512-yC9/bw6P0YmV2/oxm4DLrSgrzHhbz9H+vgUScmSFN5KilR/KFGVRbUi9a0mIYPsXK44HvnysVVi/iIysRJVvNw=="
},
"cli-truncate": {
"version": "3.1.0",
"requires": {
@ -22992,6 +23148,11 @@
"minimist": "^1.2.6"
}
},
"diacritics": {
"version": "1.3.0",
"resolved": "https://registry.npmjs.org/diacritics/-/diacritics-1.3.0.tgz",
"integrity": "sha512-wlwEkqcsaxvPJML+rDh/2iS824jbREk6DUMUKkEaSlxdYHeS43cClJtsWglvw2RfeXGm6ohKDqsXteJ5sP5enA=="
},
"didyoumean": {
"version": "1.2.2"
},
@ -23745,6 +23906,21 @@
"optimist": "~0.3.5"
}
},
"geojson-precision": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/geojson-precision/-/geojson-precision-1.0.0.tgz",
"integrity": "sha512-lXK9eCxhZQnZSMtz+xcy16H6In9oGbtYg0A92elUX13QtdrIsngrU2w9ZjkKB2GY1TDIJJ22elzcgRAEmyFoXQ==",
"requires": {
"commander": "2.19.0"
},
"dependencies": {
"commander": {
"version": "2.19.0",
"resolved": "https://registry.npmjs.org/commander/-/commander-2.19.0.tgz",
"integrity": "sha512-6tvAOO+D6OENvRAh524Dh9jcfKTYDQAqvqezbCW82xj5X0pSrcpxtvRKHLG0yBY6SD7PSDrJaj+0AiOcKVd1Xg=="
}
}
},
"geojson-random": {
"version": "0.2.2"
},
@ -24645,6 +24821,11 @@
"lilconfig": {
"version": "2.0.6"
},
"lineclip": {
"version": "1.1.5",
"resolved": "https://registry.npmjs.org/lineclip/-/lineclip-1.1.5.tgz",
"integrity": "sha512-KlA/wRSjpKl7tS9iRUdlG72oQ7qZ1IlVbVgHwoO10TBR/4gQ86uhKow6nlzMAJJhjCWKto8OeoAzzIzKSmN25A=="
},
"local-pkg": {
"version": "0.4.3"
},
@ -25029,6 +25210,16 @@
}
}
},
"name-suggestion-index": {
"version": "6.0.20240422",
"resolved": "https://registry.npmjs.org/name-suggestion-index/-/name-suggestion-index-6.0.20240422.tgz",
"integrity": "sha512-NP0QJfCGKkpduNruS6dM8U7uA//EjyH4Kw+lavUWuQxOl0QxhFVF9caMh3UPvDZgqdMOMpyi/z195rjieAAPyQ==",
"requires": {
"diacritics": "^1.3.0",
"run-s": "^0.0.0",
"which-polygon": "^2.2.1"
}
},
"nano-markdown": {
"version": "1.2.2"
},
@ -25397,6 +25588,15 @@
"point-in-polygon": {
"version": "1.1.0"
},
"polyclip-ts": {
"version": "0.16.5",
"resolved": "https://registry.npmjs.org/polyclip-ts/-/polyclip-ts-0.16.5.tgz",
"integrity": "sha512-ZchnG0zGZReHgEo3EYzEUi6UmfQFFzNnj6AFU+gBm+IJJ4qG9gL4CwjtCV6oi/PittUPpJLiLJxcn/AgrCBO+g==",
"requires": {
"bignumber.js": "^9.1.0",
"splaytree-ts": "^1.0.1"
}
},
"polygon-clipping": {
"version": "0.15.3",
"requires": {
@ -26344,6 +26544,11 @@
"queue-microtask": "^1.2.2"
}
},
"run-s": {
"version": "0.0.0",
"resolved": "https://registry.npmjs.org/run-s/-/run-s-0.0.0.tgz",
"integrity": "sha512-KPDNauF2Tpnm3nG0+0LJuJxwBFrhAdthpM8bVdDvjWQA7pWP7QoNwEl1+dJ7WVJj81AQP/i6kl6JUmAk7tg3Og=="
},
"rw": {
"version": "1.3.3"
},
@ -26752,6 +26957,11 @@
"splaytree": {
"version": "3.1.1"
},
"splaytree-ts": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/splaytree-ts/-/splaytree-ts-1.0.1.tgz",
"integrity": "sha512-B+VzCm33/KEchi/fzT6/3NRHm8k5+Kf37SBQO3meHHS/tK2xBnIm4ZvusQ1wUpHgKMCCqEWgXnwFXAa1nD289g=="
},
"split-string": {
"version": "3.1.0",
"requires": {
@ -28027,6 +28237,15 @@
"isexe": "^2.0.0"
}
},
"which-polygon": {
"version": "2.2.1",
"resolved": "https://registry.npmjs.org/which-polygon/-/which-polygon-2.2.1.tgz",
"integrity": "sha512-RlpWbqz12OMT0r2lEHk7IUPXz0hb1L/ZZsGushB2P2qxuBu1aq1+bcTfsLtfoRBYHsED6ruBMiwFaidvXZfQVw==",
"requires": {
"lineclip": "^1.1.5",
"rbush": "^2.0.1"
}
},
"which-typed-array": {
"version": "1.1.9",
"dev": true,

View file

@ -86,7 +86,6 @@
"optimize-images-png": "cd assets/generated/ && find -name '*.png' -exec optipng '{}' \\; && echo 'PNGs are optimized'",
"optimize-images-jpg": "cd assets/ && find . -regextype sed -regex \".*/.*.\\(jpg\\|JPG\\|JPEG\\|jpeg\\)\" -exec jpegoptim '{}' \\; && echo 'JPGs are optimized'",
"optimize-images-scaledown-jpg": "cd assets/ && find . -regextype sed -regex \".*/.*.\\(jpg\\|JPG\\|JPEG\\|jpeg\\)\" -exec mogrify -resize 640x640\\> '{}' \\; && echo 'JPGs are optimized'",
"generate:stats": "vite-node scripts/GenerateSeries.ts",
"reset:layeroverview": "npm run prep:layeroverview && npm run generate:layeroverview && npm run refresh:layeroverview",
"prep:layeroverview": "mkdir -p ./src/assets/generated/layers; echo {\\\"themes\\\":[]} > ./src/assets/generated/known_themes.json && echo {\\\"layers\\\": []} > ./src/assets/generated/known_layers.json && rm -f ./src/assets/generated/layers/*.json && rm -f ./src/assets/generated/themes/*.json && cp ./assets/layers/usersettings/usersettings.json ./src/assets/generated/layers/usersettings.json && echo '{}' > ./src/assets/generated/layers/favourite.json && echo '{}' > ./src/assets/generated/layers/summary.json",
@ -131,6 +130,7 @@
"@comunica/core": "^3.0.1",
"@comunica/query-sparql": "^3.0.1",
"@comunica/query-sparql-link-traversal": "^0.3.0",
"@rapideditor/location-conflation": "^1.3.0",
"@rgossiaux/svelte-headlessui": "^1.0.2",
"@rgossiaux/svelte-heroicons": "^0.1.2",
"@rollup/plugin-typescript": "^11.0.0",
@ -172,6 +172,7 @@
"mangrove-reviews-typescript": "^1.1.0",
"maplibre-gl": "^4.1.1",
"monaco-editor": "^0.46.0",
"name-suggestion-index": "^6.0.20240422",
"nano-markdown": "^1.2.2",
"opening_hours": "^3.6.0",
"osm-auth": "^2.2.0",

View file

@ -0,0 +1,103 @@
<script lang="ts">
import type { Feature, MultiPolygon } from "geojson"
import { UIEventSource } from "../../../Logic/UIEventSource"
import * as nsi from "../../../../node_modules/name-suggestion-index/dist/nsi.json"
import * as nsiFeatures from "../../../../node_modules/name-suggestion-index/dist/featureCollection.json"
import { LocationConflation } from "@rapideditor/location-conflation"
import * as turf from "@turf/turf"
const nsiFile: NSIFile = nsi
const loco = new LocationConflation(nsiFeatures)
/**
* All props for this input helper
*/
export let value: UIEventSource<string> = new UIEventSource<string>(undefined)
export let feature: Feature
// Currently hardcoded, should be dynamic
let maintag = "amenity=atm"
let tag = "brand"
const path = `${tag}s/${maintag.split("=")[0]}/${maintag.split("=")[1]}`
let items = nsiFile.nsi[path].items
// Get the coordinates if the feature is a point, otherwise use the center
let lon: number
let lat: number
if (feature.geometry.type === "Point") {
const coordinates = feature.geometry.coordinates
lon = coordinates[0]
lat = coordinates[1]
} else {
lon = feature.bbox[0] + (feature.bbox[2] - feature.bbox[0]) / 2
lat = feature.bbox[1] + (feature.bbox[3] - feature.bbox[1]) / 2
}
// Filter the items
let filter = ""
$: filteredItems = items
.filter((item) => item.displayName.toLowerCase().includes(filter.toLowerCase()))
.filter((item) => {
// Check if the feature is in the location set using the location-conflation library
const resolvedSet = loco.resolveLocationSet(item.locationSet)
if (resolvedSet) {
const setFeature: Feature<MultiPolygon> = resolvedSet.feature
// We actually have a location set, so we can check if the feature is in it, by determining if our point is inside of the MultiPolygon using @turf/boolean-point-in-polygon
return turf.booleanPointInPolygon([lon, lat], setFeature.geometry)
}
return true
})
.slice(0, 25)
/**
* Some interfaces for the NSI files
*/
interface NSIFile {
_meta: {
version: string
generated: string
url: string
hash: string
}
nsi: {
[path: string]: NSIEntry
}
}
interface NSIEntry {
properties: {
path: string
skipCollection?: boolean
preserveTags?: string[]
exclude: unknown
}
items: NSIItem[]
}
interface NSIItem {
displayName: string
id: string
locationSet: unknown
tags: {
[key: string]: string
}
fromTemplate?: boolean
}
</script>
<div>
<input type="text" placeholder="Filter entries" bind:value={filter} />
<div class="flex h-32 w-full flex-wrap overflow-hidden">
{#each filteredItems as item}
<div
class="m-1 h-fit rounded-full border border-black p-4 text-center"
on:click={() => {
value.setData(item.tags[tag])
}}
>
{item.displayName}
</div>
{/each}
</div>
</div>

View file

@ -19,6 +19,7 @@
import OpeningHoursInput from "./Helpers/OpeningHoursInput.svelte"
import SlopeInput from "./Helpers/SlopeInput.svelte"
import type { SpecialVisualizationState } from "../SpecialVisualization"
import NameSuggestionIndexInput from "./Helpers/NameSuggestionIndexInput.svelte"
export let type: ValidatorType
export let value: UIEventSource<string | object>
@ -50,4 +51,6 @@
<SlopeInput {value} {feature} {state} />
{:else if type === "wikidata"}
<ToSvelte construct={() => InputHelpers.constructWikidataHelper(value, properties)} />
{:else if type === "nsi"}
<NameSuggestionIndexInput {value} {feature} />
{/if}

View file

@ -28,6 +28,7 @@ import TagValidator from "./Validators/TagValidator"
import IdValidator from "./Validators/IdValidator"
import SlopeValidator from "./Validators/SlopeValidator"
import VeloparkValidator from "./Validators/VeloparkValidator"
import NameSuggestionIndexValidator from "./Validators/NameSuggestionIndexValidator"
export type ValidatorType = (typeof Validators.availableTypes)[number]
@ -60,6 +61,7 @@ export default class Validators {
"id",
"slope",
"velopark",
"nsi",
] as const
public static readonly AllValidators: ReadonlyArray<Validator> = [
@ -89,6 +91,7 @@ export default class Validators {
new IdValidator(),
new SlopeValidator(),
new VeloparkValidator(),
new NameSuggestionIndexValidator(),
]
private static _byType = Validators._byTypeConstructor()

View file

@ -0,0 +1,37 @@
import Title from "../../Base/Title"
import Combine from "../../Base/Combine"
import { Validator } from "../Validator"
import Table from "../../Base/Table"
export default class NameSuggestionIndexValidator extends Validator {
constructor() {
super(
"nsi",
new Combine([
"Gives a list of possible suggestions for a brand or operator tag.",
new Title("Helper arguments"),
new Table(
["name", "doc"],
[
[
"options",
new Combine([
"A JSON-object of type `{ main: string, key: string }`. ",
new Table(
["subarg", "doc"],
[
[
"main",
"The main tag to give suggestions for, e.g. `amenity=restaurant`.",
],
["key", "The key to give suggestions for, e.g. `brand`."],
]
),
]),
],
]
),
])
)
}
}