Esempio n. 1
0
def heightmap_tiles_near(routes, dist_nm):
    tilesize = 64
    zoomlevel = 8

    tiles_on_levels = dict()

    tottiles = 0
    while zoomlevel >= 0:
        path = os.path.join(os.getenv("SWFP_DATADIR"),
                            "tiles/elev/level%d" % (zoomlevel))
        blob = BlobFile(path, tilesize=tilesize)

        def cm(latlonstr, zoomlevel):
            return clampmerc(
                mapper.latlon2merc(mapper.from_str(latlonstr), zoomlevel))

        resultset = get_all_tiles_near(routes, zoomlevel, dist_nm, tilesize)
        result = dict()
        for merc in resultset:
            result[merc] = blob.get_tile(*merc)
        tottiles += len(result)
        tiles_on_levels[zoomlevel] = result

        zoomlevel -= 1

    return tiles_on_levels
Esempio n. 2
0
def map_tiles_near(routes, dist_nm):
    tilesize = 256
    zoomlevel = 7

    tiles_on_levels = dict()

    tottiles = 0

    path = os.path.join(os.getenv("SWFP_DATADIR"),
                        "tiles/elev/level%d" % (zoomlevel))
    blob = BlobFile(path, tilesize=tilesize)

    def cm(latlonstr, zoomlevel):
        return clampmerc(
            mapper.latlon2merc(mapper.from_str(latlonstr), zoomlevel))

    resultset = get_all_tiles_near(routes, zoomlevel, dist_nm, tilesize)
    result = dict()
    for merc in resultset:
        rawtile = blob.get_tile(*merc)
        io = StringIO.StringIO(rawtile)
        io.seek(0)
        im = Image.open(io)
        x, y = merc
        print "Map merc ", merc
        x %= 512
        y %= 512
        if x >= 256:
            im = im.transpose(Image.FLIP_LEFT_RIGHT)
            print "X-flipping"
        else:
            print "Not X-flipping"
        if y >= 256:
            im = im.transpose(Image.FLIP_TOP_BOTTOM)
            print "Y-flippin'"
        else:
            print "Not Y-flippin'"
        buf = StringIO.StringIO()
        im.save(buf, "png")
        png = buf.getvalue()
        result[merc] = png
    tottiles += len(result)
    tiles_on_levels[zoomlevel] = result

    return tiles_on_levels
Esempio n. 3
0
def map_tiles_near(routes,dist_nm):
    tilesize=256
    zoomlevel=7

    tiles_on_levels=dict()

    tottiles=0

    path=os.path.join(os.getenv("SWFP_DATADIR"),"tiles/elev/level%d"%(zoomlevel))
    blob=BlobFile(path,tilesize=tilesize)
    def cm(latlonstr,zoomlevel):
        return clampmerc(mapper.latlon2merc(mapper.from_str(latlonstr),zoomlevel))
            
    resultset=get_all_tiles_near(routes,zoomlevel,dist_nm,tilesize)
    result=dict()
    for merc in resultset:
        rawtile=blob.get_tile(*merc)
        io=StringIO.StringIO(rawtile)
        io.seek(0)
        im=Image.open(io)
        x,y=merc
        print "Map merc ",merc        
        x%=512
        y%=512
        if x>=256:
            im=im.transpose(Image.FLIP_LEFT_RIGHT)
            print "X-flipping"
        else:
            print "Not X-flipping"
        if y>=256:
            im=im.transpose(Image.FLIP_TOP_BOTTOM)
            print "Y-flippin'"
        else:
            print "Not Y-flippin'"
        buf=StringIO.StringIO()
        im.save(buf,"png")
        png=buf.getvalue()
        result[merc]=png
    tottiles+=len(result)
    tiles_on_levels[zoomlevel]=result

    return tiles_on_levels
def heightmap_tiles_near(routes,dist_nm):
    tilesize=64
    zoomlevel=8

    tiles_on_levels=dict()

    tottiles=0
    while zoomlevel>=0:       
        path=os.path.join(os.getenv("SWFP_DATADIR"),"tiles/elev/level%d"%(zoomlevel))
        blob=BlobFile(path,tilesize=tilesize)
        def cm(latlonstr,zoomlevel):
            return clampmerc(mapper.latlon2merc(mapper.from_str(latlonstr),zoomlevel))
                
        resultset=get_all_tiles_near(routes,zoomlevel,dist_nm,tilesize)
        result=dict()
        for merc in resultset:
            result[merc]=blob.get_tile(*merc)
        tottiles+=len(result)
        tiles_on_levels[zoomlevel]=result
        
        zoomlevel-=1


    return tiles_on_levels