Exemplo n.º 1
0
    def __init__(self, main_form, *args):
        QDialog.__init__(self, main_form)
        #self.helper = HelpHandler(self)
        #self.help_topic = "epanet/src/src/Register.htm"
        self.ui = Ui_frmTranslateCoordinatesDesigner()
        self.ui.setupUi(self)
        self.setModal(0)
        # self.cmdOK.clicked.connect(self.cmdOK_Clicked)
        # self.cmdCancel.clicked.connect(self.cmdCancel_Clicked)
        # self.toolButton.clicked.connect(self.toolButton_Clicked)
        self.ui.btnTranslate.clicked.connect(self.translate)
        self.ui.btnCancel.clicked.connect(self.cancel)
        self.ui.btnSelectCRS.clicked.connect(self.set_dst_crs)
        self.msg = ""
        self.model_layers = []
        self.pt_src_ll = Coordinate()
        self.pt_src_ur = Coordinate()
        self.pt_dst_ll = None
        self.pt_dst_ur = None
        if not args or len(args) < 2:
            self.msg = "Not enough coordinate information."
        else:
            self.set_coords_source_ll(args[0])
            self.set_coords_source_ur(args[1])

        # need to load table with selected file names
        self.GISDataFiles = {}
        self.file_filter = "Shapefile (*.shp);;All files (*.*)"
        self.data_path = ""
        if args:
            self.file_filter = args[0]
            if len(args) > 1:
                self.GISDataFiles = args[1]
        self._main_form = main_form
        self.model_map_crs_name = ""
        self.model_map_crs_unit = ""
        self.destination_crs_name = ""
        self.destination_crs_unit = ""
        self.set_from()
        def update_centroidlinks(self, geom):
            from qgis.core import QgsGeometry, QGis, QgsPoint
            feature_name = self.feature.attributes()[0]
            for section_field_name in self.session.section_types.values():
                try:
                    object = None
                    if self.layer == self.session.model_layers.layer_by_name(
                            section_field_name):
                        section = getattr(self.session.project,
                                          section_field_name)
                        object = section.value[feature_name]
                        if section_field_name != "subcatchments":
                            if hasattr(object, "vertices"):
                                del object.vertices[:]
                                for v in geom.asPolyline():
                                    coord = Coordinate()
                                    coord.x = v.x()
                                    coord.y = v.y()
                                    object.vertices.append(coord)
                    if object is not None and hasattr(object, "centroid"):
                        new_c_g = geom.centroid()
                        new_c = new_c_g.asPoint()
                        object.centroid.x = str(new_c.x)
                        object.centroid.y = str(new_c.y)
                        for fc in self.subcentroids.getFeatures():
                            if fc["sub_modelid"] == feature_name:
                                # from qgis.core import QgsMap
                                change_map = {fc.id(): new_c_g}
                                self.subcentroids.dataProvider(
                                ).changeGeometryValues(change_map)
                                break
                        for fl in self.sublinks.dataProvider().getFeatures():
                            if fl["inlet"] == self.feature["c_modelid"]:
                                if fl.geometry().wkbType(
                                ) == QGis.WKBLineString:
                                    line = fl.geometry().asPolyline()
                                    new_l_g = QgsGeometry.fromPolyline(
                                        [new_c, line[-1]])
                                    change_map = {fl.id(): new_l_g}
                                    self.sublinks.dataProvider(
                                    ).changeGeometryValues(change_map)
                                break

                    break
                except Exception as ex1:
                    print("Searching for object to edit vertex of: " +
                          str(ex1) + '\n' + str(traceback.print_exc()))
