From 5242baa8116ca8fa10bb9a0bb0ba36d8dc8b6bd5 Mon Sep 17 00:00:00 2001 From: Jakob Miksch Date: Wed, 25 Dec 2024 17:41:07 +0100 Subject: [PATCH] Update UI --- web-client/src/App.vue | 40 ++++++++++++++++++--------- web-client/src/components/OsmInfo.vue | 36 ++++++++++++++++++++++++ 2 files changed, 63 insertions(+), 13 deletions(-) create mode 100644 web-client/src/components/OsmInfo.vue diff --git a/web-client/src/App.vue b/web-client/src/App.vue index cdda0c0..cb3040b 100644 --- a/web-client/src/App.vue +++ b/web-client/src/App.vue @@ -9,20 +9,15 @@ color: zoom < minZoomForQuery ? 'red' : 'green' }">Zoom Level: {{ zoom?.toFixed(2) }}

Search Radius: {{ extractedSearchRadius }} meter

-

{{ displayedFeatures.length }} features found

+

{{ foundFeatures.length }} features found

-

- {{ - // @ts-ignore - feature.geometry ? '' : 'No geometry, because outside of BBOX' }} - - {{ feature }} -

+ +
- + @@ -35,6 +30,8 @@ import 'ol/ol.css' import VectorSource from 'ol/source/Vector' import VectorLayer from 'ol/layer/Vector' +import OsmInfo from './components/OsmInfo.vue' + import {GeoJSON} from "ol/format" import XYZ from 'ol/source/XYZ' import { Feature } from 'ol' @@ -46,20 +43,37 @@ useGeographic() const minZoomForQuery = 14 const { map, onMapClick, extent, zoom } = useOl() -const displayedFeatures = ref([]) +const foundFeatures = ref([]) const functionName = ref("") const functionNameOptions = ref() const clickedLatitude = ref(NaN) const clickedLongitude = ref(NaN) +enum QueryType { + ENCLOSING = 'enclosing', + AROUND = 'around' +} + // @ts-ignore const extractedSearchRadius = computed(() => Math.round(10 * Math.pow(1.5, 19 - zoom.value))) +const displayedResult = computed(() => foundFeatures.value.map(feature => { + const { geometry, properties } = feature + const { query_type, osm_id, osm_type, tags, geometry_type } = properties + const url = `https://osm.org/${osm_type}/${osm_id}` + const hidden = !geometry + return { url, geometry_type, tags, query_type, osm_id, osm_type, hidden } +})) + +const enclosingFeatures = computed(() => displayedResult.value.filter(result => result.query_type === QueryType.ENCLOSING)) + +const aroundFeatures = computed(()=>displayedResult.value.filter(result => result.query_type === QueryType.AROUND)) + const resultVectorSource = new VectorSource() const pointDataSource = new VectorSource() const reset = (() => { - displayedFeatures.value = [] + foundFeatures.value = [] resultVectorSource.clear() pointDataSource.clear() }) @@ -69,7 +83,7 @@ const triggerRequest = () => { // @ts-ignore if (zoom.value < minZoomForQuery) { // @ts-ignore - alert(`Zoom must be below ${minZoom}`) + alert(`Zoom must be below ${minZoomForQuery}`) return } @@ -84,7 +98,7 @@ const triggerRequest = () => { .then(geojson => { const { features } = geojson - displayedFeatures.value = features + foundFeatures.value = features const olFeatures = new GeoJSON().readFeatures(geojson) as any // TODO: fix TS anys diff --git a/web-client/src/components/OsmInfo.vue b/web-client/src/components/OsmInfo.vue new file mode 100644 index 0000000..10b368a --- /dev/null +++ b/web-client/src/components/OsmInfo.vue @@ -0,0 +1,36 @@ + + + + +