function obj = laneType(type,varargin)
% lt = laneType(type) constructs a lane type object for the type of lane 
% specified at the input. type is a character vector or string scalar 
% specifying the type of lane and can be any one of the following:
%  'Driving' for driving lane
%  'Border'  for border lane
%  'Restricted' for restricted lane
%  'Shoulder' for shoulder lane
%  'Parking' for parking lane.
%
%   lt = laneType(type, Name, Value, ...) specifies additional
%   name-value pair arguments described below:
%
%     Color      An 1-by-3 array or a color name as in MATLAB ColorSpec 
%                specifying the lane color. Default is
%                Driving - [0.8 0.8 0.8]
%                Border  - [0.72 0.72 0.72]
%                Restricted - [0.59 0.56 0.62]
%                Shoulder - [0.59 0.59 0.59]
%                Parking - [0.28 0.28 0.28]                 
%
%     Strength   A scalar specifying the transparency for the lane color.
%                The value range is from 0 to 1. The default value is 1.
%
%   % Example
%   % -------
%   % Create a curved road with three lanes
%   s = drivingScenario;
%   roadCenters = [0 0; 10 0; 53 -20];
%
%   lt = [laneType('Border')
%         laneType('Driving')
%         laneType('Driving')];
%
%   road(s, roadCenters, 'Lanes', lanespec(3,'Type',lt));
%   plot(s);
%
%   See also lanespec, road, drivingScenario

%   Copyright 2019 The MathWorks, Inc.

if ischar(type) || isstring(type)
    type = validatestring(type,{'Driving','Parking','Border','Shoulder',...
        'Restricted'},mfilename, 'type');
else
    % Must be LaneTypes
    validateattributes(type,{'LaneTypes'},{'scalar'},mfilename,'type');
end

switch type
    case {'Driving'}
        % Construct a Driving lane type
        obj = driving.scenario.DrivingLaneType(type,varargin{:});
    case {'Border'}
        % Construct the Border lane type
        obj = driving.scenario.BorderLaneType(type,varargin{:});
    case {'Restricted'}
        % Construct a Restricted lane type
        obj = driving.scenario.RestrictedLaneType(type,varargin{:});
    case {'Shoulder'}
        % Construct a Shoulder lane type
        obj = driving.scenario.ShoulderLaneType(type,varargin{:});
    case {'Parking'}
        % Construct a Parking lane type
        obj = driving.scenario.ParkingLaneType(type,varargin{:});
end