How to format structured addresses correctly for North America?

  • First, thank you for DAVdroid! It works well, and I appreciate your support of f-droid and Free software.

    Problem: Structured addresses in contacts synced by DAVdroid are formatted incorrectly for North America.

    123 Street Ave
    Anytown, ST 12345

    123 Street Ave
    12345 Anytown

    Or, more succinctly, I’d expect:
    Street POBox Extended \n City, Region Postcode \n Country
    But I get:
    Streed POBox Extended \n Postcode City \n Region \n Country


    It’s my understanding is that this is because my canonical address book, at FastMail, only supports structured address entry and does not set a separate ADR LABEL field. Therefore, vcard4android takes it upon itself to generate a formatted address, and selects a formatting that’s great for much of Europe, but non-conforming for the US and Canada.

    Last year, you mentioned that DAVdroid could either generate its own formatted address or leave it up to Android, but that Android’s own generated addresses looked “very strange.” Do they, by chance, match the expected format above?

    If I edit the formatted address on my device using the stock Android contacts application, then the structured data is lost and replaced with a single Street field containing the entire formatted address.


    I appreciate that there are no perfect solutions here, but what are some possible ways for my addresses to end up formatted correctly on my device? Off the top of my head, it seems like one of the follow paths may be fruitful:

    1. Give up on structured data, manually enter all of my addresses, formatted, into the Street field in FastMail.
    2. Allow users to opt-out of DAVdroid generating its own formatted addresses.
    3. Allow users to specify their own formatted address template.
    4. Have DAVdroid switch address formats based on Country.
    5. Attempt to auto-detect US / Canadian addresses and format them accordingly.
    6. Fork DAVdroid, make an American version that formats addresses as above. Probably OK, since we generally ignore the rest of the world’s standards and conventions anyways.
    7. Something else entirely?

    Any thoughts on what path would be most reasonable?

  • Note to self: A few projects that might be interesting trailheads for dealing with address formatting / parsing: openvenues/libpostal, opencagedata/address-formatting, and commerceguys/addressing.

    Edit: Also, Mapzen has a good blog post on using libpostal and address-formatting to do this sort of thing.

Similar topics