Method: AtlasEngine::Pt::AddressImporter::OpenAddress::Mapper#map

Defined in:
app/countries/atlas_engine/pt/address_importer/open_address/mapper.rb

#map(feature) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'app/countries/atlas_engine/pt/address_importer/open_address/mapper.rb', line 12

def map(feature)
  city, street, number, unit, postcode = feature["properties"].values_at(
    "city",
    "street",
    "number",
    "unit",
    "postcode",
  )
  {
    source_id: openaddress_source_id(feature),
    locale: @locale,
    country_code: "PT",
    province_code: province_code_from_zip(postcode),
    # Omitted: region1..4
    city: [city.titleize],
    suburb: nil,
    zip: postcode,
    street: street.titleize,
    building_and_unit_ranges: housenumber_and_unit(number, unit),
    latitude: geometry(feature)&.at(1),
    longitude: geometry(feature)&.at(0),
  }
end