Skip to content

Commit

Permalink
working on Partial Displaced Left Turn Intersection (E-W)
Browse files Browse the repository at this point in the history
  • Loading branch information
geoyogesh committed Oct 6, 2020
1 parent d3d22d3 commit 167bd0a
Show file tree
Hide file tree
Showing 6 changed files with 263 additions and 7 deletions.
Original file line number Diff line number Diff line change
@@ -1 +1,130 @@
<p>partial-displaced-left-turn-intersection-east-west-configuration works!</p>
<table class="no-border centered-child" [formGroup]="form">
<tr>
<td></td>
<td>
<table>
<tr>
<td><img src="assets/capx/south-right-turn.png" /></td>
<td><img src="assets/capx/south-thru.png" /></td>
<td><img src="assets/capx/south-left-turn.png" /></td>
<td><img src="assets/capx/south-u-turn.png" /></td>
</tr>
<tr>
<td class="readonly pepch"><div>PEPCH <br/> {{(capxStateService.masterParameters$ | async)!.south_bound_right}}</div></td>
<td class="readonly pepch"><div>PEPCH <br/> {{(capxStateService.masterParameters$ | async)!.south_bound_thru}}</div></td>
<td class="readonly pepch"><div>PEPCH <br/> {{(capxStateService.masterParameters$ | async)!.south_bound_left}}</div></td>
<td class="readonly pepch"><div>PEPCH <br/> {{(capxStateService.masterParameters$ | async)!.south_bound_u}}</div></td>
</tr>
<tr>
<td class="editable"><div><input type="number" value="0" formControlName="south_bound_right"></div></td>
<td class="editable"><div><input type="number" min="0" max="9" value="1" formControlName="south_bound_thru"></div></td>
<td colspan="2" class="editable"><div><input type="number" min="0" max="9" value="1" formControlName="south_bound_left"></div></td>
</tr>
</table>
</td>
<td></td>
</tr>
<tr>
<td>

<div>
<table class="config-table">
<tr>
<td><img src="assets/capx/east-u-turn.png" /></td>
<td class="readonly pepch"><div class="east-rotation">{{(capxStateService.masterParameters$ | async)!.east_bound_u}} <br/> PEPCH</div></td>
<td rowspan="2" class="editable"><div class="east-rotation"><input type="number" min="0" max="9" value="1" formControlName="east_bound_left"></div></td>
</tr>
<tr>
<td><img src="assets/capx/east-left-turn.png" /></td>
<td class="readonly pepch"><div class="east-rotation">{{(capxStateService.masterParameters$ | async)!.east_bound_left}} <br/> PEPCH</div></td>
</tr>

<tr>
<td><img src="assets/capx/east-thru.png" /></td>
<td class="readonly pepch"><div class="east-rotation">{{(capxStateService.masterParameters$ | async)!.east_bound_thru}} <br/> PEPCH</div></td>
<td class="editable"><div class="east-rotation"><input type="number" min="0" max="9" value="1" formControlName="east_bound_thru"></div></td>
</tr>

<tr>
<td><img src="assets/capx/east-right-turn.png" /></td>
<td class="readonly pepch"><div class="east-rotation">{{(capxStateService.masterParameters$ | async)!.east_bound_right}} <br/> PEPCH</div></td>
<td class="editable"><div class="east-rotation"><input type="number" min="0" max="9" value="1" formControlName="east_bound_right"></div></td>
</tr>
</table>
</div>


</td>
<td>

<div>
<table class="zone-table">
<tr>
<td class="zone-cell">Zone 5</td>
</tr>
<tr>
<td [ngStyle]="{'color': 'black', 'background-color': (capxStateService.getClvRangeColor((capxStateService.state.get(junctions.PartialDisplacedLeftTurnIntersectionEastWest).intersectionResult | async).zone5_center_clv))}">{{(capxStateService.state.get(junctions.PartialDisplacedLeftTurnIntersectionEastWest).intersectionResult | async).zone5_center_clv}}</td>
</tr>
</table>
</div>

