Changeset 11166 in josm for trunk/src


Ignore:
Timestamp:
2016-10-26T13:09:07+02:00 (3 years ago)
Author:
simon04
Message:

fix #13827 - Exporting invalid multipolygon as GeoJSON crashes JOSM

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/io/GeoJSONWriter.java

    r10852 r11166  
    1818import javax.json.stream.JsonGenerator;
    1919
     20import org.openstreetmap.josm.Main;
    2021import org.openstreetmap.josm.data.Bounds;
    2122import org.openstreetmap.josm.data.coor.EastNorth;
     
    119120        @Override
    120121        public void visit(Relation r) {
    121             if (r != null && r.isMultipolygon() && !r.hasIncompleteMembers()) {
     122            if (r == null || !r.isMultipolygon() || r.hasIncompleteMembers()) {
     123                return;
     124            }
     125            try {
    122126                final Pair<List<JoinedPolygon>, List<JoinedPolygon>> mp = MultipolygonBuilder.joinWays(r);
    123127                final JsonArrayBuilder polygon = Json.createArrayBuilder();
     
    130134                final JsonArrayBuilder multiPolygon = Json.createArrayBuilder().add(polygon);
    131135                geomObj.add("coordinates", multiPolygon);
     136            } catch (MultipolygonBuilder.JoinedPolygonCreationException ex) {
     137                Main.warn("GeoJSON: Failed to export multipolygon " + r.getUniqueId());
     138                Main.warn(ex);
    132139            }
    133140        }
Note: See TracChangeset for help on using the changeset viewer.