Geohash: Difference between revisions

422 bytes added ,  3 years ago
m
→‎{{header|Phix}}: added precision 22 test
(julia example)
m (→‎{{header|Phix}}: added precision 22 test)
Line 223:
sequence tests = {{{51.433718, -0.214126}, 2},
{{51.433718, -0.214126}, 9},
{{57.64911, 10.40744 }, 11}},
{{57.64911, 10.40744 }, 22}}
for i=1 to length(tests) do
Line 235 ⟶ 236:
tests = append(tests,"ezs42")
for i=1 to length(tests) do
printf(1,"%-12s22s ==> %v\n",{tests[i],decode_geohash(tests[i])})
end for</lang>
{{out}}
Line 242 ⟶ 243:
geohash for {51.433718,-0.214126}, precision 9 = gcpue5hp4
geohash for {57.64911,10.40744}, precision 11 = u4pruydqqvj
geohash for {57.64911,10.40744}, precision 22 = u4pruydqqvj8pr9yc27rjr
 
decode tests:
gc ==> {{50.625,56.25},{-11.25,0}}
gcpue5hp4 ==> {{51.43369675,51.43373966},{-0.2141475677,-0.2141046524}}
u4pruydqqvj ==> {{57.64910996,57.6491113},{10.40743902,10.40744036}}
ezs42 u4pruydqqvj8pr9yc27rjr ==> {{4257.5830078164911,4257.6269531264911},{-510.62540744,-510.58105468840744}}
ezs42 ==> {{42.58300781,42.62695312},{-5.625,-5.581054688}}
</pre>
Not surprisingly, "gc" is not even accurate to one significant digit, but a precision of 9 is accurate to 5 or 6 significant digits, and 11 to 6 or 7 digits, and 22 exceeds the natural 10 sig digs of %v. Note that 32-bit gives a last character of 'q' for the precision 22 test, for obvious reasons, the above results are from using the 64-bit interpreter.
 
=={{header|Python}}==
7,803

edits