Skip to content

Specify region type explicitly #620

@noracato

Description

@noracato

Currently we derive the region type (for some reason called group) for datasets by checking the first letters of thegeo_id. Adding more and more region types has caused this if/else method to grow:

def group
    if geo_id.start_with?('GM', 'BEGM', 'DKGM')
      'municipality'
    elsif geo_id.start_with?('WK')
      'district'
    elsif geo_id.start_with?('BU', 'BEBU')
      'neighbourhood'
    elsif geo_id.start_with?('RG')
      'region'
    elsif entso_data_source? || geo_id.start_with?('UKNI') || geo_id.start_with?('GB')
      'country'
    elsif geo_id.start_with?('RES', 'ES')
      'res'
    else
      'province'
    end
 end

in models/dataset.rb.

It would be better to define a new attribute on Dataset, where users can set the region type explicitly. And available region types could be validated through Atlas.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions