修改tilecache1.0实现客户端切图

修改tilecache1.0实现客户端切图


发布日期: 2015-07-22 更新日期: 2015-07-22 编辑:bukun 浏览次数: 3676

标签:

摘要: 1.为什么要编写此脚本 由于自带的tilecache_seed.py出现问题,运行就报错误,结合它的Client.py及Service.py和Layer.py的代码,编写了一个简单的脚本,用来实现tilecachae_seed.py的功能 2.脚本代码如下: ...

1.为什么要编写此脚本

由于自带的tilecache_seed.py出现问题,运行就报错误,结合它的Client.py及Service.py和Layer.py的代码,编写了一个简单的脚本,用来实现tilecachae_seed.py的功能

2.脚本代码如下:

!/usr/bin/python

"""
引入服务类
"""

import TileCache.Service
import time,math,sys
"""
从tilecache的layer包引入tile类
"""
from TileCache.Layer import Tile
def main ():

    cfgfile=sys.argv[1]
    layername=sys.argv[2]
    zoom=sys.argv[3]
    zooms=zoom.split(",")
    if len(sys.argv) == 4:
        s=TileCache.Service.load(cfgfile)
        basic=s.layers[layername]
        for z in range(int(zooms[0]),int(zooms[1]),1):
            bottomleft=basic.getClosestCell(z,basic.bbox[0:2])
            topright=basic.getClosestCell(z,basic.bbox[2:4])
            print 'bottomleft='+str(bottomleft)+"\n\ttopright="+str(topright)
            zcount=0
            metaSize=basic.getMetaSize(z)
            ztiles=int(math.ceil(float(topright[1]-bottomleft[1])/metaSize[0])*math.ceil(float(topright[0]-bottomleft[0])/metaSize[1]))
            for y in range(bottomleft[1],topright[1],metaSize[1]):
                for x in range(bottomleft[0],topright[0],metaSize[0]):
                    tileStart=time.time()
                    tile=Tile(basic,x,y,z)
                    s.renderTile(tile)
                    zcount+=1
                    print '\n\tx='+str(x)+'\n\ty='+str(y)+'\n\tz='+str(z)+'run time='+str((time.time()-tileStart))
    else:
        print 'please input arguments examples:\n\tpython client_seed.py /etc/tilecache.cfg basic 5,6\n\tthis is seed 5 to 6 photo!\n\t'

if __name__ == '__main__':
    main()

3.运行此脚本

python client_seed.py /etc/tilecache.cfg basic 5,6

关注公众号
获取免费资源

随机推荐


Copyright © Since 2014. 开源地理空间基金会中文分会 吉ICP备05002032号

Powered by TorCMS

OSGeo 中国中心 邮件列表

问题讨论 : 要订阅或者退订列表,请点击 订阅

发言 : 请写信给: osgeo-china@lists.osgeo.org