summaryrefslogtreecommitdiffstats
path: root/debian/missing-sources/leaflet.js/geo/projection
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--debian/missing-sources/leaflet.js/geo/projection/Projection.LonLat.js28
-rw-r--r--debian/missing-sources/leaflet.js/geo/projection/Projection.Mercator.js49
-rw-r--r--debian/missing-sources/leaflet.js/geo/projection/Projection.SphericalMercator.js42
-rw-r--r--debian/missing-sources/leaflet.js/geo/projection/index.js26
4 files changed, 145 insertions, 0 deletions
diff --git a/debian/missing-sources/leaflet.js/geo/projection/Projection.LonLat.js b/debian/missing-sources/leaflet.js/geo/projection/Projection.LonLat.js
new file mode 100644
index 0000000..774f66f
--- /dev/null
+++ b/debian/missing-sources/leaflet.js/geo/projection/Projection.LonLat.js
@@ -0,0 +1,28 @@
+import {LatLng} from '../LatLng';
+import {Bounds} from '../../geometry/Bounds';
+import {Point} from '../../geometry/Point';
+
+/*
+ * @namespace Projection
+ * @section
+ * Leaflet comes with a set of already defined Projections out of the box:
+ *
+ * @projection L.Projection.LonLat
+ *
+ * Equirectangular, or Plate Carree projection — the most simple projection,
+ * mostly used by GIS enthusiasts. Directly maps `x` as longitude, and `y` as
+ * latitude. Also suitable for flat worlds, e.g. game maps. Used by the
+ * `EPSG:4326` and `Simple` CRS.
+ */
+
+export var LonLat = {
+ project: function (latlng) {
+ return new Point(latlng.lng, latlng.lat);
+ },
+
+ unproject: function (point) {
+ return new LatLng(point.y, point.x);
+ },
+
+ bounds: new Bounds([-180, -90], [180, 90])
+};
diff --git a/debian/missing-sources/leaflet.js/geo/projection/Projection.Mercator.js b/debian/missing-sources/leaflet.js/geo/projection/Projection.Mercator.js
new file mode 100644
index 0000000..00ab52a
--- /dev/null
+++ b/debian/missing-sources/leaflet.js/geo/projection/Projection.Mercator.js
@@ -0,0 +1,49 @@
+import {LatLng} from '../LatLng';
+import {Bounds} from '../../geometry/Bounds';
+import {Point} from '../../geometry/Point';
+
+/*
+ * @namespace Projection
+ * @projection L.Projection.Mercator
+ *
+ * Elliptical Mercator projection — more complex than Spherical Mercator. Takes into account that Earth is a geoid, not a perfect sphere. Used by the EPSG:3395 CRS.
+ */
+
+export var Mercator = {
+ R: 6378137,
+ R_MINOR: 6356752.314245179,
+
+ bounds: new Bounds([-20037508.34279, -15496570.73972], [20037508.34279, 18764656.23138]),
+
+ project: function (latlng) {
+ var d = Math.PI / 180,
+ r = this.R,
+ y = latlng.lat * d,
+ tmp = this.R_MINOR / r,
+ e = Math.sqrt(1 - tmp * tmp),
+ con = e * Math.sin(y);
+
+ var ts = Math.tan(Math.PI / 4 - y / 2) / Math.pow((1 - con) / (1 + con), e / 2);
+ y = -r * Math.log(Math.max(ts, 1E-10));
+
+ return new Point(latlng.lng * d * r, y);
+ },
+
+ unproject: function (point) {
+ var d = 180 / Math.PI,
+ r = this.R,
+ tmp = this.R_MINOR / r,
+ e = Math.sqrt(1 - tmp * tmp),
+ ts = Math.exp(-point.y / r),
+ phi = Math.PI / 2 - 2 * Math.atan(ts);
+
+ for (var i = 0, dphi = 0.1, con; i < 15 && Math.abs(dphi) > 1e-7; i++) {
+ con = e * Math.sin(phi);
+ con = Math.pow((1 - con) / (1 + con), e / 2);
+ dphi = Math.PI / 2 - 2 * Math.atan(ts * con) - phi;
+ phi += dphi;
+ }
+
+ return new LatLng(phi * d, point.x * d / r);
+ }
+};
diff --git a/debian/missing-sources/leaflet.js/geo/projection/Projection.SphericalMercator.js b/debian/missing-sources/leaflet.js/geo/projection/Projection.SphericalMercator.js
new file mode 100644
index 0000000..b6f6539
--- /dev/null
+++ b/debian/missing-sources/leaflet.js/geo/projection/Projection.SphericalMercator.js
@@ -0,0 +1,42 @@
+import {LatLng} from '../LatLng';
+import {Bounds} from '../../geometry/Bounds';
+import {Point} from '../../geometry/Point';
+
+/*
+ * @namespace Projection
+ * @projection L.Projection.SphericalMercator
+ *
+ * Spherical Mercator projection — the most common projection for online maps,
+ * used by almost all free and commercial tile providers. Assumes that Earth is
+ * a sphere. Used by the `EPSG:3857` CRS.
+ */
+
+export var SphericalMercator = {
+
+ R: 6378137,
+ MAX_LATITUDE: 85.0511287798,
+
+ project: function (latlng) {
+ var d = Math.PI / 180,
+ max = this.MAX_LATITUDE,
+ lat = Math.max(Math.min(max, latlng.lat), -max),
+ sin = Math.sin(lat * d);
+
+ return new Point(
+ this.R * latlng.lng * d,
+ this.R * Math.log((1 + sin) / (1 - sin)) / 2);
+ },
+
+ unproject: function (point) {
+ var d = 180 / Math.PI;
+
+ return new LatLng(
+ (2 * Math.atan(Math.exp(point.y / this.R)) - (Math.PI / 2)) * d,
+ point.x * d / this.R);
+ },
+
+ bounds: (function () {
+ var d = 6378137 * Math.PI;
+ return new Bounds([-d, -d], [d, d]);
+ })()
+};
diff --git a/debian/missing-sources/leaflet.js/geo/projection/index.js b/debian/missing-sources/leaflet.js/geo/projection/index.js
new file mode 100644
index 0000000..feee601
--- /dev/null
+++ b/debian/missing-sources/leaflet.js/geo/projection/index.js
@@ -0,0 +1,26 @@
+/*
+ * @class Projection
+
+ * An object with methods for projecting geographical coordinates of the world onto
+ * a flat surface (and back). See [Map projection](http://en.wikipedia.org/wiki/Map_projection).
+
+ * @property bounds: Bounds
+ * The bounds (specified in CRS units) where the projection is valid
+
+ * @method project(latlng: LatLng): Point
+ * Projects geographical coordinates into a 2D point.
+ * Only accepts actual `L.LatLng` instances, not arrays.
+
+ * @method unproject(point: Point): LatLng
+ * The inverse of `project`. Projects a 2D point into a geographical location.
+ * Only accepts actual `L.Point` instances, not arrays.
+
+ * Note that the projection instances do not inherit from Leafet's `Class` object,
+ * and can't be instantiated. Also, new classes can't inherit from them,
+ * and methods can't be added to them with the `include` function.
+
+ */
+
+export {LonLat} from './Projection.LonLat';
+export {Mercator} from './Projection.Mercator';
+export {SphericalMercator} from './Projection.SphericalMercator';