284 lines
12 KiB
PHP
284 lines
12 KiB
PHP
<?php
|
||
declare(strict_types=1);
|
||
|
||
namespace Esun\Agent\Model\Map;
|
||
|
||
class CountryPosition
|
||
{
|
||
/**
|
||
* Coordinates are percentages calibrated to Esun_Agent::images/world-map-dots.svg.
|
||
* They belong to the country, never to an individual agent record.
|
||
* Base label points come from Natural Earth 1:50m Admin 0 map units and are
|
||
* projected to this SVG; countries already used by eSUN keep their visual overrides.
|
||
*/
|
||
private const POSITIONS = [
|
||
'AF' => [68.471, 33.867], // Afghanistan
|
||
'AL' => [55.587, 30.802], // Albania
|
||
'DZ' => [50.780, 37.062], // Algeria
|
||
'AS' => [2.570, 57.959], // American Samoa
|
||
'AD' => [50.428, 29.908], // Andorra
|
||
'AO' => [54.996, 56.768], // Angola
|
||
'AI' => [32.493, 41.385], // Anguilla
|
||
'AQ' => [59.968, 92.000], // Antarctica
|
||
'AG' => [32.831, 41.936], // Antigua & Barbuda
|
||
'AR' => [31.900, 81.900], // Argentina
|
||
'AM' => [62.445, 30.894], // Armenia
|
||
'AN' => [30.855, 44.265], // Netherlands Antilles (legacy Magento country code)
|
||
'AW' => [30.563, 44.089], // Aruba
|
||
'AU' => [85.400, 77.000], // Australia
|
||
'AT' => [53.750, 30.000], // Austria
|
||
'AZ' => [63.114, 30.921], // Azerbaijan
|
||
'BS' => [28.570, 37.532], // Bahamas
|
||
'BH' => [64.043, 37.696], // Bahrain
|
||
'BD' => [74.912, 38.565], // Bangladesh
|
||
'BB' => [33.453, 43.784], // Barbados
|
||
'BY' => [57.894, 24.584], // Belarus
|
||
'BE' => [49.300, 26.000], // Belgium
|
||
'BZ' => [25.358, 41.877], // Belize
|
||
'BJ' => [50.653, 45.124], // Benin
|
||
'BM' => [32.010, 34.749], // Bermuda
|
||
'BT' => [75.011, 36.997], // Bhutan
|
||
'BO' => [32.057, 59.259], // Bolivia
|
||
'BA' => [55.273, 29.214], // Bosnia & Herzegovina
|
||
'BW' => [56.716, 62.279], // Botswana
|
||
'BV' => [50.944, 80.222], // Bouvet Island
|
||
'BR' => [34.250, 66.700], // Brazil
|
||
'IO' => [69.819, 53.439], // British Indian Ocean Territory
|
||
'VG' => [32.045, 41.299], // British Virgin Islands
|
||
'BN' => [81.820, 47.899], // Brunei
|
||
'BG' => [57.000, 30.000], // Bulgaria
|
||
'BF' => [49.621, 44.016], // Burkina Faso
|
||
'BI' => [58.310, 51.852], // Burundi
|
||
'KH' => [79.029, 44.028], // Cambodia
|
||
'CM' => [53.465, 47.835], // Cameroon
|
||
'CA' => [20.556, 23.556], // Canada
|
||
'CV' => [43.433, 42.881], // Cape Verde
|
||
'BQ' => [32.463, 41.715], // Caribbean Netherlands
|
||
'KY' => [27.433, 40.877], // Cayman Islands
|
||
'CF' => [55.807, 46.699], // Central African Republic
|
||
'TD' => [55.179, 42.849], // Chad
|
||
'CL' => [29.100, 79.200], // Chile
|
||
'CN' => [79.538, 34.654], // China
|
||
'CX' => [79.353, 55.828], // Christmas Island
|
||
'CC' => [76.897, 56.755], // Cocos (Keeling) Islands
|
||
'CO' => [29.674, 48.407], // Colombia
|
||
'KM' => [62.033, 56.515], // Comoros
|
||
'CG' => [54.417, 49.933], // Congo - Brazzaville
|
||
'CD' => [56.516, 51.032], // Congo - Kinshasa
|
||
'CK' => [5.615, 61.787], // Cook Islands
|
||
'CR' => [26.645, 45.247], // Costa Rica
|
||
'HR' => [54.548, 28.369], // Croatia
|
||
'CU' => [28.340, 39.926], // Cuba
|
||
'CW' => [30.855, 44.265], // Curaçao
|
||
'CY' => [59.190, 33.513], // Cyprus
|
||
'CZ' => [54.272, 26.444], // Czechia
|
||
'CI' => [48.453, 46.462], // Côte d’Ivoire
|
||
'DK' => [52.505, 23.571], // Denmark
|
||
'DJ' => [61.805, 44.345], // Djibouti
|
||
'DM' => [32.960, 42.700], // Dominica
|
||
'DO' => [30.374, 40.979], // Dominican Republic
|
||
'EC' => [27.200, 60.800], // Ecuador
|
||
'EG' => [57.000, 38.500], // Egypt
|
||
'SV' => [25.308, 43.537], // El Salvador
|
||
'GQ' => [52.497, 48.898], // Equatorial Guinea
|
||
'ER' => [60.635, 42.545], // Eritrea
|
||
'EE' => [58.000, 22.000], // Estonia
|
||
'SZ' => [58.741, 64.741], // Eswatini
|
||
'ET' => [60.858, 46.207], // Ethiopia
|
||
'FK' => [33.684, 78.672], // Falkland Islands
|
||
'FO' => [48.039, 20.635], // Faroe Islands
|
||
'FJ' => [98.000, 59.903], // Fiji
|
||
'FI' => [54.400, 17.500], // Finland
|
||
'FR' => [47.500, 30.000], // France
|
||
'GF' => [35.259, 48.111], // French Guiana
|
||
'PF' => [8.483, 59.793], // French Polynesia
|
||
'TF' => [69.201, 77.391], // French Southern Territories
|
||
'GA' => [53.288, 50.243], // Gabon
|
||
'GM' => [45.834, 43.558], // Gambia
|
||
'GE' => [62.149, 30.228], // Georgia
|
||
'DE' => [51.900, 26.400], // Germany
|
||
'GH' => [49.712, 46.356], // Ghana
|
||
'GI' => [48.514, 32.934], // Gibraltar
|
||
'GR' => [55.300, 35.200], // Greece
|
||
'GL' => [39.074, 14.905], // Greenland
|
||
'GD' => [32.867, 44.280], // Grenada
|
||
'GP' => [32.935, 42.303], // Guadeloupe
|
||
'GU' => [90.195, 43.694], // Guam
|
||
'GT' => [22.000, 50.500], // Guatemala
|
||
'GG' => [49.288, 26.642], // Guernsey
|
||
'GN' => [47.218, 44.986], // Guinea
|
||
'GW' => [45.966, 44.256], // Guinea-Bissau
|
||
'GY' => [33.627, 47.580], // Guyana
|
||
'HT' => [29.938, 40.903], // Haiti
|
||
'HM' => [70.418, 79.502], // Heard & McDonald Islands
|
||
'HN' => [25.865, 43.014], // Honduras
|
||
'HK' => [81.694, 39.399], // Hong Kong SAR China
|
||
'HU' => [55.402, 27.765], // Hungary
|
||
'IS' => [44.813, 19.410], // Iceland
|
||
'IN' => [67.500, 48.500], // India
|
||
'ID' => [74.000, 72.500], // Indonesia
|
||
'IR' => [65.259, 34.810], // Iran
|
||
'IQ' => [62.017, 34.372], // Iraq
|
||
'IE' => [47.834, 24.935], // Ireland
|
||
'IM' => [48.742, 24.396], // Isle of Man
|
||
'IL' => [62.050, 38.861], // Israel
|
||
'IT' => [53.077, 28.876], // Italy
|
||
'JM' => [28.523, 41.435], // Jamaica
|
||
'JP' => [88.456, 32.933], // Japan
|
||
'JE' => [49.419, 26.757], // Jersey
|
||
'JO' => [60.104, 35.453], // Jordan
|
||
'KZ' => [69.079, 26.836], // Kazakhstan
|
||
'KE' => [60.530, 49.741], // Kenya
|
||
'KI' => [6.282, 49.140], // Kiribati
|
||
'XK' => [55.795, 29.886], // Kosovo
|
||
'KW' => [63.143, 36.110], // Kuwait
|
||
'KG' => [70.704, 30.323], // Kyrgyzstan
|
||
'LA' => [78.482, 40.824], // Laos
|
||
'LV' => [57.072, 23.052], // Latvia
|
||
'LB' => [59.998, 33.881], // Lebanon
|
||
'LS' => [57.846, 66.378], // Lesotho
|
||
'LR' => [47.372, 46.955], // Liberia
|
||
'LY' => [55.003, 37.420], // Libya
|
||
'LI' => [52.655, 27.753], // Liechtenstein
|
||
'LT' => [56.692, 23.979], // Lithuania
|
||
'LU' => [51.688, 26.515], // Luxembourg
|
||
'MO' => [81.543, 39.550], // Macao SAR China
|
||
'MG' => [62.973, 60.349], // Madagascar
|
||
'MW' => [59.336, 57.437], // Malawi
|
||
'MY' => [81.621, 48.806], // Malaysia
|
||
'MV' => [70.419, 48.029], // Maldives
|
||
'ML' => [49.434, 41.173], // Mali
|
||
'MT' => [54.009, 33.051], // Malta
|
||
'MH' => [97.554, 46.655], // Marshall Islands
|
||
'MQ' => [33.040, 43.053], // Martinique
|
||
'MR' => [47.294, 40.751], // Mauritania
|
||
'MU' => [65.991, 61.278], // Mauritius
|
||
'YT' => [62.542, 57.097], // Mayotte
|
||
'MX' => [21.667, 39.139], // Mexico
|
||
'FM' => [93.954, 46.748], // Micronesia
|
||
'MD' => [57.913, 27.600], // Moldova
|
||
'MC' => [52.055, 29.345], // Monaco
|
||
'MN' => [78.889, 28.278], // Mongolia
|
||
'ME' => [55.318, 29.787], // Montenegro
|
||
'MS' => [32.725, 42.096], // Montserrat
|
||
'MA' => [48.004, 35.054], // Morocco
|
||
'MZ' => [60.511, 57.746], // Mozambique
|
||
'MM' => [76.612, 39.812], // Myanmar (Burma)
|
||
'NA' => [54.752, 61.431], // Namibia
|
||
'NR' => [96.370, 50.289], // Nauru
|
||
'NP' => [73.233, 36.637], // Nepal
|
||
'NL' => [51.000, 21.000], // Netherlands
|
||
'NC' => [95.857, 61.703], // New Caledonia
|
||
'NZ' => [95.000, 84.300], // New Zealand
|
||
'NI' => [26.370, 44.017], // Nicaragua
|
||
'NE' => [52.640, 41.762], // Niger
|
||
'NG' => [52.084, 45.542], // Nigeria
|
||
'NU' => [2.816, 60.581], // Niue
|
||
'NF' => [96.654, 66.129], // Norfolk Island
|
||
'KP' => [85.123, 31.165], // North Korea
|
||
'MK' => [55.988, 30.375], // North Macedonia
|
||
'MP' => [90.482, 42.828], // Northern Mariana Islands
|
||
'NO' => [49.400, 14.000], // Norway
|
||
'OM' => [65.927, 39.554], // Oman
|
||
'PK' => [69.040, 36.150], // Pakistan
|
||
'PW' => [87.383, 46.450], // Palau
|
||
'PS' => [59.523, 35.217], // Palestinian Territories
|
||
'PA' => [27.680, 45.881], // Panama
|
||
'PG' => [89.975, 53.164], // Papua New Guinea
|
||
'PY' => [33.293, 62.041], // Paraguay
|
||
'PE' => [28.250, 68.100], // Peru
|
||
'PH' => [77.300, 54.500], // Philippines
|
||
'PN' => [14.356, 63.536], // Pitcairn Islands
|
||
'PL' => [55.000, 25.000], // Poland
|
||
'PT' => [45.293, 34.539], // Portugal
|
||
'QA' => [64.207, 38.082], // Qatar
|
||
'RO' => [56.937, 28.404], // Romania
|
||
'RU' => [72.222, 24.028], // Russia
|
||
'RW' => [58.362, 51.054], // Rwanda
|
||
'RE' => [65.427, 61.730], // Réunion
|
||
'WS' => [2.100, 57.577], // Samoa
|
||
'SM' => [53.456, 29.253], // San Marino
|
||
'SA' => [62.769, 46.847], // Saudi Arabia
|
||
'SN' => [45.895, 42.851], // Senegal
|
||
'RS' => [55.950, 29.293], // Serbia
|
||
'SC' => [65.411, 52.598], // Seychelles
|
||
'SL' => [46.732, 45.931], // Sierra Leone
|
||
'SG' => [74.000, 58.500], // Singapore
|
||
'SX' => [32.481, 41.481], // Sint Maarten
|
||
'SK' => [55.292, 26.987], // Slovakia
|
||
'SI' => [54.143, 28.249], // Slovenia
|
||
'SB' => [94.214, 54.461], // Solomon Islands
|
||
'SO' => [62.553, 48.315], // Somalia
|
||
'ZA' => [53.800, 69.500], // South Africa
|
||
'GS' => [41.371, 80.935], // South Georgia & South Sandwich Islands
|
||
'KR' => [82.175, 37.264], // South Korea
|
||
'ES' => [49.038, 31.068], // Spain
|
||
'LK' => [72.418, 46.420], // Sri Lanka
|
||
'BL' => [32.546, 41.546], // St. Barthélemy
|
||
'SH' => [48.413, 58.861], // St. Helena
|
||
'KN' => [32.567, 41.813], // St. Kitts & Nevis
|
||
'LC' => [33.061, 43.440], // St. Lucia
|
||
'MF' => [32.486, 41.462], // St. Martin
|
||
'PM' => [34.352, 27.787], // St. Pierre & Miquelon
|
||
'VC' => [32.962, 43.820], // St. Vincent & Grenadines
|
||
'SD' => [58.128, 42.288], // Sudan
|
||
'SR' => [34.469, 48.043], // Suriname
|
||
'SJ' => [55.022, 12.799], // Svalbard & Jan Mayen
|
||
'SE' => [55.283, 18.900], // Sweden
|
||
'CH' => [50.500, 31.000], // Switzerland
|
||
'SY' => [60.633, 33.469], // Syria
|
||
'ST' => [51.950, 49.542], // São Tomé & Príncipe
|
||
'TW' => [81.600, 45.000], // Taiwan
|
||
'TJ' => [70.163, 31.961], // Tajikistan
|
||
'TZ' => [60.922, 53.405], // Tanzania
|
||
'TH' => [72.200, 50.500], // Thailand
|
||
'TL' => [84.960, 54.891], // Timor-Leste
|
||
'TG' => [50.294, 45.841], // Togo
|
||
'TK' => [2.087, 54.757], // Tokelau
|
||
'TO' => [2.000, 61.783], // Tonga
|
||
'TT' => [33.078, 44.806], // Trinidad & Tobago
|
||
'TN' => [52.502, 34.092], // Tunisia
|
||
'TM' => [66.299, 31.179], // Turkmenistan
|
||
'TC' => [30.069, 39.698], // Turks & Caicos Islands
|
||
'TV' => [98.000, 54.730], // Tuvalu
|
||
'TR' => [59.700, 30.500], // Türkiye
|
||
'UM' => [2.000, 36.683], // U.S. Outlying Islands
|
||
'VI' => [32.006, 41.620], // U.S. Virgin Islands
|
||
'UG' => [59.152, 49.068], // Uganda
|
||
'UA' => [58.928, 26.519], // Ukraine
|
||
'AE' => [65.000, 44.000], // United Arab Emirates
|
||
'GB' => [43.100, 26.100], // United Kingdom
|
||
'US' => [22.778, 31.583], // United States
|
||
'UY' => [34.454, 68.312], // Uruguay
|
||
'UZ' => [67.778, 30.639], // Uzbekistan
|
||
'VU' => [96.364, 58.540], // Vanuatu
|
||
'VA' => [53.459, 30.212], // Vatican City
|
||
'VE' => [32.056, 46.608], // Venezuela
|
||
'VN' => [74.800, 50.800], // Vietnam
|
||
'WF' => [2.000, 57.937], // Wallis & Futuna
|
||
'EH' => [46.492, 38.682], // Western Sahara
|
||
'YE' => [62.743, 42.762], // Yemen
|
||
'ZM' => [57.332, 58.145], // Zambia
|
||
'ZW' => [58.313, 60.506], // Zimbabwe
|
||
'AX' => [55.519, 21.593], // Åland Islands
|
||
];
|
||
|
||
/**
|
||
* @return array{x: float, y: float}|null
|
||
*/
|
||
public function get(string $countryCode): ?array
|
||
{
|
||
$position = self::POSITIONS[strtoupper(trim($countryCode))] ?? null;
|
||
if ($position === null) {
|
||
return null;
|
||
}
|
||
|
||
return ['x' => $position[0], 'y' => $position[1]];
|
||
}
|
||
|
||
public function has(string $countryCode): bool
|
||
{
|
||
return $this->get($countryCode) !== null;
|
||
}
|
||
}
|