-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
This reverts commit e266496.
- Loading branch information
1 parent
ab7cda6
commit b1d8a3f
Showing
8 changed files
with
57 additions
and
130 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,98 +1,11 @@ | ||
/* Cache constants */ | ||
// A cache containing Google Autocomplete results | ||
const AUTOCOMPLETE_CACHE_OPTIONS = { | ||
max: 10000, // Max 10000 autocomplete results | ||
maxAge: 1000 * 60 * 60 * 24 * 5, // Max age in 5 days | ||
}; | ||
|
||
// A cache containing saved routes IDs to routes | ||
const ROUTES_CALC_CACHE_OPTIONS = { | ||
max: 1000, // Max 1000 routes | ||
maxAge: 1000 * 60 * 15, // Max age in 15 minutes | ||
}; | ||
|
||
// A cache mapping a /search's request query string to its Google autocomplete predictions | ||
const QUERY_PREDICTIONS_CACHE_OPTIONS = { | ||
max: 10000, // Max 1000 predictions | ||
maxAge: 1000 * 60 * 60 * 24 * 5, // Max age in 5 days | ||
}; | ||
|
||
/* Count constants */ | ||
// The minimum fuzzy string matching ratio that a word has to match a target word for /search | ||
const MIN_FUZZ_RATIO = 75; | ||
|
||
/* Delay Buffer constants */ | ||
// A buffer to account for routes in past 20 minutes with delays | ||
const FIRST_DELAY_BUFFER_IN_MINUTES = 20; | ||
// An additional buffer to account for time needed to walk from current location to bus stop | ||
const SECOND_DELAY_BUFFER_IN_MINUTES = 40; | ||
|
||
/* Distance & Speed constants */ | ||
// > 3.0 suggests getting off bus earlier and walk half a mile instead of waiting longer | ||
const MAX_WALK_DIST_PER_LEG = 2000; | ||
// The distance (in meters) within which to return Google place results for autocomplete. | ||
const AUTOCOMPLETE_RADIUS = 24140; | ||
const WALK_SPEED = 3.0; | ||
|
||
/* Degrees Precision constants */ | ||
const DEG_MIN_PRECISION = 1; | ||
const DEG_KM_PRECISION = 2; // 2 degrees of precision is about 1 km, a barely walkable stop | ||
const DEG_WALK_PRECISION = 3; // 3 degrees of precision is about 111 meters, a walkable stop | ||
const DEG_NEARBY_PRECISION = 4; // 4 degrees of precision is about 11 meters, a nearby stop | ||
const DEG_EQ_PRECISION = 5; // 5 degrees of precision is about 1.1 meters, a stop | ||
const DEG_EXACT_PRECISION = 6; // 6 degrees of precision is about 111 mm, an exact point | ||
const DEG_MAX_PRECISION = 6; | ||
|
||
/* String & URL constants */ | ||
const BUS_STOP = 'busStop'; | ||
const CURRENT_LOCATION = 'Current Location'; | ||
const GOOGLE_AUTOCOMPLETE_URL = 'https://maps.googleapis.com/maps/api/place/autocomplete/json'; | ||
const GOOGLE_PLACE = 'googlePlace'; | ||
const GOOGLE_PLACE_LOCATION = '42.4440,-76.5019'; | ||
const GOOGLE_PLACES_URL = 'https://maps.googleapis.com/maps/api/place/details/json'; | ||
const TOKEN_URL = 'https://gateway.api.cloud.wso2.com:443/token'; | ||
|
||
/* Time constants */ | ||
const SEC_IN_MS = 1000; | ||
const MIN_IN_MS = SEC_IN_MS * 60; | ||
const HOUR_IN_MS = MIN_IN_MS * 60; | ||
const THREE_SEC_IN_MS = 3000; | ||
const TOKEN_EXPIRATION_WINDOW_IN_MS = 500; | ||
|
||
/* Request constants */ | ||
const GET_OPTIONS = { | ||
method: 'GET', | ||
headers: { 'Cache-Control': 'no-cache' }, | ||
timeout: THREE_SEC_IN_MS, | ||
}; | ||
|
||
export default { | ||
AUTOCOMPLETE_CACHE_OPTIONS, | ||
BUS_STOP, | ||
CURRENT_LOCATION, | ||
DEG_EQ_PRECISION, | ||
DEG_EXACT_PRECISION, | ||
DEG_KM_PRECISION, | ||
DEG_MAX_PRECISION, | ||
DEG_MIN_PRECISION, | ||
DEG_NEARBY_PRECISION, | ||
DEG_WALK_PRECISION, | ||
FIRST_DELAY_BUFFER_IN_MINUTES, | ||
GET_OPTIONS, | ||
GOOGLE_AUTOCOMPLETE_URL, | ||
GOOGLE_PLACE, | ||
GOOGLE_PLACE_LOCATION, | ||
GOOGLE_PLACES_URL, | ||
HOUR_IN_MS, | ||
MIN_FUZZ_RATIO, | ||
MAX_WALK_DIST_PER_LEG, | ||
QUERY_PREDICTIONS_CACHE_OPTIONS, | ||
AUTOCOMPLETE_RADIUS, | ||
ROUTES_CALC_CACHE_OPTIONS, | ||
SEC_IN_MS, | ||
SECOND_DELAY_BUFFER_IN_MINUTES, | ||
THREE_SEC_IN_MS, | ||
TOKEN_EXPIRATION_WINDOW_IN_MS, | ||
TOKEN_URL, | ||
WALK_SPEED, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters