mirror of
https://gitlab.com/oeffi/oeffi.git
synced 2025-07-07 21:28:49 +00:00
GeocoderThread: Prefer parsing address from individual fields.
This commit is contained in:
parent
46e70d02a7
commit
ee99146c97
1 changed files with 8 additions and 6 deletions
|
@ -114,16 +114,18 @@ public class GeocoderThread extends Thread {
|
||||||
else
|
else
|
||||||
coord = null;
|
coord = null;
|
||||||
|
|
||||||
final Location location;
|
|
||||||
final int maxAddressLineIndex = address.getMaxAddressLineIndex();
|
final int maxAddressLineIndex = address.getMaxAddressLineIndex();
|
||||||
if (maxAddressLineIndex >= 2 && Strings.emptyToNull(address.getAddressLine(2)) != null) {
|
final Location location;
|
||||||
location = new Location(LocationType.ADDRESS, null, coord, address.getAddressLine(1),
|
if (Strings.emptyToNull(address.getFeatureName()) != null && Strings.emptyToNull(address.getLocality()) != null
|
||||||
address.getAddressLine(0));
|
&& Strings.emptyToNull(address.getPostalCode()) != null) {
|
||||||
} else if (address.getThoroughfare() != null) {
|
|
||||||
final Joiner joiner = Joiner.on(' ').skipNulls();
|
final Joiner joiner = Joiner.on(' ').skipNulls();
|
||||||
|
final String thoroughfare = Strings.emptyToNull(address.getThoroughfare());
|
||||||
location = new Location(LocationType.ADDRESS, null, coord,
|
location = new Location(LocationType.ADDRESS, null, coord,
|
||||||
joiner.join(address.getPostalCode(), address.getLocality()),
|
joiner.join(address.getPostalCode(), address.getLocality()),
|
||||||
joiner.join(address.getThoroughfare(), address.getFeatureName()));
|
joiner.join(thoroughfare, address.getFeatureName()));
|
||||||
|
} else if (maxAddressLineIndex >= 2 && Strings.emptyToNull(address.getAddressLine(2)) != null) {
|
||||||
|
location = new Location(LocationType.ADDRESS, null, coord, address.getAddressLine(1),
|
||||||
|
address.getAddressLine(0));
|
||||||
} else {
|
} else {
|
||||||
location = new Location(LocationType.ADDRESS, null, coord);
|
location = new Location(LocationType.ADDRESS, null, coord);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue