diff --git a/OsmAnd-java/src/main/java/net/osmand/data/City.java b/OsmAnd-java/src/main/java/net/osmand/data/City.java index 933218343a..f8faef5f67 100644 --- a/OsmAnd-java/src/main/java/net/osmand/data/City.java +++ b/OsmAnd-java/src/main/java/net/osmand/data/City.java @@ -161,8 +161,12 @@ public class City extends MapObject { public JSONObject toJSON(boolean includingBuildings) { JSONObject json = super.toJSON(); - json.put("type", type.name()); - json.put("postcode", postcode); + if (type != null) { + json.put("type", type.name()); + } + if (postcode != null) { + json.put("postcode", postcode); + } JSONArray listOfStreetsArr = new JSONArray(); for (Street s : listOfStreets) { listOfStreetsArr.put(s.toJSON(includingBuildings)); diff --git a/OsmAnd-java/src/main/java/net/osmand/search/SearchUICore.java b/OsmAnd-java/src/main/java/net/osmand/search/SearchUICore.java index b49ec81d94..058abc58fa 100644 --- a/OsmAnd-java/src/main/java/net/osmand/search/SearchUICore.java +++ b/OsmAnd-java/src/main/java/net/osmand/search/SearchUICore.java @@ -786,22 +786,23 @@ public class SearchUICore { cities = new HashSet<>(); } Set streets = new HashSet<>(); - - for (MapObject obj : exportedObjects) { - if (obj instanceof Amenity) { - amenities.add((Amenity) obj); - } else if (obj instanceof Street) { - Street street = (Street) obj; - streets.add(street); - if (street.getCity() != null) { - final City city = street.getCity(); + if (exportedObjects != null) { + for (MapObject obj : exportedObjects) { + if (obj instanceof Amenity) { + amenities.add((Amenity) obj); + } else if (obj instanceof Street) { + Street street = (Street) obj; + streets.add(street); + if (street.getCity() != null) { + final City city = street.getCity(); + cities.add(city); + streetCities.add(city); + } + } else if (obj instanceof City) { + City city = (City) obj; cities.add(city); - streetCities.add(city); + matchedCities.add(city); } - } else if (obj instanceof City) { - City city = (City) obj; - cities.add(city); - matchedCities.add(city); } } for (City city : cities) { @@ -834,7 +835,7 @@ public class SearchUICore { JSONArray citiesArr = new JSONArray(); for (City city : cities) { final JSONObject cityObj = city.toJSON(exportSettings.isExportBuildings()); - if (exportedCities.contains(city)) { + if (exportedCities != null && exportedCities.contains(city)) { if (!exportSettings.isExportEmptyCities()) { continue; }