Changeset 11572 in josm for trunk


Ignore:
Timestamp:
2017-02-17T23:34:47+01:00 (7 years ago)
Author:
stoecker
Message:

fix imagery compare, add date check

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/scripts/SyncEditorImageryIndex.groovy

    r11423 r11572  
    211211            for (def m : e.getMirrors()) {
    212212                url = getUrl(m)
     213                m.setName(m.getName().replaceAll(" mirror server( \\d+)?",""))
    213214                if (josmUrls.containsKey(url)) {
    214215                    myprintln "+++ JOSM-Mirror-URL is not unique: "+url
     
    421422                josmIds.put(id, j);
    422423            }
     424            def d = getDate(j)
     425            if(d != null) {
     426                def reg = (d =~ /^(\d\d\d\d)(-(\d\d)(-(\d\d))?)?(;(\d\d\d\d)(-(\d\d)(-(\d\d))?)?)?/)
     427                if(reg == null || reg.count != 1) {
     428                    myprintln "* JOSM-Date '${d}' is strange: ${getDescription(j)}"
     429                } else {
     430                    try {
     431                        def first = verifyDate(reg[0][1],reg[0][3],reg[0][5]);
     432                        def second = verifyDate(reg[0][7],reg[0][9],reg[0][11]);
     433                        if(second.compareTo(first) < 0) {
     434                            myprintln "* JOSM-Date '${d}' is strange (second earlier than first): ${getDescription(j)}"
     435                        }
     436                    }
     437                    catch (Exception e) {
     438                        myprintln "* JOSM-Date '${d}' is strange (${e.getMessage()}): ${getDescription(j)}"
     439                    }
     440                }
     441            }           
    423442            def js = getShapes(j)
    424443            if(js.size()) {
     
    452471        return e.get("properties").getString("url")
    453472    }
     473    static String getDate(Object e) {
     474        if (e instanceof ImageryInfo) return e.date
     475        def start = e.get("properties").getString("start_date")
     476        def end = e.get("properties").getString("end_date")
     477        if(start != null && end != null)
     478            return start+";"+end
     479        else if(start != null)
     480            return start
     481        else
     482            return end
     483    }
     484    static Date verifyDate(String year, String month, String day) {
     485        def date
     486        if(year == null)
     487            date = "3000-01-01"
     488        else
     489            date = year + "-" + (month == null ? "01" : month) + "-" + (day == null ? "01" : day)
     490        def df = new java.text.SimpleDateFormat("yyyy-MM-dd")
     491        df.setLenient(false)
     492        return df.parse(date)
     493    }
    454494    static String getId(Object e) {
    455495        if (e instanceof ImageryInfo) return e.getId()
  • trunk/src/org/openstreetmap/josm/data/imagery/ImageryInfo.java

    r11571 r11572  
    442442    public ImageryInfo(ImageryInfo i) {
    443443        super(i.name, i.url, i.id);
     444        this.origName = i.origName;
     445        this.langName = i.langName;
    444446        this.defaultEntry = i.defaultEntry;
    445447        this.cookies = i.cookies;
     
    11971199               if (num > 1) {
    11981200                   n.name = tr("{0} mirror server {1}", n.name, num);
    1199                    n.origName += " mirror server " + num;
     1201                   if(n.origName != null) {
     1202                       n.origName += " mirror server " + num;
     1203                   }
    12001204               } else {
    12011205                   n.name = tr("{0} mirror server", n.name);
    1202                    n.origName += " mirror server";
     1206                   if(n.origName != null) {
     1207                       n.origName += " mirror server";
     1208                   }
    12031209               }
    12041210               l.add(n);
Note: See TracChangeset for help on using the changeset viewer.