( camera: Camera, targetModelId: CameraModelId, threshold: number = DEFAULT_CONVERSION_THRESHOLD )
| 62 | * @returns Conversion result with new parameters or error |
| 63 | */ |
| 64 | export function convertCameraModel( |
| 65 | camera: Camera, |
| 66 | targetModelId: CameraModelId, |
| 67 | threshold: number = DEFAULT_CONVERSION_THRESHOLD |
| 68 | ): ConversionResult { |
| 69 | const { modelId: fromModel, params } = camera; |
| 70 | |
| 71 | // Same model - no conversion needed |
| 72 | if (fromModel === targetModelId) { |
| 73 | return { type: 'exact', params: [...params] }; |
| 74 | } |
| 75 | |
| 76 | // Check compatibility first |
| 77 | const compatibility = canConvertModel(fromModel, targetModelId); |
| 78 | if (compatibility === 'incompatible') { |
| 79 | return { |
| 80 | type: 'incompatible', |
| 81 | reason: getIncompatibilityReason(fromModel, targetModelId), |
| 82 | }; |
| 83 | } |
| 84 | |
| 85 | // Perform the conversion |
| 86 | return performConversion(fromModel, targetModelId, params, threshold); |
| 87 | } |
| 88 | |
| 89 | function getIncompatibilityReason(from: CameraModelId, to: CameraModelId): string { |
| 90 | const fromName = getModelName(from); |
no test coverage detected