|
1 | | -/* Cache constants */ |
2 | | -// A cache containing Google Autocomplete results |
3 | | -const AUTOCOMPLETE_CACHE_OPTIONS = { |
4 | | - max: 10000, // Max 10000 autocomplete results |
5 | | - maxAge: 1000 * 60 * 60 * 24 * 5, // Max age in 5 days |
6 | | -}; |
7 | | - |
8 | | -// A cache containing saved routes IDs to routes |
9 | | -const ROUTES_CALC_CACHE_OPTIONS = { |
10 | | - max: 1000, // Max 1000 routes |
11 | | - maxAge: 1000 * 60 * 15, // Max age in 15 minutes |
12 | | -}; |
13 | | - |
14 | | -// A cache mapping a /search's request query string to its Google autocomplete predictions |
15 | | -const QUERY_PREDICTIONS_CACHE_OPTIONS = { |
16 | | - max: 10000, // Max 1000 predictions |
17 | | - maxAge: 1000 * 60 * 60 * 24 * 5, // Max age in 5 days |
18 | | -}; |
19 | | - |
20 | | -/* Count constants */ |
21 | | -// The minimum fuzzy string matching ratio that a word has to match a target word for /search |
22 | | -const MIN_FUZZ_RATIO = 75; |
23 | | - |
24 | | -/* Delay Buffer constants */ |
25 | | -// A buffer to account for routes in past 20 minutes with delays |
26 | | -const FIRST_DELAY_BUFFER_IN_MINUTES = 20; |
27 | | -// An additional buffer to account for time needed to walk from current location to bus stop |
28 | | -const SECOND_DELAY_BUFFER_IN_MINUTES = 40; |
29 | | - |
30 | | -/* Distance & Speed constants */ |
31 | | -// > 3.0 suggests getting off bus earlier and walk half a mile instead of waiting longer |
32 | | -const MAX_WALK_DIST_PER_LEG = 2000; |
33 | | -// The distance (in meters) within which to return Google place results for autocomplete. |
34 | | -const AUTOCOMPLETE_RADIUS = 24140; |
35 | | -const WALK_SPEED = 3.0; |
36 | | - |
37 | | -/* Degrees Precision constants */ |
38 | | -const DEG_MIN_PRECISION = 1; |
39 | | -const DEG_KM_PRECISION = 2; // 2 degrees of precision is about 1 km, a barely walkable stop |
40 | | -const DEG_WALK_PRECISION = 3; // 3 degrees of precision is about 111 meters, a walkable stop |
41 | | -const DEG_NEARBY_PRECISION = 4; // 4 degrees of precision is about 11 meters, a nearby stop |
42 | | -const DEG_EQ_PRECISION = 5; // 5 degrees of precision is about 1.1 meters, a stop |
43 | | -const DEG_EXACT_PRECISION = 6; // 6 degrees of precision is about 111 mm, an exact point |
44 | | -const DEG_MAX_PRECISION = 6; |
45 | | - |
46 | | -/* String & URL constants */ |
47 | | -const BUS_STOP = 'busStop'; |
48 | | -const CURRENT_LOCATION = 'Current Location'; |
49 | | -const GOOGLE_AUTOCOMPLETE_URL = 'https://maps.googleapis.com/maps/api/place/autocomplete/json'; |
50 | | -const GOOGLE_PLACE = 'googlePlace'; |
51 | | -const GOOGLE_PLACE_LOCATION = '42.4440,-76.5019'; |
52 | | -const GOOGLE_PLACES_URL = 'https://maps.googleapis.com/maps/api/place/details/json'; |
53 | | -const TOKEN_URL = 'https://gateway.api.cloud.wso2.com:443/token'; |
54 | | - |
55 | | -/* Time constants */ |
56 | | -const SEC_IN_MS = 1000; |
57 | | -const MIN_IN_MS = SEC_IN_MS * 60; |
58 | | -const HOUR_IN_MS = MIN_IN_MS * 60; |
59 | 1 | const THREE_SEC_IN_MS = 3000; |
60 | | -const TOKEN_EXPIRATION_WINDOW_IN_MS = 500; |
61 | 2 |
|
62 | | -/* Request constants */ |
63 | 3 | const GET_OPTIONS = { |
64 | 4 | method: 'GET', |
65 | 5 | headers: { 'Cache-Control': 'no-cache' }, |
66 | 6 | timeout: THREE_SEC_IN_MS, |
67 | 7 | }; |
68 | 8 |
|
69 | 9 | export default { |
70 | | - AUTOCOMPLETE_CACHE_OPTIONS, |
71 | | - BUS_STOP, |
72 | | - CURRENT_LOCATION, |
73 | | - DEG_EQ_PRECISION, |
74 | | - DEG_EXACT_PRECISION, |
75 | | - DEG_KM_PRECISION, |
76 | | - DEG_MAX_PRECISION, |
77 | | - DEG_MIN_PRECISION, |
78 | | - DEG_NEARBY_PRECISION, |
79 | | - DEG_WALK_PRECISION, |
80 | | - FIRST_DELAY_BUFFER_IN_MINUTES, |
81 | 10 | GET_OPTIONS, |
82 | | - GOOGLE_AUTOCOMPLETE_URL, |
83 | | - GOOGLE_PLACE, |
84 | | - GOOGLE_PLACE_LOCATION, |
85 | | - GOOGLE_PLACES_URL, |
86 | | - HOUR_IN_MS, |
87 | | - MIN_FUZZ_RATIO, |
88 | | - MAX_WALK_DIST_PER_LEG, |
89 | | - QUERY_PREDICTIONS_CACHE_OPTIONS, |
90 | | - AUTOCOMPLETE_RADIUS, |
91 | | - ROUTES_CALC_CACHE_OPTIONS, |
92 | | - SEC_IN_MS, |
93 | | - SECOND_DELAY_BUFFER_IN_MINUTES, |
94 | | - THREE_SEC_IN_MS, |
95 | | - TOKEN_EXPIRATION_WINDOW_IN_MS, |
96 | | - TOKEN_URL, |
97 | | - WALK_SPEED, |
98 | 11 | }; |
0 commit comments