%% Create Parking Lot with Spaces Along Edges
% Create a driving scenario containing a short road that enters into a parking lot that is 50 meters long and 20 meters wide. Plot the parking lot and display the edge numbers along which you can insert parking spaces. Because edge 3 forms a junction with the road, its edge number does not display on the plot, but you can still insert spaces along it.

scenario = drivingScenario;
roadcenters = [25 30; 25 15];
road(scenario,roadcenters);

vertices = [0 0; 50 0; 50 20; 0 20];
lot = parkingLot(scenario,vertices);
plot(scenario,ParkingLotEdges="On")

%
% Define the parking space type to add along one of the edges. Set an angle of 60 degrees. Plot the parking space.

space = parkingSpace(Angle=60);
plot(space)

%
% Insert the angled spaces along edge 1 of the parking lot.

insertParkingSpaces(lot,space,Edge=1)

%
% Insert angled spaces along edge 3: five above the junction and five below the junction. Offset these spaces by 3 meters and 30 meters from the bottom of edge 3, respectively. Reverse the angle of the spaces used along edge 1.

numSpaces = 5;
space = parkingSpace(Angle=120);
insertParkingSpaces(lot,space,numSpaces,Edge=3,Offset=3)
insertParkingSpaces(lot,space,numSpaces,Edge=3,Offset=30)

%
% Copyright 2021 The MathWorks, Inc.