diff --git a/Epa2GIS.py b/Epa2GIS.py index be92621..9b73317 100644 --- a/Epa2GIS.py +++ b/Epa2GIS.py @@ -1,32 +1,38 @@ -#(C)Marios Kyriakou 2016 -#University of Cyprus, KIOS Research Center for Intelligent Systems and Networks +# (C) Marios Kyriakou 2016 +# University of Cyprus, KIOS Research Center for Intelligent Systems and Networks import readEpanetFile as d -from qgis.core import QgsFeature,QgsVectorLayer,QgsVectorFileWriter,QgsField,QgsPoint,QgsGeometry -import qgis.utils, os +from qgis.core import QgsFeature, QgsVectorLayer, QgsVectorFileWriter, QgsField, QgsPoint, QgsGeometry, \ + QgsMapLayerRegistry, QgsLayerTreeLayer, QgsProject, QgsCoordinateReferenceSystem from PyQt4.QtGui import QProgressBar from qgis.gui import QgsMessageBar from PyQt4.QtCore import QVariant import collections import numpy as np +import qgis.utils +import os + +# noinspection SpellCheckingInspection def epa2gis(inpname): + plugin_path = os.path.dirname(__file__) file_extension = os.path.dirname(inpname) inpname = os.path.basename(inpname) - inp = file_extension + '/'+ inpname - if len(file_extension)==0: + inp = file_extension + '/' + inpname + if len(file_extension) == 0: inp = inpname newpath = file_extension + '/_shapefiles_' if not os.path.exists(newpath): os.makedirs(newpath) - iface=qgis.utils.iface + iface = qgis.utils.iface d.LoadFile(inp) d.BinUpdateClass() - nlinkCount=d.getBinLinkCount() + nlinkCount = d.getBinLinkCount() + res = newpath + '\\' - saveFile=res+inpname[:len(inpname)-4] + saveFile = res + inpname[:len(inpname) - 4] - #Get all Sections + # Get all Sections mixing = d.getMixingSection() reactions = d.getReactionsSection() sources = d.getSourcesSection() @@ -44,23 +50,27 @@ def epa2gis(inpname): report = d.getReportSection() options = d.getOptionsSection() - #Get all Section lengths - allSections=[len(energy),len(optReactions),len(demands),len(status),len(emitters),len(controls),len(patterns), - len(curves[0]),len(quality),len(rules),len(sources),len(reactions),len(mixing),len(times),len(report), - len(options),d.getBinNodeCount(),d.getBinLinkCount()] - ss=max(allSections) - idx = iface.legendInterface().addGroup(inpname[:len(inpname)-4]) - xy=d.getBinNodeCoordinates() - x=xy[0] - y=xy[1] - vertx=xy[2] - verty=xy[3] - vertxyFinal=[] + # Get all Section lengths + allSections = [len(energy), len(optReactions), len(demands), len(status), len(emitters), len(controls), + len(patterns), + len(curves[0]), len(quality), len(rules), len(sources), len(reactions), len(mixing), len(times), + len(report), + len(options), d.getBinNodeCount(), d.getBinLinkCount()] + ss = max(allSections) + root = QgsProject.instance().layerTreeRoot() + idx = root.insertGroup(0, inpname[:len(inpname) - 4]) + + xy = d.getBinNodeCoordinates() + x = xy[0] + y = xy[1] + vertx = xy[2] + verty = xy[3] + vertxyFinal = [] for i in range(len(vertx)): - vertxy=[] + vertxy = [] for u in range(len(vertx[i])): - vertxy.append([float(vertx[i][u]),float(verty[i][u])]) - if vertxy!=[]: + vertxy.append([float(vertx[i][u]), float(verty[i][u])]) + if vertxy: vertxyFinal.append(vertxy) otherDemads = d.getBinNodeBaseDemandsDemSection() @@ -72,6 +82,7 @@ def epa2gis(inpname): for i, p in enumerate(otherDemads[1]): otherDemadsIndex.append(ndID.index(p)) otherDemadsPatterns.append(otherDemads[2][i]) + counter = collections.Counter(otherDemadsIndex) maxCategories = 1 if counter: @@ -80,20 +91,20 @@ def epa2gis(inpname): if not ndBaseD: ndBaseD = otherDemads[0] - #Get data of Junctions - if d.getBinNodeJunctionCount()>0: + # Get data of Junctions + if d.getBinNodeJunctionCount() > 0: ndBaseTmp = np.empty((len(ndBaseD), maxCategories,)) ndPatTmp = [] - for t in range(0,maxCategories): - for u in range(0,len(ndBaseD)): + for t in range(0, maxCategories): + for u in range(0, len(ndBaseD)): ndBaseTmp[u][t] = 0 - ndPatTmp.append(['None']*2) + ndPatTmp.append(['None'] * 2) - for uu in range(0,len(ndBaseD)): + for uu in range(0, len(ndBaseD)): if d.getBinNodeBaseDemands(): ndBaseTmp[uu][0] = ndBaseD[uu] ndPatTmp[uu][0] = ndPatID[uu] - t=0 + t = 0 for i, p in enumerate(otherDemadsIndex): if d.getBinNodeBaseDemands(): ndBaseTmp[p][t] = ndBaseD[otherDemadsIndex[i]] @@ -101,588 +112,556 @@ def epa2gis(inpname): else: ndBaseTmp[p][t] = otherDemads[0][i] ndPatTmp[p][t] = otherDemads[2][i] - - t=t+1 - if t>max(counter.values())-1: - t=max(counter.values())-1 - if i>0: - if otherDemadsIndex[i-1]==p: - ndBaseTmp[p][t] = otherDemads[0][i] - ndPatTmp[p][t] = otherDemads[2][i] - t = t - 1 + t = t + 1 + if t > max(counter.values()) - 1: + t = max(counter.values()) - 1 + if i > 0: + if otherDemadsIndex[i - 1] == p: + ndBaseTmp[p][t] = otherDemads[0][i] + ndPatTmp[p][t] = otherDemads[2][i] + t = t - 1 # Write Junction Shapefile - fields=["ID","Elevation"]#,"pattern","demand"] - fieldsCode=[0,1] - for u in range(0,maxCategories): - fields.append('Demand' + str(u+1)); fields.append('Pattern' + str(u+1)) - fieldsCode.append(1); fieldsCode.append(0) + fields = ["ID", "Elevation"] # , "pattern", "demand"] + fieldsCode = [0, 1] + for u in range(0, maxCategories): + fields.append('Demand' + str(u + 1)) + fields.append('Pattern' + str(u + 1)) + fieldsCode.append(1) + fieldsCode.append(0) posJunction = QgsVectorLayer("point", "Junctions", "memory") prJunction = posJunction.dataProvider() ndBaseTmp = ndBaseTmp.tolist() - createColumnsAttrb(prJunction,fields,fieldsCode) + createColumnsAttrb(prJunction, fields, fieldsCode) posJunction.startEditing() - ndEle=d.getBinNodeJunctionElevations() + ndEle = d.getBinNodeJunctionElevations() - #Get data of Pipes - #Write shapefile pipe - if nlinkCount>0: + # Get data of Pipes + # Write shapefile pipe + if nlinkCount > 0: posPipe = QgsVectorLayer("LineString", "Pipes", "memory") prPipe = posPipe.dataProvider() - fields=["ID","NodeFrom","NodeTo","Status","Length","Diameter","Roughness","MinorLoss"] - fieldsCode=[0,0,0,0,1,1,1,1] - createColumnsAttrb(prPipe,fields,fieldsCode) + fields = ["ID", "NodeFrom", "NodeTo", "Status", "Length", "Diameter", "Roughness", "MinorLoss"] + fieldsCode = [0, 0, 0, 0, 1, 1, 1, 1] + createColumnsAttrb(prPipe, fields, fieldsCode) posPipe.startEditing() pIndex = d.getBinLinkPumpIndex() vIndex = d.getBinLinkValveIndex() - ndlConn=d.getBinNodesConnectingLinksID() - x1=[];x2=[];y1=[];y2=[] - stat=d.getBinLinkInitialStatus() - - kk=0; ch=0 - linkID=d.getBinLinkNameID() - linkLengths=d.getBinLinkLength() - linkDiameters=d.getBinLinkDiameter() - linkRough=d.getBinLinkRoughnessCoeff() - linkMinorloss=d.getBinLinkMinorLossCoeff() + ndlConn = d.getBinNodesConnectingLinksID() + x1 = [] + x2 = [] + y1 = [] + y2 = [] + stat = d.getBinLinkInitialStatus() + + kk = 0 + ch = 0 + linkID = d.getBinLinkNameID() + linkLengths = d.getBinLinkLength() + linkDiameters = d.getBinLinkDiameter() + linkRough = d.getBinLinkRoughnessCoeff() + linkMinorloss = d.getBinLinkMinorLossCoeff() # Write Tank Shapefile and get tank data - if d.getBinNodeTankCount()>0: - posTank = QgsVectorLayer("point", "Reservoirs", "memory") - prTank = posTank.dataProvider() - fields=["ID","Elevation","InitLevel","MinLevel","MaxLevel","Diameter","MinVolume","VolumeCurve"] - fieldsCode=[0,1,1,1,1,1,1,1] - createColumnsAttrb(prTank,fields,fieldsCode) - posTank.startEditing() - - ndTankelevation=d.getBinNodeTankElevations() - initiallev=d.getBinNodeTankInitialLevel() - minimumlev=d.getBinNodeTankMinimumWaterLevel() - maximumlev=d.getBinNodeTankMaximumWaterLevel() - diameter=d.getBinNodeTankDiameter() - minimumvol=d.getBinNodeTankMinimumWaterVolume() - volumecurv=d.getBinNodeTankVolumeCurveID() - ndTankID=d.getBinNodeTankNameID() + posTank = QgsVectorLayer("point", "Reservoirs", "memory") + prTank = posTank.dataProvider() + fields = ["ID", "Elevation", "InitLevel", "MinLevel", "MaxLevel", "Diameter", "MinVolume", "VolumeCurve"] + fieldsCode = [0, 1, 1, 1, 1, 1, 1, 0] + createColumnsAttrb(prTank, fields, fieldsCode) + posTank.startEditing() + + if d.getBinNodeTankCount() > 0: + ndTankelevation = d.getBinNodeTankElevations() + initiallev = d.getBinNodeTankInitialLevel() + minimumlev = d.getBinNodeTankMinimumWaterLevel() + maximumlev = d.getBinNodeTankMaximumWaterLevel() + diameter = d.getBinNodeTankDiameter() + minimumvol = d.getBinNodeTankMinimumWaterVolume() + volumecurv = d.getBinNodeTankVolumeCurveID() + ndTankID = d.getBinNodeTankNameID() # Write Reservoir Shapefile - if d.getBinNodeReservoirCount()>0: - posReservoirs = QgsVectorLayer("point", "Reservoirs", "memory") - prReservoirs = posReservoirs.dataProvider() - fields=["ID","Head"] - fieldsCode=[0,1] - createColumnsAttrb(prReservoirs,fields,fieldsCode) - head=d.getBinNodeReservoirElevations() - posReservoirs.startEditing() - if times!=[]: + posReservoirs = QgsVectorLayer("point", "Reservoirs", "memory") + prReservoirs = posReservoirs.dataProvider() + fields = ["ID", "Head"] + fieldsCode = [0, 1] + createColumnsAttrb(prReservoirs, fields, fieldsCode) + head = d.getBinNodeReservoirElevations() + posReservoirs.startEditing() + + if times: posTimes = QgsVectorLayer("point", "Times", "memory") prTimes = posTimes.dataProvider() - if energy!=[]: + if energy: posE = QgsVectorLayer("point", "Energy", "memory") prE = posE.dataProvider() - if report!=[]: + if report: posRep = QgsVectorLayer("point", "Report", "memory") prRep = posRep.dataProvider() - if options!=[]: + if options: posOpt = QgsVectorLayer("point", "Options", "memory") prOpt = posOpt.dataProvider() - if optReactions!=[]: + if optReactions: posO = QgsVectorLayer("point", "Reactions", "memory") prO = posO.dataProvider() - ppE=[];ppO=[];ppTimes=[];ppRep=[];ppOpt=[] - ppMix=[];ppReactions=[];ppSourc=[];ppRul=[];ppPat=[] - ppQual=[];ppDem=[];ppStat=[];ppEmit=[];ppCont=[];ppCurv=[] - vvLink=68 + ppE = [] + ppO = [] + ppTimes = [] + ppRep = [] + ppOpt = [] + ppMix = [] + ppReactions = [] + ppSourc = [] + ppRul = [] + ppPat = [] + ppQual = [] + ppDem = [] + ppStat = [] + ppEmit = [] + ppCont = [] + ppCurv = [] for i in range(ss): - if i==ss/vvLink and vvLink>-1: - vvLink=vvLink-1 - - if i2: - ppSourc.append([sources[i][0],sources[i][1],sources[i][2]]) - if i2: - ppRul.append([rules[i][0][1][1],rules[i][1][0]+rules[i][2][0]+rules[i][3][0]]) - if i 2: + ppRul.append([rules[i][0][1][1], rules[i][1][0] + rules[i][2][0] + rules[i][3][0]]) + if i < allSections[8]: + ppQual.append([quality[i][0], quality[i][1]]) + if i < allSections[7]: + ppCurv.append([str(curves[0][i][0]), str(curves[0][i][1]), str(curves[0][i][2]), str(curves[1][i])]) + if i < allSections[6]: + ppPat.append([patterns[i][0], str(patterns[i][1])]) + if i < allSections[5]: ppCont.append([controls[i]]) - if i2: - ppDem.append([demands[i][0],demands[i][1],demands[i][2]]) - if i 2: + ppDem.append([demands[i][0], demands[i][1], demands[i][2]]) + if i < allSections[0]: mm = energy[i][0] - if mm.upper()=="GLOBAL": - prE.addAttributes( [ QgsField("Global"+energy[i][1], QVariant.String) ] ) - if len(energy[i])>2: + if mm.upper() == "GLOBAL": + prE.addAttributes([QgsField("Global" + energy[i][1], QVariant.String)]) + if len(energy[i]) > 2: ppE.append(energy[i][2]) else: ppE.append('') - if mm.upper()=="PUMP": - prE.addAttributes( [ QgsField("Pump", QVariant.String) ] ) - if len(energy[i])>2: - ppE.append(energy[i][1]+' '+energy[i][2]) + if mm.upper() == "PUMP": + prE.addAttributes([QgsField("Pump", QVariant.String)]) + if len(energy[i]) > 2: + ppE.append(energy[i][1] + ' ' + energy[i][2]) else: ppE.append(energy[i][1]) - elif mm.upper()=="DEMAND": - if energy[i][1].upper()=="CHARGE": - prE.addAttributes( [ QgsField("DemCharge", QVariant.String) ] ) - if len(energy[i])>2: + elif mm.upper() == "DEMAND": + if energy[i][1].upper() == "CHARGE": + prE.addAttributes([QgsField("DemCharge", QVariant.String)]) + if len(energy[i]) > 2: ppE.append(energy[i][2]) - if i2: + if mm.upper() == "ORDER": + prO.addAttributes([QgsField("Order" + optReactions[i][1], QVariant.String)]) + if len(optReactions[i]) > 2: ppO.append(optReactions[i][2]) else: ppO.append('') - elif mm.upper()=="GLOBAL": - prO.addAttributes( [ QgsField("Global"+optReactions[i][1], QVariant.String) ] ) - if len(optReactions[i])>2: + elif mm.upper() == "GLOBAL": + prO.addAttributes([QgsField("Global" + optReactions[i][1], QVariant.String)]) + if len(optReactions[i]) > 2: ppO.append(optReactions[i][2]) else: ppO.append('') - elif mm.upper()=="BULK": - prO.addAttributes( [ QgsField("Bulk", QVariant.String) ] ) - if len(optReactions[i])>2: - ppO.append(optReactions[i][1]+' '+optReactions[i][2]) + elif mm.upper() == "BULK": + prO.addAttributes([QgsField("Bulk", QVariant.String)]) + if len(optReactions[i]) > 2: + ppO.append(optReactions[i][1] + ' ' + optReactions[i][2]) else: ppO.append(optReactions[i][1]) - elif mm.upper()=="WALL": - prO.addAttributes( [ QgsField("Wall", QVariant.String) ] ) - if len(optReactions[i])>2: - ppO.append(optReactions[i][1]+' '+optReactions[i][2]) + elif mm.upper() == "WALL": + prO.addAttributes([QgsField("Wall", QVariant.String)]) + if len(optReactions[i]) > 2: + ppO.append(optReactions[i][1] + ' ' + optReactions[i][2]) else: ppO.append(optReactions[i][1]) - elif mm.upper()=="TANK": - prO.addAttributes( [ QgsField("Tank", QVariant.String) ] ) - if len(optReactions[i])>2: - ppO.append(optReactions[i][1]+' '+optReactions[i][2]) + elif mm.upper() == "TANK": + prO.addAttributes([QgsField("Tank", QVariant.String)]) + if len(optReactions[i]) > 2: + ppO.append(optReactions[i][1] + ' ' + optReactions[i][2]) else: ppO.append(optReactions[i][1]) - elif mm.upper()=="LIMITING": - if optReactions[i][1].upper()=="POTENTIAL": - prO.addAttributes( [ QgsField("LimPotent", QVariant.String) ] ) - if len(optReactions[i])>2: + elif mm.upper() == "LIMITING": + if optReactions[i][1].upper() == "POTENTIAL": + prO.addAttributes([QgsField("LimPotent", QVariant.String)]) + if len(optReactions[i]) > 2: ppO.append(optReactions[i][2]) - elif mm.upper()=="ROUGHNESS": - if optReactions[i][1].upper()=="CORRELATION": - prO.addAttributes( [ QgsField("RoughCorr", QVariant.String) ] ) - if len(optReactions[i])>2: + elif mm.upper() == "ROUGHNESS": + if optReactions[i][1].upper() == "CORRELATION": + prO.addAttributes([QgsField("RoughCorr", QVariant.String)]) + if len(optReactions[i]) > 2: ppO.append(optReactions[i][2]) - if i3: - ppTimes.append(times[i][2]+' '+times[i][3]) + elif mm.upper() == "START": + if times[i][1].upper() == "CLOCKTIME": + prTimes.addAttributes([QgsField("StartClock", QVariant.String)]) + if len(times[i]) > 3: + ppTimes.append(times[i][2] + ' ' + times[i][3]) else: ppTimes.append(times[i][2]) - elif mm.upper()=="STATISTIC": - prTimes.addAttributes( [ QgsField("Statistic", QVariant.String) ] ) - if times[i][1].upper()=='NONE' or times[i][1].upper()=='AVERAGE' or times[i][1].upper()=='MINIMUM' or times[i][1].upper()=='MAXIMUM' or times[i][1].upper()=='RANGE': + elif mm.upper() == "STATISTIC": + prTimes.addAttributes([QgsField("Statistic", QVariant.String)]) + if times[i][1].upper() == 'NONE' or times[i][1].upper() == 'AVERAGE' or times[i][1].upper() \ + == 'MINIMUM' or times[i][1].upper() == 'MAXIMUM' or times[i][1].upper() == 'RANGE': ppTimes.append(times[i][1]) - if i2: - ppRep.append(report[i][1]+' '+report[i][2]) + elif mm.upper() == "NODES": + prRep.addAttributes([QgsField("Nodes", QVariant.String)]) + if len(report[i]) > 2: + ppRep.append(report[i][1] + ' ' + report[i][2]) else: ppRep.append(report[i][1]) - elif mm.upper()=="LINKS": - prRep.addAttributes( [ QgsField("Links", QVariant.String) ] ) - if len(report[i])>2: - ppRep.append(report[i][1]+' '+report[i][2]) + elif mm.upper() == "LINKS": + prRep.addAttributes([QgsField("Links", QVariant.String)]) + if len(report[i]) > 2: + ppRep.append(report[i][1] + ' ' + report[i][2]) else: ppRep.append(report[i][1]) else: - prRep.addAttributes( [ QgsField(mm, QVariant.String) ] ) - if len(report[i])>2: - ppRep.append(report[i][1]+' '+report[i][2]) + prRep.addAttributes([QgsField(mm, QVariant.String)]) + if len(report[i]) > 2: + ppRep.append(report[i][1] + ' ' + report[i][2]) else: ppRep.append(report[i][1]) - if i2: - ppOpt.append(options[i][1]+' '+options[i][2]) + if mm.upper() == "HYDRAULICS": + prOpt.addAttributes([QgsField("Hydraulics", QVariant.String)]) + if len(options[i]) > 2: + ppOpt.append(options[i][1] + ' ' + options[i][2]) else: ppOpt.append(options[i][1]) - elif mm.upper()=="QUALITY": - prOpt.addAttributes( [ QgsField("Quality", QVariant.String) ] ) - if len(options[i])>2: - ppOpt.append(options[i][1]+' '+options[i][2]) - elif len(options[i])>3: - ppOpt.append(options[i][1]+' '+options[i][2]+' '+options[i][3]) + elif mm.upper() == "QUALITY": + prOpt.addAttributes([QgsField("Quality", QVariant.String)]) + if len(options[i]) > 2: + ppOpt.append(options[i][1] + ' ' + options[i][2]) + elif len(options[i]) > 3: + ppOpt.append(options[i][1] + ' ' + options[i][2] + ' ' + options[i][3]) else: ppOpt.append(options[i][1]) - elif mm.upper()=="VISCOSITY": - prOpt.addAttributes( [ QgsField("Viscosity", QVariant.String) ] ) + elif mm.upper() == "VISCOSITY": + prOpt.addAttributes([QgsField("Viscosity", QVariant.String)]) ppOpt.append(options[i][1]) - elif mm.upper()=="DIFFUSIVITY": - prOpt.addAttributes( [ QgsField("Diffusivity", QVariant.String) ] ) + elif mm.upper() == "DIFFUSIVITY": + prOpt.addAttributes([QgsField("Diffusivity", QVariant.String)]) ppOpt.append(options[i][1]) - elif mm.upper()=="SPECIFIC": - if options[i][1].upper()=="GRAVITY": - prOpt.addAttributes( [ QgsField("SpecGrav", QVariant.String) ] ) + elif mm.upper() == "SPECIFIC": + if options[i][1].upper() == "GRAVITY": + prOpt.addAttributes([QgsField("SpecGrav", QVariant.String)]) ppOpt.append(options[i][2]) - elif mm.upper()=="TRIALS": - prOpt.addAttributes( [ QgsField("Trials", QVariant.String) ] ) + elif mm.upper() == "TRIALS": + prOpt.addAttributes([QgsField("Trials", QVariant.String)]) ppOpt.append(options[i][1]) - elif mm.upper()=="HEADLOSS": - prOpt.addAttributes( [ QgsField("Headloss", QVariant.String) ] ) + elif mm.upper() == "HEADLOSS": + prOpt.addAttributes([QgsField("Headloss", QVariant.String)]) ppOpt.append(options[i][1]) - elif mm.upper()=="ACCURACY": - prOpt.addAttributes( [ QgsField("Accuracy", QVariant.String) ] ) + elif mm.upper() == "ACCURACY": + prOpt.addAttributes([QgsField("Accuracy", QVariant.String)]) ppOpt.append(options[i][1]) - elif mm.upper()=="UNBALANCED": - prOpt.addAttributes( [ QgsField("Unbalanced", QVariant.String) ] ) - if len(options[i])>2: - ppOpt.append(options[i][1]+' '+options[i][2]) + elif mm.upper() == "UNBALANCED": + prOpt.addAttributes([QgsField("Unbalanced", QVariant.String)]) + if len(options[i]) > 2: + ppOpt.append(options[i][1] + ' ' + options[i][2]) else: ppOpt.append(options[i][1]) - elif mm.upper()=="PATTERN": - prOpt.addAttributes( [ QgsField("PatID", QVariant.String) ] ) + elif mm.upper() == "PATTERN": + prOpt.addAttributes([QgsField("PatID", QVariant.String)]) ppOpt.append(options[i][1]) - elif mm.upper()=="TOLERANCE": - prOpt.addAttributes( [ QgsField("Tolerance", QVariant.String) ] ) + elif mm.upper() == "TOLERANCE": + prOpt.addAttributes([QgsField("Tolerance", QVariant.String)]) ppOpt.append(options[i][1]) - elif mm.upper()=="MAP": - prOpt.addAttributes( [ QgsField("Map", QVariant.String) ] ) + elif mm.upper() == "MAP": + prOpt.addAttributes([QgsField("Map", QVariant.String)]) ppOpt.append(options[i][1]) - elif mm.upper()=="DEMAND": - if options[i][1].upper()=="MULTIPLIER": - prOpt.addAttributes( [ QgsField("DemMult", QVariant.String) ] ) + elif mm.upper() == "DEMAND": + if options[i][1].upper() == "MULTIPLIER": + prOpt.addAttributes([QgsField("DemMult", QVariant.String)]) ppOpt.append(options[i][2]) - elif mm.upper()=="EMITTER": - if options[i][1].upper()=="EXPONENT": - prOpt.addAttributes( [ QgsField("EmitExp", QVariant.String) ] ) + elif mm.upper() == "EMITTER": + if options[i][1].upper() == "EXPONENT": + prOpt.addAttributes([QgsField("EmitExp", QVariant.String)]) ppOpt.append(options[i][2]) - elif mm.upper()=="CHECKFREQ": - prOpt.addAttributes( [ QgsField("CheckFreq", QVariant.String) ] ) + elif mm.upper() == "CHECKFREQ": + prOpt.addAttributes([QgsField("CheckFreq", QVariant.String)]) ppOpt.append(options[i][1]) - elif mm.upper()=="MAXCHECK": - prOpt.addAttributes( [ QgsField("MaxCheck", QVariant.String) ] ) + elif mm.upper() == "MAXCHECK": + prOpt.addAttributes([QgsField("MaxCheck", QVariant.String)]) ppOpt.append(options[i][1]) - elif mm.upper()=="DAMPLIMIT": - prOpt.addAttributes( [ QgsField("DampLimit", QVariant.String) ] ) + elif mm.upper() == "DAMPLIMIT": + prOpt.addAttributes([QgsField("DampLimit", QVariant.String)]) ppOpt.append(options[i][1]) - if options!=[]: - writeDBF(posOpt,[ppOpt],prOpt,saveFile,inpname, "_OPTIONS", iface,idx) - - if report!=[]: - writeDBF(posRep,[ppRep],prRep,saveFile,inpname, "_REPORT", iface,idx) - - if times!=[]: - writeDBF(posTimes,[ppTimes],prTimes,saveFile,inpname, "_TIMES", iface,idx) - - if energy!=[]: - writeDBF(posE,[ppE],prE,saveFile,inpname, "_ENERGY", iface,idx) - - if optReactions!=[]: - writeDBF(posO,[ppO],prO,saveFile,inpname, "_REACTIONS", iface,idx) - - if mixing!=[]: - posMix = QgsVectorLayer("point", "Mixing", "memory") - prMix = posMix.dataProvider() - fields=["Tank_ID","Model","Fraction"] - fieldsCode=[0,0,1] #0 String, 1 Double - createColumnsAttrb(prMix,fields,fieldsCode) - writeDBF(posMix,ppMix,prMix,saveFile,inpname, "_MIXING", iface,idx) - - if reactions!=[]: - posReact = QgsVectorLayer("point", "ReactionsInfo", "memory") - prReact = posReact.dataProvider() - fields=["Type","Pipe/Tank","Coeff."]; fieldsCode=[0,0,1] - createColumnsAttrb(prReact,fields,fieldsCode) - writeDBF(posReact,ppReactions,prReact,saveFile,inpname, "_REACTIONSinfo", iface,idx) - - if sources!=[]: - posSourc = QgsVectorLayer("point", "Sources", "memory") - prSourc = posSourc.dataProvider() - fields=["Node_ID","Type","Strength","Pattern"]; fieldsCode=[0,0,1,0] - createColumnsAttrb(prSourc,fields,fieldsCode) - writeDBF(posSourc,ppSourc,prSourc,saveFile,inpname, "_SOURCES", iface,idx) - - if rules!=[] and len(rules[0])>3: - posRul = QgsVectorLayer("point", "Rules", "memory") - prRul = posRul.dataProvider() - fields=["Rule_ID","Rule"]; fieldsCode=[0,0] - createColumnsAttrb(prRul,fields,fieldsCode) - writeDBF(posRul,ppRul,prRul,saveFile,inpname, "_RULES", iface,idx) - - if ppQual!=[]: - posQual = QgsVectorLayer("point", "Sources", "memory") - prQual = posQual.dataProvider() - fields=["Node_ID","Init_Qual"]; fieldsCode=[0,1] - createColumnsAttrb(prQual,fields,fieldsCode) - writeDBF(posQual,ppQual,prQual,saveFile,inpname, "_QUALITY", iface,idx) - - # if demands!=[]: - # posDem = QgsVectorLayer("point", "Demands", "memory") - # prDem = posDem.dataProvider() - # fields=["ID","Demand","Pattern"]; fieldsCode=[0,1,0] - # createColumnsAttrb(prDem,fields,fieldsCode) - # writeDBF(posDem,ppDem,prDem,saveFile,inpname, "_DEMANDS", iface,idx) - - if status!=[]: - posStat = QgsVectorLayer("point", "Status", "memory") - prStat = posStat.dataProvider() - fields=["Link_ID","Status/Setting"]; fieldsCode=[0,0] - createColumnsAttrb(prStat,fields,fieldsCode) - writeDBF(posStat,ppStat,prStat,saveFile,inpname, "_STATUS", iface,idx) - - if emitters!=[]: - posEmit = QgsVectorLayer("point", "Emitters", "memory") - prEmit = posEmit.dataProvider() - fields=["Junc_ID","Coeff."]; fieldsCode=[0,1] - createColumnsAttrb(prEmit,fields,fieldsCode) - writeDBF(posEmit,ppEmit,prEmit,saveFile,inpname, "_EMITTERS", iface,idx) - - if controls!=[]: - posCont = QgsVectorLayer("point", "Controls", "memory") - prCont = posCont.dataProvider() - fields=["Controls"]; fieldsCode=[0] - createColumnsAttrb(prCont,fields,fieldsCode) - writeDBF(posCont,ppCont,prCont,saveFile,inpname, "_CONTROLS", iface,idx) - - if patterns!=[]: - posPat = QgsVectorLayer("point", "Patterns", "memory") - prPat = posPat.dataProvider() - fields=["Pattern_ID","Multipliers"]; fieldsCode=[0,0] - createColumnsAttrb(prPat,fields,fieldsCode) - writeDBF(posPat,ppPat,prPat,saveFile,inpname, "_PATTERNS", iface,idx) - - if curves[0]!=[]: - posCurv = QgsVectorLayer("point", "Curves", "memory") - prCurv = posCurv.dataProvider() - fields=["Curve_ID","X-Value","Y-Value","Type"]; fieldsCode=[0,0,0,0] - createColumnsAttrb(prCurv,fields,fieldsCode) - writeDBF(posCurv,ppCurv,prCurv,saveFile,inpname, "_CURVES", iface,idx) - + writeDBF(posOpt, [ppOpt], prOpt, saveFile, inpname, "_OPTIONS", idx) + + writeDBF(posRep, [ppRep], prRep, saveFile, inpname, "_REPORT", idx) + + #if times: + writeDBF(posTimes, [ppTimes], prTimes, saveFile, inpname, "_TIMES", idx) + + #if energy: + writeDBF(posE, [ppE], prE, saveFile, inpname, "_ENERGY", idx) + + #if optReactions: + writeDBF(posO, [ppO], prO, saveFile, inpname, "_REACTIONS", idx) + + posMix = QgsVectorLayer("point", "Mixing", "memory") + prMix = posMix.dataProvider() + fields = ["Tank_ID", "Model", "Fraction"] + fieldsCode = [0, 0, 1] # 0 String, 1 Double + createColumnsAttrb(prMix, fields, fieldsCode) + writeDBF(posMix, ppMix, prMix, saveFile, inpname, "_MIXING", idx) + + posReact = QgsVectorLayer("point", "ReactionsI", "memory") + prReact = posReact.dataProvider() + fields = ["Type", "Pipe/Tank", "Coeff."] + fieldsCode = [0, 0, 1] + createColumnsAttrb(prReact, fields, fieldsCode) + writeDBF(posReact, ppReactions, prReact, saveFile, inpname, "_REACTIONS_I", idx) + + posSourc = QgsVectorLayer("point", "Sources", "memory") + prSourc = posSourc.dataProvider() + fields = ["Node_ID", "Type", "Strength", "Pattern"] + fieldsCode = [0, 0, 1, 0] + createColumnsAttrb(prSourc, fields, fieldsCode) + writeDBF(posSourc, ppSourc, prSourc, saveFile, inpname, "_SOURCES", idx) + + posRul = QgsVectorLayer("point", "Rules", "memory") + prRul = posRul.dataProvider() + fields = ["Rule_ID", "Rule"] + fieldsCode = [0, 0] + createColumnsAttrb(prRul, fields, fieldsCode) + writeDBF(posRul, ppRul, prRul, saveFile, inpname, "_RULES", idx) + + posQual = QgsVectorLayer("point", "Sources", "memory") + prQual = posQual.dataProvider() + fields = ["Node_ID", "Init_Qual"] + fieldsCode = [0, 1] + createColumnsAttrb(prQual, fields, fieldsCode) + writeDBF(posQual, ppQual, prQual, saveFile, inpname, "_QUALITY", idx) + + posStat = QgsVectorLayer("point", "Status", "memory") + prStat = posStat.dataProvider() + fields = ["Link_ID", "Status/Setting"] + fieldsCode = [0, 0] + createColumnsAttrb(prStat, fields, fieldsCode) + writeDBF(posStat, ppStat, prStat, saveFile, inpname, "_STATUS", idx) + + posEmit = QgsVectorLayer("point", "Emitters", "memory") + prEmit = posEmit.dataProvider() + fields = ["Junc_ID", "Coeff."] + fieldsCode = [0, 1] + createColumnsAttrb(prEmit, fields, fieldsCode) + writeDBF(posEmit, ppEmit, prEmit, saveFile, inpname, "_EMITTERS", idx) + + posCont = QgsVectorLayer("point", "Controls", "memory") + prCont = posCont.dataProvider() + fields = ["Controls"] + fieldsCode = [0] + createColumnsAttrb(prCont, fields, fieldsCode) + writeDBF(posCont, ppCont, prCont, saveFile, inpname, "_CONTROLS", idx) + + posPat = QgsVectorLayer("point", "Patterns", "memory") + prPat = posPat.dataProvider() + fields = ["Pattern_ID", "Multipliers"] + fieldsCode = [0, 0] + createColumnsAttrb(prPat, fields, fieldsCode) + writeDBF(posPat, ppPat, prPat, saveFile, inpname, "_PATTERNS", idx) + + posCurv = QgsVectorLayer("point", "Curves", "memory") + prCurv = posCurv.dataProvider() + fields = ["Curve_ID", "X-Value", "Y-Value", "Type"] + fieldsCode = [0, 0, 0, 0] + createColumnsAttrb(prCurv, fields, fieldsCode) + writeDBF(posCurv, ppCurv, prCurv, saveFile, inpname, "_CURVES", idx) # Write Valve Shapefile - if d.getBinLinkValveCount()>0: - posValve = QgsVectorLayer("point", "Valve", "memory") - prValve = posValve.dataProvider() - fields=["ID","NodeFrom","NodeTo","Diameter","Type","Setting","MinorLoss"] - fieldsCode=[0,0,0,1,0,1,1] - createColumnsAttrb(prValve,fields,fieldsCode) - - linkID=d.getBinLinkValveNameID() - linkType=d.getBinLinkValveType() # valve type - linkDiameter=d.getBinLinkValveDiameters() - linkInitSett=d.getBinLinkValveSetting() #BinLinkValveSetting - linkMinorloss=d.getBinLinkValveMinorLoss() - - posValve.startEditing() + posValve = QgsVectorLayer("LineString", "Valve", "memory") + prValve = posValve.dataProvider() + fields = ["ID", "NodeFrom", "NodeTo", "Diameter", "Type", "Setting", "MinorLoss"] + fieldsCode = [0, 0, 0, 1, 0, 1, 1] + createColumnsAttrb(prValve, fields, fieldsCode) + posValve.startEditing() + + if d.getBinLinkValveCount() > 0: + + linkID = d.getBinLinkValveNameID() + linkType = d.getBinLinkValveType() # valve type + linkDiameter = d.getBinLinkValveDiameters() + linkInitSett = d.getBinLinkValveSetting() # BinLinkValveSetting + linkMinorloss = d.getBinLinkValveMinorLoss() + for i, p in enumerate(d.getBinLinkValveIndex()): - xx= (float(x1[p])+float(x2[p]))/2 - yy= (float(y1[p])+float(y2[p]))/2 + point1 = QgsPoint(float(x[ndID.index(d.getBinLinkFromNode()[p])]), float(y[ndID.index(d.getBinLinkFromNode()[p])])) + point2 = QgsPoint(float(x[ndID.index(d.getBinLinkToNode()[p])]), float(y[ndID.index(d.getBinLinkToNode()[p])])) feature = QgsFeature() - point = QgsPoint(xx,yy) - feature.setGeometry(QgsGeometry.fromPoint(point)) - feature.setAttributes([linkID[i],ndlConn[0][p],ndlConn[1][p],linkDiameter[i],linkType[i],linkInitSett[i],linkMinorloss[i]]) + feature.setGeometry(QgsGeometry.fromPolyline([point1, point2])) + + feature.setAttributes( + [linkID[i], ndlConn[0][p], ndlConn[1][p], linkDiameter[i], linkType[i], linkInitSett[i], + linkMinorloss[i]]) prValve.addFeatures([feature]) - QgsVectorFileWriter.writeAsVectorFormat(posValve,saveFile+"_valves"+'.shp',"utf-8",None,"ESRI Shapefile") - ll=iface.addVectorLayer(saveFile+"_valves"+'.shp', inpname[:len(inpname)-4]+"_valves", "ogr") - iface.legendInterface().moveLayer( ll, idx ) - # Write Pump Shapefile - if d.getBinLinkPumpCount()>0: - posPump = QgsVectorLayer("point", "Pump", "memory") - prPump = posPump.dataProvider() - fields=["ID","NodeFrom","NodeTo","Power","Pattern","Curve"] - fieldsCode=[0,0,0,0,0,0]#,1,1] + QgsVectorFileWriter.writeAsVectorFormat(posValve, saveFile + "_valves" + '.shp', "utf-8", None, + "ESRI Shapefile") + ll = QgsVectorLayer(saveFile + "_valves" + '.shp', inpname[:len(inpname) - 4] + "_valves", "ogr") + QgsMapLayerRegistry.instance().addMapLayer(ll, False) + nvalves = QgsLayerTreeLayer(ll) + idx.insertChildNode(0, nvalves) + nvalves.setCustomProperty("showFeatureCount", True) + ll.loadNamedStyle(plugin_path + "/qmls/" + 'valvesline' + ".qml") + ll.triggerRepaint() + # Write Pump Shapefile + posPump = QgsVectorLayer("LineString", "Pump", "memory") + prPump = posPump.dataProvider() + fields = ["ID", "NodeFrom", "NodeTo", "Power", "Pattern", "Curve"] + fieldsCode = [0, 0, 0, 0, 0, 0] + createColumnsAttrb(prPump, fields, fieldsCode) + posPump.startEditing() + + if d.getBinLinkPumpCount() > 0: curveXY = d.getBinCurvesXY() curvesID = d.getBinCurvesNameID() @@ -692,69 +671,72 @@ def epa2gis(inpname): if l not in b: b.append(l) curvesIDunique = b - CurvesTmpIndices=[] + CurvesTmpIndices = [] for p in range(0, len(curvesIDunique)): CurvesTmpIndices.append(curvesID.count(curvesIDunique[p])) - curveIndices=[] - Curve=d.getBinLinkPumpCurveNameID() + curveIndices = [] + Curve = d.getBinLinkPumpCurveNameID() for i in range(len(Curve)): curveIndices.append(curvesIDunique.index(Curve[i])) if d.getBinCurveCount(): - CurvesTmpIndicesFinal=[] - CurvesTmpIndicesFinal.append([ CurvesTmpIndices[index] for index in curveIndices ]) + CurvesTmpIndicesFinal = [] + CurvesTmpIndicesFinal.append([CurvesTmpIndices[index] for index in curveIndices]) - CurvesTmp=[] - i=0 + CurvesTmp = [] + i = 0 for u in range(max(CurvesTmpIndicesFinal[0])): - fields.append('Head'+str(u+1)); fields.append('Flow'+str(u+1)) - fieldsCode.append(1); fieldsCode.append(1) - if u0: - for uu in range(0,len(pumpNameIDPower)): - if pumpNameIDPower[uu]==pumpID[i]: - power=chPowerPump[uu] - if len(patternsIDs)>0: - for uu in range(0,len(ppatt)): - if ppatt[uu]==pumpID[i]: - pattern=patternsIDs[uu] - - xx= (float(x1[p])+float(x2[p]))/2 - yy= (float(y1[p])+float(y2[p]))/2 + + Curve = [] + power = [] + pattern = [] + pumpNameIDPower = d.getBinLinkPumpNameIDPower() + if len(pumpNameIDPower) > 0: + for uu in range(0, len(pumpNameIDPower)): + if pumpNameIDPower[uu] == pumpID[i]: + power = chPowerPump[uu] + if len(patternsIDs) > 0: + for uu in range(0, len(ppatt)): + if ppatt[uu] == pumpID[i]: + pattern = patternsIDs[uu] + + point1 = QgsPoint(float(x[ndID.index(d.getBinLinkFromNode()[p])]), float(y[ndID.index(d.getBinLinkFromNode()[p])])) + point2 = QgsPoint(float(x[ndID.index(d.getBinLinkToNode()[p])]), float(y[ndID.index(d.getBinLinkToNode()[p])])) feature = QgsFeature() - point = QgsPoint(xx,yy) - feature.setGeometry(QgsGeometry.fromPoint(point)) + feature.setGeometry(QgsGeometry.fromPolyline([point1, point2])) - if Curve==[]: - Curve='NULL' - if power==[]: - power='NULL' - if pattern==[]: - pattern='NULL' + if not Curve: + Curve = 'NULL' + if not power: + power = 'NULL' + if not pattern: + pattern = 'NULL' - if d.getBinCurveCount()>0 and len(pumpNameIDPower)==0: - Curve=d.getBinLinkPumpCurveNameID()[i] + if d.getBinCurveCount() > 0 and len(pumpNameIDPower) == 0: + Curve = d.getBinLinkPumpCurveNameID()[i] curveIndex = curvesIDunique.index(Curve) - feature.initAttributes(6+sum(CurvesTmpIndices)*2+1) + feature.initAttributes(6 + sum(CurvesTmpIndices) * 2 + 1) feature.setAttribute(0, linkID[p]) feature.setAttribute(1, ndlConn[0][p]) feature.setAttribute(2, ndlConn[1][p]) @@ -762,58 +744,90 @@ def epa2gis(inpname): feature.setAttribute(4, pattern) feature.setAttribute(5, Curve) - if d.getBinCurveCount()==1: - w=6 + if d.getBinCurveCount() == 1: + w = 6 for p in range(CurvesTmpIndices[curveIndex]): - print 6+sum(CurvesTmpIndices) feature.setAttribute(w, CurvesTmp[curveIndex][p][0]) - feature.setAttribute(w+1, CurvesTmp[curveIndex][p][1]) - w=w+2 + feature.setAttribute(w + 1, CurvesTmp[curveIndex][p][1]) + w = w + 2 - for j in range(d.getBinCurveCount()-1): - w=6 + for j in range(d.getBinCurveCount() - 1): + w = 6 for p in range(CurvesTmpIndices[curveIndex]): feature.setAttribute(w, CurvesTmp[curveIndex][p][0]) - feature.setAttribute(w+1, CurvesTmp[curveIndex][p][1]) - w=w+2 + feature.setAttribute(w + 1, CurvesTmp[curveIndex][p][1]) + w = w + 2 prPump.addFeatures([feature]) - QgsVectorFileWriter.writeAsVectorFormat(posPump,saveFile+"_pumps"+'.shp',"utf-8",None,"ESRI Shapefile") - ll=iface.addVectorLayer(saveFile+"_pumps"+'.shp', inpname[:len(inpname)-4]+"_pumps", "ogr") - iface.legendInterface().moveLayer( ll, idx ) - if d.getBinLinkPipeCount(): - QgsVectorFileWriter.writeAsVectorFormat(posPipe,saveFile+"_pipes"+'.shp',"utf-8",None,"ESRI Shapefile") - ll=iface.addVectorLayer(saveFile+"_pipes"+'.shp', inpname[:len(inpname)-4]+"_pipes", "ogr") - iface.legendInterface().moveLayer( ll, idx ) - if d.getBinNodeJunctionCount(): - QgsVectorFileWriter.writeAsVectorFormat(posJunction,saveFile+"_junctions"+'.shp',"utf-8",None,"ESRI Shapefile") - ll=iface.addVectorLayer(saveFile+"_junctions"+'.shp', inpname[:len(inpname)-4]+"_junctions", "ogr") - iface.legendInterface().moveLayer( ll, idx ) - if d.getBinNodeTankCount(): - QgsVectorFileWriter.writeAsVectorFormat(posTank,saveFile+"_tanks"+'.shp',"utf-8",None,"ESRI Shapefile") - ll=iface.addVectorLayer(saveFile+"_tanks"+'.shp', inpname[:len(inpname)-4]+"_tanks", "ogr") - iface.legendInterface().moveLayer( ll, idx ) - if d.getBinNodeReservoirCount(): - QgsVectorFileWriter.writeAsVectorFormat(posReservoirs,saveFile+"_reservoirs"+'.shp',"utf-8",None,"ESRI Shapefile") - ll=iface.addVectorLayer(saveFile+"_reservoirs"+'.shp', inpname[:len(inpname)-4]+"_reservoirs", "ogr") - iface.legendInterface().moveLayer( ll, idx ) - - return idx - -def writeDBF(pos,pp,pr,saveFile,inpname, param, iface,idx): - pos.startEditing() - for i in range(len(pp)): - feat = QgsFeature() - feat.setAttributes(pp[i]) - pr.addFeatures([feat]) - QgsVectorFileWriter.writeAsVectorFormat(pos,saveFile+param+'.dbf',"utf-8",None,"DBF file") - ll=iface.addVectorLayer(saveFile+param+'.dbf', inpname[:len(inpname)-4]+param, "ogr") - iface.legendInterface().moveLayer( ll, idx ) - -def createColumnsAttrb(pr,fields,fieldsCode): - for i in range(len(fieldsCode)): - if fieldsCode[i]==0: - pr.addAttributes( [ QgsField(fields[i], QVariant.String) ] ) - else: - pr.addAttributes( [ QgsField(fields[i], QVariant.Double, 'double', 20, 2) ] ) + QgsVectorFileWriter.writeAsVectorFormat(posPump, saveFile + "_pumps" + '.shp', "utf-8", None, "ESRI Shapefile") + ll = QgsVectorLayer(saveFile + "_pumps" + '.shp', inpname[:len(inpname) - 4] + "_pumps", "ogr") + QgsMapLayerRegistry.instance().addMapLayer(ll, False) + npump = QgsLayerTreeLayer(ll) + idx.insertChildNode(0, npump) + npump.setCustomProperty("showFeatureCount", True) + ll.loadNamedStyle(plugin_path + "/qmls/" + 'pumpsline' + ".qml") + ll.triggerRepaint() + + QgsVectorFileWriter.writeAsVectorFormat(posPipe, saveFile + "_pipes" + '.shp', "utf-8", None, "ESRI Shapefile") + ll = QgsVectorLayer(saveFile + "_pipes" + '.shp', inpname[:len(inpname) - 4] + "_pipes", "ogr") + QgsMapLayerRegistry.instance().addMapLayer(ll, False) + npipe = QgsLayerTreeLayer(ll) + idx.insertChildNode(0, npipe) + npipe.setCustomProperty("showFeatureCount", True) + ll.loadNamedStyle(plugin_path + "/qmls/" + 'pipes' + ".qml") + ll.triggerRepaint() + iface.mapCanvas().setExtent(ll.extent()) + + QgsVectorFileWriter.writeAsVectorFormat(posJunction, saveFile + "_junctions" + '.shp', "utf-8", None, + "ESRI Shapefile") + ll = QgsVectorLayer(saveFile + "_junctions" + '.shp', inpname[:len(inpname) - 4] + "_junctions", "ogr") + QgsMapLayerRegistry.instance().addMapLayer(ll, False) + njunc = QgsLayerTreeLayer(ll) + idx.insertChildNode(0, njunc) + njunc.setCustomProperty("showFeatureCount", True) + ll.loadNamedStyle(plugin_path + "/qmls/" + 'junctions' + ".qml") + ll.triggerRepaint() + + QgsVectorFileWriter.writeAsVectorFormat(posTank, saveFile + "_tanks" + '.shp', "utf-8", None, "ESRI Shapefile") + ll = QgsVectorLayer(saveFile + "_tanks" + '.shp', inpname[:len(inpname) - 4] + "_tanks", "ogr") + QgsMapLayerRegistry.instance().addMapLayer(ll, False) + ntanks = QgsLayerTreeLayer(ll) + idx.insertChildNode(0, ntanks) + ntanks.setCustomProperty("showFeatureCount", True) + ll.loadNamedStyle(plugin_path + "/qmls/" + 'tanks' + ".qml") + ll.triggerRepaint() + + QgsVectorFileWriter.writeAsVectorFormat(posReservoirs, saveFile + "_reservoirs" + '.shp', "utf-8", None, + "ESRI Shapefile") + ll = QgsVectorLayer(saveFile + "_reservoirs" + '.shp', inpname[:len(inpname) - 4] + "_reservoirs", "ogr") + QgsMapLayerRegistry.instance().addMapLayer(ll, False) + nres = QgsLayerTreeLayer(ll) + idx.insertChildNode(0, nres) + nres.setCustomProperty("showFeatureCount", True) + ll.loadNamedStyle(plugin_path + "/qmls/" + 'reservoirs' + ".qml") + ll.triggerRepaint() + + +def writeDBF(pos, pp, pr, save_file, inpname, param, idx): + pos.startEditing() + for i in range(len(pp)): + feat = QgsFeature() + feat.setAttributes(pp[i]) + pr.addFeatures([feat]) + epsgCode = pos.crs().authid() + QgsVectorFileWriter.writeAsVectorFormat(pos, save_file + param + '.dbf', "utf-8", + QgsCoordinateReferenceSystem(epsgCode), "DBF file") + ll = QgsVectorLayer(save_file + param + '.dbf', inpname[:len(inpname) - 4] + param, "ogr") + QgsMapLayerRegistry.instance().addMapLayer(ll, False) + nn = QgsLayerTreeLayer(ll) + idx.insertChildNode(0, nn) + nn.setCustomProperty("showFeatureCount", True) + + +def createColumnsAttrb(pr, fields, fields_code): + for i in range(len(fields_code)): + if fields_code[i] == 0: + pr.addAttributes([QgsField(fields[i], QVariant.String)]) + else: + pr.addAttributes([QgsField(fields[i], QVariant.Double, 'double', 20, 6)]) diff --git a/ExportEpanetInpFiles_dialog.py b/ExportEpanetInpFiles_dialog.py new file mode 100644 index 0000000..5685d62 --- /dev/null +++ b/ExportEpanetInpFiles_dialog.py @@ -0,0 +1,45 @@ +# -*- coding: utf-8 -*- +""" +/*************************************************************************** + ExportEpanetInpFilesDialog + A QGIS plugin + Export shapefiles to epanet input files + ------------------- + begin : 2017-04-20 + git sha : $Format:%H$ + copyright : (C) 2017 by KIOS Research Center + email : mariosmsk@gmail.com + ***************************************************************************/ + +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ +""" + +import os + +from PyQt4 import QtGui, uic + +FORM_CLASS, _ = uic.loadUiType(os.path.join( + os.path.dirname(__file__), 'ExportEpanetInpFiles_dialog_base.ui')) + + +class ExportEpanetInpFilesDialog(QtGui.QDialog, FORM_CLASS): + def __init__(self, parent=None): + """Constructor.""" + super(ExportEpanetInpFilesDialog, self).__init__(parent) + # Set up the user interface from Designer. + # After setupUI you can access any designer object by doing + # self., and you can use autoconnect slots - see + # http://qt-project.org/doc/qt-4.8/designer-using-a-ui-file.html + # #widgets-and-dialogs-with-auto-connect + + self.setupUi(self) + + + diff --git a/ExportEpanetInpFiles_dialog_base.ui b/ExportEpanetInpFiles_dialog_base.ui new file mode 100644 index 0000000..302db32 --- /dev/null +++ b/ExportEpanetInpFiles_dialog_base.ui @@ -0,0 +1,702 @@ + + + ExportEpanetInpFilesDialogBase + + + + 0 + 0 + 361 + 713 + + + + Select layers and export Epanet Inp File + + + + + 110 + 50 + 241 + 22 + + + + + + + 10 + 50 + 81 + 21 + + + + + 75 + true + + + + [JUNCTIONS] : + + + + + + 10 + 80 + 91 + 21 + + + + + 75 + true + + + + [RESERVOIRS] : + + + + + + 110 + 80 + 241 + 22 + + + + + + + 110 + 110 + 241 + 22 + + + + + + + 10 + 110 + 91 + 21 + + + + + 75 + true + + + + [TANKS] : + + + + + + 10 + 140 + 91 + 21 + + + + + 75 + true + + + + [PIPES] : + + + + + + 110 + 140 + 241 + 22 + + + + + + + 10 + 170 + 91 + 21 + + + + + 75 + true + + + + [PUMPS] : + + + + + + 110 + 170 + 241 + 22 + + + + + + + 10 + 200 + 91 + 21 + + + + + 75 + true + + + + [VALVES] : + + + + + + 110 + 200 + 241 + 22 + + + + + + + 110 + 230 + 241 + 22 + + + + + + + 10 + 230 + 71 + 21 + + + + + 75 + true + + + + [STATUS] : + + + + + + 110 + 260 + 241 + 22 + + + + + + + 10 + 260 + 81 + 21 + + + + + 75 + true + + + + [PATTERNS] : + + + + + + 110 + 290 + 241 + 22 + + + + + + + 10 + 290 + 61 + 21 + + + + + 75 + true + + + + [CURVES] : + + + + + + 110 + 320 + 241 + 22 + + + + + + + 10 + 320 + 81 + 21 + + + + + 75 + true + + + + [CONTROLS] : + + + + + + 110 + 350 + 241 + 22 + + + + + + + 10 + 350 + 61 + 21 + + + + + 75 + true + + + + [RULES] : + + + + + + 110 + 380 + 241 + 22 + + + + + + + 10 + 380 + 61 + 21 + + + + + 75 + true + + + + [ENERGY] : + + + + + + 110 + 410 + 241 + 22 + + + + + + + 10 + 410 + 81 + 21 + + + + + 75 + true + + + + [EMITTERS] : + + + + + + 110 + 440 + 241 + 22 + + + + + + + 10 + 440 + 71 + 21 + + + + + 75 + true + + + + [QUALITY] : + + + + + + 110 + 470 + 241 + 22 + + + + + + + 10 + 470 + 71 + 21 + + + + + 75 + true + + + + [SOURCES] : + + + + + + 110 + 500 + 241 + 22 + + + + + + + 10 + 500 + 81 + 21 + + + + + 75 + true + + + + [REACTIONS] : + + + + + + 110 + 560 + 241 + 22 + + + + + + + 10 + 560 + 71 + 21 + + + + + 75 + true + + + + [MIXING] : + + + + + + 110 + 620 + 241 + 22 + + + + + + + 10 + 620 + 71 + 21 + + + + + 75 + true + + + + [OPTIONS] : + + + + + + 110 + 590 + 241 + 22 + + + + + + + 10 + 590 + 71 + 21 + + + + + 75 + true + + + + [TIMES] : + + + + + + 110 + 650 + 241 + 22 + + + + + + + 10 + 650 + 71 + 21 + + + + + 75 + true + + + + [REPORT] : + + + + + + 170 + 680 + 75 + 23 + + + + OK + + + + + + 270 + 680 + 75 + 23 + + + + Cancel + + + + + + 10 + 10 + 111 + 21 + + + + + 75 + true + + + + EPANET File Export + + + + + + 279 + 10 + 71 + 21 + + + + + 75 + true + + + + Browse... + + + + + + 120 + 10 + 151 + 20 + + + + + + + 10 + 530 + 111 + 21 + + + + + 75 + true + + + + [REACTIONS_I] : + + + + + + 110 + 530 + 241 + 22 + + + + + + + diff --git a/README.md b/README.md index b8d1524..1d1ab66 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,9 @@ # ImportEpanetInpFiles -QGIS plugin - Import Epanet Input Files -(to be completed) +QGIS plugin + +This tool can be used to IMPORT EPANET INP File to shapefiles and adds them in the QGIS canvas. Also, the shapefiles stored into the _shapefiles_ folder. Can be used to EXPORT EPANET INP File. + +QGIS 2 + +[![IMAGE ALT TEXT HERE](https://img.youtube.com/vi/Fn0MCkTXAYQ/0.jpg)](https://www.youtube.com/watch?v=Fn0MCkTXAYQ) diff --git a/expepanet.png b/expepanet.png new file mode 100644 index 0000000..c3e27d7 Binary files /dev/null and b/expepanet.png differ diff --git a/impepanet.png b/impepanet.png index fceda0e..bb34b1e 100644 Binary files a/impepanet.png and b/impepanet.png differ diff --git a/main.py b/main.py index 19f4cb5..dfc689e 100644 --- a/main.py +++ b/main.py @@ -1,40 +1,412 @@ -#(C)Marios Kyriakou 2016 -#University of Cyprus, KIOS Research Center for Intelligent Systems and Networks -#import qgis.utils +# (C)Marios Kyriakou 2016 +# University of Cyprus, KIOS Research Center for Intelligent Systems and Networks import os from Epa2GIS import epa2gis -from PyQt4.QtCore import QObject, SIGNAL -from PyQt4.QtGui import QAction, QIcon, QFileDialog, QMessageBox +from PyQt4.QtCore import QObject, SIGNAL, Qt +from PyQt4.QtGui import QAction, QIcon, QFileDialog, QMessageBox, QWidget +from .ExportEpanetInpFiles_dialog import ExportEpanetInpFilesDialog import resources_rc + class ImpEpanet(object): - def __init__(self, iface): - # Save a reference to the QGIS iface - self.iface = iface - - def initGui(self): - # Create action - self.action = QAction(QIcon(":/plugins/ImportEpanetInpFiles/impepanet.png"),"Import Epanet Input File",self.iface.mainWindow()) - self.action.setWhatsThis("Import Epanet Input File") - QObject.connect(self.action,SIGNAL("triggered()"),self.run) - self.iface.addToolBarIcon(self.action) - self.iface.addPluginToMenu("&ImportEpanetInpFiles",self.action) - - def unload(self): - # Remove the plugin - self.iface.removePluginMenu("&ImportEpanetInpFiles",self.action) - self.iface.removeToolBarIcon(self.action) - - def run(self): - filePath = QFileDialog.getOpenFileName(self.iface.mainWindow(),"Choose EPANET Input file" , os.getcwd(), "Epanet Inp File (*.inp)") - if filePath == "": - return - s = epa2gis(filePath) - idx=s#[0] - #pb=s[1] - #pb.setValue(100) - self.iface.messageBar().clearWidgets() - msgBox = QMessageBox() - msgBox.setWindowTitle('ImportEpanetInpFiles') - msgBox.setText('Shapefiles have been created successfully in folder "_shapefiles_".') - msgBox.exec_() \ No newline at end of file + def __init__(self, iface): + # Save a reference to the QGIS iface + self.iface = iface + self.canvas = self.iface.mapCanvas() + self.dlg = ExportEpanetInpFilesDialog() + self.sections = ['junctions', 'tanks', 'pipes', 'pumps', 'reservoirs', 'valves', 'STATUS', 'PATTERNS', 'CURVES', + 'CONTROLS', 'RULES', 'ENERGY', 'REACTIONS', 'REACTIONS_I', 'EMITTERS', 'QUALITY', 'SOURCES', + 'MIXING', 'TIMES', 'REPORT', 'OPTIONS'] + + def initGui(self): + # Create action + + self.action = QAction(QIcon(":/plugins/ImportEpanetInpFiles/impepanet.png"), "Import Epanet Input File", + self.iface.mainWindow()) + self.action.setWhatsThis("Import Epanet Input File") + QObject.connect(self.action, SIGNAL("triggered()"), self.run) + self.iface.addToolBarIcon(self.action) + self.iface.addPluginToMenu("&ImportEpanetInpFiles", self.action) + + self.actionexp = QAction(QIcon(":/plugins/ImportEpanetInpFiles/expepanet.png"), "Export Epanet Input File", + self.iface.mainWindow()) + self.actionexp.setWhatsThis("Export Epanet Input File") + QObject.connect(self.actionexp, SIGNAL("triggered()"), self.runexp) + self.iface.addToolBarIcon(self.actionexp) + self.iface.addPluginToMenu("&ImportEpanetInpFiles", self.actionexp) + + self.dlg.ok_button.clicked.connect(self.ok) + self.dlg.cancel_button.clicked.connect(self.cancel) + self.dlg.toolButtonOut.clicked.connect(self.toolButtonOut) + + def unload(self): + # Remove the plugin + self.iface.removePluginMenu("&ImportEpanetInpFiles", self.action) + self.iface.removeToolBarIcon(self.action) + + self.iface.removePluginMenu("&ImportEpanetInpFiles", self.actionexp) + self.iface.removeToolBarIcon(self.actionexp) + + def run(self): + filePath = QFileDialog.getOpenFileName(self.iface.mainWindow(), "Choose EPANET Input file", + os.path.join(os.path.join(os.path.expanduser('~')), 'Desktop'), + "Epanet Inp File (*.inp)") + if filePath == "": + return + epa2gis(filePath) + self.iface.messageBar().clearWidgets() + msgBox = QMessageBox() + msgBox.setWindowTitle('ImportEpanetInpFiles') + msgBox.setText('Shapefiles have been created successfully in folder "_shapefiles_".') + msgBox.exec_() + + def runexp(self): + self.dlg.out.setText('') + self.layers = self.canvas.layers() + self.layer_list = [] + self.layer_list = ['NONE'] + [self.layer_list.append(layer.name()) for layer in self.layers] + + for sect in self.sections: + eval('self.dlg.sect_' + sect + '.clear()') + eval('self.dlg.sect_' + sect + '.addItems(self.layer_list)') + indices = [i for i, s in enumerate(self.layer_list) if sect in s] + if indices: + if sect == 'REACTIONS': + eval('self.dlg.sect_' + sect + '.setCurrentIndex(indices[1])') + else: + eval('self.dlg.sect_' + sect + '.setCurrentIndex(indices[0])') + + self.dlg.setWindowFlags(Qt.CustomizeWindowHint | Qt.WindowStaysOnTopHint | Qt.WindowCloseButtonHint) + self.dlg.show() + + def cancel(self): + self.dlg.close() + self.layer_list = [] + self.layer_list = ['NONE'] + [eval('self.dlg.sect_' + sect + '.clear()') for sect in self.sections] + + def toolButtonOut(self): + self.outEpanetName = QFileDialog.getSaveFileName(None, 'Save File', + os.path.join(os.path.join(os.path.expanduser('~')), + 'Desktop'), 'Epanet Inp File (*.inp)') + self.dlg.out.setText(self.outEpanetName) + + def selectOutp(self): + msgBox = QMessageBox() + msgBox.setIcon(QMessageBox.Warning) + msgBox.setWindowTitle('Warning') + msgBox.setText('Please define Epanet Inp File location.') + msgBox.setWindowFlags(Qt.CustomizeWindowHint | Qt.WindowStaysOnTopHint | Qt.WindowCloseButtonHint) + msgBox.exec_() + return True + + def ok(self): + # Here check if select OK button, get the layer fields + # Initialize + # [JUNCTIONS] + if self.dlg.out.text() == '': + if self.selectOutp(): + return + elif os.path.isabs(self.dlg.out.text()) == False: + if self.selectOutp(): + return + + self.outEpanetName = self.dlg.out.text() + + try: + f = open(self.outEpanetName, "w") + f.close() + except: + msgBox = QMessageBox() + msgBox.setIcon(QMessageBox.Warning) + msgBox.setWindowTitle('Warning') + msgBox.setText('Please define Epanet Inp File location.') + msgBox.setWindowFlags(Qt.CustomizeWindowHint | Qt.WindowStaysOnTopHint | Qt.WindowCloseButtonHint) + msgBox.exec_() + return + + if not self.layers: + msgBox = QMessageBox() + msgBox.setIcon(QMessageBox.Warning) + msgBox.setWindowTitle('Warning') + msgBox.setText('No layers selected.') + msgBox.setWindowFlags(Qt.CustomizeWindowHint | Qt.WindowStaysOnTopHint | Qt.WindowCloseButtonHint) + msgBox.exec_() + return + xypipes_id = [] + xypipesvert = [] + for sect in self.sections: + exec 'sect' + sect + '=[]' in globals(), locals() + exec 'xy' + sect + '=[]' in globals(), locals() + if eval('self.dlg.sect_' + sect + '.currentText()') != 'NONE': + # Get layer field names + indLayerName = self.layer_list.index(eval('self.dlg.sect_' + sect + '.currentText()')) - 1 + fields = self.layers[indLayerName].pendingFields() + field_names = [field.name() for field in fields] + for elem in self.layers[indLayerName].getFeatures(): + eval('sect' + sect + '.append(dict(zip(field_names, elem.attributes())))') + if any(sect in s for s in self.sections[0:5]): + geom = elem.geometry() + if self.layers[indLayerName].geometryType() == 0: + eval('xy' + sect + '.append(geom.asPoint())') + elif self.layers[indLayerName].geometryType() == 1: + eval('xy' + sect + '.append(geom.asPolyline())') + if sect == 'pipes': + if geom.asPolyline() > 2: + for pp in range(len(geom.asPolyline())-2): + xypipes_id.append(elem.attributes()[0]) + xypipesvert.append(geom.asPolyline()[pp]) + if sect == 'junctions': + if 'Elevation' not in sectjunctions[0].keys(): + QMessageBox.warning(QWidget(), "Message", "Elevation field is missing.") + # (myDirectory,nameFile) = os.path.split(self.iface.activeLayer().dataProvider().dataSourceUri()) + my_directory = '' + f = open(self.outEpanetName, 'wt') + f.write('[TITLE]\n') + f.write('Export input file via plugin ExportEpanetInpFiles. \n\n') + f.write('[JUNCTIONS]\n') + node_i_ds = [] + for i in range(len(sectjunctions)): + node_i_ds.append(sectjunctions[i]['ID']) + f.write(sectjunctions[i]['ID'] + ' ' + str(sectjunctions[i]['Elevation']) + '\n') + f.write('\n[RESERVOIRS]\n') + for i in range(len(sectreservoirs)): + node_i_ds.append(sectreservoirs[i]['ID']) + f.write(sectreservoirs[i]['ID'] + ' ' + str(sectreservoirs[i]['Head']) + '\n') + f.write('\n[TANKS]\n') + for i in range(len(secttanks)): + node_i_ds.append(secttanks[i]['ID']) + if secttanks[i]['VolumeCurv'] == None: + secttanks[i]['VolumeCurv'] = "" + f.write(secttanks[i]['ID'] + ' ' + str(secttanks[i]['Elevation']) + ' ' + str(secttanks[i]['InitLevel']) + + ' ' + str(secttanks[i]['MinLevel']) + ' ' + str(secttanks[i]['MaxLevel']) + ' ' + str( + secttanks[i]['Diameter']) + + ' ' + str(secttanks[i]['MinVolume']) + ' ' + str(secttanks[i]['VolumeCurv']) + ' ' + '\n') + f.write('\n[PIPES]\n') + for i in range(len(sectpipes)): + if (sectpipes[i]['NodeFrom'] in node_i_ds) and (sectpipes[i]['NodeTo'] in node_i_ds): + f.write(sectpipes[i]['ID'] + ' ' + sectpipes[i]['NodeFrom'] + + ' ' + sectpipes[i]['NodeTo'] + ' ' + str(sectpipes[i]['Length']) + ' ' + str( + sectpipes[i]['Diameter']) + + ' ' + str(sectpipes[i]['Roughness']) + ' ' + str(sectpipes[i]['MinorLoss']) + ' ' + + sectpipes[i]['Status'] + '\n') + f.write('\n[PUMPS]\n') + for i in range(len(sectpumps)): + if sectpumps[i]['Curve'] != 'NULL': + try: + sectpumps[i]['Curve'] = 'HEAD ' + sectpumps[i]['Curve'] + except: + sectpumps[i]['Curve'] = 'HEAD ' + else: + sectpumps[i]['Curve'] = '' + if sectpumps[i]['Pattern'] != 'NULL': + try: + sectpumps[i]['Pattern'] = 'PATTERN ' + sectpumps[i]['Pattern'] + except: + sectpumps[i]['Pattern'] = "PATTERN " + else: + sectpumps[i]['Pattern'] = '' + if sectpumps[i]['Power'] != 'NULL': + try: + sectpumps[i]['Power'] = 'POWER ' + sectpumps[i]['Power'] + except: + sectpumps[i]['Power'] = "POWER " + else: + sectpumps[i]['Power'] = '' + + try: + f.write(sectpumps[i]['ID'] + ' ' + sectpumps[i]['NodeFrom'] + + ' ' + sectpumps[i]['NodeTo'] + ' ' + sectpumps[i]['Curve'] + + ' ' + str(sectpumps[i]['Pattern']) + ' ' + str(sectpumps[i]['Power']) + '\n') + except: + f.write(sectpumps[i]['ID'] +'\n') + + f.write('\n[VALVES]\n') + if self.dlg.sect_valves.currentText() != 'NONE': + for i in range(len(sectvalves)): + try: + sectvalves[i]['NodeFrom'] = sectvalves[i]['NodeFrom'] + '' + except: + sectvalves[i]['NodeFrom'] = "" + + try: + sectvalves[i]['NodeTo'] = sectvalves[i]['NodeTo'] + '' + except: + sectvalves[i]['NodeTo'] = "" + f.write("{} {} {} {} {} {} {}\n".format(sectvalves[i]['ID'], sectvalves[i]['NodeFrom'], + sectvalves[i]['NodeTo'], + str(sectvalves[i]['Diameter']), + sectvalves[i]['Type'], + str(sectvalves[i]['Setting']), + str(sectvalves[i]['MinorLoss']))) + + f.write('\n[DEMANDS]\n') + for i in range(len(sectjunctions)): + for u in range((len(sectjunctions[i]) - 2) / 2): + if sectjunctions[i]['Demand' + str(u + 1)] == 0 and str( + sectjunctions[i]['Pattern' + str(u + 1)]) == 'None': + continue + if str(sectjunctions[i]['Pattern' + str(u + 1)]) == 'NULL' or str( + sectjunctions[i]['Pattern' + str(u + 1)]) == 'None': + sectjunctions[i]['Pattern' + str(u + 1)] = '' + f.write(sectjunctions[i]['ID'] + ' ' + str(sectjunctions[i]['Demand' + str(u + 1)]) + + ' ' + str(sectjunctions[i]['Pattern' + str(u + 1)]) + '\n') + + f.write('\n[STATUS]\n') + for i in range(len(sectSTATUS)): + f.write("{} {}\n".format(sectSTATUS[i]['Link_ID'], sectSTATUS[i]['Status/Set'])) + + f.write('\n[PATTERNS]\n') + for i in range(len(sectPATTERNS)): + f.write("{} {}\n".format(sectPATTERNS[i]['Pattern_ID'], sectPATTERNS[i]['Multiplier'])) + + f.write('\n[CURVES]\n') + for i in range(len(sectCURVES)): + f.write(";{}:\n {} {} {}\n".format(sectCURVES[i]['Type'], sectCURVES[i]['Curve_ID'], + str(sectCURVES[i]['X-Value']),str(sectCURVES[i]['Y-Value']))) + + f.write('\n[CONTROLS]\n') + for i in range(len(sectCONTROLS)): + f.write("{}\n".format(sectCONTROLS[i]['Controls'])) + + f.write('\n[RULES]\n') + for i in range(len(sectRULES)): + f.write("RULE {}\n {}\n".format(sectRULES[i]['Rule_ID'], sectRULES[i]['Rule'])) + + f.write('\n[ENERGY]\n') + if sectENERGY: + try: f.write('Global Efficiency ' + str(sectENERGY[0]['GlobalEffi']) + '\n') + except: pass + try: f.write('Global Price ' + str(sectENERGY[0]['GlobalPric']) + '\n') + except: pass + try: f.write('Demand Charge ' + str(sectENERGY[0]['DemCharge']) + '\n') + except: pass + + f.write('\n[REACTIONS]\n') + if sectREACTIONS: + try: f.write('Order Bulk ' + str(sectREACTIONS[0]['OrderBulk']) + '\n') + except: pass + try: f.write('Order Tank ' + str(sectREACTIONS[0]['OrderTank']) + '\n') + except: pass + try: f.write('Order Wall ' + str(sectREACTIONS[0]['OrderWall']) + '\n') + except: pass + try: f.write('Global Bulk ' + str(sectREACTIONS[0]['GlobalBulk']) + '\n') + except: pass + try: f.write('Global Wall ' + str(sectREACTIONS[0]['GlobalWall']) + '\n') + except: pass + try: f.write('Limiting Potential ' + str(sectREACTIONS[0]['LimPotent']) + '\n') + except: pass + try: f.write('Roughness Correlation ' + str(sectREACTIONS[0]['RoughCorr']) + '\n') + except: pass + + f.write('\n[REACTIONS]\n') + for i in range(len(sectREACTIONS_I)): + f.write('{} {} {} \n'.format(sectREACTIONS_I[i]['Type'], + sectREACTIONS_I[i]['Pipe/Tank'], str(sectREACTIONS_I[i]['Coeff.']))) + f.write('\n[EMITTERS]\n') + for i in range(len(sectEMITTERS)): + f.write('{} {}\n'.format(sectEMITTERS[i]['Junc_ID'], str(sectEMITTERS[i]['Coeff.']))) + + f.write('\n[SOURCES]\n') + for i in range(len(sectSOURCES)): + try: + sectSOURCES[i]['Pattern'] = sectSOURCES[i]['Pattern'] + '' + except: + sectSOURCES[i]['Pattern'] = '' + f.write("{} {} {} {}\n".format(sectSOURCES[i]['Node_ID'], sectSOURCES[i]['Type'], + str(sectSOURCES[i]['Strength']), + sectSOURCES[i]['Pattern'])) + + f.write('\n[MIXING]\n') + for i in range(len(sectMIXING)): + f.write('{} {} {} \n'.format(sectMIXING[i]['Tank_ID'], + sectMIXING[i]['Model'], str(sectMIXING[i]['Fraction']))) + + f.write('\n[TIMES]\n') + if sectTIMES: + try: f.write('Duration ' + str(sectTIMES[0]['Duration']) + '\n') + except: pass + try: f.write('Hydraulic Timestep ' + str(sectTIMES[0]['HydStep']) + '\n') + except: pass + try: f.write('Quality Timestep ' + str(sectTIMES[0]['QualStep']) + '\n') + except: pass + try: f.write('Pattern Timestep ' + str(sectTIMES[0]['PatStep']) + '\n') + except: pass + try: f.write('Pattern Start ' + str(sectTIMES[0]['PatStart']) + '\n') + except: pass + try: f.write('Report Timestep ' + str(sectTIMES[0]['RepStep']) + '\n') + except: pass + try: f.write('Report Start ' + str(sectTIMES[0]['RepStart']) + '\n') + except: pass + try: f.write('Start ClockTime ' + str(sectTIMES[0]['StartClock']) + '\n') + except: pass + try: f.write('Statistic ' + str(sectTIMES[0]['Statistic']) + '\n') + except: pass + + f.write('\n[REPORT]\n') + if sectREPORT: + try: f.write('Status ' + sectREPORT[0]['Status'] + '\n') + except: pass + try: f.write('Summary ' + sectREPORT[0]['Summary'] + '\n') + except: pass + try: f.write('Page ' + sectREPORT[0]['Page'] + '\n') + except: pass + + f.write('\n[OPTIONS]\n') + if sectOPTIONS: + try: f.write('Units ' + str(sectOPTIONS[0]['Units']) + '\n'); + except: pass + try: f.write('Headloss ' + str(sectOPTIONS[0]['Headloss']) + '\n') + except: pass + try: f.write('Specific Gravity ' + str(sectOPTIONS[0]['SpecGrav']) + '\n') + except: pass + try: f.write('Viscosity ' + str(sectOPTIONS[0]['Viscosity']) + '\n') + except: pass + try: f.write('Trials ' + str(sectOPTIONS[0]['Trials']) + '\n') + except: pass + try: f.write('Accuracy ' + str(sectOPTIONS[0]['Accuracy']) + '\n') + except: pass + try: f.write('CHECKFREQ ' + str(sectOPTIONS[0]['CheckFreq']) + '\n') + except: pass + try: f.write('MAXCHECK ' + str(sectOPTIONS[0]['MaxCheck']) + '\n') + except: pass + try: f.write('DAMPLIMIT ' + str(sectOPTIONS[0]['DampLimit']) + '\n') + except: pass + try: f.write('Unbalanced ' + str(sectOPTIONS[0]['Unbalanced']) + '\n') + except: pass + try: f.write('Pattern ' + str(sectOPTIONS[0]['PatID']) + '\n') + except: pass + try: f.write('Demand Multiplier ' + str(sectOPTIONS[0]['DemMult']) + '\n') + except: pass + try: f.write('Emitter Exponent ' + str(sectOPTIONS[0]['EmitExp']) + '\n') + except: pass + try: f.write('Quality ' + str(sectOPTIONS[0]['Quality']) + '\n') + except: pass + try: f.write('Diffusivity ' + str(sectOPTIONS[0]['Diffusivit']) + '\n') + except: pass + try: f.write('Tolerance ' + str(sectOPTIONS[0]['Tolerance']) + '\n') + except: pass + + f.write('\n[COORDINATES]\n') + for i in range(len(sectjunctions)): + f.write(sectjunctions[i]['ID'] + ' ' + str(xyjunctions[i][0]) + ' ' + str(xyjunctions[i][1]) + '\n') + for i in range(len(sectreservoirs)): + f.write(sectreservoirs[i]['ID'] + ' ' + str(xyreservoirs[i][0]) + ' ' + str(xyreservoirs[i][1]) + '\n') + for i in range(len(secttanks)): + f.write(secttanks[i]['ID'] + ' ' + str(xytanks[i][0]) + ' ' + str(xytanks[i][1]) + '\n') + + f.write('\n[VERTICES]\n') + + for l in range(len(xypipes_id)): + f.write(xypipes_id[l] + ' ' + str(xypipesvert[l][0]) + ' ' + str(xypipesvert[l][1]) + '\n') + + f.write('\n[END]\n') + + f.close() + + self.cancel() + msgBox = QMessageBox() + msgBox.setWindowTitle('Export Options') + msgBox.setText('Export Epanet Inp File "' + self.outEpanetName + '" succesful.') + msgBox.exec_() diff --git a/metadata.txt b/metadata.txt index 40f565a..90b05d3 100644 --- a/metadata.txt +++ b/metadata.txt @@ -9,12 +9,12 @@ [general] name=ImportEpanetInpFiles qgisMinimumVersion=2.0 -description=Import Epanet Input Files -version=0.7 +description=IMPORT and EXPORT --> EPANET INP Files +version=0.8 author=KIOS Research Center email=mariosmsk@gmail.com -about=ImportEpanetInpFiles converts EPANET Input File to shapefiles and adds them in the QGIS canvas. Also, the shapefiles stored into the _shapefiles_ folder. +about=This tool can be used to IMPORT EPANET INP File to shapefiles and adds them in the QGIS canvas. Also, the shapefiles stored into the _shapefiles_ folder. Can be used to EXPORT EPANET INP File. tracker=https://github.com/KIOS-Research/ImportEpanetInpFiles/issues repository=https://github.com/KIOS-Research/ImportEpanetInpFiles @@ -35,9 +35,11 @@ changelog=2016-03-14 ImportEpanetInpFiles 0.2: Update fields names, Remove section Demands, Add Demand and Pattern columns based on demand categories 2017-10-13 ImportEpanetInpFiles 0.7: Fixed error with curves + 2017-04-13 ImportEpanetInpFiles 0.8: + Add qml files, Clear code, Fix bug in SOURCES, Add EXPORT EPANET INP File # Tags are comma separated with spaces allowed -tags=epanet,import,inp,network +tags=epanet,import,export,inp,network homepage=https://github.com/KIOS-Research/ImportEpanetInpFiles category=Plugins diff --git a/qmls/junctions.qml b/qmls/junctions.qml new file mode 100644 index 0000000..7430c12 --- /dev/null +++ b/qmls/junctions.qml @@ -0,0 +1,320 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 0 + 0 + 0 + DC_ID + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + . + + + + + + + + + + + + + + . + + 0 + + + 0 + generatedlayout + + + + + + + + + + + + COALESCE("DC_ID", '<NULL>') + 0 + diff --git a/qmls/pipes.qml b/qmls/pipes.qml new file mode 100644 index 0000000..97985cd --- /dev/null +++ b/qmls/pipes.qml @@ -0,0 +1,376 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 0 + 0 + 0 + DC_ID + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + . + + + + + + + + + + + + + + + + + + . + + 0 + + + 0 + generatedlayout + + + + + + + + + + + + + + + + COALESCE("DC_ID", '<NULL>') + 1 + diff --git a/qmls/pumpsline.qml b/qmls/pumpsline.qml new file mode 100644 index 0000000..ce25d3c --- /dev/null +++ b/qmls/pumpsline.qml @@ -0,0 +1,389 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 0 + 0 + 0 + ID + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 0 + + + 0 + generatedlayout + + + + + + + + + + + + + + + + COALESCE( "ID", '<NULL>' ) + 1 + diff --git a/qmls/reservoirs.qml b/qmls/reservoirs.qml new file mode 100644 index 0000000..b610e53 --- /dev/null +++ b/qmls/reservoirs.qml @@ -0,0 +1,309 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 0 + 0 + 0 + DC_ID + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + . + + + + + + + + + + + + . + + 0 + + + 0 + generatedlayout + + + + + + + + + + COALESCE("DC_ID", '<NULL>') + 0 + diff --git a/qmls/tanks.qml b/qmls/tanks.qml new file mode 100644 index 0000000..b1c05d1 --- /dev/null +++ b/qmls/tanks.qml @@ -0,0 +1,324 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 0 + 0 + 0 + ID + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + . + + 0 + + + 0 + generatedlayout + + + + + + + + + + + + + + + + ID + 0 + diff --git a/qmls/valves.qml b/qmls/valves.qml new file mode 100644 index 0000000..7e6d393 --- /dev/null +++ b/qmls/valves.qml @@ -0,0 +1,239 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 0 + 0 + 0 + DC_ID + + + + + + + + + + + + + + + + + + . + + 0 + . + generatedlayout + + + + diff --git a/qmls/valvesline.qml b/qmls/valvesline.qml new file mode 100644 index 0000000..70181f5 --- /dev/null +++ b/qmls/valvesline.qml @@ -0,0 +1,382 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 0 + 0 + 0 + ID + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 0 + + + 0 + generatedlayout + + + + + + + + + + + + + + + COALESCE( "ID", '<NULL>' ) + 1 + diff --git a/readEpanetFile.py b/readEpanetFile.py index 34f82e0..711793e 100644 --- a/readEpanetFile.py +++ b/readEpanetFile.py @@ -1,580 +1,711 @@ # Read Epanet File import os + + def LoadFile(inp): global inpname, mm - mm=[] - #getPathPlugin = os.path.dirname(os.path.realpath(__file__))+"\\" - #inpname = getPathPlugin + inp + mm = [] inpname = inp -def BinUpdateClass():#(pb): + +def BinUpdateClass(): global mm - mm = getBinInfo()#(pb) + mm = getBinInfo() return mm -## get Info + +# get Info def getBinNodeReservoirIndex(): - ind=range(getBinNodeJunctionCount()+1,getBinNodeJunctionCount()+getBinNodeReservoirCount()+1) + ind = range(getBinNodeJunctionCount() + 1, getBinNodeJunctionCount() + getBinNodeReservoirCount() + 1) return ind + def getBinNodeTankIndex(): - ind=range(getBinNodeJunctionCount()+getBinNodeReservoirCount()+1,getBinNodeCount()+1) + ind = range(getBinNodeJunctionCount() + getBinNodeReservoirCount() + 1, getBinNodeCount() + 1) return ind + def getBinNodeDemandPatternID(): global mm return mm[3] + def getBinNodeJunctionCount(): global mm return mm[4] + def getBinNodeReservoirCount(): global mm return mm[7] + def getBinNodeIndex(id): - nodeNameID = getBinNodeNameID() - return nodeNameID.index(id) + node_name_i_d = getBinNodeNameID() + return node_name_i_d.index(id) + def getBinNodeNameID(): global mm - return mm[0]+mm[5]+mm[8] + return mm[0] + mm[5] + mm[8] + def getBinNodeJunctionNameID(): global mm return mm[0] + def getBinReservoirNameID(): global mm return mm[5] -# def getBinNodeElevations(): -# global mm -# nodeElevations=getBinNodeJunctionElevations() -# for i in range(len(mm[6])): -# nodeElevations.append(mm[6][i])#reservoirs -# for i in range(len(mm[6])): -# nodeElevations.append(mm[9][i]) -# return nodeElevations def getBinNodeJunctionElevations(): global mm return mm[1] + def getBinNodeReservoirElevations(): global mm return mm[6] + def getBinNodeBaseDemands(): global mm return mm[2] + def getBinNodeBaseDemandsDemSection(): global mm - return mm[62], mm[63], mm[64] # nodeJunctionsDemSection, nodeJunctionsIDDemSection, nodeJunctionsPatDemSection + return mm[62], mm[63], mm[64] # nodeJunctionsDemSection, nodeJunctionsIDDemSection, nodeJunctionsPatDemSection + # Tanks Info def getBinNodeTankNameID(): global mm return mm[8] + def getBinNodeTankCount(): return len(getBinNodeTankNameID()) + def getBinNodeTankElevations(): global mm return mm[9] + def getBinNodeTankInitialLevel(): global mm return mm[10] + def getBinNodeTankMinimumWaterLevel(): global mm return mm[11] + def getBinNodeTankMaximumWaterLevel(): global mm return mm[12] + def getBinNodeTankDiameter(): global mm return mm[13] + def getBinNodeTankMinimumWaterVolume(): global mm return mm[14] + def getBinNodeTankVolumeCurveID(): global mm return mm[35] + # Get Links Info def getBinLinkPumpIndex(): - ind=[] - for i in range(getBinLinkPipeCount()+1,getBinLinkPipeCount()+getBinLinkPumpCount()+1): - ind.append(i-1) + ind = [] + for i in range(getBinLinkPipeCount() + 1, getBinLinkPipeCount() + getBinLinkPumpCount() + 1): + ind.append(i - 1) return ind + def getBinLinkValveIndex(): - ind=[] - for i in range(getBinLinkPipeCount()+getBinLinkPumpCount()+1,getBinLinkCount()+1): - ind.append(i-1) + ind = [] + for i in range(getBinLinkPipeCount() + getBinLinkPumpCount() + 1, getBinLinkCount() + 1): + ind.append(i - 1) return ind + def getBinLinkIndex(id): linkNameID = getBinLinkNameID() return linkNameID.index(id) + def getBinLinkNameID(): global mm - return mm[15]+mm[22]+mm[27] + return mm[15] + mm[22] + mm[27] + def getBinLinkLength(): - ll=getBinLinkPipeLengths() - for i in range(getBinLinkPipeCount()+1,getBinLinkCount()+1): - ll.append(0) - return ll + ll = getBinLinkPipeLengths() + for i in range(getBinLinkPipeCount() + 1, getBinLinkCount() + 1): + ll.append(0) + return ll + def getBinLinkDiameter(): - ll=getBinLinkPipeDiameters() - vld=getBinLinkValveDiameters() - for i in range(getBinLinkPipeCount()+1,getBinLinkPipeCount()+getBinLinkPumpCount()+1): - ll.append(0) - for i in range(getBinLinkValveCount()): - ll.append(vld[i]) - return ll + ll = getBinLinkPipeDiameters() + vld = getBinLinkValveDiameters() + for i in range(getBinLinkPipeCount() + 1, getBinLinkPipeCount() + getBinLinkPumpCount() + 1): + ll.append(0) + for i in range(getBinLinkValveCount()): + ll.append(vld[i]) + return ll + def getBinLinkRoughnessCoeff(): - ll=getBinLinkPipeRoughness() - for i in range(getBinLinkPipeCount()+1,getBinLinkCount()+1): - ll.append(0) - return ll + ll = getBinLinkPipeRoughness() + for i in range(getBinLinkPipeCount() + 1, getBinLinkCount() + 1): + ll.append(0) + return ll + def getBinLinkMinorLossCoeff(): - ll=getBinLinkPipeMinorLoss() - vld=getBinLinkValveMinorLoss() - for i in range(getBinLinkPipeCount()+1,getBinLinkPipeCount()+getBinLinkPumpCount()+1): - ll.append(0) - for i in range(getBinLinkValveCount()): - ll.append(vld[i]) - return ll + ll = getBinLinkPipeMinorLoss() + vld = getBinLinkValveMinorLoss() + for i in range(getBinLinkPipeCount() + 1, getBinLinkPipeCount() + getBinLinkPumpCount() + 1): + ll.append(0) + for i in range(getBinLinkValveCount()): + ll.append(vld[i]) + return ll def getBinLinkPipeCount(): return len(getBinLinkPipeNameID()) + def getBinLinkPipeNameID(): global mm return mm[15] + def getBinLinkFromNode(): global mm return mm[16] + def getBinLinkToNode(): global mm return mm[17] + def getBinLinkPipeLengths(): global mm return mm[18] + def getBinLinkPipeDiameters(): global mm return mm[19] + def getBinLinkPipeRoughness(): global mm return mm[20] + def getBinLinkPipeMinorLoss(): global mm return mm[21] + # Get Pumps Info def getBinLinkPumpCount(): return len(getBinLinkPumpNameID()) + def getBinLinkPumpNameID(): global mm return mm[22] + def getBinLinkPumpPatterns(): global mm return mm[23] + def getBinLinkPumpCurveNameID(): global mm return mm[24] + def getBinLinkPumpPower(): global mm return mm[25] + def getBinLinkPumpNameIDPower(): global mm return mm[26] + def getBinLinkPumpSpeed(): global mm return mm[38] + def getBinLinkPumpPatternsPumpID(): global mm return mm[39] -#Get Valves Info +# Get Valves Info def getBinLinkValveCount(): return len(getBinLinkValveNameID()) + def getBinLinkValveNameID(): global mm return mm[27] + def getBinLinkValveDiameters(): global mm return mm[28] + def getBinLinkValveType(): global mm return mm[29] + def getBinLinkValveSetting(): global mm return mm[30] + def getBinLinkValveMinorLoss(): global mm return mm[31] + def getBinNodesConnectingLinksID(): return [mm[16], mm[17]] + def getBinNodesConnectingLinksIndex(): NodesConnectingLinksID = getBinNodesConnectingLinksID() - nodeInd=[] + nodeInd = [] for i in range(getBinLinkCount()): - nodeInd.append([getBinNodeIndex(NodesConnectingLinksID[0][i]),getBinNodeIndex(NodesConnectingLinksID[1][i])]) + nodeInd.append([getBinNodeIndex(NodesConnectingLinksID[0][i]), getBinNodeIndex(NodesConnectingLinksID[1][i])]) return nodeInd + def getBinLinkCount(): - return getBinLinkPipeCount()+getBinLinkPumpCount()+getBinLinkValveCount() + return getBinLinkPipeCount() + getBinLinkPumpCount() + getBinLinkValveCount() + def getBinNodeCount(): - return getBinNodeJunctionCount()+getBinNodeReservoirCount()+getBinNodeTankCount() + return getBinNodeJunctionCount() + getBinNodeReservoirCount() + getBinNodeTankCount() -#Status + +# Status def getBinLinkInitialStatus(): global mm return mm[32] + def getBinLinkInitialStatusNameID(): global mm return mm[33] -#Curves + +# Curves def getBinCurvesNameID(): global mm return mm[36] + def getBinCurvesXY(): global mm return mm[37] + def getBinCurveCount(): global mm return len(set(mm[36])) + def getDemandsSection(): global mm return mm[44] + def getStatusSection(): global mm return mm[45] + def getEmittersSection(): global mm return mm[46] + def getControlsSection(): global mm return mm[47] + def getPatternsSection(): global mm return mm[48] + def getCurvesSection(): global mm - return mm[49],mm[50] + return mm[49], mm[50] + def getQualitySection(): global mm return mm[51] + def getRulesSection(): global mm return mm[52] + def getSourcesSection(): global mm return mm[53] + def getEnergySection(): global mm return mm[54] + def getReactionsSection(): global mm return mm[55] + def getReactionsOptionsSection(): global mm return mm[56] + def getMixingSection(): global mm return mm[57] + def getTimesSection(): global mm return mm[58] + def getOptionsSection(): global mm return mm[59] + def getReportSection(): global mm return mm[60] + def getLabelsSection(): global mm return mm[61] # Get all info -def getBinInfo():#(pb): +def getBinInfo(): global inpname - file = open(inpname,'r') - - nodeJunctionNameID=[] - nodeJunctionElevations=[] - nodeJunctionBaseDemands=[] - - nodeJunctionsDemSection=[] - nodeJunctionsIDDemSection=[] - nodeJunctionsPatDemSection=[] - - nodePatternNameID=[] - nodeReservoirNameID=[] - nodeReservoirElevations=[] - - BinNodeTankNameID=[] - BinNodeTankElevation=[] - BinNodeTankInitLevel=[] - BinNodeTankMinLevel=[] - BinNodeTankMaxLevel=[] - BinNodeTankDiameter=[] - BinNodeTankMinVol=[] - BinNodeTankVolumeCurveID=[] - - BinLinkPipeNameID=[] - BinLinkFromNode=[] - BinLinkToNode=[] - BinLinkPipeLengths=[] - BinLinkPipeDiameters=[] - BinLinkPipeRoughness=[] - BinLinkPipeMinorLoss=[] - - BinLinkPumpPatterns=[] - BinLinkPumpCurveNameID=[] - BinLinkPumpPower=[] - BinLinkPumpNameIDPower=[] - BinLinkPumpNameID=[] - BinLinkPumpSpeed=[] - BinLinkPumpPatternsPumpID=[] - - BinLinkValveNameID=[] - BinLinkValveDiameters=[] - BinLinkValveType=[] - BinLinkValveSetting=[] - BinLinkValveMinorLoss=[] - - BinLinkInitialStatus=[] - BinLinkInitialStatusNameID=[] - BincountStatuslines=[] - linkNameID=[] - - BinCurvesNameID=[] - BinCurvesXY=[] - - #Sections - demandsSection=[] - statusSection=[] - emittersSection=[] - controlsSection=[] - patternsSection=[] - curvesSection=[] - curvesSectionType=[] - qualitySection=[] - rulesSection=[]; rules=[] - sourcesSection=[] - energySection=[] - reactionsSection=[] - reactionsOptionSection=[] - mixingSection=[] - timesSection=[] - optionsSection=[] - reportSection=[] - labelsSection=[] - - s1=file.readline() - num=13;sec=[0]*num - x=[] - y=[] + file = open(inpname, 'r') + + nodeJunctionNameID = [] + nodeJunctionElevations = [] + nodeJunctionBaseDemands = [] + + nodeJunctionsDemSection = [] + nodeJunctionsIDDemSection = [] + nodeJunctionsPatDemSection = [] + + nodePatternNameID = [] + nodeReservoirNameID = [] + nodeReservoirElevations = [] + + BinNodeTankNameID = [] + BinNodeTankElevation = [] + BinNodeTankInitLevel = [] + BinNodeTankMinLevel = [] + BinNodeTankMaxLevel = [] + BinNodeTankDiameter = [] + BinNodeTankMinVol = [] + BinNodeTankVolumeCurveID = [] + + BinLinkPipeNameID = [] + BinLinkFromNode = [] + BinLinkToNode = [] + BinLinkPipeLengths = [] + BinLinkPipeDiameters = [] + BinLinkPipeRoughness = [] + BinLinkPipeMinorLoss = [] + + BinLinkPumpPatterns = [] + BinLinkPumpCurveNameID = [] + BinLinkPumpPower = [] + BinLinkPumpNameIDPower = [] + BinLinkPumpNameID = [] + BinLinkPumpSpeed = [] + BinLinkPumpPatternsPumpID = [] + + BinLinkValveNameID = [] + BinLinkValveDiameters = [] + BinLinkValveType = [] + BinLinkValveSetting = [] + BinLinkValveMinorLoss = [] + + BinLinkInitialStatus = [] + BinLinkInitialStatusNameID = [] + BincountStatuslines = [] + linkNameID = [] + + BinCurvesNameID = [] + BinCurvesXY = [] + + # Sections + demandsSection = [] + statusSection = [] + emittersSection = [] + controlsSection = [] + patternsSection = [] + curvesSection = [] + curvesSectionType = [] + qualitySection = [] + rulesSection = [] + rules = [] + sourcesSection = [] + energySection = [] + reactionsSection = [] + reactionsOptionSection = [] + mixingSection = [] + timesSection = [] + optionsSection = [] + reportSection = [] + labelsSection = [] + + s1 = file.readline() + + num = 13 + sec = [0] * num + x = [] + y = [] # Create a list. - vertx=[];verty=[] + vertx = [] + verty = [] # Append empty lists in first two indexes. - sec2=[0]*num;ch1=0;ch=1 - #pb.setValue(2) + sec2 = [0] * num + ch1 = 0 + ch = 1 while True: if "[" in s1: pass else: - s1=file.readline() - ok=0 + s1 = file.readline() + ok = 0 if "[END]" in s1: - #pb.setValue(10) + # pb.setValue(10) file.close() - return [nodeJunctionNameID, nodeJunctionElevations, nodeJunctionBaseDemands, nodePatternNameID, len(nodeJunctionNameID),#01234 - nodeReservoirNameID, nodeReservoirElevations, len(nodeReservoirNameID),#567 - BinNodeTankNameID, BinNodeTankElevation, BinNodeTankInitLevel, BinNodeTankMinLevel, BinNodeTankMaxLevel, BinNodeTankDiameter, BinNodeTankMinVol, #8#9#10#11#12#13#14 - BinLinkPipeNameID, BinLinkFromNode, BinLinkToNode, BinLinkPipeLengths, BinLinkPipeDiameters, BinLinkPipeRoughness, BinLinkPipeMinorLoss, #15#16#17#18#19#20#21 - BinLinkPumpNameID, BinLinkPumpPatterns, BinLinkPumpCurveNameID, BinLinkPumpPower, BinLinkPumpNameIDPower, #22#23#24#25#26 - BinLinkValveNameID, BinLinkValveDiameters, BinLinkValveType, BinLinkValveSetting, BinLinkValveMinorLoss, #27#28#29#30#31 - BinLinkInitialStatus, BinLinkInitialStatusNameID, BincountStatuslines, BinNodeTankVolumeCurveID, #32#33#34#35 - BinCurvesNameID, BinCurvesXY, BinLinkPumpSpeed, BinLinkPumpPatternsPumpID, #36#37#38#39 - x,y,vertx,verty, #40#41#42#43 - demandsSection,statusSection,emittersSection,controlsSection,patternsSection,curvesSection,curvesSectionType,#44#45#46#47#48#49#50 - qualitySection,rulesSection,sourcesSection,energySection,reactionsSection,reactionsOptionSection,mixingSection,#51#52#53#54#55#56#57 - timesSection,optionsSection,reportSection,labelsSection,#58#59#60#61 - nodeJunctionsDemSection, nodeJunctionsIDDemSection, nodeJunctionsPatDemSection] #62#63#64 + return [nodeJunctionNameID, nodeJunctionElevations, nodeJunctionBaseDemands, nodePatternNameID, + len(nodeJunctionNameID), # 01234 + nodeReservoirNameID, nodeReservoirElevations, len(nodeReservoirNameID), # 567 + BinNodeTankNameID, BinNodeTankElevation, BinNodeTankInitLevel, BinNodeTankMinLevel, + BinNodeTankMaxLevel, BinNodeTankDiameter, BinNodeTankMinVol, # 8#9#10#11#12#13#14 + BinLinkPipeNameID, BinLinkFromNode, BinLinkToNode, BinLinkPipeLengths, BinLinkPipeDiameters, + BinLinkPipeRoughness, BinLinkPipeMinorLoss, # 15#16#17#18#19#20#21 + BinLinkPumpNameID, BinLinkPumpPatterns, BinLinkPumpCurveNameID, BinLinkPumpPower, + BinLinkPumpNameIDPower, # 22#23#24#25#26 + BinLinkValveNameID, BinLinkValveDiameters, BinLinkValveType, BinLinkValveSetting, + BinLinkValveMinorLoss, # 27#28#29#30#31 + BinLinkInitialStatus, BinLinkInitialStatusNameID, BincountStatuslines, BinNodeTankVolumeCurveID, + # 32#33#34#35 + BinCurvesNameID, BinCurvesXY, BinLinkPumpSpeed, BinLinkPumpPatternsPumpID, # 36#37#38#39 + x, y, vertx, verty, # 40#41#42#43 + demandsSection, statusSection, emittersSection, controlsSection, patternsSection, curvesSection, + curvesSectionType, # 44#45#46#47#48#49#50 + qualitySection, rulesSection, sourcesSection, energySection, reactionsSection, + reactionsOptionSection, mixingSection, # 51#52#53#54#55#56#57 + timesSection, optionsSection, reportSection, labelsSection, # 58#59#60#61 + nodeJunctionsDemSection, nodeJunctionsIDDemSection, nodeJunctionsPatDemSection] # 62#63#64 elif "[JUNCTIONS]" in s1: - sec[0]=1;s1=file.readline(); pass + sec[0] = 1 + s1 = file.readline() elif "[RESERVOIRS]" in s1: - sec=[0]*num;sec[1]=1;s1=file.readline() + sec = [0] * num + sec[1] = 1 + s1 = file.readline() elif "[TANKS]" in s1: - sec=[0]*num;sec[2]=1;s1=file.readline() + sec = [0] * num + sec[2] = 1 + s1 = file.readline() elif "[PIPES]" in s1: - sec=[0]*num;sec[3]=1;s1=file.readline() + sec = [0] * num + sec[3] = 1 + s1 = file.readline() elif "[PUMPS]" in s1: - sec=[0]*num;sec[4]=1;s1=file.readline() + sec = [0] * num + sec[4] = 1 + s1 = file.readline() elif "[VALVES]" in s1: - sec=[0]*num;sec[5]=1;s1=file.readline() + sec = [0] * num + sec[5] = 1 + s1 = file.readline() if "[STATUS]" in s1: - sec=[0]*num;sec2=[0]*num;sec[7]=1;s1=file.readline() - for i in range(0,len(BinLinkPipeNameID)+len(BinLinkPumpNameID)+len(BinLinkValveNameID)): + sec = [0] * num + sec2 = [0] * num + sec[7] = 1 + s1 = file.readline() + for i in range(0, len(BinLinkPipeNameID) + len(BinLinkPumpNameID) + len(BinLinkValveNameID)): vertx.append([]) verty.append([]) linknameid = BinLinkPipeNameID + BinLinkPumpNameID + BinLinkValveNameID elif "[DEMANDS]" in s1: - sec=[0]*num;sec[8]=1;s1=file.readline() - elif ("[JUNCTIONS]" in s1 or "[RESERVOIRS]" in s1 or "[TANKS]" in s1 or "[PIPES]" in s1 or "[PUMPS]" in s1 or "[VALVES]" in s1): - ok=1 - elif "[TAGS]" in s1 and ok==0: - sec=[0]*num;s1=file.readline() + sec = [0] * num + sec[8] = 1 + s1 = file.readline() + elif ("[JUNCTIONS]" in s1 or "[RESERVOIRS]" in s1 or "[TANKS]" in s1 or "[PIPES]" in s1 or "[PUMPS]" in s1 or + "[VALVES]" in s1): + ok = 1 + elif "[TAGS]" in s1 and ok == 0: + sec = [0] * num + s1 = file.readline() elif "[PATTERNS]" in s1: - sec=[0]*num;sec[6]=1;s1=file.readline() + sec = [0] * num + sec[6] = 1 + s1 = file.readline() elif "[CURVES]" in s1: - sec=[0]*num;sec[9]=1;s1=file.readline() + sec = [0] * num + sec[9] = 1 + s1 = file.readline() elif "[CONTROLS]" in s1: - sec=[0]*num;sec[10]=1;s1=file.readline() + sec = [0] * num + sec[10] = 1 + s1 = file.readline() elif "[COORDINATES]" in s1: - sec2=[0]*num;sec2[0]=1;s1=file.readline() - #pb.setValue(5) + sec2 = [0] * num + sec2[0] = 1 + s1 = file.readline() elif "[VERTICES]" in s1: - #pb.setValue(7) - sec2=[0]*num;sec2[1]=1;s1=file.readline() + sec2 = [0] * num + sec2[1] = 1 + s1 = file.readline() elif "[LABELS]" in s1: - sec2=[0]*num;sec2[12]=1;s1=file.readline() + sec2 = [0] * num + sec2[12] = 1 + s1 = file.readline() elif "[EMITTERS]" in s1: - sec2=[0]*num;sec2[2]=1;s1=file.readline() + sec2 = [0] * num + sec2[2] = 1 + s1 = file.readline() elif "[RULES]" in s1: - sec=[0]*num;sec2=[0]*num;sec2[3]=1;s1=file.readline() + sec = [0] * num + sec2 = [0] * num + sec2[3] = 1 + s1 = file.readline() elif "[ENERGY]" in s1: - sec2=[0]*num;sec2[6]=1 - if rules!=[]: + sec2 = [0] * num + sec2[6] = 1 + if rules != []: rulesSection.append(rules) - s1=file.readline() + s1 = file.readline() elif "[QUALITY]" in s1: - sec2=[0]*num;sec=[0]*num;sec2[4]=1;s1=file.readline() + sec2 = [0] * num + sec = [0] * num + sec2[4] = 1 + s1 = file.readline() elif "[SOURCES]" in s1: - sec2=[0]*num;sec2[5]=1;s1=file.readline() + sec2 = [0] * num + sec2[5] = 1 + s1 = file.readline() elif "[REACTIONS]" in s1: - sec2=[0]*num;sec2[7]=1;s1=file.readline() + sec2 = [0] * num + sec2[7] = 1 + s1 = file.readline() elif "[MIXING]" in s1: - sec2=[0]*num;sec2[8]=1;s1=file.readline() + sec2 = [0] * num + sec2[8] = 1 + s1 = file.readline() elif "[TIMES]" in s1: - sec2=[0]*num;sec2[9]=1;s1=file.readline() + sec2 = [0] * num + sec2[9] = 1 + s1 = file.readline() elif "[REPORT]" in s1: - sec2=[0]*num;sec2[10]=1;s1=file.readline() + sec2 = [0] * num + sec2[10] = 1 + s1 = file.readline() elif "[OPTIONS]" in s1: - sec2=[0]*num;sec2[11]=1;s1=file.readline() + sec2 = [0] * num + sec2[11] = 1 + s1 = file.readline() elif "[BACKDROP]" in s1: - sec2=[0]*num;s1=file.readline() + sec2 = [0] * num + s1 = file.readline() elif "[" in s1: - s1=file.readline() + s1 = file.readline() - if sec[0]==1: #JUNCTIONS + if sec[0] == 1: # JUNCTIONS if "[" in s1: continue - mm=s1.split() - if len(mm)>1: - if mm[0][0]==';': + mm = s1.split() + if len(mm) > 1: + if mm[0][0] == ';': pass else: nodeJunctionNameID.append(mm[0]) nodeJunctionElevations.append(float(mm[1])) - if len(mm)>2: + if len(mm) > 2: nodeJunctionBaseDemands.append(float(mm[2])) - if len(mm)>3: - if mm[3][0]!=';': + if len(mm) > 3: + if mm[3][0] != ';': nodePatternNameID.append(mm[3]) else: nodePatternNameID.append('') else: nodePatternNameID.append('') - if sec[1]==1: #RESERVOIRS + if sec[1] == 1: # RESERVOIRS if "[" in s1: continue - mm=s1.split() - if len(mm)>0: - if mm[0][0]==';': + mm = s1.split() + if len(mm) > 0: + if mm[0][0] == ';': pass else: nodeReservoirNameID.append(mm[0]) nodeReservoirElevations.append(float(mm[1])) - if len(mm)>2: - if mm[2][0]!=';': + if len(mm) > 2: + if mm[2][0] != ';': nodePatternNameID.append(mm[2]) else: nodePatternNameID.append('') else: nodePatternNameID.append('') - if sec[2]==1: #TANKS + if sec[2] == 1: # TANKS if "[" in s1: continue - mm=s1.split() - if len(mm)>0: - if mm[0][0]==';': + mm = s1.split() + if len(mm) > 0: + if mm[0][0] == ';': pass else: BinNodeTankNameID.append(mm[0]) @@ -585,20 +716,20 @@ def getBinInfo():#(pb): BinNodeTankDiameter.append(float(mm[5])) BinNodeTankMinVol.append(float(mm[6])) nodePatternNameID.append('') - if len(mm)>7: - if mm[7][0]!=';': + if len(mm) > 7: + if mm[7][0] != ';': BinNodeTankVolumeCurveID.append(mm[7]) else: BinNodeTankVolumeCurveID.append('') else: BinNodeTankVolumeCurveID.append('') - if sec[3]==1: #PIPES + if sec[3] == 1: # PIPES if "[" in s1: continue - mm=s1.split() - if len(mm)>0: - if mm[0][0]==';': + mm = s1.split() + if len(mm) > 0: + if mm[0][0] == ';': pass else: linkNameID.append(mm[0]) @@ -608,54 +739,53 @@ def getBinInfo():#(pb): BinLinkPipeLengths.append(float(mm[3])) BinLinkPipeDiameters.append(float(mm[4])) BinLinkPipeRoughness.append(float(mm[5])) - if len(mm)>6: + if len(mm) > 6: BinLinkPipeMinorLoss.append(float(mm[6])) else: BinLinkPipeMinorLoss.append('') - if len(mm)>7: - if mm[7][0]!=';': - if mm[7]=='Open': + if len(mm) > 7: + if mm[7][0] != ';': + if mm[7] == 'Open': BinLinkInitialStatus.append('OPEN') else: BinLinkInitialStatus.append(mm[7]) - if sec[4]==1: #PUMPS + if sec[4] == 1: # PUMPS if "[" in s1: continue - mm=s1.split() - if len(mm)>0: - if mm[0][0]==';': + mm = s1.split() + if len(mm) > 0: + if mm[0][0] == ';': pass else: linkNameID.append(mm[0]) BinLinkPumpNameID.append(mm[0]) BinLinkFromNode.append(mm[1]) BinLinkToNode.append(mm[2]) - if len(mm)>4: - if mm[3]=='HEAD': + if len(mm) > 4: + if mm[3] == 'HEAD': BinLinkPumpCurveNameID.append(mm[4]) - elif mm[3]=='POWER': + elif mm[3] == 'POWER': BinLinkPumpPower.append(float(mm[4])) BinLinkPumpNameIDPower.append(mm[0]) - if len(mm)>6: - if mm[5][0]!=';': - if mm[5]=='SPEED': + if len(mm) > 6: + if mm[5][0] != ';': + if mm[5] == 'SPEED': BinLinkPumpSpeed.append(mm[6]) else: BinLinkPumpPatterns.append(mm[6]) BinLinkPumpPatternsPumpID.append(mm[0]) - if len(mm)>8: + if len(mm) > 8: BinLinkPumpPatterns.append(mm[8]) BinLinkPumpPatternsPumpID.append(mm[0]) - - if sec[5]==1: #VALVES + if sec[5] == 1: # VALVES if "[" in s1: continue - mm=s1.split() - if len(mm)>1: - if mm[0][0]==';': + mm = s1.split() + if len(mm) > 1: + if mm[0][0] == ';': pass else: linkNameID.append(mm[0]) @@ -665,55 +795,58 @@ def getBinInfo():#(pb): BinLinkValveDiameters.append(float(mm[3])) BinLinkValveType.append(mm[4]) BinLinkValveSetting.append(float(mm[5])) - if len(mm)>6: - if mm[6][0]!=';': + if len(mm) > 6: + if mm[6][0] != ';': BinLinkValveMinorLoss.append(float(mm[6])) - if sec[6]==1: #PATTERNS + if sec[6] == 1: # PATTERNS if "[" in s1: continue - mm=s1.split() - if len(mm)>1: - if mm[0][0]==';': + mm = s1.split() + if len(mm) > 1: + if mm[0][0] == ';': pass else: - patternsSection.append([mm[0],' '.join(mm[1:])]) + patternsSection.append([mm[0], ' '.join(mm[1:])]) - if sec[7]==1: #STATUS + if sec[7] == 1: # STATUS if "[" in s1: continue - mm=s1.split() - if len(mm)>1: - if mm[0][0]==';': + mm = s1.split() + if len(mm) > 1: + if mm[0][0] == ';': pass else: statusSection.append(mm) BinLinkInitialStatusNameID.append(mm[0]) - if mm[1]=='Open': + if mm[1] == 'Open': BinLinkInitialStatus.append('OPEN') else: BinLinkInitialStatus.append(mm[1]) BincountStatuslines.append(mm) - if sec[8]==1: #DEMANDS + if sec[8] == 1: # DEMANDS if "[" in s1: continue - mm=s1.split() - if len(mm)>1: - if mm[0][0]==';': + mm = s1.split() + if len(mm) > 1: + if mm[0][0] == ';': pass else: nodeJunctionsIDDemSection.append(mm[0]) nodeJunctionsDemSection.append(float(mm[1])) - nodeJunctionsPatDemSection.append(mm[2]) + try: + nodeJunctionsPatDemSection.append(mm[2]) + except: + nodeJunctionsPatDemSection.append('') demandsSection.append(mm) - if sec[9]==1: #CURVES + if sec[9] == 1: # CURVES if "[" in s1: continue - mm=s1.split() - if len(mm)>1: - if mm[0]==';ID': + mm = s1.split() + if len(mm) > 1: + if mm[0] == ';ID': continue elif ";PUMP:" in mm[0].upper(): curvesSectionType.append('PUMP') @@ -725,348 +858,348 @@ def getBinInfo():#(pb): curvesSectionType.append('HEADLOSS') else: curvesSectionType.append('PUMP') - #else: - if mm[0][0]!=';': + if mm[0][0] != ';': curvesSection.append(mm) BinCurvesNameID.append(mm[0]) - BinCurvesXY.append([float(mm[1]),float(mm[2])]) + BinCurvesXY.append([float(mm[1]), float(mm[2])]) - if sec[10]==1: #CONTROLS + if sec[10] == 1: # CONTROLS if "[" in s1: continue - mm=s1.split() - if len(mm)>1: - if mm[0][0]==';': + mm = s1.split() + if len(mm) > 1: + if mm[0][0] == ';': pass else: controlsSection.append(' '.join(mm)) - if sec2[0]==1: #COORDINATES + if sec2[0] == 1: # COORDINATES if "[" in s1: continue - mm=s1.split() - if len(mm)>2: - if mm[0][0]!=';': + mm = s1.split() + if len(mm) > 2: + if mm[0][0] != ';': x.append(float(mm[1])) y.append(float(mm[2])) - if sec2[1]==1: #VERTICES + if sec2[1] == 1: # VERTICES if "[" in s1: continue - mm=s1.split() - if len(mm)>2: - if mm[0][0]!=';': + mm = s1.split() + if len(mm) > 2: + if mm[0][0] != ';': linkIndex = linknameid.index(mm[0]) vertx[linkIndex].append(float(mm[1])) verty[linkIndex].append(float(mm[2])) - - if sec2[2]==1: #EMITTERS + if sec2[2] == 1: # EMITTERS if "[" in s1: continue - mm=s1.split() - if len(mm)>1: - if mm[0][0]==';': + mm = s1.split() + if len(mm) > 1: + if mm[0][0] == ';': pass else: emittersSection.append(mm) - if sec2[3]==1: #RULES + if sec2[3] == 1: # RULES if "[" in s1: continue - mm=s1.split() - if len(mm)>1: - if mm[0][0]==';': + mm = s1.split() + if len(mm) > 1: + if mm[0][0] == ';': pass else: if "RULE" in mm[0].upper(): - if (rules!=[] or ch==0): - rulesSection.append(rules); ch=0 - rules=[] - rules.append([s1,mm]) + if rules != [] or ch == 0: + rulesSection.append(rules) + ch = 0 + rules = [] + rules.append([s1, mm]) else: - rules.append([s1,mm]) + rules.append([s1, mm]) else: - rules.append([s1,mm]) - + rules.append([s1, mm]) - if sec2[4]==1: #QUALITY + if sec2[4] == 1: # QUALITY if "[" in s1: continue - mm=s1.split() - if len(mm)>1: - if mm[0][0]==';': + mm = s1.split() + if len(mm) > 1: + if mm[0][0] == ';': pass else: qualitySection.append(mm) - if sec2[5]==1: #SOURCES + if sec2[5] == 1: # SOURCES if "[" in s1: continue - mm=s1.split() - if len(mm)>1: - if mm[0][0]==';': + mm = s1.split() + if len(mm) > 1: + if mm[0][0] == ';': pass else: sourcesSection.append(mm) - if sec2[6]==1: #ENERGY + if sec2[6] == 1: # ENERGY if "[" in s1: continue - mm=s1.split() - if len(mm)>1: - if mm[0][0]==';': + mm = s1.split() + if len(mm) > 1: + if mm[0][0] == ';': pass else: energySection.append(mm) - if sec2[7]==1: #REACTIONS + if sec2[7] == 1: # REACTIONS if "[" in s1: continue - mm=s1.split() - if len(mm)>1: - if mm[0][0]==';': + mm = s1.split() + if len(mm) > 1: + if mm[0][0] == ';': pass else: - if ("ORDER" in mm[0].upper() and ch1==0) or ch1==1: - reactionsOptionSection.append(mm);ch1=1 + if ("ORDER" in mm[0].upper() and ch1 == 0) or ch1 == 1: + reactionsOptionSection.append(mm) + ch1 = 1 else: reactionsSection.append(mm) - if sec2[8]==1: #MIXING + if sec2[8] == 1: # MIXING if "[" in s1: continue - mm=s1.split() - if len(mm)>1: - if mm[0][0]==';': + mm = s1.split() + if len(mm) > 1: + if mm[0][0] == ';': pass else: mixingSection.append(mm) - if sec2[9]==1: #TIMES + if sec2[9] == 1: # TIMES if "[" in s1: continue - mm=s1.split() - if len(mm)>1: - if mm[0][0]==';': + mm = s1.split() + if len(mm) > 1: + if mm[0][0] == ';': pass else: timesSection.append(mm) - if sec2[10]==1: #REPORT + if sec2[10] == 1: # REPORT if "[" in s1: continue - mm=s1.split() - if len(mm)>1: - if mm[0][0]==';': + mm = s1.split() + if len(mm) > 1: + if mm[0][0] == ';': pass else: reportSection.append(mm) - if sec2[11]==1: #OPTIONS + if sec2[11] == 1: # OPTIONS if "[" in s1: continue - mm=s1.split() - if len(mm)>1: - if mm[0][0]==';': + mm = s1.split() + if len(mm) > 1: + if mm[0][0] == ';': pass else: optionsSection.append(mm) - if sec2[12]==1: #LABELS + if sec2[12] == 1: # LABELS if "[" in s1: continue - mm=s1.split() - if len(mm)>1: - if mm[0][0]==';': + mm = s1.split() + if len(mm) > 1: + if mm[0][0] == ';': pass else: labelsSection.append(mm) -## Node Coordinates +# Node Coordinates def getBinNodeCoordinates(): global mm - return mm[40],mm[41],mm[42],mm[43]#,mm[44],mm[45],mm[46],mm[47] - #x,y,x1,y1,x2,y2,vertx,verty] #40#41#42#43#44#45#46#47 - -EN_ELEVATION = 0 # /* Node parameters */ -EN_BASEDEMAND = 1 -EN_PATTERN = 2 -EN_EMITTER = 3 -EN_INITQUAL = 4 -EN_SOURCEQUAL = 5 -EN_SOURCEPAT = 6 -EN_SOURCETYPE = 7 -EN_TANKLEVEL = 8 -EN_DEMAND = 9 -EN_HEAD = 10 -EN_PRESSURE = 11 -EN_QUALITY = 12 -EN_SOURCEMASS = 13 -EN_INITVOLUME = 14 -EN_MIXMODEL = 15 -EN_MIXZONEVOL = 16 - -EN_TANKDIAM = 17 -EN_MINVOLUME = 18 -EN_VOLCURVE = 19 -EN_MINLEVEL = 20 -EN_MAXLEVEL = 21 -EN_MIXFRACTION = 22 -EN_TANK_KBULK = 23 - -EN_DIAMETER = 0 # /* Link parameters */ -EN_LENGTH = 1 -EN_ROUGHNESS = 2 -EN_MINORLOSS = 3 -EN_INITSTATUS = 4 -EN_INITSETTING = 5 -EN_KBULK = 6 -EN_KWALL = 7 -EN_FLOW = 8 -EN_VELOCITY = 9 -EN_HEADLOSS = 10 -EN_STATUS = 11 -EN_SETTING = 12 -EN_ENERGY = 13 - -EN_DURATION = 0 # /* Time parameters */ -EN_HYDSTEP = 1 -EN_QUALSTEP = 2 -EN_PATTERNSTEP = 3 -EN_PATTERNSTART = 4 -EN_REPORTSTEP = 5 -EN_REPORTSTART = 6 -EN_RULESTEP = 7 -EN_STATISTIC = 8 -EN_PERIODS = 9 - -EN_NODECOUNT = 0 # /* Component counts */ -EN_TANKCOUNT = 1 -EN_LINKCOUNT = 2 -EN_PATCOUNT = 3 -EN_CURVECOUNT = 4 -EN_CONTROLCOUNT = 5 - -EN_JUNCTION = 0 # /* Node types */ -EN_RESERVOIR = 1 -EN_TANK = 2 - -EN_CVPIPE = 0 # /* Link types */ -EN_PIPE = 1 -EN_PUMP = 2 -EN_PRV = 3 -EN_PSV = 4 -EN_PBV = 5 -EN_FCV = 6 -EN_TCV = 7 -EN_GPV = 8 - -EN_NONE = 0 # /* Quality analysis types */ -EN_CHEM = 1 -EN_AGE = 2 -EN_TRACE = 3 - -EN_CONCEN = 0 # /* Source quality types */ -EN_MASS = 1 -EN_SETPOINT = 2 -EN_FLOWPACED = 3 - -EN_CFS = 0 # /* Flow units types */ -EN_GPM = 1 -EN_MGD = 2 -EN_IMGD = 3 -EN_AFD = 4 -EN_LPS = 5 -EN_LPM = 6 -EN_MLD = 7 -EN_CMH = 8 -EN_CMD = 9 - -EN_TRIALS = 0 # /* Misc. options */ -EN_ACCURACY = 1 -EN_TOLERANCE = 2 -EN_EMITEXPON = 3 -EN_DEMANDMULT = 4 - -EN_LOWLEVEL = 0 # /* Control types */ -EN_HILEVEL = 1 -EN_TIMER = 2 -EN_TIMEOFDAY = 3 - -EN_AVERAGE = 1 # /* Time statistic types. */ -EN_MINIMUM = 2 -EN_MAXIMUM = 3 -EN_RANGE = 4 - -EN_MIX1 = 0 # /* Tank mixing models */ -EN_MIX2 = 1 -EN_FIFO = 2 -EN_LIFO = 3 - -EN_NOSAVE = 0 # /* Save-results-to-file flag */ -EN_SAVE = 1 -EN_INITFLOW = 10 # /* Re-initialize flow flag */ - -Open = 1 -Closed = 0 + return mm[40], mm[41], mm[42], mm[43] # ,mm[44],mm[45],mm[46],mm[47] + # x,y,x1,y1,x2,y2,vertx,verty] #40#41#42#43#44#45#46#47 + + +EN_ELEVATION = 0 # /* Node parameters */ +EN_BASEDEMAND = 1 +EN_PATTERN = 2 +EN_EMITTER = 3 +EN_INITQUAL = 4 +EN_SOURCEQUAL = 5 +EN_SOURCEPAT = 6 +EN_SOURCETYPE = 7 +EN_TANKLEVEL = 8 +EN_DEMAND = 9 +EN_HEAD = 10 +EN_PRESSURE = 11 +EN_QUALITY = 12 +EN_SOURCEMASS = 13 +EN_INITVOLUME = 14 +EN_MIXMODEL = 15 +EN_MIXZONEVOL = 16 + +EN_TANKDIAM = 17 +EN_MINVOLUME = 18 +EN_VOLCURVE = 19 +EN_MINLEVEL = 20 +EN_MAXLEVEL = 21 +EN_MIXFRACTION = 22 +EN_TANK_KBULK = 23 + +EN_DIAMETER = 0 # /* Link parameters */ +EN_LENGTH = 1 +EN_ROUGHNESS = 2 +EN_MINORLOSS = 3 +EN_INITSTATUS = 4 +EN_INITSETTING = 5 +EN_KBULK = 6 +EN_KWALL = 7 +EN_FLOW = 8 +EN_VELOCITY = 9 +EN_HEADLOSS = 10 +EN_STATUS = 11 +EN_SETTING = 12 +EN_ENERGY = 13 + +EN_DURATION = 0 # /* Time parameters */ +EN_HYDSTEP = 1 +EN_QUALSTEP = 2 +EN_PATTERNSTEP = 3 +EN_PATTERNSTART = 4 +EN_REPORTSTEP = 5 +EN_REPORTSTART = 6 +EN_RULESTEP = 7 +EN_STATISTIC = 8 +EN_PERIODS = 9 + +EN_NODECOUNT = 0 # /* Component counts */ +EN_TANKCOUNT = 1 +EN_LINKCOUNT = 2 +EN_PATCOUNT = 3 +EN_CURVECOUNT = 4 +EN_CONTROLCOUNT = 5 + +EN_JUNCTION = 0 # /* Node types */ +EN_RESERVOIR = 1 +EN_TANK = 2 + +EN_CVPIPE = 0 # /* Link types */ +EN_PIPE = 1 +EN_PUMP = 2 +EN_PRV = 3 +EN_PSV = 4 +EN_PBV = 5 +EN_FCV = 6 +EN_TCV = 7 +EN_GPV = 8 + +EN_NONE = 0 # /* Quality analysis types */ +EN_CHEM = 1 +EN_AGE = 2 +EN_TRACE = 3 + +EN_CONCEN = 0 # /* Source quality types */ +EN_MASS = 1 +EN_SETPOINT = 2 +EN_FLOWPACED = 3 + +EN_CFS = 0 # /* Flow units types */ +EN_GPM = 1 +EN_MGD = 2 +EN_IMGD = 3 +EN_AFD = 4 +EN_LPS = 5 +EN_LPM = 6 +EN_MLD = 7 +EN_CMH = 8 +EN_CMD = 9 + +EN_TRIALS = 0 # /* Misc. options */ +EN_ACCURACY = 1 +EN_TOLERANCE = 2 +EN_EMITEXPON = 3 +EN_DEMANDMULT = 4 + +EN_LOWLEVEL = 0 # /* Control types */ +EN_HILEVEL = 1 +EN_TIMER = 2 +EN_TIMEOFDAY = 3 + +EN_AVERAGE = 1 # /* Time statistic types. */ +EN_MINIMUM = 2 +EN_MAXIMUM = 3 +EN_RANGE = 4 + +EN_MIX1 = 0 # /* Tank mixing models */ +EN_MIX2 = 1 +EN_FIFO = 2 +EN_LIFO = 3 + +EN_NOSAVE = 0 # /* Save-results-to-file flag */ +EN_SAVE = 1 +EN_INITFLOW = 10 # /* Re-initialize flow flag */ + +Open = 1 +Closed = 0 # Constants for units -FlowUnits= { EN_CFS :"cfs" , - EN_GPM :"gpm" , - EN_MGD :"a-f/d" , - EN_IMGD:"mgd" , - EN_AFD :"Imgd" , - EN_LPS :"L/s" , - EN_LPM :"Lpm" , - EN_MLD :"m3/h" , - EN_CMH :"m3/d" , - EN_CMD :"ML/d" } +FlowUnits = {EN_CFS: "cfs", + EN_GPM: "gpm", + EN_MGD: "a-f/d", + EN_IMGD: "mgd", + EN_AFD: "Imgd", + EN_LPS: "L/s", + EN_LPM: "Lpm", + EN_MLD: "m3/h", + EN_CMH: "m3/d", + EN_CMD: "ML/d"} # Constants for links -TYPELINK= { EN_CVPIPE :"CV" , - EN_PIPE :"PIPE" , - EN_PUMP :"PUMP" , - EN_PRV:"PRV" , - EN_PSV :"PSV" , - EN_PBV :"PBV" , - EN_FCV :"FCV" , - EN_TCV :"TCV" , - EN_GPV :"GPV" } +TYPELINK = {EN_CVPIPE: "CV", + EN_PIPE: "PIPE", + EN_PUMP: "PUMP", + EN_PRV: "PRV", + EN_PSV: "PSV", + EN_PBV: "PBV", + EN_FCV: "FCV", + EN_TCV: "TCV", + EN_GPV: "GPV"} # Constants for nodes -TYPENODE= { EN_JUNCTION :"JUNCTION" , - EN_RESERVOIR :"RESERVOIR", - EN_TANK :"TANK" } +TYPENODE = {EN_JUNCTION: "JUNCTION", + EN_RESERVOIR: "RESERVOIR", + EN_TANK: "TANK"} # Constants for controls -TYPECONTROL= { EN_LOWLEVEL :"LOWLEVEL" , - EN_HILEVEL :"HIGHLEVEL" , - EN_TIMER :"TIMER" , - EN_TIMEOFDAY :"TIMEOFDAY"} +TYPECONTROL = {EN_LOWLEVEL: "LOWLEVEL", + EN_HILEVEL: "HIGHLEVEL", + EN_TIMER: "TIMER", + EN_TIMEOFDAY: "TIMEOFDAY"} # Constants for mixing models -TYPEMIXMODEL= { EN_MIX1 :"MIX1" , - EN_MIX2 :"MIX2" , - EN_FIFO :"FIFO" , - EN_LIFO :"LIFO" } +TYPEMIXMODEL = {EN_MIX1: "MIX1", + EN_MIX2: "MIX2", + EN_FIFO: "FIFO", + EN_LIFO: "LIFO"} # Constants for quality -TYPEQUALITY= { EN_NONE :"NONE" , - EN_CHEM :"CHEM" , - EN_AGE :"AGE" , - EN_TRACE :"TRACE"} +TYPEQUALITY = {EN_NONE: "NONE", + EN_CHEM: "CHEM", + EN_AGE: "AGE", + EN_TRACE: "TRACE"} # Constants for sources -TYPESOURCE= { EN_CONCEN :"CONCEN" , - EN_MASS :"MASS" , - EN_SETPOINT :"SETPOINT" , - EN_FLOWPACED :"FLOWPACED"} +TYPESOURCE = {EN_CONCEN: "CONCEN", + EN_MASS: "MASS", + EN_SETPOINT: "SETPOINT", + EN_FLOWPACED: "FLOWPACED"} # Constants for statistics -TYPESTATS= { EN_NONE :"NONE" , - EN_AVERAGE :"AVERAGE", - EN_MINIMUM :"MINIMUM", - EN_MAXIMUM :"MAXIMUM", - EN_RANGE :"RANGE" } \ No newline at end of file +TYPESTATS = {EN_NONE: "NONE", + EN_AVERAGE: "AVERAGE", + EN_MINIMUM: "MINIMUM", + EN_MAXIMUM: "MAXIMUM", + EN_RANGE: "RANGE"} diff --git a/resources.qrc b/resources.qrc index a1ec099..ceeccc9 100644 --- a/resources.qrc +++ b/resources.qrc @@ -1,5 +1,6 @@ impepanet.png + expepanet.png diff --git a/resources_rc.py b/resources_rc.py index 239e036..5b8eb75 100644 --- a/resources_rc.py +++ b/resources_rc.py @@ -2,135 +2,61 @@ # Resource object code # -# Created: Wed 2. Mar 22:15:19 2016 -# by: The Resource Compiler for PyQt (Qt v4.8.5) +# Created: Sat 14. Apr 15:18:21 2018 +# by: The Resource Compiler for PyQt (Qt v4.8.6) # # WARNING! All changes made in this file will be lost! from PyQt4 import QtCore qt_resource_data = "\ -\x00\x00\x07\x6d\ +\x00\x00\x01\x3f\ +\x89\ +\x50\x4e\x47\x0d\x0a\x1a\x0a\x00\x00\x00\x0d\x49\x48\x44\x52\x00\ +\x00\x00\x34\x00\x00\x00\x32\x08\x06\x00\x00\x00\x13\x21\xf8\xf6\ +\x00\x00\x00\x04\x67\x41\x4d\x41\x00\x00\xb1\x8f\x0b\xfc\x61\x05\ +\x00\x00\x00\x09\x70\x48\x59\x73\x00\x00\x0e\xc4\x00\x00\x0e\xc4\ +\x01\x95\x2b\x0e\x1b\x00\x00\x00\xe1\x49\x44\x41\x54\x68\x43\xed\ +\xd8\xc1\x0e\x82\x40\x0c\x84\xe1\xc5\x13\xef\xff\xc2\x08\x09\xbd\ +\x28\x1b\xda\xed\x74\x19\xcd\xfc\x17\x3d\x98\x6d\x3f\x05\x63\x5c\ +\x5a\xdb\xb6\xe6\xc8\xf7\xaa\x7e\x8b\x7b\x52\xbf\xe3\x8c\xbb\x5e\ +\xe7\x63\x69\xb6\x88\x67\xa1\x6c\xe5\xa0\x4f\x44\x35\xaa\x14\xd4\ +\x5b\xbe\x12\x55\x06\xba\x5b\xba\x0a\xb5\x1f\xfb\x7d\xab\xce\xb8\ +\x79\xad\xcc\xac\xab\x39\xf0\x4f\x28\xfa\xce\xa3\x3f\x29\x28\x68\ +\x74\x39\x24\x0a\x06\xca\x2e\x85\x42\x41\x40\xa8\x65\x10\xe7\xa4\ +\x41\xc8\xcb\xe5\x28\x7b\x5e\x0a\x84\xc6\x58\x99\x73\x87\x41\x55\ +\x18\x6b\xf4\xfc\x21\x50\x35\xc6\x1a\x99\x13\x06\xcd\xc2\x58\xd1\ +\x79\x21\xd0\x6c\x8c\x15\x99\xeb\x06\x3d\x85\xb1\xbc\xf3\xf7\x97\ +\xe9\xb7\x1c\x75\x02\xb1\x27\x10\x7b\x02\xb1\x27\x10\x7b\x02\xb1\ +\x27\x10\x7b\x02\xb1\x27\x10\x7b\x02\xb1\x27\x10\x7b\x65\xa0\x75\ +\x3d\x9f\x4c\x4e\x7f\x63\xb1\x27\x10\x7b\x7f\x07\xba\xfc\x52\xf8\ +\xe5\x74\xc9\xb1\x27\x10\x77\xad\xbd\x01\xb3\x1a\x1a\xa2\x3e\xed\ +\xec\x08\x00\x00\x00\x00\x49\x45\x4e\x44\xae\x42\x60\x82\ +\x00\x00\x01\x69\ \x89\ \x50\x4e\x47\x0d\x0a\x1a\x0a\x00\x00\x00\x0d\x49\x48\x44\x52\x00\ \x00\x00\x34\x00\x00\x00\x32\x08\x06\x00\x00\x00\x13\x21\xf8\xf6\ \x00\x00\x00\x01\x73\x52\x47\x42\x00\xae\xce\x1c\xe9\x00\x00\x00\ \x04\x67\x41\x4d\x41\x00\x00\xb1\x8f\x0b\xfc\x61\x05\x00\x00\x00\ \x09\x70\x48\x59\x73\x00\x00\x0e\xc4\x00\x00\x0e\xc4\x01\x95\x2b\ -\x0e\x1b\x00\x00\x07\x02\x49\x44\x41\x54\x68\x43\xed\x99\x09\x88\ -\x95\x55\x14\xc7\xff\xdf\x9b\x37\xe3\x92\x69\x6e\x63\x9a\x25\x64\ -\x56\x90\x2d\x96\xb6\x60\x19\x91\x5a\x24\xa5\x48\x43\x58\x49\x45\ -\x21\x52\x12\x44\xd8\x82\x2d\x56\x94\x85\x45\x49\x45\x90\x65\xb9\ -\x64\x51\x66\x66\xb6\x63\x49\x92\x96\x66\xa5\x95\x89\x4b\x1b\xe6\ -\xa4\x93\x3a\x9b\xb3\xcf\xdc\x7e\xe7\xbd\xf7\x8d\xdf\x3c\xc7\x79\ -\x5b\xf3\xe6\x25\xfd\xe1\xbc\xbb\xdf\x7b\xfe\x77\x39\xf7\xdc\xef\ -\x79\x0e\x28\x45\xbc\xf9\xa9\xf4\xc2\xdb\x52\x28\xe4\xe4\x79\xb1\ -\xcc\x0e\x82\x29\xdf\xd0\x20\x9d\x75\xb2\xa7\x39\x77\x4a\x29\x13\ -\xfa\x70\x8d\x74\xc5\x04\x22\xfd\x91\x0e\x26\xd3\x0c\x63\x50\x21\ -\x4d\xba\x36\x0d\x42\x53\x1e\x93\xe6\x2e\x22\xd2\x2d\x9a\xce\x19\ -\x34\x4a\x7d\xfb\xb0\x6b\x62\xc9\xa4\x11\xce\xe3\x27\x57\x56\x26\ -\x0e\x61\xd8\xa4\x4c\x28\xa7\xc1\x44\x1f\x59\x84\x40\x66\x84\x72\ -\x70\xeb\xa5\x4c\x28\xe4\xb7\x70\x35\x58\x96\x75\x89\x49\x59\x79\ -\x16\x89\x37\x13\xaa\xac\x92\xca\x0f\xa0\x63\x1b\x62\xa8\xad\xe3\ -\xc7\x14\xcc\xeb\x2c\xed\x5f\x22\xd5\xfd\x4d\xe6\x6f\x52\xcd\x0e\ -\xa9\xa9\x52\x3a\xf0\x4d\xb4\xd7\xaa\x6f\x49\x63\x7a\xaa\x7f\x96\ -\x4a\x9e\x23\xdc\x65\xcd\xdb\x15\x76\x27\x46\xcc\x76\xa7\x91\xe8\ -\xb5\x93\x1c\xb3\x60\x89\x70\x14\x02\x97\x48\xdd\x9d\xb3\x08\xbb\ -\x40\xa0\x53\x54\xaa\x50\x7e\xe0\x6c\x69\xfb\x68\xe9\x84\xa5\xd2\ -\xde\xa7\xc9\xef\x4a\x1d\x6e\x86\xde\x77\x05\xa6\xaf\x1d\xc0\xdc\ -\x0d\xe4\x6e\x0c\xdd\xfe\xa4\x53\x5d\x09\x19\x85\x48\xef\x24\xc4\ -\xc8\xd8\x0a\x35\x35\x11\x86\xb1\x95\x7d\x51\xb8\x07\x3d\x71\x31\ -\x85\x8f\x61\x29\xd7\x4a\x83\x5e\x26\x5c\x2e\xf5\xe2\xa6\xcb\xeb\ -\x25\x75\x1f\x1b\x5d\xc5\x76\x46\x13\xf3\xe6\x5d\x7b\x9f\x73\x8b\ -\x97\x91\x62\xa2\x23\x48\xe6\x9a\xf5\xcf\x84\xbf\xa2\xd6\xc6\x66\ -\xbf\x64\x3e\xca\x5f\x07\x31\x88\x1a\x82\x67\xc7\xef\xd7\x42\x3f\ -\xdf\xcf\xb3\x74\x32\xe3\x1a\x82\x75\x83\x71\x56\x68\x40\x3f\xd4\ -\xc8\x0b\x6e\x33\x2b\xac\x45\x38\x16\x87\x15\x6c\x41\x14\x38\x50\ -\x65\xeb\x39\x78\x48\xcd\x9f\xc4\x31\x10\x3d\x6f\x88\x92\x69\xa2\ -\xcc\xfa\xaa\xf8\x2e\x4a\xb4\x82\x3a\xd5\x5b\x39\xa8\xd4\xa9\x2b\ -\x26\xe4\x9c\x55\x6e\x90\xea\xf7\x51\xb7\x9c\x73\xf7\x53\x4b\xf2\ -\xf1\xf0\xb7\x6a\xcd\x96\x68\x5f\x0d\xb4\xab\xde\x1c\xed\x23\xd0\ -\xce\x86\x6c\xb9\xab\x21\x33\x7e\xac\x53\xfd\x36\xa7\x3d\xdf\x1e\ -\x2a\xb5\x5b\x9d\x6e\x2a\xa2\x19\x06\x44\x21\x14\x2f\x7b\x17\x17\ -\x68\x04\x24\xd8\x87\x15\xdf\x4b\x3b\xd8\x62\x05\x94\x6d\x1f\x2f\ -\xe5\x13\x56\xbc\x2f\xfd\xf5\x0e\x2b\xc9\x5e\x3d\xf0\x09\xdb\xf5\ -\x5c\x32\xeb\x09\x07\x4b\xa5\x9f\x93\xcf\xf9\xca\xef\xce\x59\x5b\ -\x00\xd1\xdd\x8c\xff\x07\x04\xab\xe9\x7f\x23\x4a\x73\x0e\xea\x4d\ -\xc8\x2f\x9e\xc3\x18\x34\x2d\x67\xbc\x4e\x43\x59\x0d\x2c\x54\x98\ -\x33\x52\xf1\x15\x99\xa0\xe6\xf7\x08\x31\xcf\x73\x71\x84\x38\x16\ -\x9d\x0b\x3c\x26\xd9\x53\xdf\x9e\x87\x4a\x41\xbe\xa7\xae\x5d\x68\ -\xe9\x2f\xb3\x63\xf0\x72\x66\xbd\x00\x85\xab\x37\x71\x2a\x31\x12\ -\x65\xcc\x5c\x2f\x08\xfd\xfd\xb5\xd4\xe3\x1a\x46\x41\xa1\xd2\x2f\ -\x51\x80\xf3\x55\xb9\x9a\x36\x30\x0e\x73\xe6\x4c\x03\x9b\x08\x83\ -\x11\xde\x37\x0f\x05\xf1\x7c\x77\xdd\x8f\xd2\x28\x5b\xfc\x28\x24\ -\xf1\x38\x4b\x21\x61\x16\xd5\x60\xe7\xd4\x26\xa9\xe0\x78\xf2\x31\ -\x3a\x46\x6a\xcf\x8b\xe4\xad\x8c\x74\xe7\x9c\x17\x47\x08\xd8\xc1\ -\x6a\x0b\x66\x0b\x22\xb0\x7a\x1e\xb3\x1b\xc6\xec\x95\xae\xe2\x0c\ -\x32\x73\xdd\x06\xb1\x12\x3f\x4a\xfd\xa6\x40\x0c\x93\x5e\x63\xf1\ -\xa9\x28\x08\x99\x46\x36\x79\x08\xc5\xea\x7e\x65\xf6\xd9\xbb\x5e\ -\x6c\xaf\x37\x60\xea\x2d\x3f\x7c\x1c\x21\xcb\x6a\x46\xa6\x92\xad\ -\x75\xec\x74\xda\xb3\xea\x21\xda\x9a\xa5\xb4\xf1\x1c\x7d\x74\x1d\ -\x45\x9a\x44\xe8\x68\xd2\xb4\x0d\x13\xe6\x33\x6e\x0c\xde\xe4\x07\ -\x9d\x5b\xc8\xdb\x26\x62\x14\xd8\x4a\x45\x57\xf2\xde\x61\xa2\x0f\ -\x87\x5b\x9f\xe0\x2d\xc4\x0e\x89\x98\x6f\x9b\x0e\x7f\x02\x6c\x2f\ -\x1b\x59\x0b\x2d\xcf\x2f\x33\xb1\xbc\x20\xfc\x72\x7f\x72\xfc\x69\ -\xb5\xb0\xf8\x79\xa9\xcf\x6d\x07\xf3\xfc\xfe\xfc\x7e\x2c\x34\x58\ -\x3c\x98\xe6\xd8\xf6\x37\xa3\x10\x4b\xa6\x07\x53\xc8\x1f\x2c\xb8\ -\x72\x06\xbf\xcc\xe0\xd7\xf1\xc5\xe0\xd7\x37\x58\xdc\x04\xa5\x54\ -\x08\x99\x20\x89\xf8\x7e\x7c\x04\xcb\x02\xf9\x99\x11\x6a\x0f\x04\ -\x95\x4e\x03\xb9\x47\x28\x43\xfc\x4f\xa8\xd9\xca\xe5\x20\x9a\x5c\ -\xfc\x3d\x94\x04\x7a\x62\xa9\x65\x1e\x77\x86\x7b\xfd\x5f\x07\x16\ -\xbd\x1b\xd6\x3f\x65\x42\xb3\x30\x42\x32\x52\xdc\x97\xad\xba\x46\ -\x41\xc1\xab\x39\x04\x36\x11\x7b\x91\xd6\xea\xfb\x12\xbf\x0b\xb8\ -\x6e\x5a\xad\xe7\x8b\x39\xd7\x7b\xa4\x85\x0f\x79\xa9\xdf\x43\x3e\ -\x7e\xd8\xee\x58\x62\x3a\x88\xa5\xe3\x51\xc0\x1d\xb9\x81\xd7\xc4\ -\xf5\x77\x90\xb0\x09\x30\x18\x19\xc6\xd8\xf6\x11\x8e\x05\x6e\x56\ -\x6b\xdf\x9b\x0a\x71\xce\xfb\x8f\x21\x62\x53\x6d\x02\x99\xc7\xef\ -\x96\x26\x5e\x12\x6d\xd3\x1a\x1a\x58\x9d\x33\x87\xe0\x50\xd8\x5d\ -\x6d\x84\x34\x14\x19\x81\x9c\xe6\x5c\xd1\x3d\xf6\x42\xfa\x77\xb0\ -\x71\x2b\x7d\x9e\x18\xeb\xdb\x64\x38\x32\x24\x56\xd8\x06\x74\x16\ -\x72\x4e\xac\x0d\xf5\xdf\x5a\x19\x2b\x48\x02\x29\x6f\xb9\x54\x10\ -\x99\xd1\x74\x46\x88\x5b\xb9\x7a\xbb\x70\x93\x44\x46\x84\x76\xe3\ -\xc5\xb7\x0e\xa7\x25\xf8\x8b\xe7\x4f\x24\x6a\x7e\x68\x16\x91\x26\ -\x21\xa7\xd7\x3f\xc6\x7f\xc4\x77\x7a\xe4\xa5\x58\x56\x00\x57\xdd\ -\xe9\xa9\xe8\x26\x22\x76\x76\xe2\x47\x30\x0b\x19\xbf\x04\xf1\x48\ -\x50\xdc\x16\xd2\x24\xe4\x69\xea\xe3\x04\x38\xd8\x0f\xcc\x74\xda\ -\xc2\x73\xc4\xb0\x1b\xeb\x15\x3e\xdf\xe9\x3d\x3c\x7c\x41\xb6\x45\ -\xef\xa6\x24\x16\x69\xf8\x28\x8b\x1c\xce\x94\x64\x8e\xb4\x08\xad\ -\xe3\x81\x59\xfe\x0b\x11\x7b\x74\x15\x7a\x1a\x7a\x8d\xd3\xfc\x15\ -\x4e\xc7\x9e\xcd\x75\x50\x8b\xb2\xb6\x32\x41\x9d\xed\x0c\xfc\x25\ -\x3d\x3c\x43\x5a\xbf\xa0\xfd\xc8\x18\xd2\x22\x64\x4f\x08\xf1\x4c\ -\x89\x28\x0d\xa9\xc6\x7a\x4f\x37\x4e\x27\x61\x1f\x5a\xec\xa5\xea\ -\xc3\x16\xc3\xee\x10\xc2\x6d\x6b\x9c\xee\xbf\x25\x92\x9b\x18\x19\ -\x70\x4e\x99\x50\x19\x8f\xc8\x0d\x9f\x11\xb1\xa7\xb6\x0f\xb3\xff\ -\xbc\xb3\x5a\x28\x62\x2f\x45\x2e\xbb\x8b\x46\xc2\xe7\x3b\xe9\xa4\ -\xe3\xdb\x77\x65\x7c\xa4\x4c\x68\xda\x6c\x7e\x62\x2f\xe8\xc3\xc2\ -\x0e\x7e\x89\xa7\xb9\x73\x9c\xbe\x98\x1b\xcd\xca\x16\x52\x24\xe4\ -\xb4\xc8\xfe\x1b\xf2\x3f\x79\xb5\x86\x7a\x69\xc0\x00\xce\xff\x26\ -\xe9\x96\x09\xd9\x59\x95\x20\x52\x22\xf4\xd8\x2b\xfc\xd8\x19\x69\ -\xab\x15\x06\x60\xd4\x30\xa9\x77\x0f\x3b\x40\xd9\x47\x4a\x84\x66\ -\x3c\xcb\x8c\x27\xfa\xe7\x0e\x8f\xf7\x8d\xd7\xa4\x79\xcb\xb3\xbf\ -\x3a\x86\xa4\x09\xbd\xb3\x8a\x19\x2f\x23\x92\xa8\x85\xf1\xe8\x23\ -\xdd\x3c\x4d\xfa\xd3\xbc\xe0\x2c\x23\x69\x42\xd3\x66\xa3\xa9\x59\ -\x32\x83\xed\x26\x73\xf1\xf1\x72\x23\x06\xa0\x1a\x31\xf3\x5c\x4e\ -\xc1\x7e\x42\x73\x89\x20\xbf\x76\x23\x61\x3a\xc8\x60\xb7\x26\x45\ -\xa8\x06\xa5\x77\xad\x22\x62\x4a\x47\xde\x32\x8c\x48\x3c\x8f\xf3\ -\x34\x64\xb0\x34\xee\x52\xa7\xdb\x70\x75\x9e\x99\xe9\x69\xc5\xab\ -\xd2\xe6\x95\x2e\xf2\xb5\xf6\xea\xd1\xd6\x3a\xcb\x48\xf6\xf9\xb0\ -\x62\xb5\x73\xcb\x56\x39\xb7\xe5\xb7\x26\x57\x5d\xcb\x63\xb7\x1d\ -\xa1\x33\x90\xc0\xf3\x61\xf1\xc7\xb1\x82\x24\x90\xf4\x96\x1b\x77\ -\xa1\x34\xfe\x62\xe9\x94\x41\x5e\xe4\x73\x71\xbb\x22\x83\xee\x93\ -\x26\xf4\x5f\xc1\x91\x4f\xc8\xbe\x05\x74\x38\x32\xd8\x72\x2d\x3f\ -\x92\xe0\xb6\x9c\x7a\x92\x74\xdd\xe5\x52\x55\xf3\x1f\x5b\xd9\x45\ -\xf7\xa3\xa4\x7b\x9f\x25\x62\x53\x6d\xc4\x4a\xa5\xc5\xcf\x49\x93\ -\xc6\x5a\x69\x62\x78\x93\x1f\x80\xd0\x52\x62\xbe\x7f\x06\xa9\x83\ -\xff\xd2\x75\x10\xcc\x1b\xf1\x57\xc9\x08\x41\x70\xd2\x65\xb1\x74\ -\x02\x84\xec\x13\x50\x0b\xd8\x96\xb3\x0b\xb4\x23\x25\xb8\xe5\xb8\ -\xf2\x1a\x53\xf8\x5a\x1b\x1a\x35\x8c\x16\x76\xb3\xdb\x17\x9a\x5c\ -\x13\xdb\x29\x78\x1c\x63\xce\x23\x4c\x12\x9e\x73\x4d\xee\x29\x9e\ -\x04\x1f\xac\xf1\x94\x6f\x4f\xea\x1c\x01\x57\x6a\x04\x33\xa7\x48\ -\x17\x9c\x1e\x8d\x27\x86\xf4\x0f\x8c\x8b\xdf\xec\xde\x57\xb8\x49\ -\x00\x00\x00\x00\x49\x45\x4e\x44\xae\x42\x60\x82\ +\x0e\x1b\x00\x00\x00\xfe\x49\x44\x41\x54\x68\x43\xed\xd8\xcb\x0e\ +\xc2\x30\x0c\x44\xd1\x94\x55\xff\xff\x87\x0b\xa3\x96\x4d\x94\x0a\ +\x3f\xc6\xc1\x04\x1f\x09\xc1\x02\x25\xbe\x40\x2b\x91\xad\xb5\xe3\ +\x68\x02\xb2\x77\x9d\xb6\xd7\xaa\x52\xec\x75\x1f\xd7\xf3\x32\x2a\ +\x28\xbb\xff\x08\xc2\x85\xda\x3f\xd8\xf6\xfd\x7a\xa1\x20\x99\x69\ +\x78\x97\xbb\x7b\xb3\x54\xd4\x5d\xae\x37\xda\xa7\xae\xa1\xec\x2a\ +\x28\xbb\x0a\xca\xae\x82\xb2\xab\xa0\xec\x2a\x28\xbb\x0a\xca\xae\ +\x82\xb2\xab\xa0\xec\x2a\x28\xbb\xe5\x82\xc4\xa7\x3e\x9a\x93\x9c\ +\x28\xfd\x5c\xae\x53\x1f\xef\xd1\x96\x97\x74\x7f\xd5\x4f\xee\x5b\ +\x51\x9a\x7d\xd5\xd7\xd0\xec\x28\xed\x7e\xa6\x9b\xc2\xac\x28\xcb\ +\x3e\xe6\xbb\x5c\x74\x94\x75\x7d\x73\x10\x44\x45\x79\xd6\x75\x05\ +\x01\x3b\xca\xbb\x9e\x3b\x08\x58\x51\x8c\x75\x28\x41\xe0\x1d\x86\ +\xf5\xa1\xd0\x82\xc0\x3a\x14\x2b\x06\xa8\x41\xa0\x1d\x8e\x19\x03\ +\xf4\x20\x90\x0e\xc9\x8e\x81\x90\x20\xf8\x34\x6c\x44\x0c\x84\x05\ +\xc1\xdd\xd0\x51\x31\x10\x1a\x04\xfd\xf0\x91\x31\x10\x1e\x04\xef\ +\x88\xe8\x18\x18\xfe\xc1\xfb\x65\x53\xbe\xa1\x99\x2a\x28\xbb\xc5\ +\x82\x5a\x7b\x02\x62\x14\x66\x17\xaf\xab\xd7\x21\x00\x00\x00\x00\ +\x49\x45\x4e\x44\xae\x42\x60\x82\ " qt_resource_name = "\ @@ -144,6 +70,10 @@ \x00\x6d\x00\x70\x00\x6f\x00\x72\x00\x74\x00\x45\x00\x70\x00\x61\x00\x6e\x00\x65\x00\x74\x00\x49\x00\x6e\x00\x70\x00\x46\x00\x69\ \x00\x6c\x00\x65\x00\x73\ \x00\x0d\ +\x0d\x2a\xda\xe7\ +\x00\x65\ +\x00\x78\x00\x70\x00\x65\x00\x70\x00\x61\x00\x6e\x00\x65\x00\x74\x00\x2e\x00\x70\x00\x6e\x00\x67\ +\x00\x0d\ \x04\x4a\xda\x07\ \x00\x69\ \x00\x6d\x00\x70\x00\x65\x00\x70\x00\x61\x00\x6e\x00\x65\x00\x74\x00\x2e\x00\x70\x00\x6e\x00\x67\ @@ -152,7 +82,8 @@ qt_resource_struct = "\ \x00\x00\x00\x00\x00\x02\x00\x00\x00\x01\x00\x00\x00\x01\ \x00\x00\x00\x00\x00\x02\x00\x00\x00\x01\x00\x00\x00\x02\ -\x00\x00\x00\x14\x00\x02\x00\x00\x00\x01\x00\x00\x00\x03\ +\x00\x00\x00\x14\x00\x02\x00\x00\x00\x02\x00\x00\x00\x03\ +\x00\x00\x00\x62\x00\x00\x00\x00\x00\x01\x00\x00\x01\x43\ \x00\x00\x00\x42\x00\x00\x00\x00\x00\x01\x00\x00\x00\x00\ "