OpenCageData / address-formatting

templates to format geographic addresses
MIT License
394 stars 84 forks source link

Trailing slash in Indian addresses #114

Closed rkoeze closed 1 month ago

rkoeze commented 2 months ago

Hi folks,

First of all, thanks for maintaining this project! It's greatly appreciated.

I maintain the java implementation and was recently made aware of the following case: when Indian address parts contain a city but not a postcode the result will include a trailing slash. So for instance:

country_code: 'IN',
road: 'Baner',
city: 'Pune',
state: 'Maharashtra',
country: 'India',

Will be formatted as this:

Baner
Pune -
Maharashtra
India

I'm not 100% sure what is the correct output here, but I suspect that the trailing slash should be removed in this case. Is that correct? If so, would it make sense to contain a rule in the postformat_replace field for this case or do something like this:

{{#first}} {{{city}}} || {{{town}}} || {{{village}}} || {{{hamlet}}} {{/first}} {{#postcode}} - {{{postcode}}} {{/postcode}} 

I've confirmed that this also occurs in at least one other implementation.

freyfogle commented 1 month ago

Thanks for the bug report. Will create a test case and come back to you in next day or so.

freyfogle commented 1 month ago

this is now solved, thanks again for making us aware.