Module: AtlasEngine::AddressImporter::OpenAddress::FeatureHelper
- Extended by:
- T::Helpers, T::Sig
- Included in:
- DefaultMapper
- Defined in:
- app/models/atlas_engine/address_importer/open_address/feature_helper.rb
Instance Method Summary collapse
- #geometry(feature) ⇒ Object
- #housenumber_and_unit(number, unit) ⇒ Object
- #normalize_zip(zip) ⇒ Object
- #openaddress_source_id(feature) ⇒ Object
- #province_code_from_name(district) ⇒ Object
- #province_code_from_zip(zip) ⇒ Object
- #province_from_code(region) ⇒ Object
Instance Method Details
#geometry(feature) ⇒ Object
37 38 39 40 41 42 |
# File 'app/models/atlas_engine/address_importer/open_address/feature_helper.rb', line 37 def geometry(feature) geom = feature["geometry"] if geom.present? && geom["type"] == "Point" geom["coordinates"] end end |
#housenumber_and_unit(number, unit) ⇒ Object
30 31 32 33 34 |
# File 'app/models/atlas_engine/address_importer/open_address/feature_helper.rb', line 30 def housenumber_and_unit(number, unit) return {} if number.blank? { number => unit.present? ? { unit => {} } : {} } end |
#normalize_zip(zip) ⇒ Object
45 46 47 48 49 50 51 |
# File 'app/models/atlas_engine/address_importer/open_address/feature_helper.rb', line 45 def normalize_zip(zip) Worldwide::Zip.normalize( country_code: @country_code, zip: zip, strip_extraneous_characters: true, ) end |
#openaddress_source_id(feature) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'app/models/atlas_engine/address_importer/open_address/feature_helper.rb', line 12 def openaddress_source_id(feature) objid, hash = feature["properties"].values_at("id", "hash") if objid.present? # OA indicates an OpenAddresses-provided ID "OA-#{objid}" elsif hash.present? # Which may come from a different field, hence the hash sign "OA##{hash}" else # AT signifies an Atlas-calculated hash "AT-#{signature(feature)}" end end |
#province_code_from_name(district) ⇒ Object
54 |
# File 'app/models/atlas_engine/address_importer/open_address/feature_helper.rb', line 54 def province_code_from_name(district) = zones_mapping[district.downcase] |
#province_code_from_zip(zip) ⇒ Object
60 61 62 63 64 65 66 67 |
# File 'app/models/atlas_engine/address_importer/open_address/feature_helper.rb', line 60 def province_code_from_zip(zip) @zip_to_province_mapping ||= {} unless @zip_to_province_mapping.key?(zip) province = Worldwide.region(code: @country_code).zone(zip: zip) @zip_to_province_mapping[zip] = province.province? ? province.iso_code : nil end @zip_to_province_mapping[zip] end |
#province_from_code(region) ⇒ Object
57 |
# File 'app/models/atlas_engine/address_importer/open_address/feature_helper.rb', line 57 def province_from_code(region) = zone_codes.include?(region) ? region : nil |