Class: GeographicAreasGeographicItem

Inherits:
ApplicationRecord show all
Includes:
Shared::IsData
Defined in:
app/models/geographic_areas_geographic_item.rb

Overview

A GeographicAreaGeographicItem is an assertion that a GeographicArea was defined by a shape (GeographicItem) according to some source. The assertion may be bound by time.

Instance Attribute Summary (collapse)

Class Method Summary (collapse)

Methods included from ActiverecordUtilities

#trim_attributes

Instance Attribute Details

- (String) data_origin

The origin of this shape associations, take from SFGs /gaz data

Returns:

  • (String)


31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
# File 'app/models/geographic_areas_geographic_item.rb', line 31

class GeographicAreasGeographicItem < ApplicationRecord
  include Shared::IsData

  belongs_to :geographic_area, inverse_of: :geographic_areas_geographic_items
  belongs_to :geographic_item, inverse_of: :geographic_areas_geographic_items

  validates :geographic_area, presence: true
  validates :geographic_item, presence: true unless ENV['NO_GEO_VALID']

  # # Postgis specific SQL
  # scope :ordered_by_data_origin, lambda {
  #   order(
  #     "CASE geographic_areas_geographic_items.data_origin
  #      WHEN 'ne_country' THEN 1
  #      WHEN 'ne_state' THEN 2
  #      WHEN 'gadm' THEN 3
  #      ELSE 4
  #      END"
  #   )
  # }

  # https://github.com/DimaSavitsky/test-prototype/blob/df3c7c792331e19adfbb2065c7185623cabef24e/app/models/onet/occupation.rb#L61
  def self.ordered_by_data_origin
    t = arel_table
    c = Arel::Nodes::Case.new(t[:data_origin])
    c.when('ne_country').then(1)
    c.when('ne_state').then(2)
    c.when('gadm').then(2)
    c.else(4)
    
    order(c)
  end


end

- (String) date_valid_from

The verbatim value taken from the source data as to when this shape was first valid for the associated

GeographicArea (name)

Returns:

  • (String)


31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
# File 'app/models/geographic_areas_geographic_item.rb', line 31

class GeographicAreasGeographicItem < ApplicationRecord
  include Shared::IsData

  belongs_to :geographic_area, inverse_of: :geographic_areas_geographic_items
  belongs_to :geographic_item, inverse_of: :geographic_areas_geographic_items

  validates :geographic_area, presence: true
  validates :geographic_item, presence: true unless ENV['NO_GEO_VALID']

  # # Postgis specific SQL
  # scope :ordered_by_data_origin, lambda {
  #   order(
  #     "CASE geographic_areas_geographic_items.data_origin
  #      WHEN 'ne_country' THEN 1
  #      WHEN 'ne_state' THEN 2
  #      WHEN 'gadm' THEN 3
  #      ELSE 4
  #      END"
  #   )
  # }

  # https://github.com/DimaSavitsky/test-prototype/blob/df3c7c792331e19adfbb2065c7185623cabef24e/app/models/onet/occupation.rb#L61
  def self.ordered_by_data_origin
    t = arel_table
    c = Arel::Nodes::Case.new(t[:data_origin])
    c.when('ne_country').then(1)
    c.when('ne_state').then(2)
    c.when('gadm').then(2)
    c.else(4)
    
    order(c)
  end


end

- (String) date_valid_to

The verbatim data value taken from the source data as to when this shape was last valid for the associated

GeographicArea (name)

Returns:

  • (String)


31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
# File 'app/models/geographic_areas_geographic_item.rb', line 31

class GeographicAreasGeographicItem < ApplicationRecord
  include Shared::IsData

  belongs_to :geographic_area, inverse_of: :geographic_areas_geographic_items
  belongs_to :geographic_item, inverse_of: :geographic_areas_geographic_items

  validates :geographic_area, presence: true
  validates :geographic_item, presence: true unless ENV['NO_GEO_VALID']

  # # Postgis specific SQL
  # scope :ordered_by_data_origin, lambda {
  #   order(
  #     "CASE geographic_areas_geographic_items.data_origin
  #      WHEN 'ne_country' THEN 1
  #      WHEN 'ne_state' THEN 2
  #      WHEN 'gadm' THEN 3
  #      ELSE 4
  #      END"
  #   )
  # }

  # https://github.com/DimaSavitsky/test-prototype/blob/df3c7c792331e19adfbb2065c7185623cabef24e/app/models/onet/occupation.rb#L61
  def self.ordered_by_data_origin
    t = arel_table
    c = Arel::Nodes::Case.new(t[:data_origin])
    c.when('ne_country').then(1)
    c.when('ne_state').then(2)
    c.when('gadm').then(2)
    c.else(4)
    
    order(c)
  end


