getPointResolution returns proj units

This commit is contained in:
ahocevar
2019-02-07 12:25:37 +01:00
parent b3bc78daec
commit fecb8de769
2 changed files with 7 additions and 1 deletions

View File

@@ -188,6 +188,12 @@ export function getPointResolution(projection, resolution, point, opt_units) {
const getter = projection.getPointResolutionFunc(); const getter = projection.getPointResolutionFunc();
if (getter) { if (getter) {
pointResolution = getter(resolution, point); pointResolution = getter(resolution, point);
if (opt_units && opt_units !== projection.getUnits()) {
const metersPerUnit = projection.getMetersPerUnit();
if (metersPerUnit) {
pointResolution = pointResolution * metersPerUnit / METERS_PER_UNIT[opt_units];
}
}
} else { } else {
const units = projection.getUnits(); const units = projection.getUnits();
if (units == Units.DEGREES && !opt_units || opt_units == Units.DEGREES) { if (units == Units.DEGREES && !opt_units || opt_units == Units.DEGREES) {

View File

@@ -19,7 +19,7 @@ import {METERS_PER_UNIT} from './Units.js';
* @property {function(number, import("../coordinate.js").Coordinate):number} [getPointResolution] * @property {function(number, import("../coordinate.js").Coordinate):number} [getPointResolution]
* Function to determine resolution at a point. The function is called with a * Function to determine resolution at a point. The function is called with a
* `{number}` view resolution and an `{import("../coordinate.js").Coordinate}` as arguments, and returns * `{number}` view resolution and an `{import("../coordinate.js").Coordinate}` as arguments, and returns
* the `{number}` resolution at the passed coordinate. If this is `undefined`, * the `{number}` resolution in projection units at the passed coordinate. If this is `undefined`,
* the default {@link module:ol/proj#getPointResolution} function will be used. * the default {@link module:ol/proj#getPointResolution} function will be used.
*/ */