Пример #1
0
    def inlezen(self):
        """import the file after all settings wehere made"""
        importAttr = self.type.currentText()
        invalidCount = 0
        for importType in self.mappingDict:
            if self.mappingDict[importType]["targetType"] != 'niet importeren':
                checkConv = False
                expr = QC.QgsExpression('"{}"= \'{}\''.format(
                    importAttr, importType))
                featureIt = self.importLayer.getFeatures(
                    QC.QgsFeatureRequest(expr))
                targetFeature = QC.QgsFeature()
                targetLayerName = self.mappingDict[importType]["layerName"]
                if 'Labels' in targetLayerName:
                    LabelDialog.attributes = [
                        self.type.itemText(i) for i in range(self.type.count())
                    ]
                    LabelDialog.importType = importType
                    labelField, dummy = LabelDialog.getLabelAtrribute()
                targetLayer = UC.getlayer_byname(targetLayerName)
                targetFields = targetLayer.fields()
                targetFeature.initAttributes(targetFields.count())
                targetFeature.setFields(targetFields)
                if self.mappingDict[importType][
                        "convType"] != self.layerImportType:
                    checkConv = True
                query = "SELECT foreign_key, identifier, input_label FROM config_object WHERE child_layer = '{}'".format(
                    targetLayerName)
                attrs = UC.read_settings(query, False)[0]
                targetFeature[
                    attrs[1]] = self.mappingDict[importType]["targetType"]
                targetFeature[attrs[0]] = self.object_id.text()
                targetLayer.startEditing()

                for feat in featureIt:
                    geom = None
                    if not checkConv:
                        geom = EF.getfeature_geometry(feat.geometry(),
                                                      self.layerImportType)
                        if 'Labels' in targetLayerName:
                            if feat[labelField]:
                                targetFeature[attrs[2]] = feat[labelField]
                            else:
                                targetFeature[attrs[2]] = 'geen label'
                    if geom:
                        targetFeature.setGeometry(geom)
                        invalidCheck = UC.write_layer(targetLayer,
                                                      targetFeature, True)
                        if invalidCheck == 'invalid':
                            invalidCount += 1
                targetLayer.commitChanges()
        if invalidCount > 0:
            MSG.showMsgBox('importpartiallysuccesfull',
                           '{}'.format(invalidCount))
        else:
            MSG.showMsgBox('importsuccesfull')
        QC.QgsProject.instance().removeMapLayers([self.importLayer.id()])
Пример #2
0
 def getIconPath(self, feat):
     if self.infoBoxIni["infoLayer"] in self.layerSet.keys(
     ) and self.iconPath.text() != "":
         iconPathExp = core.QgsExpression()
         content = iconPathExp.replaceExpressionText(
             self.iconPath.text().replace("\n", ""),
             self.get_featureContext(feat))
         return content
     return ""
Пример #3
0
 def getInfoField(self,feat):
     if self.infoBoxIni["infoLayer"] in self.layerSet.keys() and self.infoField.text() != "":
         infoFieldExp = core.QgsExpression()
         content = infoFieldExp.replaceExpressionText(self.infoField.text(), self.get_featureContext(feat))
         if content:
             content = content.replace("\n","")
             content = content.replace('"',"")
             content = content.replace("'","")
         return content
     return ""
Пример #4
0
 def getHtml(self,feat):
     if self.infoBoxIni["infoLayer"] in self.layerSet.keys() and self.enableInfoBoxCheckbox.isChecked():
         htmlExp = core.QgsExpression()
         html = htmlExp.replaceExpressionText(self.infoboxHtml.toPlainText().replace("\n",""), self.get_featureContext(feat))
         if html:
             html = html.replace("\n","")
             html = html.replace('"',"")
             html = html.replace("'","")
             return html
         else:
             return ""
     else:
         return ""
Пример #5
0
    def __populate(self):
        """Find all previous objections for the parcel and add them."""
        if not self.previousObjectionsLayer:
            return

        expr = '"perceel_2019" like \'%%%s%%\'' % (self.uniek_id)
        objectionList = []
        for i in self.previousObjectionsLayer.getFeatures(
                QGisCore.QgsFeatureRequest(QGisCore.QgsExpression(expr))):
            objectionList.append(i)

        filteredObjectionList = []
        for i in objectionList:
            perceel_2019 = i.attribute('perceel_2019').split(',')
            if self.uniek_id in perceel_2019:
                filteredObjectionList.append(i)

        for i in sorted(filteredObjectionList,
                        key=lambda x: int(x.attribute('jaar'))):
            self.addObjection(i)
Пример #6
0
    def clearWithMode(self, mode, toggleRendering=True):
        """Clear the selected geometry that have the given mode.

        Parameters
        ----------
        mode : int
            Clear the geometries that have been selected using this mode.
        toggleRendering : boolean, optional
            Redraw the map after changing the tempLayer. Defaults to True.
            When making multiple changes to the selection set only the last
            change to toggleRendering=`True` for improved performance.

        """
        if not self.__getLayer():
            return
        self.main.iface.mapCanvas().setRenderFlag(False)
        for feature in self.layer.getFeatures(QGisCore.QgsFeatureRequest(
                QGisCore.QgsExpression('mode = %i' % mode))):
            self.layer.deleteFeature(feature.id())
        if toggleRendering:
            self.main.iface.mapCanvas().setRenderFlag(True)