Changeset 13831 in josm for trunk/scripts


Ignore:
Timestamp:
2018-05-25T19:50:34+02:00 (6 years ago)
Author:
Don-vip
Message:

fix #16313 - NPE

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/scripts/SyncEditorLayerIndex.groovy

    r13827 r13831  
    2222import javax.json.JsonObject
    2323import javax.json.JsonReader
     24import javax.json.JsonValue
    2425
    2526import org.openstreetmap.josm.Main
     
    989990            return []
    990991        }
    991         if(!e.isNull("geometry")) {
    992             def ex = e.get("geometry")
    993             if(ex != null && !ex.isNull("coordinates")) {
    994                 def poly = ex.get("coordinates")
    995                 List<Shape> l = []
    996                 for(def shapes: poly) {
    997                     def s = new Shape()
    998                     for(def point: shapes) {
    999                         def lon = point[0].toString()
    1000                         def lat = point[1].toString()
    1001                         s.addPoint(lat, lon)
    1002                     }
    1003                     l.add(s)
    1004                 }
    1005                 return l
    1006             }
     992        def ex = e.get("geometry")
     993        if (ex != null && !JsonValue.NULL.equals(ex) && !ex.isNull("coordinates")) {
     994            def poly = ex.get("coordinates")
     995            List<Shape> l = []
     996            for(def shapes: poly) {
     997                def s = new Shape()
     998                for(def point: shapes) {
     999                    def lon = point[0].toString()
     1000                    def lat = point[1].toString()
     1001                    s.addPoint(lat, lon)
     1002                }
     1003                l.add(s)
     1004            }
     1005            return l
    10071006        }
    10081007        return []
Note: See TracChangeset for help on using the changeset viewer.