</td>
<td>
<div>
<table>
<tr>
<td class="editable"><div class="west-rotation"><input type="number" min="0" max="9" value="1" formControlName="west_bound_right"></div></td>
<td class="readonly pepch"><div class="west-rotation">PEPCH <br/> {{(capxStateService.masterParameters$ | async)!.west_bound_right}}</div></td>
<td><img src="assets/capx/west-right-turn.png" /></td>
</tr>
<tr>
<td class="editable"><div class="west-rotation"><input type="number" min="0" max="9" value="1" formControlName="west_bound_thru"></div></td>
<td class="readonly pepch"><div class="west-rotation">PEPCH <br/> {{(capxStateService.masterParameters$ | async)!.west_bound_thru}}</div></td>
<td><img src="assets/capx/west-thru.png" /></td>
</tr>

<tr>
<td rowspan="2" class="editable"><div class="west-rotation"><input type="number" min="0" max="9" value="1" formControlName="west_bound_left"></div></td>
<td class="readonly pepch"><div class="west-rotation">PEPCH <br/> {{(capxStateService.masterParameters$ | async)!.west_bound_left}}</div></td>
<td><img src="assets/capx/west-left-turn.png" /></td>
</tr>

<tr>
<td class="readonly pepch"><div class="west-rotation">PEPCH <br/> {{(capxStateService.masterParameters$ | async)!.west_bound_u}}</div></td>
<td><img src="assets/capx/west-u-turn.png" /></td>
</tr>
</table>
</div>


</td>
</tr>
<tr>
<td></td>
<td>

<table>
<tr>
<td colspan="2" class="editable"><input type="number" min="0" max="9" value="1" formControlName="north_bound_left"></td>
<td class="editable"><input type="number" value="0" formControlName="north_bound_thru"></td>
<td class="editable"><input type="number" min="0" max="9" value="1" formControlName="north_bound_right"></td>
</tr>
<tr>
<td class="readonly pepch">{{(capxStateService.masterParameters$ | async)!.north_bound_u}} <br/> PEPCH</td>
<td class="readonly pepch">{{(capxStateService.masterParameters$ | async)!.north_bound_left}} <br/> PEPCH</td>
<td class="readonly pepch">{{(capxStateService.masterParameters$ | async)!.north_bound_thru}} <br/> PEPCH</td>
<td class="readonly pepch">{{(capxStateService.masterParameters$ | async)!.north_bound_right}} <br/> PEPCH</td>
</tr>
<tr>
<td><img src="assets/capx/north-u-turn.png" /></td>
<td><img src="assets/capx/north-left-turn.png" /></td>
<td><img src="assets/capx/north-thru.png" /></td>
<td><img src="assets/capx/north-right-turn.png" /></td>
</tr>
</table>


</td>
<td></td>
</tr>
</table>
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
:host
{
display: block;
overflow-y: auto;

table tr td input {
max-width: 30px;
}
}
Original file line number Diff line number Diff line change
@@ -1,16 +1,56 @@
import { ChangeDetectionStrategy, Component, OnInit } from '@angular/core';
import { CapxStateService } from './../../../../../services/capx-state.service';
import { ChangeDetectionStrategy, Component, OnDestroy, OnInit } from '@angular/core';
import { FormBuilder, FormGroup, Validators } from '@angular/forms';
import { CapxIntersectionAnalysisResultParameters, Junction } from './../../../../../services/models/junction-capacity-analyser';
import { Junctions } from './../../../../../services/models/junctions';
import { BehaviorSubject } from 'rxjs';

@Component({
selector: 'capx-partial-displaced-left-turn-intersection-east-west-configuration',
templateUrl: './partial-displaced-left-turn-intersection-east-west-configuration.component.html',
styleUrls: ['./partial-displaced-left-turn-intersection-east-west-configuration.component.scss'],
changeDetection: ChangeDetectionStrategy.OnPush
})
export class PartialDisplacedLeftTurnIntersectionEastWestConfigurationComponent implements OnInit {
export class PartialDisplacedLeftTurnIntersectionEastWestConfigurationComponent implements OnInit, OnDestroy {

constructor() { }
result$: BehaviorSubject<CapxIntersectionAnalysisResultParameters> = new BehaviorSubject(null);

junctions = Junctions;
constructor(private fb: FormBuilder, public capxStateService: CapxStateService) { }


form: FormGroup = this.fb.group({
east_bound_left: [null , Validators.required],
east_bound_thru: [null, Validators.required],
east_bound_right: [null, Validators.required],
west_bound_left: [null, Validators.required],
west_bound_thru: [null, Validators.required],
west_bound_right: [null, Validators.required],
south_bound_left: [null, Validators.required],
south_bound_thru: [null, Validators.required],
south_bound_right: [null, Validators.required],
north_bound_left: [null, Validators.required],
north_bound_thru: [null, Validators.required],
north_bound_right: [null, Validators.required]
});

ngOnInit(): void {
this.form.valueChanges.subscribe(value => {
this.capxStateService.updatePartialDisplacedLeftTurnIntersectionEastWestParameters(value);
});

// tslint:disable-next-line: max-line-length
this.form.setValue(this.capxStateService.partialDisplacedLeftTurnIntersectionEastWestJunctionParameters$.value, {onlySelf: true, emitEvent: false});

const junction = this.capxStateService.state.get(Junctions.PartialDisplacedLeftTurnIntersectionEastWest) as Junction;
(junction.intersectionResult as BehaviorSubject<CapxIntersectionAnalysisResultParameters>).subscribe(result => {
this.result$.next(result);
});
}

ngOnDestroy(): void {
this.result$.complete();
}

}

Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
:host
{
display: block;
overflow-y: scroll;
overflow-y: auto;

table tr td input {
max-width: 30px;
Expand Down
67 changes: 65 additions & 2 deletions projects/capx/src/app/capx/services/capx-state.service.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Junction, JunctionTypes, CapxPartialDisplacedLeftTurnIntersectionNorthSouth } from './models/junction-capacity-analyser';
import { Junction, JunctionTypes, CapxPartialDisplacedLeftTurnIntersectionNorthSouth, CapxPartialDisplacedLeftTurnIntersectionEastWest } from './models/junction-capacity-analyser';
import { Junctions } from './models/junctions';

// tslint:disable: variable-name
Expand Down Expand Up @@ -168,6 +168,21 @@ export class CapxStateService {
north_bound_right: 1
});

partialDisplacedLeftTurnIntersectionEastWestJunctionParameters$ = new BehaviorSubject<CapxPartialDisplacedLeftTurnIntersectionEastWest>({
east_bound_left: 2,
east_bound_thru: 3,
east_bound_right: 1,
west_bound_left: 2,
west_bound_thru: 3,
west_bound_right: 1,
south_bound_left: 1,
south_bound_thru: 2,
south_bound_right: 1,
north_bound_left: 1,
north_bound_thru: 2,
north_bound_right: 1
});

rank$ = new BehaviorSubject<Map<string, number | null>>(new Map());


Expand Down Expand Up @@ -477,6 +492,7 @@ export class CapxStateService {
this.solve();
this.solveConventionalJunction();
this.solvePartialDisplacedLeftTurnIntersectionNorthSouthJunction();
this.solvePartialDisplacedLeftTurnIntersectionEastWestJunction();
}

public updateInputParameters(params: CapxInputParameters): void {
Expand Down Expand Up @@ -669,7 +685,7 @@ export class CapxStateService {
this.rank$.next(inter_ranks);
}


//#region Conventional
public updateConventionalJunctionParameters(params: CapxConventionalJunctionParameters): void {
this.conventionalJunctionParameters$.next(params);
this.solveConventionalJunction();
Expand Down Expand Up @@ -705,7 +721,11 @@ export class CapxStateService {

this.updateRank();
}
//#endregion



//#region Partial Displaced LeftTurn Intersection North South
public updatePartialDisplacedLeftTurnIntersectionNorthSouthParameters(params: CapxPartialDisplacedLeftTurnIntersectionNorthSouth): void {
this.partialDisplacedLeftTurnIntersectionNorthSouthJunctionParameters$.next(params);
this.solvePartialDisplacedLeftTurnIntersectionNorthSouthJunction();
Expand Down Expand Up @@ -743,6 +763,49 @@ export class CapxStateService {

this.updateRank();
}
//#endregion


//#region Partial Displaced LeftTurn Intersection East West
public updatePartialDisplacedLeftTurnIntersectionEastWestParameters(params: CapxPartialDisplacedLeftTurnIntersectionEastWest): void {
this.partialDisplacedLeftTurnIntersectionEastWestJunctionParameters$.next(params);
this.solvePartialDisplacedLeftTurnIntersectionEastWestJunction();
}

private solvePartialDisplacedLeftTurnIntersectionEastWestJunction(): void {
const inputParameters = this.inputParameters$.value;
const masterParameters = this.masterParameters$.value;
const junctionParameters = this.partialDisplacedLeftTurnIntersectionEastWestJunctionParameters$.value;

const zone1_north_clv = masterParameters.south_bound_left / inputParameters.adjustment_factor_left_turn / junctionParameters.south_bound_left + (masterParameters.north_bound_thru + masterParameters.east_bound_left) / junctionParameters.north_bound_thru

const zone5_center_clv = max(masterParameters.north_bound_left / inputParameters.adjustment_factor_left_turn / junctionParameters.north_bound_left, masterParameters.north_bound_thru / junctionParameters.north_bound_thru, round(max(0, masterParameters.north_bound_right / inputParameters.adjustment_factor_right_turn / junctionParameters.north_bound_right - masterParameters.east_bound_left / inputParameters.adjustment_factor_left_turn / junctionParameters.east_bound_left), 0), masterParameters.south_bound_left / inputParameters.adjustment_factor_left_turn / junctionParameters.south_bound_left, masterParameters.south_bound_thru / junctionParameters.south_bound_thru, round(max(0, masterParameters.south_bound_right / inputParameters.adjustment_factor_right_turn / junctionParameters.south_bound_right - masterParameters.east_bound_left / inputParameters.adjustment_factor_left_turn / junctionParameters.east_bound_left), 0)) + max(masterParameters.east_bound_left / inputParameters.adjustment_factor_left_turn / junctionParameters.east_bound_left + max(masterParameters.west_bound_thru / junctionParameters.west_bound_thru, round(max(0, masterParameters.west_bound_right / inputParameters.adjustment_factor_right_turn / junctionParameters.west_bound_right - masterParameters.south_bound_left / inputParameters.adjustment_factor_left_turn / junctionParameters.south_bound_left), 0)), masterParameters.west_bound_left / inputParameters.adjustment_factor_left_turn / junctionParameters.west_bound_left + max( masterParameters.east_bound_thru / junctionParameters.east_bound_thru, round(max(0, masterParameters.east_bound_right / inputParameters.adjustment_factor_right_turn / junctionParameters.east_bound_right - masterParameters.north_bound_left / inputParameters.adjustment_factor_left_turn / junctionParameters.north_bound_left), 0)))

const zone2_south_clv = masterParameters.north_bound_left / inputParameters.adjustment_factor_left_turn / junctionParameters.north_bound_left + (masterParameters.south_bound_thru + masterParameters.west_bound_left) / junctionParameters.south_bound_thru


const zone1_north_vc = round(zone1_north_clv / inputParameters.critical_lane_volume, 2);
const zone5_center_vc = round(zone5_center_clv / inputParameters.critical_lane_volume, 2);
const zone2_south_vc = round(zone2_south_clv / inputParameters.critical_lane_volume, 2);
(this.state.get(Junctions.PartialDisplacedLeftTurnIntersectionNorthSouth)?.intersectionResult as BehaviorSubject<CapxIntersectionAnalysisResultParameters>).next({
zone1_north_clv: round(zone1_north_clv),
zone1_north_vc,
zone2_south_clv: round(zone2_south_clv),
zone2_south_vc,
zone3_east_clv: null,
zone3_east_vc: null,
zone4_west_clv: null,
zone4_west_vc: null,
zone5_center_clv: round(zone5_center_clv),
zone5_center_vc,
all_clv: round(max(zone1_north_clv, zone5_center_clv, zone2_south_clv)),
all_vc: max(zone1_north_vc, zone5_center_vc, zone2_south_vc)
});

this.updateRank();
}
//#endregion


public getClvRangeColor(zone_all_clv: number | null): string {
// update range text
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,21 @@ export interface CapxPartialDisplacedLeftTurnIntersectionNorthSouth {
north_bound_right: number;
}

export interface CapxPartialDisplacedLeftTurnIntersectionEastWest {
east_bound_left: number;
east_bound_thru: number;
east_bound_right: number;
west_bound_left: number;
west_bound_thru: number;
west_bound_right: number;
south_bound_left: number;
south_bound_thru: number;
south_bound_right: number;
north_bound_left: number;
north_bound_thru: number;
north_bound_right: number;
}

export interface CapxIntersectionAnalysisResultParameters {
zone1_north_clv: number | null;
zone1_north_vc: number | null;
Expand Down

0 comments on commit 167bd0a

Please sign in to comment.