kopia lustrzana https://github.com/JOSM/MapWithAI
Better replacement tag handling
Signed-off-by: Taylor Smock <taylor.smock@kaart.com>pull/1/head
rodzic
978c175d26
commit
0b10f3f927
|
@ -153,6 +153,7 @@ public class ESRISourceReader implements Closeable {
|
||||||
JsonObject info = reader.readObject();
|
JsonObject info = reader.readObject();
|
||||||
JsonArray layers = info.getJsonArray("layers");
|
JsonArray layers = info.getJsonArray("layers");
|
||||||
// TODO use all the layers?
|
// TODO use all the layers?
|
||||||
|
|
||||||
JsonObject layer = layers.get(0).asJsonObject();
|
JsonObject layer = layers.get(0).asJsonObject();
|
||||||
String partialUrl = (url.endsWith("/") ? url : url + "/") + layer.getInt("id");
|
String partialUrl = (url.endsWith("/") ? url : url + "/") + layer.getInt("id");
|
||||||
mapwithaiInfo.setReplacementTags(getReplacementTags(partialUrl));
|
mapwithaiInfo.setReplacementTags(getReplacementTags(partialUrl));
|
||||||
|
@ -169,15 +170,21 @@ public class ESRISourceReader implements Closeable {
|
||||||
try (CachedFile featureServer = new CachedFile(toGet);
|
try (CachedFile featureServer = new CachedFile(toGet);
|
||||||
BufferedReader br = featureServer.getContentReader();
|
BufferedReader br = featureServer.getContentReader();
|
||||||
JsonReader reader = Json.createReader(br)) {
|
JsonReader reader = Json.createReader(br)) {
|
||||||
|
|
||||||
return reader.readObject().getJsonArray("fields").getValuesAs(JsonObject.class).stream()
|
return reader.readObject().getJsonArray("fields").getValuesAs(JsonObject.class).stream()
|
||||||
.collect(Collectors.toMap(o -> o.getString("name"), o -> o.getString("alias", null)));
|
.collect(Collectors.toMap(o -> o.getString("name"), ESRISourceReader::getReplacementTag));
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
Logging.error(e);
|
Logging.error(e);
|
||||||
}
|
}
|
||||||
return Collections.emptyMap();
|
return Collections.emptyMap();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static String getReplacementTag(JsonObject tag) {
|
||||||
|
if (tag.getBoolean("editable", true) && !"esriFieldTypeOID".equals(tag.getString("type", null))) {
|
||||||
|
return tag.getString("alias", "");
|
||||||
|
}
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets whether opening HTTP connections should fail fast, i.e., whether a
|
* Sets whether opening HTTP connections should fail fast, i.e., whether a
|
||||||
* {@link HttpClient#setConnectTimeout(int) low connect timeout} should be used.
|
* {@link HttpClient#setConnectTimeout(int) low connect timeout} should be used.
|
||||||
|
|
Ładowanie…
Reference in New Issue