Changeset 12806 in josm
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/io/importexport/GeoJSONExporter.java
r12671 r12806 36 36 if (layer instanceof OsmDataLayer) { 37 37 try (Writer out = Files.newBufferedWriter(file.toPath(), StandardCharsets.UTF_8)) { 38 out.write(new GeoJSONWriter(( OsmDataLayer) layer).write());38 out.write(new GeoJSONWriter(((OsmDataLayer) layer).data).write()); 39 39 } 40 40 } else { -
trunk/src/org/openstreetmap/josm/io/GeoJSONWriter.java
r12620 r12806 43 43 public class GeoJSONWriter { 44 44 45 private final OsmDataLayer layer;45 private final DataSet data; 46 46 private final Projection projection; 47 47 private static final boolean SKIP_EMPTY_NODES = true; … … 51 51 * @param layer The OSM data layer to save 52 52 * @since 10852 53 */ 53 * @deprecated To be removed end of 2017. Use {@link #GeoJSONWriter(DataSet)} instead 54 */ 55 @Deprecated 54 56 public GeoJSONWriter(OsmDataLayer layer) { 55 this.layer = layer; 57 this(layer.data); 58 } 59 60 /** 61 * Constructs a new {@code GeoJSONWriter}. 62 * @param ds The OSM data set to save 63 * @since 12806 64 */ 65 public GeoJSONWriter(DataSet ds) { 66 this.data = ds; 56 67 this.projection = ProjectionPreference.wgs84.getProjection(); 57 68 } … … 79 90 .add("type", "FeatureCollection") 80 91 .add("generator", "JOSM"); 81 appendLayerBounds( layer.data, object);82 appendLayerFeatures( layer.data, object);92 appendLayerBounds(data, object); 93 appendLayerFeatures(data, object); 83 94 writer.writeObject(object.build()); 84 95 return stringWriter.toString(); -
trunk/test/unit/org/openstreetmap/josm/io/GeoJSONWriterTest.java
r12439 r12806 16 16 import org.openstreetmap.josm.data.osm.Node; 17 17 import org.openstreetmap.josm.data.osm.Way; 18 import org.openstreetmap.josm.gui.layer.OsmDataLayer;19 18 20 19 /** … … 41 40 final DataSet ds = new DataSet(); 42 41 ds.addPrimitive(node); 43 final OsmDataLayer layer = new OsmDataLayer(ds, "foo", null); 44 final GeoJSONWriter writer = new GeoJSONWriter(layer); 42 final GeoJSONWriter writer = new GeoJSONWriter(ds); 45 43 assertEquals(("" + 46 44 "{\n" + … … 80 78 way.setNodes(Arrays.asList(n1, n2)); 81 79 ds.addPrimitive(way); 82 final OsmDataLayer layer = new OsmDataLayer(ds, "foo", null); 83 final GeoJSONWriter writer = new GeoJSONWriter(layer); 80 final GeoJSONWriter writer = new GeoJSONWriter(ds); 84 81 assertEquals(("" + 85 82 "{\n" + … … 118 115 try (FileInputStream in = new FileInputStream(TestUtils.getTestDataRoot() + "multipolygon.osm")) { 119 116 DataSet ds = OsmReader.parseDataSet(in, null); 120 final OsmDataLayer layer = new OsmDataLayer(ds, "foo", null); 121 final GeoJSONWriter writer = new GeoJSONWriter(layer); 117 final GeoJSONWriter writer = new GeoJSONWriter(ds); 122 118 assertTrue(writer.write().contains("MultiPolygon")); 123 119 } … … 132 128 try (FileInputStream in = new FileInputStream("data_nodist/multipolygon.osm")) { 133 129 DataSet ds = OsmReader.parseDataSet(in, null); 134 final OsmDataLayer layer = new OsmDataLayer(ds, "foo", null); 135 final GeoJSONWriter writer = new GeoJSONWriter(layer); 130 final GeoJSONWriter writer = new GeoJSONWriter(ds); 136 131 assertTrue(writer.write().contains("MultiPolygon")); 137 132 }
Note:
See TracChangeset
for help on using the changeset viewer.