Class: AtlasEngine::Au::AddressImporter::OpenAddress::Mapper

Inherits:
AtlasEngine::AddressImporter::OpenAddress::DefaultMapper show all
Defined in:
app/countries/atlas_engine/au/address_importer/open_address/mapper.rb

Instance Method Summary collapse

Methods inherited from AtlasEngine::AddressImporter::OpenAddress::DefaultMapper

#initialize

Methods included from AtlasEngine::AddressImporter::OpenAddress::FeatureHelper

#geometry, #housenumber_and_unit, #normalize_zip, #openaddress_source_id, #province_code_from_name, #province_code_from_zip, #province_from_code

Constructor Details

This class inherits a constructor from AtlasEngine::AddressImporter::OpenAddress::DefaultMapper

Instance Method Details

#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
35
36
# File 'app/countries/atlas_engine/au/address_importer/open_address/mapper.rb', line 12

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: "AU",
    province_code: province_from_code(region),
    # Omitted: region1..4
    city: [city.titleize],
    suburb: nil, # District field seems to always be empty and not useful
    zip: postcode,
    street: street.titleize,
    # NOTE: unit seems to be 'UNIT|SUITE|CARSPACE|SHOP|VILLA N'. Do we strip text before the number?
    building_and_unit_ranges: housenumber_and_unit(number, unit),
    latitude: geometry(feature)&.at(1),
    longitude: geometry(feature)&.at(0),
  }
end