Class: OvertureMaps::Import::LocationBasedRunner
- Inherits:
-
Object
- Object
- OvertureMaps::Import::LocationBasedRunner
- Defined in:
- lib/overture_maps/import/location_based_runner.rb
Overview
Orchestrates a location-based import: resolves the location (bbox string or division name) to a bounding box, downloads or reuses a bbox-filtered parquet extract per feature type, and streams it into the target model via Runner.
Themes map one or more feature types to models:
models: { "segment" => OvertureSegment, "connector" => OvertureConnector }
For single-model themes, model_class: alone is enough.
This class never prompts or exits. Interactive behavior is injected by the rake layer through callbacks:
select_division: ->(results) { result or nil } nil aborts
confirm_cached: ->(path) { :use | :refresh | :abort }
Without callbacks (library/job usage) it picks the largest matching division and reuses exact cache hits.
Instance Attribute Summary collapse
-
#bbox ⇒ Object
readonly
Returns the value of attribute bbox.
-
#error_count ⇒ Object
readonly
Returns the value of attribute error_count.
-
#errors ⇒ Object
readonly
Returns the value of attribute errors.
-
#imported_count ⇒ Object
readonly
Returns the value of attribute imported_count.
-
#location ⇒ Object
readonly
Returns the value of attribute location.
-
#theme ⇒ Object
readonly
Returns the value of attribute theme.
Instance Method Summary collapse
-
#initialize(theme:, location:, model_class: nil, models: nil, categories: nil, batch_size: nil, release: nil, output_dir: nil, select_division: nil, confirm_cached: nil) ⇒ LocationBasedRunner
constructor
A new instance of LocationBasedRunner.
- #run ⇒ Object
- #success? ⇒ Boolean
Constructor Details
#initialize(theme:, location:, model_class: nil, models: nil, categories: nil, batch_size: nil, release: nil, output_dir: nil, select_division: nil, confirm_cached: nil) ⇒ LocationBasedRunner
Returns a new instance of LocationBasedRunner.
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/overture_maps/import/location_based_runner.rb', line 23 def initialize(theme:, location:, model_class: nil, models: nil, categories: nil, batch_size: nil, release: nil, output_dir: nil, select_division: nil, confirm_cached: nil) @theme = theme @location = location @models = resolve_models(model_class, models) @categories = categories @batch_size = batch_size @release = Releases.validate!(release || Releases.current) @output_dir = output_dir @select_division = select_division @confirm_cached = confirm_cached @imported_count = 0 @error_count = 0 @errors = [] end |
Instance Attribute Details
#bbox ⇒ Object (readonly)
Returns the value of attribute bbox.
21 22 23 |
# File 'lib/overture_maps/import/location_based_runner.rb', line 21 def bbox @bbox end |
#error_count ⇒ Object (readonly)
Returns the value of attribute error_count.
21 22 23 |
# File 'lib/overture_maps/import/location_based_runner.rb', line 21 def error_count @error_count end |
#errors ⇒ Object (readonly)
Returns the value of attribute errors.
21 22 23 |
# File 'lib/overture_maps/import/location_based_runner.rb', line 21 def errors @errors end |
#imported_count ⇒ Object (readonly)
Returns the value of attribute imported_count.
21 22 23 |
# File 'lib/overture_maps/import/location_based_runner.rb', line 21 def imported_count @imported_count end |
#location ⇒ Object (readonly)
Returns the value of attribute location.
21 22 23 |
# File 'lib/overture_maps/import/location_based_runner.rb', line 21 def location @location end |
#theme ⇒ Object (readonly)
Returns the value of attribute theme.
21 22 23 |
# File 'lib/overture_maps/import/location_based_runner.rb', line 21 def theme @theme end |
Instance Method Details
#run ⇒ Object
40 41 42 43 44 45 46 |
# File 'lib/overture_maps/import/location_based_runner.rb', line 40 def run @bbox = resolve_bbox log "Bounding box: #{bbox} (release #{@release})" @models.each { |type, model_class| import_type(type, model_class) } self end |
#success? ⇒ Boolean
48 49 50 |
# File 'lib/overture_maps/import/location_based_runner.rb', line 48 def success? @error_count.zero? end |