Last active
January 5, 2017 18:53
-
-
Save auser/19a4b215e13bc7bf2af4610fdb9d11be to your computer and use it in GitHub Desktop.
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
# Old | |
[latStr, lngStr] = String.split(geo, ",") | |
{lat, _} = Float.parse(latStr) | |
{lng, _} = Float.parse(lngStr) | |
[bl, tr] = Geocalc.bounding_box([lat,lng], 10_000) | |
[lat1, lng1] = bl; | |
[lat2, lng2] = tr; | |
coords = "#{lat1}, #{lng1}, #{lat2}, #{lng2}" | |
# new | |
# coords = bounding_box(geo, 50_000) | |
defp bounding_box(geo, distance \\ 50_000) do | |
String.split(geo, ",") | |
|> Enum.map(fn(v) -> String.to_float(v) end) | |
|> Geocalc.bounding_box(distance) | |
|> Enum.map(fn([lat,lng]) -> "#{lat},#{lng}" end) | |
|> Enum.join(",") | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment