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)

Method Summary

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
# 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

  # 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"
    )
  }

  validates :geographic_item, presence: true unless ENV['NO_GEO_VALID']
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
# 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

  # 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"
    )
  }

  validates :geographic_item, presence: true unless ENV['NO_GEO_VALID']
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
# 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

  # 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"
    )
  }

  validates :geographic_item, presence: true unless ENV['NO_GEO_VALID']
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
# 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

  # 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"
    )
  }

  validates :geographic_item, presence: true unless ENV['NO_GEO_VALID']
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
# 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

  # 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"
    )
  }

  validates :geographic_item, presence: true unless ENV['NO_GEO_VALID']
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
# 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

  # 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"
    )
  }

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