decidim 0.26.9 → 0.26.10

Sign up to get free protection for your applications and to get access to all the features.
Files changed (117) hide show
  1. checksums.yaml +4 -4
  2. data/lib/decidim/version.rb +1 -1
  3. data/package-lock.json +7 -7
  4. data/packages/browserslist-config/package.json +1 -1
  5. data/packages/core/node_modules/leaflet/CHANGELOG.md +2191 -0
  6. data/packages/core/node_modules/leaflet/LICENSE +26 -0
  7. data/packages/core/node_modules/leaflet/README.md +55 -0
  8. data/packages/core/node_modules/leaflet/dist/images/layers-2x.png +0 -0
  9. data/packages/core/node_modules/leaflet/dist/images/layers.png +0 -0
  10. data/packages/core/node_modules/leaflet/dist/images/marker-icon-2x.png +0 -0
  11. data/packages/core/node_modules/leaflet/dist/images/marker-icon.png +0 -0
  12. data/packages/core/node_modules/leaflet/dist/images/marker-shadow.png +0 -0
  13. data/packages/core/node_modules/leaflet/dist/leaflet-src.esm.js +14419 -0
  14. data/packages/core/node_modules/leaflet/dist/leaflet-src.esm.js.map +1 -0
  15. data/packages/core/node_modules/leaflet/dist/leaflet-src.js +14512 -0
  16. data/packages/core/node_modules/leaflet/dist/leaflet-src.js.map +1 -0
  17. data/packages/core/node_modules/leaflet/dist/leaflet.css +661 -0
  18. data/packages/core/node_modules/leaflet/dist/leaflet.js +6 -0
  19. data/packages/core/node_modules/leaflet/dist/leaflet.js.map +1 -0
  20. data/packages/core/node_modules/leaflet/package.json +149 -0
  21. data/packages/core/node_modules/leaflet/src/Leaflet.js +24 -0
  22. data/packages/core/node_modules/leaflet/src/control/Control.Attribution.js +148 -0
  23. data/packages/core/node_modules/leaflet/src/control/Control.Layers.js +443 -0
  24. data/packages/core/node_modules/leaflet/src/control/Control.Scale.js +132 -0
  25. data/packages/core/node_modules/leaflet/src/control/Control.Zoom.js +146 -0
  26. data/packages/core/node_modules/leaflet/src/control/Control.js +174 -0
  27. data/packages/core/node_modules/leaflet/src/control/index.js +17 -0
  28. data/packages/core/node_modules/leaflet/src/core/Browser.js +220 -0
  29. data/packages/core/node_modules/leaflet/src/core/Class.js +135 -0
  30. data/packages/core/node_modules/leaflet/src/core/Class.leafdoc +197 -0
  31. data/packages/core/node_modules/leaflet/src/core/Events.js +344 -0
  32. data/packages/core/node_modules/leaflet/src/core/Events.leafdoc +143 -0
  33. data/packages/core/node_modules/leaflet/src/core/Handler.js +57 -0
  34. data/packages/core/node_modules/leaflet/src/core/Util.js +241 -0
  35. data/packages/core/node_modules/leaflet/src/core/index.js +15 -0
  36. data/packages/core/node_modules/leaflet/src/dom/DomEvent.DoubleTap.js +91 -0
  37. data/packages/core/node_modules/leaflet/src/dom/DomEvent.Pointer.js +97 -0
  38. data/packages/core/node_modules/leaflet/src/dom/DomEvent.js +315 -0
  39. data/packages/core/node_modules/leaflet/src/dom/DomUtil.js +349 -0
  40. data/packages/core/node_modules/leaflet/src/dom/Draggable.js +220 -0
  41. data/packages/core/node_modules/leaflet/src/dom/PosAnimation.js +113 -0
  42. data/packages/core/node_modules/leaflet/src/dom/index.js +9 -0
  43. data/packages/core/node_modules/leaflet/src/geo/LatLng.js +137 -0
  44. data/packages/core/node_modules/leaflet/src/geo/LatLngBounds.js +251 -0
  45. data/packages/core/node_modules/leaflet/src/geo/crs/CRS.EPSG3395.js +20 -0
  46. data/packages/core/node_modules/leaflet/src/geo/crs/CRS.EPSG3857.js +27 -0
  47. data/packages/core/node_modules/leaflet/src/geo/crs/CRS.EPSG4326.js +23 -0
  48. data/packages/core/node_modules/leaflet/src/geo/crs/CRS.Earth.js +33 -0
  49. data/packages/core/node_modules/leaflet/src/geo/crs/CRS.Simple.js +36 -0
  50. data/packages/core/node_modules/leaflet/src/geo/crs/CRS.js +139 -0
  51. data/packages/core/node_modules/leaflet/src/geo/crs/index.js +15 -0
  52. data/packages/core/node_modules/leaflet/src/geo/index.js +7 -0
  53. data/packages/core/node_modules/leaflet/src/geo/projection/Projection.LonLat.js +28 -0
  54. data/packages/core/node_modules/leaflet/src/geo/projection/Projection.Mercator.js +49 -0
  55. data/packages/core/node_modules/leaflet/src/geo/projection/Projection.SphericalMercator.js +44 -0
  56. data/packages/core/node_modules/leaflet/src/geo/projection/index.js +26 -0
  57. data/packages/core/node_modules/leaflet/src/geometry/Bounds.js +219 -0
  58. data/packages/core/node_modules/leaflet/src/geometry/LineUtil.js +306 -0
  59. data/packages/core/node_modules/leaflet/src/geometry/Point.js +222 -0
  60. data/packages/core/node_modules/leaflet/src/geometry/PolyUtil.js +129 -0
  61. data/packages/core/node_modules/leaflet/src/geometry/Transformation.js +79 -0
  62. data/packages/core/node_modules/leaflet/src/geometry/index.js +8 -0
  63. data/packages/core/node_modules/leaflet/src/images/layers.svg +1 -0
  64. data/packages/core/node_modules/leaflet/src/images/logo.svg +1 -0
  65. data/packages/core/node_modules/leaflet/src/images/marker.svg +1 -0
  66. data/packages/core/node_modules/leaflet/src/layer/DivOverlay.js +348 -0
  67. data/packages/core/node_modules/leaflet/src/layer/FeatureGroup.js +94 -0
  68. data/packages/core/node_modules/leaflet/src/layer/GeoJSON.js +452 -0
  69. data/packages/core/node_modules/leaflet/src/layer/ImageOverlay.js +270 -0
  70. data/packages/core/node_modules/leaflet/src/layer/Layer.Interactive.leafdoc +39 -0
  71. data/packages/core/node_modules/leaflet/src/layer/Layer.js +275 -0
  72. data/packages/core/node_modules/leaflet/src/layer/LayerGroup.js +159 -0
  73. data/packages/core/node_modules/leaflet/src/layer/Popup.js +506 -0
  74. data/packages/core/node_modules/leaflet/src/layer/SVGOverlay.js +50 -0
  75. data/packages/core/node_modules/leaflet/src/layer/Tooltip.js +444 -0
  76. data/packages/core/node_modules/leaflet/src/layer/VideoOverlay.js +106 -0
  77. data/packages/core/node_modules/leaflet/src/layer/index.js +24 -0
  78. data/packages/core/node_modules/leaflet/src/layer/marker/DivIcon.js +74 -0
  79. data/packages/core/node_modules/leaflet/src/layer/marker/Icon.Default.js +66 -0
  80. data/packages/core/node_modules/leaflet/src/layer/marker/Icon.js +165 -0
  81. data/packages/core/node_modules/leaflet/src/layer/marker/Marker.Drag.js +161 -0
  82. data/packages/core/node_modules/leaflet/src/layer/marker/Marker.js +419 -0
  83. data/packages/core/node_modules/leaflet/src/layer/marker/index.js +8 -0
  84. data/packages/core/node_modules/leaflet/src/layer/tile/GridLayer.js +923 -0
  85. data/packages/core/node_modules/leaflet/src/layer/tile/TileLayer.WMS.js +137 -0
  86. data/packages/core/node_modules/leaflet/src/layer/tile/TileLayer.js +289 -0
  87. data/packages/core/node_modules/leaflet/src/layer/tile/index.js +6 -0
  88. data/packages/core/node_modules/leaflet/src/layer/vector/Canvas.js +492 -0
  89. data/packages/core/node_modules/leaflet/src/layer/vector/Circle.js +113 -0
  90. data/packages/core/node_modules/leaflet/src/layer/vector/CircleMarker.js +109 -0
  91. data/packages/core/node_modules/leaflet/src/layer/vector/Path.js +148 -0
  92. data/packages/core/node_modules/leaflet/src/layer/vector/Polygon.js +159 -0
  93. data/packages/core/node_modules/leaflet/src/layer/vector/Polyline.js +307 -0
  94. data/packages/core/node_modules/leaflet/src/layer/vector/Rectangle.js +57 -0
  95. data/packages/core/node_modules/leaflet/src/layer/vector/Renderer.getRenderer.js +45 -0
  96. data/packages/core/node_modules/leaflet/src/layer/vector/Renderer.js +133 -0
  97. data/packages/core/node_modules/leaflet/src/layer/vector/SVG.Util.js +39 -0
  98. data/packages/core/node_modules/leaflet/src/layer/vector/SVG.VML.js +144 -0
  99. data/packages/core/node_modules/leaflet/src/layer/vector/SVG.js +207 -0
  100. data/packages/core/node_modules/leaflet/src/layer/vector/index.js +14 -0
  101. data/packages/core/node_modules/leaflet/src/map/Map.js +1751 -0
  102. data/packages/core/node_modules/leaflet/src/map/Map.methodOptions.leafdoc +112 -0
  103. data/packages/core/node_modules/leaflet/src/map/handler/Map.BoxZoom.js +152 -0
  104. data/packages/core/node_modules/leaflet/src/map/handler/Map.DoubleClickZoom.js +55 -0
  105. data/packages/core/node_modules/leaflet/src/map/handler/Map.Drag.js +235 -0
  106. data/packages/core/node_modules/leaflet/src/map/handler/Map.Keyboard.js +183 -0
  107. data/packages/core/node_modules/leaflet/src/map/handler/Map.ScrollWheelZoom.js +91 -0
  108. data/packages/core/node_modules/leaflet/src/map/handler/Map.TapHold.js +102 -0
  109. data/packages/core/node_modules/leaflet/src/map/handler/Map.TouchZoom.js +130 -0
  110. data/packages/core/node_modules/leaflet/src/map/index.js +17 -0
  111. data/packages/core/package.json +1 -1
  112. data/packages/dev/package.json +1 -1
  113. data/packages/elections/package.json +1 -1
  114. data/packages/eslint-config/package.json +1 -1
  115. data/packages/stylelint-config/package.json +1 -1
  116. data/packages/webpacker/package.json +1 -1
  117. metadata +148 -42
