コード例 #1
0
ファイル: moduleHEC2DXF.py プロジェクト: rfleissner/ChEsher
    def create(self):
        info = "Input data:\n"
        
        try:
            self.readSDF(self.ui.lineEditInputSDF.text())
            info += " - Reach:\t\t\t\t{0}\n".format(self.REACH_ID)
            info += " - Number of cross sections:\t\t{0}\n".format(self.NUMBER_OF_CROSS_SECTIONS)
            info += " - Number of water surface profiles:\t{0}\n".format(self.NUMBER_OF_PROFILES)
        except:
            QMessageBox.critical(self.widget, "Error", "Not able to load GIS data file!\nCheck filename or content!")
            return
        
        from shapely.geometry import LineString
        
        reachStation = {}
        profileStation = {}
        bottom = {}
        
        profileStation_ = po.determineFlowDirection(self.nodReach, self.nodProfiles, self.proProfiles)[2]

        for pID in range(len(self.CROSS_SECTIONS["SURFACE_LINE"]["x"])):
            
            d = []
            x_ = []
            y_ = []
            z_ = []
            x_.append(self.CROSS_SECTIONS["SURFACE_LINE"]["x"][pID][0])
            y_.append(self.CROSS_SECTIONS["SURFACE_LINE"]["y"][pID][0])
            z_.append(self.CROSS_SECTIONS["SURFACE_LINE"]["z"][pID][0])            
            d.append(0.0)
            
            totLen = 0.0
            for nID in range(len(self.CROSS_SECTIONS["SURFACE_LINE"]["x"][pID])-1):
                xi = self.CROSS_SECTIONS["SURFACE_LINE"]["x"][pID][nID]
                xj = self.CROSS_SECTIONS["SURFACE_LINE"]["x"][pID][nID+1]
                yi = self.CROSS_SECTIONS["SURFACE_LINE"]["y"][pID][nID]
                yj = self.CROSS_SECTIONS["SURFACE_LINE"]["y"][pID][nID+1]

                profile_line = LineString([(xi, yi), (xj, yj)])
                totLen += profile_line.length
                if profile_line.length >= 0.005:
                    d.append(totLen)
                    x_.append(self.CROSS_SECTIONS["SURFACE_LINE"]["x"][pID][nID+1])
                    y_.append(self.CROSS_SECTIONS["SURFACE_LINE"]["y"][pID][nID+1])
                    z_.append(self.CROSS_SECTIONS["SURFACE_LINE"]["z"][pID][nID+1])

            x = np.array(x_)
            y = np.array(y_)
            z = np.array(z_)
            
            reachStation[self.CROSS_SECTIONS["PROFILE_ID"][pID]] = self.CROSS_SECTIONS["STATION"][pID]
            profileStation[self.CROSS_SECTIONS["PROFILE_ID"][pID]] = profileStation_[pID+1]
            bottom[self.CROSS_SECTIONS["PROFILE_ID"][pID]] = [x, y, z, d]

        scale = self.ui.spinBoxScale.value()
        superelevation = self.ui.doubleSpinBoxSuperelevation.value()
        
        info += "\nOutput data:\n"
             
        try:
            cs = ProfileWriter(self.ui.lineEditOutputDXF.text(),\
                bottom,
                reachStation,
                profileStation,
                scale,
                superelevation,
                self.settings,
                self.REACH_ID)   

            cs.drawBottom()
            cs.draw1dResults(self.PROFILE_NAMES, self.CROSS_SECTIONS["WATER_ELEVATION"], self.CROSS_SECTIONS["LEVEE_POSITIONS"])
            cs.saveDXF()    
            
            info += " - DXF file written to {0}.\n".format(self.ui.lineEditOutputDXF.text())
    
        except:
            info += " - ERROR: Not able to write profiles!\n"

        QMessageBox.information(self.widget, "Module HEC2DXF", info)        
