Skip to content

Commit

Permalink
Merge pull request #6204 from tschaub/proj
Browse files Browse the repository at this point in the history
Refactored proj modules
  • Loading branch information
tschaub committed Dec 6, 2016
2 parents db5032a + 6259caf commit fc8915d
Show file tree
Hide file tree
Showing 18 changed files with 601 additions and 509 deletions.
16 changes: 16 additions & 0 deletions changelog/upgrade-notes.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,22 @@ view.animate({
});
```

#### Use `ol.proj.getPointResolution()` instead of `projection.getPointResolution()`

The experimental `getPointResolution` method has been removed from `ol.Projection` instances. Since the implementation of this method required an inverse transform (function for transforming projected coordinates to geographic coordinates) and `ol.Projection` instances are not constructed with forward or inverse transforms, it does not make sense that a projection instance can always calculate the point resolution.

As a substitute for the `projection.getPointResolution()` function, a `ol.proj.getPointResolution()` function has been added. To upgrade, you will need to change things like this:
```js
projection.getPointResolution(resolution, point);
```

into this:
```js
ol.proj.getPointResolution(projection, resolution, point);
```

Note that if you were previously creating a projection with a `getPointResolution` function in the constructor (or calling `projection.setGetPointResolution()` after construction), this function will be used by `ol.proj.getPointResolution()`.

### v3.19.1

#### `ol.style.Fill` with `CanvasGradient` or `CanvasPattern`
Expand Down
4 changes: 2 additions & 2 deletions src/ol/control/scaleline.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ goog.require('ol.asserts');
goog.require('ol.control.Control');
goog.require('ol.css');
goog.require('ol.events');
goog.require('ol.proj.METERS_PER_UNIT');
goog.require('ol.proj');
goog.require('ol.proj.Units');


Expand Down Expand Up @@ -169,7 +169,7 @@ ol.control.ScaleLine.prototype.updateElement_ = function() {
var projection = viewState.projection;
var metersPerUnit = projection.getMetersPerUnit();
var pointResolution =
projection.getPointResolution(viewState.resolution, center) *
ol.proj.getPointResolution(projection, viewState.resolution, center) *
metersPerUnit;

var nominalCount = this.minWidth_ * pointResolution;
Expand Down
13 changes: 4 additions & 9 deletions src/ol/proj/epsg3857.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,20 +22,15 @@ ol.proj.EPSG3857_ = function(code) {
units: ol.proj.Units.METERS,
extent: ol.proj.EPSG3857.EXTENT,
global: true,
worldExtent: ol.proj.EPSG3857.WORLD_EXTENT
worldExtent: ol.proj.EPSG3857.WORLD_EXTENT,
getPointResolution: function(resolution, point) {
return resolution / ol.math.cosh(point[1] / ol.proj.EPSG3857.RADIUS);
}
});
};
ol.inherits(ol.proj.EPSG3857_, ol.proj.Projection);


/**
* @inheritDoc
*/
ol.proj.EPSG3857_.prototype.getPointResolution = function(resolution, point) {
return resolution / ol.math.cosh(point[1] / ol.proj.EPSG3857.RADIUS);
};


/**
* @const
* @type {number}
Expand Down
8 changes: 0 additions & 8 deletions src/ol/proj/epsg4326.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,6 @@ ol.proj.EPSG4326_ = function(code, opt_axisOrientation) {
ol.inherits(ol.proj.EPSG4326_, ol.proj.Projection);


/**
* @inheritDoc
*/
ol.proj.EPSG4326_.prototype.getPointResolution = function(resolution, point) {
return resolution;
};


/**
* Extent of the EPSG:4326 projection which is the whole world.
*
Expand Down
Loading

0 comments on commit fc8915d

Please sign in to comment.