Changeset 12806 in josm


Ignore:
Timestamp:
2017-09-09T17:48:13+02:00 (7 years ago)
Author:
Don-vip
Message:

see #15229 - see #15182 - remove GUI references from GeoJSONWriter

Location:
trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/gui/io/importexport/GeoJSONExporter.java

    r12671 r12806  
    3636        if (layer instanceof OsmDataLayer) {
    3737            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());
    3939            }
    4040        } else {
  • trunk/src/org/openstreetmap/josm/io/GeoJSONWriter.java

    r12620 r12806  
    4343public class GeoJSONWriter {
    4444
    45     private final OsmDataLayer layer;
     45    private final DataSet data;
    4646    private final Projection projection;
    4747    private static final boolean SKIP_EMPTY_NODES = true;
     
    5151     * @param layer The OSM data layer to save
    5252     * @since 10852
    53      */
     53     * @deprecated To be removed end of 2017. Use {@link #GeoJSONWriter(DataSet)} instead
     54     */
     55    @Deprecated
    5456    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;
    5667        this.projection = ProjectionPreference.wgs84.getProjection();
    5768    }
     
    7990                    .add("type", "FeatureCollection")
    8091                    .add("generator", "JOSM");
    81             appendLayerBounds(layer.data, object);
    82             appendLayerFeatures(layer.data, object);
     92            appendLayerBounds(data, object);
     93            appendLayerFeatures(data, object);
    8394            writer.writeObject(object.build());
    8495            return stringWriter.toString();
  • trunk/test/unit/org/openstreetmap/josm/io/GeoJSONWriterTest.java

    r12439 r12806  
    1616import org.openstreetmap.josm.data.osm.Node;
    1717import org.openstreetmap.josm.data.osm.Way;
    18 import org.openstreetmap.josm.gui.layer.OsmDataLayer;
    1918
    2019/**
     
    4140        final DataSet ds = new DataSet();
    4241        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);
    4543        assertEquals(("" +
    4644                "{\n" +
     
    8078        way.setNodes(Arrays.asList(n1, n2));
    8179        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);
    8481        assertEquals(("" +
    8582                "{\n" +
     
    118115        try (FileInputStream in = new FileInputStream(TestUtils.getTestDataRoot() + "multipolygon.osm")) {
    119116            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);
    122118            assertTrue(writer.write().contains("MultiPolygon"));
    123119        }
     
    132128        try (FileInputStream in = new FileInputStream("data_nodist/multipolygon.osm")) {
    133129            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);
    136131            assertTrue(writer.write().contains("MultiPolygon"));
    137132        }
Note: See TracChangeset for help on using the changeset viewer.