Changeset 9124 in josm


Ignore:
Timestamp:
2015-12-14T23:18:24+01:00 (4 years ago)
Author:
bastiK
Message:

guess resonable projection bounds, when they haven't been specified (see #12186)

Location:
trunk/src/org/openstreetmap/josm/data/projection
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/data/projection/CustomProjection.java

    r9106 r9124  
    588588    public Bounds getWorldBoundsLatLon() {
    589589        if (bounds != null) return bounds;
    590         return new Bounds(
    591             new LatLon(-90.0, -180.0),
    592             new LatLon(90.0, 180.0));
     590        Bounds ab = proj.getAlgorithmBounds();
     591        if (ab != null) {
     592            double minlon = Math.max(ab.getMinLon() + lon0 + pm, -180);
     593            double maxlon = Math.min(ab.getMaxLon() + lon0 + pm, 180);
     594            return new Bounds(ab.getMinLat(), minlon, ab.getMaxLat(), maxlon, false);
     595        } else {
     596            return new Bounds(
     597                new LatLon(-90.0, -180.0),
     598                new LatLon(90.0, 180.0));
     599        }
    593600    }
    594601
  • trunk/src/org/openstreetmap/josm/data/projection/proj/DoubleStereographic.java

    r9108 r9124  
    1616import static org.openstreetmap.josm.tools.I18n.tr;
    1717
     18import org.openstreetmap.josm.data.Bounds;
    1819import org.openstreetmap.josm.data.projection.Ellipsoid;
    1920import org.openstreetmap.josm.data.projection.ProjectionConfigurationException;
     
    2829 * Sec. 1.3.7.1 Oblique and Equatorial Stereographic, http://www.epsg.org/GuidanceNotes
    2930 */
    30 
    3131public class DoubleStereographic implements Proj {
    3232
     
    109109        return new double[] {phi, lambda};
    110110    }
     111
     112    @Override
     113    public Bounds getAlgorithmBounds() {
     114        return new Bounds(-89, -87, 89, 87, false);
     115    }
    111116}
  • trunk/src/org/openstreetmap/josm/data/projection/proj/LambertConformalConic.java

    r9116 r9124  
    1515import static org.openstreetmap.josm.tools.I18n.tr;
    1616
     17import org.openstreetmap.josm.data.Bounds;
    1718import org.openstreetmap.josm.data.projection.CustomProjection.Param;
    1819import org.openstreetmap.josm.data.projection.Ellipsoid;
     
    177178        return params;
    178179    }
     180
     181    @Override
     182    public Bounds getAlgorithmBounds() {
     183        double lat;
     184        if (params instanceof Parameters2SP) {
     185            Parameters2SP p2p = (Parameters2SP) params;
     186            lat = (p2p.standardParallel1 + p2p.standardParallel2) / 2;
     187        } else {
     188            lat = params.latitudeOrigin;
     189        }
     190        double minlat = Math.max(lat - 60, -89);
     191        double maxlat = Math.min(lat + 60, 89);
     192        return new Bounds(minlat, -85, maxlat, 85, false);
     193    }
    179194}
  • trunk/src/org/openstreetmap/josm/data/projection/proj/LonLat.java

    r8444 r9124  
    44import static org.openstreetmap.josm.tools.I18n.tr;
    55
     6import org.openstreetmap.josm.data.Bounds;
    67import org.openstreetmap.josm.data.projection.ProjectionConfigurationException;
    78
     
    3738        return new double[] {Math.toRadians(north * a), Math.toRadians(east * a)};
    3839    }
     40
     41    @Override
     42    public Bounds getAlgorithmBounds() {
     43        return new Bounds(-90, -180, 90, 180, false);
     44    }
    3945}
  • trunk/src/org/openstreetmap/josm/data/projection/proj/Mercator.java

    r8444 r9124  
    99import static org.openstreetmap.josm.tools.I18n.tr;
    1010
     11import org.openstreetmap.josm.data.Bounds;
    1112import org.openstreetmap.josm.data.projection.ProjectionConfigurationException;
    1213
     
    3940        return new double[] {atan(sinh(north)), east};
    4041    }
     42
     43    @Override
     44    public Bounds getAlgorithmBounds() {
     45        return new Bounds(-89, -180, 89, 180, false);
     46    }
    4147}
  • trunk/src/org/openstreetmap/josm/data/projection/proj/Proj.java

    r8568 r9124  
    22package org.openstreetmap.josm.data.projection.proj;
    33
     4import org.openstreetmap.josm.data.Bounds;
    45import org.openstreetmap.josm.data.projection.ProjectionConfigurationException;
    56
     
    6465     */
    6566    double[] invproject(double east, double north);
     67
     68    /**
     69     * Return the bounds where this projection is applicable.
     70     *
     71     * This is a fallback for when the projection bounds are not specified
     72     * explicitly.
     73     *
     74     * In this area, the round trip lat/lon -> east/north -> lat/lon should
     75     * return the starting value with small error. In addition, regions with
     76     * extreme distortions should be excluded, if possible.
     77     *
     78     * It need not be the absolute maximum, but rather an area that is safe to
     79     * display in JOSM and contain everything that one would expect to use.
     80     *
     81     * @return the bounds where this projection is applicable, null if unknown
     82     */
     83    Bounds getAlgorithmBounds();
    6684}
  • trunk/src/org/openstreetmap/josm/data/projection/proj/SwissObliqueMercator.java

    r8540 r9124  
    1717import static org.openstreetmap.josm.tools.I18n.tr;
    1818
     19import org.openstreetmap.josm.data.Bounds;
    1920import org.openstreetmap.josm.data.projection.Ellipsoid;
    2021import org.openstreetmap.josm.data.projection.ProjectionConfigurationException;
     
    7576    @Override
    7677    public double[] project(double phi, double lambda) {
    77 
    7878        double S = alpha * log(tan(PI / 4 + phi / 2)) - alpha * ellps.e / 2
    7979            * log((1 + ellps.e * sin(phi)) / (1 - ellps.e * sin(phi))) + k;
     
    115115        return new double[] {phi, lambda};
    116116    }
     117
     118    @Override
     119    public Bounds getAlgorithmBounds() {
     120        return new Bounds(-85, -179, 85, 179, false);
     121    }
    117122}
  • trunk/src/org/openstreetmap/josm/data/projection/proj/TransverseMercator.java

    r9117 r9124  
    44import static org.openstreetmap.josm.tools.I18n.tr;
    55
     6import org.openstreetmap.josm.data.Bounds;
    67import org.openstreetmap.josm.data.projection.ProjectionConfigurationException;
    78
     
    181182        return new double[] {y, x};
    182183    }
     184
     185    @Override
     186    public Bounds getAlgorithmBounds() {
     187        return new Bounds(-90, -10, 90, 10, false);
     188    }
    183189}
Note: See TracChangeset for help on using the changeset viewer.