function drawWarehousePathBetweenShelves()

in use-cases/order-picking/src/main/resources/META-INF/resources/warehouse-api.js [233:301]


function drawWarehousePathBetweenShelves(ctx, trolleyIndex, trolleyCount,
        startShelving, startSide, startRow, startPoint,
        endShelving, endSide, endRow, endPoint) {
    ctx.moveTo(startPoint.x, startPoint.y);
    if (startShelving === endShelving) {
        if (startSide === endSide) {
            // Two points on the same shelf and same side
            ctx.lineTo(endPoint.x, endPoint.y);
        } else {
            // Two points on the same shelf but different sides
            const isAbove = startRow + endRow < 2*SHELVING_ROWS - startRow - endRow;
            const aisleChangeStartPoint = location2AisleLane(startShelving, startSide, isAbove, trolleyIndex, trolleyCount);
            const aisleChangeEndPoint = location2AisleLane(endShelving, endSide, isAbove, trolleyIndex, trolleyCount);
            ctx.lineTo(aisleChangeStartPoint.x, aisleChangeStartPoint.y);
            ctx.lineTo(aisleChangeEndPoint.x, aisleChangeEndPoint.y);
            ctx.lineTo(endPoint.x, endPoint.y);
        }
    } else if (startShelving.x === endShelving.x) {
        if (startSide === endSide) {
            // Same Aisle, different rows
            ctx.lineTo(endPoint.x, endPoint.y);
        } else {
            // Different Aisle
            if (startShelving.y < endShelving.y) {
                // Going up
                const aisleChangeStartPoint = location2AisleLane(endShelving, startSide, false, trolleyIndex, trolleyCount);
                const aisleChangeEndPoint = location2AisleLane(endShelving, endSide, false, trolleyIndex, trolleyCount);
                ctx.lineTo(aisleChangeStartPoint.x, aisleChangeStartPoint.y);
                ctx.lineTo(aisleChangeEndPoint.x, aisleChangeEndPoint.y);
                ctx.lineTo(endPoint.x, endPoint.y);
            } else {
                // Going down
                const aisleChangeStartPoint = location2AisleLane(endShelving, startSide, true, trolleyIndex, trolleyCount);
                const aisleChangeEndPoint = location2AisleLane(endShelving, endSide, true, trolleyIndex, trolleyCount);
                ctx.lineTo(aisleChangeStartPoint.x, aisleChangeStartPoint.y);
                ctx.lineTo(aisleChangeEndPoint.x, aisleChangeEndPoint.y);
                ctx.lineTo(endPoint.x, endPoint.y);
            }
        }
    } else if (startShelving.y === endShelving.y) {
        const startColumn = shelvingToColumn(startShelving);
        const endColumn = shelvingToColumn(endShelving);
        if (startSide === LEFT) {
            if (endSide === RIGHT && endColumn === startColumn - 1) {
                // Same Aisle, different shelving
                ctx.lineTo(endPoint.x, startPoint.y);
                ctx.lineTo(endPoint.x, endPoint.y);
            } else {
                drawWarehousePathBetweenColumns(ctx, trolleyIndex, trolleyCount,
                        startShelving, startSide, startRow, startPoint,
                        endShelving, endSide, endRow, endPoint);
            }
        } else {
            if (endSide === LEFT && endColumn === startColumn + 1) {
                // Same Aisle, different shelving
                ctx.lineTo(endPoint.x, startPoint.y);
                ctx.lineTo(endPoint.x, endPoint.y);
            } else {
                drawWarehousePathBetweenColumns(ctx, trolleyIndex, trolleyCount,
                        startShelving, startSide, startRow, startPoint,
                        endShelving, endSide, endRow, endPoint);
            }
        }
    } else {
        drawWarehousePathBetweenColumns(ctx, trolleyIndex, trolleyCount,
                startShelving, startSide, startRow, startPoint,
                endShelving, endSide, endRow, endPoint);
    }
}