Improve overpass efficiency by omitting profiles which are subsumed by any other

This commit is contained in:
stopflock
2025-12-10 15:26:42 -06:00
parent e6b18bf89b
commit 4a4fc30828
4 changed files with 136 additions and 5 deletions
+6 -1
View File
@@ -29,6 +29,8 @@ class NodeProviderWithCache extends ChangeNotifier {
if (enabledProfiles.isEmpty) return [];
// Filter nodes to only show those matching enabled profiles
// Note: This uses ALL enabled profiles for filtering, even though Overpass queries
// may be deduplicated for efficiency (broader profiles capture nodes for specific ones)
return allNodes.where((node) {
return _matchesAnyProfile(node, enabledProfiles);
}).toList();
@@ -107,9 +109,12 @@ class NodeProviderWithCache extends ChangeNotifier {
return false;
}
/// Check if a node matches a specific profile (all profile tags must match)
/// Check if a node matches a specific profile (all non-empty profile tags must match)
bool _nodeMatchesProfile(OsmNode node, NodeProfile profile) {
for (final entry in profile.tags.entries) {
// Skip empty values - they are used for refinement UI, not matching
if (entry.value.trim().isEmpty) continue;
if (node.tags[entry.key] != entry.value) return false;
}
return true;