From d85e4a78b2a85dad384a1c56b468389b29358b4c Mon Sep 17 00:00:00 2001 From: arnasbr Date: Fri, 26 Apr 2024 18:25:59 +0300 Subject: [PATCH 1/8] Reworking locations --- README.md | 42 +- locations_data.json | 1030 ++++++++++++++++++++++++++++++++++ proto_locations_data.json | 66 +++ scripts/common.js | 291 +--------- scripts/routes.js | 4 +- scripts/time-filter-proto.js | 8 +- scripts/time-filter.js | 4 +- scripts/time-map-fast.js | 4 +- scripts/time-map.js | 4 +- 9 files changed, 1125 insertions(+), 328 deletions(-) create mode 100644 locations_data.json create mode 100644 proto_locations_data.json diff --git a/README.md b/README.md index e8735f6..d079284 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,12 @@ 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_data.json` file. +- Supported locations for proto requests are listed in the `proto_locations_data.json` 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 files. **NOTE:** 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_data.json b/locations_data.json new file mode 100644 index 0000000..018bd6c --- /dev/null +++ b/locations_data.json @@ -0,0 +1,1030 @@ +{ + "CI/Abidjan": { + "lat": 5.3167, + "lng": -4.0333 + }, + "AE/Abu Dhabi": { + "lat": 24.4667, + "lng": 54.3667 + }, + "NG/Abuja": { + "lat": 9.0667, + "lng": 7.4833 + }, + "GH/Accra": { + "lat": 5.55, + "lng": -0.2 + }, + "PN/Adamstown": { + "lat": -25.0667, + "lng": -130.1 + }, + "ET/Addis Ababa": { + "lat": 9.03, + "lng": 38.74 + }, + "DZ/Algiers": { + "lat": 36.7539, + "lng": 3.0589 + }, + "NU/Alofi": { + "lat": -19.056, + "lng": -169.921 + }, + "JO/Amman": { + "lat": 31.9497, + "lng": 35.9328 + }, + "NL/Amsterdam": { + "lat": 52.3728, + "lng": 4.8936 + }, + "AD/Andorra la Vella": { + "lat": 42.5, + "lng": 1.5 + }, + "TR/Ankara": { + "lat": 39.93, + "lng": 32.85 + }, + "MG/Antananarivo": { + "lat": -18.91, + "lng": 47.525 + }, + "WS/Apia": { + "lat": -13.8333, + "lng": -171.75 + }, + "TM/Ashgabat": { + "lat": 37.9375, + "lng": 58.38 + }, + "ER/Asmara": { + "lat": 15.3228, + "lng": 38.925 + }, + "KZ/Astana": { + "lat": 51.1472, + "lng": 71.4222 + }, + "PY/Asuncion": { + "lat": -25.3, + "lng": -57.6333 + }, + "GR/Athens": { + "lat": 37.9842, + "lng": 23.7281 + }, + "CK/Avarua": { + "lat": -21.207, + "lng": -159.771 + }, + "IQ/Baghdad": { + "lat": 33.3153, + "lng": 44.3661 + }, + "AZ/Baku": { + "lat": 40.3953, + "lng": 49.8822 + }, + "ML/Bamako": { + "lat": 12.6392, + "lng": -8.0028 + }, + "BN/Bandar Seri Begawan": { + "lat": 4.8903, + "lng": 114.9422 + }, + "TH/Bangkok": { + "lat": 13.7525, + "lng": 100.4942 + }, + "CF/Bangui": { + "lat": 4.3733, + "lng": 18.5628 + }, + "GM/Banjul": { + "lat": 13.4531, + "lng": -16.5775 + }, + "GP/Basse-Terre": { + "lat": 16.0104, + "lng": -61.7055 + }, + "KN/Basseterre": { + "lat": 17.3, + "lng": -62.7333 + }, + "CN/Beijing": { + "lat": 39.9067, + "lng": 116.3975 + }, + "LB/Beirut": { + "lat": 33.8983, + "lng": 35.5057 + }, + "RS/Belgrade": { + "lat": 44.82, + "lng": 20.46 + }, + "BZ/Belmopan": { + "lat": 17.2514, + "lng": -88.7669 + }, + "DE/Berlin": { + "lat": 52.52, + "lng": 13.405 + }, + "CH/Bern": { + "lat": 46.9481, + "lng": 7.4475 + }, + "KG/Bishkek": { + "lat": 42.8747, + "lng": 74.6122 + }, + "GW/Bissau": { + "lat": 11.85, + "lng": -15.5667 + }, + "ZA/Bloemfontein": { + "lat": -29.1167, + "lng": 26.2167 + }, + "CO/Bogota": { + "lat": 4.7111, + "lng": -74.0722 + }, + "MS/Brades": { + "lat": 16.7928, + "lng": -62.2106 + }, + "BR/Brasilia": { + "lat": -15.7939, + "lng": -47.8828 + }, + "SK/Bratislava": { + "lat": 48.1439, + "lng": 17.1097 + }, + "CG/Brazzaville": { + "lat": -4.2694, + "lng": 15.2711 + }, + "BB/Bridgetown": { + "lat": 13.0975, + "lng": -59.6167 + }, + "BE/Brussels": { + "lat": 50.8467, + "lng": 4.3525 + }, + "RO/Bucharest": { + "lat": 44.4325, + "lng": 26.1039 + }, + "HU/Budapest": { + "lat": 47.4925, + "lng": 19.0514 + }, + "AR/Buenos Aires": { + "lat": -34.6033, + "lng": -58.3817 + }, + "BI/Bujumbura": { + "lat": -3.3833, + "lng": 29.3667 + }, + "EG/Cairo": { + "lat": 30.0444, + "lng": 31.2358 + }, + "AU/Canberra": { + "lat": -35.2931, + "lng": 149.1269 + }, + "ZA/Cape Town": { + "lat": -33.9253, + "lng": 18.4239 + }, + "MP/Capitol Hill": { + "lat": 15.2137, + "lng": 145.7546 + }, + "VE/Caracas": { + "lat": 10.4806, + "lng": -66.9036 + }, + "LC/Castries": { + "lat": 14.0167, + "lng": -60.9833 + }, + "GF/Cayenne": { + "lat": 4.933, + "lng": -52.33 + }, + "VI/Charlotte Amalie": { + "lat": 18.342, + "lng": -64.9331 + }, + "MD/Chisinau": { + "lat": 47.0228, + "lng": 28.8353 + }, + "LK/Colombo": { + "lat": 6.9344, + "lng": 79.8428 + }, + "GN/Conakry": { + "lat": 9.5092, + "lng": -13.7122 + }, + "DK/Copenhagen": { + "lat": 55.6761, + "lng": 12.5683 + }, + "BJ/Cotonou": { + "lat": 6.3667, + "lng": 2.4333 + }, + "SN/Dakar": { + "lat": 14.6928, + "lng": -17.4467 + }, + "SY/Damascus": { + "lat": 33.5131, + "lng": 36.2919 + }, + "BD/Dhaka": { + "lat": 23.7639, + "lng": 90.3889 + }, + "TL/Dili": { + "lat": -8.5536, + "lng": 125.5783 + }, + "DJ/Djibouti": { + "lat": 11.5883, + "lng": 43.145 + }, + "TZ/Dodoma": { + "lat": -6.1731, + "lng": 35.7419 + }, + "QA/Doha": { + "lat": 25.2867, + "lng": 51.5333 + }, + "IM/Douglas": { + "lat": 54.15, + "lng": -4.4775 + }, + "IE/Dublin": { + "lat": 53.35, + "lng": -6.2603 + }, + "TJ/Dushanbe": { + "lat": 38.5367, + "lng": 68.78 + }, + "CX/Flying Fish Cove": { + "lat": -10.4261, + "lng": 105.6728 + }, + "MQ/Fort-de-France": { + "lat": 14.6, + "lng": -61.0667 + }, + "SL/Freetown": { + "lat": 8.4844, + "lng": -13.2344 + }, + "TV/Funafuti": { + "lat": -8.5167, + "lng": 179.2 + }, + "BW/Gaborone": { + "lat": -24.6581, + "lng": 25.9122 + }, + "XG/Gaza": { + "lat": 31.5069, + "lng": 34.456 + }, + "KY/George Town": { + "lat": 19.2866, + "lng": -81.3744 + }, + "GY/Georgetown": { + "lat": 6.8058, + "lng": -58.1508 + }, + "GI/Gibraltar": { + "lat": 36.14, + "lng": -5.35 + }, + "BI/Gitega": { + "lat": -3.4283, + "lng": 29.925 + }, + "TC/Grand Turk": { + "lat": 21.459, + "lng": -71.139 + }, + "GT/Guatemala City": { + "lat": 14.6133, + "lng": -90.5353 + }, + "BL/Gustavia": { + "lat": 17.8979, + "lng": -62.8506 + }, + "GU/Hagta": { + "lat": 13.4745, + "lng": 144.7504 + }, + "BM/Hamilton": { + "lat": 32.293, + "lng": -64.782 + }, + "VN/Hanoi": { + "lat": 21, + "lng": 105.85 + }, + "ZW/Harare": { + "lat": -17.8292, + "lng": 31.0522 + }, + "CU/Havana": { + "lat": 23.1367, + "lng": -82.3589 + }, + "FI/Helsinki": { + "lat": 60.1708, + "lng": 24.9375 + }, + "HK/Hong Kong": { + "lat": 22.3, + "lng": 114.2 + }, + "SB/Honiara": { + "lat": -9.4319, + "lng": 159.9556 + }, + "PK/Islamabad": { + "lat": 33.6931, + "lng": 73.0639 + }, + "ID/Jakarta": { + "lat": -6.175, + "lng": 106.8275 + }, + "SH/Jamestown": { + "lat": -15.9251, + "lng": -5.7179 + }, + "IL/Jerusalem": { + "lat": 31.7789, + "lng": 35.2256 + }, + "SS/Juba": { + "lat": 4.85, + "lng": 31.6 + }, + "AF/Kabul": { + "lat": 34.5253, + "lng": 69.1783 + }, + "UG/Kampala": { + "lat": 0.3136, + "lng": 32.5811 + }, + "NP/Kathmandu": { + "lat": 27.71, + "lng": 85.32 + }, + "SD/Khartoum": { + "lat": 15.6, + "lng": 32.5 + }, + "RW/Kigali": { + "lat": -1.9439, + "lng": 30.0594 + }, + "GS/King Edward Point": { + "lat": -54.2833, + "lng": -36.5 + }, + "JM/Kingston": { + "lat": 17.9714, + "lng": -76.7931 + }, + "NF/Kingston": { + "lat": -29.0606, + "lng": 167.9619 + }, + "VC/Kingstown": { + "lat": 13.1578, + "lng": -61.225 + }, + "CD/Kinshasa": { + "lat": -4.3219, + "lng": 15.3119 + }, + "MY/Kuala Lumpur": { + "lat": 3.1478, + "lng": 101.6953 + }, + "KW/Kuwait City": { + "lat": 29.3697, + "lng": 47.9783 + }, + "UA/Kyiv": { + "lat": 50.45, + "lng": 30.5233 + }, + "BO/La Paz": { + "lat": -16.4958, + "lng": -68.1333 + }, + "GA/Libreville": { + "lat": 0.3903, + "lng": 9.4542 + }, + "MW/Lilongwe": { + "lat": -13.9833, + "lng": 33.7833 + }, + "PE/Lima": { + "lat": -12.06, + "lng": -77.0375 + }, + "PT/Lisbon": { + "lat": 38.7253, + "lng": -9.15 + }, + "SI/Ljubljana": { + "lat": 46.0514, + "lng": 14.5061 + }, + "SZ/Lobamba": { + "lat": -26.4465, + "lng": 31.2064 + }, + "TG/Lome": { + "lat": 6.1319, + "lng": 1.2228 + }, + "GB/London": { + "lat": 51.5072, + "lng": -0.1275 + }, + "XR/Longyearbyen": { + "lat": 78.22, + "lng": 15.65 + }, + "AO/Luanda": { + "lat": -8.8383, + "lng": 13.2344 + }, + "ZM/Lusaka": { + "lat": -15.4167, + "lng": 28.2833 + }, + "LU/Luxembourg": { + "lat": 49.6117, + "lng": 6.1319 + }, + "ES/Madrid": { + "lat": 40.4169, + "lng": -3.7033 + }, + "MH/Majuro": { + "lat": 7.0833, + "lng": 171.3833 + }, + "GQ/Malabo": { + "lat": 3.7456, + "lng": 8.7744 + }, + "MV/Male": { + "lat": 4.1753, + "lng": 73.5089 + }, + "YT/Mamoudzou": { + "lat": -12.7806, + "lng": 45.2278 + }, + "NI/Managua": { + "lat": 12.1364, + "lng": -86.2514 + }, + "BH/Manama": { + "lat": 26.225, + "lng": 50.5775 + }, + "PH/Manila": { + "lat": 14.5958, + "lng": 120.9772 + }, + "MZ/Maputo": { + "lat": -25.9667, + "lng": 32.5833 + }, + "MF/Marigot": { + "lat": 18.0706, + "lng": -63.0847 + }, + "LS/Maseru": { + "lat": -29.31, + "lng": 27.48 + }, + "WF/Mata-Utu": { + "lat": -13.2833, + "lng": -176.1833 + }, + "SZ/Mbabane": { + "lat": -26.3167, + "lng": 31.1333 + }, + "MX/Mexico City": { + "lat": 19.4333, + "lng": -99.1333 + }, + "BY/Minsk": { + "lat": 53.9, + "lng": 27.5667 + }, + "SO/Mogadishu": { + "lat": 2.0392, + "lng": 45.3419 + }, + "MC/Monaco": { + "lat": 43.7333, + "lng": 7.4167 + }, + "LR/Monrovia": { + "lat": 6.3133, + "lng": -10.8014 + }, + "UY/Montevideo": { + "lat": -34.8836, + "lng": -56.1819 + }, + "KM/Moroni": { + "lat": -11.699, + "lng": 43.256 + }, + "RU/Moscow": { + "lat": 55.7558, + "lng": 37.6172 + }, + "OM/Muscat": { + "lat": 23.6139, + "lng": 58.5922 + }, + "TD/N'Djamena": { + "lat": 12.11, + "lng": 15.05 + }, + "KE/Nairobi": { + "lat": -1.2864, + "lng": 36.8172 + }, + "BS/Nassau": { + "lat": 25.0781, + "lng": -77.3386 + }, + "MM/Nay Pyi Taw": { + "lat": 19.7475, + "lng": 96.115 + }, + "IN/New Delhi": { + "lat": 28.6139, + "lng": 77.2089 + }, + "PW/Ngerulmud": { + "lat": 7.5006, + "lng": 134.6242 + }, + "NE/Niamey": { + "lat": 13.515, + "lng": 2.1175 + }, + "CY/Nicosia": { + "lat": 35.1725, + "lng": 33.365 + }, + "MR/Nouakchott": { + "lat": 18.0858, + "lng": -15.9785 + }, + "NC/Noumea": { + "lat": -22.2758, + "lng": 166.458 + }, + "TO/Nuku`alofa": { + "lat": -21.1333, + "lng": -175.2 + }, + "GL/Nuuk": { + "lat": 64.1814, + "lng": -51.6942 + }, + "AW/Oranjestad": { + "lat": 12.5186, + "lng": -70.0358 + }, + "NO/Oslo": { + "lat": 59.9133, + "lng": 10.7389 + }, + "CA/Ottawa": { + "lat": 45.4247, + "lng": -75.695 + }, + "BF/Ouagadougou": { + "lat": 12.3686, + "lng": -1.5275 + }, + "AS/Pago Pago": { + "lat": -14.274, + "lng": -170.7046 + }, + "FM/Palikir": { + "lat": 6.9172, + "lng": 158.1589 + }, + "PA/Panama City": { + "lat": 8.9833, + "lng": -79.5167 + }, + "PF/Papeete": { + "lat": -17.5334, + "lng": -149.5667 + }, + "SR/Paramaribo": { + "lat": 5.8522, + "lng": -55.2039 + }, + "FR/Paris": { + "lat": 48.8567, + "lng": 2.3522 + }, + "SX/Philipsburg": { + "lat": 18.0237, + "lng": -63.0458 + }, + "KH/Phnom Penh": { + "lat": 11.5694, + "lng": 104.9211 + }, + "MS/Plymouth": { + "lat": 16.7064, + "lng": -62.2158 + }, + "ME/Podgorica": { + "lat": 42.4414, + "lng": 19.2628 + }, + "MU/Port Louis": { + "lat": -20.1644, + "lng": 57.5042 + }, + "PG/Port Moresby": { + "lat": -9.4789, + "lng": 147.1494 + }, + "TT/Port of Spain": { + "lat": 10.6667, + "lng": -61.5167 + }, + "HT/Port-au-Prince": { + "lat": 18.5333, + "lng": -72.3333 + }, + "VU/Port-Vila": { + "lat": -17.7333, + "lng": 168.3167 + }, + "BJ/Porto-Novo": { + "lat": 6.4972, + "lng": 2.605 + }, + "CZ/Prague": { + "lat": 50.0875, + "lng": 14.4214 + }, + "CV/Praia": { + "lat": 14.918, + "lng": -23.509 + }, + "ZA/Pretoria": { + "lat": -25.7461, + "lng": 28.1881 + }, + "XK/Pristina": { + "lat": 42.6633, + "lng": 21.1622 + }, + "MY/Putrajaya": { + "lat": 2.93, + "lng": 101.69 + }, + "KP/Pyongyang": { + "lat": 39.0167, + "lng": 125.7475 + }, + "EC/Quito": { + "lat": -0.22, + "lng": -78.5125 + }, + "MA/Rabat": { + "lat": 34.0209, + "lng": -6.8416 + }, + "MM/Rangoon": { + "lat": 16.795, + "lng": 96.16 + }, + "IS/Reykjavik": { + "lat": 64.1467, + "lng": -21.94 + }, + "LV/Riga": { + "lat": 56.9489, + "lng": 24.1064 + }, + "SA/Riyadh": { + "lat": 24.6333, + "lng": 46.7167 + }, + "VG/Road Town": { + "lat": 18.4167, + "lng": -64.6167 + }, + "IT/Rome": { + "lat": 41.8933, + "lng": 12.4828 + }, + "DM/Roseau": { + "lat": 15.3014, + "lng": -61.3883 + }, + "GD/Saint George's": { + "lat": 12.05, + "lng": -61.75 + }, + "JE/Saint Helier": { + "lat": 49.1858, + "lng": -2.11 + }, + "AG/Saint John's": { + "lat": 17.1167, + "lng": -61.85 + }, + "GG/Saint Peter Port": { + "lat": 49.4555, + "lng": -2.5368 + }, + "RE/Saint-Denis": { + "lat": -20.8789, + "lng": 55.4481 + }, + "PM/Saint-Pierre": { + "lat": 46.7778, + "lng": -56.1778 + }, + "CR/San Jose": { + "lat": 9.9325, + "lng": -84.08 + }, + "PR/San Juan": { + "lat": 18.3985, + "lng": -66.061 + }, + "SM/San Marino": { + "lat": 43.9346, + "lng": 12.4473 + }, + "SV/San Salvador": { + "lat": 13.6989, + "lng": -89.1914 + }, + "YE/Sanaa": { + "lat": 15.3483, + "lng": 44.2064 + }, + "CL/Santiago": { + "lat": -33.4372, + "lng": -70.6506 + }, + "DO/Santo Domingo": { + "lat": 18.4667, + "lng": -69.95 + }, + "ST/Sao Tome": { + "lat": 0.3361, + "lng": 6.7306 + }, + "BA/Sarajevo": { + "lat": 43.8564, + "lng": 18.4131 + }, + "KR/Seoul": { + "lat": 37.56, + "lng": 126.99 + }, + "SG/Singapore": { + "lat": 1.3, + "lng": 103.8 + }, + "MK/Skopje": { + "lat": 41.9961, + "lng": 21.4317 + }, + "BG/Sofia": { + "lat": 42.7, + "lng": 23.33 + }, + "LK/Sri Jayewardenepura Kotte": { + "lat": 6.9108, + "lng": 79.8878 + }, + "FK/Stanley": { + "lat": -51.7, + "lng": -57.85 + }, + "SE/Stockholm": { + "lat": 59.3294, + "lng": 18.0686 + }, + "BO/Sucre": { + "lat": -19.0475, + "lng": -65.26 + }, + "FJ/Suva": { + "lat": -18.1416, + "lng": 178.4419 + }, + "TW/Taipei": { + "lat": 25.0375, + "lng": 121.5625 + }, + "EE/Tallinn": { + "lat": 59.4372, + "lng": 24.7453 + }, + "KI/Tarawa": { + "lat": 1.3382, + "lng": 173.0176 + }, + "UZ/Tashkent": { + "lat": 41.3111, + "lng": 69.2797 + }, + "GE/Tbilisi": { + "lat": 41.7225, + "lng": 44.7925 + }, + "HN/Tegucigalpa": { + "lat": 14.1058, + "lng": -87.2047 + }, + "IR/Tehran": { + "lat": 35.6892, + "lng": 51.3889 + }, + "NL/The Hague": { + "lat": 52.08, + "lng": 4.31 + }, + "AI/The Valley": { + "lat": 18.2208, + "lng": -63.0517 + }, + "BT/Thimphu": { + "lat": 27.4722, + "lng": 89.6361 + }, + "MA/Tifariti": { + "lat": 26.158, + "lng": -10.567 + }, + "AL/Tirana": { + "lat": 41.3289, + "lng": 19.8178 + }, + "JP/Tokyo": { + "lat": 35.6897, + "lng": 139.6922 + }, + "FO/Torshavn": { + "lat": 62, + "lng": -6.7833 + }, + "LY/Tripoli": { + "lat": 32.8872, + "lng": 13.1914 + }, + "TN/Tunis": { + "lat": 36.8064, + "lng": 10.1817 + }, + "MN/Ulaanbaatar": { + "lat": 47.9203, + "lng": 106.9172 + }, + "LI/Vaduz": { + "lat": 47.141, + "lng": 9.521 + }, + "MT/Valletta": { + "lat": 35.8983, + "lng": 14.5125 + }, + "VA/Vatican City": { + "lat": 41.904, + "lng": 12.453 + }, + "SC/Victoria": { + "lat": -4.6231, + "lng": 55.4525 + }, + "AT/Vienna": { + "lat": 48.2083, + "lng": 16.3725 + }, + "LA/Vientiane": { + "lat": 17.98, + "lng": 102.63 + }, + "LT/Vilnius": { + "lat": 54.6872, + "lng": 25.28 + }, + "PL/Warsaw": { + "lat": 52.23, + "lng": 21.0111 + }, + "US/Washington": { + "lat": 38.9047, + "lng": -77.0163 + }, + "US/Anchorage": { + "lat": 61.218056, + "lng": -149.900284 + }, + "US/Chicago": { + "lat": 41.8781136, + "lng": -87.6297982 + }, + "US/Huntsville": { + "lat": 34.7303688, + "lng": -86.5861037 + }, + "US/New York": { + "lat": 40.712776, + "lng": -74.005974 + }, + "US/Denver": { + "lat": 39.739235, + "lng": -104.99025 + }, + "US/Los Angeles": { + "lat": 34.052235, + "lng": -118.243683 + }, + "NZ/Wellington": { + "lat": -41.2889, + "lng": 174.7772 + }, + "CW/Willemstad": { + "lat": 12.108, + "lng": -68.935 + }, + "NA/Windhoek": { + "lat": -22.57, + "lng": 17.0836 + }, + "CI/Yamoussoukro": { + "lat": 6.8161, + "lng": -5.2742 + }, + "CM/Yaounde": { + "lat": 3.8667, + "lng": 11.5167 + }, + "NR/Yaren": { + "lat": -0.5477, + "lng": 166.9209 + }, + "AM/Yerevan": { + "lat": 40.1814, + "lng": 44.5144 + }, + "HR/Zagreb": { + "lat": 45.8131, + "lng": 15.9775 + } +} diff --git a/proto_locations_data.json b/proto_locations_data.json new file mode 100644 index 0000000..a56d5f1 --- /dev/null +++ b/proto_locations_data.json @@ -0,0 +1,66 @@ +{ + "LV/Riga": { + "lat": 56.9489, + "lng": 24.1064 + }, + "NL/The Hague": { + "lat": 52.08, + "lng": 4.31 + }, + "AT/Vienna": { + "lat": 48.2083, + "lng": 16.3725 + }, + "BE/Brussels": { + "lat": 50.8467, + "lng": 4.3525 + }, + "DE/Berlin": { + "lat": 52.52, + "lng": 13.405 + }, + "FR/Paris": { + "lat": 48.8567, + "lng": 2.3522 + }, + "IE/Dublin": { + "lat": 53.35, + "lng": -6.2603 + }, + "LT/Vilnius": { + "lat": 54.6872, + "lng": 25.28 + }, + "UK/London": { + "lat": 51.5072, + "lng": -0.1275 + }, + "US/Anchorage": { + "lat": 61.218056, + "lng": -149.900284 + }, + "US/Chicago": { + "lat": 41.8781136, + "lng": -87.6297982 + }, + "US/Huntsville": { + "lat": 34.7303688, + "lng": -86.5861037 + }, + "US/New York": { + "lat": 40.712776, + "lng": -74.005974 + }, + "US/Washington": { + "lat": 38.9047, + "lng": -77.0163 + }, + "US/Denver": { + "lat": 39.739235, + "lng": -104.99025 + }, + "US/Los Angeles": { + "lat": 34.052235, + "lng": -118.243683 + } +} diff --git a/scripts/common.js b/scripts/common.js index 27444b9..41321f8 100644 --- a/scripts/common.js +++ b/scripts/common.js @@ -53,295 +53,16 @@ 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') - } -} - -export function getCountryCoordinates (countryCode, coordinatesEnv) { - if (coordinatesEnv) { - return coords(coordinatesEnv) - } - return countries[countryCode] +export function getCountryCoordinates (location) { + return countries[location] } -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 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 } +export function getProtoCountryCoordinates (location) { + return protoCountries[location] } -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 } -} +export const countries = JSON.parse(open('../locations_data.json')) +export const protoCountries = JSON.parse(open('../proto_locations_data.json')) function randomInRange (min, max) { return Math.random() * (max - min) + min diff --git a/scripts/routes.js b/scripts/routes.js index 72f4fb4..51cbc6e 100644 --- a/scripts/routes.js +++ b/scripts/routes.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 countryCoords = getCountryCoordinates(location) const url = `https://${host}/v4/routes` const transportation = __ENV.TRANSPORTATION || 'driving+ferry' const uniqueRequestsAmount = parseInt(__ENV.UNIQUE_REQUESTS || 100) diff --git a/scripts/time-filter-proto.js b/scripts/time-filter-proto.js index 2848034..b8f243f 100644 --- a/scripts/time-filter-proto.js +++ b/scripts/time-filter-proto.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 countryCoords = getProtoCountryCoordinates(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) diff --git a/scripts/time-filter.js b/scripts/time-filter.js index 319ea77..6d62040 100644 --- a/scripts/time-filter.js +++ b/scripts/time-filter.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 countryCoords = getCountryCoordinates(location) const url = `https://${host}/v4/time-filter` const transportation = __ENV.TRANSPORTATION || 'driving+ferry' const travelTime = parseInt(__ENV.TRAVEL_TIME || 1900) diff --git a/scripts/time-map-fast.js b/scripts/time-map-fast.js index 066fa12..383a3af 100644 --- a/scripts/time-map-fast.js +++ b/scripts/time-map-fast.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 countryCoords = getCountryCoordinates(location) const url = `https://${host}/v4/time-map/fast` const transportation = __ENV.TRANSPORTATION || 'driving+ferry' const travelTime = parseInt(__ENV.TRAVEL_TIME || 7200) diff --git a/scripts/time-map.js b/scripts/time-map.js index e348486..988be4d 100644 --- a/scripts/time-map.js +++ b/scripts/time-map.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 countryCoords = getCountryCoordinates(location) const url = `https://${host}/v4/time-map` const transportation = __ENV.TRANSPORTATION || 'driving+ferry' const travelTime = parseInt(__ENV.TRAVEL_TIME || 7200) From 89634ad61ff0c5192d470f5b6edefe804a86cc9c Mon Sep 17 00:00:00 2001 From: arnasbr Date: Fri, 26 Apr 2024 18:35:58 +0300 Subject: [PATCH 2/8] README updates --- README.md | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index d079284..773c2ce 100644 --- a/README.md +++ b/README.md @@ -158,7 +158,11 @@ https://k6.io/docs/using-k6/metrics/ - Supported locations for normal requests are listed in the `locations_data.json` file. - Supported locations for proto requests are listed in the `proto_locations_data.json` file. -If you want to add a new location, simply append the files. **NOTE:** Proto requests support a much more limited amount of countries. +If you want to add a new location, simply append the json files. + +**NOTE 1:** When adding a new country, please specify the ISO2 country code in the beginning, like it's done everywhere else. 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 From f94433c130451ef68f85a5a5296949bb27c824e3 Mon Sep 17 00:00:00 2001 From: arnasbr Date: Fri, 26 Apr 2024 18:38:37 +0300 Subject: [PATCH 3/8] README updates --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 773c2ce..67d23b6 100644 --- a/README.md +++ b/README.md @@ -160,7 +160,7 @@ https://k6.io/docs/using-k6/metrics/ If you want to add a new location, simply append the json files. -**NOTE 1:** When adding a new country, please specify the ISO2 country code in the beginning, like it's done everywhere else. Example: 'GB/London'. +**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. From c6386ece355f9b791e034ea0dcc0485d2340a9b1 Mon Sep 17 00:00:00 2001 From: arnasbr Date: Fri, 26 Apr 2024 18:42:06 +0300 Subject: [PATCH 4/8] Organizing files --- README.md | 4 ++-- locations_data.json => locations/locations_data.json | 0 .../proto_locations_data.json | 0 scripts/common.js | 4 ++-- 4 files changed, 4 insertions(+), 4 deletions(-) rename locations_data.json => locations/locations_data.json (100%) rename proto_locations_data.json => locations/proto_locations_data.json (100%) diff --git a/README.md b/README.md index 67d23b6..516dddb 100644 --- a/README.md +++ b/README.md @@ -155,8 +155,8 @@ https://k6.io/docs/using-k6/metrics/ ### Supported Countries -- Supported locations for normal requests are listed in the `locations_data.json` file. -- Supported locations for proto requests are listed in the `proto_locations_data.json` file. +- Supported locations for normal requests are listed in the `locations/locations_data.json` file. +- Supported locations for proto requests are listed in the `locations/proto_locations_data.json` file. If you want to add a new location, simply append the json files. diff --git a/locations_data.json b/locations/locations_data.json similarity index 100% rename from locations_data.json rename to locations/locations_data.json diff --git a/proto_locations_data.json b/locations/proto_locations_data.json similarity index 100% rename from proto_locations_data.json rename to locations/proto_locations_data.json diff --git a/scripts/common.js b/scripts/common.js index 41321f8..9a1b79c 100644 --- a/scripts/common.js +++ b/scripts/common.js @@ -61,8 +61,8 @@ export function getProtoCountryCoordinates (location) { return protoCountries[location] } -export const countries = JSON.parse(open('../locations_data.json')) -export const protoCountries = JSON.parse(open('../proto_locations_data.json')) +export const countries = JSON.parse(open('../locations/locations_data.json')) +export const protoCountries = JSON.parse(open('../locations/proto_locations_data.json')) function randomInRange (min, max) { return Math.random() * (max - min) + min From 80ceeee2668f9fbfbf5e7bb69d3318608b040a89 Mon Sep 17 00:00:00 2001 From: arnasbr Date: Tue, 7 May 2024 16:29:42 +0300 Subject: [PATCH 5/8] Removed json, added csv --- locations/locations_data.csv | 253 +++++++ locations/locations_data.json | 1030 --------------------------- locations/proto_locations_data.csv | 17 + locations/proto_locations_data.json | 66 -- scripts/common.js | 28 +- scripts/routes.js | 12 +- scripts/time-filter-proto.js | 6 +- scripts/time-filter.js | 10 +- scripts/time-map-fast.js | 10 +- scripts/time-map.js | 10 +- 10 files changed, 315 insertions(+), 1127 deletions(-) create mode 100644 locations/locations_data.csv delete mode 100644 locations/locations_data.json create mode 100644 locations/proto_locations_data.csv delete mode 100644 locations/proto_locations_data.json 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/locations_data.json b/locations/locations_data.json deleted file mode 100644 index 018bd6c..0000000 --- a/locations/locations_data.json +++ /dev/null @@ -1,1030 +0,0 @@ -{ - "CI/Abidjan": { - "lat": 5.3167, - "lng": -4.0333 - }, - "AE/Abu Dhabi": { - "lat": 24.4667, - "lng": 54.3667 - }, - "NG/Abuja": { - "lat": 9.0667, - "lng": 7.4833 - }, - "GH/Accra": { - "lat": 5.55, - "lng": -0.2 - }, - "PN/Adamstown": { - "lat": -25.0667, - "lng": -130.1 - }, - "ET/Addis Ababa": { - "lat": 9.03, - "lng": 38.74 - }, - "DZ/Algiers": { - "lat": 36.7539, - "lng": 3.0589 - }, - "NU/Alofi": { - "lat": -19.056, - "lng": -169.921 - }, - "JO/Amman": { - "lat": 31.9497, - "lng": 35.9328 - }, - "NL/Amsterdam": { - "lat": 52.3728, - "lng": 4.8936 - }, - "AD/Andorra la Vella": { - "lat": 42.5, - "lng": 1.5 - }, - "TR/Ankara": { - "lat": 39.93, - "lng": 32.85 - }, - "MG/Antananarivo": { - "lat": -18.91, - "lng": 47.525 - }, - "WS/Apia": { - "lat": -13.8333, - "lng": -171.75 - }, - "TM/Ashgabat": { - "lat": 37.9375, - "lng": 58.38 - }, - "ER/Asmara": { - "lat": 15.3228, - "lng": 38.925 - }, - "KZ/Astana": { - "lat": 51.1472, - "lng": 71.4222 - }, - "PY/Asuncion": { - "lat": -25.3, - "lng": -57.6333 - }, - "GR/Athens": { - "lat": 37.9842, - "lng": 23.7281 - }, - "CK/Avarua": { - "lat": -21.207, - "lng": -159.771 - }, - "IQ/Baghdad": { - "lat": 33.3153, - "lng": 44.3661 - }, - "AZ/Baku": { - "lat": 40.3953, - "lng": 49.8822 - }, - "ML/Bamako": { - "lat": 12.6392, - "lng": -8.0028 - }, - "BN/Bandar Seri Begawan": { - "lat": 4.8903, - "lng": 114.9422 - }, - "TH/Bangkok": { - "lat": 13.7525, - "lng": 100.4942 - }, - "CF/Bangui": { - "lat": 4.3733, - "lng": 18.5628 - }, - "GM/Banjul": { - "lat": 13.4531, - "lng": -16.5775 - }, - "GP/Basse-Terre": { - "lat": 16.0104, - "lng": -61.7055 - }, - "KN/Basseterre": { - "lat": 17.3, - "lng": -62.7333 - }, - "CN/Beijing": { - "lat": 39.9067, - "lng": 116.3975 - }, - "LB/Beirut": { - "lat": 33.8983, - "lng": 35.5057 - }, - "RS/Belgrade": { - "lat": 44.82, - "lng": 20.46 - }, - "BZ/Belmopan": { - "lat": 17.2514, - "lng": -88.7669 - }, - "DE/Berlin": { - "lat": 52.52, - "lng": 13.405 - }, - "CH/Bern": { - "lat": 46.9481, - "lng": 7.4475 - }, - "KG/Bishkek": { - "lat": 42.8747, - "lng": 74.6122 - }, - "GW/Bissau": { - "lat": 11.85, - "lng": -15.5667 - }, - "ZA/Bloemfontein": { - "lat": -29.1167, - "lng": 26.2167 - }, - "CO/Bogota": { - "lat": 4.7111, - "lng": -74.0722 - }, - "MS/Brades": { - "lat": 16.7928, - "lng": -62.2106 - }, - "BR/Brasilia": { - "lat": -15.7939, - "lng": -47.8828 - }, - "SK/Bratislava": { - "lat": 48.1439, - "lng": 17.1097 - }, - "CG/Brazzaville": { - "lat": -4.2694, - "lng": 15.2711 - }, - "BB/Bridgetown": { - "lat": 13.0975, - "lng": -59.6167 - }, - "BE/Brussels": { - "lat": 50.8467, - "lng": 4.3525 - }, - "RO/Bucharest": { - "lat": 44.4325, - "lng": 26.1039 - }, - "HU/Budapest": { - "lat": 47.4925, - "lng": 19.0514 - }, - "AR/Buenos Aires": { - "lat": -34.6033, - "lng": -58.3817 - }, - "BI/Bujumbura": { - "lat": -3.3833, - "lng": 29.3667 - }, - "EG/Cairo": { - "lat": 30.0444, - "lng": 31.2358 - }, - "AU/Canberra": { - "lat": -35.2931, - "lng": 149.1269 - }, - "ZA/Cape Town": { - "lat": -33.9253, - "lng": 18.4239 - }, - "MP/Capitol Hill": { - "lat": 15.2137, - "lng": 145.7546 - }, - "VE/Caracas": { - "lat": 10.4806, - "lng": -66.9036 - }, - "LC/Castries": { - "lat": 14.0167, - "lng": -60.9833 - }, - "GF/Cayenne": { - "lat": 4.933, - "lng": -52.33 - }, - "VI/Charlotte Amalie": { - "lat": 18.342, - "lng": -64.9331 - }, - "MD/Chisinau": { - "lat": 47.0228, - "lng": 28.8353 - }, - "LK/Colombo": { - "lat": 6.9344, - "lng": 79.8428 - }, - "GN/Conakry": { - "lat": 9.5092, - "lng": -13.7122 - }, - "DK/Copenhagen": { - "lat": 55.6761, - "lng": 12.5683 - }, - "BJ/Cotonou": { - "lat": 6.3667, - "lng": 2.4333 - }, - "SN/Dakar": { - "lat": 14.6928, - "lng": -17.4467 - }, - "SY/Damascus": { - "lat": 33.5131, - "lng": 36.2919 - }, - "BD/Dhaka": { - "lat": 23.7639, - "lng": 90.3889 - }, - "TL/Dili": { - "lat": -8.5536, - "lng": 125.5783 - }, - "DJ/Djibouti": { - "lat": 11.5883, - "lng": 43.145 - }, - "TZ/Dodoma": { - "lat": -6.1731, - "lng": 35.7419 - }, - "QA/Doha": { - "lat": 25.2867, - "lng": 51.5333 - }, - "IM/Douglas": { - "lat": 54.15, - "lng": -4.4775 - }, - "IE/Dublin": { - "lat": 53.35, - "lng": -6.2603 - }, - "TJ/Dushanbe": { - "lat": 38.5367, - "lng": 68.78 - }, - "CX/Flying Fish Cove": { - "lat": -10.4261, - "lng": 105.6728 - }, - "MQ/Fort-de-France": { - "lat": 14.6, - "lng": -61.0667 - }, - "SL/Freetown": { - "lat": 8.4844, - "lng": -13.2344 - }, - "TV/Funafuti": { - "lat": -8.5167, - "lng": 179.2 - }, - "BW/Gaborone": { - "lat": -24.6581, - "lng": 25.9122 - }, - "XG/Gaza": { - "lat": 31.5069, - "lng": 34.456 - }, - "KY/George Town": { - "lat": 19.2866, - "lng": -81.3744 - }, - "GY/Georgetown": { - "lat": 6.8058, - "lng": -58.1508 - }, - "GI/Gibraltar": { - "lat": 36.14, - "lng": -5.35 - }, - "BI/Gitega": { - "lat": -3.4283, - "lng": 29.925 - }, - "TC/Grand Turk": { - "lat": 21.459, - "lng": -71.139 - }, - "GT/Guatemala City": { - "lat": 14.6133, - "lng": -90.5353 - }, - "BL/Gustavia": { - "lat": 17.8979, - "lng": -62.8506 - }, - "GU/Hagta": { - "lat": 13.4745, - "lng": 144.7504 - }, - "BM/Hamilton": { - "lat": 32.293, - "lng": -64.782 - }, - "VN/Hanoi": { - "lat": 21, - "lng": 105.85 - }, - "ZW/Harare": { - "lat": -17.8292, - "lng": 31.0522 - }, - "CU/Havana": { - "lat": 23.1367, - "lng": -82.3589 - }, - "FI/Helsinki": { - "lat": 60.1708, - "lng": 24.9375 - }, - "HK/Hong Kong": { - "lat": 22.3, - "lng": 114.2 - }, - "SB/Honiara": { - "lat": -9.4319, - "lng": 159.9556 - }, - "PK/Islamabad": { - "lat": 33.6931, - "lng": 73.0639 - }, - "ID/Jakarta": { - "lat": -6.175, - "lng": 106.8275 - }, - "SH/Jamestown": { - "lat": -15.9251, - "lng": -5.7179 - }, - "IL/Jerusalem": { - "lat": 31.7789, - "lng": 35.2256 - }, - "SS/Juba": { - "lat": 4.85, - "lng": 31.6 - }, - "AF/Kabul": { - "lat": 34.5253, - "lng": 69.1783 - }, - "UG/Kampala": { - "lat": 0.3136, - "lng": 32.5811 - }, - "NP/Kathmandu": { - "lat": 27.71, - "lng": 85.32 - }, - "SD/Khartoum": { - "lat": 15.6, - "lng": 32.5 - }, - "RW/Kigali": { - "lat": -1.9439, - "lng": 30.0594 - }, - "GS/King Edward Point": { - "lat": -54.2833, - "lng": -36.5 - }, - "JM/Kingston": { - "lat": 17.9714, - "lng": -76.7931 - }, - "NF/Kingston": { - "lat": -29.0606, - "lng": 167.9619 - }, - "VC/Kingstown": { - "lat": 13.1578, - "lng": -61.225 - }, - "CD/Kinshasa": { - "lat": -4.3219, - "lng": 15.3119 - }, - "MY/Kuala Lumpur": { - "lat": 3.1478, - "lng": 101.6953 - }, - "KW/Kuwait City": { - "lat": 29.3697, - "lng": 47.9783 - }, - "UA/Kyiv": { - "lat": 50.45, - "lng": 30.5233 - }, - "BO/La Paz": { - "lat": -16.4958, - "lng": -68.1333 - }, - "GA/Libreville": { - "lat": 0.3903, - "lng": 9.4542 - }, - "MW/Lilongwe": { - "lat": -13.9833, - "lng": 33.7833 - }, - "PE/Lima": { - "lat": -12.06, - "lng": -77.0375 - }, - "PT/Lisbon": { - "lat": 38.7253, - "lng": -9.15 - }, - "SI/Ljubljana": { - "lat": 46.0514, - "lng": 14.5061 - }, - "SZ/Lobamba": { - "lat": -26.4465, - "lng": 31.2064 - }, - "TG/Lome": { - "lat": 6.1319, - "lng": 1.2228 - }, - "GB/London": { - "lat": 51.5072, - "lng": -0.1275 - }, - "XR/Longyearbyen": { - "lat": 78.22, - "lng": 15.65 - }, - "AO/Luanda": { - "lat": -8.8383, - "lng": 13.2344 - }, - "ZM/Lusaka": { - "lat": -15.4167, - "lng": 28.2833 - }, - "LU/Luxembourg": { - "lat": 49.6117, - "lng": 6.1319 - }, - "ES/Madrid": { - "lat": 40.4169, - "lng": -3.7033 - }, - "MH/Majuro": { - "lat": 7.0833, - "lng": 171.3833 - }, - "GQ/Malabo": { - "lat": 3.7456, - "lng": 8.7744 - }, - "MV/Male": { - "lat": 4.1753, - "lng": 73.5089 - }, - "YT/Mamoudzou": { - "lat": -12.7806, - "lng": 45.2278 - }, - "NI/Managua": { - "lat": 12.1364, - "lng": -86.2514 - }, - "BH/Manama": { - "lat": 26.225, - "lng": 50.5775 - }, - "PH/Manila": { - "lat": 14.5958, - "lng": 120.9772 - }, - "MZ/Maputo": { - "lat": -25.9667, - "lng": 32.5833 - }, - "MF/Marigot": { - "lat": 18.0706, - "lng": -63.0847 - }, - "LS/Maseru": { - "lat": -29.31, - "lng": 27.48 - }, - "WF/Mata-Utu": { - "lat": -13.2833, - "lng": -176.1833 - }, - "SZ/Mbabane": { - "lat": -26.3167, - "lng": 31.1333 - }, - "MX/Mexico City": { - "lat": 19.4333, - "lng": -99.1333 - }, - "BY/Minsk": { - "lat": 53.9, - "lng": 27.5667 - }, - "SO/Mogadishu": { - "lat": 2.0392, - "lng": 45.3419 - }, - "MC/Monaco": { - "lat": 43.7333, - "lng": 7.4167 - }, - "LR/Monrovia": { - "lat": 6.3133, - "lng": -10.8014 - }, - "UY/Montevideo": { - "lat": -34.8836, - "lng": -56.1819 - }, - "KM/Moroni": { - "lat": -11.699, - "lng": 43.256 - }, - "RU/Moscow": { - "lat": 55.7558, - "lng": 37.6172 - }, - "OM/Muscat": { - "lat": 23.6139, - "lng": 58.5922 - }, - "TD/N'Djamena": { - "lat": 12.11, - "lng": 15.05 - }, - "KE/Nairobi": { - "lat": -1.2864, - "lng": 36.8172 - }, - "BS/Nassau": { - "lat": 25.0781, - "lng": -77.3386 - }, - "MM/Nay Pyi Taw": { - "lat": 19.7475, - "lng": 96.115 - }, - "IN/New Delhi": { - "lat": 28.6139, - "lng": 77.2089 - }, - "PW/Ngerulmud": { - "lat": 7.5006, - "lng": 134.6242 - }, - "NE/Niamey": { - "lat": 13.515, - "lng": 2.1175 - }, - "CY/Nicosia": { - "lat": 35.1725, - "lng": 33.365 - }, - "MR/Nouakchott": { - "lat": 18.0858, - "lng": -15.9785 - }, - "NC/Noumea": { - "lat": -22.2758, - "lng": 166.458 - }, - "TO/Nuku`alofa": { - "lat": -21.1333, - "lng": -175.2 - }, - "GL/Nuuk": { - "lat": 64.1814, - "lng": -51.6942 - }, - "AW/Oranjestad": { - "lat": 12.5186, - "lng": -70.0358 - }, - "NO/Oslo": { - "lat": 59.9133, - "lng": 10.7389 - }, - "CA/Ottawa": { - "lat": 45.4247, - "lng": -75.695 - }, - "BF/Ouagadougou": { - "lat": 12.3686, - "lng": -1.5275 - }, - "AS/Pago Pago": { - "lat": -14.274, - "lng": -170.7046 - }, - "FM/Palikir": { - "lat": 6.9172, - "lng": 158.1589 - }, - "PA/Panama City": { - "lat": 8.9833, - "lng": -79.5167 - }, - "PF/Papeete": { - "lat": -17.5334, - "lng": -149.5667 - }, - "SR/Paramaribo": { - "lat": 5.8522, - "lng": -55.2039 - }, - "FR/Paris": { - "lat": 48.8567, - "lng": 2.3522 - }, - "SX/Philipsburg": { - "lat": 18.0237, - "lng": -63.0458 - }, - "KH/Phnom Penh": { - "lat": 11.5694, - "lng": 104.9211 - }, - "MS/Plymouth": { - "lat": 16.7064, - "lng": -62.2158 - }, - "ME/Podgorica": { - "lat": 42.4414, - "lng": 19.2628 - }, - "MU/Port Louis": { - "lat": -20.1644, - "lng": 57.5042 - }, - "PG/Port Moresby": { - "lat": -9.4789, - "lng": 147.1494 - }, - "TT/Port of Spain": { - "lat": 10.6667, - "lng": -61.5167 - }, - "HT/Port-au-Prince": { - "lat": 18.5333, - "lng": -72.3333 - }, - "VU/Port-Vila": { - "lat": -17.7333, - "lng": 168.3167 - }, - "BJ/Porto-Novo": { - "lat": 6.4972, - "lng": 2.605 - }, - "CZ/Prague": { - "lat": 50.0875, - "lng": 14.4214 - }, - "CV/Praia": { - "lat": 14.918, - "lng": -23.509 - }, - "ZA/Pretoria": { - "lat": -25.7461, - "lng": 28.1881 - }, - "XK/Pristina": { - "lat": 42.6633, - "lng": 21.1622 - }, - "MY/Putrajaya": { - "lat": 2.93, - "lng": 101.69 - }, - "KP/Pyongyang": { - "lat": 39.0167, - "lng": 125.7475 - }, - "EC/Quito": { - "lat": -0.22, - "lng": -78.5125 - }, - "MA/Rabat": { - "lat": 34.0209, - "lng": -6.8416 - }, - "MM/Rangoon": { - "lat": 16.795, - "lng": 96.16 - }, - "IS/Reykjavik": { - "lat": 64.1467, - "lng": -21.94 - }, - "LV/Riga": { - "lat": 56.9489, - "lng": 24.1064 - }, - "SA/Riyadh": { - "lat": 24.6333, - "lng": 46.7167 - }, - "VG/Road Town": { - "lat": 18.4167, - "lng": -64.6167 - }, - "IT/Rome": { - "lat": 41.8933, - "lng": 12.4828 - }, - "DM/Roseau": { - "lat": 15.3014, - "lng": -61.3883 - }, - "GD/Saint George's": { - "lat": 12.05, - "lng": -61.75 - }, - "JE/Saint Helier": { - "lat": 49.1858, - "lng": -2.11 - }, - "AG/Saint John's": { - "lat": 17.1167, - "lng": -61.85 - }, - "GG/Saint Peter Port": { - "lat": 49.4555, - "lng": -2.5368 - }, - "RE/Saint-Denis": { - "lat": -20.8789, - "lng": 55.4481 - }, - "PM/Saint-Pierre": { - "lat": 46.7778, - "lng": -56.1778 - }, - "CR/San Jose": { - "lat": 9.9325, - "lng": -84.08 - }, - "PR/San Juan": { - "lat": 18.3985, - "lng": -66.061 - }, - "SM/San Marino": { - "lat": 43.9346, - "lng": 12.4473 - }, - "SV/San Salvador": { - "lat": 13.6989, - "lng": -89.1914 - }, - "YE/Sanaa": { - "lat": 15.3483, - "lng": 44.2064 - }, - "CL/Santiago": { - "lat": -33.4372, - "lng": -70.6506 - }, - "DO/Santo Domingo": { - "lat": 18.4667, - "lng": -69.95 - }, - "ST/Sao Tome": { - "lat": 0.3361, - "lng": 6.7306 - }, - "BA/Sarajevo": { - "lat": 43.8564, - "lng": 18.4131 - }, - "KR/Seoul": { - "lat": 37.56, - "lng": 126.99 - }, - "SG/Singapore": { - "lat": 1.3, - "lng": 103.8 - }, - "MK/Skopje": { - "lat": 41.9961, - "lng": 21.4317 - }, - "BG/Sofia": { - "lat": 42.7, - "lng": 23.33 - }, - "LK/Sri Jayewardenepura Kotte": { - "lat": 6.9108, - "lng": 79.8878 - }, - "FK/Stanley": { - "lat": -51.7, - "lng": -57.85 - }, - "SE/Stockholm": { - "lat": 59.3294, - "lng": 18.0686 - }, - "BO/Sucre": { - "lat": -19.0475, - "lng": -65.26 - }, - "FJ/Suva": { - "lat": -18.1416, - "lng": 178.4419 - }, - "TW/Taipei": { - "lat": 25.0375, - "lng": 121.5625 - }, - "EE/Tallinn": { - "lat": 59.4372, - "lng": 24.7453 - }, - "KI/Tarawa": { - "lat": 1.3382, - "lng": 173.0176 - }, - "UZ/Tashkent": { - "lat": 41.3111, - "lng": 69.2797 - }, - "GE/Tbilisi": { - "lat": 41.7225, - "lng": 44.7925 - }, - "HN/Tegucigalpa": { - "lat": 14.1058, - "lng": -87.2047 - }, - "IR/Tehran": { - "lat": 35.6892, - "lng": 51.3889 - }, - "NL/The Hague": { - "lat": 52.08, - "lng": 4.31 - }, - "AI/The Valley": { - "lat": 18.2208, - "lng": -63.0517 - }, - "BT/Thimphu": { - "lat": 27.4722, - "lng": 89.6361 - }, - "MA/Tifariti": { - "lat": 26.158, - "lng": -10.567 - }, - "AL/Tirana": { - "lat": 41.3289, - "lng": 19.8178 - }, - "JP/Tokyo": { - "lat": 35.6897, - "lng": 139.6922 - }, - "FO/Torshavn": { - "lat": 62, - "lng": -6.7833 - }, - "LY/Tripoli": { - "lat": 32.8872, - "lng": 13.1914 - }, - "TN/Tunis": { - "lat": 36.8064, - "lng": 10.1817 - }, - "MN/Ulaanbaatar": { - "lat": 47.9203, - "lng": 106.9172 - }, - "LI/Vaduz": { - "lat": 47.141, - "lng": 9.521 - }, - "MT/Valletta": { - "lat": 35.8983, - "lng": 14.5125 - }, - "VA/Vatican City": { - "lat": 41.904, - "lng": 12.453 - }, - "SC/Victoria": { - "lat": -4.6231, - "lng": 55.4525 - }, - "AT/Vienna": { - "lat": 48.2083, - "lng": 16.3725 - }, - "LA/Vientiane": { - "lat": 17.98, - "lng": 102.63 - }, - "LT/Vilnius": { - "lat": 54.6872, - "lng": 25.28 - }, - "PL/Warsaw": { - "lat": 52.23, - "lng": 21.0111 - }, - "US/Washington": { - "lat": 38.9047, - "lng": -77.0163 - }, - "US/Anchorage": { - "lat": 61.218056, - "lng": -149.900284 - }, - "US/Chicago": { - "lat": 41.8781136, - "lng": -87.6297982 - }, - "US/Huntsville": { - "lat": 34.7303688, - "lng": -86.5861037 - }, - "US/New York": { - "lat": 40.712776, - "lng": -74.005974 - }, - "US/Denver": { - "lat": 39.739235, - "lng": -104.99025 - }, - "US/Los Angeles": { - "lat": 34.052235, - "lng": -118.243683 - }, - "NZ/Wellington": { - "lat": -41.2889, - "lng": 174.7772 - }, - "CW/Willemstad": { - "lat": 12.108, - "lng": -68.935 - }, - "NA/Windhoek": { - "lat": -22.57, - "lng": 17.0836 - }, - "CI/Yamoussoukro": { - "lat": 6.8161, - "lng": -5.2742 - }, - "CM/Yaounde": { - "lat": 3.8667, - "lng": 11.5167 - }, - "NR/Yaren": { - "lat": -0.5477, - "lng": 166.9209 - }, - "AM/Yerevan": { - "lat": 40.1814, - "lng": 44.5144 - }, - "HR/Zagreb": { - "lat": 45.8131, - "lng": 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/locations/proto_locations_data.json b/locations/proto_locations_data.json deleted file mode 100644 index a56d5f1..0000000 --- a/locations/proto_locations_data.json +++ /dev/null @@ -1,66 +0,0 @@ -{ - "LV/Riga": { - "lat": 56.9489, - "lng": 24.1064 - }, - "NL/The Hague": { - "lat": 52.08, - "lng": 4.31 - }, - "AT/Vienna": { - "lat": 48.2083, - "lng": 16.3725 - }, - "BE/Brussels": { - "lat": 50.8467, - "lng": 4.3525 - }, - "DE/Berlin": { - "lat": 52.52, - "lng": 13.405 - }, - "FR/Paris": { - "lat": 48.8567, - "lng": 2.3522 - }, - "IE/Dublin": { - "lat": 53.35, - "lng": -6.2603 - }, - "LT/Vilnius": { - "lat": 54.6872, - "lng": 25.28 - }, - "UK/London": { - "lat": 51.5072, - "lng": -0.1275 - }, - "US/Anchorage": { - "lat": 61.218056, - "lng": -149.900284 - }, - "US/Chicago": { - "lat": 41.8781136, - "lng": -87.6297982 - }, - "US/Huntsville": { - "lat": 34.7303688, - "lng": -86.5861037 - }, - "US/New York": { - "lat": 40.712776, - "lng": -74.005974 - }, - "US/Washington": { - "lat": 38.9047, - "lng": -77.0163 - }, - "US/Denver": { - "lat": 39.739235, - "lng": -104.99025 - }, - "US/Los Angeles": { - "lat": 34.052235, - "lng": -118.243683 - } -} diff --git a/scripts/common.js b/scripts/common.js index 9a1b79c..9548ce9 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,16 +54,29 @@ export function setThresholdsForScenarios (options) { } } -export function getCountryCoordinates (location) { - return countries[location] +export function getLocationCoordinates (location) { + return locations.get(location) +} + +export function getProtoLocationCoordinates (location) { + return protoLocations.get(location) } -export function getProtoCountryCoordinates (location) { - return protoCountries[location] +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); + + return [name, {lat, lng}] + })) } -export const countries = JSON.parse(open('../locations/locations_data.json')) -export const protoCountries = JSON.parse(open('../locations/proto_locations_data.json')) +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 51cbc6e..ba3f361 100644 --- a/scripts/routes.js +++ b/scripts/routes.js @@ -15,7 +15,7 @@ import { summaryTrendStats, deleteOneScenarioMetrics, oneScenarioReport, - getCountryCoordinates, + getLocationCoordinates, randomIndex } from './common.js' @@ -38,7 +38,7 @@ export function setup () { const apiKey = __ENV.API_KEY const host = __ENV.HOST || 'api.traveltimeapp.com' const location = __ENV.LOCATION || 'GB/London' - const countryCoords = getCountryCoordinates(location) + 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 b8f243f..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' @@ -47,7 +47,7 @@ export function setup () { const location = __ENV.LOCATION || 'UK/London' const country = location.slice(0, 2).toLowerCase() - const countryCoords = getProtoCountryCoordinates(location) + const locationCoords = getProtoLocationCoordinates(location) const query = __ENV.QUERY || `api/v2/${countryCode(country)}/time-filter/fast/${transportation}` const isManyToOne = __ENV.MANY_TO_ONE !== undefined @@ -69,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 6d62040..9ac6eb3 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' @@ -38,7 +38,7 @@ export function setup () { const apiKey = __ENV.API_KEY const host = __ENV.HOST || 'api.traveltimeapp.com' const location = __ENV.LOCATION || 'GB/London' - const countryCoords = getCountryCoordinates(location) + 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, countryCoords.lng, diff), dateTime ) ) diff --git a/scripts/time-map-fast.js b/scripts/time-map-fast.js index 383a3af..c5372e8 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' @@ -38,7 +38,7 @@ export function setup () { const apiKey = __ENV.API_KEY const host = __ENV.HOST || 'api.traveltimeapp.com' const location = __ENV.LOCATION || 'GB/London' - const countryCoords = getCountryCoordinates(location) + 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, countryCoords.lng, diff), arrivalTimePeriod, levelOfDetails ) diff --git a/scripts/time-map.js b/scripts/time-map.js index 988be4d..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' @@ -38,7 +38,7 @@ export function setup () { const apiKey = __ENV.API_KEY const host = __ENV.HOST || 'api.traveltimeapp.com' const location = __ENV.LOCATION || 'GB/London' - const countryCoords = getCountryCoordinates(location) + 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 ) ) From 38d34e3bd6a6f167202bd33a75e340dd0a9d7589 Mon Sep 17 00:00:00 2001 From: arnasbr Date: Tue, 7 May 2024 16:33:37 +0300 Subject: [PATCH 6/8] fixes --- scripts/common.js | 12 ++++++------ scripts/time-filter.js | 2 +- scripts/time-map-fast.js | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/scripts/common.js b/scripts/common.js index 9548ce9..0e346fd 100644 --- a/scripts/common.js +++ b/scripts/common.js @@ -62,16 +62,16 @@ export function getProtoLocationCoordinates (location) { return protoLocations.get(location) } -function parseLocations(filePath) { +function parseLocations (filePath) { const file = open(filePath) - const parsedData = papaparse.parse(file, { header: true, skipEmptyLines: true }).data; + 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); + const name = location.name + const lat = parseFloat(location.lat) + const lng = parseFloat(location.lng) - return [name, {lat, lng}] + return [name, { lat, lng }] })) } diff --git a/scripts/time-filter.js b/scripts/time-filter.js index 9ac6eb3..8590a79 100644 --- a/scripts/time-filter.js +++ b/scripts/time-filter.js @@ -172,7 +172,7 @@ function generateRequestBodies ( transportation, destinationsAmount, rangeSettings, - generateRandomCoordinate(locationCoords.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 c5372e8..2c87248 100644 --- a/scripts/time-map-fast.js +++ b/scripts/time-map-fast.js @@ -136,7 +136,7 @@ function generateRequestBodies (count, travelTime, transportation, locationCoord () => generateBody( travelTime, transportation, - generateRandomCoordinate(locationCoords.lat, countryCoords.lng, diff), + generateRandomCoordinate(locationCoords.lat, locationCoords.lng, diff), arrivalTimePeriod, levelOfDetails ) From b6aa9967ec9d54d3c18fd1c9b12b92ca350bbd83 Mon Sep 17 00:00:00 2001 From: arnasbr Date: Tue, 7 May 2024 16:34:26 +0300 Subject: [PATCH 7/8] README --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 516dddb..0e7b3b9 100644 --- a/README.md +++ b/README.md @@ -155,10 +155,10 @@ https://k6.io/docs/using-k6/metrics/ ### Supported Countries -- Supported locations for normal requests are listed in the `locations/locations_data.json` file. -- Supported locations for proto requests are listed in the `locations/proto_locations_data.json` file. +- 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. -If you want to add a new location, simply append the json files. +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'. From 9f5c477c2767c21781f9c2a175e8200f0432d025 Mon Sep 17 00:00:00 2001 From: arnasbr Date: Tue, 7 May 2024 16:42:47 +0300 Subject: [PATCH 8/8] Some error handling --- scripts/common.js | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/scripts/common.js b/scripts/common.js index 0e346fd..e6f8bfc 100644 --- a/scripts/common.js +++ b/scripts/common.js @@ -54,12 +54,20 @@ export function setThresholdsForScenarios (options) { } } +function getLocation (location, locationsMap) { + const coordinates = locationsMap.get(location) + if (coordinates === undefined) { + throw new Error(`Location "${location}" doesn't exist.`) + } + return coordinates +} + export function getLocationCoordinates (location) { - return locations.get(location) + return getLocation(location, locations) } export function getProtoLocationCoordinates (location) { - return protoLocations.get(location) + return getLocation(location, protoLocations) } function parseLocations (filePath) {