app/models/geographic_area.rb
# Hack.  If TDWG Gazetteer data are eliminated this needs to be removed.
Hack.  If TDWG Gazetteer data are eliminated this needs to be removed.
Hack . If TDWG Gazetteer data are eliminated this needs to be removed .
def categorize_tdwg
    if g = GeographicArea
      .where(name: name) 
      .where('level0_id = parent_id') 
      .where.not(geographic_area_type: [111,112]).any? 
    return {state: name}
    end
    return {country: 'United States'} if name =~ /U\.S\.A/
    return {country: 'Canada'} if name =~ /Canada/
    return {country: 'Chile'} if name =~ /Chile.Central/
    if g = GeographicArea
      .where(name: name) 
      .where('level0_id = id') 
      .where.not(geographic_area_type: [111,112]).any? 
    return {country: name}
    end
    {}
  end
def categorize_tdwg if g = GeographicArea . where ( name : name ) . where ( 'level0_id = parent_id' ) . where . not ( geographic_area_type : [ 111 , 112 ] ) . any? return { state : name } end return { country : 'United States' } if name =~ / U \. S \. A / return { country : 'Canada' } if name =~ / Canada / return { country : 'Chile' } if name =~ / Chile.Central / if g = GeographicArea . where ( name : name ) . where ( 'level0_id = id' ) . where . not ( geographic_area_type : [ 111 , 112 ] ) . any? return { country : name } end { } end
Hack.
Hack .
# shares the same name # parent is a country # not another TDWG record # TODO: more manual checks can be added here intermediate areas like "Western Canada" # Many other countries are a mess here. # shares the same name # self is a country # not another TDWG record