end

- (Integer) geographic_area_id

The id of a GeographicArea that represents the area of this association.

Returns:

  • (Integer)


31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
# File 'app/models/geographic_areas_geographic_item.rb', line 31

class GeographicAreasGeographicItem < ApplicationRecord
  include Shared::IsData

  belongs_to :geographic_area, inverse_of: :geographic_areas_geographic_items
  belongs_to :geographic_item, inverse_of: :geographic_areas_geographic_items

  validates :geographic_area, presence: true
  validates :geographic_item, presence: true unless ENV['NO_GEO_VALID']

  # # Postgis specific SQL
  # scope :ordered_by_data_origin, lambda {
  #   order(
  #     "CASE geographic_areas_geographic_items.data_origin
  #      WHEN 'ne_country' THEN 1
  #      WHEN 'ne_state' THEN 2
  #      WHEN 'gadm' THEN 3
  #      ELSE 4
  #      END"
  #   )
  # }

  # https://github.com/DimaSavitsky/test-prototype/blob/df3c7c792331e19adfbb2065c7185623cabef24e/app/models/onet/occupation.rb#L61
  def self.ordered_by_data_origin
    t = arel_table
    c = Arel::Nodes::Case.new(t[:data_origin])
    c.when('ne_country').then(1)
    c.when('ne_state').then(2)
    c.when('gadm').then(2)
    c.else(4)
    
    order(c)
  end


end

- (Integer) geographic_item_id

The id of a GeographicItem that represents the geography of this association.

Returns:

  • (Integer)


31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
# File 'app/models/geographic_areas_geographic_item.rb', line 31

class GeographicAreasGeographicItem < ApplicationRecord
  include Shared::IsData

  belongs_to :geographic_area, inverse_of: :geographic_areas_geographic_items
  belongs_to :geographic_item, inverse_of: :geographic_areas_geographic_items

  validates :geographic_area, presence: true
  validates :geographic_item, presence: true unless ENV['NO_GEO_VALID']

  # # Postgis specific SQL
  # scope :ordered_by_data_origin, lambda {
  #   order(
  #     "CASE geographic_areas_geographic_items.data_origin
  #      WHEN 'ne_country' THEN 1
  #      WHEN 'ne_state' THEN 2
  #      WHEN 'gadm' THEN 3
  #      ELSE 4
  #      END"
  #   )
  # }

  # https://github.com/DimaSavitsky/test-prototype/blob/df3c7c792331e19adfbb2065c7185623cabef24e/app/models/onet/occupation.rb#L61
  def self.ordered_by_data_origin
    t = arel_table
    c = Arel::Nodes::Case.new(t[:data_origin])
    c.when('ne_country').then(1)
    c.when('ne_state').then(2)
    c.when('gadm').then(2)
    c.else(4)
    
    order(c)
  end


end

- (String) origin_gid

The gid (row number) taken from the shape table from the source

Returns:

  • (String)


31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
# File 'app/models/geographic_areas_geographic_item.rb', line 31

class GeographicAreasGeographicItem < ApplicationRecord
  include Shared::IsData

  belongs_to :geographic_area, inverse_of: :geographic_areas_geographic_items
  belongs_to :geographic_item, inverse_of: :geographic_areas_geographic_items

  validates :geographic_area, presence: true
  validates :geographic_item, presence: true unless ENV['NO_GEO_VALID']

  # # Postgis specific SQL
  # scope :ordered_by_data_origin, lambda {
  #   order(
  #     "CASE geographic_areas_geographic_items.data_origin
  #      WHEN 'ne_country' THEN 1
  #      WHEN 'ne_state' THEN 2
  #      WHEN 'gadm' THEN 3
  #      ELSE 4
  #      END"
  #   )
  # }

  # https://github.com/DimaSavitsky/test-prototype/blob/df3c7c792331e19adfbb2065c7185623cabef24e/app/models/onet/occupation.rb#L61
  def self.ordered_by_data_origin
    t = arel_table
    c = Arel::Nodes::Case.new(t[:data_origin])
    c.when('ne_country').then(1)
    c.when('ne_state').then(2)
    c.when('gadm').then(2)
    c.else(4)
    
    order(c)
  end


end

Class Method Details

+ (Object) ordered_by_data_origin



53
54
55
56
57
58
59
60
61
62
# File 'app/models/geographic_areas_geographic_item.rb', line 53

def self.ordered_by_data_origin
  t = arel_table
  c = Arel::Nodes::Case.new(t[:data_origin])
  c.when('ne_country').then(1)
  c.when('ne_state').then(2)
  c.when('gadm').then(2)
  c.else(4)
  
  order(c)
end