Changeset 14120 in josm for trunk/test/unit/org


Ignore:
Timestamp:
2018-08-11T17:29:48+02:00 (6 years ago)
Author:
Don-vip
Message:

see #15229 - deprecate all Main methods related to projections. New ProjectionRegistry class

Location:
trunk/test/unit/org/openstreetmap/josm
Files:
18 edited

Legend:

Unmodified
Added
Removed
  • trunk/test/unit/org/openstreetmap/josm/JOSMFixture.java

    r14119 r14120  
    1818import org.openstreetmap.josm.data.preferences.JosmBaseDirectories;
    1919import org.openstreetmap.josm.data.preferences.JosmUrls;
     20import org.openstreetmap.josm.data.projection.ProjectionRegistry;
    2021import org.openstreetmap.josm.data.projection.Projections;
    2122import org.openstreetmap.josm.gui.MainApplication;
     
    126127
    127128        // init projection
    128         Main.setProjection(Projections.getProjectionByCode("EPSG:3857")); // Mercator
     129        ProjectionRegistry.setProjection(Projections.getProjectionByCode("EPSG:3857")); // Mercator
    129130
    130131        // setup projection grid files
  • trunk/test/unit/org/openstreetmap/josm/MainTest.java

    r14119 r14120  
    1515import org.openstreetmap.josm.Main.InitStatusListener;
    1616import org.openstreetmap.josm.Main.InitializationTask;
     17import org.openstreetmap.josm.data.coor.conversion.CoordinateFormatManager;
    1718import org.openstreetmap.josm.io.OnlineResource;
    1819import org.openstreetmap.josm.testutils.JOSMTestRules;
     
    3839    public void testPreConstructorInit() {
    3940        Main.preConstructorInit();
    40         assertNotNull(Main.getProjection());
     41        assertNotNull(CoordinateFormatManager.getDefaultFormat());
    4142    }
    4243
  • trunk/test/unit/org/openstreetmap/josm/command/MoveCommandTest.java

    r13489 r14120  
    1515import org.junit.Rule;
    1616import org.junit.Test;
    17 import org.openstreetmap.josm.Main;
    1817import org.openstreetmap.josm.TestUtils;
    1918import org.openstreetmap.josm.command.CommandTest.CommandTestDataWithRelation;
     
    2423import org.openstreetmap.josm.data.osm.OsmPrimitive;
    2524import org.openstreetmap.josm.data.osm.User;
     25import org.openstreetmap.josm.data.projection.ProjectionRegistry;
    2626import org.openstreetmap.josm.gui.layer.OsmDataLayer;
    2727import org.openstreetmap.josm.testutils.JOSMTestRules;
     
    5757    public void testConstructors() {
    5858        EastNorth offset = new EastNorth(1, 2);
    59         LatLon destLatLon = Main.getProjection().eastNorth2latlon(offset);
     59        LatLon destLatLon = ProjectionRegistry.getProjection().eastNorth2latlon(offset);
    6060        EastNorth start = new EastNorth(2, 0);
    6161
  • trunk/test/unit/org/openstreetmap/josm/data/gpx/GpxDataTest.java

    r13210 r14120  
    2020import org.junit.Rule;
    2121import org.junit.Test;
    22 import org.openstreetmap.josm.Main;
    2322import org.openstreetmap.josm.TestUtils;
    2423import org.openstreetmap.josm.data.Bounds;
     
    2827import org.openstreetmap.josm.data.gpx.GpxData.GpxDataChangeEvent;
    2928import org.openstreetmap.josm.data.gpx.GpxData.GpxDataChangeListener;
     29import org.openstreetmap.josm.data.projection.ProjectionRegistry;
    3030import org.openstreetmap.josm.testutils.JOSMTestRules;
    3131import org.openstreetmap.josm.tools.ListenerList;
     
    327327        List<WayPoint> points = Stream
    328328                .of(new EastNorth(10, 10), new EastNorth(10, 0), new EastNorth(-1, 0))
    329                 .map(Main.getProjection()::eastNorth2latlon)
     329                .map(ProjectionRegistry.getProjection()::eastNorth2latlon)
    330330                .map(WayPoint::new)
    331331                .collect(Collectors.toList());
     
    336336
    337337        WayPoint close = data.nearestPointOnTrack(new EastNorth(5, 5), 10);
    338         assertEquals(10, close.getEastNorth(Main.getProjection()).east(), .01);
    339         assertEquals(5, close.getEastNorth(Main.getProjection()).north(), .01);
     338        assertEquals(10, close.getEastNorth(ProjectionRegistry.getProjection()).east(), .01);
     339        assertEquals(5, close.getEastNorth(ProjectionRegistry.getProjection()).north(), .01);
    340340
    341341        close = data.nearestPointOnTrack(new EastNorth(15, 5), 10);
    342         assertEquals(10, close.getEastNorth(Main.getProjection()).east(), .01);
    343         assertEquals(5, close.getEastNorth(Main.getProjection()).north(), .01);
     342        assertEquals(10, close.getEastNorth(ProjectionRegistry.getProjection()).east(), .01);
     343        assertEquals(5, close.getEastNorth(ProjectionRegistry.getProjection()).north(), .01);
    344344
    345345        assertNull(data.nearestPointOnTrack(new EastNorth(5, 5), 1));
  • trunk/test/unit/org/openstreetmap/josm/data/imagery/TemplatedWMSTileSourceTest.java

    r12669 r14120  
    1010import org.openstreetmap.gui.jmapviewer.interfaces.ICoordinate;
    1111import org.openstreetmap.gui.jmapviewer.tilesources.TemplatedTMSTileSource;
    12 import org.openstreetmap.josm.Main;
    1312import org.openstreetmap.josm.data.Bounds;
    1413import org.openstreetmap.josm.data.coor.EastNorth;
     
    1615import org.openstreetmap.josm.data.projection.CustomProjection;
    1716import org.openstreetmap.josm.data.projection.Projection;
     17import org.openstreetmap.josm.data.projection.ProjectionRegistry;
    1818import org.openstreetmap.josm.data.projection.Projections;
    1919import org.openstreetmap.josm.testutils.JOSMTestRules;
     
    4242    public void testEPSG3857() {
    4343        Projection projection = Projections.getProjectionByCode("EPSG:3857");
    44         Main.setProjection(projection);
     44        ProjectionRegistry.setProjection(projection);
    4545        TemplatedWMSTileSource source = new TemplatedWMSTileSource(testImageryWMS, projection);
    4646        verifyMercatorTile(source, 0, 0, 1);
     
    6767    public void testEPSG4326() {
    6868        Projection projection = Projections.getProjectionByCode("EPSG:4326");
    69         Main.setProjection(projection);
     69        ProjectionRegistry.setProjection(projection);
    7070        TemplatedWMSTileSource source = getSource(projection);
    7171
     
    8383    public void testEPSG4326widebounds() {
    8484        Projection projection = new CustomProjection("+proj=lonlat +datum=WGS84 +axis=neu +bounds=-180,53,180,54");
    85         Main.setProjection(projection);
     85        ProjectionRegistry.setProjection(projection);
    8686        TemplatedWMSTileSource source = getSource(projection);
    8787
     
    9696    public void testEPSG4326narrowbounds() {
    9797        Projection projection = new CustomProjection("+proj=lonlat +datum=WGS84 +axis=neu +bounds=18,-90,20,90");
    98         Main.setProjection(projection);
     98        ProjectionRegistry.setProjection(projection);
    9999        TemplatedWMSTileSource source = getSource(projection);
    100100
     
    109109    public void testEPSG2180() {
    110110        Projection projection = Projections.getProjectionByCode("EPSG:2180");
    111         Main.setProjection(projection);
     111        ProjectionRegistry.setProjection(projection);
    112112        TemplatedWMSTileSource source = getSource(projection);
    113113
     
    128128                new CustomProjection("+proj=utm +zone=33 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 "
    129129                        + "+units=m +no_defs +axis=neu +wmssrs=EPSG:3006 +bounds=10.5700,55.2000,24.1800,69.1000 ");
    130         Main.setProjection(projection);
     130        ProjectionRegistry.setProjection(projection);
    131131        TemplatedWMSTileSource source = getSource(projection);
    132132
     
    144144                new CustomProjection("+proj=utm +zone=33 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 "
    145145                        + "+units=m +no_defs +axis=neu +wmssrs=EPSG:3006");
    146         Main.setProjection(projection);
     146        ProjectionRegistry.setProjection(projection);
    147147        TemplatedWMSTileSource source = getSource(projection);
    148148
     
    174174
    175175    private void verifyLocation(TemplatedWMSTileSource source, LatLon location, int z) {
     176        Projection projection = ProjectionRegistry.getProjection();
    176177        assertTrue(
    177178                "Point outside world bounds",
    178                 Main.getProjection().getWorldBoundsLatLon().contains(location)
     179                projection.getWorldBoundsLatLon().contains(location)
    179180                );
    180181
     
    187188                tileIndex.getYIndex() <= source.getTileYMax(z));
    188189
    189         EastNorth locationEN = Main.getProjection().latlon2eastNorth(location);
    190         EastNorth x1 = Main.getProjection().latlon2eastNorth(getTileLatLon(source, tileIndex, z));
    191         EastNorth x2 = Main.getProjection().latlon2eastNorth(getTileLatLon(source, tileIndex.getXIndex() + 1, tileIndex.getYIndex() + 1, z));
     190        EastNorth locationEN = projection.latlon2eastNorth(location);
     191        EastNorth x1 = projection.latlon2eastNorth(getTileLatLon(source, tileIndex, z));
     192        EastNorth x2 = projection.latlon2eastNorth(getTileLatLon(source, tileIndex.getXIndex() + 1, tileIndex.getYIndex() + 1, z));
    192193        // test that location is within tile bounds
    193194        assertTrue(locationEN.toString() + " not within " + bboxStr(x1, x2) +
  • trunk/test/unit/org/openstreetmap/josm/data/imagery/WMSEndpointTileSourceTest.java

    r14092 r14120  
    1111import org.junit.Rule;
    1212import org.junit.Test;
    13 import org.openstreetmap.josm.Main;
    1413import org.openstreetmap.josm.TestUtils;
    1514import org.openstreetmap.josm.data.imagery.ImageryInfo.ImageryType;
     15import org.openstreetmap.josm.data.projection.ProjectionRegistry;
    1616import org.openstreetmap.josm.data.projection.Projections;
    1717import org.openstreetmap.josm.spi.preferences.Config;
     
    7878        ImageryInfo wmsImageryInfo = ImageryLayerInfo.instance.getDefaultLayers().get(0);
    7979        assertEquals("single_node_in_way", wmsImageryInfo.getDefaultLayers().get(0).getLayerName());
    80         WMSEndpointTileSource tileSource = new WMSEndpointTileSource(wmsImageryInfo, Main.getProjection());
     80        WMSEndpointTileSource tileSource = new WMSEndpointTileSource(wmsImageryInfo, ProjectionRegistry.getProjection());
    8181        tileSource.initProjection(Projections.getProjectionByCode("EPSG:3857"));
    8282        assertEquals("https://tools.geofabrik.de/osmi/views/geometry/wxs?FORMAT=image/png&TRANSPARENT=TRUE&VERSION=1.1.1&SERVICE=WMS&"
     
    122122        ImageryInfo wmsImageryInfo = ImageryLayerInfo.instance.getDefaultLayers().get(0);
    123123        wmsImageryInfo.setDefaultLayers(Arrays.asList(new DefaultLayer(ImageryType.WMS_ENDPOINT, "historiske-ortofoto", "", "")));
    124         WMSEndpointTileSource tileSource = new WMSEndpointTileSource(wmsImageryInfo, Main.getProjection());
     124        WMSEndpointTileSource tileSource = new WMSEndpointTileSource(wmsImageryInfo, ProjectionRegistry.getProjection());
    125125        tileSource.initProjection(Projections.getProjectionByCode("EPSG:3857"));
    126126        assertEquals("b8e36d51-119a-423b-b156-d744d54123d5", wmsImageryInfo.getCustomHttpHeaders().get("X-WAAPI-TOKEN"));
  • trunk/test/unit/org/openstreetmap/josm/data/imagery/WMTSTileSourceTest.java

    r14049 r14120  
    2121import org.openstreetmap.gui.jmapviewer.TileXY;
    2222import org.openstreetmap.gui.jmapviewer.tilesources.TemplatedTMSTileSource;
    23 import org.openstreetmap.josm.Main;
    2423import org.openstreetmap.josm.TestUtils;
    2524import org.openstreetmap.josm.data.Bounds;
     
    2726import org.openstreetmap.josm.data.imagery.ImageryInfo.ImageryType;
    2827import org.openstreetmap.josm.data.imagery.WMTSTileSource.WMTSGetCapabilitiesException;
     28import org.openstreetmap.josm.data.projection.ProjectionRegistry;
    2929import org.openstreetmap.josm.data.projection.Projections;
    3030import org.openstreetmap.josm.spi.preferences.Config;
     
    8585    @Test
    8686    public void testPseudoMercator() throws IOException, WMTSGetCapabilitiesException {
    87         Main.setProjection(Projections.getProjectionByCode("EPSG:3857"));
     87        ProjectionRegistry.setProjection(Projections.getProjectionByCode("EPSG:3857"));
    8888        WMTSTileSource testSource = new WMTSTileSource(testImageryPSEUDO_MERCATOR);
    89         testSource.initProjection(Main.getProjection());
     89        testSource.initProjection(ProjectionRegistry.getProjection());
    9090
    9191        verifyMercatorTile(testSource, 0, 0, 1);
     
    115115    @Test
    116116    public void testWALLONIE() throws IOException, WMTSGetCapabilitiesException {
    117         Main.setProjection(Projections.getProjectionByCode("EPSG:31370"));
     117        ProjectionRegistry.setProjection(Projections.getProjectionByCode("EPSG:31370"));
    118118        WMTSTileSource testSource = new WMTSTileSource(testImageryWALLONIE);
    119         testSource.initProjection(Main.getProjection());
     119        testSource.initProjection(ProjectionRegistry.getProjection());
    120120
    121121        assertEquals("http://geoservices.wallonie.be/arcgis/rest/services/DONNEES_BASE/FOND_PLAN_ANNOTATIONS_2012_RW_NB/"
     
    135135    @Ignore("disable this test, needs further working") // XXX
    136136    public void testWALLONIENoMatrixDimension() throws IOException, WMTSGetCapabilitiesException {
    137         Main.setProjection(Projections.getProjectionByCode("EPSG:31370"));
     137        ProjectionRegistry.setProjection(Projections.getProjectionByCode("EPSG:31370"));
    138138        WMTSTileSource testSource = new WMTSTileSource(getImagery("test/data/wmts/WMTSCapabilities-Wallonie-nomatrixdimension.xml"));
    139         testSource.initProjection(Main.getProjection());
     139        testSource.initProjection(ProjectionRegistry.getProjection());
    140140
    141141        Bounds wallonieBounds = new Bounds(
     
    159159    @Test
    160160    public void testWIEN() throws IOException, WMTSGetCapabilitiesException {
    161         Main.setProjection(Projections.getProjectionByCode("EPSG:3857"));
     161        ProjectionRegistry.setProjection(Projections.getProjectionByCode("EPSG:3857"));
    162162        WMTSTileSource testSource = new WMTSTileSource(testImageryWIEN);
    163         testSource.initProjection(Main.getProjection());
     163        testSource.initProjection(ProjectionRegistry.getProjection());
    164164        int zoomOffset = 10;
    165165
     
    201201    @Test
    202202    public void testGeoportalTOPOPL() throws IOException, WMTSGetCapabilitiesException {
    203         Main.setProjection(Projections.getProjectionByCode("EPSG:4326"));
     203        ProjectionRegistry.setProjection(Projections.getProjectionByCode("EPSG:4326"));
    204204        WMTSTileSource testSource = new WMTSTileSource(testImageryTOPO_PL);
    205         testSource.initProjection(Main.getProjection());
     205        testSource.initProjection(ProjectionRegistry.getProjection());
    206206        verifyTile(new LatLon(56, 12), testSource, 0, 0, 1);
    207207        verifyTile(new LatLon(56, 12), testSource, 0, 0, 2);
     
    223223    @Test
    224224    public void testGeoportalORTOPL4326() throws IOException, WMTSGetCapabilitiesException {
    225         Main.setProjection(Projections.getProjectionByCode("EPSG:4326"));
     225        ProjectionRegistry.setProjection(Projections.getProjectionByCode("EPSG:4326"));
    226226        WMTSTileSource testSource = new WMTSTileSource(testImageryORTO_PL);
    227         testSource.initProjection(Main.getProjection());
     227        testSource.initProjection(ProjectionRegistry.getProjection());
    228228        verifyTile(new LatLon(53.60205873528009, 19.552206794646956), testSource, 12412, 3941, 13);
    229229        verifyTile(new LatLon(49.79005619189761, 22.778262259134397), testSource, 17714, 10206, 13);
     
    232232    @Test
    233233    public void testGeoportalORTOPL2180() throws IOException, WMTSGetCapabilitiesException {
    234         Main.setProjection(Projections.getProjectionByCode("EPSG:2180"));
     234        ProjectionRegistry.setProjection(Projections.getProjectionByCode("EPSG:2180"));
    235235        WMTSTileSource testSource = new WMTSTileSource(testImageryORTO_PL);
    236         testSource.initProjection(Main.getProjection());
     236        testSource.initProjection(ProjectionRegistry.getProjection());
    237237
    238238        verifyTile(new LatLon(53.59940948387726, 19.560544913270064), testSource, 6453, 3140, 13);
     
    242242    @Test
    243243    public void testTicket12168() throws IOException, WMTSGetCapabilitiesException {
    244         Main.setProjection(Projections.getProjectionByCode("EPSG:3857"));
     244        ProjectionRegistry.setProjection(Projections.getProjectionByCode("EPSG:3857"));
    245245        WMTSTileSource testSource = new WMTSTileSource(testImagery12168);
    246         testSource.initProjection(Main.getProjection());
     246        testSource.initProjection(ProjectionRegistry.getProjection());
    247247        assertEquals(
    248248                "http://www.ngi.be/cartoweb/1.0.0/topo/default/3857/7/1/1.png",
     
    252252    @Test
    253253    public void testTwoTileSetsForOneProjection() throws Exception {
    254         Main.setProjection(Projections.getProjectionByCode("EPSG:3857"));
     254        ProjectionRegistry.setProjection(Projections.getProjectionByCode("EPSG:3857"));
    255255        ImageryInfo ontario = getImagery(TestUtils.getTestDataRoot() + "wmts/WMTSCapabilities-Ontario.xml");
    256256        ontario.setDefaultLayers(Arrays.asList(new DefaultLayer[] {
     
    258258        }));
    259259        WMTSTileSource testSource = new WMTSTileSource(ontario);
    260         testSource.initProjection(Main.getProjection());
     260        testSource.initProjection(ProjectionRegistry.getProjection());
    261261        assertEquals(
    262262                "http://maps.ottawa.ca/arcgis/rest/services/Basemap_Imagery_2014/MapServer/WMTS/tile/1.0.0/Basemap_Imagery_2014/default/"
     
    269269    @Test
    270270    public void testTwoTileSetsForOneProjectionSecondLayer() throws Exception {
    271         Main.setProjection(Projections.getProjectionByCode("EPSG:3857"));
     271        ProjectionRegistry.setProjection(Projections.getProjectionByCode("EPSG:3857"));
    272272        ImageryInfo ontario = getImagery(TestUtils.getTestDataRoot() + "wmts/WMTSCapabilities-Ontario.xml");
    273273        ontario.setDefaultLayers(Arrays.asList(new DefaultLayer[] {
     
    275275        }));
    276276        WMTSTileSource testSource = new WMTSTileSource(ontario);
    277         testSource.initProjection(Main.getProjection());
     277        testSource.initProjection(ProjectionRegistry.getProjection());
    278278        assertEquals(
    279279                "http://maps.ottawa.ca/arcgis/rest/services/Basemap_Imagery_2014/MapServer/WMTS/tile/1.0.0/Basemap_Imagery_2014/default/"
     
    286286    @Test
    287287    public void testManyLayersScrollbars() throws Exception {
    288         Main.setProjection(Projections.getProjectionByCode("EPSG:3857"));
     288        ProjectionRegistry.setProjection(Projections.getProjectionByCode("EPSG:3857"));
    289289        WMTSTileSource testSource = new WMTSTileSource(testLotsOfLayers);
    290         testSource.initProjection(Main.getProjection());
     290        testSource.initProjection(ProjectionRegistry.getProjection());
    291291    }
    292292
    293293    @Test
    294294    public void testParserForDuplicateTags() throws Exception {
    295         Main.setProjection(Projections.getProjectionByCode("EPSG:3857"));
     295        ProjectionRegistry.setProjection(Projections.getProjectionByCode("EPSG:3857"));
    296296        WMTSTileSource testSource = new WMTSTileSource(testDuplicateTags);
    297         testSource.initProjection(Main.getProjection());
     297        testSource.initProjection(ProjectionRegistry.getProjection());
    298298        assertEquals(
    299299                "http://tile.informatievlaanderen.be/ws/raadpleegdiensten/wmts?SERVICE=WMTS&REQUEST=GetTile&VERSION=1.0.0&LAYER=grb_bsk&"
     
    305305    @Test
    306306    public void testParserForMissingStyleIdentifier() throws Exception {
    307         Main.setProjection(Projections.getProjectionByCode("EPSG:3857"));
     307        ProjectionRegistry.setProjection(Projections.getProjectionByCode("EPSG:3857"));
    308308        WMTSTileSource testSource = new WMTSTileSource(testMissingStyleIdentifer);
    309         testSource.initProjection(Main.getProjection());
     309        testSource.initProjection(ProjectionRegistry.getProjection());
    310310    }
    311311
    312312    @Test
    313313    public void testForMultipleTileMatricesForOneLayerProjection() throws Exception {
    314         Main.setProjection(Projections.getProjectionByCode("EPSG:3857"));
     314        ProjectionRegistry.setProjection(Projections.getProjectionByCode("EPSG:3857"));
    315315        ImageryInfo copy = new ImageryInfo(testMultipleTileMatrixForLayer);
    316316        List<DefaultLayer> defaultLayers = new ArrayList<>(1);
     
    318318        copy.setDefaultLayers(defaultLayers);
    319319        WMTSTileSource testSource = new WMTSTileSource(copy);
    320         testSource.initProjection(Main.getProjection());
     320        testSource.initProjection(ProjectionRegistry.getProjection());
    321321        assertEquals(
    322322                "http://188.253.0.155:6080/arcgis/rest/services/Mashhad_BaseMap_1/MapServer/WMTS/tile/1.0.0/Mashhad_BaseMap_1"
     
    333333    @Test
    334334    public void testDimension() throws IOException, WMTSGetCapabilitiesException {
    335         Main.setProjection(Projections.getProjectionByCode("EPSG:21781"));
     335        ProjectionRegistry.setProjection(Projections.getProjectionByCode("EPSG:21781"));
    336336        ImageryInfo info = new ImageryInfo(testImageryGeoAdminCh);
    337337        List<DefaultLayer> defaultLayers = new ArrayList<>(1);
     
    339339        info.setDefaultLayers(defaultLayers);
    340340        WMTSTileSource testSource = new WMTSTileSource(info);
    341         testSource.initProjection(Main.getProjection());
     341        testSource.initProjection(ProjectionRegistry.getProjection());
    342342        assertEquals(
    343343                "http://wmts.geo.admin.ch/1.0.0/ch.are.agglomerationen_isolierte_staedte/default/20140101/21781/1/3/2.png",
     
    414414    @Test
    415415    public void testGisKtnGvAt() throws IOException, WMTSGetCapabilitiesException {
    416         Main.setProjection(Projections.getProjectionByCode("EPSG:31258"));
     416        ProjectionRegistry.setProjection(Projections.getProjectionByCode("EPSG:31258"));
    417417        final WMTSTileSource source = new WMTSTileSource(testImageryGisKtnGvAt);
    418         source.initProjection(Main.getProjection());
     418        source.initProjection(ProjectionRegistry.getProjection());
    419419        final TileXY tile = source.latLonToTileXY(46.6103, 13.8558, 11);
    420420        assertEquals("https://gis.ktn.gv.at/arcgis/rest/services/tilecache/Ortho_2013_2015" +
  • trunk/test/unit/org/openstreetmap/josm/data/osm/DataSetMergerTest.java

    r12750 r14120  
    1919import org.junit.Rule;
    2020import org.junit.Test;
    21 import org.openstreetmap.josm.Main;
    2221import org.openstreetmap.josm.data.coor.LatLon;
     22import org.openstreetmap.josm.data.projection.ProjectionRegistry;
    2323import org.openstreetmap.josm.data.projection.Projections;
    2424import org.openstreetmap.josm.testutils.JOSMTestRules;
     
    4949        their = new DataSet();
    5050        their.setVersion("0.6");
    51         Main.setProjection(Projections.getProjectionByCode("EPSG:3857")); // Mercator
     51        ProjectionRegistry.setProjection(Projections.getProjectionByCode("EPSG:3857")); // Mercator
    5252    }
    5353
  • trunk/test/unit/org/openstreetmap/josm/data/osm/OsmPrimitiveTest.java

    r10945 r14120  
    99import org.junit.Rule;
    1010import org.junit.Test;
    11 import org.openstreetmap.josm.Main;
    1211import org.openstreetmap.josm.data.coor.LatLon;
     12import org.openstreetmap.josm.data.projection.ProjectionRegistry;
    1313import org.openstreetmap.josm.data.projection.Projections;
    1414import org.openstreetmap.josm.testutils.JOSMTestRules;
     
    4040    @BeforeClass
    4141    public static void setUp() {
    42         Main.setProjection(Projections.getProjectionByCode("EPSG:3857")); // Mercator
     42        ProjectionRegistry.setProjection(Projections.getProjectionByCode("EPSG:3857")); // Mercator
    4343    }
    4444
  • trunk/test/unit/org/openstreetmap/josm/data/osm/QuadBucketsTest.java

    r14092 r14120  
    1717import org.junit.Rule;
    1818import org.junit.Test;
    19 import org.openstreetmap.josm.Main;
    2019import org.openstreetmap.josm.data.coor.LatLon;
     20import org.openstreetmap.josm.data.projection.ProjectionRegistry;
    2121import org.openstreetmap.josm.data.projection.Projections;
    2222import org.openstreetmap.josm.gui.progress.NullProgressMonitor;
     
    8383    @Test
    8484    public void testRemove() throws Exception {
    85         Main.setProjection(Projections.getProjectionByCode("EPSG:3857")); // Mercator
     85        ProjectionRegistry.setProjection(Projections.getProjectionByCode("EPSG:3857")); // Mercator
    8686        try (InputStream fis = new FileInputStream("data_nodist/restriction.osm")) {
    8787            DataSet ds = OsmReader.parseDataSet(fis, NullProgressMonitor.INSTANCE);
     
    9696    @Test
    9797    public void testMove() throws Exception {
    98         Main.setProjection(Projections.getProjectionByCode("EPSG:3857")); // Mercator
     98        ProjectionRegistry.setProjection(Projections.getProjectionByCode("EPSG:3857")); // Mercator
    9999        try (InputStream fis = new FileInputStream("data_nodist/restriction.osm")) {
    100100            DataSet ds = OsmReader.parseDataSet(fis, NullProgressMonitor.INSTANCE);
  • trunk/test/unit/org/openstreetmap/josm/data/projection/SwissGridTest.java

    r13702 r14120  
    88import org.junit.Rule;
    99import org.junit.Test;
    10 import org.openstreetmap.josm.Main;
    1110import org.openstreetmap.josm.data.coor.EastNorth;
    1211import org.openstreetmap.josm.data.coor.LatLon;
     
    3433    @BeforeClass
    3534    public static void setUp() {
    36         Main.setProjection(Projections.getProjectionByCode(SWISS_EPSG_CODE)); // Swiss grid
     35        ProjectionRegistry.setProjection(Projections.getProjectionByCode(SWISS_EPSG_CODE)); // Swiss grid
    3736    }
    3837
     
    9796    public void testAlatlon2eastNorth() {
    9897        LatLon ll = new LatLon(46.518, 6.567);
    99         EastNorth en = Main.getProjection().latlon2eastNorth(ll);
     98        EastNorth en = ProjectionRegistry.getProjection().latlon2eastNorth(ll);
    10099        if (debug) {
    101100            System.out.println(en);
     
    105104
    106105        ll = new LatLon(47.78, 8.58);
    107         en = Main.getProjection().latlon2eastNorth(ll);
     106        en = ProjectionRegistry.getProjection().latlon2eastNorth(ll);
    108107        if (debug) {
    109108            System.out.println(en);
     
    113112
    114113        ll = new LatLon(46.58, 10.48);
    115         en = Main.getProjection().latlon2eastNorth(ll);
     114        en = ProjectionRegistry.getProjection().latlon2eastNorth(ll);
    116115        if (debug) {
    117116            System.out.println(en);
     
    121120
    122121        ll = new LatLon(46.0 + 57.0 / 60 + 3.89813884505 / 3600, 7.0 + 26.0 / 60 + 19.076595154147 / 3600);
    123         en = Main.getProjection().latlon2eastNorth(ll);
     122        en = ProjectionRegistry.getProjection().latlon2eastNorth(ll);
    124123        if (debug) {
    125124            System.out.println(en);
     
    130129        // http://geodesy.geo.admin.ch/reframe/lv03towgs84?easting=700000&northing=100000
    131130        ll = new LatLon(46.04412093223244, 8.730497366167727);
    132         en = Main.getProjection().latlon2eastNorth(ll);
     131        en = ProjectionRegistry.getProjection().latlon2eastNorth(ll);
    133132        if (debug) {
    134133            System.out.println(en);
     
    144143    public void testBeastNorth2latlon() {
    145144        EastNorth en = new EastNorth(533112.13, 152227.35);
    146         LatLon ll = Main.getProjection().eastNorth2latlon(en);
     145        LatLon ll = ProjectionRegistry.getProjection().eastNorth2latlon(en);
    147146        if (debug) {
    148147            System.out.println(ll);
     
    152151
    153152        en = new EastNorth(685542.97, 292783.21);
    154         ll = Main.getProjection().eastNorth2latlon(en);
     153        ll = ProjectionRegistry.getProjection().eastNorth2latlon(en);
    155154        if (debug) {
    156155            System.out.println(ll);
     
    160159
    161160        en = new EastNorth(833066.95, 163265.32);
    162         ll = Main.getProjection().eastNorth2latlon(en);
     161        ll = ProjectionRegistry.getProjection().eastNorth2latlon(en);
    163162        if (debug) {
    164163            System.out.println(ll);
     
    168167
    169168        en = new EastNorth(600000.0, 200000.0);
    170         ll = Main.getProjection().eastNorth2latlon(en);
     169        ll = ProjectionRegistry.getProjection().eastNorth2latlon(en);
    171170        if (debug) {
    172171            System.out.println(ll);
     
    177176        // http://geodesy.geo.admin.ch/reframe/lv03towgs84?easting=700000&northing=100000
    178177        en = new EastNorth(700000.0, 100000.0);
    179         ll = Main.getProjection().eastNorth2latlon(en);
     178        ll = ProjectionRegistry.getProjection().eastNorth2latlon(en);
    180179        if (debug) {
    181180            System.out.println(ll);
     
    191190    public void testCsendandreturn() {
    192191        EastNorth en = new EastNorth(533111.69, 152227.85);
    193         LatLon ll = Main.getProjection().eastNorth2latlon(en);
    194         EastNorth en2 = Main.getProjection().latlon2eastNorth(ll);
     192        LatLon ll = ProjectionRegistry.getProjection().eastNorth2latlon(en);
     193        EastNorth en2 = ProjectionRegistry.getProjection().latlon2eastNorth(ll);
    195194        if (debug) {
    196195            System.out.println(en.east() - en2.east());
     
    203202
    204203        en = new EastNorth(685544.16, 292782.91);
    205         ll = Main.getProjection().eastNorth2latlon(en);
    206         en2 = Main.getProjection().latlon2eastNorth(ll);
     204        ll = ProjectionRegistry.getProjection().eastNorth2latlon(en);
     205        en2 = ProjectionRegistry.getProjection().latlon2eastNorth(ll);
    207206        if (debug) {
    208207            System.out.println(en.east() - en2.east());
     
    215214
    216215        en = new EastNorth(833068.04, 163265.39);
    217         ll = Main.getProjection().eastNorth2latlon(en);
    218         en2 = Main.getProjection().latlon2eastNorth(ll);
     216        ll = ProjectionRegistry.getProjection().eastNorth2latlon(en);
     217        en2 = ProjectionRegistry.getProjection().latlon2eastNorth(ll);
    219218        if (debug) {
    220219            System.out.println(en.east() - en2.east());
     
    227226
    228227        en = new EastNorth(600000.0, 200000.0);
    229         ll = Main.getProjection().eastNorth2latlon(en);
    230         en2 = Main.getProjection().latlon2eastNorth(ll);
     228        ll = ProjectionRegistry.getProjection().eastNorth2latlon(en);
     229        en2 = ProjectionRegistry.getProjection().latlon2eastNorth(ll);
    231230        if (debug) {
    232231            System.out.println(en.east() - en2.east());
     
    239238
    240239        en = new EastNorth(700000.0, 100000.0);
    241         ll = Main.getProjection().eastNorth2latlon(en);
    242         en2 = Main.getProjection().latlon2eastNorth(ll);
     240        ll = ProjectionRegistry.getProjection().eastNorth2latlon(en);
     241        en2 = ProjectionRegistry.getProjection().latlon2eastNorth(ll);
    243242        if (debug) {
    244243            System.out.println(en.east() - en2.east());
  • trunk/test/unit/org/openstreetmap/josm/gui/MapViewStateTest.java

    r12076 r14120  
    1313import org.junit.Test;
    1414import org.openstreetmap.josm.JOSMFixture;
    15 import org.openstreetmap.josm.Main;
    1615import org.openstreetmap.josm.data.coor.EastNorth;
    1716import org.openstreetmap.josm.data.coor.LatLon;
     17import org.openstreetmap.josm.data.projection.ProjectionRegistry;
    1818import org.openstreetmap.josm.gui.MapViewState.MapViewPoint;
    1919import org.openstreetmap.josm.gui.MapViewState.MapViewRectangle;
     
    111111
    112112        EastNorth eastnorth = p.getEastNorth();
    113         LatLon shouldLatLon = Main.getProjection().getWorldBoundsLatLon().getCenter();
    114         EastNorth shouldEastNorth = Main.getProjection().latlon2eastNorth(shouldLatLon);
     113        LatLon shouldLatLon = ProjectionRegistry.getProjection().getWorldBoundsLatLon().getCenter();
     114        EastNorth shouldEastNorth = ProjectionRegistry.getProjection().latlon2eastNorth(shouldLatLon);
    115115        assertEquals("east", shouldEastNorth.east(), eastnorth.east(), 0.01);
    116116        assertEquals("north", shouldEastNorth.north(), eastnorth.north(), 0.01);
  • trunk/test/unit/org/openstreetmap/josm/gui/NavigatableComponentTest.java

    r11867 r14120  
    1818import org.junit.Rule;
    1919import org.junit.Test;
    20 import org.openstreetmap.josm.Main;
    2120import org.openstreetmap.josm.data.Bounds;
    2221import org.openstreetmap.josm.data.ProjectionBounds;
    2322import org.openstreetmap.josm.data.coor.EastNorth;
    2423import org.openstreetmap.josm.data.coor.LatLon;
     24import org.openstreetmap.josm.data.projection.ProjectionRegistry;
    2525import org.openstreetmap.josm.gui.util.GuiHelper;
    2626import org.openstreetmap.josm.testutils.JOSMTestRules;
     
    8282    @Test
    8383    public void testDefaultScale() {
    84         assertEquals(Main.getProjection().getDefaultZoomInPPD(), component.getScale(), 0.00001);
     84        assertEquals(ProjectionRegistry.getProjection().getDefaultZoomInPPD(), component.getScale(), 0.00001);
    8585    }
    8686
  • trunk/test/unit/org/openstreetmap/josm/gui/datatransfer/OsmTransferHandlerTest.java

    r12922 r14120  
    99import org.junit.Rule;
    1010import org.junit.Test;
    11 import org.openstreetmap.josm.Main;
    1211import org.openstreetmap.josm.actions.CopyAction;
    1312import org.openstreetmap.josm.data.coor.LatLon;
    1413import org.openstreetmap.josm.data.osm.DataSet;
    1514import org.openstreetmap.josm.data.osm.Node;
     15import org.openstreetmap.josm.data.projection.ProjectionRegistry;
    1616import org.openstreetmap.josm.gui.MainApplication;
    1717import org.openstreetmap.josm.gui.layer.OsmDataLayer;
     
    5555
    5656        LatLon pos = new LatLon(55, -5);
    57         transferHandler.pasteOn(target, Main.getProjection().latlon2eastNorth(pos));
     57        transferHandler.pasteOn(target, ProjectionRegistry.getProjection().latlon2eastNorth(pos));
    5858        assertTrue(pos.equalsEpsilon(ds2.getNodes().iterator().next().getCoor()));
    5959    }
  • trunk/test/unit/org/openstreetmap/josm/gui/dialogs/MinimapDialogTest.java

    r14052 r14120  
    33
    44import static java.util.concurrent.TimeUnit.MILLISECONDS;
    5 import static org.openstreetmap.josm.tools.I18n.tr;
    65import static org.junit.Assert.assertEquals;
    76import static org.junit.Assert.assertFalse;
    87import static org.junit.Assert.assertTrue;
    98import static org.junit.Assert.fail;
     9import static org.openstreetmap.josm.tools.I18n.tr;
    1010
    1111import java.awt.Color;
     
    1919import java.util.regex.Matcher;
    2020
     21import javax.swing.JCheckBoxMenuItem;
    2122import javax.swing.JMenuItem;
    22 import javax.swing.JCheckBoxMenuItem;
    2323import javax.swing.JPopupMenu;
    2424
     
    3131import org.openstreetmap.josm.data.DataSource;
    3232import org.openstreetmap.josm.data.osm.DataSet;
     33import org.openstreetmap.josm.data.projection.ProjectionRegistry;
    3334import org.openstreetmap.josm.data.projection.Projections;
    3435import org.openstreetmap.josm.gui.MainApplication;
     
    3637import org.openstreetmap.josm.gui.bbox.SlippyMapBBoxChooser;
    3738import org.openstreetmap.josm.gui.bbox.SourceButton;
     39import org.openstreetmap.josm.gui.layer.LayerManagerTest.TestLayer;
    3840import org.openstreetmap.josm.gui.layer.OsmDataLayer;
    39 import org.openstreetmap.josm.gui.layer.LayerManagerTest.TestLayer;
    4041import org.openstreetmap.josm.gui.util.GuiHelper;
    4142import org.openstreetmap.josm.testutils.ImagePatternMatching;
     
    278279        Main.pref.put("slippy_map_chooser.mapstyle", "White Tiles");
    279280        // ensure projection matches JMapViewer's
    280         Main.setProjection(Projections.getProjectionByCode("EPSG:3857"));
     281        ProjectionRegistry.setProjection(Projections.getProjectionByCode("EPSG:3857"));
    281282
    282283        MapView mapView = MainApplication.getMap().mapView;
  • trunk/test/unit/org/openstreetmap/josm/gui/layer/LayerTest.java

    r12990 r14120  
    1414import org.junit.Rule;
    1515import org.junit.Test;
    16 import org.openstreetmap.josm.Main;
    1716import org.openstreetmap.josm.data.preferences.AbstractProperty;
    1817import org.openstreetmap.josm.data.preferences.NamedColorProperty;
     18import org.openstreetmap.josm.data.projection.ProjectionRegistry;
    1919import org.openstreetmap.josm.testutils.JOSMTestRules;
    2020
     
    181181    public void testIsProjectionSupported() {
    182182        assertFalse(testLayer.isProjectionSupported(null));
    183         assertTrue(testLayer.isProjectionSupported(Main.getProjection()));
     183        assertTrue(testLayer.isProjectionSupported(ProjectionRegistry.getProjection()));
    184184    }
    185185
  • trunk/test/unit/org/openstreetmap/josm/io/session/SessionWriterTest.java

    r13797 r14120  
    1313import org.junit.Rule;
    1414import org.junit.Test;
    15 import org.openstreetmap.josm.Main;
    1615import org.openstreetmap.josm.data.coor.LatLon;
    1716import org.openstreetmap.josm.data.gpx.GpxData;
     
    2120import org.openstreetmap.josm.data.notes.Note;
    2221import org.openstreetmap.josm.data.osm.DataSet;
     22import org.openstreetmap.josm.data.projection.ProjectionRegistry;
    2323import org.openstreetmap.josm.gui.MainApplication;
    2424import org.openstreetmap.josm.gui.layer.GpxLayer;
     
    144144        TMSLayer layer = new TMSLayer(new ImageryInfo("the name", "http://www.url.com/"));
    145145        layer.getDisplaySettings().setOffsetBookmark(
    146                 new OffsetBookmark(Main.getProjection().toCode(), layer.getInfo().getId(), layer.getInfo().getName(), "", 12, 34));
     146                new OffsetBookmark(ProjectionRegistry.getProjection().toCode(), layer.getInfo().getId(), layer.getInfo().getName(), "", 12, 34));
    147147        return layer;
    148148    }
  • trunk/test/unit/org/openstreetmap/josm/testutils/JOSMTestRules.java

    r14119 r14120  
    3232import org.openstreetmap.josm.data.preferences.JosmBaseDirectories;
    3333import org.openstreetmap.josm.data.preferences.JosmUrls;
     34import org.openstreetmap.josm.data.projection.ProjectionRegistry;
    3435import org.openstreetmap.josm.data.projection.Projections;
    3536import org.openstreetmap.josm.gui.MainApplication;
     
    472473
    473474        if (useProjection) {
    474             Main.setProjection(Projections.getProjectionByCode("EPSG:3857")); // Mercator
     475            ProjectionRegistry.setProjection(Projections.getProjectionByCode("EPSG:3857")); // Mercator
    475476        }
    476477
     
    589590
    590591        // TODO: Remove global listeners and other global state.
    591         Main.clearProjectionChangeListeners();
     592        ProjectionRegistry.clearProjectionChangeListeners();
    592593        Main.pref.resetToInitialState();
    593594        Main.platform = null;
Note: See TracChangeset for help on using the changeset viewer.