{"record":{"id":"46cd8984234a116a","repo":"gchq/CyberChef","slug":"invalid-co-ordinate-format-for-degrees-decimal-min","errorCode":null,"errorMessage":"Invalid co-ordinate format for Degrees Decimal Minutes.","messagePattern":"Invalid co-ordinate format for Degrees Decimal Minutes\\.","errorType":"exception","errorClass":"OperationError","httpStatus":null,"severity":"error","filePath":"src/core/lib/ConvertCoordinates.mjs","lineNumber":179,"sourceCode":"                    throw new OperationError(\"Invalid co-ordinate format for Degrees Minutes Seconds\");\n                }\n            } else {\n                // Not a pair, so only try to convert one set of co-ordinates\n                splitLat = splitInput(split[0]);\n                if (splitLat.length >= 3) {\n                    lat = convDMSToDD(splitLat[0], splitLat[1], splitLat[2]);\n                    latlon = new LatLonEllipsoidal(lat.degrees, lat.degrees);\n                } else {\n                    throw new OperationError(\"Invalid co-ordinate format for Degrees Minutes Seconds\");\n                }\n            }\n            break;\n        case \"Degrees Decimal Minutes\":\n            if (isPair) {\n                splitLat = splitInput(split[0]);\n                splitLong = splitInput(split[1]);\n                if (splitLat.length !== 2 || splitLong.length !== 2) {\n                    throw new OperationError(\"Invalid co-ordinate format for Degrees Decimal Minutes.\");\n                }\n                // Convert to decimal degrees, and then convert to a geodesy object\n                lat = convDDMToDD(splitLat[0], splitLat[1], 10);\n                lon = convDDMToDD(splitLong[0], splitLong[1], 10);\n                latlon = new LatLonEllipsoidal(lat.degrees, lon.degrees);\n            } else {\n                // Not a pair, so only try to convert one set of co-ordinates\n                splitLat = splitInput(input);\n                if (splitLat.length !== 2) {\n                    throw new OperationError(\"Invalid co-ordinate format for Degrees Decimal Minutes.\");\n                }\n                lat = convDDMToDD(splitLat[0], splitLat[1], 10);\n                latlon = new LatLonEllipsoidal(lat.degrees, lat.degrees);\n            }\n            break;\n        case \"Decimal Degrees\":\n            if (isPair) {\n                splitLat =  splitInput(split[0]);","sourceCodeStart":161,"sourceCodeEnd":197,"githubUrl":"https://github.com/gchq/CyberChef/blob/4290ea753912378913b1f3f54e0fc5720afeda5d/src/core/lib/ConvertCoordinates.mjs#L161-L197","documentation":"Thrown in the 'Degrees Decimal Minutes' branch when isPair is true but splitInput of either segment does not return exactly 2 numeric parts. DDM requires exactly degrees and decimal-minutes for BOTH halves.","triggerScenarios":"inFormat='Degrees Decimal Minutes' with a paired input where one half has only degrees (1 number) or has 3+ numbers (e.g. leftover seconds), so splitLat.length !== 2 or splitLong.length !== 2.","commonSituations":"Mixing DDM with DMS data (extra seconds field present); one coordinate given as plain decimal degrees (single number); inconsistent delimiters collapsing one field to zero numbers.","solutions":["Make sure each half of the pair has exactly two numeric components: degrees and decimal minutes.","If seconds are present, switch inFormat to 'Degrees Minutes Seconds'.","If only a single decimal value per half is available, use 'Decimal Degrees'."],"exampleFix":"// before\nconvertCoordinates(\"51 30 26, 0 7 39\", \"Degrees Decimal Minutes\", \"Comma\", ...);\n// 3 numbers each -> throws\n\n// after\nconvertCoordinates(\"51 30.433, 0 7.650\", \"Degrees Decimal Minutes\", \"Comma\", ...);","handlingStrategy":"validation","validationCode":"function splitInput(s){return s.split(/\\s+/).map(x=>x.replace(/[^0-9.-]/g,\"\")).filter(Boolean).map(Number);}\nif (splitInput(split[0]).length !== 2 || splitInput(split[1]).length !== 2) {\n  throw new Error(\"DDM pair needs exactly degrees and decimal-minutes per half.\");\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Ensure exactly two numeric tokens per half (no seconds).","If seconds present, use DMS; if one number, use DD.","Validate token counts before invoking."],"tags":["coordinates","geo","input-validation","ddm"],"backgroundTag":null,"analyzedSha":"4290ea753912378913b1f3f54e0fc5720afeda5d","analyzedAt":"2026-08-13T06:05:50.210Z","schemaVersion":2},"datasetVersion":"2026-08-13T09:17:06.757Z"}