Changeset 11412 in josm


Ignore:
Timestamp:
2016-12-22T18:03:12+01:00 (8 years ago)
Author:
stoecker
Message:

see #12706 - switch to geojson

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/build.xml

    r11324 r11412  
    689689        <echo message="Checking editor imagery difference"/>
    690690        <groovy src="scripts/SyncEditorImageryIndex.groovy" classpath="${dist.dir}/josm-custom.jar">
    691             <arg value="-nomissingeii"/>
     691                <!--<arg value="-nomissingeii"/>-->
    692692        </groovy>
    693693    </target>
     
    707707        </exec>
    708708        <exec append="false" executable="wget" failifexecutionfails="true">
    709             <arg value="https://raw.githubusercontent.com/osmlab/editor-imagery-index/gh-pages/imagery.json"/>
     709            <arg value="https://raw.githubusercontent.com/osmlab/editor-imagery-index/gh-pages/imagery.geojson"/>
    710710            <arg value="-O"/>
    711             <arg value="imagery.json"/>
     711            <arg value="imagery.geojson"/>
    712712            <arg value="--unlink"/>
    713713        </exec>
  • trunk/scripts/SyncEditorImageryIndex.groovy

    r11411 r11412  
    2121import javax.json.JsonObject
    2222import javax.json.JsonReader
     23import javax.json.JsonValue
    2324
    2425import org.openstreetmap.josm.data.imagery.ImageryInfo
     
    3435    def josmUrls = new HashMap<String, ImageryInfo>()
    3536
    36     static String eiiInputFile = 'imagery.json'
     37    static String eiiInputFile = 'imagery.geojson'
    3738    static String josmInputFile = 'maps.xml'
    3839    static String ignoreInputFile = 'maps_ignores.txt'
     
    174175        FileReader fr = new FileReader(eiiInputFile)
    175176        JsonReader jr = Json.createReader(fr)
    176         eiiEntries = jr.readArray()
     177        eiiEntries = jr.readObject().get("features")
    177178        jr.close()
    178179
     
    234235        myprintln "*** URLs found in EII but not in JOSM (${l1.size()}): ***"
    235236        if (!l1.isEmpty()) {
    236             for (def l : l1)
    237                 myprintln "-"+l
     237            for (def l : l1) {
     238                myprintln "-" + l
     239            }
    238240        }
    239241
     
    243245        myprintln "*** URLs found in JOSM but not in EII (${l2.size()}): ***"
    244246        if (!l2.isEmpty()) {
    245             for (def l : l2)
     247            for (def l : l2) {
    246248                myprintln "+" + l
     249            }
    247250        }
    248251    }
     
    368371    static String getUrl(Object e) {
    369372        if (e instanceof ImageryInfo) return e.url
    370         return e.getString("url")
     373        return e.get("properties").getString("url")
    371374    }
    372375    static String getName(Object e) {
    373376        if (e instanceof ImageryInfo) return e.getOriginalName()
    374         return e.getString("name")
     377        return e.get("properties").getString("name")
    375378    }
    376379    static List<Shape> getShapes(Object e) {
     
    382385            return []
    383386        }
    384         def ex = e.get("extent")
    385         if(ex != null) {
    386             def poly = ex.get("polygon")
    387             if(poly != null) {
     387        if(!e.isNull("geometry")) {
     388            def ex = e.get("geometry")
     389            if(ex != null && !ex.isNull("coordinates")) {
     390                def poly = ex.get("coordinates")
    388391                List<Shape> l = []
    389392                for(def shapes: poly) {
     
    406409    static String getType(Object e) {
    407410        if (e instanceof ImageryInfo) return e.getImageryType().getTypeString()
    408         return e.getString("type")
     411        return e.get("properties").getString("type")
    409412    }
    410413    static Integer getMinZoom(Object e) {
     
    413416            return mz == 0 ? null : mz
    414417        } else {
    415             def ext = e.getJsonObject("extent")
    416             if (ext == null) return null
    417             def num = ext.getJsonNumber("min_zoom")
     418            def num = e.get("properties").getJsonNumber("min_zoom")
    418419            if (num == null) return null
    419420            return num.intValue()
     
    425426            return mz == 0 ? null : mz
    426427        } else {
    427             def ext = e.getJsonObject("extent")
    428             if (ext == null) return null
    429             def num = ext.getJsonNumber("max_zoom")
     428            def num = e.get("properties").getJsonNumber("max_zoom")
    430429            if (num == null) return null
    431430            return num.intValue()
     
    434433    static String getCountryCode(Object e) {
    435434        if (e instanceof ImageryInfo) return "".equals(e.getCountryCode()) ? null : e.getCountryCode()
    436         return e.getString("country_code", null)
     435        return e.get("properties").getString("country_code", null)
    437436    }
    438437    static String getQuality(Object e) {
    439438        //if (e instanceof ImageryInfo) return "".equals(e.getQuality()) ? null : e.getQuality()
    440439        if (e instanceof ImageryInfo) return null
    441         return e.get("best") ? "best" : null
     440        return e.get("properties").get("best") ? "best" : null
    442441    }
    443442    String getDescription(Object o) {
Note: See TracChangeset for help on using the changeset viewer.