View / refactor how zoom and resolution are computed

This commit aims to simplify the computation of zoom and resolution in the
View class.

Previously zoom levels and resolution computations were mixed in different places,
ie resolution constraints, initial values, etc.

Now the View class only has the `getZoomForResolution` and `getResolutionForZoom`
methods to convert from one system to another.

Other than that, most computations use the resolution system internally.

The `constrainResolution` method also does not exist anymore, and is replaced
by `getValidResolution` and `getValidZoomLevel` public methods.
This commit is contained in:
Olivier Guyot
2019-01-14 16:34:29 +01:00
parent 1f379a06a4
commit 1c5fd62e43
5 changed files with 252 additions and 217 deletions

View File

@@ -103,7 +103,7 @@ describe('ol.interaction.DragZoom', function() {
setTimeout(function() {
const view = map.getView();
const resolution = view.getResolution();
expect(resolution).to.eql(view.constrainResolution(0.5));
expect(resolution).to.eql(view.getValidResolution(0.5));
done();
}, 50);
}, 50);