kopia lustrzana https://github.com/JOSM/MapWithAI
Add code to not conflate certain sources, when necessary
Signed-off-by: Taylor Smock <taylor.smock@kaart.com>pull/1/head
rodzic
43510ce15e
commit
c5cb23a17b
|
@ -39,6 +39,8 @@ public class MapWithAIInfo extends
|
|||
private String conflationUrl;
|
||||
private JsonArray conflationParameters;
|
||||
private String alreadyConflatedKey;
|
||||
/** This is for categories that cannot be conflated */
|
||||
private ArrayList<MapWithAICategory> conflationIgnoreCategory;
|
||||
|
||||
/**
|
||||
* when adding a field, also adapt the: {@link #MapWithAIPreferenceEntry
|
||||
|
@ -451,4 +453,29 @@ public class MapWithAIInfo extends
|
|||
public String getAlreadyConflatedKey() {
|
||||
return alreadyConflatedKey;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add categories that should not be sent to this MapWithAIInfo's conflation
|
||||
* service
|
||||
*
|
||||
* @param cat The category that cannot be conflated
|
||||
*/
|
||||
public void addConflationIgnoreCategory(MapWithAICategory cat) {
|
||||
if (this.conflationIgnoreCategory == null) {
|
||||
this.conflationIgnoreCategory = new ArrayList<>();
|
||||
}
|
||||
this.conflationIgnoreCategory.add(cat);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get categories that should not be sent to the conflation service
|
||||
*
|
||||
* @return An unmodifiable list of non-conflation categories
|
||||
*/
|
||||
public List<MapWithAICategory> getConflationIgnoreCategory() {
|
||||
if (this.conflationIgnoreCategory == null) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
return Collections.unmodifiableList(this.conflationIgnoreCategory);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -39,6 +39,7 @@ public class ESRISourceReader implements Closeable {
|
|||
private final MapWithAIInfo source;
|
||||
private CachedFile cachedFile;
|
||||
private boolean fastFail;
|
||||
private List<MapWithAICategory> ignoreConflationCategories;
|
||||
private static final String JSON_QUERY_PARAM = "?f=json";
|
||||
|
||||
/**
|
||||
|
@ -60,6 +61,7 @@ public class ESRISourceReader implements Closeable {
|
|||
*/
|
||||
public ESRISourceReader(MapWithAIInfo source) {
|
||||
this.source = source;
|
||||
this.ignoreConflationCategories = source.getConflationIgnoreCategory();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -143,6 +145,9 @@ public class ESRISourceReader implements Closeable {
|
|||
newInfo.setAdditionalCategories(categories);
|
||||
}
|
||||
|
||||
if (this.ignoreConflationCategories.contains(newInfo.getCategory())) {
|
||||
newInfo.setConflation(false);
|
||||
}
|
||||
if (feature.containsKey("accessInformation")) {
|
||||
newInfo.setAttributionText(feature.getString("accessInformation"));
|
||||
}
|
||||
|
|
|
@ -13,12 +13,15 @@ import java.util.Collection;
|
|||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import javax.json.Json;
|
||||
import javax.json.JsonArray;
|
||||
import javax.json.JsonObject;
|
||||
import javax.json.JsonReader;
|
||||
import javax.json.JsonString;
|
||||
import javax.json.JsonStructure;
|
||||
import javax.json.JsonValue;
|
||||
|
||||
|
@ -130,6 +133,13 @@ public class MapWithAISourceReader implements Closeable {
|
|||
info.setConflationUrl(conflationUrl);
|
||||
info.setAlreadyConflatedKey(alreadyConflatedKey);
|
||||
info.setCategory(MapWithAICategory.fromString(category));
|
||||
if (values.containsKey("conflation_ignore_categories")) {
|
||||
JsonArray ignore = values.getJsonArray("conflation_ignore_categories");
|
||||
for (MapWithAICategory cat : ignore.getValuesAs(JsonString.class).stream().map(JsonString::getString)
|
||||
.map(MapWithAICategory::fromString).filter(Objects::nonNull).collect(Collectors.toList())) {
|
||||
info.addConflationIgnoreCategory(cat);
|
||||
}
|
||||
}
|
||||
if (values.containsKey("terms_of_use_url")) {
|
||||
info.setTermsOfUseURL(values.getString("terms_of_use_url"));
|
||||
}
|
||||
|
|
Ładowanie…
Reference in New Issue