Created
February 21, 2012 21:20
-
-
Save asmuth/1879034 to your computer and use it in GitHub Desktop.
simple geohash point on range to bitstream - my first scala script :)
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
def geohashify_n(n: Double, rLeft: Int, rRight: Int, depth: Int): String = { | |
val mid = ((rRight - rLeft) / 2) + rLeft | |
if (depth == 0) | |
return "" | |
if (n > mid) | |
"1" + geohashify_n(n, mid, rRight, depth - 1) | |
else | |
"0" + geohashify_n(n, rLeft, mid, depth - 1) | |
} | |
println(geohashify_n(42.6, -90, 90, 10)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment