diff --git a/twitch/chatguessr.js b/twitch/chatguessr.js index 6cff586..35375e0 100644 --- a/twitch/chatguessr.js +++ b/twitch/chatguessr.js @@ -27,19 +27,18 @@ return data.countryCode; } }; + function moveFrom(coords, angle, distance) { + let radianAngle = (angle * Math.PI) / 180; + let x = 0 + distance * Math.cos(radianAngle); + let y = 0 + distance * Math.sin(radianAngle); + let newLat = coords.lat + y * M; + let newLng = coords.lng + (x * M) / Math.cos(coords.lat * (Math.PI / 180)); + return { lat: newLat, lng: newLng }; + } function getSurroundings (location) { const meters = 100; const R_EARTH = 6378.137; const M = 1 / (((2 * Math.PI) / 360) * R_EARTH) / 1000; - - function moveFrom(coords, angle, distance) { - let radianAngle = (angle * Math.PI) / 180; - let x = 0 + distance * Math.cos(radianAngle); - let y = 0 + distance * Math.sin(radianAngle); - let newLat = coords.lat + y * M; - let newLng = coords.lng + (x * M) / Math.cos(coords.lat * (Math.PI / 180)); - return { lat: newLat, lng: newLng }; - } let coordinates = [location]; for (let angle = 0; angle < 360; angle += 45) { coordinates.push(moveFrom({ lat: location.lat, lng: location.lng }, angle, meters));