[OSM-dev] Building quadtile-capable rails_port on OS X

Frederik Ramm frederik at remote.org
Fri Sep 28 20:29:18 BST 2007


Hi,

> > > Alternatively, is there any way an "easy-but-slow" workaround could
> > > be provided avoiding the need to install the function when running
> > > locally?
> 
> Tis done - update and have fun.

I played around with an altogether different approach but abandoned it
because it kept giving me the wrong values and I couldn't find out
what was wrong. Just in case someone wants to pick up the pieces:

delimiter |
create function tile_for_point(latitude int, longitude int) returns
bigint
begin
declare x bigint;
declare y bigint;
set x=round((longitude/1000000.0 + 180.0) * 65535.0 / 360.0);
set y=round((latitude/1000000.0 + 90.0) * 65535.0 / 180.0);
return ((x & 32768) << 16) + ((x & 16384) << 15) + ((x & 8192) << 14)
+ ((x & 4096) << 13) + ((x & 2048) << 12) + ((x & 1024) << 11) + ((x &
512) << 10) + ((x & 256) << 9 ) + ((x & 128) << 8) + ((x & 64) << 7) +
((x & 32) << 6) + ((x & 16) << 5) + ((x & 8) << 4) + ((x & 4) << 3) +
((x & 2) << 2) + ((x & 1) << 1) + ((y & 32768) << 15) + ((y & 16384)
<< 14) + ((y & 8192) << 13) + ((y & 4096) << 12) + ((y & 2048) << 11)
+ ((y & 1024) << 10) + ((y & 512) << 9) + ((y & 256) << 8) + ((y &
128) << 7) + ((y & 64) << 6) + ((y & 32) << 5) + ((y & 16) << 4) + ((y
& 8) << 3) + ((y & 4) << 2) + ((y & 2) << 1) + (y & 1)
;   
end|

Can't really see why it shouldn't work, most likely some trouble with
an overflow somewhere.

Bye
Frederik

-- 
Frederik Ramm  ##  eMail frederik at remote.org  ##  N49°00.09' E008°23.33'





More information about the dev mailing list