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

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

Location:
trunk/src/org/openstreetmap/josm/data
Files:
2 added
15 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/data/coor/CachedLatLon.java

    r12161 r14120  
    44import java.util.Objects;
    55
    6 import org.openstreetmap.josm.Main;
    76import org.openstreetmap.josm.data.projection.Projecting;
    87import org.openstreetmap.josm.data.projection.Projection;
     8import org.openstreetmap.josm.data.projection.ProjectionRegistry;
    99
    1010/**
     
    4646     */
    4747    public CachedLatLon(EastNorth eastNorth) {
    48         this(eastNorth, Main.getProjection());
     48        this(eastNorth, ProjectionRegistry.getProjection());
    4949    }
    5050
  • trunk/src/org/openstreetmap/josm/data/coor/LatLon.java

    r14091 r14120  
    1717import java.util.Objects;
    1818
    19 import org.openstreetmap.josm.Main;
    2019import org.openstreetmap.josm.data.Bounds;
     20import org.openstreetmap.josm.data.projection.ProjectionRegistry;
    2121import org.openstreetmap.josm.tools.Logging;
    2222import org.openstreetmap.josm.tools.Utils;
     
    195195     */
    196196    public boolean isOutSideWorld() {
    197         Bounds b = Main.getProjection().getWorldBoundsLatLon();
     197        Bounds b = ProjectionRegistry.getProjection().getWorldBoundsLatLon();
    198198        return lat() < b.getMinLat() || lat() > b.getMaxLat() ||
    199199                lon() < b.getMinLon() || lon() > b.getMaxLon();
  • trunk/src/org/openstreetmap/josm/data/coor/conversion/ProjectedCoordinateFormat.java

    r12741 r14120  
    44import static org.openstreetmap.josm.tools.I18n.tr;
    55
    6 import org.openstreetmap.josm.Main;
    76import org.openstreetmap.josm.data.coor.ILatLon;
     7import org.openstreetmap.josm.data.projection.ProjectionRegistry;
    88
    99/**
     
    2525    @Override
    2626    public String latToString(ILatLon ll) {
    27         return cDdFormatter.format(ll.getEastNorth(Main.getProjection()).north());
     27        return cDdFormatter.format(ll.getEastNorth(ProjectionRegistry.getProjection()).north());
    2828    }
    2929
    3030    @Override
    3131    public String lonToString(ILatLon ll) {
    32         return cDdFormatter.format(ll.getEastNorth(Main.getProjection()).east());
     32        return cDdFormatter.format(ll.getEastNorth(ProjectionRegistry.getProjection()).east());
    3333    }
    3434}
  • trunk/src/org/openstreetmap/josm/data/gpx/GpxData.java

    r13257 r14120  
    2020import java.util.stream.Stream;
    2121
    22 import org.openstreetmap.josm.Main;
    2322import org.openstreetmap.josm.data.Bounds;
    2423import org.openstreetmap.josm.data.Data;
     
    2625import org.openstreetmap.josm.data.coor.EastNorth;
    2726import org.openstreetmap.josm.data.gpx.GpxTrack.GpxTrackChangeListener;
     27import org.openstreetmap.josm.data.projection.ProjectionRegistry;
    2828import org.openstreetmap.josm.gui.MainApplication;
    2929import org.openstreetmap.josm.gui.layer.GpxLayer;
     
    539539                WayPoint r = null;
    540540                for (WayPoint wpSeg : seg.getWayPoints()) {
    541                     EastNorth en = wpSeg.getEastNorth(Main.getProjection());
     541                    EastNorth en = wpSeg.getEastNorth(ProjectionRegistry.getProjection());
    542542                    if (r == null) {
    543543                        r = wpSeg;
     
    586586                }
    587587                if (r != null) {
    588                     EastNorth c = r.getEastNorth(Main.getProjection());
     588                    EastNorth c = r.getEastNorth(ProjectionRegistry.getProjection());
    589589                    /* if there is only one point in the seg, it will do this twice, but no matter */
    590590                    rx = c.east();
     
    603603        if (bestEN == null)
    604604            return null;
    605         WayPoint best = new WayPoint(Main.getProjection().eastNorth2latlon(bestEN));
     605        WayPoint best = new WayPoint(ProjectionRegistry.getProjection().eastNorth2latlon(bestEN));
    606606        best.time = bestTime;
    607607        return best;
  • trunk/src/org/openstreetmap/josm/data/imagery/OffsetBookmark.java

    r13798 r14120  
    1010import java.util.stream.Collectors;
    1111
    12 import org.openstreetmap.josm.Main;
    1312import org.openstreetmap.josm.data.StructUtils;
    1413import org.openstreetmap.josm.data.StructUtils.StructEntry;
     
    1817import org.openstreetmap.josm.data.coor.LatLon;
    1918import org.openstreetmap.josm.data.projection.Projection;
     19import org.openstreetmap.josm.data.projection.ProjectionRegistry;
    2020import org.openstreetmap.josm.data.projection.Projections;
    2121import org.openstreetmap.josm.gui.MainApplication;
     
    4949    public boolean isUsable(ImageryLayer layer) {
    5050        if (projection_code == null) return false;
    51         if (!Main.getProjection().toCode().equals(projection_code) && !hasCenter()) return false;
     51        if (!ProjectionRegistry.getProjection().toCode().equals(projection_code) && !hasCenter()) return false;
    5252        ImageryInfo info = layer.getInfo();
    5353        return imagery_id != null ? Objects.equals(info.getId(), imagery_id) : Objects.equals(info.getName(), imagery_name);
     
    363363        LatLon center;
    364364        if (MainApplication.isDisplayingMapView()) {
    365             center = Main.getProjection().eastNorth2latlon(MainApplication.getMap().mapView.getCenter());
     365            center = ProjectionRegistry.getProjection().eastNorth2latlon(MainApplication.getMap().mapView.getCenter());
    366366        } else {
    367367            center = LatLon.ZERO;
    368368        }
    369369        OffsetBookmark nb = new OffsetBookmark(
    370                 Main.getProjection().toCode(), layer.getInfo().getId(), layer.getInfo().getName(),
     370                ProjectionRegistry.getProjection().toCode(), layer.getInfo().getId(), layer.getInfo().getName(),
    371371                name, layer.getDisplaySettings().getDisplacement(), center);
    372372        for (ListIterator<OffsetBookmark> it = allBookmarks.listIterator(); it.hasNext();) {
  • trunk/src/org/openstreetmap/josm/data/imagery/TemplatedWMSTileSource.java

    r13733 r14120  
    1616
    1717import org.openstreetmap.gui.jmapviewer.interfaces.TemplatedTileSource;
    18 import org.openstreetmap.josm.Main;
    1918import org.openstreetmap.josm.data.coor.EastNorth;
    2019import org.openstreetmap.josm.data.projection.Projection;
     20import org.openstreetmap.josm.data.projection.ProjectionRegistry;
    2121import org.openstreetmap.josm.gui.layer.WMSLayer;
    2222import org.openstreetmap.josm.tools.CheckParameterUtil;
     
    108108        } else if (baseUrl.toLowerCase(Locale.US).contains("crs=")) {
    109109            // assume WMS 1.3.0
    110             switchLatLon = Main.getProjection().switchXY();
     110            switchLatLon = ProjectionRegistry.getProjection().switchXY();
    111111        }
    112112        String bbox = getBbox(zoom, tilex, tiley, switchLatLon);
  • trunk/src/org/openstreetmap/josm/data/imagery/WMTSTileSource.java

    r13879 r14120  
    5050import org.openstreetmap.josm.data.imagery.ImageryInfo.ImageryType;
    5151import org.openstreetmap.josm.data.projection.Projection;
     52import org.openstreetmap.josm.data.projection.ProjectionRegistry;
    5253import org.openstreetmap.josm.data.projection.Projections;
    5354import org.openstreetmap.josm.gui.ExtendedDialog;
     
    346347            List<Layer> ls = layerById.entrySet().iterator().next().getValue()
    347348                    .stream().filter(
    348                             u -> u.tileMatrixSet.crs.equals(Main.getProjection().toCode()))
     349                            u -> u.tileMatrixSet.crs.equals(ProjectionRegistry.getProjection().toCode()))
    349350                    .collect(Collectors.toList());
    350351            if (ls.size() == 1) {
     
    631632    private static TileMatrix parseTileMatrix(XMLStreamReader reader, String matrixCrs) throws XMLStreamException {
    632633        Projection matrixProj = Optional.ofNullable(Projections.getProjectionByCode(matrixCrs))
    633                 .orElseGet(Main::getProjection); // use current projection if none found. Maybe user is using custom string
     634                .orElseGet(ProjectionRegistry::getProjection); // use current projection if none found. Maybe user is using custom string
    634635        TileMatrix ret = new TileMatrix();
    635636        for (int event = reader.getEventType();
  • trunk/src/org/openstreetmap/josm/data/osm/DataSet.java

    r14119 r14120  
    2525import java.util.stream.Stream;
    2626
    27 import org.openstreetmap.josm.Main;
    2827import org.openstreetmap.josm.data.APIDataSet.APIOperation;
    2928import org.openstreetmap.josm.data.Bounds;
     
    5453import org.openstreetmap.josm.data.projection.Projection;
    5554import org.openstreetmap.josm.data.projection.ProjectionChangeListener;
     55import org.openstreetmap.josm.data.projection.ProjectionRegistry;
    5656import org.openstreetmap.josm.gui.progress.ProgressMonitor;
    5757import org.openstreetmap.josm.spi.preferences.Config;
     
    175175        // Transparently register as projection change listener. No need to explicitly remove
    176176        // the listener, projection change listeners are managed as WeakReferences.
    177         Main.addProjectionChangeListener(this);
     177        ProjectionRegistry.addProjectionChangeListener(this);
    178178        addSelectionListener((DataSelectionListener) e -> fireSelectionChange(e.getSelection()));
    179179    }
     
    10451045     */
    10461046    public void invalidateEastNorthCache() {
    1047         if (Main.getProjection() == null)
     1047        if (ProjectionRegistry.getProjection() == null)
    10481048            return; // sanity check
    10491049        beginUpdate();
  • trunk/src/org/openstreetmap/josm/data/osm/INode.java

    r13669 r14120  
    66import org.openstreetmap.josm.data.coor.ILatLon;
    77import org.openstreetmap.josm.data.coor.LatLon;
     8import org.openstreetmap.josm.data.projection.ProjectionRegistry;
    89
    910/**
     
    3435     */
    3536    default EastNorth getEastNorth() {
    36         return getEastNorth(Main.getProjection());
     37        return getEastNorth(ProjectionRegistry.getProjection());
    3738    }
    3839
  • trunk/src/org/openstreetmap/josm/data/osm/Node.java

    r13669 r14120  
    1010import java.util.function.Predicate;
    1111
    12 import org.openstreetmap.josm.Main;
    1312import org.openstreetmap.josm.data.coor.EastNorth;
    1413import org.openstreetmap.josm.data.coor.LatLon;
     
    1615import org.openstreetmap.josm.data.osm.visitor.PrimitiveVisitor;
    1716import org.openstreetmap.josm.data.projection.Projecting;
     17import org.openstreetmap.josm.data.projection.ProjectionRegistry;
    1818import org.openstreetmap.josm.tools.CheckParameterUtil;
    1919import org.openstreetmap.josm.tools.Utils;
     
    114114            invalidateEastNorthCache();
    115115        } else if (eastNorth != null) {
    116             LatLon ll = Main.getProjection().eastNorth2latlon(eastNorth);
     116            LatLon ll = ProjectionRegistry.getProjection().eastNorth2latlon(eastNorth);
    117117            this.lat = ll.lat();
    118118            this.lon = ll.lon();
    119119            this.east = eastNorth.east();
    120120            this.north = eastNorth.north();
    121             this.eastNorthCacheKey = Main.getProjection().getCacheKey();
     121            this.eastNorthCacheKey = ProjectionRegistry.getProjection().getCacheKey();
    122122        } else {
    123123            this.lat = Double.NaN;
  • trunk/src/org/openstreetmap/josm/data/osm/NodeData.java

    r13764 r14120  
    22package org.openstreetmap.josm.data.osm;
    33
    4 import org.openstreetmap.josm.Main;
    54import org.openstreetmap.josm.data.coor.EastNorth;
    65import org.openstreetmap.josm.data.coor.LatLon;
    76import org.openstreetmap.josm.data.osm.visitor.PrimitiveVisitor;
     7import org.openstreetmap.josm.data.projection.ProjectionRegistry;
    88
    99/**
     
    7777    @Override
    7878    public void setEastNorth(EastNorth eastNorth) {
    79         setCoor(Main.getProjection().eastNorth2latlon(eastNorth));
     79        setCoor(ProjectionRegistry.getProjection().eastNorth2latlon(eastNorth));
    8080    }
    8181
  • trunk/src/org/openstreetmap/josm/data/osm/search/SearchCompiler.java

    r14098 r14120  
    2323import java.util.stream.Collectors;
    2424
    25 import org.openstreetmap.josm.Main;
    2625import org.openstreetmap.josm.data.Bounds;
    2726import org.openstreetmap.josm.data.coor.LatLon;
     
    3635import org.openstreetmap.josm.data.osm.search.PushbackTokenizer.Range;
    3736import org.openstreetmap.josm.data.osm.search.PushbackTokenizer.Token;
     37import org.openstreetmap.josm.data.projection.ProjectionRegistry;
    3838import org.openstreetmap.josm.gui.mappaint.Environment;
    3939import org.openstreetmap.josm.gui.mappaint.mapcss.Selector;
     
    18951895        protected Collection<Bounds> getBounds(OsmPrimitive primitive) {
    18961896            final Collection<Bounds> bounds = super.getBounds(primitive);
    1897             return bounds == null || bounds.isEmpty() ? Collections.singleton(Main.getProjection().getWorldBoundsLatLon()) : bounds;
     1897            return bounds == null || bounds.isEmpty() ?
     1898                    Collections.singleton(ProjectionRegistry.getProjection().getWorldBoundsLatLon()) : bounds;
    18981899        }
    18991900
  • trunk/src/org/openstreetmap/josm/data/osm/visitor/BoundingXYVisitor.java

    r13906 r14120  
    44import java.util.Collection;
    55
    6 import org.openstreetmap.josm.Main;
    76import org.openstreetmap.josm.data.Bounds;
    87import org.openstreetmap.josm.data.ProjectionBounds;
     
    1918import org.openstreetmap.josm.data.osm.Relation;
    2019import org.openstreetmap.josm.data.osm.Way;
     20import org.openstreetmap.josm.data.projection.ProjectionRegistry;
    2121import org.openstreetmap.josm.gui.MainApplication;
    2222import org.openstreetmap.josm.gui.MapFrame;
     
    7676    public void visit(Bounds b) {
    7777        if (b != null) {
    78             Main.getProjection().visitOutline(b, this::visit);
     78            ProjectionRegistry.getProjection().visitOutline(b, this::visit);
    7979        }
    8080    }
     
    9898    public void visit(ILatLon latlon) {
    9999        if (latlon != null) {
    100             visit(latlon.getEastNorth(Main.getProjection()));
     100            visit(latlon.getEastNorth(ProjectionRegistry.getProjection()));
    101101        }
    102102    }
     
    159159        if (bounds == null)
    160160            return;
    161         LatLon minLatlon = Main.getProjection().eastNorth2latlon(bounds.getMin());
    162         LatLon maxLatlon = Main.getProjection().eastNorth2latlon(bounds.getMax());
     161        LatLon minLatlon = ProjectionRegistry.getProjection().eastNorth2latlon(bounds.getMin());
     162        LatLon maxLatlon = ProjectionRegistry.getProjection().eastNorth2latlon(bounds.getMax());
    163163        bounds = new ProjectionBounds(new LatLon(
    164164                        Math.max(-90, minLatlon.lat() - enlargeDegree),
    165                         Math.max(-180, minLatlon.lon() - enlargeDegree)).getEastNorth(Main.getProjection()),
     165                        Math.max(-180, minLatlon.lon() - enlargeDegree)).getEastNorth(ProjectionRegistry.getProjection()),
    166166                new LatLon(
    167167                        Math.min(90, maxLatlon.lat() + enlargeDegree),
    168                         Math.min(180, maxLatlon.lon() + enlargeDegree)).getEastNorth(Main.getProjection()));
     168                        Math.min(180, maxLatlon.lon() + enlargeDegree)).getEastNorth(ProjectionRegistry.getProjection()));
    169169    }
    170170
  • trunk/src/org/openstreetmap/josm/data/osm/visitor/paint/relations/MultipolygonCache.java

    r14000 r14120  
    99import java.util.concurrent.ConcurrentHashMap;
    1010
    11 import org.openstreetmap.josm.Main;
    1211import org.openstreetmap.josm.data.osm.DataSelectionListener;
    1312import org.openstreetmap.josm.data.osm.DataSet;
     
    2928import org.openstreetmap.josm.data.projection.Projection;
    3029import org.openstreetmap.josm.data.projection.ProjectionChangeListener;
     30import org.openstreetmap.josm.data.projection.ProjectionRegistry;
    3131import org.openstreetmap.josm.gui.MainApplication;
    3232import org.openstreetmap.josm.gui.layer.LayerManager.LayerAddEvent;
     
    4949
    5050    private MultipolygonCache() {
    51         Main.addProjectionChangeListener(this);
     51        ProjectionRegistry.addProjectionChangeListener(this);
    5252        SelectionEventManager.getInstance().addSelectionListener(this);
    5353        MainApplication.getLayerManager().addLayerChangeListener(this);
  • trunk/src/org/openstreetmap/josm/data/validation/OsmValidator.java

    r13672 r14120  
    3131import org.openstreetmap.josm.Main;
    3232import org.openstreetmap.josm.data.preferences.sources.ValidatorPrefHelper;
     33import org.openstreetmap.josm.data.projection.ProjectionRegistry;
    3334import org.openstreetmap.josm.data.validation.tests.Addresses;
    3435import org.openstreetmap.josm.data.validation.tests.ApiCapabilitiesTest;
     
    352353     */
    353354    public static void initializeGridDetail() {
    354         String code = Main.getProjection().toCode();
     355        String code = ProjectionRegistry.getProjection().toCode();
    355356        if (Arrays.asList(ProjectionPreference.wgs84.allCodes()).contains(code)) {
    356357            OsmValidator.griddetail = 10_000;
Note: See TracChangeset for help on using the changeset viewer.