Beispiel #1
0
    def finish_feature_creation(self, layerId, features):
        if len(features) != 1:
            # TODO send this info to controller
            # message = QCoreApplication.translate("WizardTranslations", "'{}' tool has been closed. We should have got only one {} by we have {}").format(self.WIZARD_TOOL_NAME, self.WIZARD_FEATURE_NAME, len(features))
            # self.logger.warning(__name__, "We should have got only one {}, but we have {}".format(self.WIZARD_FEATURE_NAME, len(features)))
            return SpacialSourceFinishFeatureCreationArgs(
                added_features_amount=len(features))

        feature = features[0]

        if not feature.isValid():
            # TODO send this info to controller
            # self.logger.warning(__name__, "Feature not found in layer Spatial Source...")
            return SpacialSourceFinishFeatureCreationArgs(is_valid=False)

        feature_tid = feature[self.names.T_ID_F]

        feature_ids = LADMData.get_list_of_features_ids(
            self.__layers[self.names.LC_PLOT_T], self.names.T_ID_F)
        new_features = LADMData.save_relations(
            self.__layers[self.names.COL_UE_SOURCE_T],
            self.names.COL_UE_SOURCE_T_LC_PLOT_F, feature_ids,
            self.names.COL_UE_SOURCE_T_SOURCE_F, feature_tid)
        # all_new_features.extend(new_features)
        feature_ids = LADMData.get_list_of_features_ids(
            self.__layers[self.names.LC_BOUNDARY_T], self.names.T_ID_F)

        new_features = LADMData.save_relations(
            self.__layers[self.names.COL_CCL_SOURCE_T],
            self.names.COL_CCL_SOURCE_T_BOUNDARY_F, feature_ids,
            self.names.COL_CCL_SOURCE_T_SOURCE_F, feature_tid)

        feature_ids = LADMData.get_list_of_features_ids(
            self.__layers[self.names.LC_BOUNDARY_POINT_T], self.names.T_ID_F)
        new_features = LADMData.save_relations(
            self.__layers[self.names.COL_POINT_SOURCE_T],
            self.names.COL_POINT_SOURCE_T_LC_BOUNDARY_POINT_F, feature_ids,
            self.names.COL_POINT_SOURCE_T_SOURCE_F, feature_tid)

        feature_ids = LADMData.get_list_of_features_ids(
            self.__layers[self.names.LC_SURVEY_POINT_T], self.names.T_ID_F)
        new_features = LADMData.save_relations(
            self.__layers[self.names.COL_POINT_SOURCE_T],
            self.names.COL_POINT_SOURCE_T_LC_SURVEY_POINT_F, feature_ids,
            self.names.COL_POINT_SOURCE_T_SOURCE_F, feature_tid)

        feature_ids = LADMData.get_list_of_features_ids(
            self.__layers[self.names.LC_CONTROL_POINT_T], self.names.T_ID_F)

        new_features = LADMData.save_relations(
            self.__layers[self.names.COL_POINT_SOURCE_T],
            self.names.COL_POINT_SOURCE_T_LC_CONTROL_POINT_F, feature_ids,
            self.names.COL_POINT_SOURCE_T_SOURCE_F, feature_tid)

        return SpacialSourceFinishFeatureCreationArgs(True, feature_tid, 1,
                                                      None)
    def finish_feature_creation(self, layerId, features):
        if len(features) != 1:
            return SpacialSourceFinishFeatureCreationArgs(added_features_amount=len(features))

        fid = features[0].id()

        # editing layer Name?
        if not self.__editing_layer.getFeature(fid).isValid():
            # self.logger.warning(__name__, "Feature not found in layer {}...".format(self.__editing_layer_name))
            # TODO send this info to controller
            return SpacialSourceFinishFeatureCreationArgs(SpacialSourceFinishFeatureCreationArgs(is_valid=False))

        # feature_rrr_id: generic name used for represent id for right, restriction
        # feature_rrr_id = self._layers[self.EDITING_LAYER_NAME].getFeature(fid)[self.names.T_ID_F]
        feature_tid = self.__editing_layer.getFeature(fid)[self.__db.names.T_ID_F]

        administrative_source_ids = LADMData.get_list_of_features_ids(self.__layers[self.names.LC_ADMINISTRATIVE_SOURCE_T], self.names.T_ID_F)

        # Fill rrrfuente table
        new_features = []
        attr_fk = None

        if self.__editing_layer_name == self.names.LC_RIGHT_T:
            attr_fk = self.names.COL_RRR_SOURCE_T_LC_RIGHT_F
        elif self.__editing_layer_name == self.names.LC_RESTRICTION_T:
            attr_fk = self.names.COL_RRR_SOURCE_T_LC_RESTRICTION_F

        new_features = LADMData.save_relations(self.__layers[self.names.COL_RRR_SOURCE_T],
                                               self.names.COL_RRR_SOURCE_T_SOURCE_F,
                                               administrative_source_ids, attr_fk, feature_tid)
        return SpacialSourceFinishFeatureCreationArgs(True, feature_tid, 1, None)
