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)
