address-formatter-java

A simple address-formatter-java.

License

License

Categories

Categories

Java Languages Net ORM Data
GroupId

GroupId

net.placemarkt
ArtifactId

ArtifactId

address-formatter-java
Last Version

Last Version

0.0.9
Release Date

Release Date

Type

Type

jar
Description

Description

address-formatter-java
A simple address-formatter-java.
Project URL

Project URL

http://placemarkt.net
Source Code Management

Source Code Management

https://github.com/placemarkt/address-formatter-java

Download address-formatter-java

How to add to project

<!-- https://jarcasting.com/artifacts/net.placemarkt/address-formatter-java/ -->
<dependency>
    <groupId>net.placemarkt</groupId>
    <artifactId>address-formatter-java</artifactId>
    <version>0.0.9</version>
</dependency>
// https://jarcasting.com/artifacts/net.placemarkt/address-formatter-java/
implementation 'net.placemarkt:address-formatter-java:0.0.9'
// https://jarcasting.com/artifacts/net.placemarkt/address-formatter-java/
implementation ("net.placemarkt:address-formatter-java:0.0.9")
'net.placemarkt:address-formatter-java:jar:0.0.9'
<dependency org="net.placemarkt" name="address-formatter-java" rev="0.0.9">
  <artifact name="address-formatter-java" type="jar" />
</dependency>
@Grapes(
@Grab(group='net.placemarkt', module='address-formatter-java', version='0.0.9')
)
libraryDependencies += "net.placemarkt" % "address-formatter-java" % "0.0.9"
[net.placemarkt/address-formatter-java "0.0.9"]

Dependencies

compile (5)

Group / Artifact Type Version
junit : junit jar 4.13
com.fasterxml.jackson.core : jackson-core jar 2.11.3
com.fasterxml.jackson.dataformat : jackson-dataformat-yaml jar 2.11.3
com.google.guava : guava jar 30.0-jre
com.github.spullara.mustache.java : compiler jar 0.9.7

Project Modules

There are no modules declared in this project.

Address Formatter

Overview

A Maven 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.

For Java 8 and above.

Installation

Add the following to your pom.xml to use the latest release with Maven:

<dependency>
  <groupId>net.placemarkt</groupId>
  <artifactId>address-formatter-java</artifactId>
  <version>0.0.9</version>
</dependency> 

API

// Constructor
AddressFormatter(Boolean abbreviate, Boolean appendCountry)

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

Use

AddressFormatter formatter = new AddressFormatter(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
*/

AddressFormatter abbreviateFormatter = new AddressFormatter(true, 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 = abbreviateFormatter.format(json);
/*
301 Hamilton Ave
Palo Alto, CA 94303
United States of America
*/

AddressFormatter appendCountryFormatter = new AddressFormatter(false, true);
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',}"
String formatted = appendCountryFormatter.format(json);
/*
301 Hamilton Ave
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

net.placemarkt

Placemarkt

Location bookmarking for your favorite places

Versions

Version
0.0.9