function [spheroidout, c1out, c2out, c3out, inDegrees] = parseTransformationInputs( ...
    spheroid, c1, c2, c3, angleUnit)
% Parse inputs to geodetic2ecef and ecef2geodetic

% Copyright 2019-2020 The MathWorks, Inc.

%#codegen

    coder.ignoreCatch
    try %#ok<EMTC>
        % New output variables are required below (instead of passing
        % through input variables) to support MATLAB Coder, since otherwise
        % it would be possible for the shape of the variables to change due
        % to the call to deal.
        if isobject(spheroid)
            % [X, Y, Z] = geodetic2ecef(SPHEROID, PHI, LAMBDA, H, SPHEROID [, angleUnit])
            c1out = c1;
            c2out = c2;
            c3out = c3;
            spheroidout = spheroid;
            inDegrees = (nargin < 5 || map.geodesy.isDegree(angleUnit));
        else
            % Older syntax with PHI and LAMBDA defaulting to radians:
            %    [X, Y, Z] = geodetic2ecef(PHI, LAMBDA, H, SPHEROID)
            % Also do the right thing with this undocumented syntax:
            %    [X, Y, Z] = geodetic2ecef(PHI, LAMBDA, H, SPHEROID, angleUnit)
            % SPHEROID can be a spheroid object or an ellipsoid vector.
            [c1out, c2out, c3out, spheroidout] = deal(spheroid, c1, c2, c3);
            inDegrees = ~(nargin < 5 || ~map.geodesy.isDegree(angleUnit));
        end
    catch e
        throwAsCaller(e)
    end
end
