Fix creating search tests

This commit is contained in:
max-klaus 2020-05-31 18:53:08 +03:00
parent a3fc582b45
commit 624a501326
2 changed files with 22 additions and 17 deletions

View file

@ -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));

View file

@ -786,22 +786,23 @@ public class SearchUICore {
cities = new HashSet<>();
}
Set<Street> 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;
}