Skip to content

Instantly share code, notes, and snippets.

@asmuth
Created February 21, 2012 21:20
Show Gist options
  • Save asmuth/1879034 to your computer and use it in GitHub Desktop.
Save asmuth/1879034 to your computer and use it in GitHub Desktop.
simple geohash point on range to bitstream - my first scala script :)
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