1import { ApifyClient } from 'apify-client';
2
3
4
5const client = new ApifyClient({
6 token: '<YOUR_API_TOKEN>',
7});
8
9
10const input = {
11 "requests": [
12 "signal timing: phase 1: NB 450 vph 2 lanes, SB 380 vph 2 lanes; phase 2: EB 300 vph, WB 260 vph; phase 3: NBL 180 vph, SBL 150 vph; 45 mph, 70 ft intersection, 60 ft crosswalk",
13 "yellow and all-red for 45 mph, 3% downgrade, 80 ft intersection",
14 "critical flow ratios 0.25, 0.20, 0.15; lost time 12 s total",
15 "check: cycle 90 s, greens 40 30; NS 600 vph 2 lanes; EW 400 vph 1 lane, PHF 0.92",
16 "intersection: phase A: main street 900 vph 2 lanes; phase B: side street 350 vph, 50 km/h, 20 m wide, crosswalk 14 m",
17 {
18 "type": "timing",
19 "phases": [
20 {
21 "name": "North-south",
22 "movements": [
23 {
24 "name": "NB",
25 "volume": 620,
26 "lanes": 2
27 },
28 {
29 "name": "SB",
30 "volume": 540,
31 "lanes": 2
32 }
33 ]
34 },
35 {
36 "name": "East-west",
37 "movements": [
38 {
39 "name": "EB",
40 "volume": 410,
41 "lanes": 1
42 },
43 {
44 "name": "WB",
45 "volume": 380,
46 "lanes": 1
47 }
48 ]
49 }
50 ],
51 "saturationFlow": 1850,
52 "speed": "40 mph",
53 "width": "60 ft",
54 "maxCycle": 120
55 }
56 ]
57};
58
59
60const run = await client.actor("jumblemog/traffic-signal-calculator").call(input);
61
62
63console.log('Results from dataset');
64console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
65const { items } = await client.dataset(run.defaultDatasetId).listItems();
66items.forEach((item) => {
67 console.dir(item);
68});
69
70