An open API service indexing awesome lists of open source software.

https://github.com/woheller69/androidaddressformatter

Android library for formatting data in the OpenStreetMaps address field generated by the Nominatim API.
https://github.com/woheller69/androidaddressformatter

Last synced: 1 day ago
JSON representation

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

Awesome Lists containing this project

README

          

# 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](https://github.com/OpenCageData/address-formatting/) team,
who did the work of collating the postal address formats upon which this library relies,
and to the work of [Placemarkt](https://github.com/placemarkt/address-formatter-java) who build the code for Java.

### Installation

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

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

Add the library dependency to your build.gradle file.

```gradle
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](LICENSE) for details.

### Contributions

Contributions welcome. Be nice.

### Acknowledgements
- [Java implementation](https://github.com/placemarkt/address-formatter-java)
- [Javascript implementation](https://github.com/fragaria/address-formatter)