Manual class transform

This commit is contained in:
Tim Schaub
2018-07-16 17:09:50 -06:00
parent 7b4a73f3b9
commit f78d0d4cfa
96 changed files with 8112 additions and 7964 deletions

View File

@@ -55,134 +55,134 @@ import {METERS_PER_UNIT} from '../proj/Units.js';
* @api
*/
class Projection {
constructor(options) {
/**
constructor(options) {
/**
* @private
* @type {string}
*/
this.code_ = options.code;
this.code_ = options.code;
/**
/**
* Units of projected coordinates. When set to `TILE_PIXELS`, a
* `this.extent_` and `this.worldExtent_` must be configured properly for each
* tile.
* @private
* @type {module:ol/proj/Units}
*/
this.units_ = /** @type {module:ol/proj/Units} */ (options.units);
this.units_ = /** @type {module:ol/proj/Units} */ (options.units);
/**
/**
* Validity extent of the projection in projected coordinates. For projections
* with `TILE_PIXELS` units, this is the extent of the tile in
* tile pixel space.
* @private
* @type {module:ol/extent~Extent}
*/
this.extent_ = options.extent !== undefined ? options.extent : null;
this.extent_ = options.extent !== undefined ? options.extent : null;
/**
/**
* Extent of the world in EPSG:4326. For projections with
* `TILE_PIXELS` units, this is the extent of the tile in
* projected coordinate space.
* @private
* @type {module:ol/extent~Extent}
*/
this.worldExtent_ = options.worldExtent !== undefined ?
options.worldExtent : null;
this.worldExtent_ = options.worldExtent !== undefined ?
options.worldExtent : null;
/**
/**
* @private
* @type {string}
*/
this.axisOrientation_ = options.axisOrientation !== undefined ?
options.axisOrientation : 'enu';
this.axisOrientation_ = options.axisOrientation !== undefined ?
options.axisOrientation : 'enu';
/**
/**
* @private
* @type {boolean}
*/
this.global_ = options.global !== undefined ? options.global : false;
this.global_ = options.global !== undefined ? options.global : false;
/**
/**
* @private
* @type {boolean}
*/
this.canWrapX_ = !!(this.global_ && this.extent_);
this.canWrapX_ = !!(this.global_ && this.extent_);
/**
/**
* @private
* @type {function(number, module:ol/coordinate~Coordinate):number|undefined}
*/
this.getPointResolutionFunc_ = options.getPointResolution;
this.getPointResolutionFunc_ = options.getPointResolution;
/**
/**
* @private
* @type {module:ol/tilegrid/TileGrid}
*/
this.defaultTileGrid_ = null;
this.defaultTileGrid_ = null;
/**
/**
* @private
* @type {number|undefined}
*/
this.metersPerUnit_ = options.metersPerUnit;
}
this.metersPerUnit_ = options.metersPerUnit;
}
/**
/**
* @return {boolean} The projection is suitable for wrapping the x-axis
*/
canWrapX() {
return this.canWrapX_;
}
canWrapX() {
return this.canWrapX_;
}
/**
/**
* Get the code for this projection, e.g. 'EPSG:4326'.
* @return {string} Code.
* @api
*/
getCode() {
return this.code_;
}
getCode() {
return this.code_;
}
/**
/**
* Get the validity extent for this projection.
* @return {module:ol/extent~Extent} Extent.
* @api
*/
getExtent() {
return this.extent_;
}
getExtent() {
return this.extent_;
}
/**
/**
* Get the units of this projection.
* @return {module:ol/proj/Units} Units.
* @api
*/
getUnits() {
return this.units_;
}
getUnits() {
return this.units_;
}
/**
/**
* Get the amount of meters per unit of this projection. If the projection is
* not configured with `metersPerUnit` or a units identifier, the return is
* `undefined`.
* @return {number|undefined} Meters.
* @api
*/
getMetersPerUnit() {
return this.metersPerUnit_ || METERS_PER_UNIT[this.units_];
}
getMetersPerUnit() {
return this.metersPerUnit_ || METERS_PER_UNIT[this.units_];
}
/**
/**
* Get the world extent for this projection.
* @return {module:ol/extent~Extent} Extent.
* @api
*/
getWorldExtent() {
return this.worldExtent_;
}
getWorldExtent() {
return this.worldExtent_;
}
/**
/**
* Get the axis orientation of this projection.
* Example values are:
* enu - the default easting, northing, elevation.
@@ -193,81 +193,81 @@ class Projection {
* @return {string} Axis orientation.
* @api
*/
getAxisOrientation() {
return this.axisOrientation_;
}
getAxisOrientation() {
return this.axisOrientation_;
}
/**
/**
* Is this projection a global projection which spans the whole world?
* @return {boolean} Whether the projection is global.
* @api
*/
isGlobal() {
return this.global_;
}
isGlobal() {
return this.global_;
}
/**
/**
* Set if the projection is a global projection which spans the whole world
* @param {boolean} global Whether the projection is global.
* @api
*/
setGlobal(global) {
this.global_ = global;
this.canWrapX_ = !!(global && this.extent_);
}
setGlobal(global) {
this.global_ = global;
this.canWrapX_ = !!(global && this.extent_);
}
/**
/**
* @return {module:ol/tilegrid/TileGrid} The default tile grid.
*/
getDefaultTileGrid() {
return this.defaultTileGrid_;
}
getDefaultTileGrid() {
return this.defaultTileGrid_;
}
/**
/**
* @param {module:ol/tilegrid/TileGrid} tileGrid The default tile grid.
*/
setDefaultTileGrid(tileGrid) {
this.defaultTileGrid_ = tileGrid;
}
setDefaultTileGrid(tileGrid) {
this.defaultTileGrid_ = tileGrid;
}
/**
/**
* Set the validity extent for this projection.
* @param {module:ol/extent~Extent} extent Extent.
* @api
*/
setExtent(extent) {
this.extent_ = extent;
this.canWrapX_ = !!(this.global_ && extent);
}
setExtent(extent) {
this.extent_ = extent;
this.canWrapX_ = !!(this.global_ && extent);
}
/**
/**
* Set the world extent for this projection.
* @param {module:ol/extent~Extent} worldExtent World extent
* [minlon, minlat, maxlon, maxlat].
* @api
*/
setWorldExtent(worldExtent) {
this.worldExtent_ = worldExtent;
}
setWorldExtent(worldExtent) {
this.worldExtent_ = worldExtent;
}
/**
/**
* Set the getPointResolution function (see {@link module:ol/proj~getPointResolution}
* for this projection.
* @param {function(number, module:ol/coordinate~Coordinate):number} func Function
* @api
*/
setGetPointResolution(func) {
this.getPointResolutionFunc_ = func;
}
setGetPointResolution(func) {
this.getPointResolutionFunc_ = func;
}
/**
/**
* Get the custom point resolution function for this projection (if set).
* @return {function(number, module:ol/coordinate~Coordinate):number|undefined} The custom point
* resolution function (if set).
*/
getPointResolutionFunc() {
return this.getPointResolutionFunc_;
}
getPointResolutionFunc() {
return this.getPointResolutionFunc_;
}
}
export default Projection;

View File

@@ -48,18 +48,24 @@ export const WORLD_EXTENT = [-180, -85, 180, 85];
* @extends {module:ol/proj/Projection}
* @param {string} code Code.
*/
function EPSG3857Projection(code) {
Projection.call(this, {
code: code,
units: Units.METERS,
extent: EXTENT,
global: true,
worldExtent: WORLD_EXTENT,
getPointResolution: function(resolution, point) {
return resolution / cosh(point[1] / RADIUS);
}
});
class EPSG3857Projection {
constructor(code) {
Projection.call(this, {
code: code,
units: Units.METERS,
extent: EXTENT,
global: true,
worldExtent: WORLD_EXTENT,
getPointResolution: function(resolution, point) {
return resolution / cosh(point[1] / RADIUS);
}
});
}
}
inherits(EPSG3857Projection, Projection);

View File

@@ -44,17 +44,23 @@ export const METERS_PER_UNIT = Math.PI * RADIUS / 180;
* @param {string} code Code.
* @param {string=} opt_axisOrientation Axis orientation.
*/
function EPSG4326Projection(code, opt_axisOrientation) {
Projection.call(this, {
code: code,
units: Units.DEGREES,
extent: EXTENT,
axisOrientation: opt_axisOrientation,
global: true,
metersPerUnit: METERS_PER_UNIT,
worldExtent: EXTENT
});
class EPSG4326Projection {
constructor(code, opt_axisOrientation) {
Projection.call(this, {
code: code,
units: Units.DEGREES,
extent: EXTENT,
axisOrientation: opt_axisOrientation,
global: true,
metersPerUnit: METERS_PER_UNIT,
worldExtent: EXTENT
});
}
}
inherits(EPSG4326Projection, Projection);