Changeset 11612 in josm for trunk


Ignore:
Timestamp:
2017-02-25T14:07:17+01:00 (8 years ago)
Author:
stoecker
Message:

add dates with open timespan

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/data/maps.xsd

    r11579 r11612  
    660660                                                        <!-- A base64-encoded image that is displayed as menu/toolbar icon -->
    661661                                                        <xs:element name="icon" minOccurs="0" maxOccurs="1" type="xs:string" />
    662                                                         <!-- Date in form YYYY-MM-DD;YYYY-MM-DD (each element after first year is optional -->
     662                                                        <!-- Date in form YYYY-MM-DD;YYYY-MM-DD (each element after first year is optional, a single - marks an unknown or open timespan like -;2015) -->
    663663                                                        <xs:element name="date" minOccurs="0" maxOccurs="1" type="xs:string" />
    664664                                                        <xs:element name="mirror" minOccurs="0">
  • trunk/scripts/SyncEditorLayerIndex.groovy

    r11603 r11612  
    307307        /*myprintln "*** Same URL, but different dates: ***"
    308308        for (def url : eliUrls.keySet()) {
    309             def e = eliUrls.get(url)
     309            def ed = getDate(eliUrls.get(url))
    310310            if (!josmUrls.containsKey(url)) continue
    311311            def j = josmUrls.get(url)
    312             if (!getDate(e).equals(getDate(j))) {
    313                 myprintln "* Date differs ('${getDate(e)}' != '${getDate(j)}'): ${getDescription(j)}"
     312            def jd = getDate(j)
     313            // The forms 2015;- or -;2015 or 2015;2015 are handled equal to 2015
     314            String ef = ed.replaceAll("\\A-;","").replaceAll(";-\\z","").replaceAll("\\A([0-9-]+);\\1\\z","\$1");
     315            if (!ed.equals(jd) && !ef.equals(jd)) {
     316                String t = "'${ed}'";
     317                if (!ed.equals(ef)) {
     318                    t += "or '${ef}'";
     319                }
     320                myprintln "* Date differs (${t} != '${jd}'): ${getDescription(j)}"
    314321            }
    315322        }*/
     
    409416            def d = getDate(j)
    410417            if(!d.isEmpty()) {
    411                 def reg = (d =~ /^(\d\d\d\d)(-(\d\d)(-(\d\d))?)?(;(\d\d\d\d)(-(\d\d)(-(\d\d))?)?)?/)
     418                def reg = (d =~ /^(-|(\d\d\d\d)(-(\d\d)(-(\d\d))?)?)(;(-|(\d\d\d\d)(-(\d\d)(-(\d\d))?)?))?/)
    412419                if(reg == null || reg.count != 1) {
    413420                    myprintln "* JOSM-Date '${d}' is strange: ${getDescription(j)}"
    414421                } else {
    415422                    try {
    416                         def first = verifyDate(reg[0][1],reg[0][3],reg[0][5]);
    417                         def second = verifyDate(reg[0][7],reg[0][9],reg[0][11]);
     423                        def first = verifyDate(reg[0][2],reg[0][4],reg[0][6]);
     424                        def second = verifyDate(reg[0][9],reg[0][11],reg[0][13]);
    418425                        if(second.compareTo(first) < 0) {
    419426                            myprintln "* JOSM-Date '${d}' is strange (second earlier than first): ${getDescription(j)}"
     
    464471            return start+";"+end
    465472        else if(!start.isEmpty())
    466             return start
    467         else
    468             return end
     473            return start+";-"
     474        else if(!end.isEmpty())
     475            return "-;"+end
     476        return "";
    469477    }
    470478    static Date verifyDate(String year, String month, String day) {
Note: See TracChangeset for help on using the changeset viewer.