Changeset 18011 in josm for trunk/src/org


Ignore:
Timestamp:
2021-07-13T22:49:09+02:00 (3 years ago)
Author:
Don-vip
Message:

see #17177 - add debug log on saving, wait for saving in testMapillaryStyle, code style

Location:
trunk/src/org/openstreetmap/josm
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/data/imagery/vectortile/mapbox/style/MapboxVectorStyle.java

    r17990 r18011  
    1717import java.util.List;
    1818import java.util.Map;
     19import java.util.Map.Entry;
    1920import java.util.Objects;
    2021import java.util.Optional;
     
    2425import javax.imageio.ImageIO;
    2526import javax.json.Json;
    26 import javax.json.JsonArray;
    2727import javax.json.JsonObject;
    2828import javax.json.JsonReader;
    29 import javax.json.JsonStructure;
    3029import javax.json.JsonValue;
    3130
     
    6059                    BufferedReader reader = style.getContentReader();
    6160                    JsonReader jsonReader = Json.createReader(reader)) {
    62                 JsonStructure structure = jsonReader.read();
    63                 return new MapboxVectorStyle(structure.asJsonObject());
     61                return new MapboxVectorStyle(jsonReader.read().asJsonObject());
    6462            } catch (IOException e) {
    6563                Logging.error(e);
     
    10098            final List<Source> sourceList;
    10199            if (jsonObject.containsKey("sources") && jsonObject.get("sources").getValueType() == JsonValue.ValueType.OBJECT) {
    102                 final JsonObject sourceObj = jsonObject.getJsonObject("sources");
    103                 sourceList = sourceObj.entrySet().stream().filter(entry -> entry.getValue().getValueType() == JsonValue.ValueType.OBJECT)
     100                sourceList = jsonObject.getJsonObject("sources").entrySet().stream()
     101                  .filter(entry -> entry.getValue().getValueType() == JsonValue.ValueType.OBJECT)
    104102                  .map(entry -> {
    105103                      try {
     
    119117            final List<Layers> layers;
    120118            if (jsonObject.containsKey("layers") && jsonObject.get("layers").getValueType() == JsonValue.ValueType.ARRAY) {
    121                 JsonArray lArray = jsonObject.getJsonArray("layers");
    122                 layers = lArray.stream().filter(JsonObject.class::isInstance).map(JsonObject.class::cast).map(obj -> new Layers(id, obj))
     119                layers = jsonObject.getJsonArray("layers").stream()
     120                  .filter(JsonObject.class::isInstance).map(JsonObject.class::cast).map(obj -> new Layers(id, obj))
    123121                  .collect(Collectors.toList());
    124122            } else {
     
    130128            // Abuse HashMap null (null == default)
    131129            this.sources = new LinkedHashMap<>();
    132             for (Map.Entry<Optional<Source>, List<Layers>> entry : sourceLayer.entrySet()) {
     130            for (Entry<Optional<Source>, List<Layers>> entry : sourceLayer.entrySet()) {
    133131                final Source source = entry.getKey().orElse(null);
    134132                final String data = entry.getValue().stream().map(Layers::toString).collect(Collectors.joining());
     
    159157        // HiDPI images first -- if this succeeds, don't bother with the lower resolution (JOSM has no method to switch)
    160158        try (CachedFile spriteJson = new CachedFile(this.spriteUrl + "@2x.json");
    161           CachedFile spritePng = new CachedFile(this.spriteUrl + "@2x.png")) {
     159             CachedFile spritePng = new CachedFile(this.spriteUrl + "@2x.png")) {
    162160            if (parseSprites(spriteJson, spritePng)) {
    163161                return;
     
    165163        }
    166164        try (CachedFile spriteJson = new CachedFile(this.spriteUrl + ".json");
    167         CachedFile spritePng = new CachedFile(this.spriteUrl + ".png")) {
     165             CachedFile spritePng = new CachedFile(this.spriteUrl + ".png")) {
    168166            parseSprites(spriteJson, spritePng);
    169167        }
     
    193191            return false;
    194192        }
    195         for (Map.Entry<String, JsonValue> entry : spriteObject.entrySet()) {
     193        for (Entry<String, JsonValue> entry : spriteObject.entrySet()) {
    196194            final JsonObject info = entry.getValue().asJsonObject();
    197195            int width = info.getInt("width");
     
    218216        }
    219217        final File toSave = new File(location, name);
     218        Logging.debug("Saving {0} to {1}...", object.getClass().getSimpleName(), toSave);
    220219        try {
    221220            if (object instanceof BufferedImage) {
  • trunk/src/org/openstreetmap/josm/gui/mappaint/mapcss/MapCSSStyleSource.java

    r17994 r18011  
    9595    static final Set<String> SUPPORTED_KEYS = new HashSet<>();
    9696    static {
    97         Field[] declaredFields = StyleKeys.class.getDeclaredFields();
    98         for (Field f : declaredFields) {
     97        for (Field f : StyleKeys.class.getDeclaredFields()) {
    9998            try {
    10099                SUPPORTED_KEYS.add((String) f.get(null));
Note: See TracChangeset for help on using the changeset viewer.