Exemplo n.º 3
0
    def check_coords(self):
        # check source LL coordinates
        new_src_LL = Coordinate()
        val, val_is_good = ParseData.floatTryParse(self.ui.txtLL_src_x.text())
        if val_is_good:
            new_src_LL.x = val
        else:
            return False
        val, val_is_good = ParseData.floatTryParse(self.ui.txtLL_src_y.text())
        if val_is_good:
            new_src_LL.y = val
        else:
            return False

        # check source UR coordinates
        new_src_UR = Coordinate()
        val, val_is_good = ParseData.floatTryParse(self.ui.txtUR_src_x.text())
        if val_is_good:
            new_src_UR.x = val
        else:
            return False
        val, val_is_good = ParseData.floatTryParse(self.ui.txtUR_src_y.text())
        if val_is_good:
            new_src_UR.y = val
        else:
            return False

        # check destination LL coordinates
        new_dst_LL = Coordinate()
        val, val_is_good = ParseData.floatTryParse(self.ui.txtLL_dst_x.text())
        if val_is_good:
            new_dst_LL.x = val
        else:
            return False
        val, val_is_good = ParseData.floatTryParse(self.ui.txtLL_dst_y.text())
        if val_is_good:
            new_dst_LL.y = val
        else:
            return False

        # check destination UR coordinates
        new_dst_UR = Coordinate()
        val, val_is_good = ParseData.floatTryParse(self.ui.txtUR_dst_x.text())
        if val_is_good:
            new_dst_UR.x = val
        else:
            return False
        val, val_is_good = ParseData.floatTryParse(self.ui.txtUR_dst_y.text())
        if val_is_good:
            new_dst_UR.y = val
        else:
            return False

        self.pt_src_ll.x = new_src_LL.x
        self.pt_src_ll.y = new_src_LL.y
        self.pt_src_ur.x = new_src_UR.x
        self.pt_src_ur.y = new_src_UR.y

        if not self.pt_dst_ll:
            self.pt_dst_ll = type(self.pt_src_ll)()
        if not self.pt_dst_ur:
            self.pt_dst_ur = type(self.pt_src_ur)()
        self.pt_dst_ll.x = new_dst_LL.x
        self.pt_dst_ll.y = new_dst_LL.y
        self.pt_dst_ur.x = new_dst_UR.x
        self.pt_dst_ur.y = new_dst_UR.y

        return True
    def __init__(self):
        Section.__init__(self)
        Polygon.__init__(self)

        ## Coordinates: Subcatchment's centroid on the Study Area Map.
        ## If not set, the subcatchment will not appear on the map.
        self.centroid = Coordinate()

        ## str: Optional description of the Subcatchment.
        self.description = ''

        ## Optional label used to categorize or classify the Subcatchment.
        self.tag = ''

        ## str: The RainGage ID associated with the Subcatchment.
        self.rain_gage = 'None'

        ## The Node or Subcatchment which receives Subcatchment's runoff.
        self.outlet = 'None'

        ## float: Area of the subcatchment (acres or hectares).
        self.area = 0.0

        ## float: Percent of land area which is impervious.
        self.percent_impervious = 0.0

        ## Characteristic width of the overland flow path for sheet flow
        ## runoff (feet or meters). An initial estimate of the characteristic
        ## width is given by the subcatchment area divided by the average
        ## maximum overland flow length. The maximum overland flow
        ## length is the length of the flow path from the the furthest drainage
        ## point of the subcatchment before the flow becomes channelized.
        ## Maximum lengths from several different possible flow paths
        ## should be averaged. These paths should reflect slow flow, such as
        ## over pervious surfaces, more than rapid flow over pavement, for
        ## example. Adjustments should be made to the width parameter to
        ## produce good fits to measured runoff hydrographs.
        self.width = 0.0

        ## float: Average percent slope of the subcatchment.
        self.percent_slope = 0.0

        ## float: Manning's n for overland flow in impervious part of Subcatchment
        self.n_imperv = 0.0

        ## Manning's n for overland flow in pervious part of Subcatchment
        self.n_perv = 0.0

        ## float: Depth of depression storage on the impervious portion of the
        ## Subcatchment (inches or millimeters)
        self.storage_depth_imperv = 0.0

        ## float: Depth of depression storage on the pervious portion of the
        ## Subcatchment (inches or millimeters)
        self.storage_depth_perv = 0.0

        ## float: Percent of the impervious area with no depression storage.
        self.percent_zero_impervious = 0.0

        ## Routing: Internal routing of runoff between pervious and impervious areas
        self.subarea_routing = Routing.OUTLET

        ## float: Percent of runoff routed between subareas
        self.percent_routed = 100.0

        ## infiltration parameters from horton, green-ampt, or scs classes
        self.infiltration_parameters = HortonInfiltration()
        #self.infiltration_parameters.subcatchment = self.name

        ## Snow pack parameter set (if any) of the subcatchment.
        self.snow_pack = ''

        ## Total length of curbs in the subcatchment (any length units).
        ## Used only when initial_loadings are normalized to curb length.
        self.curb_length = 0

        ## Optional monthly pattern that adjusts pervious Mannings N
        self.nperv_pattern = ''

        ## Optional monthly pattern that adjusts depression storage
        self.dstore_pattern = ''

        ## Optional monthly pattern that adjusts infiltration rate
        self.infil_pattern = ''
