Skip to content

Commit

Permalink
Categorize search results into the origins that can be queried for be…
Browse files Browse the repository at this point in the history
…tter UX
  • Loading branch information
marionb committed Nov 13, 2024
1 parent 4c7f7af commit 8f14c55
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 34 deletions.
6 changes: 2 additions & 4 deletions src/app/_services/map.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down Expand Up @@ -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],
Expand Down Expand Up @@ -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 '
Expand Down
45 changes: 15 additions & 30 deletions src/app/welcome/map/map.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand Down Expand Up @@ -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
Expand All @@ -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;
}
Expand Down

0 comments on commit 8f14c55

Please sign in to comment.