Ignore:
Timestamp:
2015-07-04T22:52:23+02:00 (4 years ago)
Author:
wiktorn
Message:

Basic WMTS support.

  • added information about units and to_meter to EPSG projection definitions (needed for WMTS)
  • added WMTSTileSource and WMTSLayer classes
  • a bit of cleanup of AbstractTileSourceLayer and align so it will work properly with WMTS tile definitions
  • added Imagery Preferences panel for WMTS and icon for button
  • added removal of wms: / tms: / wmts: prefix, if user will paste them into the field
  • CachedFile - added possibility to send custom headers with request
  • added support for unit and to_meter in CustomProjection
  • AbstractTMSTileSource cleanups (change of Coordinate to ICoordinate)
  • moved JCSCachedTileLoaderJob.read() to Utils

Addresses: #10623

Tested with Polish WMTS service proivders, Walonnie needs still some debugging, as it is not working right now.

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

Legend:

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

    r8533 r8568  
    88import java.util.List;
    99import java.util.Map;
     10import java.util.concurrent.ConcurrentHashMap;
    1011import java.util.regex.Matcher;
    1112import java.util.regex.Pattern;
     
    3536public class CustomProjection extends AbstractProjection {
    3637
     38    private final static Map<String, Double> UNITS_TO_METERS = getUnitsToMeters();
     39    private final static double METER_PER_UNIT_DEGREE = 2 * Math.PI * 6370997 / 360;
     40
    3741    /**
    3842     * pref String that defines the projection
     
    4549    protected String cacheDir;
    4650    protected Bounds bounds;
     51    private double metersPerUnit = METER_PER_UNIT_DEGREE; // default to degrees
    4752
    4853    /**
     
    8994        wktext("wktext", false),  // ignored
    9095        /** meters, US survey feet, etc. */
    91         units("units", true),     // ignored
     96        units("units", true),
    9297        /** Don't use the /usr/share/proj/proj_def.dat defaults file */
    9398        no_defs("no_defs", false),
    9499        init("init", true),
     100        to_meter("to_meter", true),
    95101        // JOSM extensions, not present in PROJ.4
    96102        wmssrs("wmssrs", true),
     
    103109
    104110        /** Map of all parameters by key */
    105         static final Map<String, Param> paramsByKey = new HashMap<>();
     111        static final Map<String, Param> paramsByKey = new ConcurrentHashMap<>();
    106112        static {
    107113            for (Param p : Param.values()) {
     
    198204            if (s != null) {
    199205                this.code = s;
     206            }
     207            s = parameters.get(Param.units.key);
     208            if (s != null) {
     209                this.metersPerUnit = UNITS_TO_METERS.get(s);
     210            }
     211            s = parameters.get(Param.to_meter.key);
     212            if (s != null) {
     213                this.metersPerUnit = parseDouble(s, Param.to_meter.key);
    200214            }
    201215        }
     
    528542        return name != null ? name : tr("Custom Projection");
    529543    }
     544
     545    @Override
     546    public double getMetersPerUnit() {
     547        return metersPerUnit;
     548    }
     549
     550    private static Map<String, Double> getUnitsToMeters() {
     551        Map<String, Double> ret = new ConcurrentHashMap<>();
     552        ret.put("km", 1000d);
     553        ret.put("m", 1d);
     554        ret.put("dm", 1d/10);
     555        ret.put("cm", 1d/100);
     556        ret.put("mm", 1d/1000);
     557        ret.put("kmi", 1852.0);
     558        ret.put("in", 0.0254);
     559        ret.put("ft", 0.3048);
     560        ret.put("yd", 0.9144);
     561        ret.put("mi", 1609.344);
     562        ret.put("fathom", 1.8288);
     563        ret.put("chain", 20.1168);
     564        ret.put("link", 0.201168);
     565        ret.put("us-in", 1d/39.37);
     566        ret.put("us-ft", 0.304800609601219);
     567        ret.put("us-yd", 0.914401828803658);
     568        ret.put("us-ch", 20.11684023368047);
     569        ret.put("us-mi", 1609.347218694437);
     570        ret.put("ind-yd", 0.91439523);
     571        ret.put("ind-ft", 0.30479841);
     572        ret.put("ind-ch", 20.11669506);
     573        ret.put("degree", METER_PER_UNIT_DEGREE);
     574        return ret;
     575    }
    530576}
  • trunk/src/org/openstreetmap/josm/data/projection/Projection.java

    r6069 r8568  
    6868     */
    6969    Bounds getWorldBoundsLatLon();
     70
     71    /**
     72     * Get the number of meters per unit of this projection. This more
     73     * defines the scale of the map, than real conversion of unit to meters
     74     * as this value is more less correct only along great circles.
     75     *
     76     * Used by WMTS to properly scale tiles
     77     * @return meters per unit of projection
     78     *
     79     */
     80    double getMetersPerUnit();
    7081}
  • trunk/src/org/openstreetmap/josm/data/projection/proj/Proj.java

    r7509 r8568  
    6464     */
    6565    double[] invproject(double east, double north);
    66 
    6766}
Note: See TracChangeset for help on using the changeset viewer.