Changeset 9628 in josm for trunk/src


Ignore:
Timestamp:
2016-01-25T12:36:19+01:00 (9 years ago)
Author:
bastiK
Message:

fix WMTS with EPSG:4326 broken in [9608] (see #12186)

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

Legend:

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

    r9608 r9628  
    5555    protected String cacheDir;
    5656    protected Bounds bounds;
    57     private double metersPerUnit = 1;
     57    private double metersPerUnit;
     58    private double metersPerUnitNoDegrees;
    5859    private String axis = "enu"; // default axis orientation is East, North, Up
    5960
     
    286287                this.code = s;
    287288            }
     289            boolean defaultUnits = true;
    288290            s = parameters.get(Param.units.key);
    289291            if (s != null) {
     
    291293                if (UNITS_TO_METERS.containsKey(s)) {
    292294                    this.metersPerUnit = UNITS_TO_METERS.get(s);
     295                    this.metersPerUnitNoDegrees = this.metersPerUnit;
     296                    defaultUnits = false;
    293297                } else {
    294298                    Main.warn("No metersPerUnit found for: " + s);
     
    298302            if (s != null) {
    299303                this.metersPerUnit = parseDouble(s, Param.to_meter.key);
     304                this.metersPerUnitNoDegrees = this.metersPerUnit;
     305                defaultUnits = false;
     306            }
     307            if (defaultUnits) {
     308                this.metersPerUnit = proj.isGeographic() ? METER_PER_UNIT_DEGREE : 1;
     309                this.metersPerUnitNoDegrees = 1;
    300310            }
    301311            s = parameters.get(Param.axis.key);
     
    700710        return metersPerUnit;
    701711    }
     712   
     713    /**
     714     * Like {@link #getMetersPerUnit()}, but has default value 1 for a
     715     * geographic CRS. I.e. by default, degrees are not converted to meters,
     716     * but left alone (similar to proj.4 behavior).
     717     * @return
     718     */
     719    public double getMetersPerUnitProj() {
     720        return metersPerUnitNoDegrees;
     721    }
    702722
    703723    @Override
  • trunk/src/org/openstreetmap/josm/data/projection/Projection.java

    r9419 r9628  
    9696     * Get the number of meters per unit of this projection. This more
    9797     * defines the scale of the map, than real conversion of unit to meters
    98      * as this value is more less correct only along great circles.
     98     * as this value is more less correct only along certain lines of true scale.
    9999     *
    100100     * Used by WMTS to properly scale tiles
    101101     * @return meters per unit of projection
    102      *
    103102     */
    104103    double getMetersPerUnit();
  • trunk/src/org/openstreetmap/josm/data/projection/proj/AbstractProj.java

    r9573 r9628  
    9999    }
    100100
     101    @Override
     102    public boolean isGeographic() {
     103        return false;
     104    }
     105
    101106    /**
    102107     * Calculates the meridian distance. This is the distance along the central
  • trunk/src/org/openstreetmap/josm/data/projection/proj/DoubleStereographic.java

    r9124 r9628  
    2929 * Sec. 1.3.7.1 Oblique and Equatorial Stereographic, http://www.epsg.org/GuidanceNotes
    3030 */
    31 public class DoubleStereographic implements Proj {
     31public class DoubleStereographic extends AbstractProj {
    3232
    3333    private Ellipsoid ellps;
    34     private double e;
    3534    private double n;
    3635    private double c;
     
    5251    @Override
    5352    public void initialize(ProjParameters params) throws ProjectionConfigurationException {
     53        super.initialize(params);
    5454        if (params.lat0 == null)
    5555            throw new ProjectionConfigurationException(tr("Parameter ''{0}'' required.", "lat_0"));
    5656        ellps = params.ellps;
    57         e = ellps.e;
    5857        initialize(params.lat0);
    5958    }
  • trunk/src/org/openstreetmap/josm/data/projection/proj/LonLat.java

    r9124 r9628  
    4343        return new Bounds(-90, -180, 90, 180, false);
    4444    }
     45
     46    @Override
     47    public boolean isGeographic() {
     48        return true;
     49    }
    4550}
  • trunk/src/org/openstreetmap/josm/data/projection/proj/Proj.java

    r9132 r9628  
    8282     */
    8383    Bounds getAlgorithmBounds();
     84
     85    /**
     86     * Return true, if a geographic coordinate reference system is represented.
     87     *
     88     * I.e. if it returns latitude/longitude values rather than Cartesian
     89     * east/north coordinates on a flat surface.
     90     * @return true, if it is geographic
     91     */
     92    boolean isGeographic();
    8493}
  • trunk/src/org/openstreetmap/josm/data/projection/proj/SwissObliqueMercator.java

    r9579 r9628  
    3434 * this formula (rigorous formulas)</a>.
    3535 */
    36 public class SwissObliqueMercator implements Proj {
     36public class SwissObliqueMercator extends AbstractProj {
    3737
    3838    // CHECKSTYLE.ON: LineLength
     
    4949    @Override
    5050    public void initialize(ProjParameters params) throws ProjectionConfigurationException {
     51        super.initialize(params);
    5152        if (params.lat0 == null)
    5253            throw new ProjectionConfigurationException(tr("Parameter ''{0}'' required.", "lat_0"));
Note: See TracChangeset for help on using the changeset viewer.