<?php
|
/*---------------------------------------------------------------*/
|
/*
|
Titre : Distances entre grandes villes du monde
|
|
URL : https://phpsources.net/code_s.php?id=1008
|
Date édition : 15 Fév 2019
|
Date mise à jour : 08 Aout 2019
|
Rapport de la maj:
|
- fonctionnement du code vérifié
|
- modification de la description
|
*/
|
/*---------------------------------------------------------------*/
|
|
function distance_monde($ville1 , $ville2){
|
$cities = array();
|
$cities["Addis Ababa"]["N"] = array(9, 2, 0);
|
$cities["Addis Ababa"]["E"] = array(38, 45, 0);
|
$cities["Adelaide"]["S"] = array(34, 56, 0);
|
$cities["Adelaide"]["E"] = array(138, 35, 0);
|
$cities["Aden"]["N"] = array(12, 48, 0);
|
$cities["Aden"]["E"] = array(45, 0, 0);
|
$cities["Algers"]["N"] = array(36, 46, 0);
|
$cities["Algers"]["E"] = array(30, 3, 0);
|
$cities["Amman"]["N"] = array(31, 57, 0);
|
$cities["Amman"]["E"] = array(35, 57, 0);
|
$cities["Amsterdam"]["N"] = array(52, 21, 0);
|
$cities["Amsterdam"]["E"] = array(4, 52, 0);
|
$cities["Anadyr"]["N"] = array(64, 50, 0);
|
$cities["Anadyr"]["E"] = array(177, 50, 0);
|
$cities["Anchorage"]["N"] = array(61, 10, 43);
|
$cities["Anchorage"]["W"] = array(149, 11, 11);
|
$cities["Ankara"]["N"] = array(39, 57, 0);
|
$cities["Ankara"]["E"] = array(32, 53, 0);
|
$cities["Antananarivo"]["S"] = array(18, 55, 0);
|
$cities["Antananarivo"]["E"] = array(47, 31, 0);
|
$cities["Asuncion"]["S"] = array(25, 14, 0);
|
$cities["Asuncion"]["W"] = array(57, 31, 0);
|
$cities["Athenes"]["N"] = array(37, 58, 0);
|
$cities["Athenes"]["E"] = array(23, 43, 0);
|
$cities["Atlanta"]["N"] = array(33, 45, 46);
|
$cities["Atlanta"]["W"] = array(84, 25, 21);
|
$cities["Austin"]["N"] = array(30, 18, 21);
|
$cities["Austin"]["W"] = array(97, 45, 2);
|
$cities["Azores"]["N"] = array(38, 46, 12);
|
$cities["Azores"]["W"] = array(27, 6, 0);
|
$cities["Bagdad"]["N"] = array(33, 20, 0);
|
$cities["Bagdad"]["E"] = array(44, 26, 0);
|
$cities["Bangalore"]["N"] = array(13, 48, 0);
|
$cities["Bangalore"]["E"] = array(77, 18, 0);
|
$cities["Bangkok"]["N"] = array(13, 44, 0);
|
$cities["Bangkok"]["E"] = array(100, 30, 0);
|
$cities["Barcelone"]["N"] = array(41, 24, 0);
|
$cities["Barcelone"]["E"] = array(2, 9, 0);
|
$cities["Beijing"]["N"] = array(39, 55, 0);
|
$cities["Beijing"]["E"] = array(116, 26, 0);
|
$cities["Beyrouth"]["N"] = array(33, 54, 0);
|
$cities["Beyrouth"]["E"] = array(35, 28, 0);
|
$cities["Belgrade"]["N"] = array(44, 48, 0);
|
$cities["Belgrade"]["E"] = array(20, 28, 0);
|
$cities["Berlin"]["N"] = array(52, 27, 0);
|
$cities["Berlin"]["E"] = array(13, 18, 0);
|
$cities["Bermuda"]["N"] = array(32, 22, 1);
|
$cities["Bermuda"]["W"] = array(64, 40, 59);
|
$cities["Bern"]["N"] = array(46, 57, 0);
|
$cities["Bern"]["E"] = array(7, 26, 0);
|
$cities["Bogota"]["N"] = array(4, 36, 0);
|
$cities["Bogota"]["W"] = array(74, 5, 0);
|
$cities["Boston"]["N"] = array(42, 20, 10);
|
$cities["Boston"]["W"] = array(71, 1, 4);
|
$cities["Brasilia"]["S"] = array(15, 47, 0);
|
$cities["Brasilia"]["W"] = array(47, 55, 0);
|
$cities["Brisbane"]["S"] = array(2, 28, 0);
|
$cities["Brisbane"]["E"] = array(153, 2, 0);
|
$cities["Bruxelles"]["N"] = array(50, 48, 0);
|
$cities["Bruxelles"]["E"] = array(4, 21, 0);
|
$cities["Bucarest"]["N"] = array(44, 26, 0);
|
$cities["Bucarest"]["E"] = array(26, 6, 0);
|
$cities["Budapest"]["N"] = array(47, 30, 0);
|
$cities["Budapest"]["E"] = array(19, 5, 0);
|
$cities["Buenos Aires"]["S"] = array(34, 35, 0);
|
$cities["Buenos Aires"]["W"] = array(58, 29, 0);
|
$cities["Le Caire"]["N"] = array(29, 52, 0);
|
$cities["Le Caire"]["E"] = array(31, 20, 0);
|
$cities["Calcutta"]["N"] = array(22, 32, 0);
|
$cities["Calcutta"]["E"] = array(88, 20, 0);
|
$cities["Canberra"]["S"] = array(35, 21, 0);
|
$cities["Canberra"]["E"] = array(149, 10, 0);
|
$cities["Cape Town"]["S"] = array(33, 56, 0);
|
$cities["Cape Town"]["E"] = array(18, 29, 0);
|
$cities["Caracas"]["N"] = array(10, 30, 0);
|
$cities["Caracas"]["W"] = array(66, 56, 0);
|
$cities["Casablanca"]["N"] = array(33, 35, 0);
|
$cities["Casablanca"]["W"] = array(7, 39, 0);
|
$cities["Chicago"]["N"] = array(41, 50, 13);
|
$cities["Chicago"]["W"] = array(87, 41, 6);
|
$cities["Copenhague"]["N"] = array(55, 41, 0);
|
$cities["Copenhague"]["W"] = array(12, 3, 0);
|
$cities["Dakar"]["N"] = array(14, 45, 0);
|
$cities["Dakar"]["W"] = array(17, 30, 0);
|
$cities["Dallas"]["N"] = array(32, 47, 39);
|
$cities["Dallas"]["W"] = array(96, 45, 55);
|
$cities["Damascus"]["N"] = array(33, 31, 0);
|
$cities["Damascus"]["E"] = array(36, 18, 0);
|
$cities["Dar es Salaam"]["S"] = array(6, 50, 0);
|
$cities["Dar es Salaam"]["E"] = array(39, 18, 0);
|
$cities["Darwin"]["S"] = array(12, 28, 0);
|
$cities["Darwin"]["E"] = array(130, 51, 0);
|
$cities["Denver"]["N"] = array(39, 46, 5);
|
$cities["Denver"]["W"] = array(104, 52, 22);
|
$cities["Detroit"]["N"] = array(42, 22, 59);
|
$cities["Detroit"]["W"] = array(83, 6, 8);
|
$cities["Dhaka"]["N"] = array(23, 51, 0);
|
$cities["Dhaka"]["E"] = array(90, 24, 0);
|
$cities["Dublin"]["N"] = array(53, 22, 0);
|
$cities["Dublin"]["W"] = array(6, 21, 00);
|
$cities["Edmonton"]["N"] = array(53, 30, 0);
|
$cities["Edmonton"]["W"] = array(113, 30, 0);
|
$cities["Frankfurt"]["N"] = array(50, 1, 59);
|
$cities["Frankfurt"]["E"] = array(8, 34, 1);
|
$cities["Geneva"]["N"] = array(46, 14, 0);
|
$cities["Geneva"]["E"] = array(6, 4, 0);
|
$cities["Genoa"]["N"] = array(44, 24, 47);
|
$cities["Genoa"]["E"] = array(8, 51, 0);
|
$cities["Guatemala"]["N"] = array(14, 37, 0);
|
$cities["Guatemala"]["W"] = array(90, 31, 0);
|
$cities["Hanoi"]["N"] = array(21, 1, 0);
|
$cities["Hanoi"]["E"] = array(105, 42, 0);
|
$cities["Harare"]["S"] = array(17, 50, 0);
|
$cities["Harare"]["E"] = array(31, 30, 0);
|
$cities["Havana"]["N"] = array(23, 8, 0);
|
$cities["Havana"]["W"] = array(82, 21, 0);
|
$cities["Helsinki"]["N"] = array(60, 10, 0);
|
$cities["Helsinki"]["E"] = array(24, 57, 0);
|
$cities["Ho Chi Minh"]["N"] = array(10, 47, 0);
|
$cities["Ho Chi Minh"]["E"] = array(106, 42, 0);
|
$cities["Hong Kong"]["N"] = array(22, 18, 0);
|
$cities["Hong Kong"]["E"] = array(114, 10, 0);
|
$cities["Honolulu"]["N"] = array(21, 18, 0);
|
$cities["Honolulu"]["W"] = array(157, 51, 0);
|
$cities["Houston"]["N"] = array(29, 46, 7);
|
$cities["Houston"]["W"] = array(95, 23, 12);
|
$cities["Indianapolis"]["N"] = array(39, 46, 35);
|
$cities["Indianapolis"]["W"] = array(86, 8, 46);
|
$cities["Islamabad"]["N"] = array(33, 37, 0);
|
$cities["Islamabad"]["E"] = array(73, 6, 0);
|
$cities["Istanbul"]["N"] = array(40, 58, 0);
|
$cities["Istanbul"]["E"] = array(28, 50, 0);
|
$cities["Jakarta"]["S"] = array(6, 8, 0);
|
$cities["Jakarta"]["E"] = array(106, 45, 0);
|
$cities["Jerusalem"]["N"] = array(31, 47, 0);
|
$cities["Jerusalem"]["E"] = array(35, 13, 0);
|
$cities["Johannesburg"]["S"] = array(26, 11, 0);
|
$cities["Johannesburg"]["E"] = array(28, 3, 0);
|
$cities["Kaboul"]["N"] = array(34, 34, 1);
|
$cities["Kaboul"]["E"] = array(69, 13, 1);
|
$cities["Kathmandu"]["N"] = array(27, 42, 0);
|
$cities["Kathmandu"]["E"] = array(82, 12, 0);
|
$cities["Khartoum"]["N"] = array(15, 37, 0);
|
$cities["Khartoum"]["E"] = array(32, 33, 0);
|
$cities["Kiev"]["N"] = array(50, 30, 0);
|
$cities["Kiev"]["E"] = array(30, 28, 0);
|
$cities["Kigali"]["S"] = array(2, 18, 0);
|
$cities["Kigali"]["E"] = array(29, 57, 0);
|
$cities["Kingston"]["N"] = array(18, 0, 0);
|
$cities["Kingston"]["W"] = array(76, 45, 0);
|
$cities["Kinshasa"]["S"] = array(4, 23, 0);
|
$cities["Kinshasa"]["E"] = array(15, 27, 0);
|
$cities["Kuala Lumpur"]["N"] = array(3, 7, 0);
|
$cities["Kuala Lumpur"]["E"] = array(101, 42, 0);
|
$cities["Koweit"]["N"] = array(29, 4, 0);
|
$cities["Koweit"]["E"] = array(47, 59, 0);
|
$cities["La Paz"]["S"] = array(16, 30, 0);
|
$cities["La Paz"]["W"] = array(68, 9, 0);
|
$cities["Las Palmas"]["N"] = array(27, 55, 59);
|
$cities["Las Palmas"]["W"] = array(15, 22, 58);
|
$cities["Lagos"]["N"] = array(6, 27, 0);
|
$cities["Lagos"]["E"] = array(3, 24, 0);
|
$cities["Lima"]["S"] = array(12, 5, 0);
|
$cities["Lima"]["W"] = array(77, 3, 0);
|
$cities["Lisbon"]["N"] = array(38, 42, 0);
|
$cities["Lisbon"]["W"] = array(9, 5, 0);
|
$cities["Londres"]["N"] = array(51, 30, 0);
|
$cities["Londres"]["W"] = array(0, 7, 0);
|
$cities["Los Angeles"]["N"] = array(34, 6, 44);
|
$cities["Los Angeles"]["W"] = array(128, 24, 40);
|
$cities["Madrid"]["N"] = array(40, 25, 0);
|
$cities["Madrid"]["W"] = array(3, 41, 0);
|
$cities["Male"]["N"] = array(4, 0, 0);
|
$cities["Male"]["W"] = array(73, 0, 0);
|
$cities["Managua"]["N"] = array(12, 10, 0);
|
$cities["Managua"]["W"] = array(86, 15, 0);
|
$cities["Manila"]["N"] = array(14, 37, 0);
|
$cities["Manila"]["E"] = array(121, 0, 0);
|
$cities["Maujuro"]["N"] = array(6, 58, 0);
|
$cities["Maujuro"]["E"] = array(173, 42, 0);
|
$cities["Melbourne"]["S"] = array(37, 52, 0);
|
$cities["Melbourne"]["E"] = array(145, 8, 0);
|
$cities["Mexico"]["N"] = array(19, 24, 0);
|
$cities["Mexico"]["W"] = array(99, 12, 0);
|
$cities["Miami"]["N"] = array(25, 46, 32);
|
$cities["Miami"]["W"] = array(80, 12, 39);
|
$cities["Milan"]["N"] = array(45, 27, 0);
|
$cities["Milan"]["E"] = array(9, 17, 0);
|
$cities["Minneapolis"]["N"] = array(44, 57, 43);
|
$cities["Minneapolis"]["W"] = array(93, 16, 1);
|
$cities["Minsk"]["N"] = array(53, 54, 0);
|
$cities["Minsk"]["E"] = array(27, 34, 0);
|
$cities["Montevideo"]["S"] = array(34, 51, 0);
|
$cities["Montevideo"]["W"] = array(56, 13, 0);
|
$cities["Montreal"]["N"] = array(45, 30, 0);
|
$cities["Montreal"]["W"] = array(73, 34, 48);
|
$cities["Moscou"]["N"] = array(55, 46, 0);
|
$cities["Moscou"]["E"] = array(37, 40, 0);
|
$cities["Muscat"]["N"] = array(23, 31, 0);
|
$cities["Muscat"]["E"] = array(58, 42, 0);
|
$cities["Nairobi"]["S"] = array(1, 16, 0);
|
$cities["Nairobi"]["E"] = array(36, 48, 0);
|
$cities["Naples"]["N"] = array(40, 53, 0);
|
$cities["Naples"]["E"] = array(14, 18, 0);
|
$cities["Nassau"]["N"] = array(25, 5, 0);
|
$cities["Nassau"]["W"] = array(77, 21, 0);
|
$cities["New Orleans"]["N"] = array(30, 3, 57);
|
$cities["New Orleans"]["W"] = array(89, 55, 53);
|
$cities["New Delhi"]["N"] = array(28, 54, 0);
|
$cities["New Delhi"]["E"] = array(77, 13, 0);
|
$cities["New York"]["N"] = array(40, 40, 11);
|
$cities["New York"]["W"] = array(73, 56, 38);
|
$cities["Nice"]["N"] = array(43, 42, 0);
|
$cities["Nice"]["E"] = array(7, 21, 0);
|
$cities["Oslo"]["N"] = array(59, 56, 0);
|
$cities["Oslo"]["E"] = array(10, 44, 0);
|
$cities["Ottawa"]["N"] = array(45, 25, 12);
|
$cities["Ottawa"]["W"] = array(75, 40, 12);
|
$cities["Panama"]["N"] = array(9, 4, 1);
|
$cities["Panama"]["W"] = array(79, 22, 59);
|
$cities["Paris"]["N"] = array(48, 49, 0);
|
$cities["Paris"]["W"] = array(2, 29, 0);
|
$cities["Perth"]["S"] = array(31, 57, 0);
|
$cities["Perth"]["E"] = array(115, 41, 0);
|
$cities["Phoenix"]["N"] = array(33, 32, 33);
|
$cities["Phoenix"]["W"] = array(112, 4, 17);
|
$cities["Phnom Penh"]["N"] = array(11, 33, 0);
|
$cities["Phnom Penh"]["E"] = array(104, 51, 0);
|
$cities["Port Moresby"]["S"] = array(9, 27, 0);
|
$cities["Port Moresby"]["E"] = array(147, 13, 0);
|
$cities["Prague"]["N"] = array(50, 5, 0);
|
$cities["Prague"]["E"] = array(14, 25, 0);
|
$cities["Pyongyang"]["N"] = array(39, 2, 0);
|
$cities["Pyongyang"]["E"] = array(125, 41, 0);
|
$cities["Reykjavik"]["N"] = array(64, 8, 0);
|
$cities["Reykjavik"]["E"] = array(21, 56, 0);
|
$cities["Rio de Janeiro"]["S"] = array(22, 55, 0);
|
$cities["Rio de Janeiro"]["W"] = array(43, 12, 0);
|
$cities["Riyadh"]["N"] = array(24, 39, 0);
|
$cities["Riyadh"]["E"] = array(46, 42, 0);
|
$cities["Rome"]["N"] = array(41, 48, 0);
|
$cities["Rome"]["E"] = array(12, 36, 0);
|
$cities["Saint John"]["N"] = array(47, 4, 58);
|
$cities["Saint John"]["W"] = array(52, 42, 36);
|
$cities["Sanaa"]["N"] = array(15, 20, 0);
|
$cities["Sanaa"]["E"] = array(44, 21, 0);
|
$cities["San Francisco"]["N"] = array(37, 47, 36);
|
$cities["San Francisco"]["W"] = array(122, 33, 17);
|
$cities["San Jose"]["N"] = array(9, 57, 0);
|
$cities["San Jose"]["W"] = array(84, 5, 0);
|
$cities["San Juan"]["N"] = array(18, 29, 0);
|
$cities["San Juan"]["W"] = array(66, 7, 0);
|
$cities["San Salvador"]["N"] = array(13, 42, 0);
|
$cities["San Salvador"]["W"] = array(89, 13, 0);
|
$cities["Santo Domingo"]["N"] = array(18, 29, 0);
|
$cities["Santo Domingo"]["W"] = array(69, 54, 0);
|
$cities["Santiago"]["S"] = array(33, 27, 0);
|
$cities["Santiago"]["W"] = array(70, 42, 0);
|
$cities["Sao Paulo"]["S"] = array(23, 33, 0);
|
$cities["Sao Paulo"]["W"] = array(46, 38, 0);
|
$cities["Seattle"]["N"] = array(47, 37, 18);
|
$cities["Seattle"]["W"] = array(122, 21, 1);
|
$cities["Seoul"]["N"] = array(37, 34, 0);
|
$cities["Seoul"]["E"] = array(126, 58, 0);
|
$cities["Shanghai"]["N"] = array(31, 12, 0);
|
$cities["Shanghai"]["E"] = array(121, 26, 0);
|
$cities["Singapore"]["N"] = array(1, 18, 0);
|
$cities["Singapore"]["E"] = array(103, 50, 0);
|
$cities["Sofia"]["N"] = array(42, 42, 0);
|
$cities["Sofia"]["E"] = array(23, 20, 0);
|
$cities["Stockholm"]["N"] = array(59, 21, 0);
|
$cities["Stockholm"]["E"] = array(18, 4, 0);
|
$cities["Suva"]["S"] = array(18, 10, 0);
|
$cities["Suva"]["E"] = array(178, 25, 0);
|
$cities["Sydney"]["S"] = array(33, 52, 0);
|
$cities["Sydney"]["E"] = array(151, 12, 0);
|
$cities["Taipei"]["N"] = array(25, 2, 0);
|
$cities["Taipei"]["E"] = array(121, 31, 0);
|
$cities["Tallinn"]["N"] = array(59, 25, 0);
|
$cities["Tallinn"]["E"] = array(24, 45, 0);
|
$cities["Tashkent"]["N"] = array(41, 19, 0);
|
$cities["Tashkent"]["E"] = array(69, 15, 0);
|
$cities["Tegucigalpa"]["N"] = array(14, 4, 0);
|
$cities["Tegucigalpa"]["W"] = array(87, 13, 0);
|
$cities["Tehran"]["N"] = array(35, 41, 0);
|
$cities["Tehran"]["E"] = array(51, 25, 0);
|
$cities["Timbuktu"]["N"] = array(16, 46, 0);
|
$cities["Timbuktu"]["W"] = array(3, 1, 0);
|
$cities["Tokyo"]["N"] = array(35, 41, 0);
|
$cities["Tokyo"]["E"] = array(139, 46, 0);
|
$cities["Toronto"]["N"] = array(43, 40, 12);
|
$cities["Toronto"]["W"] = array(79, 22, 12);
|
$cities["Tripoli"]["N"] = array(32, 50, 0);
|
$cities["Tripoli"]["E"] = array(13, 13, 0);
|
$cities["Tunis"]["N"] = array(36, 51, 0);
|
$cities["Tunis"]["E"] = array(10, 13, 1);
|
$cities["Ulaanbaatar"]["N"] = array(59, 10, 0);
|
$cities["Ulaanbaatar"]["E"] = array(107, 21, 0);
|
$cities["Vancouver"]["N"] = array(49, 15, 0);
|
$cities["Vancouver"]["W"] = array(123, 4, 48);
|
$cities["Venice"]["N"] = array(45, 25, 0);
|
$cities["Venice"]["E"] = array(12, 18, 0);
|
$cities["Vienna"]["N"] = array(48, 15, 0);
|
$cities["Vienna"]["E"] = array(16, 22, 0);
|
$cities["Vladivostok"]["N"] = array(43, 7, 0);
|
$cities["Vladivostok"]["E"] = array(131, 55, 0);
|
$cities["Warsaw"]["N"] = array(52, 13, 0);
|
$cities["Warsaw"]["E"] = array(21, 2, 0);
|
$cities["Washington"]["N"] = array(38, 54, 18);
|
$cities["Washington"]["W"] = array(77, 0, 8);
|
$cities["Wellington"]["S"] = array(41, 17, 0);
|
$cities["Wellington"]["E"] = array(174, 46, 0);
|
$cities["Zagreb"]["N"] = array(45, 48, 0);
|
$cities["Zagreb"]["E"] = array(15, 58, 0);
|
$cities["Zurich"]["N"] = array(47, 23, 0);
|
$cities["Zurich"]["E"] = array(8, 33, 0);
|
if (!isset($cities[ucfirst(strtolower($ville1))])){
|
return FALSE;
|
}
|
if (!isset($cities[ucfirst(strtolower($ville2))])){
|
return FALSE;
|
}
|
|
$from = $cities[ucfirst(strtolower($ville1))];
|
$to = $cities[ucfirst(strtolower($ville2))];
|
|
if (isset($from['N'])){
|
$lat1 = $from['N'][0] + $from['N'][1] / 60 + $from['N'][2]/3600;
|
} else {
|
$lat1 = 0 - ($from['S'][0] + $from['S'][1] / 60 + $from['S'][2]/3600);
|
}
|
if (isset($from['E'])){
|
$lon1 = $from['E'][0] + $from['E'][1] / 60 + $from['E'][2]/3600;
|
} else {
|
$lon1= 0 - ($from['W'][0] + $from['W'][1] / 60 + $from['W'][2]/3600);
|
}
|
|
if (isset($from['N'])){
|
$lat2 = $to['N'][0] + $to['N'][1] / 60 + $to['N'][2]/3600;
|
} else {
|
$lat2 = 0 - ($to['S'][0] + $to['S'][1] / 60 + $to['S'][2]/3600);
|
}
|
if (isset($to['E'])){
|
$lon2 = $to['E'][0] + $to['E'][1] / 60 + $to['E'][2]/3600;
|
} else {
|
$lon2 = 0 - ($to['W'][0] + $to['W'][1] / 60 + $to['W'][2]/3600);
|
}
|
|
$lat1 = deg2rad($lat1);
|
$lon1 = deg2rad($lon1);
|
$lat2 = deg2rad($lat2);
|
$lon2 = deg2rad($lon2);
|
|
$dlat = $lat2-$lat1;
|
$dlon = $lon2-$lon1;
|
$R = 6371.03;
|
|
$a = pow((sin($dlat/2)), 2) + cos($lat1) * cos($lat2) * pow((sin($dlon/2)
|
), 2
|
);
|
$c = 2*atan2(sqrt($a), sqrt(1-$a));
|
$d = $R*$c;
|
|
return $d;
|
}
|
?>
|
|
|