[go: nahoru, domu]

Skip to content

Android library for formatting data in the OpenStreetMaps address field generated by the Nominatim API.

License

Notifications You must be signed in to change notification settings

woheller69/AndroidAddressFormatter

Repository files navigation

Android Address Formatter

Overview

A package for formatting data in the OpenStreetMaps address field generated by the Nominatim API. This project was only possible thanks to the amazing OpenCage team, who did the work of collating the postal address formats upon which this library relies, and to the work of Placemarkt who build the code for Java.

Installation

Add the JitPack repository to your root build.gradle at the end of repositories:

allprojects {
  repositories {
    ...
    maven { url 'https://jitpack.io' }
  }
}

Add the library dependency to your build.gradle file.

dependencies {
    implementation 'com.github.woheller69:AndroidAddressFormatter:-SNAPSHOT'
}

API

// Constructor
AndroidAddressFormatter(Boolean abbreviate, Boolean appendCountry, Boolean appendUnknown)

abbreviate: true: use abbreviations
appendCountry: true: show country name
appendUnknown: true: show unknown address parameters as additional string

// Methods
format(String json)
format(String json, String fallbackCountryCode)

Use

AndroidAddressFormatter formatter = new AndroidAddressFormatter(false, false, false);
String json = "{country_code: 'US',\n"
          + "house_number: '301',\n"
          + "road: 'Hamilton Avenue',\n"
          + "neighbourhood: 'Crescent Park',\n"
          + "city: 'Palo Alto',\n"
          + "postcode: '94303',\n"
          + "county: 'Santa Clara County',\n"
          + "state: 'California',\n"
          + "country: 'United States',}";
String formatted = formatter.format(json);
/*
301 Hamilton Avenue
Palo Alto, CA 94303
United States of America
*/

License

This project is licensed under the MIT License. See the LICENSE for details.

Contributions

Contributions welcome. Be nice.

Acknowledgements

About

Android library for formatting data in the OpenStreetMaps address field generated by the Nominatim API.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages