{"ScriptPreparationCode":"function getDistanceFromLatLonInKm2(lat, lng, lat0, lng0) {\r\n //https://jonisalonen.com/2014/computing-distance-between-coordinates-can-be-simple-and-fast/\r\n \r\n let deglen = 110.25\r\n let x = lat - lat0\r\n let y = (lng - lng0)*Math.cos(lat0)\r\n return deglen*Math.sqrt(x*x \u002B y*y)\r\n}\r\n\r\nfunction getDistanceFromLatLonInKm(lat1, lon1, lat2, lon2) {\r\n var R = 6371; // Radius of the earth in km\r\n var dLat = deg2rad(lat2-lat1); // deg2rad below\r\n var dLon = deg2rad(lon2-lon1); \r\n var a = \r\n Math.sin(dLat/2) * Math.sin(dLat/2) \u002B\r\n Math.cos(deg2rad(lat1)) * Math.cos(deg2rad(lat2)) * \r\n Math.sin(dLon/2) * Math.sin(dLon/2)\r\n ; \r\n var c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1-a)); \r\n var d = R * c; // Distance in km\r\n return d;\r\n}\r\n\r\nfunction deg2rad(deg) {\r\n return deg * (Math.PI/180)\r\n}","TestCases":[{"Name":"full","Code":"getDistanceFromLatLonInKm(51.496, -0.143, 51.601, -0.118);","IsDeferred":false},{"Name":"quick","Code":"getDistanceFromLatLonInKm2(51.496, -0.143, 51.601, -0.118);","IsDeferred":false}]}