Class: AtlasEngine::AddressImporter::OpenAddress::DefaultMapper
- Inherits:
-
Object
- Object
- AtlasEngine::AddressImporter::OpenAddress::DefaultMapper
- Extended by:
- T::Sig
- Includes:
- FeatureHelper
- Defined in:
- app/models/atlas_engine/address_importer/open_address/default_mapper.rb
Direct Known Subclasses
AtlasEngine::Au::AddressImporter::OpenAddress::Mapper, Bm::AddressImporter::OpenAddress::Mapper, Ch::AddressImporter::OpenAddress::Mapper, It::AddressImporter::OpenAddress::Mapper, Kr::AddressImporter::OpenAddress::Mapper, Pt::AddressImporter::OpenAddress::Mapper, Si::AddressImporter::OpenAddress::Mapper, Tt::AddressImporter::OpenAddress::Mapper, Us::AddressImporter::OpenAddress::Mapper
Instance Method Summary collapse
-
#initialize(country_code:, province_code: nil, locale: nil) ⇒ DefaultMapper
constructor
A new instance of DefaultMapper.
- #map(feature) ⇒ Object
Methods included from FeatureHelper
#geometry, #housenumber_and_unit, #normalize_zip, #openaddress_source_id, #province_code_from_name, #province_code_from_zip, #province_from_code
Constructor Details
#initialize(country_code:, province_code: nil, locale: nil) ⇒ DefaultMapper
Returns a new instance of DefaultMapper.
11 12 13 14 15 |
# File 'app/models/atlas_engine/address_importer/open_address/default_mapper.rb', line 11 def initialize(country_code:, province_code: nil, locale: nil) @country_code = country_code @province_code = province_code @locale = locale end |
Instance Method Details
#map(feature) ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'app/models/atlas_engine/address_importer/open_address/default_mapper.rb', line 18 def map(feature) region, city, street, number, unit, postcode = feature["properties"].values_at( "region", "city", "street", "number", "unit", "postcode", ) { source_id: openaddress_source_id(feature), locale: @locale, country_code: @country_code, province_code: @province_code, region1: region, # Don't titleize. The sources have proper capitalization, and it's a problem for cities like # 's-Graveland, which would get titleized to "'S Graveland" which is wrong. city: [city], suburb: nil, zip: normalize_zip(postcode), street: street, building_and_unit_ranges: housenumber_and_unit(number, unit), latitude: geometry(feature)&.at(1), longitude: geometry(feature)&.at(0), } end |