Beispiel #3
0
    def finish_feature_creation(self, layerId, features):
        if len(features) != 1:
            # TODO send this info to controller
            # message = QCoreApplication.translate("WizardTranslations", "'{}' tool has been closed. We should have got only one {} by we have {}").format(self.WIZARD_TOOL_NAME, self.WIZARD_FEATURE_NAME, len(features))
            # self.logger.warning(__name__, "We should have got only one {}, but we have {}".format(self.WIZARD_FEATURE_NAME, len(features)))
            return ParcelFinishFeatureCreationArgs(
                added_features_amount=len(features))

        if not self.is_each_layer_valid():
            return ParcelFinishFeatureCreationArgs(valid_constraints=False)

        feature = features[0]

        if not feature.isValid():
            # TODO send this info to controller
            # self.logger.warning(__name__, "Feature not found in layer Spatial Source...")
            return ParcelFinishFeatureCreationArgs(is_valid=False)

        # TODO What is the difference?
        # feature_tid = feature[self.__db.names.T_ID_F]
        feature_tid = self.__editing_layer.getFeature(
            feature.id())[self.__db.names.T_ID_F]

        plot_ids = list()
        building_ids = list()
        building_unit_ids = list()

        # Apply restriction to the selection

        # add plot associated
        if self.__db.names.LC_PLOT_T in self.__constraint_types_of_parcels[
                self.parcel_type_ili_code]:
            add_features = self.__constraint_types_of_parcels[
                self.parcel_type_ili_code][
                    self.__db.names.LC_PLOT_T] is not None
        else:
            add_features = True

        if add_features:
            plot_ids = LADMData.get_list_of_features_ids(
                self.__layers[self.__db.names.LC_PLOT_T],
                self.__db.names.T_ID_F)

        new_features = LADMData.save_relations(
            self.__layers[self.__db.names.COL_UE_BAUNIT_T],
            self.__db.names.COL_UE_BAUNIT_T_LC_PLOT_F, plot_ids,
            self.__db.names.COL_UE_BAUNIT_T_PARCEL_F, feature_tid)

        # add building associated
        if self.__db.names.LC_BUILDING_T in self.__constraint_types_of_parcels[
                self.parcel_type_ili_code]:
            add_features = self.__constraint_types_of_parcels[
                self.parcel_type_ili_code][
                    self.__db.names.LC_BUILDING_T] is not None
        else:
            add_features = True

        if add_features:
            building_ids = LADMData.get_list_of_features_ids(
                self.__layers[self.__db.names.LC_BUILDING_T],
                self.__db.names.T_ID_F)

        new_features = LADMData.save_relations(
            self.__layers[self.__db.names.COL_UE_BAUNIT_T],
            self.__db.names.COL_UE_BAUNIT_T_LC_BUILDING_F, building_ids,
            self.__db.names.COL_UE_BAUNIT_T_PARCEL_F, feature_tid)

        # add building unit associated
        if self.__db.names.LC_BUILDING_UNIT_T in self.__constraint_types_of_parcels[
                self.parcel_type_ili_code]:
            add_features = self.__constraint_types_of_parcels[
                self.parcel_type_ili_code][
                    self.__db.names.LC_BUILDING_UNIT_T] is not None
        else:
            add_features = True

        if add_features:
            building_unit_ids = LADMData.get_list_of_features_ids(
                self.__layers[self.__db.names.LC_BUILDING_UNIT_T],
                self.__db.names.T_ID_F)

        new_features = LADMData.save_relations(
            self.__layers[self.__db.names.COL_UE_BAUNIT_T],
            self.__db.names.COL_UE_BAUNIT_T_LC_BUILDING_UNIT_F,
            building_unit_ids, self.__db.names.COL_UE_BAUNIT_T_PARCEL_F,
            feature_tid)

        return ParcelFinishFeatureCreationArgs(True, feature_tid, 1, None)