Skip to content

Commit 3e5e285

Browse files
authored
Merge pull request #491 from lonvia/fix-missing-country-code
fix incompatible function call in country code lib
2 parents 4f90293 + e041602 commit 3e5e285

File tree

3 files changed

+13
-5
lines changed

3 files changed

+13
-5
lines changed

src/main/java/de/komoot/photon/PhotonDoc.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ public class PhotonDoc {
4646
private String houseNumber;
4747
private Point centroid;
4848

49-
public PhotonDoc(long placeId, String osmType, long osmId, String tagKey, String tagValue, Map<String, String> name, String houseNumber, Map<String, String> address, Map<String, String> extratags, Envelope bbox, long parentPlaceId, double importance, CountryCode countryCode, Point centroid, long linkedPlaceId, int rankAddress) {
49+
public PhotonDoc(long placeId, String osmType, long osmId, String tagKey, String tagValue, Map<String, String> name, String houseNumber, Map<String, String> address, Map<String, String> extratags, Envelope bbox, long parentPlaceId, double importance, String countryCode, Point centroid, long linkedPlaceId, int rankAddress) {
5050
if (extratags != null) {
5151
String place = extratags.get("place");
5252
if (place == null) {
@@ -71,7 +71,7 @@ public PhotonDoc(long placeId, String osmType, long osmId, String tagKey, String
7171
this.bbox = bbox;
7272
this.parentPlaceId = parentPlaceId;
7373
this.importance = importance;
74-
this.countryCode = countryCode;
74+
this.countryCode = CountryCode.getByCode(countryCode, false);
7575
this.centroid = centroid;
7676
this.linkedPlaceId = linkedPlaceId;
7777
this.rankAddress = rankAddress;

src/main/java/de/komoot/photon/nominatim/NominatimConnector.java

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package de.komoot.photon.nominatim;
22

33
import com.google.common.collect.ImmutableList;
4-
import com.neovisionaries.i18n.CountryCode;
54
import com.vividsolutions.jts.geom.Envelope;
65
import com.vividsolutions.jts.geom.Geometry;
76
import com.vividsolutions.jts.geom.GeometryFactory;
@@ -148,7 +147,7 @@ public NominatimResult mapRow(ResultSet rs, int rownum) throws SQLException {
148147
(Envelope) null,
149148
rs.getLong("parent_place_id"),
150149
0d, // importance
151-
CountryCode.getByCode(rs.getString("country_code")),
150+
rs.getString("country_code"),
152151
(Point) null, // centroid
153152
0,
154153
30
@@ -192,7 +191,7 @@ public NominatimResult mapRow(ResultSet rs, int rowNum) throws SQLException {
192191
envelope,
193192
rs.getLong("parent_place_id"),
194193
importance,
195-
CountryCode.getByCode(rs.getString("country_code")),
194+
rs.getString("country_code"),
196195
(Point) DBUtils.extractGeometry(rs, "centroid"),
197196
rs.getLong("linked_place_id"),
198197
rs.getInt("rank_address")

src/test/java/de/komoot/photon/PhotonDocTest.java

+9
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import java.util.HashMap;
44

5+
import com.neovisionaries.i18n.CountryCode;
56
import org.hamcrest.core.IsEqual;
67
import org.junit.Assert;
78
import org.junit.Test;
@@ -32,6 +33,14 @@ public void testCompleteAddressCreatesStreetIfNonExistantBefore() {
3233
Assert.assertThat(doc.getStreet().get("name"), IsEqual.equalTo("test street"));
3334
}
3435

36+
@Test
37+
public void testAddCountryCode() {
38+
PhotonDoc doc = new PhotonDoc(1, "W", 2, "highway", "residential", null, "4", null, null, null, 0, 30, "de", null, 0, 30);
39+
40+
Assert.assertNotNull(doc.getCountryCode());
41+
Assert.assertEquals("DE", doc.getCountryCode().getAlpha2());
42+
}
43+
3544
private PhotonDoc createPhotonDocWithAddress(HashMap<String, String> address) {
3645
return new PhotonDoc(1, "W", 2, "highway", "residential", null, "4", address, null, null, 0, 30, null, null, 0, 30);
3746
}

0 commit comments

Comments
 (0)