From 03dcffdf3d48869dff8952e43a8d6a2528187403 Mon Sep 17 00:00:00 2001 From: Vaibhav Singh Date: Wed, 11 Mar 2026 14:20:17 +0530 Subject: [PATCH 1/5] Add tag-based search to feature list (e.g. building=yes) --- modules/ui/feature_list.js | 60 +++++++++++++++++++++++++++++++++----- 1 file changed, 53 insertions(+), 7 deletions(-) diff --git a/modules/ui/feature_list.js b/modules/ui/feature_list.js index 506d5bb674..8951d356df 100644 --- a/modules/ui/feature_list.js +++ b/modules/ui/feature_list.js @@ -98,13 +98,31 @@ export function uiFeatureList(context) { function keypress(d3_event) { - var q = search.property('value'), - items = list.selectAll('.feature-list-item'); - if (d3_event.keyCode === 13 && // ↩ Return - q.length && - items.size()) { - click(d3_event, items.datum()); + var q = search.property('value'), + items = list.selectAll('.feature-list-item'); + + if (d3_event.keyCode === 13 && q.length && items.size()) { + + const tagMatch = q.match(/^([a-zA-Z0-9:_-]+)=([a-zA-Z0-9:_-]+)$/); + + if (tagMatch) { + const ids = []; + + items.each(function(d) { + if (d.entity) { + ids.push(d.entity.id); + } + }); + + if (ids.length) { + context.enter(modeSelect(context, ids)); } + + return; + } + + click(d3_event, items.datum()); + } } @@ -131,6 +149,7 @@ export function uiFeatureList(context) { var graph = context.graph(); var visibleCenter = context.map().extent().center(); var q = search.property('value').toLowerCase().trim(); + const tagMatch = q.match(/^([a-zA-Z0-9:_-]+)=([a-zA-Z0-9:_-]+)$/); if (!q) return []; @@ -183,6 +202,33 @@ export function uiFeatureList(context) { } var allEntities = graph.entities; + const tagResults = []; + + if (tagMatch) { + const key = tagMatch[1]; + const value = tagMatch[2]; + const extent = context.map().extent(); + + for (let entityID in allEntities) { + let entity = allEntities[entityID]; + if (!entity || !entity.tags) continue; + + if (entity.tags[key] === value) { + + if (!extent.intersects(entity.extent(graph))) continue; + + tagResults.push({ + id: entity.id, + entity: entity, + geometry: entity.geometry(graph), + type: utilDisplayType(entity.id), + name: utilDisplayName(entity) || key + '=' + value + }); + } + + if (tagResults.length > 100) break; + } + } const localResults = []; for (var id in allEntities) { var entity = allEntities[id]; @@ -269,7 +315,7 @@ export function uiFeatureList(context) { }); } - return [...idResult, ...localResults, ...coordResult, ...geocodeResults, ...extraResults]; + return [...tagResults, ...idResult, ...localResults, ...coordResult, ...geocodeResults, ...extraResults]; } From 7509f121ae88b188dd456fd5874447810b992e35 Mon Sep 17 00:00:00 2001 From: Vaibhav Singh Date: Fri, 13 Mar 2026 19:47:57 +0530 Subject: [PATCH 2/5] Improve indentation for cleaner diff --- modules/ui/feature_list.js | 56 +++++++++++++++++--------------------- 1 file changed, 25 insertions(+), 31 deletions(-) diff --git a/modules/ui/feature_list.js b/modules/ui/feature_list.js index 8951d356df..2ca97a25c3 100644 --- a/modules/ui/feature_list.js +++ b/modules/ui/feature_list.js @@ -98,31 +98,29 @@ export function uiFeatureList(context) { function keypress(d3_event) { - var q = search.property('value'), - items = list.selectAll('.feature-list-item'); + var q = search.property('value'), + items = list.selectAll('.feature-list-item'); + if (d3_event.keyCode === 13 && // ↩ Return + q.length && + items.size()) { + const tagMatch = q.match(/^([a-zA-Z0-9:_-]+)=([a-zA-Z0-9:_-]+)$/); - if (d3_event.keyCode === 13 && q.length && items.size()) { + if (tagMatch) { + const ids = []; - const tagMatch = q.match(/^([a-zA-Z0-9:_-]+)=([a-zA-Z0-9:_-]+)$/); - - if (tagMatch) { - const ids = []; - - items.each(function(d) { + items.each(function(d) { if (d.entity) { ids.push(d.entity.id); } - }); - - if (ids.length) { - context.enter(modeSelect(context, ids)); - } - - return; - } + }); - click(d3_event, items.datum()); - } + if (ids.length) { + context.enter(modeSelect(context, ids)); + } + return; + } + click(d3_event, items.datum()); + } } @@ -201,20 +199,18 @@ export function uiFeatureList(context) { }); } - var allEntities = graph.entities; - const tagResults = []; + var allEntities = graph.entities; + const tagResults = []; - if (tagMatch) { + if (tagMatch) { const key = tagMatch[1]; const value = tagMatch[2]; const extent = context.map().extent(); - for (let entityID in allEntities) { + for (let entityID in allEntities) { let entity = allEntities[entityID]; if (!entity || !entity.tags) continue; - - if (entity.tags[key] === value) { - + if (entity.tags[key] === value) { if (!extent.intersects(entity.extent(graph))) continue; tagResults.push({ @@ -223,12 +219,10 @@ export function uiFeatureList(context) { geometry: entity.geometry(graph), type: utilDisplayType(entity.id), name: utilDisplayName(entity) || key + '=' + value - }); - } + } );} - if (tagResults.length > 100) break; - } - } + if (tagResults.length > 100) break; + }} const localResults = []; for (var id in allEntities) { var entity = allEntities[id]; From 96a99ef180ceba487c11a120bf6319b432ff9c45 Mon Sep 17 00:00:00 2001 From: Vaibhav Singh Date: Sat, 14 Mar 2026 14:11:16 +0530 Subject: [PATCH 3/5] Remove whitespace changes --- modules/ui/feature_list.js | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/modules/ui/feature_list.js b/modules/ui/feature_list.js index 2ca97a25c3..8699dc82ca 100644 --- a/modules/ui/feature_list.js +++ b/modules/ui/feature_list.js @@ -105,22 +105,19 @@ export function uiFeatureList(context) { items.size()) { const tagMatch = q.match(/^([a-zA-Z0-9:_-]+)=([a-zA-Z0-9:_-]+)$/); - if (tagMatch) { + if (tagMatch) { const ids = []; - items.each(function(d) { - if (d.entity) { - ids.push(d.entity.id); - } + if (d.entity) { + ids.push(d.entity.id);} }); - if (ids.length) { context.enter(modeSelect(context, ids)); } - return; - } - click(d3_event, items.datum()); - } + return; + } + click(d3_event, items.datum()); + } } @@ -208,8 +205,8 @@ export function uiFeatureList(context) { const extent = context.map().extent(); for (let entityID in allEntities) { - let entity = allEntities[entityID]; - if (!entity || !entity.tags) continue; + let entity = allEntities[entityID]; + if (!entity || !entity.tags) continue; if (entity.tags[key] === value) { if (!extent.intersects(entity.extent(graph))) continue; @@ -219,7 +216,7 @@ export function uiFeatureList(context) { geometry: entity.geometry(graph), type: utilDisplayType(entity.id), name: utilDisplayName(entity) || key + '=' + value - } );} + });} if (tagResults.length > 100) break; }} From c0dd68c5efe4104fe8f5872db9764b731c56e895 Mon Sep 17 00:00:00 2001 From: Vaibhav Singh Date: Sat, 14 Mar 2026 15:10:46 +0530 Subject: [PATCH 4/5] Clean up indentation and add tag-based search support --- modules/ui/feature_list.js | 74 +++++++++++++++++++------------------- 1 file changed, 38 insertions(+), 36 deletions(-) diff --git a/modules/ui/feature_list.js b/modules/ui/feature_list.js index 8699dc82ca..433191b04e 100644 --- a/modules/ui/feature_list.js +++ b/modules/ui/feature_list.js @@ -98,25 +98,26 @@ export function uiFeatureList(context) { function keypress(d3_event) { - var q = search.property('value'), + var q = search.property('value'), items = list.selectAll('.feature-list-item'); if (d3_event.keyCode === 13 && // ↩ Return q.length && items.size()) { const tagMatch = q.match(/^([a-zA-Z0-9:_-]+)=([a-zA-Z0-9:_-]+)$/); + if (tagMatch) { + const ids = []; - if (tagMatch) { - const ids = []; - items.each(function(d) { - if (d.entity) { - ids.push(d.entity.id);} - }); - if (ids.length) { - context.enter(modeSelect(context, ids)); + items.each(function(d) { + if (d.entity) { + ids.push(d.entity.id); + } + }); + if (ids.length) { + context.enter(modeSelect(context, ids)); + } + return; } - return; - } - click(d3_event, items.datum()); + click(d3_event, items.datum()); } } @@ -196,30 +197,31 @@ export function uiFeatureList(context) { }); } - var allEntities = graph.entities; - const tagResults = []; - - if (tagMatch) { - const key = tagMatch[1]; - const value = tagMatch[2]; - const extent = context.map().extent(); - - for (let entityID in allEntities) { - let entity = allEntities[entityID]; - if (!entity || !entity.tags) continue; - if (entity.tags[key] === value) { - if (!extent.intersects(entity.extent(graph))) continue; - - tagResults.push({ - id: entity.id, - entity: entity, - geometry: entity.geometry(graph), - type: utilDisplayType(entity.id), - name: utilDisplayName(entity) || key + '=' + value - });} - - if (tagResults.length > 100) break; - }} + var allEntities = graph.entities; + const tagResults = []; + if (tagMatch) { + const key = tagMatch[1]; + const value = tagMatch[2]; + const extent = context.map().extent(); + + for (var id in allEntities) { + var entity = allEntities[id]; + if (!entity || !entity.tags) continue; + + if (entity.tags[key] === value) { + if (!extent.intersects(entity.extent(graph))) continue; + + tagResults.push({ + id: entity.id, + entity: entity, + geometry: entity.geometry(graph), + type: utilDisplayType(entity.id), + name: utilDisplayName(entity) || key + '=' + value + }); + } + if (tagResults.length > 100) break; + } + } const localResults = []; for (var id in allEntities) { var entity = allEntities[id]; From 5d66fbe0ca4df7afe87fb46c39c9264c5ecfb460 Mon Sep 17 00:00:00 2001 From: Vaibhav Singh Date: Sat, 14 Mar 2026 22:33:24 +0530 Subject: [PATCH 5/5] Store tag regex in reusable constant --- modules/ui/feature_list.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/modules/ui/feature_list.js b/modules/ui/feature_list.js index 433191b04e..48d0f97ad1 100644 --- a/modules/ui/feature_list.js +++ b/modules/ui/feature_list.js @@ -22,6 +22,7 @@ import { utilHighlightEntities, utilNoAuto } from '../util'; +const tagRegex = /^([a-zA-Z0-9:_-]+)=([a-zA-Z0-9:_-]+)$/; export const idMatch = q => { @@ -103,7 +104,7 @@ export function uiFeatureList(context) { if (d3_event.keyCode === 13 && // ↩ Return q.length && items.size()) { - const tagMatch = q.match(/^([a-zA-Z0-9:_-]+)=([a-zA-Z0-9:_-]+)$/); + const tagMatch = q.match(tagRegex); if (tagMatch) { const ids = []; @@ -145,7 +146,7 @@ export function uiFeatureList(context) { var graph = context.graph(); var visibleCenter = context.map().extent().center(); var q = search.property('value').toLowerCase().trim(); - const tagMatch = q.match(/^([a-zA-Z0-9:_-]+)=([a-zA-Z0-9:_-]+)$/); + const tagMatch = q.match(tagRegex); if (!q) return [];