{"record":{"id":"aacfc77017d8d914","repo":"gchq/CyberChef","slug":"invalid-co-ordinate-format-for-decimal-degrees","errorCode":null,"errorMessage":"Invalid co-ordinate format for Decimal Degrees.","messagePattern":"Invalid co-ordinate format for Decimal Degrees\\.","errorType":"exception","errorClass":"OperationError","httpStatus":null,"severity":"error","filePath":"src/core/lib/ConvertCoordinates.mjs","lineNumber":200,"sourceCode":"                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]);\n                splitLong = splitInput(split[1]);\n                if (splitLat.length !== 1 || splitLong.length !== 1) {\n                    throw new OperationError(\"Invalid co-ordinate format for Decimal Degrees.\");\n                }\n                latlon = new LatLonEllipsoidal(splitLat[0], splitLong[0]);\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 !== 1) {\n                    throw new OperationError(\"Invalid co-ordinate format for Decimal Degrees.\");\n                }\n                latlon = new LatLonEllipsoidal(splitLat[0], splitLat[0]);\n            }\n            break;\n        default:\n            throw new OperationError(`Unknown input format '${inFormat}'`);\n    }\n\n    // Everything is now a geodesy latlon object\n    // These store the latitude and longitude as decimal\n    if (inFormat.includes(\"Degrees\")) {","sourceCodeStart":182,"sourceCodeEnd":218,"githubUrl":"https://github.com/gchq/CyberChef/blob/4290ea753912378913b1f3f54e0fc5720afeda5d/src/core/lib/ConvertCoordinates.mjs#L182-L218","documentation":"Thrown in the 'Decimal Degrees' branch when isPair is true but splitInput of either segment does not return exactly 1 numeric part. Decimal Degrees expects a single numeric value per half.","triggerScenarios":"inFormat='Decimal Degrees' with a paired input where one half contains multiple numbers (e.g. DMS or DDM data, or stray digits), so splitLat.length !== 1 or splitLong.length !== 1.","commonSituations":"Selecting 'Decimal Degrees' while the data is actually in DMS/DDM form; extra spaces producing multiple numeric tokens; degree/minute symbols leaving residual numbers.","solutions":["Ensure each half of the pair is a single decimal-degrees number.","Pick the correct inFormat matching the actual data (DMS or DDM) if multiple numbers are present.","Sanitise each half so splitInput returns exactly one value."],"exampleFix":"// before\nconvertCoordinates(\"51 30.443, 0 7.65\", \"Decimal Degrees\", \"Comma\", ...);\n// 2 numbers each -> throws\n\n// after\nconvertCoordinates(\"51.5072, 0.1275\", \"Decimal Degrees\", \"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 !== 1 || splitInput(split[1]).length !== 1) {\n  throw new Error(\"Decimal Degrees pair needs exactly one number per half.\");\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Provide one decimal number per half.","If multiple numbers appear, select the matching DMS/DDM format.","Sanitise each half before counting tokens."],"tags":["coordinates","geo","input-validation","decimal-degrees"],"backgroundTag":null,"analyzedSha":"4290ea753912378913b1f3f54e0fc5720afeda5d","analyzedAt":"2026-08-13T06:05:50.210Z","schemaVersion":2},"datasetVersion":"2026-08-13T09:17:06.757Z"}