I am working on a personal web gis client and the first thing I am implementing is support for OGC WMS 1.3.0.
Right now, I am in the middle of greying out layers in my layer tree which are not visible at the current view scale.
From the official documentation I read:
The and elements define the range of scales for which it is appropriate to generate a map of a Layer. Because maps from a WMS may be viewed on arbitrary displays rather than on paper, the values used are actually the scale denominators relative to a common display pixel size. (...) For the purposes of this International Standard, the common pixel size is defined to be 0,28 mm × 0,28 mm. Because arbitrary clients can request maps from a server, the true pixel size of the final rendering device is unknown to the server.
Probably is either that English is not my first language and that I am very bad with numbers, but I am struggling to figure out the meaning of this sentence.
Take this WMS for example. Some layers have <MaxScaleDenominator> equals to 94494.047619.
First of all, how can I read this number in terms of scale? Does it represent the common 1:94494.047619 scale, or do I have to do some calculations with the standardize 0,28 mm × 0,28 mm pixel size to understand it?
Also, if
the true pixel size of the final rendering device is unknown is there a way to to the server
is there a way to retrieve it client side (if that is indeed required for what I need to do)?
EDIT1
So I already got pretty good results. I have the below code which logs to console the current scale of my view (might be not 100% clean, but it seems to work, I adapted it from here):
import {METERS_PER_UNIT} from 'ol/proj/Units.js';
// return current scale in map units according to DPI
function mapScale(map, dpi) {
var unit = map.getView().getProjection().getUnits();
var resolution = map.getView().getResolution();
var inchesPerMetre = 39.37;
return resolution * METERS_PER_UNIT[unit] * inchesPerMetre * dpi;
}
export function getScale(map) {
map.getView().on('propertychange', function(e) {
switch (e.key) {
case 'resolution':
// log DPI to console
console.log("DPI:" + window.devicePixelRatio);
// log scale in map units to console
console.log("1:" + mapScale(map, window.devicePixelRatio * 96));
break;
}
});
}
Now I can see in the console when I am farther than the aforementioned <MaxScaledenominator> (94494.047619), and indeed, if I turn on the layer it won't show up till I have reach at least this value (actually it turns on at 1:72223 at minimum as I am using OpenStreetMap basemaps and this is one of its fixed scale level).
This seems to confirm that the numbers are meant like "traditional" scales (i.e. 1:94494.047619). Can anybody please confirm and elaborate a bit on this?