Skip to content

Commit

Permalink
Merge pull request #808 from lonvia/address-for-rank-0
Browse files Browse the repository at this point in the history
Introduce 'other' rank for address rank 0 objects
  • Loading branch information
lonvia authored May 31, 2024
2 parents d747059 + ba04e9b commit ce3424b
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 2 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,7 @@ List of available layers:
- county
- state
- country
- other (e.g. natural features)

```
http://localhost:2322/api?q=berlin&layer=city&layer=locality
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ public enum AddressType {
CITY("city", 13, 16),
COUNTY("county", 10, 12),
STATE("state", 5, 9),
COUNTRY("country", 4, 4);
COUNTRY("country", 4, 4),
OTHER("other", 0, 0);

private final String name;
private final int minRank;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,25 @@ void testPlaceAddress() throws ParseException {
AssertUtil.assertAddressName("Le Havre", doc, AddressType.STATE);
}

@Test
void testPlaceAddressAddressRank0() throws ParseException {
PlacexTestRow place = new PlacexTestRow("natural", "water").name("Lake Tee").rankAddress(0).rankSearch(20).add(jdbc);

place.addAddresslines(jdbc,
new PlacexTestRow("place", "county").name("Lost County").rankAddress(12).add(jdbc),
new PlacexTestRow("place", "state").name("Le Havre").rankAddress(8).add(jdbc));

connector.readEntireDatabase();

assertEquals(3, importer.size());
importer.assertContains(place);

PhotonDoc doc = importer.get(place);

AssertUtil.assertAddressName("Lost County", doc, AddressType.COUNTY);
AssertUtil.assertAddressName("Le Havre", doc, AddressType.STATE);
}

@Test
void testPoiAddress() throws ParseException {
PlacexTestRow parent = PlacexTestRow.make_street("Burg").add(jdbc);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ void testWithBadLayerFilters() {
Request mockRequest = createRequestWithLongitudeLatitude(-87d, 41d);
requestWithLayers(mockRequest, "city", "bad");

assertBadRequest(mockRequest, "Invalid layer 'bad'. Allowed layers are: house,street,locality,district,city,county,state,country");
assertBadRequest(mockRequest, "Invalid layer 'bad'. Allowed layers are: house,street,locality,district,city,county,state,country,other");
}

@Test
Expand Down

0 comments on commit ce3424b

Please sign in to comment.