Ignore:
Timestamp:
2016-08-15T14:45:38+02:00 (8 years ago)
Author:
Don-vip
Message:

fix #13287 - Projection updates to support multiple projections (patch by michael2402) - gsoc-core

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/gui/MapViewState.java

    r10651 r10805  
    1717import org.openstreetmap.josm.data.coor.EastNorth;
    1818import org.openstreetmap.josm.data.coor.LatLon;
     19import org.openstreetmap.josm.data.projection.Projecting;
    1920import org.openstreetmap.josm.data.projection.Projection;
    2021import org.openstreetmap.josm.gui.download.DownloadDialog;
     
    2829public final class MapViewState {
    2930
    30     private final Projection projection;
     31    private final Projecting projecting;
    3132
    3233    private final int viewWidth;
     
    5152     * @param topLeft The top left corner in east/north space.
    5253     */
    53     private MapViewState(Projection projection, int viewWidth, int viewHeight, double scale, EastNorth topLeft) {
    54         this.projection = projection;
     54    private MapViewState(Projecting projection, int viewWidth, int viewHeight, double scale, EastNorth topLeft) {
     55        this.projecting = projection;
    5556        this.scale = scale;
    5657        this.topLeft = topLeft;
     
    6364
    6465    private MapViewState(EastNorth topLeft, MapViewState mapViewState) {
    65         this.projection = mapViewState.projection;
     66        this.projecting = mapViewState.projecting;
    6667        this.scale = mapViewState.scale;
    6768        this.topLeft = topLeft;
     
    7475
    7576    private MapViewState(double scale, MapViewState mapViewState) {
    76         this.projection = mapViewState.projection;
     77        this.projecting = mapViewState.projecting;
    7778        this.scale = scale;
    7879        this.topLeft = mapViewState.topLeft;
     
    8586
    8687    private MapViewState(JComponent position, MapViewState mapViewState) {
    87         this.projection = mapViewState.projection;
     88        this.projecting = mapViewState.projecting;
    8889        this.scale = mapViewState.scale;
    8990        this.topLeft = mapViewState.topLeft;
     
    106107    }
    107108
    108     private MapViewState(Projection projection, MapViewState mapViewState) {
    109         this.projection = projection;
     109    private MapViewState(Projecting projecting, MapViewState mapViewState) {
     110        this.projecting = projecting;
    110111        this.scale = mapViewState.scale;
    111112        this.topLeft = mapViewState.topLeft;
     
    201202     */
    202203    public Projection getProjection() {
    203         return projection;
     204        return projecting.getBaseProjection();
    204205    }
    205206
     
    269270     */
    270271    public MapViewState usingProjection(Projection projection) {
    271         if (projection.equals(this.projection)) {
     272        if (projection.equals(this.projecting)) {
    272273            return this;
    273274        } else {
     
    358359         * Gets the current position in LatLon coordinates according to the current projection.
    359360         * @return The positon as LatLon.
     361         * @see #getLatLonClamped()
    360362         */
    361363        public LatLon getLatLon() {
    362             return projection.eastNorth2latlon(getEastNorth());
     364            return projecting.getBaseProjection().eastNorth2latlon(getEastNorth());
     365        }
     366
     367        /**
     368         * Gets the latlon coordinate clamped to the current world area.
     369         * @return The lat/lon coordinate
     370         * @since 10805
     371         */
     372        public LatLon getLatLonClamped() {
     373            return projecting.eastNorth2latlonClamped(getEastNorth());
    363374        }
    364375
     
    474485         */
    475486        public Bounds getLatLonBoundsBox() {
    476             return projection.getLatLonBoundsBox(getProjectionBounds());
     487            // TODO @michael2402: Use hillclimb.
     488            return projecting.getBaseProjection().getLatLonBoundsBox(getProjectionBounds());
    477489        }
    478490
Note: See TracChangeset for help on using the changeset viewer.