#--*--coding:utf-8--*--
#使用说明:
#只需要调用下面的autoPush这个函数,修改里面的两个参数
#参数说明:geoserverWorkeName为geoserver工作空间名称,fileName为tif存放文件夹名称
import os
def autoPush(geoserverWorkeName,fileName):
namespace = geoserverWorkeName
# 要发布的文件夹名称
train_path = fileName
# 遍历文件夹中为.tif后缀的文件,获取其路径
tif_list = [os.path.join(train_path, i) for i in os.listdir(train_path) if i.endswith('.tif')]
for onetif in tif_list:
fpname=onetif
fname = os.path.split(fpname)[-1] #获取每个tif的名字
# os.system('curl -v -u admin:geoserver -XPOST -H "Content-type: text/xml" -d "<workspace><name>'+namespace+'</name></workspace>" http://localhost:8080/geoserver/rest/workspaces')
# 发布tif
os.system('curl -u admin:geoserver -XPUT -H "Content-type:image/tiff" --data-binary @'+fpname+' http://localhost:8080/geoserver/rest/workspaces/'+namespace+'/coveragestores/'+fname+'/file.geotiff')
# url = 'http://localhost:8080/geoserver/'+namespace+'/wms?service=WMS&version=1.1.0&request=GetMap&layers='+namespace+':'+fname+'&styles=&bbox=395085.0,5292585.0,630615.0,5531415.0&width=757&height=768&srs=EPSG:32653&format=application/openlayers'
autoPush("miningtest",r'E:\tifTest\initData\DEM')
版权声明:本文为weixin_43049347原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。