Class: OvertureMaps::Models::ImportedArea

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
lib/overture_maps/models/imported_area.rb

Overview

Bookkeeping for every area/type combination that has been imported: which release the rows came from and the bbox they cover. This is what overture_maps:sync iterates to bring tables up to a newer release.

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.record!(theme:, feature_type:, model_class:, bbox:, release:, records_count:) ⇒ Object

Upserts the bookkeeping row after an import.



29
30
31
32
33
34
35
36
37
38
39
# File 'lib/overture_maps/models/imported_area.rb', line 29

def self.record!(theme:, feature_type:, model_class:, bbox:, release:, records_count:)
  area = find_or_initialize_by(theme: theme, feature_type: feature_type, slug: bbox.slug)
  area.update!(
    model_class_name: model_class.name,
    bbox_xmin: bbox.min_lng, bbox_xmax: bbox.max_lng,
    bbox_ymin: bbox.min_lat, bbox_ymax: bbox.max_lat,
    release: release,
    records_count: records_count
  )
  area
end

Instance Method Details

#model_classObject



24
25
26
# File 'lib/overture_maps/models/imported_area.rb', line 24

def model_class
  model_class_name.constantize
end

#to_bounding_boxObject



16
17
18
19
20
21
22
# File 'lib/overture_maps/models/imported_area.rb', line 16

def to_bounding_box
  BoundingBox.new(
    lat1: bbox_ymin, lng1: bbox_xmin,
    lat2: bbox_ymax, lng2: bbox_xmax,
    display_name: slug
  )
end