Added precedence for name field
@@ -20,6 +20,7 @@ import java.util.Map;
public class ConvertToJson {
private final static String[] KEYS_LANG_UNSPEC = {Constants.OSM_ID, Constants.OSM_VALUE, Constants.OSM_KEY, Constants.POSTCODE, Constants.HOUSENUMBER, Constants.COUNTRYCODE, Constants.OSM_TYPE};
private final static String[] KEYS_LANG_SPEC = {Constants.NAME, Constants.COUNTRY, Constants.CITY, Constants.STREET, Constants.STATE};
+ private final static String[] NAME_PRECEDENCE = {"housename", "int", "loc", "reg", "alt", "old"};
private final String lang;
public ConvertToJson(String lang) {
@@ -76,9 +77,13 @@ public class ConvertToJson {
return map.get(lang);
}
- if (!map.containsKey("default")) {
- return map.get(map.keySet().toArray()[0]); // Returning first value in the map
+ if (fieldName.equals("name")) {
+ for (String key : NAME_PRECEDENCE) {
+ if (map.containsKey(key))
+ return map.get(key);
}
+ }
+
return map.get("default");
}
