def saveGeorefProject(conf,inputs,outputs): import mmsession import mapfile.service as ms mapfile=conf["main"]["dataPath"]+"/georeferencer_maps/project_"+inputs["map"]["value"]+".map" m = mapscript.mapObj(mapfile) conf["senv"]["mmGeoDST"]=m.web.metadata.get("mmGeoDST") conf["senv"]["mmGeoDSO"]=m.web.metadata.get("mmGeoDSO") if inputs.has_key("dso") and inputs["dso"]["value"]=="NULL": inputs["dso"]["value"]=m.getLayer(0).name conf["senv"]["mmGeoMap"]=inputs["dso"]["value"] import shutil ofile=m.getLayer(0).data shutil.copy2(ofile,conf["main"]["tmpPath"]) conf["senv"]["mmGeoImg"]=ofile.split('/')[len(ofile.split('/'))-1] mmsession.save(conf) try: os.mkdir(conf["main"]["dataPath"]+"/georeferencer_maps/"+inputs["dso"]["value"]) except: pass if not(os.path.isfile(conf["main"]["dataPath"]+"/georeferencer_maps/project_"+inputs["dso"]["value"]+".map")) or (inputs.has_key("force") and inputs["force"]["value"]=="true"): try: import glob for name in glob.glob(conf["main"]["dataPath"]+"/georeferencer_maps/"+inputs["map"]["value"]+"/*.csv"): shutil.copy2(name,conf["main"]["dataPath"]+"/georeferencer_maps/"+inputs["dso"]["value"]) except Exception,e: print >> sys.stderr,e pass m.save(conf["main"]["dataPath"]+"/georeferencer_maps/project_"+inputs["dso"]["value"]+".map")
def saveGeoreferencedProject(conf, inputs, outputs): import mmsession import mapfile.service as ms mapfile = inputs["dst"]["value"] + "ds_ows.map" m = mapscript.mapObj(mapfile) ms.removeAllLayers(m, inputs["dso"]["value"]) m.web.metadata.set("mmGeoDST", inputs["dst"]["value"]) conf["senv"]["mmGeoDST"] = inputs["dst"]["value"] m.web.metadata.set("mmGeoDSO", inputs["dso"]["value"]) conf["senv"]["mmGeoDSO"] = inputs["dso"]["value"] conf["senv"]["mmGeoMap"] = inputs["dso"]["value"] import shutil ofile = m.getLayer(0).data shutil.copy2(ofile, conf["main"]["tmpPath"]) conf["senv"]["mmGeoImg"] = ofile.split('/')[len(ofile.split('/')) - 1] if inputs.keys().count("gcpfile") > 0: m.web.metadata.set("mmGeoGCPFile", inputs["gcpfile"]["value"]) conf["senv"]["mmGeoGCPFile"] = inputs["gcpfile"]["value"] if inputs.keys().count("size") > 0: m.web.metadata.set("mmGeoSize", inputs["size"]["value"]) conf["senv"]["mmGeoSize"] = inputs["size"]["value"] mmsession.save(conf) if not (os.path.isfile(conf["main"]["dataPath"] + "/georeferencer_maps/project_" + inputs["dso"]["value"] + ".map")): m.save(conf["main"]["dataPath"] + "/georeferencer_maps/project_" + inputs["dso"]["value"] + ".map") outputs["Result"]["value"] = zoo._("Georeference Project saved") return zoo.SERVICE_SUCCEEDED
def saveGeoreferencedProject(conf,inputs,outputs): import mmsession import mapfile.service as ms mapfile=inputs["dst"]["value"]+"ds_ows.map" m = mapscript.mapObj(mapfile) ms.removeAllLayers(m,inputs["dso"]["value"]) m.web.metadata.set("mmGeoDST",inputs["dst"]["value"]) conf["senv"]["mmGeoDST"]=inputs["dst"]["value"] m.web.metadata.set("mmGeoDSO",inputs["dso"]["value"]) conf["senv"]["mmGeoDSO"]=inputs["dso"]["value"] conf["senv"]["mmGeoMap"]=inputs["dso"]["value"] import shutil ofile=m.getLayer(0).data shutil.copy2(ofile,conf["main"]["tmpPath"]) conf["senv"]["mmGeoImg"]=ofile.split('/')[len(ofile.split('/'))-1] if inputs.keys().count("gcpfile")>0: m.web.metadata.set("mmGeoGCPFile",inputs["gcpfile"]["value"]) conf["senv"]["mmGeoGCPFile"]=inputs["gcpfile"]["value"] mmsession.save(conf) if not(os.path.isfile(conf["main"]["dataPath"]+"/georeferencer_maps/project_"+inputs["dso"]["value"]+".map")): m.save(conf["main"]["dataPath"]+"/georeferencer_maps/project_"+inputs["dso"]["value"]+".map") outputs["Result"]["value"]=zoo._("Georeference Project saved") return zoo.SERVICE_SUCCEEDED
def saveGeorefProject(conf, inputs, outputs): import mmsession import mapfile.service as ms mapfile = conf["main"][ "dataPath"] + "/georeferencer_maps/project_" + inputs["map"][ "value"] + ".map" m = mapscript.mapObj(mapfile) conf["senv"]["mmGeoDST"] = m.web.metadata.get("mmGeoDST") conf["senv"]["mmGeoDSO"] = m.web.metadata.get("mmGeoDSO") if inputs.has_key("dso") and inputs["dso"]["value"] == "NULL": inputs["dso"]["value"] = m.getLayer(0).name conf["senv"]["mmGeoMap"] = inputs["dso"]["value"] import shutil ofile = m.getLayer(0).data shutil.copy2(ofile, conf["main"]["tmpPath"]) conf["senv"]["mmGeoImg"] = ofile.split('/')[len(ofile.split('/')) - 1] mmsession.save(conf) try: os.mkdir(conf["main"]["dataPath"] + "/georeferencer_maps/" + inputs["dso"]["value"]) except: pass if not (os.path.isfile(conf["main"]["dataPath"] + "/georeferencer_maps/project_" + inputs["dso"]["value"] + ".map")) or ( inputs.has_key("force") and inputs["force"]["value"] == "true"): try: import glob for name in glob.glob(conf["main"]["dataPath"] + "/georeferencer_maps/" + inputs["map"]["value"] + "/*.csv"): shutil.copy2( name, conf["main"]["dataPath"] + "/georeferencer_maps/" + inputs["dso"]["value"]) except Exception, e: print >> sys.stderr, e pass m.save(conf["main"]["dataPath"] + "/georeferencer_maps/project_" + inputs["dso"]["value"] + ".map")
print >>sys.stderr, str(e) pass field = "file" if inputs.has_key("filename"): field = inputs["filename"]["value"] print >>sys.stderr, "ok2 " + str(inputs) tmp = inputs[field]["lref"].split("/") print >>sys.stderr, "ok3 " + str(inputs) outFileName = dir + "/" + tmp[len(tmp) - 1] print >>sys.stderr, "ok4 " + str(inputs) shutil.move(inputs[field]["lref"], outFileName) conf["senv"]["last_file"] = outFileName conf["senv"]["last_ufile"] = outFileName import mmsession mmsession.save(conf) print >>sys.stderr, "ok5 " + str(outFileName) outputs["Result"]["value"] = "Your " + tmp[len(tmp) - 1] + " file was uploaded on the server" print >>sys.stderr, "ok6 " + str(inputs) return 3 def saveOnServer0(conf, inputs, outputs): import shutil, json dir = conf["main"]["tmpPath"] + "/data_tmp_1111" + conf["senv"]["MMID"] try: shutil.os.mkdir(dir) except Exception, e: print >>sys.stderr, str(e) pass
try: shutil.os.mkdir(dir) except Exception, e: print >> sys.stderr, str(e) pass field = "file" print >> sys.stderr, inputs if inputs.has_key("filename"): field = inputs["filename"]["value"] tmp = inputs[field]["lref"].split("/") outFileName = dir + "/" + tmp[len(tmp) - 1] shutil.move(inputs[field]["lref"], outFileName) conf["senv"]["last_file"] = outFileName conf["senv"]["last_ufile"] = outFileName import mmsession mmsession.save(conf) res = { "files": [{ "message": zoo._("Your [file] file was uploaded on the server").replace( "\[file\]", tmp[len(tmp) - 1]), "fileName": outFileName }] } outputs["Result"]["value"] = json.dumps(res) return 3 def checkFile(conf, inputs, outputs): import shutil
def setDefaultExtent(conf, inputs, outputs): conf["senv"]["default_extent"] = inputs["bbox"]["value"] import mmsession mmsession.save(conf) outputs["Result"]["value"] = zoo._("Default extent set.") return zoo.SERVICE_SUCCEEDED
def setDefaultExtent(conf,inputs,outputs): conf["senv"]["default_extent"]=inputs["bbox"]["value"] import mmsession mmsession.save(conf) outputs["Result"]["value"]=zoo._("Default extent set.") return zoo.SERVICE_SUCCEEDED