Skip to content

Commit

Permalink
Merge pull request #483 from lonvia/fix-county-ranks
Browse files Browse the repository at this point in the history
fix address ranks for counties
  • Loading branch information
lonvia authored Jul 29, 2020
2 parents d0a940f + dec4454 commit feffe0a
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 16 deletions.
1 change: 1 addition & 0 deletions src/main/java/de/komoot/photon/PhotonDoc.java
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@ public void completeFromAddress() {
district = extractAddress(district, "suburb");
locality = extractAddress(locality, "neighbourhood");
county = extractAddress(county, "county");
state = extractAddress(state, "state");

String addressPostCode = address.get("postcode");
if (addressPostCode != null && !addressPostCode.equals(postcode)) {
Expand Down
34 changes: 18 additions & 16 deletions src/main/java/de/komoot/photon/nominatim/model/AddressRow.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ public class AddressRow {

static private final String[] USEFUL_CONTEXT_KEYS = new String[]{"boundary", "landuse", "place"}; // must be in alphabetic order to speed up lookup

/**
* @return whether nominatim thinks this place is a street
*/
public boolean isStreet() {
return 26 <= rankAddress && rankAddress < 28;
}
Expand All @@ -38,17 +41,29 @@ public boolean isLocality() {
public boolean isDistrict() {
return 17 <= rankAddress && rankAddress < 22;
}

/**
* @return whether nominatim thinks this place is a town or city
*/
public boolean isCity() {
return 13 <= rankAddress && rankAddress <= 16;
return 13 <= rankAddress && rankAddress < 17;
}

/**
* @return whether nominatim thinks this place is a county
*/
public boolean isCounty() {
return 5 <= rankAddress && rankAddress <= 9;
public boolean isCounty() { return 10 <= rankAddress && rankAddress < 13; }

/**
* @return whether nominatim thinks this place is a state
*/
public boolean isState() { return 5 <= rankAddress && rankAddress < 10; }

public boolean isCountry() {
return (rankAddress == 4 && "boundary".equals(osmKey) && "administrative".equals(osmValue));
}


public boolean isPostcode() {
if ("place".equals(osmKey) && "postcode".equals(osmValue)) {
return true;
Expand Down Expand Up @@ -82,19 +97,6 @@ public boolean isUsefulForContext() {
return false;
}

public boolean isCountry() {
if (rankAddress == 4 && "boundary".equals(osmKey) && "administrative".equals(osmValue)) {
return true;
}


return false;
}

public boolean isState() {
return (5 <= rankAddress && rankAddress <= 9);
}

@Override
public String toString() {
return MoreObjects.toStringHelper(this)
Expand Down

0 comments on commit feffe0a

Please sign in to comment.