From 3c99fde45db83b531c41c350ed4d0ac2a3c40c62 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 28 Apr 2024 14:45:13 +0200 Subject: Adding debian version 1.1.0-3. Signed-off-by: Daniel Baumann --- .../leaflet.js/geometry/Transformation.js | 79 ++++++++++++++++++++++ 1 file changed, 79 insertions(+) create mode 100644 debian/missing-sources/leaflet.js/geometry/Transformation.js (limited to 'debian/missing-sources/leaflet.js/geometry/Transformation.js') diff --git a/debian/missing-sources/leaflet.js/geometry/Transformation.js b/debian/missing-sources/leaflet.js/geometry/Transformation.js new file mode 100644 index 0000000..8f1147e --- /dev/null +++ b/debian/missing-sources/leaflet.js/geometry/Transformation.js @@ -0,0 +1,79 @@ +import {Point} from './Point'; +import * as Util from '../core/Util'; + +/* + * @class Transformation + * @aka L.Transformation + * + * Represents an affine transformation: a set of coefficients `a`, `b`, `c`, `d` + * for transforming a point of a form `(x, y)` into `(a*x + b, c*y + d)` and doing + * the reverse. Used by Leaflet in its projections code. + * + * @example + * + * ```js + * var transformation = L.transformation(2, 5, -1, 10), + * p = L.point(1, 2), + * p2 = transformation.transform(p), // L.point(7, 8) + * p3 = transformation.untransform(p2); // L.point(1, 2) + * ``` + */ + + +// factory new L.Transformation(a: Number, b: Number, c: Number, d: Number) +// Creates a `Transformation` object with the given coefficients. +export function Transformation(a, b, c, d) { + if (Util.isArray(a)) { + // use array properties + this._a = a[0]; + this._b = a[1]; + this._c = a[2]; + this._d = a[3]; + return; + } + this._a = a; + this._b = b; + this._c = c; + this._d = d; +} + +Transformation.prototype = { + // @method transform(point: Point, scale?: Number): Point + // Returns a transformed point, optionally multiplied by the given scale. + // Only accepts actual `L.Point` instances, not arrays. + transform: function (point, scale) { // (Point, Number) -> Point + return this._transform(point.clone(), scale); + }, + + // destructive transform (faster) + _transform: function (point, scale) { + scale = scale || 1; + point.x = scale * (this._a * point.x + this._b); + point.y = scale * (this._c * point.y + this._d); + return point; + }, + + // @method untransform(point: Point, scale?: Number): Point + // Returns the reverse transformation of the given point, optionally divided + // by the given scale. Only accepts actual `L.Point` instances, not arrays. + untransform: function (point, scale) { + scale = scale || 1; + return new Point( + (point.x / scale - this._b) / this._a, + (point.y / scale - this._d) / this._c); + } +}; + +// factory L.transformation(a: Number, b: Number, c: Number, d: Number) + +// @factory L.transformation(a: Number, b: Number, c: Number, d: Number) +// Instantiates a Transformation object with the given coefficients. + +// @alternative +// @factory L.transformation(coefficients: Array): Transformation +// Expects an coefficients array of the form +// `[a: Number, b: Number, c: Number, d: Number]`. + +export function toTransformation(a, b, c, d) { + return new Transformation(a, b, c, d); +} -- cgit v1.2.3