From 8f14c55a373ff25ceca6645729251b5ee6d891fa Mon Sep 17 00:00:00 2001 From: Marion Date: Wed, 13 Nov 2024 10:21:57 +0100 Subject: [PATCH] Categorize search results into the origins that can be queried for better UX --- src/app/_services/map.service.ts | 6 ++-- src/app/welcome/map/map.component.ts | 45 ++++++++++------------------ 2 files changed, 17 insertions(+), 34 deletions(-) diff --git a/src/app/_services/map.service.ts b/src/app/_services/map.service.ts index bc415275..61abbad0 100644 --- a/src/app/_services/map.service.ts +++ b/src/app/_services/map.service.ts @@ -291,7 +291,7 @@ export class MapService { } const url = new URL(urlText); url.searchParams.append('searchText', inputText); - url.searchParams.append('limit', '5'); // TODO find a good limit or this + url.searchParams.append('limit', '5'); // TODO find a good limit for this url.searchParams.append('geometryFormat', 'geojson'); url.searchParams.append('type', 'locations'); url.searchParams.append('sr', '2056'); @@ -322,9 +322,6 @@ export class MapService { const [minX, minY] = coords[0]; const [maxX, maxY] = coords[1]; - console.log(coords); - console.log(minX, minY, maxX, maxY); - const polygonCoords = [ [minX, minY], [maxX, minY], @@ -396,6 +393,7 @@ export class MapService { return; } const EPSG = this.configService.config.epsg || 'EPSG2056'; + // TODO is this correct or is this cauing the projection shift -> check this proj4.defs(EPSG, '+proj=somerc +lat_0=46.95240555555556 +lon_0=7.439583333333333' + ' +k_0=1 +x_0=2600000 +y_0=1200000 +ellps=bessel ' diff --git a/src/app/welcome/map/map.component.ts b/src/app/welcome/map/map.component.ts index 21ccd7a9..aba33f0c 100644 --- a/src/app/welcome/map/map.component.ts +++ b/src/app/welcome/map/map.component.ts @@ -11,29 +11,14 @@ import Feature from 'ol/Feature'; import {MatDialog} from '@angular/material/dialog'; import {ManualentryComponent} from './manualentry/manualentry.component'; -export const nameOfCategoryForGeocoder: { [prop: string]: string; } = { - neophytes: 'Plantes invasives', - search_satac: 'N° SATAC', - search_entree_sortie: 'Entrée/sortie autoroute', - rt16_giratoires: 'Giratoires', - batiments_ofs: 'Bâtiments regBL et n° egid', - axe_mistra: 'Routes et axes', - search_arrets_tp: 'Arrêts transports publics', - ImmeublesCantonHistorique: 'Biens-fonds historiques', - point_interet: 'Points d\'intérêt', - axe_rue: 'Axes et rues', - nom_local_lieu_dit: 'Noms locaux et lieux-dits', - search_cours_eau: 'Cours d\'eau', - ImmeublesCanton: 'Biens-fonds', - search_fo_administrations: 'Administrations forestières', - search_uap_publique: 'Unité d\'aménagement publique', - adresses_sitn: 'Adresses', - recenter_to: 'Recentrer sur', - localite: 'Localité', - search_fo09: 'Secours en forêt', - search_conc_hydr: 'Concessions hydrauliques', - communes: 'Communes', - cadastres: 'Cadastres', +export const nameOfCategoryForGeocoder: { [prop: string]: string; } = { // TODO this should be translated + zipcode: 'Ortschaftenverzeichnis PLZ', + gg25: 'Gemeinden', + district: 'Bezirke', + kantone: 'Kantone', + gazetteer: 'OEV Haltestellen', + address: 'Adressen', + parcel: 'Parzellen', }; @Component({ @@ -109,19 +94,19 @@ export class MapComponent implements OnInit { this.shouldDisplayClearButton = true; this.geocoderGroupOptions = []; - for (const feature of features) { // TODO the following part needs to be adapted for the swiss topo API search - const categoryId = feature.get('objectclass'); + for (const feature of features) { + const categoryId = feature.get('origin') || feature.get('origin') !== '' ? feature.get('origin') : 'Allgemein'; // TODO add to translation Allgemein let currentCategory = this.geocoderGroupOptions.find(x => x.id === categoryId); if (currentCategory) { currentCategory.items.push({ - label: categoryId, // TODO this should be a translated ctegory - feature + label: this.mapService.stripHtmlTags(feature.get('label')), + feature }); } else { currentCategory = { - id: feature.get('objectclass'), - label: feature.get('objectclass'), // TODO this should be a translated ctegory + id: categoryId, + label: nameOfCategoryForGeocoder[categoryId], items: [{ label: this.mapService.stripHtmlTags(feature.get('label')), feature @@ -138,7 +123,7 @@ export class MapComponent implements OnInit { return value.label; } - displayGeocoderResultOnTheMap(evt: MatAutocompleteSelectedEvent) { // TODO this adds the feature from the auto complete on the map + displayGeocoderResultOnTheMap(evt: MatAutocompleteSelectedEvent) { this.mapService.addFeatureFromGeocoderToDrawing(evt.option.value.feature); this.shouldDisplayClearButton = true; }