Created
July 12, 2018 19:11
-
-
Save mariohmol/3e207589f3be015c234d6310e6cedc26 to your computer and use it in GitHub Desktop.
geospatial
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const makeSquareAreaFromLatLng = function (lat, lng, distance = 10) { | |
const lat_change = distance / 111.2; | |
const lon_change = (Math.abs(Math.cos(lat * (Math.PI / 180)))) / 4; | |
const circlePoints = []; | |
const bounds = { | |
lat_min: lat - lat_change, | |
lon_min: lng - lon_change, | |
lat_max: lat + lat_change, | |
lon_max: lng + lon_change | |
}; | |
circlePoints.push([bounds.lon_min, bounds.lat_max]); | |
circlePoints.push([bounds.lon_max, bounds.lat_max]); | |
circlePoints.push([bounds.lon_max, bounds.lat_min]); | |
circlePoints.push([bounds.lon_min, bounds.lat_min]); | |
circlePoints.push([bounds.lon_min, bounds.lat_max]); | |
return circlePoints; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment