def imageMosaic(data_path,udbpath,dtName): flist = SMUP_Image.scanPath("tif",data_path) print "文件总数: ", len(flist) #显示影像文件的拼合后全幅信息 print "Entire Image Dataset Info:", SMUP_Image.calcDatasetInfo(SMUP_Image.getType("tif"),flist) SMUP_Image.Tif2UDB_Mosaic(SMUP_Image.getType("tif"),flist,udbpath,dtName)
def imageMosaic(): strSourcePath = "H:\SRTM\GeoShader01" strOutputPath = "H:\SRTM\UDB" strOutputFileName = "SRTM_GeoShader01" print "Mosaic: ", strSourcePath print "Output: ", strOutputPath,strOutputFileName SMUP_Image.Tif2UDB_Mosaic(SMUP_Image.getType("tif"), listFile(strSourcePath), strOutputPath, strOutputFileName,False)
def dispatchJobs(ch): fileTemplate = r".\\Template\T_Shader.gms" strDataPath = r"H:\SRTM\SRTM_GMG_ALL" strRenderName = r"GeoRender01" strOutputFilePath = MakeDir(r"H:\SRTM",strRenderName) strGMSPath = MakeDir(strOutputFilePath,"GMS") strLogPath = MakeDir(strOutputFilePath,"log") flist = SMUP_Image.scanPathAll(strDataPath) for f in flist: print "" print datetime.now(), "处理文件: ",f strFilePathName = f str_GMSPathFile = buildGMS(fileTemplate,strFilePathName, strGMSPath,strLogPath,strRenderName,strOutputFilePath) job = buildJob(str_GMSPathFile) SMB_Dispatch.send_job(job) print "已经提交: ",job
#生成任务参数 f_GMS= open(str_GMSPathFile,"w") f_GMS.write(strGMS) f_GMS.close() return str_GMSPathFile def runGMS(gmsPathFile): strGMPath = r"H:\GlobalMapper11\global_mapper11.exe" strGMSCMD = strGMPath + " " + gmsPathFile print "运行任务: ",strGMSCMD #os.system(strGMSCMD) subprocess.call(strGMSCMD) #=============================================================== if __name__ == '__main__': fileTemplate = r".\\Template\T_Render.gms" strGMSPath = r"H:\SRTM\GeoShader01\GMS" strLogPath = r"H:\SRTM\GeoShader01\log" strRenderName = r"GeoShader01" strOutputFilePath = r"H:\SRTM\GeoShader01" flist = SMUP_Image.scanPathAll(r"H:\SRTM\SRTM_GMG_ALL") for f in flist: print "" print datetime.now(), "处理文件: ",f strFilePathName = f str_GMSPathFile = buildGMS(fileTemplate,strFilePathName,strGMSPath,strLogPath, strRenderName,strOutputFilePath) runGMS(str_GMSPathFile)
def listFile(data_path): print "Scan Path ",data_path, flist = SMUP_Image.scanPath("tif",data_path) print "文件总数: ", len(flist) return flist
def test_image(): data_path = "H:\ETM\TIF2" flist = SMUP_Image.scanPath("tif",data_path) print flist.count #SMUP_Image.list2File("I:\ETM\FileList.txt",flist) test_image_PixelFormat(flist)
def test_image_FileName(flist): for f in flist: print SMUP_Image.getFileName(f),'\r\n'
def test_image_Info(flist): for f in flist: print SMUP_Image.calcDatasetInfoOne(SMUP_Image.getType("tif"),f),'\r\n'
def test_image_PixelFormat(flist): for f in flist: print SMUP_Image.getPixelFormatOne(SMUP_Image.getType("tif"),f),'\r\n'
# tuple of all parallel python servers to connect with ppservers = () #ppservers = ("127.0.0.1:60000", ) if len(sys.argv) > 1: ncpus = int(sys.argv[1]) job_server = pp.Server(ncpus, ppservers=ppservers) else: job_server = pp.Server(ppservers=ppservers) print "Starting pp with", job_server.get_ncpus(), "workers" #================================================================= #scan path,prepare TaskList. data_path = "H:\ETM\TIF2" #data_path = "I:\ETM\TIF" flist = SMUP_Image.scanPath("tif",data_path) print "Scan Path ",data_path,"Finish." def Task_Call(f): print "Task_Call For: ",f #print SMUP_Image.getPixelFormatOne(SMUP_Image.getType("tif"),f),'\r\n' SMUP_Image.Tif2UDBOne(f,"I:\\ETM\\UDB\\") return True def Task_Func(f): call = Task_Call(f) return call jobs = [] for f in flist: print "Commit Task ",f