Changeset 11420 in josm


Ignore:
Timestamp:
2016-12-29T22:33:24+01:00 (8 years ago)
Author:
stoecker
Message:

see #12706 - add some more checks

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/scripts/SyncEditorImageryIndex.groovy

    r11415 r11420  
    3434    def eiiUrls = new HashMap<String, JsonObject>()
    3535    def josmUrls = new HashMap<String, ImageryInfo>()
     36    def josmMirrors = new HashMap<String, ImageryInfo>()
    3637
    3738    static String eiiInputFile = 'imagery.geojson'
     
    206207                myprintln "+++ JOSM-URL is not unique: "+url
    207208            } else {
    208               josmUrls.put(url, e)
     209                josmUrls.put(url, e)
    209210            }
    210211            for (def m : e.getMirrors()) {
     
    213214                    myprintln "+++ JOSM-Mirror-URL is not unique: "+url
    214215                } else {
    215                   josmUrls.put(url, m)
     216                    josmUrls.put(url, m)
     217                    josmMirrors.put(url, m)
    216218                }
    217219            }
     
    385387            }
    386388        }
     389        myprintln "*** Mismatching icons: ***"
     390        for (def url : eiiUrls.keySet()) {
     391            def e = eiiUrls.get(url)
     392            if (!josmUrls.containsKey(url)) {
     393                continue
     394            }
     395            def j = josmUrls.get(url)
     396            def ij = getIcon(j)
     397            def ie = getIcon(e)
     398            if(ij != null && ie == null) {
     399                if(!options.nomissingeii) {
     400                    myprintln "+ No EII icon: ${getDescription(j)}"
     401                }
     402            } else if(ij == null && ie != null) {
     403                myprintln "- No JOSM icon: ${getDescription(j)}"
     404            } else if(!ij.equals(ie)) {
     405                myprintln "* Different icons: ${getDescription(j)}"
     406            }
     407        }
     408        myprintln "*** Miscellaneous checks: ***"
     409        def josmIds = new HashMap<String, ImageryInfo>()
     410        for (def url : josmUrls.keySet()) {
     411            def j = josmUrls.get(url)
     412            def id = getId(j)
     413            if(josmMirrors.containsKey(url)) {
     414                continue;
     415            }
     416            if(id == null) {
     417                myprintln "* No JOSM-ID: ${getDescription(j)}"
     418            } else if(josmIds.containsKey(id)) {
     419                myprintln "* JOSM-ID ${id} not unique: ${getDescription(j)}"
     420            } else {
     421                josmIds.put(id, j);
     422            }
     423        }
    387424    }
    388425
     
    393430        if (e instanceof ImageryInfo) return e.url
    394431        return e.get("properties").getString("url")
     432    }
     433    static String getId(Object e) {
     434        if (e instanceof ImageryInfo) return e.getId()
     435        return e.get("properties").getString("id")
    395436    }
    396437    static String getName(Object e) {
     
    458499        return e.get("properties").get("best") ? "best" : null
    459500    }
     501    static String getIcon(Object e) {
     502        if (e instanceof ImageryInfo) return e.getIcon()
     503        return e.get("properties").getString("icon", null)
     504    }
    460505    String getDescription(Object o) {
    461506        def url = getUrl(o)
Note: See TracChangeset for help on using the changeset viewer.