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 _remove_prev_layer(self): """ Removes previous temporary layer :return: None :rtype: None """ if self.prev_temp_mem_layer and len(gpx_view.get_layer_by_name(self.temp_layer_name)) != 0: gpx_view.remove_vertex(self.map_canvas, self.prev_point_row_attr) gpx_view.remove_map_layer(self.map_canvas, self.prev_temp_mem_layer) return True
def _refresh_map_canvas(self): """ Refresh map canvas on file source or feature type change :return: None :rtype: None """ curr_layer = vector_layer(self.sp_table, geom_column=self.sp_col) layer_extent = curr_layer.extent() gpx_view.remove_vertex(self.map_canvas, self.point_row_attr) self.map_canvas.setExtent(layer_extent) self.map_canvas.refresh()
def closeEvent(self, event): """ Closes the import dialog when called :param event: Close event :return: None :rtype: None """ if len(gpx_view.get_layer_by_name(self.temp_layer_name)) != 0: gpx_view.remove_vertex(self.map_canvas, self.point_row_attr) gpx_view.remove_map_layer(self.map_canvas, self.temp_mem_layer) if self.point_row_attr: self._refresh_map_canvas() self.save_handler()