@@ -0,0 +1,251 @@
1
+ import {LatLng, toLatLng} from './LatLng';
2
+
3
+ /*
4
+ * @class LatLngBounds
5
+ * @aka L.LatLngBounds
6
+ *
7
+ * Represents a rectangular geographical area on a map.
8
+ *
9
+ * @example
10
+ *
11
+ * ```js
12
+ * var corner1 = L.latLng(40.712, -74.227),
13
+ * corner2 = L.latLng(40.774, -74.125),
14
+ * bounds = L.latLngBounds(corner1, corner2);
15
+ * ```
16
+ *
17
+ * All Leaflet methods that accept LatLngBounds objects also accept them in a simple Array form (unless noted otherwise), so the bounds example above can be passed like this:
18
+ *
19
+ * ```js
20
+ * map.fitBounds([
21
+ * [40.712, -74.227],
22
+ * [40.774, -74.125]
23
+ * ]);
24
+ * ```
25
+ *
26
+ * Caution: if the area crosses the antimeridian (often confused with the International Date Line), you must specify corners _outside_ the [-180, 180] degrees longitude range.
27
+ *
28
+ * Note that `LatLngBounds` does not inherit from Leaflet's `Class` object,
29
+ * which means new classes can't inherit from it, and new methods
30
+ * can't be added to it with the `include` function.
31
+ */
32
+
33
+ export function LatLngBounds(corner1, corner2) { // (LatLng, LatLng) or (LatLng[])
34
+ if (!corner1) { return; }
35
+
36
+ var latlngs = corner2 ? [corner1, corner2] : corner1;
37
+
38
+ for (var i = 0, len = latlngs.length; i < len; i++) {
39
+ this.extend(latlngs[i]);
40
+ }
41
+ }
42
+
43
+ LatLngBounds.prototype = {
44
+
45
+ // @method extend(latlng: LatLng): this
46
+ // Extend the bounds to contain the given point
47
+
48
+ // @alternative
49
+ // @method extend(otherBounds: LatLngBounds): this
50
+ // Extend the bounds to contain the given bounds
51
+ extend: function (obj) {
52
+ var sw = this._southWest,
53
+ ne = this._northEast,
54
+ sw2, ne2;
55
+
56
+ if (obj instanceof LatLng) {
57
+ sw2 = obj;
58
+ ne2 = obj;
59
+
60
+ } else if (obj instanceof LatLngBounds) {
61
+ sw2 = obj._southWest;
62
+ ne2 = obj._northEast;
63
+
64
+ if (!sw2 || !ne2) { return this; }
65
+
66
+ } else {
67
+ return obj ? this.extend(toLatLng(obj) || toLatLngBounds(obj)) : this;
68
+ }
69
+
70
+ if (!sw && !ne) {
71
+ this._southWest = new LatLng(sw2.lat, sw2.lng);
72
+ this._northEast = new LatLng(ne2.lat, ne2.lng);
73
+ } else {
74
+ sw.lat = Math.min(sw2.lat, sw.lat);
75
+ sw.lng = Math.min(sw2.lng, sw.lng);
76
+ ne.lat = Math.max(ne2.lat, ne.lat);
77
+ ne.lng = Math.max(ne2.lng, ne.lng);
78
+ }
79
+
80
+ return this;
81
+ },
82
+
83
+ // @method pad(bufferRatio: Number): LatLngBounds
84
+ // Returns bounds created by extending or retracting the current bounds by a given ratio in each direction.
85
+ // For example, a ratio of 0.5 extends the bounds by 50% in each direction.
86
+ // Negative values will retract the bounds.
87
+ pad: function (bufferRatio) {
88
+ var sw = this._southWest,
89
+ ne = this._northEast,
90
+ heightBuffer = Math.abs(sw.lat - ne.lat) * bufferRatio,
91
+ widthBuffer = Math.abs(sw.lng - ne.lng) * bufferRatio;
92
+
93
+ return new LatLngBounds(
94
+ new LatLng(sw.lat - heightBuffer, sw.lng - widthBuffer),
95
+ new LatLng(ne.lat + heightBuffer, ne.lng + widthBuffer));
96
+ },
97
+
98
+ // @method getCenter(): LatLng
99
+ // Returns the center point of the bounds.
100
+ getCenter: function () {
101
+ return new LatLng(
102
+ (this._southWest.lat + this._northEast.lat) / 2,
103
+ (this._southWest.lng + this._northEast.lng) / 2);
104
+ },
105
+
106
+ // @method getSouthWest(): LatLng
107
+ // Returns the south-west point of the bounds.
108
+ getSouthWest: function () {
109
+ return this._southWest;
110
+ },
111
+
112
+ // @method getNorthEast(): LatLng
113
+ // Returns the north-east point of the bounds.
114
+ getNorthEast: function () {
115
+ return this._northEast;
116
+ },
117
+
118
+ // @method getNorthWest(): LatLng
119
+ // Returns the north-west point of the bounds.
120
+ getNorthWest: function () {
121
+ return new LatLng(this.getNorth(), this.getWest());
122
+ },
123
+
124
+ // @method getSouthEast(): LatLng
125
+ // Returns the south-east point of the bounds.
126
+ getSouthEast: function () {
127
+ return new LatLng(this.getSouth(), this.getEast());
128
+ },
129
+
130
+ // @method getWest(): Number
131
+ // Returns the west longitude of the bounds
132
+ getWest: function () {
133
+ return this._southWest.lng;
134
+ },
135
+
136
+ // @method getSouth(): Number
137
+ // Returns the south latitude of the bounds
138
+ getSouth: function () {
139
+ return this._southWest.lat;
140
+ },
141
+
142
+ // @method getEast(): Number
143
+ // Returns the east longitude of the bounds
144
+ getEast: function () {
145
+ return this._northEast.lng;
146
+ },
147
+
148
+ // @method getNorth(): Number
149
+ // Returns the north latitude of the bounds
150
+ getNorth: function () {
151
+ return this._northEast.lat;
152
+ },
153
+
154
+ // @method contains(otherBounds: LatLngBounds): Boolean
155
+ // Returns `true` if the rectangle contains the given one.
156
+
157
+ // @alternative
158
+ // @method contains (latlng: LatLng): Boolean
159
+ // Returns `true` if the rectangle contains the given point.
160
+ contains: function (obj) { // (LatLngBounds) or (LatLng) -> Boolean
161
+ if (typeof obj[0] === 'number' || obj instanceof LatLng || 'lat' in obj) {
162
+ obj = toLatLng(obj);
163
+ } else {
164
+ obj = toLatLngBounds(obj);
165
+ }
166
+
167
+ var sw = this._southWest,
168
+ ne = this._northEast,
169
+ sw2, ne2;
170
+
171
+ if (obj instanceof LatLngBounds) {
172
+ sw2 = obj.getSouthWest();
173
+ ne2 = obj.getNorthEast();
174
+ } else {
175
+ sw2 = ne2 = obj;
176
+ }
177
+
178
+ return (sw2.lat >= sw.lat) && (ne2.lat <= ne.lat) &&
179
+ (sw2.lng >= sw.lng) && (ne2.lng <= ne.lng);
180
+ },
181
+
182
+ // @method intersects(otherBounds: LatLngBounds): Boolean
183
+ // Returns `true` if the rectangle intersects the given bounds. Two bounds intersect if they have at least one point in common.
184
+ intersects: function (bounds) {
185
+ bounds = toLatLngBounds(bounds);
186
+
187
+ var sw = this._southWest,
188
+ ne = this._northEast,
189
+ sw2 = bounds.getSouthWest(),
190
+ ne2 = bounds.getNorthEast(),
191
+
192
+ latIntersects = (ne2.lat >= sw.lat) && (sw2.lat <= ne.lat),
193
+ lngIntersects = (ne2.lng >= sw.lng) && (sw2.lng <= ne.lng);
194
+
195
+ return latIntersects && lngIntersects;
196
+ },
197
+
198
+ // @method overlaps(otherBounds: LatLngBounds): Boolean
199
+ // Returns `true` if the rectangle overlaps the given bounds. Two bounds overlap if their intersection is an area.
200
+ overlaps: function (bounds) {
201
+ bounds = toLatLngBounds(bounds);
202
+
203
+ var sw = this._southWest,
204
+ ne = this._northEast,
205
+ sw2 = bounds.getSouthWest(),
206
+ ne2 = bounds.getNorthEast(),
207
+
208
+ latOverlaps = (ne2.lat > sw.lat) && (sw2.lat < ne.lat),
209
+ lngOverlaps = (ne2.lng > sw.lng) && (sw2.lng < ne.lng);
210
+
211
+ return latOverlaps && lngOverlaps;
212
+ },
213
+
214
+ // @method toBBoxString(): String
215
+ // Returns a string with bounding box coordinates in a 'southwest_lng,southwest_lat,northeast_lng,northeast_lat' format. Useful for sending requests to web services that return geo data.
216
+ toBBoxString: function () {
217
+ return [this.getWest(), this.getSouth(), this.getEast(), this.getNorth()].join(',');
218
+ },
219
+
220
+ // @method equals(otherBounds: LatLngBounds, maxMargin?: Number): Boolean
221
+ // Returns `true` if the rectangle is equivalent (within a small margin of error) to the given bounds. The margin of error can be overridden by setting `maxMargin` to a small number.
222
+ equals: function (bounds, maxMargin) {
223
+ if (!bounds) { return false; }
224
+
225
+ bounds = toLatLngBounds(bounds);
226
+
227
+ return this._southWest.equals(bounds.getSouthWest(), maxMargin) &&
228
+ this._northEast.equals(bounds.getNorthEast(), maxMargin);
229
+ },
230
+
231
+ // @method isValid(): Boolean
232
+ // Returns `true` if the bounds are properly initialized.
233
+ isValid: function () {
234
+ return !!(this._southWest && this._northEast);
235
+ }
236
+ };
237
+
238
+ // TODO International date line?
239
+
240
+ // @factory L.latLngBounds(corner1: LatLng, corner2: LatLng)
241
+ // Creates a `LatLngBounds` object by defining two diagonally opposite corners of the rectangle.
242
+
243
+ // @alternative
244
+ // @factory L.latLngBounds(latlngs: LatLng[])
245
+ // Creates a `LatLngBounds` object defined by the geographical points it contains. Very useful for zooming the map to fit a particular set of locations with [`fitBounds`](#map-fitbounds).
246
+ export function toLatLngBounds(a, b) {
247
+ if (a instanceof LatLngBounds) {
248
+ return a;
249
+ }
250
+ return new LatLngBounds(a, b);
251
+ }
@@ -0,0 +1,20 @@
1
+ import {Earth} from './CRS.Earth';
2
+ import {Mercator} from '../projection/Projection.Mercator';
3
+ import {toTransformation} from '../../geometry/Transformation';
4
+ import * as Util from '../../core/Util';
5
+
6
+ /*
7
+ * @namespace CRS
8
+ * @crs L.CRS.EPSG3395
9
+ *
10
+ * Rarely used by some commercial tile providers. Uses Elliptical Mercator projection.
11
+ */
12
+ export var EPSG3395 = Util.extend({}, Earth, {
13
+ code: 'EPSG:3395',
14
+ projection: Mercator,
15
+
16
+ transformation: (function () {
17
+ var scale = 0.5 / (Math.PI * Mercator.R);
18
+ return toTransformation(scale, 0.5, -scale, 0.5);
19
+ }())
20
+ });
@@ -0,0 +1,27 @@
1
+ import {Earth} from './CRS.Earth';
2
+ import {SphericalMercator} from '../projection/Projection.SphericalMercator';
3
+ import {toTransformation} from '../../geometry/Transformation';
4
+ import * as Util from '../../core/Util';
5
+
6
+ /*
7
+ * @namespace CRS
8
+ * @crs L.CRS.EPSG3857
9
+ *
10
+ * The most common CRS for online maps, used by almost all free and commercial
11
+ * tile providers. Uses Spherical Mercator projection. Set in by default in
12
+ * Map's `crs` option.
13
+ */
14
+
15
+ export var EPSG3857 = Util.extend({}, Earth, {
16
+ code: 'EPSG:3857',
17
+ projection: SphericalMercator,
18
+
19
+ transformation: (function () {
20
+ var scale = 0.5 / (Math.PI * SphericalMercator.R);
21
+ return toTransformation(scale, 0.5, -scale, 0.5);
22
+ }())
23
+ });
24
+
25
+ export var EPSG900913 = Util.extend({}, EPSG3857, {
26
+ code: 'EPSG:900913'
27
+ });
@@ -0,0 +1,23 @@
1
+ import {Earth} from './CRS.Earth';
2
+ import {LonLat} from '../projection/Projection.LonLat';
3
+ import {toTransformation} from '../../geometry/Transformation';
4
+ import * as Util from '../../core/Util';
5
+
6
+ /*
7
+ * @namespace CRS
8
+ * @crs L.CRS.EPSG4326
9
+ *
10
+ * A common CRS among GIS enthusiasts. Uses simple Equirectangular projection.
11
+ *
12
+ * Leaflet 1.0.x complies with the [TMS coordinate scheme for EPSG:4326](https://wiki.osgeo.org/wiki/Tile_Map_Service_Specification#global-geodetic),
13
+ * which is a breaking change from 0.7.x behaviour. If you are using a `TileLayer`
14
+ * with this CRS, ensure that there are two 256x256 pixel tiles covering the
15
+ * whole earth at zoom level zero, and that the tile coordinate origin is (-180,+90),
16
+ * or (-180,-90) for `TileLayer`s with [the `tms` option](#tilelayer-tms) set.
17
+ */
18
+
19
+ export var EPSG4326 = Util.extend({}, Earth, {
20
+ code: 'EPSG:4326',
21
+ projection: LonLat,
22
+ transformation: toTransformation(1 / 180, 1, -1 / 180, 0.5)
23
+ });
@@ -0,0 +1,33 @@
1
+ import {CRS} from './CRS';
2
+ import * as Util from '../../core/Util';
3
+
4
+ /*
5
+ * @namespace CRS
6
+ * @crs L.CRS.Earth
7
+ *
8
+ * Serves as the base for CRS that are global such that they cover the earth.
9
+ * Can only be used as the base for other CRS and cannot be used directly,
10
+ * since it does not have a `code`, `projection` or `transformation`. `distance()` returns
11
+ * meters.
12
+ */
13
+
14
+ export var Earth = Util.extend({}, CRS, {
15
+ wrapLng: [-180, 180],
16
+
17
+ // Mean Earth Radius, as recommended for use by
18
+ // the International Union of Geodesy and Geophysics,
19
+ // see https://rosettacode.org/wiki/Haversine_formula
20
+ R: 6371000,
21
+
22
+ // distance between two geographical points using spherical law of cosines approximation
23
+ distance: function (latlng1, latlng2) {
24
+ var rad = Math.PI / 180,
25
+ lat1 = latlng1.lat * rad,
26
+ lat2 = latlng2.lat * rad,
27
+ sinDLat = Math.sin((latlng2.lat - latlng1.lat) * rad / 2),
28
+ sinDLon = Math.sin((latlng2.lng - latlng1.lng) * rad / 2),
29
+ a = sinDLat * sinDLat + Math.cos(lat1) * Math.cos(lat2) * sinDLon * sinDLon,
30
+ c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a));
31
+ return this.R * c;
32
+ }
33
+ });
@@ -0,0 +1,36 @@
1
+ import {CRS} from './CRS';
2
+ import {LonLat} from '../projection/Projection.LonLat';
3
+ import {toTransformation} from '../../geometry/Transformation';
4
+ import * as Util from '../../core/Util';
5
+
6
+ /*
7
+ * @namespace CRS
8
+ * @crs L.CRS.Simple
9
+ *
10
+ * A simple CRS that maps longitude and latitude into `x` and `y` directly.
11
+ * May be used for maps of flat surfaces (e.g. game maps). Note that the `y`
12
+ * axis should still be inverted (going from bottom to top). `distance()` returns
13
+ * simple euclidean distance.
14
+ */
15
+
16
+ export var Simple = Util.extend({}, CRS, {
17
+ projection: LonLat,
18
+ transformation: toTransformation(1, 0, -1, 0),
19
+
20
+ scale: function (zoom) {
21
+ return Math.pow(2, zoom);
22
+ },
23
+
24
+ zoom: function (scale) {
25
+ return Math.log(scale) / Math.LN2;
26
+ },
27
+
28
+ distance: function (latlng1, latlng2) {
29
+ var dx = latlng2.lng - latlng1.lng,
30
+ dy = latlng2.lat - latlng1.lat;
31
+
32
+ return Math.sqrt(dx * dx + dy * dy);
33
+ },
34
+
35
+ infinite: true
36
+ });
@@ -0,0 +1,139 @@
1
+
2
+ import {Bounds} from '../../geometry/Bounds';
3
+ import {LatLng} from '../LatLng';
4
+ import {LatLngBounds} from '../LatLngBounds';
5
+ import * as Util from '../../core/Util';
6
+
7
+ /*
8
+ * @namespace CRS
9
+ * @crs L.CRS.Base
10
+ * Object that defines coordinate reference systems for projecting
11
+ * geographical points into pixel (screen) coordinates and back (and to
12
+ * coordinates in other units for [WMS](https://en.wikipedia.org/wiki/Web_Map_Service) services). See
13
+ * [spatial reference system](https://en.wikipedia.org/wiki/Spatial_reference_system).
14
+ *
15
+ * Leaflet defines the most usual CRSs by default. If you want to use a
16
+ * CRS not defined by default, take a look at the
17
+ * [Proj4Leaflet](https://github.com/kartena/Proj4Leaflet) plugin.
18
+ *
19
+ * Note that the CRS instances do not inherit from Leaflet's `Class` object,
20
+ * and can't be instantiated. Also, new classes can't inherit from them,
21
+ * and methods can't be added to them with the `include` function.
22
+ */
23
+
24
+ export var CRS = {
25
+ // @method latLngToPoint(latlng: LatLng, zoom: Number): Point
26
+ // Projects geographical coordinates into pixel coordinates for a given zoom.
27
+ latLngToPoint: function (latlng, zoom) {
28
+ var projectedPoint = this.projection.project(latlng),
29
+ scale = this.scale(zoom);
30
+
31
+ return this.transformation._transform(projectedPoint, scale);
32
+ },
33
+
34
+ // @method pointToLatLng(point: Point, zoom: Number): LatLng
35
+ // The inverse of `latLngToPoint`. Projects pixel coordinates on a given
36
+ // zoom into geographical coordinates.
37
+ pointToLatLng: function (point, zoom) {
38
+ var scale = this.scale(zoom),
39
+ untransformedPoint = this.transformation.untransform(point, scale);
40
+
41
+ return this.projection.unproject(untransformedPoint);
42
+ },
43
+
44
+ // @method project(latlng: LatLng): Point
45
+ // Projects geographical coordinates into coordinates in units accepted for
46
+ // this CRS (e.g. meters for EPSG:3857, for passing it to WMS services).
47
+ project: function (latlng) {
48
+ return this.projection.project(latlng);
49
+ },
50
+
51
+ // @method unproject(point: Point): LatLng
52
+ // Given a projected coordinate returns the corresponding LatLng.
53
+ // The inverse of `project`.
54
+ unproject: function (point) {
55
+ return this.projection.unproject(point);
56
+ },
57
+
58
+ // @method scale(zoom: Number): Number
59
+ // Returns the scale used when transforming projected coordinates into
60
+ // pixel coordinates for a particular zoom. For example, it returns
61
+ // `256 * 2^zoom` for Mercator-based CRS.
62
+ scale: function (zoom) {
63
+ return 256 * Math.pow(2, zoom);
64
+ },
65
+
66
+ // @method zoom(scale: Number): Number
67
+ // Inverse of `scale()`, returns the zoom level corresponding to a scale
68
+ // factor of `scale`.
69
+ zoom: function (scale) {
70
+ return Math.log(scale / 256) / Math.LN2;
71
+ },
72
+
73
+ // @method getProjectedBounds(zoom: Number): Bounds
74
+ // Returns the projection's bounds scaled and transformed for the provided `zoom`.
75
+ getProjectedBounds: function (zoom) {
76
+ if (this.infinite) { return null; }
77
+
78
+ var b = this.projection.bounds,
79
+ s = this.scale(zoom),
80
+ min = this.transformation.transform(b.min, s),
81
+ max = this.transformation.transform(b.max, s);
82
+
83
+ return new Bounds(min, max);
84
+ },
85
+
86
+ // @method distance(latlng1: LatLng, latlng2: LatLng): Number
87
+ // Returns the distance between two geographical coordinates.
88
+
89
+ // @property code: String
90
+ // Standard code name of the CRS passed into WMS services (e.g. `'EPSG:3857'`)
91
+ //
92
+ // @property wrapLng: Number[]
93
+ // An array of two numbers defining whether the longitude (horizontal) coordinate
94
+ // axis wraps around a given range and how. Defaults to `[-180, 180]` in most
95
+ // geographical CRSs. If `undefined`, the longitude axis does not wrap around.
96
+ //
97
+ // @property wrapLat: Number[]
98
+ // Like `wrapLng`, but for the latitude (vertical) axis.
99
+
100
+ // wrapLng: [min, max],
101
+ // wrapLat: [min, max],
102
+
103
+ // @property infinite: Boolean
104
+ // If true, the coordinate space will be unbounded (infinite in both axes)
105
+ infinite: false,
106
+
107
+ // @method wrapLatLng(latlng: LatLng): LatLng
108
+ // Returns a `LatLng` where lat and lng has been wrapped according to the
109
+ // CRS's `wrapLat` and `wrapLng` properties, if they are outside the CRS's bounds.
110
+ wrapLatLng: function (latlng) {
111
+ var lng = this.wrapLng ? Util.wrapNum(latlng.lng, this.wrapLng, true) : latlng.lng,
112
+ lat = this.wrapLat ? Util.wrapNum(latlng.lat, this.wrapLat, true) : latlng.lat,
113
+ alt = latlng.alt;
114
+
115
+ return new LatLng(lat, lng, alt);
116
+ },
117
+
118
+ // @method wrapLatLngBounds(bounds: LatLngBounds): LatLngBounds
119
+ // Returns a `LatLngBounds` with the same size as the given one, ensuring
120
+ // that its center is within the CRS's bounds.
121
+ // Only accepts actual `L.LatLngBounds` instances, not arrays.
122
+ wrapLatLngBounds: function (bounds) {
123
+ var center = bounds.getCenter(),
124
+ newCenter = this.wrapLatLng(center),
125
+ latShift = center.lat - newCenter.lat,
126
+ lngShift = center.lng - newCenter.lng;
127
+
128
+ if (latShift === 0 && lngShift === 0) {
129
+ return bounds;
130
+ }
131
+
132
+ var sw = bounds.getSouthWest(),
133
+ ne = bounds.getNorthEast(),
134
+ newSw = new LatLng(sw.lat - latShift, sw.lng - lngShift),
135
+ newNe = new LatLng(ne.lat - latShift, ne.lng - lngShift);
136
+
137
+ return new LatLngBounds(newSw, newNe);
138
+ }
139
+ };
@@ -0,0 +1,15 @@
1
+ import {CRS} from './CRS';
2
+ import {Earth} from './CRS.Earth';
3
+ import {EPSG3395} from './CRS.EPSG3395';
4
+ import {EPSG3857, EPSG900913} from './CRS.EPSG3857';
5
+ import {EPSG4326} from './CRS.EPSG4326';
6
+ import {Simple} from './CRS.Simple';
7
+
8
+ CRS.Earth = Earth;
9
+ CRS.EPSG3395 = EPSG3395;
10
+ CRS.EPSG3857 = EPSG3857;
11
+ CRS.EPSG900913 = EPSG900913;
12
+ CRS.EPSG4326 = EPSG4326;
13
+ CRS.Simple = Simple;
14
+
15
+ export {CRS};
@@ -0,0 +1,7 @@
1
+ export {LatLng, toLatLng as latLng} from './LatLng';
2
+ export {LatLngBounds, toLatLngBounds as latLngBounds} from './LatLngBounds';
3
+
4
+ import * as Projection from './projection/index';
5
+ export {Projection};
6
+
7
+ export * from './crs/index';
@@ -0,0 +1,28 @@
1
+ import {LatLng} from '../LatLng';
2
+ import {Bounds} from '../../geometry/Bounds';
3
+ import {Point} from '../../geometry/Point';
4
+
5
+ /*
6
+ * @namespace Projection
7
+ * @section
8
+ * Leaflet comes with a set of already defined Projections out of the box:
9
+ *
10
+ * @projection L.Projection.LonLat
11
+ *
12
+ * Equirectangular, or Plate Carree projection — the most simple projection,
13
+ * mostly used by GIS enthusiasts. Directly maps `x` as longitude, and `y` as
14
+ * latitude. Also suitable for flat worlds, e.g. game maps. Used by the
15
+ * `EPSG:4326` and `Simple` CRS.
16
+ */
17
+
18
+ export var LonLat = {
19
+ project: function (latlng) {
20
+ return new Point(latlng.lng, latlng.lat);
21
+ },
22
+
23
+ unproject: function (point) {
24
+ return new LatLng(point.y, point.x);
25
+ },
26
+
27
+ bounds: new Bounds([-180, -90], [180, 90])
28
+ };
@@ -0,0 +1,49 @@
1
+ import {LatLng} from '../LatLng';
2
+ import {Bounds} from '../../geometry/Bounds';
3
+ import {Point} from '../../geometry/Point';
4
+
5
+ /*
6
+ * @namespace Projection
7
+ * @projection L.Projection.Mercator
8
+ *
9
+ * Elliptical Mercator projection — more complex than Spherical Mercator. Assumes that Earth is an ellipsoid. Used by the EPSG:3395 CRS.
10
+ */
11
+
12
+ export var Mercator = {
13
+ R: 6378137,
14
+ R_MINOR: 6356752.314245179,
15
+
16
+ bounds: new Bounds([-20037508.34279, -15496570.73972], [20037508.34279, 18764656.23138]),
17
+
18
+ project: function (latlng) {
19
+ var d = Math.PI / 180,
20
+ r = this.R,
21
+ y = latlng.lat * d,
22
+ tmp = this.R_MINOR / r,
23
+ e = Math.sqrt(1 - tmp * tmp),
24
+ con = e * Math.sin(y);
25
+
26
+ var ts = Math.tan(Math.PI / 4 - y / 2) / Math.pow((1 - con) / (1 + con), e / 2);
27
+ y = -r * Math.log(Math.max(ts, 1E-10));
28
+
29
+ return new Point(latlng.lng * d * r, y);
30
+ },
31
+
32
+ unproject: function (point) {
33
+ var d = 180 / Math.PI,
34
+ r = this.R,
35
+ tmp = this.R_MINOR / r,
36
+ e = Math.sqrt(1 - tmp * tmp),
37
+ ts = Math.exp(-point.y / r),
38
+ phi = Math.PI / 2 - 2 * Math.atan(ts);
39
+
40
+ for (var i = 0, dphi = 0.1, con; i < 15 && Math.abs(dphi) > 1e-7; i++) {
41
+ con = e * Math.sin(phi);
42
+ con = Math.pow((1 - con) / (1 + con), e / 2);
43
+ dphi = Math.PI / 2 - 2 * Math.atan(ts * con) - phi;
44
+ phi += dphi;
45
+ }
46
+
47
+ return new LatLng(phi * d, point.x * d / r);
48
+ }
49
+ };
@@ -0,0 +1,44 @@
1
+ import {LatLng} from '../LatLng';
2
+ import {Bounds} from '../../geometry/Bounds';
3
+ import {Point} from '../../geometry/Point';
4
+
5
+ /*
6
+ * @namespace Projection
7
+ * @projection L.Projection.SphericalMercator
8
+ *
9
+ * Spherical Mercator projection — the most common projection for online maps,
10
+ * used by almost all free and commercial tile providers. Assumes that Earth is
11
+ * a sphere. Used by the `EPSG:3857` CRS.
12
+ */
13
+
14
+ var earthRadius = 6378137;
15
+
16
+ export var SphericalMercator = {
17
+
18
+ R: earthRadius,
19
+ MAX_LATITUDE: 85.0511287798,
20
+
21
+ project: function (latlng) {
22
+ var d = Math.PI / 180,
23
+ max = this.MAX_LATITUDE,
24
+ lat = Math.max(Math.min(max, latlng.lat), -max),
25
+ sin = Math.sin(lat * d);
26
+
27
+ return new Point(
28
+ this.R * latlng.lng * d,
29
+ this.R * Math.log((1 + sin) / (1 - sin)) / 2);
30
+ },
31
+
32
+ unproject: function (point) {
33
+ var d = 180 / Math.PI;
34
+
35
+ return new LatLng(
36
+ (2 * Math.atan(Math.exp(point.y / this.R)) - (Math.PI / 2)) * d,
37
+ point.x * d / this.R);
38
+ },
39
+
40
+ bounds: (function () {
41
+ var d = earthRadius * Math.PI;
42
+ return new Bounds([-d, -d], [d, d]);
43
+ })()
44
+ };