From 3daa2d11f9a56bd608aedc9aed2119fc12476be8 Mon Sep 17 00:00:00 2001 From: evlist Date: Fri, 3 Feb 2023 17:46:56 +0100 Subject: [PATCH] Filter our multiple occurrences of OSM features in --- src/components/infos/Infos.tsx | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/src/components/infos/Infos.tsx b/src/components/infos/Infos.tsx index cd9b450..10fda39 100644 --- a/src/components/infos/Infos.tsx +++ b/src/components/infos/Infos.tsx @@ -55,9 +55,18 @@ export const clickHandler = (event: any) => { } }); selectedFeatures = features.filter((feature: any) => feature.get('context')); - vectorLayerFeatures = features.filter( - (feature: any) => !feature.get('context') - ); + let osmIds = new Set(); + vectorLayerFeatures = features.filter((feature: any) => { + if (feature.get('context')) { + return false; + } + const osmId = feature.get('osm_id'); + if (osmIds.has(osmId)) { + return false; + } + osmIds.add(osmId); + return true; + }); selectedFeatures.sort((f1: Feature, f2: Feature) => { const ctx1 = f1.get('context'); @@ -184,7 +193,6 @@ const Infos: Component<{}> = (props) => { title={ <>
- {`${feature.get('class')} ${feature.get('name') || ''}`}
@@ -195,8 +203,6 @@ const Infos: Component<{}> = (props) => { onClick={async () => { await Browser.open({ url: `https://www.qwant.com/?q=${encodeURIComponent( - feature.get('class') + - ' ' + feature.get('name') || '' )}&t=web`, });