The new server code looks good, so it would be great to see it go live at some point.

Tileset file description
========================
I have a converter that converts the single tiles into tileset files. Tileset 
files contain.

0: a tileset file version(currently 1), so I can modify the file format at a 
later point
2: user id of user who uploaded the thing
4: offset of tile 1 (z0x0y0)
8: offeset of tile 2  (z1x0y0)
12 offset of file 3 (z1x1y0)
...
5468:offset after tile 1365(points to end of file)
5472:data png1

Do you think it would make sense to add some more metadata to the file? E.g. client version number

Another useful piece of information might be to have the min_z and max_z values in the structure. Given that not all layers have the same number of zoom levels, I guess one needs the information of how many tiles should be in the tileset.

Will the caption / captionless layers cause any problems? Aren't those zoom levels a bit strange with respect to the z0, z6 and z12 structure of the tilesets?

...

offset is either a pointer to the file position where the png data is, or it 
can also be a blankness value:
0=unknown
1=land
2=sea
3=transparent (not implemented yet)

Hmm, I think there is a tiny bug in the serve_tiles.py, it checks for the offset being larger than 1 for special case tiles. Both sea and transparent tiles would therefore try and load a tile with an invalid offset. Shouldn't it be greater than 3?


There are no recursive blankness lookups, all blank tiles in a tilesetfile will 
have the blankness set. I plan to maintain a database of completely blank 
tilesets, to save the 6kb files in the pacific ocean etc, but that's not 
implemented yet.

It seems like the oceantiles file is a good start for a database of blank tiles info. I have attached a patch (in case this is useful), that in the case of not finding a tileset, looks up the info in the oceantiles file. For zoom levels 12 and higher, it simply returns the sea/land type specified in the oceantiles file. For lower level files it will check to see if all corresponding z12 tiles are of the same type, in which case it returns that type. Otherwise it returns unknown.


I was wandering what the plans for the transition period are. I have seen that you have a converter script to take the existing tiles and convert them to the one file per tileset. Are you planning on converting all of the files during transition or, will the two types of tiles go side by side? Adding a fall-back to the serve_tiles.py shouldn't be hard in case of gradually transitioning.

Kai


spaetz

P.S. I will try to put all this in the wiki soon

That would be great. A short instruction of how to get all of this running might be good as well.


_______________________________________________
Tilesathome mailing list
[email protected]
http://lists.openstreetmap.org/cgi-bin/mailman/listinfo/tilesathome


diff -r 2f5ca6c6ea8f tah_intern/serve_tiles.py
--- a/tah_intern/serve_tiles.py	Sun Jul 06 11:41:38 2008 +0100
+++ b/tah_intern/serve_tiles.py	Sun Jul 06 14:57:57 2008 +0100
@@ -49,6 +49,45 @@ def serve_tile(layername,z,x,y):
       #return  "(%d,%d,%d) as %d offset1 %d  offset2 %d " % (z,x,y,offset,d_offset,d_offset_next)
     except IOError:
       d_offset = 0
+      #There is no tileset for this tile, check the blank land/sea file instead
+      if z > 5:
+        #Lower zooms than 6 are probably meaning less and require scanning through too much of the z12 tiles
+
+        oceant = open(os.path.join(basetilepath,"oceantiles_12.dat"),'rb')
+        if z > 11:
+          #For z12 and below the file will tell us directly what type it is
+          oceant.seek((4096*base_y + base_x) >> 2)
+          data = ord(oceant.read(1));
+          type = (data & (3 << 2*((4096*base_y + base_x) % 4))) >> 2*((4096*base_y + base_x) % 4)
+          d_offset = type
+          #mark coast line tiles as unknown
+          if type == 3:
+            d_offset = 0;
+        else:
+          #for higher zoom levels, check if all of the containing z12 are of the same type
+          #otherwise return unknown
+          i = x*pow(2,12 - z)
+          j = y*pow(2,12 - z)
+          
+          oceant.seek((4096*j + i) >> 2)
+          data = ord(oceant.read(1));
+          type = (data & (3 << 2*((4096*j + i) % 4))) >> 2*((4096*j + i) % 4)
+          d_offset = type;
+          if type == 3:
+            d_offset = 0;
+          #Check that all other z12 tiles contained within the tile are also of the same type
+          for j in range(y*pow(2,12 - z),(y + 1)*pow(2,12 - z) - 1) :
+            if d_offset == 0:
+              break
+            oceant.seek((4096*j + i) >> 2)
+            data = oceant.read((pow(2,12 - z) >> 2) + 2);
+            templ = (type << 6) + (type << 4) + (type <<2) + type
+            for ii in range(0,pow(2,12 - z) >> 2):
+              if ord(data[ii]) != templ:
+                d_offset = 0;
+                break
+            
+        oceant.close()
     if d_offset > 2:
       f.seek(d_offset)
       data = f.read(d_offset_next-d_offset)
_______________________________________________
Tilesathome mailing list
[email protected]
http://lists.openstreetmap.org/cgi-bin/mailman/listinfo/tilesathome

Reply via email to