def store_coord(self, dimension=3, clist=None): """ Update coordinates in coord table, insert new point if coo is None or point not found. :param dimension: 2/3D coordinates to store (int) :param clist: name of layer to add (str) """ cl = None if clist is None: if self.coo is None: # new point to add to the first table cl = get_coordlist() if cl is None: return False self.coo = cl[0] else: self.coo = clist # e, n coordinates must be given (geometry) if self.e is None or self.n is None: return False lay = get_layer_by_name(self.coo) if lay is None: return False for feat in lay.getFeatures(): if feat['point_id'] == self.id: # set feature geometry and attributes fid = feat.id() attrs = {feat.fieldNameIndex('point_id'): self.id} if dimension in [2, 3]: attrs[feat.fieldNameIndex('e')] = self.e attrs[feat.fieldNameIndex('n')] = self.n if dimension in [3]: attrs[feat.fieldNameIndex('z')] = self.z attrs[feat.fieldNameIndex('pc')] = self.pc attrs[feat.fieldNameIndex('pt')] = self.pt lay.dataProvider().changeAttributeValues({fid: attrs}) # feat.setGeometry(QgsGeometry.fromPointXY(QgsPointXY(self.e, self.n))) lay.dataProvider().changeGeometryValues({fid: QgsGeometry.fromPointXY(QgsPointXY(self.e, self.n))}) return True # add new point feat = QgsFeature() # feat.setFields(lay.pendingFields(), True) # feat.setFields(lay.dataProvider().fields(), True) fields = lay.dataProvider().fields() feat.setFields(fields, True) feat.setAttribute(feat.fieldNameIndex('point_id'), self.id) if dimension in [2, 3]: feat.setAttribute(feat.fieldNameIndex('e'), self.e) feat.setAttribute(feat.fieldNameIndex('n'), self.n) if dimension in [1, 3]: feat.setAttribute(feat.fieldNameIndex('z'), self.z) feat.setAttribute(feat.fieldNameIndex('pc'), self.pc) feat.setAttribute(feat.fieldNameIndex('pt'), self.pt) feat.setGeometry(QgsGeometry.fromPointXY(QgsPointXY(self.e, self.n))) lay.dataProvider().addFeatures([feat]) return True
def create_path_feature_from_points(path_points, attr_vals, fields): polyline = QgsGeometry.fromPolyline(path_points) feature = QgsFeature(fields) # feature.setAttribute(0, 1) # id start_index = feature.fieldNameIndex("start point id") end_index = feature.fieldNameIndex("end point id") cost_index = feature.fieldNameIndex("total cost") feature.setAttribute(start_index, attr_vals[0]) feature.setAttribute(end_index, attr_vals[1]) feature.setAttribute(cost_index, attr_vals[2]) # cost feature.setGeometry(polyline) return feature
def create_path_feature_from_points(path_points, total_cost, ID, fields): # We create the geometry of the polyline polyline = QgsGeometry.fromPolylineXY(path_points) # We retrieve the fields and add them to the feature feature = QgsFeature(fields) cost_index = feature.fieldNameIndex("total cost") feature.setAttribute(cost_index, total_cost) # cost id_index = feature.fieldNameIndex("Construction order") feature.setAttribute(id_index, ID) # id # We add the geometry to the feature feature.setGeometry(polyline) return feature
def create_path_feature_from_Multipolyline(MultipolyLine, ID, flux, roadType, fields): # We create the geometry of the polyline polyline = QgsGeometry.fromMultiPolylineXY(MultipolyLine) # We retrieve the fields and add them to the feature feature = QgsFeature(fields) id_index = feature.fieldNameIndex("id") feature.setAttribute(id_index, ID) flux_index = feature.fieldNameIndex("flux") feature.setAttribute(flux_index, flux) road_type_index = feature.fieldNameIndex("road_type") feature.setAttribute(road_type_index, roadType) # We add the geometry to the feature feature.setGeometry(polyline) return feature
def updateOriginalLayer(self, pgInputLayer, qgisOutputVector, featureList=None, featureTupleList=None): """ Updates the original layer using the grass output layer pgInputLyr: postgis input layer qgisOutputVector: qgis output layer Speed up tips: http://nyalldawson.net/2016/10/speeding-up-your-pyqgis-scripts/ """ provider = pgInputLayer.dataProvider() # getting keyColumn because we want to be generic uri = QgsDataSourceURI(pgInputLayer.dataProvider().dataSourceUri()) keyColumn = uri.keyColumn() # starting edition mode pgInputLayer.startEditing() addList = [] idsToRemove = [] #making the changes and inserts for feature in pgInputLayer.getFeatures(): id = feature.id() outFeats = [] #getting the output features with the specific id if qgisOutputVector: for gf in qgisOutputVector.dataProvider().getFeatures( QgsFeatureRequest( QgsExpression("{0}={1}".format(keyColumn, id)))): outFeats.append(gf) elif featureTupleList: for gfid, gf in featureTupleList: if gfid == id and gf['classname'] == pgInputLayer.name(): outFeats.append(gf) else: for gf in [gf for gf in featureList if gf.id() == id]: outFeats.append(gf) #starting to make changes for i in range(len(outFeats)): if i == 0: #let's update this feature newGeom = outFeats[i].geometry() newGeom.convertToMultiType() feature.setGeometry(newGeom) pgInputLayer.updateFeature(feature) else: #for the rest, let's add them newFeat = QgsFeature(feature) newGeom = outFeats[i].geometry() newGeom.convertToMultiType() newFeat.setGeometry(newGeom) idx = newFeat.fieldNameIndex(keyColumn) newFeat.setAttribute(idx, provider.defaultValue(idx)) addList.append(newFeat) #in the case we don't find features in the output we should mark them to be removed if len(outFeats) == 0: idsToRemove.append(id) #pushing the changes into the edit buffer pgInputLayer.addFeatures(addList, True) #removing features from the layer. pgInputLayer.deleteFeatures(idsToRemove)
def create_path_feature_from_points(path_points, total_cost, fields): polyline = QgsGeometry.fromPolyline(path_points) feature = QgsFeature(fields) # feature.setAttribute(0, 1) # id cost_index = feature.fieldNameIndex("total cost") feature.setAttribute(cost_index, total_cost) # cost feature.setGeometry(polyline) return feature
def save(self): QApplication.setOverrideCursor(Qt.WaitCursor) prv = self.lyr.dataProvider() attrs = prv.fields().toList() self.lyr.startEditing() fls = [] for i in xrange(len(self.clusters)): fls.append('clust_' + str(i)) nattrs = [] for fl in fls: if self.lyr.fieldNameIndex(fl) == -1: nattrs.append(QgsField(fl, 10)) if len(nattrs)>0: self.lyr.dataProvider().addAttributes(nattrs) self.lyr.updateFields() i = 0 for cluster in self.clusters: fln = fls[i] # for fid in cluster: feats = prv.getFeatures() feat = QgsFeature() while feats.nextFeature(feat): if feat.id() in cluster: self.lyr.changeAttributeValue(feat.id(), feat.fieldNameIndex(fln), 'True') else: self.lyr.changeAttributeValue(feat.id(), feat.fieldNameIndex(fln), 'False') i += 1 self.lyr.commitChanges() QApplication.restoreOverrideCursor()
def save(self): QApplication.setOverrideCursor(Qt.WaitCursor) prv = self.lyr.dataProvider() attrs = prv.fields().toList() self.lyr.startEditing() fls = ['Li', 'E_Li', 'Var_Li', 'Z_Li', 'p_value'] nattrs = [] for fl in fls: if self.lyr.fieldNameIndex(fl) == -1: nattrs.append(QgsField(fl, 6)) fls = ['neighbours', 'influence'] for fl in fls: if self.lyr.fieldNameIndex(fl) == -1: nattrs.append(QgsField(fl, 10)) if len(nattrs)>0: self.lyr.dataProvider().addAttributes(nattrs) self.lyr.updateFields() feats = prv.getFeatures() feat = QgsFeature() i = 0 while feats.nextFeature(feat): self.lyr.changeAttributeValue(feat.id(), feat.fieldNameIndex('Li'), str(self.model.itemData(self.model.index(i, 0))[0])) self.lyr.changeAttributeValue(feat.id(), feat.fieldNameIndex('E_Li'), str(self.model.itemData(self.model.index(i, 1))[0])) self.lyr.changeAttributeValue(feat.id(), feat.fieldNameIndex('Var_Li'), str(self.model.itemData(self.model.index(i, 2))[0])) self.lyr.changeAttributeValue(feat.id(), feat.fieldNameIndex('Z_Li'), str(self.model.itemData(self.model.index(i, 3))[0])) self.lyr.changeAttributeValue(feat.id(), feat.fieldNameIndex('p_value'), str(self.model.itemData(self.model.index(i, 4))[0])) self.lyr.changeAttributeValue(feat.id(), feat.fieldNameIndex('neighbours'), str(self.model.itemData(self.model.index(i, 5))[0])) self.lyr.changeAttributeValue(feat.id(), feat.fieldNameIndex('influence'), str(self.model.itemData(self.model.index(i, 6))[0])) i += 1 self.lyr.commitChanges() QApplication.restoreOverrideCursor()
def to_args(self, feature: QgsFeature) -> Tuple[list, dict]: ''' creates parameters out of the mapped (active) fields and current values to be used in geocoding, inactive fields and fields with no values are skipped Parameters ---------- feature : QgsFeature feature to geocode Returns ---------- (list, dict) values of mapped fields without keywords are returned in the list, the dictionary contains the keywords as keys and the current values of the mapped fields as values ''' kwargs = {} args = [] attributes = feature.attributes() for field_name, (active, keyword) in self._mapping.items(): if not active: continue attributes = feature.attributes() idx = feature.fieldNameIndex(field_name) value = attributes[idx] if not value: continue if isinstance(value, float): value = int(value) value = str(value) if keyword is None: split = re.findall(r"[\w'\-]+", value) args.extend(split) else: kwargs[keyword] = value return args, kwargs
def execute(self): """ Reimplementation of the execute method from the parent class """ QgsMessageLog.logMessage( self.tr('Starting ') + self.getName() + self.tr('Process.'), "DSG Tools Plugin", QgsMessageLog.CRITICAL) try: self.setStatus(self.tr('Running'), 3) #now I'm running! self.abstractDb.deleteProcessFlags(self.getName()) classesWithElem = self.parameters['Classes'] if len(classesWithElem) == 0: self.setStatus( self.tr('No classes selected!. Nothing to be done.'), 1) #Finished return 1 for key in classesWithElem: self.startTimeCount() # preparation classAndGeom = self.classesWithElemDict[key] lyr = self.loadLayerBeforeValidationProcess(classAndGeom) localProgress = ProgressWidget( 0, 1, self.tr('Preparing execution for ') + classAndGeom['lyrName'], parent=self.iface.mapCanvas()) localProgress.step() localProgress.step() lyr.startEditing() provider = lyr.dataProvider() uri = QgsDataSourceURI(provider.dataSourceUri()) keyColumn = uri.keyColumn() if self.parameters['Only Selected']: featureList = lyr.selectedFeatures() size = len(featureList) else: featureList = lyr.getFeatures() size = len(lyr.allFeatureIds()) localProgress = ProgressWidget(1, size, self.tr('Running process on ') + classAndGeom['lyrName'], parent=self.iface.mapCanvas()) for feat in featureList: geom = feat.geometry() if not geom: #insert deletion lyr.deleteFeature(feat.id()) localProgress.step() continue if geom.geometry().partCount() > 1: parts = geom.asGeometryCollection() for part in parts: part.convertToMultiType() addList = [] for i in range(1, len(parts)): if parts[i]: newFeat = QgsFeature(feat) newFeat.setGeometry(parts[i]) idx = newFeat.fieldNameIndex(keyColumn) newFeat.setAttribute( idx, provider.defaultValue(idx)) addList.append(newFeat) feat.setGeometry(parts[0]) lyr.updateFeature(feat) lyr.addFeatures(addList, True) localProgress.step() self.logLayerTime(classAndGeom['lyrName']) msg = self.tr('All geometries are now single parted.') self.setStatus(msg, 1) #Finished return 1 except Exception as e: QgsMessageLog.logMessage(':'.join(e.args), "DSG Tools Plugin", QgsMessageLog.CRITICAL) self.finishedWithError() return 0
def updateOriginalLayerV2(self, pgInputLayer, qgisOutputVector, featureList=None, featureTupleList=None, deleteFeatures=True): """ Updates the original layer using the grass output layer pgInputLyr: postgis input layer qgisOutputVector: qgis output layer Speed up tips: http://nyalldawson.net/2016/10/speeding-up-your-pyqgis-scripts/ 1- Make pgIdList, by querying it with flag QgsFeatureRequest.NoGeometry 2- Build output dict 3- Perform operation """ provider = pgInputLayer.dataProvider() # getting keyColumn because we want to be generic uri = QgsDataSourceURI(pgInputLayer.dataProvider().dataSourceUri()) keyColumn = uri.keyColumn() # starting edition mode pgInputLayer.startEditing() pgInputLayer.beginEditCommand('Updating layer') addList = [] idsToRemove = [] inputDict = dict() #this is done to work generically with output layers that are implemented different from ours isMulti = QgsWKBTypes.isMultiType(int(pgInputLayer.wkbType())) # #making the changes and inserts #this request only takes ids to build inputDict request = QgsFeatureRequest().setFlags(QgsFeatureRequest.NoGeometry) for feature in pgInputLayer.getFeatures(request): inputDict[feature.id()] = dict() inputDict[feature.id()]['featList'] = [] inputDict[feature.id()]['featWithoutGeom'] = feature inputDictKeys = inputDict.keys() if qgisOutputVector: for feat in qgisOutputVector.dataProvider().getFeatures(): if keyColumn == '': featid = feat.id() else: featid = feat[keyColumn] if featid in inputDictKeys: #verificar quando keyColumn = '' inputDict[featid]['featList'].append(feat) elif featureTupleList: for gfid, gf in featureTupleList: if gfid in inputDictKeys and gf[ 'classname'] == pgInputLayer.name(): inputDict[gfid]['featList'].append(gf) else: for feat in featureList: if keyColumn == '': featid = feat.id() else: featid = feat[keyColumn] if featid in inputDictKeys: inputDict[featid]['featList'].append(feat) #finally, do what must be done for id in inputDictKeys: outFeats = inputDict[id]['featList'] #starting to make changes for i in range(len(outFeats)): if i == 0: #let's update this feature newGeom = outFeats[i].geometry() if newGeom: if isMulti: newGeom.convertToMultiType() pgInputLayer.changeGeometry( id, newGeom) #It is faster according to the api else: if id not in idsToRemove: idsToRemove.append(id) else: #for the rest, let's add them newFeat = QgsFeature(inputDict[id]['featWithoutGeom']) newGeom = outFeats[i].geometry() if newGeom: if isMulti and newGeom: newGeom.convertToMultiType() newFeat.setGeometry(newGeom) if keyColumn != '': idx = newFeat.fieldNameIndex(keyColumn) newFeat.setAttribute(idx, provider.defaultValue(idx)) addList.append(newFeat) else: if id not in idsToRemove: idsToRemove.append(id) #in the case we don't find features in the output we should mark them to be removed if len(outFeats) == 0 and deleteFeatures: idsToRemove.append(id) #pushing the changes into the edit buffer pgInputLayer.addFeatures(addList, True) #removing features from the layer. pgInputLayer.deleteFeatures(idsToRemove) pgInputLayer.endEditCommand()
def outattrPrep(self, dlg, lyr): feat = QgsFeature() species = '' production = '' most = QDateTime.currentDateTimeUtc() rn = dlg.tableWidget.rowCount() for i in range(rn): if i==0: species = dlg.tableWidget.item(i, 0).text() production = dlg.tableWidget.item(i, 1).text() else: species = species + ' | ' + dlg.tableWidget.item(i, 0).text() production = production + ' | ' + dlg.tableWidget.item(i, 1).text() flds = lyr.dataProvider().fields() feat.setFields(flds, True) feat.setAttribute(feat.fieldNameIndex('localid'), dlg.lineEdit_3_id.text())#mandatory feat.setAttribute(feat.fieldNameIndex('code'), dlg.lineEdit_5_code.text())#mandatory feat.setAttribute(feat.fieldNameIndex('largescale'), dlg.comboBox_4_large_scale.currentText()) feat.setAttribute(feat.fieldNameIndex('disease'), dlg.comboBox_2_disease.currentText())#mandatory feat.setAttribute(feat.fieldNameIndex('animalno'), dlg.lineEdit_6_num_animals.text())#mandatory feat.setAttribute(feat.fieldNameIndex('species'), species)#mandatory feat.setAttribute(feat.fieldNameIndex('production'), production) feat.setAttribute(feat.fieldNameIndex('year'), self.checkIntValue(dlg.lineEdit_4_year.text()))#mandatory feat.setAttribute(feat.fieldNameIndex('status'), dlg.comboBox_3_status.currentText())#mandatory feat.setAttribute(feat.fieldNameIndex('suspect'), self.dateCheck(dlg.dateEdit_dates_suspect.date())) feat.setAttribute(feat.fieldNameIndex('confirmation'), self.dateCheck(dlg.dateEdit_2_dates_confirmation.date())) feat.setAttribute(feat.fieldNameIndex('expiration'), self.dateCheck(dlg.dateEdit_3_dates_expiration.date())) feat.setAttribute(feat.fieldNameIndex('notes'), self.checkValue(dlg.textEdit_notes.toPlainText())) feat.setAttribute(feat.fieldNameIndex('hrid'), self.hashIDer(most,0)) feat.setAttribute(feat.fieldNameIndex('timestamp'), most.toString('dd/MM/yyyy hh:mm:ss')) return feat
def generateFootprintsForFilmVertical(self): self.reloadFpLayer() self.reloadCpLayer() # Error wenn nur ein punkt vorhanden if self.cpLayer.featureCount() > 1: caps = self.fpLayer.dataProvider().capabilities() if caps & QgsVectorDataProvider.AddFeatures: #Get FORM1 from FilmInfoDict f1 = self.currentFilmInfoDict["form1"] # Image height f2 = self.currentFilmInfoDict["form2"] # Image width iterFeatures = self.cpLayer.getFeatures() iterNext = self.cpLayer.getFeatures() existingFootpints = QgsVectorLayerUtils.getValues( self.fpLayer, "bildnummer")[0] ft = QgsFeature() ftNext = QgsFeature() iterNext.nextFeature(ftNext) fpFeats = [] kappasToUpdate = {} # iterate over points from CP Layer > LON, LAT i = 0 while iterFeatures.nextFeature(ft): i += 1 iterNext.nextFeature(ftNext) p = QgsPointXY(ft.geometry().asPoint()) if ft['bildnummer'] in existingFootpints: pPrevGeom = QgsGeometry(ft.geometry()) #QMessageBox.warning(None, u"Bild Nummern", u"Footprint für das Bild mit der Nummer {0} wurde bereits erstellt.".format(ft['BILD'])) continue if i == 1: pPrevGeom = QgsGeometry(ftNext.geometry()) #if iterNext.isClosed(): # #use pPrev as pNext # pNext = QgsPoint(pPrev) #else: # pNext = QgsPoint(ftNext.geometry().asPoint()) #kappa = p.azimuth(pPrev) #kappa = p.azimuth(pNext) # d = math.sqrt(2*((f1/2 * ft['MASS']/1000)**2)) d1 = f1 / 2 * ft['massstab'] / 1000 d2 = f2 / 2 * ft['massstab'] / 1000 #QMessageBox.warning(None, u"Bild Nummern", "{0}".format(d)) calcCrs = QgsCoordinateReferenceSystem() calcCrs.createFromProj4(self.Proj4Utm(p)) ctF = QgsCoordinateTransform(self.cpLayer.crs(), calcCrs, QgsProject.instance()) cpMetric = QgsGeometry(ft.geometry()) cpMetric.transform(ctF) pPrevGeom.transform(ctF) pMetric = QgsPointXY(cpMetric.asPoint()) pPrevMetric = QgsPointXY(pPrevGeom.asPoint()) kappaMetric = pMetric.azimuth(pPrevMetric) pPrevGeom = QgsGeometry(ft.geometry()) left = pMetric.x() - d2 bottom = pMetric.y() - d1 right = pMetric.x() + d2 top = pMetric.y() + d1 #R = 6371 #D = (d/1000) #cpLat = math.radians(p.y()) #cpLon = math.radians(p.x()) #urLat = math.asin( math.sin(cpLat)*math.cos(D/R) + math.cos(cpLat)*math.sin(D/R)*math.cos(urBrng) ) #urLon = cpLon + math.atan2(math.sin(urBrng)*math.sin(D/R)*math.cos(cpLat), math.cos(D/R)-math.sin(cpLat)*math.sin(urLat)) #top = math.asin( math.sin(cpLat)*math.cos(D/R) + math.cos(cpLat)*math.sin(D/R) ) #bottom = math.asin( math.sin(cpLat)*math.cos(D/R) + math.cos(cpLat)*math.sin(D/R)*-1 ) #lat = math.asin( math.sin(cpLat)*math.cos(D/R) ) #right = cpLon + math.atan2(math.sin(D/R)*math.cos(cpLat), math.cos(D/R)-math.sin(cpLat)*math.sin(lat)) #left = cpLon + math.atan2(-1*math.sin(D/R)*math.cos(cpLat), math.cos(D/R)-math.sin(cpLat)*math.sin(lat)) #QMessageBox.warning(None, u"Bild Nummern", "{0}, {1}, {2}, {3}".format(math.degrees(top), math.degrees(bottom), math.degrees(left), math.degrees(right))) #rect = QgsRectangle(math.degrees(left), math.degrees(bottom), math.degrees(right), math.degrees(top)) #l = math.degrees(left) #b = math.degrees(bottom) #r = math.degrees(right) #t = math.degrees(top) p1 = QgsGeometry.fromPointXY(QgsPointXY(left, bottom)) p2 = QgsGeometry.fromPointXY(QgsPointXY(right, bottom)) p3 = QgsGeometry.fromPointXY(QgsPointXY(right, top)) p4 = QgsGeometry.fromPointXY(QgsPointXY(left, top)) #p1.rotate(kappa+90, p) #p2.rotate(kappa+90, p) #p3.rotate(kappa+90, p) #p4.rotate(kappa+90, p) pol = [[ p1.asPoint(), p2.asPoint(), p3.asPoint(), p4.asPoint() ]] geom = QgsGeometry.fromPolygonXY(pol) geom.rotate(kappaMetric, pMetric) #Transform to DestinationCRS ctB = QgsCoordinateTransform(calcCrs, self.fpLayer.crs(), QgsProject.instance()) geom.transform(ctB) feat = QgsFeature(self.fpLayer.fields()) feat.setGeometry(geom) feat.setAttribute('filmnummer', self.currentFilmNumber) feat.setAttribute('bildnummer', ft['bildnummer']) da = QgsDistanceArea() da.setEllipsoid(self.fpLayer.crs().ellipsoidAcronym()) feat.setAttribute('shape_length', da.measurePerimeter(geom)) feat.setAttribute('shape_area', da.measureArea(geom)) fpFeats.append(feat) # update Kappa in cpLayer kappasToUpdate[ft.id()] = { ft.fieldNameIndex('kappa'): kappaMetric } iterFeatures.close() iterNext.close() resCAVs = self.cpLayer.dataProvider().changeAttributeValues( kappasToUpdate) QgsMessageLog.logMessage( f"Kappa Update for {kappasToUpdate}, Success: {resCAVs}", tag="APIS", level=Qgis.Success if resCAVs else Qgis.Critical) (res, outFeats) = self.fpLayer.dataProvider().addFeatures(fpFeats) self.fpLayer.updateExtents() if self.canvas.isCachingEnabled(): self.fpLayer.triggerRepaint() else: self.canvas.refresh() else: #Caps QMessageBox.warning(None, "Layer Capabilities!", "Layer Capabilities!") else: #small feature count QMessageBox.warning( None, "Footprints", "Zum Berechnen der senkrecht Footprint müssen mindestens zwei Bilder kartiert werden!" )
def outattrPrep(self, dlg, lyr): feat = QgsFeature() species = '' production = '' most = QDateTime.currentDateTimeUtc() rn = dlg.tableWidget.rowCount() for i in range(rn): if i==0: species = dlg.tableWidget.item(i, 0).text() production = dlg.tableWidget.item(i, 1).text() else: species = species + ' | ' + dlg.tableWidget.item(i, 0).text() production = production + ' | ' + dlg.tableWidget.item(i, 1).text() flds = lyr.dataProvider().fields() feat.setFields(flds, True) feat.setAttribute(feat.fieldNameIndex('localid'), dlg.lineEdit_3.text()) feat.setAttribute(feat.fieldNameIndex('code'), dlg.lineEdit_5.text()) feat.setAttribute(feat.fieldNameIndex('largescale'), dlg.comboBox_4.currentText()) feat.setAttribute(feat.fieldNameIndex('disease'), dlg.comboBox_2.currentText()) feat.setAttribute(feat.fieldNameIndex('animalno'), dlg.lineEdit_6.text()) feat.setAttribute(feat.fieldNameIndex('species'), species) feat.setAttribute(feat.fieldNameIndex('production'), production) feat.setAttribute(feat.fieldNameIndex('year'), dlg.lineEdit_4.text()) feat.setAttribute(feat.fieldNameIndex('status'), dlg.comboBox_3.currentText()) feat.setAttribute(feat.fieldNameIndex('suspect'), self.dateCheck(dlg.dateEdit.date())) feat.setAttribute(feat.fieldNameIndex('confirmation'), self.dateCheck(dlg.dateEdit_2.date())) feat.setAttribute(feat.fieldNameIndex('expiration'), self.dateCheck(dlg.dateEdit_3.date())) feat.setAttribute(feat.fieldNameIndex('notes'), dlg.textEdit.toPlainText()) feat.setAttribute(feat.fieldNameIndex('hrid'), self.hashIDer(most)) feat.setAttribute(feat.fieldNameIndex('timestamp'), most.toString('dd/MM/yyyy hh:mm:ss')) return feat