chore: culvert addition
This commit is contained in:
119
src/constants/detectionModeConfig.ts
Normal file
119
src/constants/detectionModeConfig.ts
Normal file
@@ -0,0 +1,119 @@
|
||||
/**
|
||||
* Detection mode configurations to support dynamic UI behavior
|
||||
*/
|
||||
|
||||
export interface DetectionTypeConfig {
|
||||
id: string;
|
||||
label: string;
|
||||
color: string;
|
||||
countKey: string; // The key in summary object from API (e.g., unique_pothole)
|
||||
listKey: string; // The key for the list of detections in DetectionData (e.g., pothole_list)
|
||||
frameCountKey: string; // The key in per-frame count object (e.g., pothole)
|
||||
}
|
||||
|
||||
export interface DetectionModeConfig {
|
||||
id: string;
|
||||
label: string;
|
||||
enabledTypes: string[]; // IDs of detection types to show in this mode
|
||||
}
|
||||
|
||||
export const DETECTION_TYPES: Record<string, DetectionTypeConfig> = {
|
||||
pothole: {
|
||||
id: 'pothole',
|
||||
label: 'Pothole',
|
||||
color: '#ef4444',
|
||||
countKey: 'unique_pothole',
|
||||
listKey: 'pothole_list',
|
||||
frameCountKey: 'pothole',
|
||||
},
|
||||
defected_sign_board: {
|
||||
id: 'defected_sign_board',
|
||||
label: 'Defect Sign Board',
|
||||
color: '#3b82f6',
|
||||
countKey: 'unique_defected_sign_board',
|
||||
listKey: 'defected_sign_board_list',
|
||||
frameCountKey: 'defected_sign_board',
|
||||
},
|
||||
road_crack: {
|
||||
id: 'road_crack',
|
||||
label: 'Road Crack',
|
||||
color: '#f59e0b',
|
||||
countKey: 'unique_road_crack',
|
||||
listKey: 'road_crack_list',
|
||||
frameCountKey: 'road_crack',
|
||||
},
|
||||
damaged_road_marking: {
|
||||
id: 'damaged_road_marking',
|
||||
label: 'Damage Road Mark',
|
||||
color: '#6366f1',
|
||||
countKey: 'unique_damaged_road_marking',
|
||||
listKey: 'damaged_road_marking_list',
|
||||
frameCountKey: 'damaged_road_marking',
|
||||
},
|
||||
good_sign_board: {
|
||||
id: 'good_sign_board',
|
||||
label: 'Good Sign Board',
|
||||
color: '#10b981',
|
||||
countKey: 'unique_good_sign_board',
|
||||
listKey: 'good_sign_board_list',
|
||||
frameCountKey: 'good_sign_board',
|
||||
},
|
||||
good_culvert: {
|
||||
id: 'good_culvert',
|
||||
label: 'Good Culvert',
|
||||
color: '#10b981',
|
||||
countKey: 'unique_good_culvert',
|
||||
listKey: 'good_culvert_list',
|
||||
frameCountKey: 'good_culvert',
|
||||
},
|
||||
defective_culvert: {
|
||||
id: 'defective_culvert',
|
||||
label: 'Defective Culvert',
|
||||
color: '#ef4444',
|
||||
countKey: 'unique_defective_culvert',
|
||||
listKey: 'defective_culvert_list',
|
||||
frameCountKey: 'defective_culvert',
|
||||
},
|
||||
};
|
||||
|
||||
export const DETECTION_MODES: Record<string, DetectionModeConfig> = {
|
||||
'pothole-detection': {
|
||||
id: 'pothole-detection',
|
||||
label: 'Pothole Detection',
|
||||
enabledTypes: ['pothole', 'road_crack', 'damaged_road_marking'],
|
||||
},
|
||||
'sign-board-detection': {
|
||||
id: 'sign-board-detection',
|
||||
label: 'Signboard Detection',
|
||||
enabledTypes: ['defected_sign_board', 'good_sign_board'],
|
||||
},
|
||||
'pot-sign-detection': {
|
||||
id: 'pot-sign-detection',
|
||||
label: 'Pothole & Signboard Detection',
|
||||
enabledTypes: [
|
||||
'pothole',
|
||||
'defected_sign_board',
|
||||
'road_crack',
|
||||
'damaged_road_marking',
|
||||
'good_sign_board',
|
||||
],
|
||||
},
|
||||
culvert_detection: {
|
||||
id: 'culvert_detection',
|
||||
label: 'Culvert Detection',
|
||||
enabledTypes: ['good_culvert', 'defective_culvert'],
|
||||
},
|
||||
};
|
||||
|
||||
// Fallback config for unknown modes
|
||||
export const DEFAULT_DETECTION_MODE: DetectionModeConfig = DETECTION_MODES['pot-sign-detection'];
|
||||
|
||||
export const getDetectionModeConfig = (mode?: string): DetectionModeConfig => {
|
||||
if (!mode) return DEFAULT_DETECTION_MODE;
|
||||
return DETECTION_MODES[mode] || DEFAULT_DETECTION_MODE;
|
||||
};
|
||||
|
||||
export const getEnabledDetectionTypes = (mode?: string): DetectionTypeConfig[] => {
|
||||
const config = getDetectionModeConfig(mode);
|
||||
return config.enabledTypes.map((typeId) => DETECTION_TYPES[typeId]).filter(Boolean);
|
||||
};
|
||||
Reference in New Issue
Block a user