def _save_feature(self): """ Load and save feature to current active layer """ # If qgs_point_list length is 0, then it is in edit mode so # allow attribute edit too. if len(self.qgs_point_list) > 0: new_geometry = gpx_view.create_geometry(self.geom_type, self.qgs_point_list) geometry_wkb = new_geometry.exportToWkt() srid = self.entity.columns[self.sp_col].srid model = self.entity_editor.model() setattr(model, self.sp_col, 'SRID={};{}'.format(srid, geometry_wkb)) self.geometry_added = True # validate empty GPS field if not self.geometry_added and self.model is None: qg.QMessageBox.critical( self, self.tr('Missing GPS Feature Error'), self.tr( 'You have not added a GPS Feature. \n' 'Please, add a GPS feature in the Feature Import tab or\n' 'digitize a feature to add a record.')) return # prevents duplicate entry self.load_bt.setDisabled(True) self.entity_editor.save_parent_editor() if self.reload: self._reload_entity_editor() self.load_bt.setDisabled(False) else: self.close()
def _update_feature(self, point_list, new_point_row_attr): """ Update feature :param point_list: Updated QGS points :param new_point_row_attr: Updated GPX data attributes :return: None :rtype: None """ if point_list: self.qgs_point_list = list(point_list) gpx_view.remove_vertex(self.map_canvas, self.prev_point_row_attr) gpx_view.delete_feature(self.map_canvas, self.temp_mem_layer) self.point_row_attr = gpx_view.update_point_row_attr( self.map_canvas, self.point_row_attr, new_point_row_attr ) self.point_row_attr = gpx_view.set_feature_vertices_marker( self.map_canvas, self.point_row_attr ) new_geometry = gpx_view.create_geometry(self.geom_type, point_list) data_provider = self.temp_mem_layer.dataProvider() gpx_view.add_feature(data_provider, new_geometry) gpx_view.commit_feature_edits(self.temp_mem_layer) self.prev_point_row_attr = list(self.point_row_attr) else: gpx_view.remove_vertex(self.map_canvas, self.prev_point_row_attr) gpx_view.delete_feature(self.map_canvas, self.temp_mem_layer)
def _save_feature(self): """ Load and save feature to current active layer """ new_geometry = gpx_view.create_geometry( self.geom_type, self.qgs_point_list ) geometry_wkb = new_geometry.exportToWkt() srid = self.entity.columns[self.sp_col].srid model = self.entity_editor.model() setattr(model, self.sp_col, 'SRID={};{}'.format(srid, geometry_wkb)) # prevents duplicate entry self.load_bt.setDisabled(True) self.entity_editor.save_parent_editor() self._reload_entity_editor() self.load_bt.setDisabled(False)
def _save_feature(self): """ Load and save feature to current active layer """ # If qgs_point_list length is 0, then it is in edit mode so # allow attribute edit too. if len(self.qgs_point_list) > 0: new_geometry = gpx_view.create_geometry( self.geom_type, self.qgs_point_list ) geometry_wkb = new_geometry.exportToWkt() srid = self.entity.columns[self.sp_col].srid model = self.entity_editor.model() setattr(model, self.sp_col, 'SRID={};{}'.format(srid, geometry_wkb)) self.geometry_added = True # validate empty GPS field if not self.geometry_added and self.model is None: qg.QMessageBox.critical( self, self.tr('Missing GPS Feature Error'), self.tr( 'You have not added a GPS Feature. \n' 'Please, add a GPS feature in the Feature Import tab or\n' 'digitize a feature to add a record.' ) ) return # prevents duplicate entry self.load_bt.setDisabled(True) self.entity_editor.save_parent_editor() if self.reload: self._reload_entity_editor() self.load_bt.setDisabled(False) else: self.close()