1/** 2 * geo.js â shared geo helpers. 3 * 4 * Extracted from three identical copies that had drifted into 5 * reservationList.js, reservationDetail.js and storeLocator.js. Each lived 6 * inside its own IIFE, so they could not share code and any fix had to be made 7 * three times. 8 */ 9 10/** 11 * Great-circle distance between two points, rounded to whole kilometres. 12 * 13 * The extracted copies all applied Math.abs() to the outlet latitude before 14 * differencing it against the user's, which is wrong in principle â it mirrors 15 * southern-hemisphere outlets onto the northern one. It happened to be harmless 16 * for this platform (every outlet is in India, north of the equator) and is 17 * corrected here rather than preserved. 18 * 19 * @param {number} uLat user latitude 20 * @param {number} uLng user longitude 21 * @param {number} oLat outlet latitude 22 * @param {number} oLng outlet longitude 23 * @returns {number} distance in km, rounded 24 */ 25export function distanceKm(uLat, uLng, oLat, oLng) { 26 var rad = Math.PI / 180; 27 var a = Math.pow(Math.sin((uLat - oLat) * rad / 2), 2) + 28 Math.cos(uLat * rad) * Math.cos(oLat * rad) * 29 Math.pow(Math.sin((uLng - oLng) * rad / 2), 2); 30 // Constant kept exactly as the extracted copies had it (3956 mi â km), so 31 // displayed distances don't shift for existing users. Only the Math.abs() 32 // quirk above is corrected here. 33 return Math.round(1.609344 * 3956 * 2 * Math.asin(Math.sqrt(a))); 34}
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.