Update to ol.proj
Add support for custom getPointResolution and setting the 'global' boolean
This commit is contained in:
+9
-1
@@ -415,7 +415,8 @@ olx.OverlayOptions.prototype.autoPanMargin;
|
|||||||
* extent: (ol.Extent|undefined),
|
* extent: (ol.Extent|undefined),
|
||||||
* axisOrientation: (string|undefined),
|
* axisOrientation: (string|undefined),
|
||||||
* global: (boolean|undefined),
|
* global: (boolean|undefined),
|
||||||
* worldExtent: (ol.Extent|undefined)}}
|
* worldExtent: (ol.Extent|undefined),
|
||||||
|
* getPointResolution: (function(number, ol.Coordinate):number|undefined) }}
|
||||||
* @api
|
* @api
|
||||||
*/
|
*/
|
||||||
olx.ProjectionOptions;
|
olx.ProjectionOptions;
|
||||||
@@ -468,6 +469,13 @@ olx.ProjectionOptions.prototype.global;
|
|||||||
*/
|
*/
|
||||||
olx.ProjectionOptions.prototype.worldExtent;
|
olx.ProjectionOptions.prototype.worldExtent;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Function to determine resolution at a point.
|
||||||
|
* @type {(function(number, ol.Coordinate):number|undefined)}
|
||||||
|
* @api
|
||||||
|
*/
|
||||||
|
olx.ProjectionOptions.prototype.getPointResolution;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Object literal with config options for the view.
|
* Object literal with config options for the view.
|
||||||
|
|||||||
+60
-10
@@ -121,6 +121,13 @@ ol.proj.Projection = function(options) {
|
|||||||
*/
|
*/
|
||||||
this.global_ = goog.isDef(options.global) ? options.global : false;
|
this.global_ = goog.isDef(options.global) ? options.global : false;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @private
|
||||||
|
* @type {function(number, ol.Coordinate):number}
|
||||||
|
*/
|
||||||
|
this.getPointResolutionFunc_ = goog.isDef(options.getPointResolution) ?
|
||||||
|
options.getPointResolution : this.getPointResolution_;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @private
|
* @private
|
||||||
* @type {ol.tilegrid.TileGrid}
|
* @type {ol.tilegrid.TileGrid}
|
||||||
@@ -206,6 +213,16 @@ ol.proj.Projection.prototype.isGlobal = function() {
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set if the projection is a global projection which spans the whole world
|
||||||
|
* @param {boolean} global Whether the projection is global.
|
||||||
|
* @api stable
|
||||||
|
*/
|
||||||
|
ol.proj.Projection.prototype.setGlobal = function(global) {
|
||||||
|
this.global_ = global;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return {ol.tilegrid.TileGrid} The default tile grid.
|
* @return {ol.tilegrid.TileGrid} The default tile grid.
|
||||||
*/
|
*/
|
||||||
@@ -244,16 +261,29 @@ ol.proj.Projection.prototype.setWorldExtent = function(worldExtent) {
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the resolution of the point in degrees. For projections with degrees as
|
* Set the getPointResolution function for this projection.
|
||||||
* the unit this will simply return the provided resolution. For other
|
* @param {function(number, ol.Coordinate):number} func Function
|
||||||
* projections the point resolution is estimated by transforming the center
|
* @api
|
||||||
* pixel to EPSG:4326, measuring its width and height on the normal sphere,
|
*/
|
||||||
* and taking the average of the width and height.
|
ol.proj.Projection.prototype.setGetPointResolution = function(func) {
|
||||||
* @param {number} resolution Resolution.
|
this.getPointResolutionFunc_ = func;
|
||||||
* @param {ol.Coordinate} point Point.
|
};
|
||||||
* @return {number} Point resolution.
|
|
||||||
*/
|
|
||||||
ol.proj.Projection.prototype.getPointResolution = function(resolution, point) {
|
/**
|
||||||
|
* Default version.
|
||||||
|
* Get the resolution of the point in degrees or distance units.
|
||||||
|
* For projections with degrees as the unit this will simply return the
|
||||||
|
* provided resolution. For other projections the point resolution is
|
||||||
|
* estimated by transforming the 'point' pixel to EPSG:4326,
|
||||||
|
* measuring its width and height on the normal sphere,
|
||||||
|
* and taking the average of the width and height.
|
||||||
|
* @param {number} resolution Nominal resolution in projection units.
|
||||||
|
* @param {ol.Coordinate} point Point to find adjusted resolution at.
|
||||||
|
* @return {number} Point resolution at point in projection units.
|
||||||
|
* @private
|
||||||
|
*/
|
||||||
|
ol.proj.Projection.prototype.getPointResolution_ = function(resolution, point) {
|
||||||
var units = this.getUnits();
|
var units = this.getUnits();
|
||||||
if (units == ol.proj.Units.DEGREES) {
|
if (units == ol.proj.Units.DEGREES) {
|
||||||
return resolution;
|
return resolution;
|
||||||
@@ -284,6 +314,26 @@ ol.proj.Projection.prototype.getPointResolution = function(resolution, point) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the resolution of the point in degrees or distance units.
|
||||||
|
* For projections with degrees as the unit this will simply return the
|
||||||
|
* provided resolution. The default for other projections is to estimate
|
||||||
|
* the point resolution by transforming the 'point' pixel to EPSG:4326,
|
||||||
|
* measuring its width and height on the normal sphere,
|
||||||
|
* and taking the average of the width and height.
|
||||||
|
* An alternative implementation may be given when constructing a
|
||||||
|
* projection. For many local projections,
|
||||||
|
* such a custom function will return the resolution unchanged.
|
||||||
|
* @param {number} resolution Resolution in projection units.
|
||||||
|
* @param {ol.Coordinate} point Point.
|
||||||
|
* @return {number} Point resolution in projection units.
|
||||||
|
* @api
|
||||||
|
*/
|
||||||
|
ol.proj.Projection.prototype.getPointResolution = function(resolution, point) {
|
||||||
|
return this.getPointResolutionFunc_(resolution, point);
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @private
|
* @private
|
||||||
* @type {Object.<string, ol.proj.Projection>}
|
* @type {Object.<string, ol.proj.Projection>}
|
||||||
|
|||||||
Reference in New Issue
Block a user