Skip to content

Improve Feature Type Grouping Logic to Avoid Relying on layer_type Field #58

@longshuicy

Description

@longshuicy

Currently, the group-by functionality for dataset_category is driven automatically by extracting values from dataset labels:

const [groupBy, setGroupBy] = useState('');
useEffect(() => {
  if (!groupBy && groupByOptions[0]) {
    setGroupBy(groupByOptions[0]);
  }
}, [groupByOptions]);

In contrast, the group-by logic for feature type relies on the resolveFeatureType() function. However, this function skips feature type resolution if the dataset is marked as a raster:

if (dataset.layer_type === 'raster') {
  return dataset;
}

This means feature type inference is bypassed based on the layer_type, which assumes the layer_type is correctly pre-set by the user. This dependency introduces a potential risk of incorrect grouping behavior if the layer_type is missing or incorrectly set in the dataset metadata.

Proposed Improvement

We may need to revisit and improve the logic:

  • Consider making feature type resolution more robust, even for raster layers.
  • Add a fallback mechanism when layer_type is not defined or unreliable.
  • Optionally log or warn when skipping feature type resolution due to missing or invalid layer_type.

Dataset Interface for Reference

export interface Dataset {
  layer_id: string;
  layer_type: LayerType;
  display_name: string;
  description: string;
  default_style_name?: string;
  ogc_service_url: string;
  timestamps: string[];
  unit?: string;
  labels: {
    dataset_category: string;
    [key: string]: string;
  };
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions