diff --git a/README.md b/README.md index e8735f6..0e7b3b9 100644 --- a/README.md +++ b/README.md @@ -19,8 +19,7 @@ docker run -e APP_ID={APP_ID} -e API_KEY={API_KEY} -e HOST=api.traveltimeapp.com //optional - -e COUNTRY=gb //optional - -e COORDINATES=-8,13 // optional, this will overwrite COUNTRY env var + -e LOCATION='GB/London' //optional -e TRANSPORTATION='driving+ferry' //optional -e DATA_PATH='../precomputed/origins.csv' // optional, this will read coordinates from a file instead of randomly generating them -e TRAVEL_TIME=7200 //optional @@ -37,8 +36,7 @@ docker run -e APP_ID={APP_ID} -e API_KEY={API_KEY} -e HOST=api.traveltimeapp.com //optional - -e COUNTRY=gb //optional - -e COORDINATES=-8,13 // optional, this will overwrite COUNTRY env var + -e LOCATION='GB/London' //optional -e TRANSPORTATION='driving+ferry' //optional -e DATA_PATH='../precomputed/origins.csv' // optional, this will read coordinates from a file instead of randomly generating them -e TRAVEL_TIME=7200 //optional @@ -57,8 +55,7 @@ docker run -e APP_ID={APP_ID} -e API_KEY={API_KEY} -e HOST=api.traveltimeapp.com //optional - -e COUNTRY=gb //optional - -e COORDINATES=-8,13 // optional, this will overwrite COUNTRY env var + -e LOCATION='GB/London' //optional -e TRANSPORTATION='driving+ferry' //optional -e DATA_PATH='../precomputed/origins.csv' // optional, this will read coordinates from a file instead of randomly generating them -e TRAVEL_TIME=7200 //optional @@ -77,8 +74,7 @@ docker run -e APP_ID={APP_ID} -e API_KEY={API_KEY} -e HOST=api.traveltimeapp.com //optional - -e COUNTRY=gb //optional - -e COORDINATES=-8,13 // optional, this will overwrite COUNTRY env var + -e LOCATION='GB/London' //optional -e TRANSPORTATION='driving+ferry' //optional -e DATA_PATH='../precomputed/routes.csv' // optional, this will read coordinates from a file instead of randomly generating them -e RPM=60 // optional @@ -98,8 +94,7 @@ docker run -e HOST=proto.api.traveltimeapp.com // optional -e TRANSPORTATION=driving+ferry // optional -e DATA_PATH='../precomputed/origins.csv' // optional, this will read coordinates from a file instead of randomly generating them - -e COORDINATES=-8,13 // optional, this will overwrite COUNTRY env var - -e COUNTRY=uk // optional, but mandatory if COORDINATES are specified + -e LOCATION='UK/London' // optional -e RPM=60 // optional -e TEST_DURATION=3 //optional, benchmark duration in minutes (not including warmup) -e TRAVEL_TIME=7200 // optional @@ -160,29 +155,16 @@ https://k6.io/docs/using-k6/metrics/ ### Supported Countries -To see a list of all supported countries, send **map-info** **GET** request ([Postman](https://docs.traveltime.com/api/start/postman-collection#)) to: -- https://api.traveltimeapp.com +- Supported locations for normal requests are listed in the `locations/locations_data.csv` file. +- Supported locations for proto requests are listed in the `locations/proto_locations_data.csv` file. -### Supported Countries for Proto -``` -lv -nl -at -be -de -fr -ie -lt -uk -us_akst -us_cstn -us_csts -us_estn -us_ests -us_hi -us_mst -us_pst -``` +If you want to add a new location, simply append the csv files. + +**NOTE 1:** When adding a new proto location, please specify the ISO2 country code in the beginning, like it's done everywhere else. It's neccessary for the request. Example: 'GB/London'. + +**NOTE 2:** Proto requests support a much more limited amount of countries. + +To see a list of all supported countries, send [map-info](https://docs.traveltime.com/api/reference/map-info) request ([Postman](https://docs.traveltime.com/api/start/postman-collection#)) to https://api.traveltimeapp.com ### Transport modes #### time-map, time-map-fast, time-filter, routes diff --git a/locations/locations_data.csv b/locations/locations_data.csv new file mode 100644 index 0000000..4c29701 --- /dev/null +++ b/locations/locations_data.csv @@ -0,0 +1,253 @@ +name,lat,lng +"CI/Abidjan",5.3167,-4.0333 +"AE/Abu Dhabi",24.4667,54.3667 +"NG/Abuja",9.0667,7.4833 +"GH/Accra",5.55,-0.2 +"PN/Adamstown",-25.0667,-130.1 +"ET/Addis Ababa",9.03,38.74 +"DZ/Algiers",36.7539,3.0589 +"NU/Alofi",-19.056,-169.921 +"JO/Amman",31.9497,35.9328 +"NL/Amsterdam",52.3728,4.8936 +"AD/Andorra la Vella",42.5,1.5 +"TR/Ankara",39.93,32.85 +"MG/Antananarivo",-18.91,47.525 +"WS/Apia",-13.8333,-171.75 +"TM/Ashgabat",37.9375,58.38 +"ER/Asmara",15.3228,38.925 +"KZ/Astana",51.1472,71.4222 +"PY/Asuncion",-25.3,-57.6333 +"GR/Athens",37.9842,23.7281 +"CK/Avarua",-21.207,-159.771 +"IQ/Baghdad",33.3153,44.3661 +"AZ/Baku",40.3953,49.8822 +"ML/Bamako",12.6392,-8.0028 +"BN/Bandar Seri Begawan",4.8903,114.9422 +"TH/Bangkok",13.7525,100.4942 +"CF/Bangui",4.3733,18.5628 +"GM/Banjul",13.4531,-16.5775 +"GP/Basse-Terre",16.0104,-61.7055 +"KN/Basseterre",17.3,-62.7333 +"CN/Beijing",39.9067,116.3975 +"LB/Beirut",33.8983,35.5057 +"RS/Belgrade",44.82,20.46 +"BZ/Belmopan",17.2514,-88.7669 +"DE/Berlin",52.52,13.405 +"CH/Bern",46.9481,7.4475 +"KG/Bishkek",42.8747,74.6122 +"GW/Bissau",11.85,-15.5667 +"ZA/Bloemfontein",-29.1167,26.2167 +"CO/Bogota",4.7111,-74.0722 +"MS/Brades",16.7928,-62.2106 +"BR/Brasilia",-15.7939,-47.8828 +"SK/Bratislava",48.1439,17.1097 +"CG/Brazzaville",-4.2694,15.2711 +"BB/Bridgetown",13.0975,-59.6167 +"BE/Brussels",50.8467,4.3525 +"RO/Bucharest",44.4325,26.1039 +"HU/Budapest",47.4925,19.0514 +"AR/Buenos Aires",-34.6033,-58.3817 +"BI/Bujumbura",-3.3833,29.3667 +"EG/Cairo",30.0444,31.2358 +"AU/Canberra",-35.2931,149.1269 +"ZA/Cape Town",-33.9253,18.4239 +"MP/Capitol Hill",15.2137,145.7546 +"VE/Caracas",10.4806,-66.9036 +"LC/Castries",14.0167,-60.9833 +"GF/Cayenne",4.933,-52.33 +"VI/Charlotte Amalie",18.342,-64.9331 +"MD/Chisinau",47.0228,28.8353 +"LK/Colombo",6.9344,79.8428 +"GN/Conakry",9.5092,-13.7122 +"DK/Copenhagen",55.6761,12.5683 +"BJ/Cotonou",6.3667,2.4333 +"SN/Dakar",14.6928,-17.4467 +"SY/Damascus",33.5131,36.2919 +"BD/Dhaka",23.7639,90.3889 +"TL/Dili",-8.5536,125.5783 +"DJ/Djibouti",11.5883,43.145 +"TZ/Dodoma",-6.1731,35.7419 +"QA/Doha",25.2867,51.5333 +"IM/Douglas",54.15,-4.4775 +"IE/Dublin",53.35,-6.2603 +"TJ/Dushanbe",38.5367,68.78 +"CX/Flying Fish Cove",-10.4261,105.6728 +"MQ/Fort-de-France",14.6,-61.0667 +"SL/Freetown",8.4844,-13.2344 +"TV/Funafuti",-8.5167,179.2 +"BW/Gaborone",-24.6581,25.9122 +"XG/Gaza",31.5069,34.456 +"KY/George Town",19.2866,-81.3744 +"GY/Georgetown",6.8058,-58.1508 +"GI/Gibraltar",36.14,-5.35 +"BI/Gitega",-3.4283,29.925 +"TC/Grand Turk",21.459,-71.139 +"GT/Guatemala City",14.6133,-90.5353 +"BL/Gustavia",17.8979,-62.8506 +"GU/Hagta",13.4745,144.7504 +"BM/Hamilton",32.293,-64.782 +"VN/Hanoi",21,105.85 +"ZW/Harare",-17.8292,31.0522 +"CU/Havana",23.1367,-82.3589 +"FI/Helsinki",60.1708,24.9375 +"HK/Hong Kong",22.3,114.2 +"SB/Honiara",-9.4319,159.9556 +"PK/Islamabad",33.6931,73.0639 +"ID/Jakarta",-6.175,106.8275 +"SH/Jamestown",-15.9251,-5.7179 +"IL/Jerusalem",31.7789,35.2256 +"SS/Juba",4.85,31.6 +"AF/Kabul",34.5253,69.1783 +"UG/Kampala",0.3136,32.5811 +"NP/Kathmandu",27.71,85.32 +"SD/Khartoum",15.6,32.5 +"RW/Kigali",-1.9439,30.0594 +"GS/King Edward Point",-54.2833,-36.5 +"JM/Kingston",17.9714,-76.7931 +"NF/Kingston",-29.0606,167.9619 +"VC/Kingstown",13.1578,-61.225 +"CD/Kinshasa",-4.3219,15.3119 +"MY/Kuala Lumpur",3.1478,101.6953 +"KW/Kuwait City",29.3697,47.9783 +"UA/Kyiv",50.45,30.5233 +"BO/La Paz",-16.4958,-68.1333 +"GA/Libreville",0.3903,9.4542 +"MW/Lilongwe",-13.9833,33.7833 +"PE/Lima",-12.06,-77.0375 +"PT/Lisbon",38.7253,-9.15 +"SI/Ljubljana",46.0514,14.5061 +"SZ/Lobamba",-26.4465,31.2064 +"TG/Lome",6.1319,1.2228 +"GB/London",51.5072,-0.1275 +"XR/Longyearbyen",78.22,15.65 +"AO/Luanda",-8.8383,13.2344 +"ZM/Lusaka",-15.4167,28.2833 +"LU/Luxembourg",49.6117,6.1319 +"ES/Madrid",40.4169,-3.7033 +"MH/Majuro",7.0833,171.3833 +"GQ/Malabo",3.7456,8.7744 +"MV/Male",4.1753,73.5089 +"YT/Mamoudzou",-12.7806,45.2278 +"NI/Managua",12.1364,-86.2514 +"BH/Manama",26.225,50.5775 +"PH/Manila",14.5958,120.9772 +"MZ/Maputo",-25.9667,32.5833 +"MF/Marigot",18.0706,-63.0847 +"LS/Maseru",-29.31,27.48 +"WF/Mata-Utu",-13.2833,-176.1833 +"SZ/Mbabane",-26.3167,31.1333 +"MX/Mexico City",19.4333,-99.1333 +"BY/Minsk",53.9,27.5667 +"SO/Mogadishu",2.0392,45.3419 +"MC/Monaco",43.7333,7.4167 +"LR/Monrovia",6.3133,-10.8014 +"UY/Montevideo",-34.8836,-56.1819 +"KM/Moroni",-11.699,43.256 +"RU/Moscow",55.7558,37.6172 +"OM/Muscat",23.6139,58.5922 +"TD/N'Djamena",12.11,15.05 +"KE/Nairobi",-1.2864,36.8172 +"BS/Nassau",25.0781,-77.3386 +"MM/Nay Pyi Taw",19.7475,96.115 +"IN/New Delhi",28.6139,77.2089 +"PW/Ngerulmud",7.5006,134.6242 +"NE/Niamey",13.515,2.1175 +"CY/Nicosia",35.1725,33.365 +"MR/Nouakchott",18.0858,-15.9785 +"NC/Noumea",-22.2758,166.458 +"TO/Nuku`alofa",-21.1333,-175.2 +"GL/Nuuk",64.1814,-51.6942 +"AW/Oranjestad",12.5186,-70.0358 +"NO/Oslo",59.9133,10.7389 +"CA/Ottawa",45.4247,-75.695 +"BF/Ouagadougou",12.3686,-1.5275 +"AS/Pago Pago",-14.274,-170.7046 +"FM/Palikir",6.9172,158.1589 +"PA/Panama City",8.9833,-79.5167 +"PF/Papeete",-17.5334,-149.5667 +"SR/Paramaribo",5.8522,-55.2039 +"FR/Paris",48.8567,2.3522 +"SX/Philipsburg",18.0237,-63.0458 +"KH/Phnom Penh",11.5694,104.9211 +"MS/Plymouth",16.7064,-62.2158 +"ME/Podgorica",42.4414,19.2628 +"MU/Port Louis",-20.1644,57.5042 +"PG/Port Moresby",-9.4789,147.1494 +"TT/Port of Spain",10.6667,-61.5167 +"HT/Port-au-Prince",18.5333,-72.3333 +"VU/Port-Vila",-17.7333,168.3167 +"BJ/Porto-Novo",6.4972,2.605 +"CZ/Prague",50.0875,14.4214 +"CV/Praia",14.918,-23.509 +"ZA/Pretoria",-25.7461,28.1881 +"XK/Pristina",42.6633,21.1622 +"MY/Putrajaya",2.93,101.69 +"KP/Pyongyang",39.0167,125.7475 +"EC/Quito",-0.22,-78.5125 +"MA/Rabat",34.0209,-6.8416 +"MM/Rangoon",16.795,96.16 +"IS/Reykjavik",64.1467,-21.94 +"LV/Riga",56.9489,24.1064 +"SA/Riyadh",24.6333,46.7167 +"VG/Road Town",18.4167,-64.6167 +"IT/Rome",41.8933,12.4828 +"DM/Roseau",15.3014,-61.3883 +"GD/Saint George's",12.05,-61.75 +"JE/Saint Helier",49.1858,-2.11 +"AG/Saint John's",17.1167,-61.85 +"GG/Saint Peter Port",49.4555,-2.5368 +"RE/Saint-Denis",-20.8789,55.4481 +"PM/Saint-Pierre",46.7778,-56.1778 +"CR/San Jose",9.9325,-84.08 +"PR/San Juan",18.3985,-66.061 +"SM/San Marino",43.9346,12.4473 +"SV/San Salvador",13.6989,-89.1914 +"YE/Sanaa",15.3483,44.2064 +"CL/Santiago",-33.4372,-70.6506 +"DO/Santo Domingo",18.4667,-69.95 +"ST/Sao Tome",0.3361,6.7306 +"BA/Sarajevo",43.8564,18.4131 +"KR/Seoul",37.56,126.99 +"SG/Singapore",1.3,103.8 +"MK/Skopje",41.9961,21.4317 +"BG/Sofia",42.7,23.33 +"LK/Sri Jayewardenepura Kotte",6.9108,79.8878 +"FK/Stanley",-51.7,-57.85 +"SE/Stockholm",59.3294,18.0686 +"BO/Sucre",-19.0475,-65.26 +"FJ/Suva",-18.1416,178.4419 +"TW/Taipei",25.0375,121.5625 +"EE/Tallinn",59.4372,24.7453 +"KI/Tarawa",1.3382,173.0176 +"UZ/Tashkent",41.3111,69.2797 +"GE/Tbilisi",41.7225,44.7925 +"HN/Tegucigalpa",14.1058,-87.2047 +"IR/Tehran",35.6892,51.3889 +"NL/The Hague",52.08,4.31 +"AI/The Valley",18.2208,-63.0517 +"BT/Thimphu",27.4722,89.6361 +"MA/Tifariti",26.158,-10.567 +"AL/Tirana",41.3289,19.8178 +"JP/Tokyo",35.6897,139.6922 +"FO/Torshavn",62,-6.7833 +"LY/Tripoli",32.8872,13.1914 +"TN/Tunis",36.8064,10.1817 +"MN/Ulaanbaatar",47.9203,106.9172 +"LI/Vaduz",47.141,9.521 +"MT/Valletta",35.8983,14.5125 +"VA/Vatican City",41.904,12.453 +"SC/Victoria",-4.6231,55.4525 +"AT/Vienna",48.2083,16.3725 +"LA/Vientiane",17.98,102.63 +"LT/Vilnius",54.6872,25.28 +"PL/Warsaw",52.23,21.0111 +"US/Washington",38.9047,-77.0163 +"NZ/Wellington",-41.2889,174.7772 +"CW/Willemstad",12.108,-68.935 +"NA/Windhoek",-22.57,17.0836 +"CI/Yamoussoukro",6.8161,-5.2742 +"CM/Yaounde",3.8667,11.5167 +"NR/Yaren",-0.5477,166.9209 +"AM/Yerevan",40.1814,44.5144 +"HR/Zagreb",45.8131,15.9775 + diff --git a/locations/proto_locations_data.csv b/locations/proto_locations_data.csv new file mode 100644 index 0000000..b7659d9 --- /dev/null +++ b/locations/proto_locations_data.csv @@ -0,0 +1,17 @@ +name,lat,lng +"LV/Riga",56.9489,24.1064 +"NL/The Hague",52.08,4.31 +"AT/Vienna",48.2083,16.3725 +"BE/Brussels",50.8467,4.3525 +"DE/Berlin",52.52,13.405 +"FR/Paris",48.8567,2.3522 +"IE/Dublin",53.35,-6.2603 +"LT/Vilnius",54.6872,25.28 +"UK/London",51.5072,-0.1275 +"US/Anchorage",61.218056,-149.900284 +"US/Chicago",41.8781136,-87.6297982 +"US/Huntsville",34.7303688,-86.5861037 +"US/New York",40.712776,-74.005974 +"US/Washington",38.9047,-77.0163 +"US/Denver",39.739235,-104.99025 +"US/Los Angeles",34.052235,-118.243683 diff --git a/scripts/common.js b/scripts/common.js index 27444b9..e6f8bfc 100644 --- a/scripts/common.js +++ b/scripts/common.js @@ -1,5 +1,6 @@ -export const summaryTrendStats = ['avg', 'min', 'max', 'p(90)', 'p(95)'] +import papaparse from 'https://jslib.k6.io/papaparse/5.1.1/index.js' +export const summaryTrendStats = ['avg', 'min', 'max', 'p(90)', 'p(95)'] export const rpm = parseInt(__ENV.RPM || '60') export const durationInMinutes = parseInt(__ENV.TEST_DURATION || '3') const warmupDurationInMinutes = 2 @@ -53,296 +54,38 @@ export function setThresholdsForScenarios (options) { } } -function coords (coordinatesEnv) { - const coords = coordinatesEnv.split(',').map(coord => coord.trim()) - if (coords.length === 2) { - const [lat, lng] = coords.map(Number) - return { lat, lng } - } else { - throw new Error('Invalid coordinates format') +function getLocation (location, locationsMap) { + const coordinates = locationsMap.get(location) + if (coordinates === undefined) { + throw new Error(`Location "${location}" doesn't exist.`) } + return coordinates } -export function getCountryCoordinates (countryCode, coordinatesEnv) { - if (coordinatesEnv) { - return coords(coordinatesEnv) - } - return countries[countryCode] +export function getLocationCoordinates (location) { + return getLocation(location, locations) } -export function getProtoCountryCoordinates (countryCodeEnv, coordinatesEnv) { - if (coordinatesEnv && countryCodeEnv) { - return coords(coordinatesEnv) - } else if (coordinatesEnv && !countryCodeEnv) { - throw new Error('Country code must be specified with custom coords for protobuf requests') - } else if (countryCodeEnv && !coordinatesEnv) { - return protoCountries[countryCodeEnv] - } else { - return protoCountries.uk // default - } +export function getProtoLocationCoordinates (location) { + return getLocation(location, protoLocations) } -export const countries = { - gs: { lat: -54.283333, lng: -36.5 }, - tf: { lat: -49.35, lng: 70.216667 }, - ps: { lat: 31.7666666666667, lng: 35.233333 }, - ax: { lat: 60.116667, lng: 19.9 }, - nr: { lat: -0.5477, lng: 166.920867 }, - mf: { lat: 18.0731, lng: -63.0822 }, - tk: { lat: -9.166667, lng: -171.833333 }, - eh: { lat: 27.153611, lng: -13.203333 }, - af: { lat: 34.5166666666667, lng: 69.183333 }, - al: { lat: 41.3166666666667, lng: 19.816667 }, - dz: { lat: 36.75, lng: 3.05 }, - as: { lat: -14.2666666666667, lng: -170.7 }, - ad: { lat: 42.5, lng: 1.516667 }, - ao: { lat: -8.83333333333333, lng: 13.216667 }, - ai: { lat: 18.2166666666667, lng: -63.05 }, - ag: { lat: 17.1166666666667, lng: -61.85 }, - ar: { lat: -34.5833333333333, lng: -58.666667 }, - am: { lat: 40.1666666666667, lng: 44.5 }, - aw: { lat: 12.5166666666667, lng: -70.033333 }, - au: { lat: -35.2666666666667, lng: 149.133333 }, - at: { lat: 48.2, lng: 16.366667 }, - az: { lat: 40.3833333333333, lng: 49.866667 }, - bs: { lat: 25.0833333333333, lng: -77.35 }, - bh: { lat: 26.2333333333333, lng: 50.566667 }, - bd: { lat: 23.7166666666667, lng: 90.4 }, - bb: { lat: 13.1, lng: -59.616667 }, - by: { lat: 53.9, lng: 27.566667 }, - be: { lat: 50.8333333333333, lng: 4.333333 }, - bz: { lat: 17.25, lng: -88.766667 }, - bj: { lat: 6.48333333333333, lng: 2.616667 }, - bm: { lat: 32.2833333333333, lng: -64.783333 }, - bt: { lat: 27.4666666666667, lng: 89.633333 }, - bo: { lat: -16.5, lng: -68.15 }, - ba: { lat: 43.8666666666667, lng: 18.416667 }, - bw: { lat: -24.6333333333333, lng: 25.9 }, - br: { lat: -15.7833333333333, lng: -47.916667 }, - vg: { lat: 18.4166666666667, lng: -64.616667 }, - bn: { lat: 4.88333333333333, lng: 114.933333 }, - bg: { lat: 42.6833333333333, lng: 23.316667 }, - bf: { lat: 12.3666666666667, lng: -1.516667 }, - mm: { lat: 16.8, lng: 96.15 }, - bi: { lat: -3.36666666666667, lng: 29.35 }, - kh: { lat: 11.55, lng: 104.916667 }, - cm: { lat: 3.86666666666667, lng: 11.516667 }, - ca: { lat: 45.4166666666667, lng: -75.7 }, - cv: { lat: 14.9166666666667, lng: -23.516667 }, - ky: { lat: 19.3, lng: -81.383333 }, - cf: { lat: 4.36666666666667, lng: 18.583333 }, - td: { lat: 12.1, lng: 15.033333 }, - cl: { lat: -33.45, lng: -70.666667 }, - cn: { lat: 39.9166666666667, lng: 116.383333 }, - cx: { lat: -10.4166666666667, lng: 105.716667 }, - cc: { lat: -12.1666666666667, lng: 96.833333 }, - co: { lat: 4.6, lng: -74.083333 }, - km: { lat: -11.7, lng: 43.233333 }, - cd: { lat: -4.31666666666667, lng: 15.3 }, - cg: { lat: -4.25, lng: 15.283333 }, - ck: { lat: -21.2, lng: -159.766667 }, - cr: { lat: 9.93333333333333, lng: -84.083333 }, - ci: { lat: 6.81666666666667, lng: -5.266667 }, - hr: { lat: 45.8, lng: 16 }, - cu: { lat: 23.1166666666667, lng: -82.35 }, - cw: { lat: 12.1, lng: -68.916667 }, - cy: { lat: 35.1666666666667, lng: 33.366667 }, - cz: { lat: 50.0833333333333, lng: 14.466667 }, - dk: { lat: 55.6666666666667, lng: 12.583333 }, - dj: { lat: 11.5833333333333, lng: 43.15 }, - dm: { lat: 15.3, lng: -61.4 }, - do: { lat: 18.4666666666667, lng: -69.9 }, - ec: { lat: -0.216666666666667, lng: -78.5 }, - eg: { lat: 30.05, lng: 31.25 }, - sv: { lat: 13.7, lng: -89.2 }, - gq: { lat: 3.75, lng: 8.783333 }, - er: { lat: 15.3333333333333, lng: 38.933333 }, - ee: { lat: 59.4333333333333, lng: 24.716667 }, - et: { lat: 9.03333333333333, lng: 38.7 }, - fk: { lat: -51.7, lng: -57.85 }, - fo: { lat: 62, lng: -6.766667 }, - fj: { lat: -18.1333333333333, lng: 178.416667 }, - fi: { lat: 60.1666666666667, lng: 24.933333 }, - fr: { lat: 48.8666666666667, lng: 2.333333 }, - pf: { lat: -17.5333333333333, lng: -149.566667 }, - ga: { lat: 0.383333333333333, lng: 9.45 }, - gm: { lat: 13.45, lng: -16.566667 }, - ge: { lat: 41.6833333333333, lng: 44.833333 }, - de: { lat: 52.5166666666667, lng: 13.4 }, - gh: { lat: 5.55, lng: -0.216667 }, - gi: { lat: 36.1333333333333, lng: -5.35 }, - gr: { lat: 37.9833333333333, lng: 23.733333 }, - gl: { lat: 64.1833333333333, lng: -51.75 }, - gd: { lat: 12.05, lng: -61.75 }, - gu: { lat: 13.4666666666667, lng: 144.733333 }, - gt: { lat: 14.6166666666667, lng: -90.516667 }, - gg: { lat: 49.45, lng: -2.533333 }, - gn: { lat: 9.5, lng: -13.7 }, - gw: { lat: 11.85, lng: -15.583333 }, - gy: { lat: 6.8, lng: -58.15 }, - ht: { lat: 18.5333333333333, lng: -72.333333 }, - va: { lat: 41.9, lng: 12.45 }, - hn: { lat: 14.1, lng: -87.216667 }, - hu: { lat: 47.5, lng: 19.083333 }, - is: { lat: 64.15, lng: -21.95 }, - in: { lat: 28.6, lng: 77.2 }, - id: { lat: -6.16666666666667, lng: 106.816667 }, - ir: { lat: 35.7, lng: 51.416667 }, - iq: { lat: 33.3333333333333, lng: 44.4 }, - ie: { lat: 53.3166666666667, lng: -6.233333 }, - im: { lat: 54.15, lng: -4.483333 }, - il: { lat: 31.7666666666667, lng: 35.233333 }, - it: { lat: 41.9, lng: 12.483333 }, - jm: { lat: 18, lng: -76.8 }, - jp: { lat: 35.6833333333333, lng: 139.75 }, - je: { lat: 49.1833333333333, lng: -2.1 }, - jo: { lat: 31.95, lng: 35.933333 }, - kz: { lat: 51.1666666666667, lng: 71.416667 }, - ke: { lat: -1.28333333333333, lng: 36.816667 }, - ki: { lat: -0.883333333333333, lng: 169.533333 }, - kp: { lat: 39.0166666666667, lng: 125.75 }, - kr: { lat: 37.55, lng: 126.983333 }, - ko: { lat: 42.6666666666667, lng: 21.166667 }, - kw: { lat: 29.3666666666667, lng: 47.966667 }, - kg: { lat: 42.8666666666667, lng: 74.6 }, - la: { lat: 17.9666666666667, lng: 102.6 }, - lv: { lat: 56.95, lng: 24.1 }, - lb: { lat: 33.8666666666667, lng: 35.5 }, - ls: { lat: -29.3166666666667, lng: 27.483333 }, - lr: { lat: 6.3, lng: -10.8 }, - ly: { lat: 32.8833333333333, lng: 13.166667 }, - li: { lat: 47.1333333333333, lng: 9.516667 }, - lt: { lat: 54.6833333333333, lng: 25.316667 }, - lu: { lat: 49.6, lng: 6.116667 }, - mk: { lat: 42, lng: 21.433333 }, - mg: { lat: -18.9166666666667, lng: 47.516667 }, - mw: { lat: -13.9666666666667, lng: 33.783333 }, - my: { lat: 3.16666666666667, lng: 101.7 }, - mv: { lat: 4.16666666666667, lng: 73.5 }, - ml: { lat: 12.65, lng: -8 }, - mt: { lat: 35.8833333333333, lng: 14.5 }, - mh: { lat: 7.1, lng: 171.383333 }, - mr: { lat: 18.0666666666667, lng: -15.966667 }, - mu: { lat: -20.15, lng: 57.483333 }, - mx: { lat: 19.4333333333333, lng: -99.133333 }, - fm: { lat: 6.91666666666667, lng: 158.15 }, - md: { lat: 47, lng: 28.85 }, - mc: { lat: 43.7333333333333, lng: 7.416667 }, - mn: { lat: 47.9166666666667, lng: 106.916667 }, - me: { lat: 42.4333333333333, lng: 19.266667 }, - ms: { lat: 16.7, lng: -62.216667 }, - ma: { lat: 34.0166666666667, lng: -6.816667 }, - mz: { lat: -25.95, lng: 32.583333 }, - na: { lat: -22.5666666666667, lng: 17.083333 }, - np: { lat: 27.7166666666667, lng: 85.316667 }, - nl: { lat: 52.35, lng: 4.916667 }, - nc: { lat: -22.2666666666667, lng: 166.45 }, - nz: { lat: -41.3, lng: 174.783333 }, - ni: { lat: 12.1333333333333, lng: -86.25 }, - ne: { lat: 13.5166666666667, lng: 2.116667 }, - ng: { lat: 9.08333333333333, lng: 7.533333 }, - nu: { lat: -19.0166666666667, lng: -169.916667 }, - nf: { lat: -29.05, lng: 167.966667 }, - mp: { lat: 15.2, lng: 145.75 }, - no: { lat: 59.9166666666667, lng: 10.75 }, - om: { lat: 23.6166666666667, lng: 58.583333 }, - pk: { lat: 33.6833333333333, lng: 73.05 }, - pw: { lat: 7.48333333333333, lng: 134.633333 }, - pa: { lat: 8.96666666666667, lng: -79.533333 }, - pg: { lat: -9.45, lng: 147.183333 }, - py: { lat: -25.2666666666667, lng: -57.666667 }, - pe: { lat: -12.05, lng: -77.05 }, - ph: { lat: 14.6, lng: 120.966667 }, - pn: { lat: -25.0666666666667, lng: -130.083333 }, - pl: { lat: 52.25, lng: 21 }, - pt: { lat: 38.7166666666667, lng: -9.133333 }, - pr: { lat: 18.4666666666667, lng: -66.116667 }, - qa: { lat: 25.2833333333333, lng: 51.533333 }, - ro: { lat: 44.4333333333333, lng: 26.1 }, - ru: { lat: 55.75, lng: 37.6 }, - rw: { lat: -1.95, lng: 30.05 }, - bl: { lat: 17.8833333333333, lng: -62.85 }, - sh: { lat: -15.9333333333333, lng: -5.716667 }, - kn: { lat: 17.3, lng: -62.716667 }, - lc: { lat: 14, lng: -61 }, - pm: { lat: 46.7666666666667, lng: -56.183333 }, - vc: { lat: 13.1333333333333, lng: -61.216667 }, - ws: { lat: -13.8166666666667, lng: -171.766667 }, - sm: { lat: 43.9333333333333, lng: 12.416667 }, - st: { lat: 0.333333333333333, lng: 6.733333 }, - sa: { lat: 24.65, lng: 46.7 }, - sn: { lat: 14.7333333333333, lng: -17.633333 }, - rs: { lat: 44.8333333333333, lng: 20.5 }, - sc: { lat: -4.61666666666667, lng: 55.45 }, - sl: { lat: 8.48333333333333, lng: -13.233333 }, - sg: { lat: 1.28333333333333, lng: 103.85 }, - sx: { lat: 18.0333333333333, lng: -63.05 }, - sk: { lat: 48.15, lng: 17.116667 }, - si: { lat: 46.05, lng: 14.516667 }, - sb: { lat: -9.43333333333333, lng: 159.95 }, - so: { lat: 2.06666666666667, lng: 45.333333 }, - za: { lat: -25.7, lng: 28.216667 }, - ss: { lat: 4.85, lng: 31.616667 }, - es: { lat: 40.4, lng: -3.683333 }, - lk: { lat: 6.93333333333333, lng: 79.85 }, - sd: { lat: 15.6, lng: 32.533333 }, - sr: { lat: 5.86666666666667, lng: -55.166667 }, - sj: { lat: 78.2166666666667, lng: 15.633333 }, - sz: { lat: -26.3166666666667, lng: 31.133333 }, - se: { lat: 59.3333333333333, lng: 18.05 }, - ch: { lat: 46.9166666666667, lng: 7.466667 }, - sy: { lat: 33.5, lng: 36.3 }, - tw: { lat: 25.0333333333333, lng: 121.516667 }, - tj: { lat: 38.55, lng: 68.766667 }, - tz: { lat: -6.8, lng: 39.283333 }, - th: { lat: 13.75, lng: 100.516667 }, - tl: { lat: -8.56666666666667, lng: 125.6 }, - tg: { lat: 6.11666666666667, lng: 1.216667 }, - tkl: { lat: -9.16666666666667, lng: -171.833333 }, - to: { lat: -21.1333333333333, lng: -175.2 }, - tt: { lat: 10.65, lng: -61.516667 }, - tn: { lat: 36.8, lng: 10.183333 }, - tr: { lat: 39.9333333333333, lng: 32.866667 }, - tm: { lat: 37.95, lng: 58.383333 }, - tc: { lat: 21.4666666666667, lng: -71.133333 }, - tv: { lat: -8.51666666666667, lng: 179.216667 }, - ug: { lat: 0.313611, lng: 32.581111 }, - ua: { lat: 50.4333333333333, lng: 30.516667 }, - ae: { lat: 25.276987, lng: 55.296249 }, - gb: { lat: 51.5, lng: -0.083333 }, - us: { lat: 38.895110, lng: -77.036366 }, - vi: { lat: 18.35, lng: -64.933333 }, - uy: { lat: -34.9, lng: -56.191667 }, - uz: { lat: 41.3166666666667, lng: 69.25 }, - vu: { lat: -17.7333333333333, lng: 168.316667 }, - ve: { lat: 10.4833333333333, lng: -66.866667 }, - vn: { lat: 21.0333333333333, lng: 105.85 }, - wf: { lat: -17.75, lng: 168.3 }, - ye: { lat: 15.35, lng: 44.2 }, - zm: { lat: -15.4166666666667, lng: 28.283333 }, - zw: { lat: -17.8166666666667, lng: 31.033333 } -} +function parseLocations (filePath) { + const file = open(filePath) + const parsedData = papaparse.parse(file, { header: true, skipEmptyLines: true }).data + + return new Map(parsedData.map(location => { + const name = location.name + const lat = parseFloat(location.lat) + const lng = parseFloat(location.lng) -export const protoCountries = { - lv: { lat: 56.945614, lng: 24.120870 }, - nl: { lat: 52.3650144, lng: 4.892851 }, - at: { lat: 48.2244617, lng: 16.326472 }, - be: { lat: 50.8610222, lng: 4.384314 }, - de: { lat: 52.5446, lng: 13.35 }, - fr: { lat: 48.8540899, lng: 2.325747 }, - ie: { lat: 53.3129170, lng: -6.3308734 }, - lt: { lat: 54.6584053, lng: 25.2288244 }, - uk: { lat: 51.42561, lng: -0.128015 }, - us_akst: { lat: 61.218056, lng: -149.900284 }, - us_cstn: { lat: 41.8781136, lng: -87.6297982 }, - us_csts: { lat: 34.7303688, lng: -86.5861037 }, - us_estn: { lat: 40.712776, lng: -74.005974 }, - us_ests: { lat: 38.907192, lng: -77.036873 }, - us_hi: { lat: 21.3098845, lng: -157.8581401 }, - us_mst: { lat: 39.739235, lng: -104.990250 }, - us_pst: { lat: 34.052235, lng: -118.243683 } + return [name, { lat, lng }] + })) } +export const locations = parseLocations('../locations/locations_data.csv') +export const protoLocations = parseLocations('../locations/proto_locations_data.csv') + function randomInRange (min, max) { return Math.random() * (max - min) + min } diff --git a/scripts/routes.js b/scripts/routes.js index 72f4fb4..ba3f361 100644 --- a/scripts/routes.js +++ b/scripts/routes.js @@ -15,7 +15,7 @@ import { summaryTrendStats, deleteOneScenarioMetrics, oneScenarioReport, - getCountryCoordinates, + getLocationCoordinates, randomIndex } from './common.js' @@ -37,8 +37,8 @@ export function setup () { const appId = __ENV.APP_ID const apiKey = __ENV.API_KEY const host = __ENV.HOST || 'api.traveltimeapp.com' - const countryCode = __ENV.COUNTRY || 'gb' - const countryCoords = getCountryCoordinates(countryCode, __ENV.COORDINATES) + const location = __ENV.LOCATION || 'GB/London' + const locationCoords = getLocationCoordinates(location) const url = `https://${host}/v4/routes` const transportation = __ENV.TRANSPORTATION || 'driving+ferry' const uniqueRequestsAmount = parseInt(__ENV.UNIQUE_REQUESTS || 100) @@ -55,7 +55,7 @@ export function setup () { const requestBodies = precomputedDataFile ? readRequestsBodies(transportation, dateTime, precomputedDataFile) - : generateRequestBodies(uniqueRequestsAmount, transportation, countryCoords, dateTime) + : generateRequestBodies(uniqueRequestsAmount, transportation, locationCoords, dateTime) return { url, requestBodies, params } } @@ -131,7 +131,7 @@ function readRequestsBodies (transportation, dateTime, precomputedDataFile) { return data } -function generateRequestBodies (count, transportation, countryCoords, dateTime) { +function generateRequestBodies (count, transportation, locationCoords, dateTime) { console.log('The amount of requests generated: ' + count) const diff = 0.01 @@ -141,8 +141,8 @@ function generateRequestBodies (count, transportation, countryCoords, dateTime) () => generateBody( transportation, dateTime, - generateRandomCoordinate(countryCoords.lat, countryCoords.lng, diff), - generateRandomCoordinate(countryCoords.lat, countryCoords.lng, diff) + generateRandomCoordinate(locationCoords.lat, locationCoords.lng, diff), + generateRandomCoordinate(locationCoords.lat, locationCoords.lng, diff) ) ) } diff --git a/scripts/time-filter-proto.js b/scripts/time-filter-proto.js index 2848034..c56c7d7 100644 --- a/scripts/time-filter-proto.js +++ b/scripts/time-filter-proto.js @@ -16,7 +16,7 @@ import { deleteOneScenarioMetrics, setThresholdsForScenarios, summaryTrendStats, - getProtoCountryCoordinates, + getProtoLocationCoordinates, randomIndex } from './common.js' @@ -44,9 +44,11 @@ export function setup () { const transportation = __ENV.TRANSPORTATION || 'driving+ferry' const protocol = __ENV.PROTOCOL || 'https' const travelTime = parseInt(__ENV.TRAVEL_TIME || 7200) - const envCountry = __ENV.COUNTRY - const countryCoords = getProtoCountryCoordinates(envCountry, __ENV.COORDINATES, true) - const country = envCountry || 'uk' + + const location = __ENV.LOCATION || 'UK/London' + const country = location.slice(0, 2).toLowerCase() + const locationCoords = getProtoLocationCoordinates(location) + const query = __ENV.QUERY || `api/v2/${countryCode(country)}/time-filter/fast/${transportation}` const isManyToOne = __ENV.MANY_TO_ONE !== undefined const uniqueRequestsAmount = parseInt(__ENV.UNIQUE_REQUESTS || 100) @@ -67,7 +69,7 @@ export function setup () { const requestBodies = precomputedDataFile ? readRequestsBodies(destinationsAmount, transportation, travelTime, isManyToOne, precomputedDataFile) - : generateRequestBodies(uniqueRequestsAmount, destinationsAmount, countryCoords, transportation, travelTime, isManyToOne) + : generateRequestBodies(uniqueRequestsAmount, destinationsAmount, locationCoords, transportation, travelTime, isManyToOne) return { url, requestBodies, params, disableBodyDecoding } } diff --git a/scripts/time-filter.js b/scripts/time-filter.js index 319ea77..8590a79 100644 --- a/scripts/time-filter.js +++ b/scripts/time-filter.js @@ -15,7 +15,7 @@ import { oneScenarioReport, deleteOneScenarioMetrics, summaryTrendStats, - getCountryCoordinates, + getLocationCoordinates, randomIndex } from './common.js' @@ -37,8 +37,8 @@ export function setup () { const appId = __ENV.APP_ID const apiKey = __ENV.API_KEY const host = __ENV.HOST || 'api.traveltimeapp.com' - const countryCode = __ENV.COUNTRY || 'gb' - const countryCoords = getCountryCoordinates(countryCode, __ENV.COORDINATES) + const location = __ENV.LOCATION || 'GB/London' + const locationCoords = getLocationCoordinates(location) const url = `https://${host}/v4/time-filter` const transportation = __ENV.TRANSPORTATION || 'driving+ferry' const travelTime = parseInt(__ENV.TRAVEL_TIME || 1900) @@ -62,7 +62,7 @@ export function setup () { const requestBodies = precomputedDataFile ? readRequestsBodies(travelTime, transportation, destinationsAmount, rangeSettings, dateTime, precomputedDataFile) - : generateRequestBodies(uniqueRequestsAmount, travelTime, transportation, destinationsAmount, rangeSettings, countryCoords, dateTime) + : generateRequestBodies(uniqueRequestsAmount, travelTime, transportation, destinationsAmount, rangeSettings, locationCoords, dateTime) return { url, requestBodies, params } } @@ -158,7 +158,7 @@ function generateRequestBodies ( transportation, destinationsAmount, rangeSettings, - countryCoords, + locationCoords, dateTime ) { console.log('The amount of requests generated: ' + count) @@ -172,7 +172,7 @@ function generateRequestBodies ( transportation, destinationsAmount, rangeSettings, - generateRandomCoordinate(countryCoords.lat, countryCoords.lng, diff), + generateRandomCoordinate(locationCoords.lat, locationCoords.lng, diff), dateTime ) ) diff --git a/scripts/time-map-fast.js b/scripts/time-map-fast.js index 066fa12..2c87248 100644 --- a/scripts/time-map-fast.js +++ b/scripts/time-map-fast.js @@ -15,7 +15,7 @@ import { setThresholdsForScenarios, oneScenarioReport, deleteOneScenarioMetrics, - getCountryCoordinates, + getLocationCoordinates, randomIndex } from './common.js' @@ -37,8 +37,8 @@ export function setup () { const appId = __ENV.APP_ID const apiKey = __ENV.API_KEY const host = __ENV.HOST || 'api.traveltimeapp.com' - const countryCode = __ENV.COUNTRY || 'gb' - const countryCoords = getCountryCoordinates(countryCode, __ENV.COORDINATES) + const location = __ENV.LOCATION || 'GB/London' + const locationCoords = getLocationCoordinates(location) const url = `https://${host}/v4/time-map/fast` const transportation = __ENV.TRANSPORTATION || 'driving+ferry' const travelTime = parseInt(__ENV.TRAVEL_TIME || 7200) @@ -56,7 +56,7 @@ export function setup () { const requestBodies = precomputedDataFile ? readRequestsBodies(travelTime, transportation, arrivalTimePeriod, levelOfDetails, precomputedDataFile) - : generateRequestBodies(uniqueRequestsAmount, travelTime, transportation, countryCoords, arrivalTimePeriod, levelOfDetails) + : generateRequestBodies(uniqueRequestsAmount, travelTime, transportation, locationCoords, arrivalTimePeriod, levelOfDetails) return { url, requestBodies, params } } @@ -126,7 +126,7 @@ function readRequestsBodies (travelTime, transportation, arrivalTimePeriod, leve return data } -function generateRequestBodies (count, travelTime, transportation, countryCoords, arrivalTimePeriod, levelOfDetails) { +function generateRequestBodies (count, travelTime, transportation, locationCoords, arrivalTimePeriod, levelOfDetails) { console.log('The amount of requests generated: ' + count) const diff = 0.01 @@ -136,7 +136,7 @@ function generateRequestBodies (count, travelTime, transportation, countryCoords () => generateBody( travelTime, transportation, - generateRandomCoordinate(countryCoords.lat, countryCoords.lng, diff), + generateRandomCoordinate(locationCoords.lat, locationCoords.lng, diff), arrivalTimePeriod, levelOfDetails ) diff --git a/scripts/time-map.js b/scripts/time-map.js index e348486..a1872d4 100644 --- a/scripts/time-map.js +++ b/scripts/time-map.js @@ -14,7 +14,7 @@ import { setThresholdsForScenarios, deleteOneScenarioMetrics, oneScenarioReport, - getCountryCoordinates, + getLocationCoordinates, summaryTrendStats, randomIndex } from './common.js' @@ -37,8 +37,8 @@ export function setup () { const appId = __ENV.APP_ID const apiKey = __ENV.API_KEY const host = __ENV.HOST || 'api.traveltimeapp.com' - const countryCode = __ENV.COUNTRY || 'gb' - const countryCoords = getCountryCoordinates(countryCode, __ENV.COORDINATES) + const location = __ENV.LOCATION || 'GB/London' + const locationCoords = getLocationCoordinates(location) const url = `https://${host}/v4/time-map` const transportation = __ENV.TRANSPORTATION || 'driving+ferry' const travelTime = parseInt(__ENV.TRAVEL_TIME || 7200) @@ -55,7 +55,7 @@ export function setup () { const requestBodies = precomputedDataFile ? readRequestsBodies(travelTime, transportation, dateTime, precomputedDataFile) - : generateRequestBodies(uniqueRequestsAmount, travelTime, transportation, countryCoords, dateTime) + : generateRequestBodies(uniqueRequestsAmount, travelTime, transportation, locationCoords, dateTime) return { url, requestBodies, params } } @@ -116,7 +116,7 @@ function readRequestsBodies (travelTime, transportation, dateTime, precomputedDa return data } -function generateRequestBodies (count, travelTime, transportation, countryCoords, dateTime) { +function generateRequestBodies (count, travelTime, transportation, locationCoords, dateTime) { console.log('The amount of requests generated: ' + count) const diff = 0.01 @@ -126,7 +126,7 @@ function generateRequestBodies (count, travelTime, transportation, countryCoords () => generateBody( travelTime, transportation, - generateRandomCoordinate(countryCoords.lat, countryCoords.lng, diff), + generateRandomCoordinate(locationCoords.lat, locationCoords.lng, diff), dateTime ) )