Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 57 additions & 1 deletion src/components/map/parts/tiles-constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ export const propertyNameMappings: Record<string, Record<number, string>> = {
surface: surfaceNames,
cyclelane: cyclelaneNames,
sac_scale: sacScaleNames,
node_type: nodeTypeNames,
type: nodeTypeNames,
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this was actually a tiny bug

intersection_type: intersectionTypeNames,
};

Expand Down Expand Up @@ -140,3 +140,59 @@ export const bitmaskPropertyMappings: Record<string, Record<number, string>> = {
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)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

value == 254 would also hide e.g. breakpoint2 == 254 which could be valid right?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

since it has the key live_speed:<dir>:breakpoint2

) {
return true;
}
return false;
}
33 changes: 18 additions & 15 deletions src/components/map/parts/tiles-info-popup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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[];
Expand Down Expand Up @@ -51,21 +52,23 @@ export function TilesInfoPopup({ features, onClose }: TilesInfoPopupProps) {
<div className="rounded-md border border-border overflow-hidden">
<table className="w-full text-xs">
<tbody>
{Object.entries(properties).map(([key, value], idx) => (
<tr
key={key}
className={
idx % 2 === 0 ? 'bg-muted/30' : 'bg-transparent'
}
>
<td className="py-1.5 px-2 text-muted-foreground whitespace-nowrap font-bold">
{key}
</td>
<td className="py-1.5 px-2 text-right font-medium">
<TilesProperty propertyKey={key} value={value} />
</td>
</tr>
))}
{Object.entries(properties)
.filter(([key, value]) => !shouldHideProperty(key, value))
.map(([key, value], idx) => (
<tr
key={key}
className={
idx % 2 === 0 ? 'bg-muted/30' : 'bg-transparent'
}
>
<td className="py-1.5 px-2 text-muted-foreground whitespace-nowrap font-bold">
{key}
</td>
<td className="py-1.5 px-2 text-right font-medium">
<TilesProperty propertyKey={key} value={value} />
</td>
</tr>
))}
</tbody>
</table>
</div>
Expand Down
2 changes: 1 addition & 1 deletion src/components/map/parts/tiles-property.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ export function TilesProperty({

if (
propertyKey.includes('speed') &&
!(propertyKey.includes('congestion') || propertyKey.includes('breakpoint'))
!(propertyKey.includes('congestion') || propertyKey.includes('bp'))
) {
return (
<span className="font-mono text-xs">
Expand Down
Loading