Geohash: Difference between revisions
m
→{{header|J}}: slight efficiency gain and an observation about rounding
(J first draft, without extra credit) |
m (→{{header|J}}: slight efficiency gain and an observation about rounding) |
||
Line 350:
geohash=: {{
bits=.
x{.gdigits{~_5 #.\,|:|.(bits#2)#:<.(2^bits)*(y+90 180)%180 360
}}</syntaxhighlight>
Note that the test cases suggest that rounding should never be used when generating a geohash. This guarantees that a short geohash is always a prefix of a longer geohash for the same location.
<syntaxhighlight lang=J> 2 geohash 51.433718 _0.214126
|