Skip to content

Instantly share code, notes, and snippets.

@sebastibe
Created August 12, 2014 06:32
Show Gist options
  • Save sebastibe/6492d286afd91af7718b to your computer and use it in GitHub Desktop.
Save sebastibe/6492d286afd91af7718b to your computer and use it in GitHub Desktop.
# Given an array of coordinates, get the bounding box
getBounds = (coordinates) ->
xv = []
yv = []
$.each(coordinates, (i, coord) ->
xv.push(coord[0])
yv.push(coord[1])
)
return [
[Math.min.apply(null, xv), Math.min.apply(null, yv)],
[Math.max.apply(null, xv), Math.max.apply(null, yv)]
]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment