[josm-dev] WMTS scales - proper definition of 1m along meridian

Paul Hartmann phaaurlt at gmail.com
Thu Jul 2 21:12:42 UTC 2015


On 02.07.2015 21:47, Wiktor Niesiobedzki wrote:
> Currently I'm working on WMTS support. As some of you may know (and
> those who do not, I refer to
> http://www.opengeospatial.org/standards/wmts) uses notion of
> scaleDenominator that's crucial to tile positioning. More less -
> scaleDenominator tell how many meters are on the tile per pixel.
> I tried several of algorithms to get the number of meters along
> meridian for current JOSM projection,

This value is not constant along a meridian, but depends on the latitude 
(and sometimes longitude). Also, the value in east direction can be 
different from the value in north direction (e.g. in WGS84).

> the best I could find is:
>
>              Projection proj = Main.getProjection();
>              EastNorth p1 = new EastNorth(0, 0);
>              EastNorth p2 = new EastNorth(0, 1);
>              double metersPerDegree =
> proj.eastNorth2latlon(p1).greatCircleDistance(p2);

What you get here is not metersPerDegree, but metersPerNorthing. As far 
as I know, this is the only way to find that number (but you have to 
plug in the actual location). I've implemented this for the Piclayer plugin:
<https://trac.openstreetmap.org/browser/subversion/applications/editors/josm/plugins/piclayer/src/org/openstreetmap/josm/plugins/piclayer/layer/PicLayerAbstract.java#L304>
Anyhow, I'm pretty sure you don't need this for a WMTS implementation.

The scale, as used by NavigatableComponent, translates screen pixels to 
East/North units. ImageryLayer.getPPD() and 
Projection.getDefaultZoomInPPD() are the same. The WMTS scaleDenominator 
seems to be similar.

> But still this doesn't give satisfactory results. From my manual
> trials, I guessed following "correct" values, depending on the
> projection used:
> EPSG:3857 (Mercator) - 1

For Mercator, the value would be cos(latitude).

> Looking through the OpenLayers code I see, that they define 4 values
> got getMetersPerUnit():
> - degrees (111194.87428468118)
> - feet (0.3048)
> - meters (1)
> - us feet (.3048006096)
>
> Do I understand correctly, that for base projections:
> - org.openstreetmap.josm.data.projection.proj.LonLat - I should use degrees
> - org.openstreetmap.josm.data.projection.proj.Mercator - I should use meters
> - org.openstreetmap.josm.data.projection.proj.TransverseMercator - I
> should use meters

There is no reason to switch to other units as this is only an internal 
number and not exposed to the user. The unit is arbitrary, so you can 
just stick to meters.

Best, Paul




More information about the josm-dev mailing list