Changeset 8803 in josm


Ignore:
Timestamp:
2015-09-29T18:56:18+02:00 (4 years ago)
Author:
simon04
Message:

fix #9114 - Store imagery offset in session

Location:
trunk
Files:
1 added
4 edited

Legend:

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

    r8526 r8803  
    8888            data.put("show-errors", Boolean.toString(tsLayer.showErrors));
    8989        }
     90        data.put("dx", String.valueOf(layer.getDx()));
     91        data.put("dy", String.valueOf(layer.getDy()));
    9092        for (Map.Entry<String, String> entry : data.entrySet()) {
    9193            Element attrElem = support.createElement(entry.getKey());
  • trunk/src/org/openstreetmap/josm/io/session/ImagerySessionImporter.java

    r8530 r8803  
    6060            }
    6161        }
     62        if (attributes.containsKey("dx") && attributes.containsKey("dy")) {
     63            layer.setOffset(Double.parseDouble(attributes.get("dx")), Double.parseDouble(attributes.get("dy")));
     64        }
    6265        return layer;
    6366    }
  • trunk/test/unit/org/openstreetmap/josm/io/session/SessionReaderTest.java

    r8450 r8803  
    22package org.openstreetmap.josm.io.session;
    33
     4import static org.hamcrest.CoreMatchers.is;
    45import static org.junit.Assert.assertEquals;
    56import static org.junit.Assert.assertNotNull;
    67import static org.junit.Assert.assertSame;
     8import static org.junit.Assert.assertThat;
    79import static org.junit.Assert.assertTrue;
    810
     
    1618import org.openstreetmap.josm.TestUtils;
    1719import org.openstreetmap.josm.gui.layer.GpxLayer;
     20import org.openstreetmap.josm.gui.layer.ImageryLayer;
    1821import org.openstreetmap.josm.gui.layer.Layer;
    1922import org.openstreetmap.josm.gui.layer.OsmDataLayer;
     
    112115        assertEquals(marker.getName(), "Marker layer name");
    113116    }
     117
     118    @Test
     119    public void testReadImage() throws IOException, IllegalDataException {
     120        final List<Layer> layers = testRead("bing.jos");
     121        assertSame(layers.size(), 1);
     122        assertTrue(layers.get(0) instanceof ImageryLayer);
     123        final ImageryLayer image = (ImageryLayer) layers.get(0);
     124        assertThat(image.getName(), is("Bing aerial imagery"));
     125        assertEquals(image.getDx(), 12.34, 1e-9);
     126        assertEquals(image.getDy(), -56.78, 1e-9);
     127    }
    114128}
  • trunk/test/unit/org/openstreetmap/josm/io/session/SessionWriterTest.java

    r8510 r8803  
    44import java.io.File;
    55import java.io.IOException;
     6import java.util.Arrays;
    67import java.util.Collections;
    78import java.util.HashMap;
     
    1516import org.openstreetmap.josm.data.gpx.GpxData;
    1617import org.openstreetmap.josm.data.gpx.WayPoint;
     18import org.openstreetmap.josm.data.imagery.ImageryInfo;
    1719import org.openstreetmap.josm.data.osm.DataSet;
    1820import org.openstreetmap.josm.gui.layer.GpxLayer;
     21import org.openstreetmap.josm.gui.layer.ImageryLayer;
    1922import org.openstreetmap.josm.gui.layer.Layer;
    2023import org.openstreetmap.josm.gui.layer.OsmDataLayer;
     24import org.openstreetmap.josm.gui.layer.TMSLayer;
    2125import org.openstreetmap.josm.gui.layer.markerlayer.MarkerLayer;
    2226import org.openstreetmap.josm.gui.preferences.projection.ProjectionPreference;
    2327import org.openstreetmap.josm.tools.MultiMap;
    24 import org.openstreetmap.josm.tools.Pair;
    2528
    2629/**
     
    124127    }
    125128
     129    private ImageryLayer createImageryLayer() {
     130        ImageryLayer layer = new TMSLayer(new ImageryInfo("the name", "http://www.url.com/"));
     131        layer.setOffset(12, 34);
     132        return layer;
     133    }
     134
    126135    /**
    127136     * Tests to write an empty .jos file.
     
    185194    public void testWriteGpxAndMarkerJoz() throws IOException {
    186195        GpxLayer gpx = createGpxLayer();
    187         testWrite(Pair.toList(new Pair<Layer, Layer>(gpx, createMarkerLayer(gpx))), true);
     196        testWrite(Arrays.asList(gpx, createMarkerLayer(gpx)), true);
     197    }
     198
     199    @Test
     200    public void testWriteImageryLayer() throws IOException {
     201        final Layer layer = createImageryLayer();
     202        testWrite(Collections.singletonList(layer), true);
    188203    }
    189204}
Note: See TracChangeset for help on using the changeset viewer.