Changeset 11166 in josm
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/io/GeoJSONWriter.java
r10852 r11166 18 18 import javax.json.stream.JsonGenerator; 19 19 20 import org.openstreetmap.josm.Main; 20 21 import org.openstreetmap.josm.data.Bounds; 21 22 import org.openstreetmap.josm.data.coor.EastNorth; … … 119 120 @Override 120 121 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 { 122 126 final Pair<List<JoinedPolygon>, List<JoinedPolygon>> mp = MultipolygonBuilder.joinWays(r); 123 127 final JsonArrayBuilder polygon = Json.createArrayBuilder(); … … 130 134 final JsonArrayBuilder multiPolygon = Json.createArrayBuilder().add(polygon); 131 135 geomObj.add("coordinates", multiPolygon); 136 } catch (MultipolygonBuilder.JoinedPolygonCreationException ex) { 137 Main.warn("GeoJSON: Failed to export multipolygon " + r.getUniqueId()); 138 Main.warn(ex); 132 139 } 133 140 } -
trunk/test/unit/org/openstreetmap/josm/io/GeoJSONWriterTest.java
r10852 r11166 77 77 } 78 78 } 79 80 /** 81 * Unit test for exporting invalid multipolygons, see #13827 82 * @throws Exception if an error occurs 83 */ 84 @Test 85 public void testMultipolygonRobustness() throws Exception { 86 try (FileInputStream in = new FileInputStream("data_nodist/multipolygon.osm")) { 87 DataSet ds = OsmReader.parseDataSet(in, null); 88 final OsmDataLayer layer = new OsmDataLayer(ds, "foo", null); 89 final GeoJSONWriter writer = new GeoJSONWriter(layer); 90 assertTrue(writer.write().contains("MultiPolygon")); 91 } 92 } 79 93 }
Note:
See TracChangeset
for help on using the changeset viewer.