Ignore:
Timestamp:
2014-01-31T14:33:28+01:00 (11 years ago)
Author:
glebius
Message:

o Provide own LatToY() and YToLat() for Scanex tile source.

This fixes #7017.

o Drop own implementation of lonToTileX() and tileXToLon().

We inherit 'em from AbstractTMSTileSource.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • applications/viewer/jmapviewer/src/org/openstreetmap/gui/jmapviewer/tilesources/ScanexTileSource.java

    r30247 r30249  
    55
    66import org.openstreetmap.gui.jmapviewer.OsmMercator;
     7
     8/*
     9 * This tilesource uses different to OsmMercator projection.
     10 *
     11 * Earth is assumed an ellipsoid in this projection, unlike
     12 * sphere in OsmMercator, so latitude calculation differs
     13 * a lot.
     14 *
     15 * The longitude calculation is the same as in OsmMercator,
     16 * we inherit it from AbstractTMSTileSource.
     17 *
     18 * TODO: correct getDistance() method.
     19 */
    720
    821public class ScanexTileSource extends TMSTileSource {
     
    6982    }
    7083
     84
     85    /*
     86     * Latitude to Y and back calculations.
     87     */
    7188    private static double RADIUS_E = 6378137;   /* radius of Earth at equator, m */
    7289    private static double EQUATOR = 40075016.68557849; /* equator length, m */
    7390    private static double E = 0.0818191908426;  /* eccentricity of Earth's ellipsoid */
     91
     92    @Override
     93    public int LatToY(double lat, int zoom) {
     94        return (int )(latToTileY(lat, zoom) * OsmMercator.TILE_SIZE);
     95    }
     96 
     97    @Override
     98    public double YToLat(int y, int zoom) {
     99        return tileYToLat((double )y / OsmMercator.TILE_SIZE, zoom);
     100    }
    74101
    75102    @Override
     
    82109
    83110    @Override
    84     public double lonToTileX(double lon, int zoom) {
    85         return (RADIUS_E * lon * Math.PI / (90*EQUATOR) + 1) * Math.pow(2.0, zoom - 1);
     111    public double tileYToLat(int y, int zoom) {
     112        return tileYToLat((double )y, zoom);
    86113    }
    87114
     
    94121     */
    95122    private double cached_lat = 0;
    96 
    97     @Override
    98     public double tileYToLat(int y, int zoom) {
     123    private double tileYToLat(double y, int zoom) {
    99124        double lat0, lat;
    100125
     
    131156        return (f/df);
    132157    }
    133 
    134     @Override
    135     public double tileXToLon(int x, int zoom) {
    136         return (x / Math.pow(2.0, zoom - 1) - 1) * (90*EQUATOR) / RADIUS_E / Math.PI;
    137     }
    138158}
Note: See TracChangeset for help on using the changeset viewer.