gchq/CyberChef · error · OperationError

Invalid co-ordinate format for Decimal Degrees.

Error message

Invalid co-ordinate format for Decimal Degrees.

What it means

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.

Source

Thrown at src/core/lib/ConvertCoordinates.mjs:200

                lat = convDDMToDD(splitLat[0], splitLat[1], 10);
                lon = convDDMToDD(splitLong[0], splitLong[1], 10);
                latlon = new LatLonEllipsoidal(lat.degrees, lon.degrees);
            } else {
                // Not a pair, so only try to convert one set of co-ordinates
                splitLat = splitInput(input);
                if (splitLat.length !== 2) {
                    throw new OperationError("Invalid co-ordinate format for Degrees Decimal Minutes.");
                }
                lat = convDDMToDD(splitLat[0], splitLat[1], 10);
                latlon = new LatLonEllipsoidal(lat.degrees, lat.degrees);
            }
            break;
        case "Decimal Degrees":
            if (isPair) {
                splitLat =  splitInput(split[0]);
                splitLong = splitInput(split[1]);
                if (splitLat.length !== 1 || splitLong.length !== 1) {
                    throw new OperationError("Invalid co-ordinate format for Decimal Degrees.");
                }
                latlon = new LatLonEllipsoidal(splitLat[0], splitLong[0]);
            } else {
                // Not a pair, so only try to convert one set of co-ordinates
                splitLat = splitInput(split[0]);
                if (splitLat.length !== 1) {
                    throw new OperationError("Invalid co-ordinate format for Decimal Degrees.");
                }
                latlon = new LatLonEllipsoidal(splitLat[0], splitLat[0]);
            }
            break;
        default:
            throw new OperationError(`Unknown input format '${inFormat}'`);
    }

    // Everything is now a geodesy latlon object
    // These store the latitude and longitude as decimal
    if (inFormat.includes("Degrees")) {

View on GitHub (pinned to 4290ea7539)

Solutions

  1. Ensure each half of the pair is a single decimal-degrees number.
  2. Pick the correct inFormat matching the actual data (DMS or DDM) if multiple numbers are present.
  3. Sanitise each half so splitInput returns exactly one value.

Example fix

// before
convertCoordinates("51 30.443, 0 7.65", "Decimal Degrees", "Comma", ...);
// 2 numbers each -> throws

// after
convertCoordinates("51.5072, 0.1275", "Decimal Degrees", "Comma", ...);
Defensive patterns

Strategy: validation

Validate before calling

function splitInput(s){return s.split(/\s+/).map(x=>x.replace(/[^0-9.-]/g,"")).filter(Boolean).map(Number);}
if (splitInput(split[0]).length !== 1 || splitInput(split[1]).length !== 1) {
  throw new Error("Decimal Degrees pair needs exactly one number per half.");
}

Prevention

When it happens

Trigger: 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.

Common situations: Selecting 'Decimal Degrees' while the data is actually in DMS/DDM form; extra spaces producing multiple numeric tokens; degree/minute symbols leaving residual numbers.

Related errors


AI-assisted analysis of gchq/CyberChef@4290ea7539 (2026-08-13). Data as JSON: /api/errors/aacfc77017d8d914. Report an issue: GitHub.