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.
- Host: GitHub
- URL: https://github.com/woheller69/androidaddressformatter
- Owner: woheller69
- License: mit
- Created: 2022-09-10T17:14:00.000Z (about 3 years ago)
- Default Branch: master
- Last Pushed: 2022-09-15T09:33:10.000Z (about 3 years ago)
- Last Synced: 2025-07-29T23:13:13.309Z (2 months ago)
- Language: Java
- Homepage:
- Size: 117 KB
- Stars: 2
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
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
*/```
### LicenseThis 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)