<HTML><BODY style="word-wrap: break-word; -khtml-nbsp-mode: space; -khtml-line-break: after-white-space; "><DIV>Hello,</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV>I had a chance to go through tile.openstreetmap.org implementation and I'd like to suggest some improvements.</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV>At the moment we store x,y,z and there is a key(x,y,z). I think we can improve by introducing spatial reference (also known as quad key etc) and this is exactly what MS VE, Oracle and others are using. There are a few benefits but the main one is </DIV><DIV>that standard b-tree index will 'cluster' tiles spatially, resulting in better I/O. It will also simplify and reduce table size a little bit.</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV> x = 32541 y = 21721 z = 16 becomes 'adbdbdbbccaddbad' // the length of this key equals to zoom level.</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV>And there is a simple logic to go to/from (see Python below)</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV>I'm not sure if this has been discussed already, thoughts?</DIV><DIV> </DIV><DIV>Cheers,</DIV><DIV>Artem</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV>def spatial_reference ( x , y, zoom):</DIV><DIV> ref = ''</DIV><DIV> for i in range(zoom,0,-1):</DIV><DIV> mask = 1 << (i - 1)</DIV><DIV> cell = ord('a')</DIV><DIV> if ( x & mask ) != 0 : cell += 1</DIV><DIV> if ( y & mask ) != 0 : cell += 2</DIV><DIV> ref += chr(cell)</DIV><DIV> return ref</DIV><DIV> </DIV><DIV>if __name__ == '__main__':</DIV><DIV> x = 32541</DIV><DIV> y = 21721</DIV><DIV> z = 16</DIV><DIV> </DIV><DIV> ref = spatial_reference(x,y,z)</DIV><DIV> print "%s %s %s -> %s" % (x,y,z,ref)</DIV><DIV> print "zoom level eq len(ref) e.g. %s" % len(ref)</DIV><DIV> </DIV><DIV><BR class="khtml-block-placeholder"></DIV><BR><DIV> <SPAN class="Apple-style-span" style="border-collapse: separate; border-spacing: 0px 0px; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: auto; -khtml-text-decorations-in-effect: none; text-indent: 0px; -apple-text-size-adjust: auto; text-transform: none; orphans: 2; white-space: normal; widows: 2; word-spacing: 0px; "><DIV>Artem Pavlenko</DIV><DIV><A href="http://mapnik.org">http://mapnik.org</A></DIV><DIV><BR class="khtml-block-placeholder"></DIV><BR class="Apple-interchange-newline"></SPAN> </DIV><BR></BODY></HTML>