def _populate_layers(self): self.stdm_layers_combo.clear() if self._curr_profile is None: return self.spatial_unit = self._curr_profile. \ social_tenure.spatial_unit # Get entities containing geometry # columns based on the config info config_entities = self._curr_profile.entities self.geom_entities = [ ge for ge in config_entities.values() if ge.TYPE_INFO == 'ENTITY' and ge.has_geometry_column() ] self._profile_spatial_layers = [] self.sp_tables = spatial_tables() for e in self.geom_entities: table_name = e.name if table_name in self.sp_tables: for gc in e.geometry_columns(): column_name = gc.name display_name = gc.layer_display() self._add_geometry_column_to_combo(table_name, column_name, display_name, gc) # Add geometry entity to the collection self._profile_spatial_layers.append(table_name) # Append the corresponding(profile) # view to the list of entity names str_view = self._curr_profile.social_tenure.view_name if str_view in self.sp_tables: self.str_view_geom_columns = table_column_names(str_view, True) if len(self.str_view_geom_columns) > 0: # Pick the first column # geom_col = geom_columns[0] for i, geom_col in enumerate(self.str_view_geom_columns): if i > 0: view_layer_name = self._curr_profile. \ social_tenure.layer_display() view_layer_name = '{}.{}'.format( view_layer_name, geom_col) else: view_layer_name = self._curr_profile. \ social_tenure.layer_display() self._add_geometry_column_to_combo( str_view, geom_col, view_layer_name, self._curr_profile.social_tenure) # Append view to the list of spatial layers self._profile_spatial_layers.append(view_layer_name)
def set_layer_entity(self): self.layer_table = self.get_layer_source( self.iface.activeLayer() ) if self.layer_table in spatial_tables(): self.entity = self.current_profile.entity_by_name( self.layer_table ) else: self.treeview_error('The layer is not a spatial entity layer. ')
def feature_layer(self, active_layer): """ Check whether the layer is feature layer or not. :param active_layer: The layer to be checked :type QGIS vectorlayer :return: Boolean """ layer_source = self.get_layer_source(active_layer) if layer_source in spatial_tables(): return True else: not_feature_msg = QApplication.translate( 'FeatureDetails', 'You have selected a non-feature layer. ' 'Please select a feature layer to view the details.' ) QMessageBox.information( self.iface.mainWindow(), "Error", not_feature_msg ) return False
def _populate_layers(self): self.stdm_layers_combo.clear() if self._curr_profile is None: return self.spatial_units = self._curr_profile.social_tenure.spatial_units # Get entities containing geometry # columns based on the config info config_entities = self._curr_profile.entities self.geom_entities = [ ge for ge in config_entities.values() if ge.TYPE_INFO == 'ENTITY' and ge.has_geometry_column() ] self._profile_spatial_layers = [] self.sp_tables = spatial_tables() for e in self.geom_entities: table_name = e.name if table_name in self.sp_tables: for i, gc in enumerate(e.geometry_columns()): column_name = gc.name display_name = gc.layer_display() if i > 0: display_name = '{}.{}'.format(display_name, gc.name) self._add_geometry_column_to_combo(table_name, column_name, display_name, gc) # Add geometry entity to the collection self._profile_spatial_layers.append(table_name) # Append the corresponding(profile) view to the list of entity names str_views = list(self._curr_profile.social_tenure.views.keys()) for str_view in str_views: if str_view in self.sp_tables: self.str_view_geom_columns = table_column_names(str_view, True) if len(self.str_view_geom_columns) > 0: # Pick the first column for i, geom_col in enumerate(self.str_view_geom_columns): view_layer_name = str_view if i > 0: view_layer_name = '{}.{}'.format( view_layer_name, geom_col) self._add_geometry_column_to_combo( str_view, geom_col, view_layer_name, self._curr_profile.social_tenure) # Append view to the list of spatial layers self._profile_spatial_layers.append(str_view) # add old config views and custom views. for sp_table in self.sp_tables: if sp_table in pg_views() and sp_table not in str_views and \ sp_table in profile_and_user_views( self._curr_profile): view_geom_columns = table_column_names(sp_table, True) for geom_col in view_geom_columns: view_layer_name = '{}.{}'.format(sp_table, geom_col) self._add_geometry_column_to_combo(sp_table, geom_col, view_layer_name, geom_col)
def _populate_layers(self): self.stdm_layers_combo.clear() if self._curr_profile is None: return self.spatial_units = self._curr_profile.social_tenure.spatial_units # Get entities containing geometry # columns based on the config info config_entities = self._curr_profile.entities self.geom_entities = [ ge for ge in config_entities.values() if ge.TYPE_INFO == 'ENTITY' and ge.has_geometry_column() ] self._profile_spatial_layers = [] self.sp_tables = spatial_tables() for e in self.geom_entities: table_name = e.name if table_name in self.sp_tables: for i, gc in enumerate(e.geometry_columns()): column_name = gc.name display_name = gc.layer_display() if i > 0: display_name = u'{}.{}'.format(display_name, gc.name) self._add_geometry_column_to_combo( table_name, column_name, display_name, gc ) # Add geometry entity to the collection self._profile_spatial_layers.append( table_name ) # Append the corresponding(profile) view to the list of entity names str_views = self._curr_profile.social_tenure.views.keys() for str_view in str_views: if str_view in self.sp_tables: self.str_view_geom_columns = table_column_names( str_view, True ) if len(self.str_view_geom_columns) > 0: # Pick the first column for i, geom_col in enumerate(self.str_view_geom_columns): view_layer_name = str_view if i > 0: view_layer_name = '{}.{}'.format( view_layer_name, geom_col ) self._add_geometry_column_to_combo( str_view, geom_col, view_layer_name, self._curr_profile.social_tenure ) # Append view to the list of spatial layers self._profile_spatial_layers.append( str_view ) # add old config views and custom views. for sp_table in self.sp_tables: if sp_table in pg_views() and sp_table not in str_views and \ sp_table in profile_and_user_views( self._curr_profile): view_geom_columns = table_column_names( sp_table, True ) for geom_col in view_geom_columns: view_layer_name = '{}.{}'.format( sp_table, geom_col ) self._add_geometry_column_to_combo( sp_table, geom_col, view_layer_name, geom_col )