camptocamp/cgxp — pull request #83 by asaunier (2012-04-27 16:11:08+00:00)
Title: Computation of resolution hint was incorrect

We use resolutionHint (generally best known as scaleHint) to check if a layer is visible at current resolution and to zoom to the "next visible scale".

To do so we used to compare minResolutionHint and maxResolutionHint (available as min/max values of layer's ScaleHint in WMS GetCapabilities response). This comparison was incorrect.

Mapserver computes max scaleHint as:
```scalehintmax = diag*(maxscaledenom/resolution)/msInchesPerUnit(MS_METERS,0);```
with
```diag = sqrt(2.0);```

On the other hand *OpenLayers.Utils.getResolutionFromScale()* returns:
```resolution = 1 / (normScale * OpenLayers.INCHES_PER_UNIT[units] * OpenLayers.DOTS_PER_INCH);```

There is a sqrt(2.0) ratio between those two values. That's because the scaleHint is based on the diagonal length of a pixel which is sqrt(2.0) longer than its side. See for instance : http://wiki.deegree.org/deegreeWiki/HowToUseScaleHintAndScaleDenominator#What_is_the_ScaleHint.3F

This pull request simply reintroduces the missing sqrt(2.0) ratio in scaleHint/resolution comparisons.