Get rid of olx.js and typedef.js typedefs for ol

This commit is contained in:
Andreas Hocevar
2018-03-08 18:42:57 +01:00
parent 8f0ffe2043
commit 95d6251dbb
198 changed files with 2262 additions and 2698 deletions

View File

@@ -4,6 +4,13 @@
import {assert} from './asserts.js';
/**
* An array representing an affine 2d transformation for use with
* {@link module:ol/transform} functions. The array has 6 elements.
* @typedef {!Array.<number>} Transform
*/
/**
* Collection of affine 2d transformation functions. The functions work on an
* array of 6 elements. The element order is compatible with the [SVGMatrix
@@ -19,14 +26,14 @@ import {assert} from './asserts.js';
/**
* @private
* @type {ol.Transform}
* @type {module:ol/transform~Transform}
*/
const tmp_ = new Array(6);
/**
* Create an identity transform.
* @return {!ol.Transform} Identity transform.
* @return {!module:ol/transform~Transform} Identity transform.
*/
export function create() {
return [1, 0, 0, 1, 0, 0];
@@ -35,8 +42,8 @@ export function create() {
/**
* Resets the given transform to an identity transform.
* @param {!ol.Transform} transform Transform.
* @return {!ol.Transform} Transform.
* @param {!module:ol/transform~Transform} transform Transform.
* @return {!module:ol/transform~Transform} Transform.
*/
export function reset(transform) {
return set(transform, 1, 0, 0, 1, 0, 0);
@@ -46,9 +53,9 @@ export function reset(transform) {
/**
* Multiply the underlying matrices of two transforms and return the result in
* the first transform.
* @param {!ol.Transform} transform1 Transform parameters of matrix 1.
* @param {!ol.Transform} transform2 Transform parameters of matrix 2.
* @return {!ol.Transform} transform1 multiplied with transform2.
* @param {!module:ol/transform~Transform} transform1 Transform parameters of matrix 1.
* @param {!module:ol/transform~Transform} transform2 Transform parameters of matrix 2.
* @return {!module:ol/transform~Transform} transform1 multiplied with transform2.
*/
export function multiply(transform1, transform2) {
const a1 = transform1[0];
@@ -76,14 +83,14 @@ export function multiply(transform1, transform2) {
/**
* Set the transform components a-f on a given transform.
* @param {!ol.Transform} transform Transform.
* @param {!module:ol/transform~Transform} transform Transform.
* @param {number} a The a component of the transform.
* @param {number} b The b component of the transform.
* @param {number} c The c component of the transform.
* @param {number} d The d component of the transform.
* @param {number} e The e component of the transform.
* @param {number} f The f component of the transform.
* @return {!ol.Transform} Matrix with transform applied.
* @return {!module:ol/transform~Transform} Matrix with transform applied.
*/
export function set(transform, a, b, c, d, e, f) {
transform[0] = a;
@@ -98,9 +105,9 @@ export function set(transform, a, b, c, d, e, f) {
/**
* Set transform on one matrix from another matrix.
* @param {!ol.Transform} transform1 Matrix to set transform to.
* @param {!ol.Transform} transform2 Matrix to set transform from.
* @return {!ol.Transform} transform1 with transform from transform2 applied.
* @param {!module:ol/transform~Transform} transform1 Matrix to set transform to.
* @param {!module:ol/transform~Transform} transform2 Matrix to set transform from.
* @return {!module:ol/transform~Transform} transform1 with transform from transform2 applied.
*/
export function setFromArray(transform1, transform2) {
transform1[0] = transform2[0];
@@ -117,9 +124,9 @@ export function setFromArray(transform1, transform2) {
* Transforms the given coordinate with the given transform returning the
* resulting, transformed coordinate. The coordinate will be modified in-place.
*
* @param {ol.Transform} transform The transformation.
* @param {ol.Coordinate|ol.Pixel} coordinate The coordinate to transform.
* @return {ol.Coordinate|ol.Pixel} return coordinate so that operations can be
* @param {module:ol/transform~Transform} transform The transformation.
* @param {module:ol/coordinate~Coordinate|module:ol~Pixel} coordinate The coordinate to transform.
* @return {module:ol/coordinate~Coordinate|module:ol~Pixel} return coordinate so that operations can be
* chained together.
*/
export function apply(transform, coordinate) {
@@ -133,9 +140,9 @@ export function apply(transform, coordinate) {
/**
* Applies rotation to the given transform.
* @param {!ol.Transform} transform Transform.
* @param {!module:ol/transform~Transform} transform Transform.
* @param {number} angle Angle in radians.
* @return {!ol.Transform} The rotated transform.
* @return {!module:ol/transform~Transform} The rotated transform.
*/
export function rotate(transform, angle) {
const cos = Math.cos(angle);
@@ -146,10 +153,10 @@ export function rotate(transform, angle) {
/**
* Applies scale to a given transform.
* @param {!ol.Transform} transform Transform.
* @param {!module:ol/transform~Transform} transform Transform.
* @param {number} x Scale factor x.
* @param {number} y Scale factor y.
* @return {!ol.Transform} The scaled transform.
* @return {!module:ol/transform~Transform} The scaled transform.
*/
export function scale(transform, x, y) {
return multiply(transform, set(tmp_, x, 0, 0, y, 0, 0));
@@ -158,10 +165,10 @@ export function scale(transform, x, y) {
/**
* Applies translation to the given transform.
* @param {!ol.Transform} transform Transform.
* @param {!module:ol/transform~Transform} transform Transform.
* @param {number} dx Translation x.
* @param {number} dy Translation y.
* @return {!ol.Transform} The translated transform.
* @return {!module:ol/transform~Transform} The translated transform.
*/
export function translate(transform, dx, dy) {
return multiply(transform, set(tmp_, 1, 0, 0, 1, dx, dy));
@@ -171,7 +178,7 @@ export function translate(transform, dx, dy) {
/**
* Creates a composite transform given an initial translation, scale, rotation, and
* final translation (in that order only, not commutative).
* @param {!ol.Transform} transform The transform (will be modified in place).
* @param {!module:ol/transform~Transform} transform The transform (will be modified in place).
* @param {number} dx1 Initial translation x.
* @param {number} dy1 Initial translation y.
* @param {number} sx Scale factor x.
@@ -179,7 +186,7 @@ export function translate(transform, dx, dy) {
* @param {number} angle Rotation (in counter-clockwise radians).
* @param {number} dx2 Final translation x.
* @param {number} dy2 Final translation y.
* @return {!ol.Transform} The composite transform.
* @return {!module:ol/transform~Transform} The composite transform.
*/
export function compose(transform, dx1, dy1, sx, sy, angle, dx2, dy2) {
const sin = Math.sin(angle);
@@ -196,8 +203,8 @@ export function compose(transform, dx1, dy1, sx, sy, angle, dx2, dy2) {
/**
* Invert the given transform.
* @param {!ol.Transform} transform Transform.
* @return {!ol.Transform} Inverse of the transform.
* @param {!module:ol/transform~Transform} transform Transform.
* @return {!module:ol/transform~Transform} Inverse of the transform.
*/
export function invert(transform) {
const det = determinant(transform);
@@ -223,7 +230,7 @@ export function invert(transform) {
/**
* Returns the determinant of the given matrix.
* @param {!ol.Transform} mat Matrix.
* @param {!module:ol/transform~Transform} mat Matrix.
* @return {number} Determinant.
*/
export function determinant(mat) {