Exemplo n.º 5
0
    def __init__(self):
        Section.__init__(self)
        Polygon.__init__(self)

        self.centroid = Coordinate()
        """Coordinates: Subcatchment's centroid on the Study Area Map.
            If not set, the subcatchment will not appear on the map."""

        self.description = ''
        """str: Optional description of the Subcatchment."""

        self.tag = ''
        """Optional label used to categorize or classify the Subcatchment."""

        self.rain_gage = ''
        """str: The RainGage ID associated with the Subcatchment."""

        self.outlet = ''
        """The Node or Subcatchment which receives Subcatchment's runoff."""

        self.area = ''
        """float: Area of the subcatchment (acres or hectares)."""

        self.percent_impervious = ''
        """float: Percent of land area which is impervious."""

        self.width = ''
        """Characteristic width of the overland flow path for sheet flow
            runoff (feet or meters). An initial estimate of the characteristic
            width is given by the subcatchment area divided by the average
            maximum overland flow length. The maximum overland flow
            length is the length of the flow path from the the furthest drainage
            point of the subcatchment before the flow becomes channelized.
            Maximum lengths from several different possible flow paths
            should be averaged. These paths should reflect slow flow, such as
            over pervious surfaces, more than rapid flow over pavement, for
            example. Adjustments should be made to the width parameter to
            produce good fits to measured runoff hydrographs."""

        self.percent_slope = ''
        """float: Average percent slope of the subcatchment."""

        self.n_imperv = ''
        """float: Manning's n for overland flow in impervious part of Subcatchment"""

        self.n_perv = ''
        """Manning's n for overland flow in pervious part of Subcatchment"""

        self.storage_depth_imperv = ''
        """float: Depth of depression storage on the impervious portion of the
            Subcatchment (inches or millimeters) """

        self.storage_depth_perv = ''
        """float: Depth of depression storage on the pervious portion of the
            Subcatchment (inches or millimeters)"""

        self.percent_zero_impervious = ''
        """float: Percent of the impervious area with no depression storage."""

        self.subarea_routing = Routing.OUTLET
        """Routing: Internal routing of runoff between pervious and impervious areas"""

        self.percent_routed = ''
        """float: Percent of runoff routed between subareas"""

        self.infiltration_parameters = HortonInfiltration()
        """infiltration parameters from horton, green-ampt, or scs classes"""

        self.groundwater = ''
        """Groundwater flow parameters for the subcatchment."""

        self.snow_pack = ''
        """Snow pack parameter set (if any) of the subcatchment."""

        self.curb_length = ''
        """ Total length of curbs in the subcatchment (any length units).
Exemplo n.º 6
0
 def __init__(self, node_id: int, lng: float, lat: float):
     self.node_id = node_id
     self.location = Coordinate(lng, lat)
     self.out_edges = {}
     self.in_edges = {}