From cc7447fa3e9a4f56f948b65957306e91b423e906 Mon Sep 17 00:00:00 2001 From: nilsnolde Date: Sat, 31 Jan 2026 23:23:37 +0100 Subject: [PATCH] filter falsey bools & live traffic --- src/components/map/parts/tiles-constants.ts | 58 ++++++++++++++++++- src/components/map/parts/tiles-info-popup.tsx | 33 ++++++----- src/components/map/parts/tiles-property.tsx | 2 +- 3 files changed, 76 insertions(+), 17 deletions(-) diff --git a/src/components/map/parts/tiles-constants.ts b/src/components/map/parts/tiles-constants.ts index b708358..40fd472 100644 --- a/src/components/map/parts/tiles-constants.ts +++ b/src/components/map/parts/tiles-constants.ts @@ -107,7 +107,7 @@ export const propertyNameMappings: Record> = { surface: surfaceNames, cyclelane: cyclelaneNames, sac_scale: sacScaleNames, - node_type: nodeTypeNames, + type: nodeTypeNames, intersection_type: intersectionTypeNames, }; @@ -140,3 +140,59 @@ export const bitmaskPropertyMappings: Record> = { access: accessFlagNames, bike_network: bikeNetworkFlagNames, }; + +const hideWhenFalseKeys: string[] = [ + // edges + 'tunnel', + 'bridge', + 'roundabout', + 'shortcut', + 'leaves_tile', + 'toll', + 'destonly', + 'destonly_hgv', + 'indoor', + 'truck_route', + 'country_crossing', + 'unpaved', + 'ramp', + 'internal', + 'shoulder', + 'dismount', + 'use_sidepath', + 'sidewalk_left', + 'sidewalk_right', + 'bss_connection', + 'lit', + 'not_thru', + 'part_of_complex_restriction', + 'deadend:fwd', + 'deadend:bwd', + 'traffic_signal:fwd', + 'traffic_signal:bwd', + 'stop_sign:fwd', + 'stop_sign:bwd', + 'yield_sign:fwd', + 'yield_sign:bwd', + // nodes + 'traffic_signal', + 'drive_on_right', + 'tagged_access', + 'private_access', + 'cash_only_toll', + 'mode_change_allowed', + 'named_intersection', +]; + +export function shouldHideProperty(key: string, value: unknown): boolean { + if (typeof value === 'boolean' && !value && hideWhenFalseKeys.includes(key)) { + return true; + } else if ( + typeof value == 'number' && + key.includes('speed') && + (value == 0 || value == 254) + ) { + return true; + } + return false; +} diff --git a/src/components/map/parts/tiles-info-popup.tsx b/src/components/map/parts/tiles-info-popup.tsx index cb5590b..de81a5d 100644 --- a/src/components/map/parts/tiles-info-popup.tsx +++ b/src/components/map/parts/tiles-info-popup.tsx @@ -3,6 +3,7 @@ import { X, Route, MapPin } from 'lucide-react'; import type { MapGeoJSONFeature } from 'maplibre-gl'; import { TilesProperty } from './tiles-property'; +import { shouldHideProperty } from './tiles-constants'; interface TilesInfoPopupProps { features: MapGeoJSONFeature[]; @@ -51,21 +52,23 @@ export function TilesInfoPopup({ features, onClose }: TilesInfoPopupProps) {
- {Object.entries(properties).map(([key, value], idx) => ( - - - - - ))} + {Object.entries(properties) + .filter(([key, value]) => !shouldHideProperty(key, value)) + .map(([key, value], idx) => ( + + + + + ))}
- {key} - - -
+ {key} + + +
diff --git a/src/components/map/parts/tiles-property.tsx b/src/components/map/parts/tiles-property.tsx index 5c06647..54e0816 100644 --- a/src/components/map/parts/tiles-property.tsx +++ b/src/components/map/parts/tiles-property.tsx @@ -105,7 +105,7 @@ export function TilesProperty({ if ( propertyKey.includes('speed') && - !(propertyKey.includes('congestion') || propertyKey.includes('breakpoint')) + !(propertyKey.includes('congestion') || propertyKey.includes('bp')) ) { return (