Exemple #1
0
def tile_from_ms(mapName,zoom,x,y):
    """ Draw a tile on request using MapServer, store in DB.
    Example:
    >>> t = tile_from_ms('stlhom',0,0,0)
    >>> t.key_name
    't:stlhom:0+0+0'
    >>> import models
    >>> t2 = models.Tile.get_by_key_name(t.key_name)
    >>> t2.key_name == t.key_name
    True
    >>> t2.typ
    'D'
    >>> t2.dat == t.dat
    True
    """
    from dynTileMapper.dtm_wsgi.models import Tile
    tid = 't:%s:%d+%d+%d'%(mapName,zoom,x,y)
    tile = Tile(tid)
    mapfile = os.path.join(MAP_FILE_HOME,mapName,'dtm.map')
    img = StringIO(tiler.Tiler(mapfile).gTileDraw(x,y,zoom))
    typ,dat = optTile(png.PNG(img),False)
    tile.typ = typ
    tile.dat = dat
    tile.put()
    return tile
Exemple #2
0
 def raw_tile(self, x, y, z, border=True):
     left, top, right, bottom = self.gTileBounds(z)
     if not (left <= x and x <= right and top <= y and y <= bottom):
         return "A", "\x00"
     mp = self.map_path
     if mp:
         img = StringIO(Tiler(mp).gTileDraw(x, y, z, border))
         typ, dat = optTile(png.PNG(img), False)
         return typ, dat
     return None, None