Skip to content

Commit ae6ff47

Browse files
astojiljgithub-actions[bot]
authored andcommitted
Enable SD-HD conflation support for traffic symbols.
GitOrigin-RevId: 5c8339890d4c29670907ca4e9e8f2bbe7036b852
1 parent f5e1955 commit ae6ff47

2 files changed

Lines changed: 25 additions & 4 deletions

File tree

3d-style/data/frc_road_classes.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,13 @@ const roadTypeToFrcMap: Record<string, number> = {
1313
};
1414

1515
export function featureFrcLevel(featureProperties: Record<string, unknown>): number | null {
16-
const cls = featureProperties['class'];
17-
if (typeof cls !== 'string') return null;
18-
const frc = roadTypeToFrcMap[cls];
19-
return frc !== undefined ? frc : null;
16+
for (const key of ['class', 'incident_class']) {
17+
const cls = featureProperties[key];
18+
if (typeof cls !== 'string') continue;
19+
const frc = roadTypeToFrcMap[cls];
20+
if (frc !== undefined) return frc;
21+
}
22+
return null;
2023
}
2124

2225
export function isFeatureCoveredByFrcMask(featureProperties: Record<string, unknown>, frcMask: number): boolean {

test/unit/source/frc_coverage.test.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,19 @@ describe('frc_road_classes', () => {
7373
test('missing class returns null', () => {
7474
expect(featureFrcLevel({})).toBeNull();
7575
});
76+
77+
test('incident_class used as fallback when class is absent', () => {
78+
expect(featureFrcLevel({'incident_class': 'motorway'})).toBe(0);
79+
expect(featureFrcLevel({'incident_class': 'primary'})).toBe(2);
80+
});
81+
82+
test('class takes precedence over incident_class', () => {
83+
expect(featureFrcLevel({'class': 'motorway', 'incident_class': 'service'})).toBe(0);
84+
});
85+
86+
test('unknown incident_class returns null', () => {
87+
expect(featureFrcLevel({'incident_class': 'aeroway'})).toBeNull();
88+
});
7689
});
7790

7891
describe('isFeatureCoveredByFrcMask', () => {
@@ -101,6 +114,11 @@ describe('frc_road_classes', () => {
101114
expect(isFeatureCoveredByFrcMask({class: 'primary'}, mask)).toBe(true);
102115
expect(isFeatureCoveredByFrcMask({class: 'secondary'}, mask)).toBe(false);
103116
});
117+
118+
test('incident_class fallback works in coverage check', () => {
119+
expect(isFeatureCoveredByFrcMask({'incident_class': 'motorway'}, 0b1)).toBe(true);
120+
expect(isFeatureCoveredByFrcMask({'incident_class': 'motorway'}, 0b10)).toBe(false);
121+
});
104122
});
105123

106124
describe('matchesCoverageSourceLayer', () => {

0 commit comments

Comments
 (0)