コード例 #2
0
    def create(self):
    
        info = "Input data:\n"

        try:
            self.nodProfiles, self.proProfiles = fh.readI2S(self.ui.lineEditInputProfiles.text())
            info += " - Profiles:\t\t\t{0}\n".format(len(self.proProfiles))
        except:
            QMessageBox.critical(self.widget, "Error", "Not able to load profiles file!\nCheck filename or content!")
            return
        try:
            self.nodReach = fh.readI2S(self.ui.lineEditInputReach.text())[0]
            info += " - Reach nodes:\t\t{0}\n".format(len(self.nodReach))
        except:
            QMessageBox.critical(self.widget, "Error", "Not able to load reach file!\nCheck filename or content!")
            return
        try:
            rows = self.ui.tableWidget.rowCount()
            for row in range(rows):
                self.ui.tableWidget.item(row, 0).text()
                self.ui.tableWidget.item(row, 1).text()
                str(self.ui.tableWidget.item(row, 2).text()).split(",")[2]
            info += " - Water surface results:\t{0}\n".format(rows)
        except:
            QMessageBox.critical(self.widget, "Error", "Check filename, surface name and colour!")
            return            
                
        self.proArranged, self.reachStation, self.profileStation, direction = po.determineFlowDirection(self.nodReach, self.nodProfiles, self.proProfiles)

        info += "\nFlow direction:\n"
        for pID_Arranged in direction:
            info += ' - Profile {0}:\t{1}\n'.format(pID_Arranged, direction[pID_Arranged])


        # create bottom cross sections
        try:
            bottom = fh.readT3StoShapely(self.ui.lineEditInputBottom.text())
            bottomCrossSections = self.getCrossSections(bottom)
        except:
            QMessageBox.critical(self.widget, "Error", "Not able to interpolate bottom profile!")
            return
        
        
        # create water surface cross sections
        try:        
            rows = self.ui.tableWidget.rowCount()
            wsCrossSections = {}
            colRGB = {}
            if rows > 0:
                for row in range(rows):
                    filename = self.ui.tableWidget.item(row, 0).text()
                    name = self.ui.tableWidget.item(row, 1).text()
                    watersurface = fh.readT3StoShapely(filename)
                    wsCrossSections[name] = self.getCrossSections(watersurface)
                    col = Colour(str(self.ui.tableWidget.item(row, 2).text()).split(","))
                    col.create()
                    colRGB[name] = col.getRGB()
        except:
            QMessageBox.critical(self.widget, "Error", "Not able to interpolate water surface profiles!")
            return
        
        scale = self.ui.spinBoxScale.value()
        superelevation = self.ui.doubleSpinBoxSuperelevation.value()
        
        info += "\nOutput data:\n"
        
        if self.ui.checkBoxOutputProfiles.isChecked():             
            try:        
                cs = ProfileWriter(self.ui.lineEditOutputProfiles.text(),\
                    bottomCrossSections,
                    self.reachStation,
                    self.profileStation,
                    scale,
                    superelevation,
                    self.settings,
                    self.ui.lineEditInputReachName.text())

                cs.drawBottom()
                cs.drawWaterSurface(wsCrossSections, colRGB)
                cs.saveDXF()

                info += " - DXF file written to {0}.\n".format(self.ui.lineEditOutputProfiles.text())
            except:
                info += " - ERROR: Not able to write profiles!\n"

        QMessageBox.information(self.widget, "Module ProfilesDXF", info)     
コード例 #3
0
    def create(self):
        info = "Input data:\n"

        try:
            self.nodProfiles, self.proProfiles = fh.readI2S(self.ui.lineEditInputProfiles.text())
            info += " - Profiles:\t\t\t{0}\n".format(len(self.proProfiles))
        except:
            QMessageBox.critical(self.widget, "Error", "Not able to load profiles file!\nCheck filename or content!")
            return
        try:
            self.nodReach = fh.readI2S(self.ui.lineEditInputReach.text())[0]
            info += " - Reach nodes:\t\t{0}\n".format(len(self.nodReach))
        except:
            QMessageBox.critical(self.widget, "Error", "Not able to load reach file!\nCheck filename or content!")
            return
        try:
            self.points = fh.readXYZ(self.ui.lineEditInputPoints.text())
            info += " - Points:\t\t\t{0}\n".format(len(self.points))
        except:
            QMessageBox.critical(self.widget, "Error", "Not able to load points file!\nCheck filename or content!")
            return

        self.proArranged, self.reachStation, self.profileStation, direction = po.determineFlowDirection(self.nodReach, self.nodProfiles, self.proProfiles)
        
        info += "\nProfile information:\n"
        for pID_Arranged in direction:
            info += ' - Profile {0}:\tFlow direction: {1}\tStation: {2}\t\n'.format(pID_Arranged, direction[pID_Arranged], round(self.reachStation[pID_Arranged], 2))

        self.pointsNormalized, self.segmentStation = self.normalizeProfiles()

        info += "\nOutput data:\n"
                    
        if self.ui.checkBoxOutputTextfile.isChecked():
            try:
                self.writeTXT()
                info += " - Textfile written to {0}.\n".format(self.ui.lineEditOutputTextfile.text())
            except:
                info += " - ERROR: Not able to write textfile!\n"

        if self.ui.checkBoxOutputDXF.isChecked():

            scale = self.ui.spinBoxScale.value()
            superelevation = self.ui.doubleSpinBoxSuperelevation.value()
            
            try:
                cs = ProfileWriter(self.ui.lineEditOutputDXF.text(),\
                    self.pointsNormalized,
                    self.reachStation,
                    self.profileStation,
                    scale,
                    superelevation,
                    self.settings,
                    self.ui.lineEditInputReachName.text())

                cs.drawBottom()
                cs.saveDXF()
                info += " - DXF file written to {0}.\n".format(self.ui.lineEditOutputDXF.text())
            except:
                info += " - ERROR: Not able to write DXF file!\n"

        if self.ui.checkBoxOutputHECRAS.isChecked():
            self.writeGEO()
            try:
                self.writeGEO()
                info += " - GEO file written to {0}.\n".format(self.ui.lineEditOutputHECRAS.text())
            except:
                info += " - ERROR: Not able to write geo file!\n"

        QMessageBox.information(self.widget, "Module XYZ2Profiles", info)