decidim 0.26.9 → 0.26.10
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of decidim might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/lib/decidim/version.rb +1 -1
- data/package-lock.json +7 -7
- data/packages/browserslist-config/package.json +1 -1
- data/packages/core/node_modules/leaflet/CHANGELOG.md +2191 -0
- data/packages/core/node_modules/leaflet/LICENSE +26 -0
- data/packages/core/node_modules/leaflet/README.md +55 -0
- data/packages/core/node_modules/leaflet/dist/images/layers-2x.png +0 -0
- data/packages/core/node_modules/leaflet/dist/images/layers.png +0 -0
- data/packages/core/node_modules/leaflet/dist/images/marker-icon-2x.png +0 -0
- data/packages/core/node_modules/leaflet/dist/images/marker-icon.png +0 -0
- data/packages/core/node_modules/leaflet/dist/images/marker-shadow.png +0 -0
- data/packages/core/node_modules/leaflet/dist/leaflet-src.esm.js +14419 -0
- data/packages/core/node_modules/leaflet/dist/leaflet-src.esm.js.map +1 -0
- data/packages/core/node_modules/leaflet/dist/leaflet-src.js +14512 -0
- data/packages/core/node_modules/leaflet/dist/leaflet-src.js.map +1 -0
- data/packages/core/node_modules/leaflet/dist/leaflet.css +661 -0
- data/packages/core/node_modules/leaflet/dist/leaflet.js +6 -0
- data/packages/core/node_modules/leaflet/dist/leaflet.js.map +1 -0
- data/packages/core/node_modules/leaflet/package.json +149 -0
- data/packages/core/node_modules/leaflet/src/Leaflet.js +24 -0
- data/packages/core/node_modules/leaflet/src/control/Control.Attribution.js +148 -0
- data/packages/core/node_modules/leaflet/src/control/Control.Layers.js +443 -0
- data/packages/core/node_modules/leaflet/src/control/Control.Scale.js +132 -0
- data/packages/core/node_modules/leaflet/src/control/Control.Zoom.js +146 -0
- data/packages/core/node_modules/leaflet/src/control/Control.js +174 -0
- data/packages/core/node_modules/leaflet/src/control/index.js +17 -0
- data/packages/core/node_modules/leaflet/src/core/Browser.js +220 -0
- data/packages/core/node_modules/leaflet/src/core/Class.js +135 -0
- data/packages/core/node_modules/leaflet/src/core/Class.leafdoc +197 -0
- data/packages/core/node_modules/leaflet/src/core/Events.js +344 -0
- data/packages/core/node_modules/leaflet/src/core/Events.leafdoc +143 -0
- data/packages/core/node_modules/leaflet/src/core/Handler.js +57 -0
- data/packages/core/node_modules/leaflet/src/core/Util.js +241 -0
- data/packages/core/node_modules/leaflet/src/core/index.js +15 -0
- data/packages/core/node_modules/leaflet/src/dom/DomEvent.DoubleTap.js +91 -0
- data/packages/core/node_modules/leaflet/src/dom/DomEvent.Pointer.js +97 -0
- data/packages/core/node_modules/leaflet/src/dom/DomEvent.js +315 -0
- data/packages/core/node_modules/leaflet/src/dom/DomUtil.js +349 -0
- data/packages/core/node_modules/leaflet/src/dom/Draggable.js +220 -0
- data/packages/core/node_modules/leaflet/src/dom/PosAnimation.js +113 -0
- data/packages/core/node_modules/leaflet/src/dom/index.js +9 -0
- data/packages/core/node_modules/leaflet/src/geo/LatLng.js +137 -0
- data/packages/core/node_modules/leaflet/src/geo/LatLngBounds.js +251 -0
- data/packages/core/node_modules/leaflet/src/geo/crs/CRS.EPSG3395.js +20 -0
- data/packages/core/node_modules/leaflet/src/geo/crs/CRS.EPSG3857.js +27 -0
- data/packages/core/node_modules/leaflet/src/geo/crs/CRS.EPSG4326.js +23 -0
- data/packages/core/node_modules/leaflet/src/geo/crs/CRS.Earth.js +33 -0
- data/packages/core/node_modules/leaflet/src/geo/crs/CRS.Simple.js +36 -0
- data/packages/core/node_modules/leaflet/src/geo/crs/CRS.js +139 -0
- data/packages/core/node_modules/leaflet/src/geo/crs/index.js +15 -0
- data/packages/core/node_modules/leaflet/src/geo/index.js +7 -0
- data/packages/core/node_modules/leaflet/src/geo/projection/Projection.LonLat.js +28 -0
- data/packages/core/node_modules/leaflet/src/geo/projection/Projection.Mercator.js +49 -0
- data/packages/core/node_modules/leaflet/src/geo/projection/Projection.SphericalMercator.js +44 -0
- data/packages/core/node_modules/leaflet/src/geo/projection/index.js +26 -0
- data/packages/core/node_modules/leaflet/src/geometry/Bounds.js +219 -0
- data/packages/core/node_modules/leaflet/src/geometry/LineUtil.js +306 -0
- data/packages/core/node_modules/leaflet/src/geometry/Point.js +222 -0
- data/packages/core/node_modules/leaflet/src/geometry/PolyUtil.js +129 -0
- data/packages/core/node_modules/leaflet/src/geometry/Transformation.js +79 -0
- data/packages/core/node_modules/leaflet/src/geometry/index.js +8 -0
- data/packages/core/node_modules/leaflet/src/images/layers.svg +1 -0
- data/packages/core/node_modules/leaflet/src/images/logo.svg +1 -0
- data/packages/core/node_modules/leaflet/src/images/marker.svg +1 -0
- data/packages/core/node_modules/leaflet/src/layer/DivOverlay.js +348 -0
- data/packages/core/node_modules/leaflet/src/layer/FeatureGroup.js +94 -0
- data/packages/core/node_modules/leaflet/src/layer/GeoJSON.js +452 -0
- data/packages/core/node_modules/leaflet/src/layer/ImageOverlay.js +270 -0
- data/packages/core/node_modules/leaflet/src/layer/Layer.Interactive.leafdoc +39 -0
- data/packages/core/node_modules/leaflet/src/layer/Layer.js +275 -0
- data/packages/core/node_modules/leaflet/src/layer/LayerGroup.js +159 -0
- data/packages/core/node_modules/leaflet/src/layer/Popup.js +506 -0
- data/packages/core/node_modules/leaflet/src/layer/SVGOverlay.js +50 -0
- data/packages/core/node_modules/leaflet/src/layer/Tooltip.js +444 -0
- data/packages/core/node_modules/leaflet/src/layer/VideoOverlay.js +106 -0
- data/packages/core/node_modules/leaflet/src/layer/index.js +24 -0
- data/packages/core/node_modules/leaflet/src/layer/marker/DivIcon.js +74 -0
- data/packages/core/node_modules/leaflet/src/layer/marker/Icon.Default.js +66 -0
- data/packages/core/node_modules/leaflet/src/layer/marker/Icon.js +165 -0
- data/packages/core/node_modules/leaflet/src/layer/marker/Marker.Drag.js +161 -0
- data/packages/core/node_modules/leaflet/src/layer/marker/Marker.js +419 -0
- data/packages/core/node_modules/leaflet/src/layer/marker/index.js +8 -0
- data/packages/core/node_modules/leaflet/src/layer/tile/GridLayer.js +923 -0
- data/packages/core/node_modules/leaflet/src/layer/tile/TileLayer.WMS.js +137 -0
- data/packages/core/node_modules/leaflet/src/layer/tile/TileLayer.js +289 -0
- data/packages/core/node_modules/leaflet/src/layer/tile/index.js +6 -0
- data/packages/core/node_modules/leaflet/src/layer/vector/Canvas.js +492 -0
- data/packages/core/node_modules/leaflet/src/layer/vector/Circle.js +113 -0
- data/packages/core/node_modules/leaflet/src/layer/vector/CircleMarker.js +109 -0
- data/packages/core/node_modules/leaflet/src/layer/vector/Path.js +148 -0
- data/packages/core/node_modules/leaflet/src/layer/vector/Polygon.js +159 -0
- data/packages/core/node_modules/leaflet/src/layer/vector/Polyline.js +307 -0
- data/packages/core/node_modules/leaflet/src/layer/vector/Rectangle.js +57 -0
- data/packages/core/node_modules/leaflet/src/layer/vector/Renderer.getRenderer.js +45 -0
- data/packages/core/node_modules/leaflet/src/layer/vector/Renderer.js +133 -0
- data/packages/core/node_modules/leaflet/src/layer/vector/SVG.Util.js +39 -0
- data/packages/core/node_modules/leaflet/src/layer/vector/SVG.VML.js +144 -0
- data/packages/core/node_modules/leaflet/src/layer/vector/SVG.js +207 -0
- data/packages/core/node_modules/leaflet/src/layer/vector/index.js +14 -0
- data/packages/core/node_modules/leaflet/src/map/Map.js +1751 -0
- data/packages/core/node_modules/leaflet/src/map/Map.methodOptions.leafdoc +112 -0
- data/packages/core/node_modules/leaflet/src/map/handler/Map.BoxZoom.js +152 -0
- data/packages/core/node_modules/leaflet/src/map/handler/Map.DoubleClickZoom.js +55 -0
- data/packages/core/node_modules/leaflet/src/map/handler/Map.Drag.js +235 -0
- data/packages/core/node_modules/leaflet/src/map/handler/Map.Keyboard.js +183 -0
- data/packages/core/node_modules/leaflet/src/map/handler/Map.ScrollWheelZoom.js +91 -0
- data/packages/core/node_modules/leaflet/src/map/handler/Map.TapHold.js +102 -0
- data/packages/core/node_modules/leaflet/src/map/handler/Map.TouchZoom.js +130 -0
- data/packages/core/node_modules/leaflet/src/map/index.js +17 -0
- data/packages/core/package.json +1 -1
- data/packages/dev/package.json +1 -1
- data/packages/elections/package.json +1 -1
- data/packages/eslint-config/package.json +1 -1
- data/packages/stylelint-config/package.json +1 -1
- data/packages/webpacker/package.json +1 -1
- metadata +148 -42
@@ -0,0 +1,222 @@
|
|
1
|
+
import {isArray, formatNum} from '../core/Util';
|
2
|
+
|
3
|
+
/*
|
4
|
+
* @class Point
|
5
|
+
* @aka L.Point
|
6
|
+
*
|
7
|
+
* Represents a point with `x` and `y` coordinates in pixels.
|
8
|
+
*
|
9
|
+
* @example
|
10
|
+
*
|
11
|
+
* ```js
|
12
|
+
* var point = L.point(200, 300);
|
13
|
+
* ```
|
14
|
+
*
|
15
|
+
* All Leaflet methods and options that accept `Point` objects also accept them in a simple Array form (unless noted otherwise), so these lines are equivalent:
|
16
|
+
*
|
17
|
+
* ```js
|
18
|
+
* map.panBy([200, 300]);
|
19
|
+
* map.panBy(L.point(200, 300));
|
20
|
+
* ```
|
21
|
+
*
|
22
|
+
* Note that `Point` does not inherit from Leaflet's `Class` object,
|
23
|
+
* which means new classes can't inherit from it, and new methods
|
24
|
+
* can't be added to it with the `include` function.
|
25
|
+
*/
|
26
|
+
|
27
|
+
export function Point(x, y, round) {
|
28
|
+
// @property x: Number; The `x` coordinate of the point
|
29
|
+
this.x = (round ? Math.round(x) : x);
|
30
|
+
// @property y: Number; The `y` coordinate of the point
|
31
|
+
this.y = (round ? Math.round(y) : y);
|
32
|
+
}
|
33
|
+
|
34
|
+
var trunc = Math.trunc || function (v) {
|
35
|
+
return v > 0 ? Math.floor(v) : Math.ceil(v);
|
36
|
+
};
|
37
|
+
|
38
|
+
Point.prototype = {
|
39
|
+
|
40
|
+
// @method clone(): Point
|
41
|
+
// Returns a copy of the current point.
|
42
|
+
clone: function () {
|
43
|
+
return new Point(this.x, this.y);
|
44
|
+
},
|
45
|
+
|
46
|
+
// @method add(otherPoint: Point): Point
|
47
|
+
// Returns the result of addition of the current and the given points.
|
48
|
+
add: function (point) {
|
49
|
+
// non-destructive, returns a new point
|
50
|
+
return this.clone()._add(toPoint(point));
|
51
|
+
},
|
52
|
+
|
53
|
+
_add: function (point) {
|
54
|
+
// destructive, used directly for performance in situations where it's safe to modify existing point
|
55
|
+
this.x += point.x;
|
56
|
+
this.y += point.y;
|
57
|
+
return this;
|
58
|
+
},
|
59
|
+
|
60
|
+
// @method subtract(otherPoint: Point): Point
|
61
|
+
// Returns the result of subtraction of the given point from the current.
|
62
|
+
subtract: function (point) {
|
63
|
+
return this.clone()._subtract(toPoint(point));
|
64
|
+
},
|
65
|
+
|
66
|
+
_subtract: function (point) {
|
67
|
+
this.x -= point.x;
|
68
|
+
this.y -= point.y;
|
69
|
+
return this;
|
70
|
+
},
|
71
|
+
|
72
|
+
// @method divideBy(num: Number): Point
|
73
|
+
// Returns the result of division of the current point by the given number.
|
74
|
+
divideBy: function (num) {
|
75
|
+
return this.clone()._divideBy(num);
|
76
|
+
},
|
77
|
+
|
78
|
+
_divideBy: function (num) {
|
79
|
+
this.x /= num;
|
80
|
+
this.y /= num;
|
81
|
+
return this;
|
82
|
+
},
|
83
|
+
|
84
|
+
// @method multiplyBy(num: Number): Point
|
85
|
+
// Returns the result of multiplication of the current point by the given number.
|
86
|
+
multiplyBy: function (num) {
|
87
|
+
return this.clone()._multiplyBy(num);
|
88
|
+
},
|
89
|
+
|
90
|
+
_multiplyBy: function (num) {
|
91
|
+
this.x *= num;
|
92
|
+
this.y *= num;
|
93
|
+
return this;
|
94
|
+
},
|
95
|
+
|
96
|
+
// @method scaleBy(scale: Point): Point
|
97
|
+
// Multiply each coordinate of the current point by each coordinate of
|
98
|
+
// `scale`. In linear algebra terms, multiply the point by the
|
99
|
+
// [scaling matrix](https://en.wikipedia.org/wiki/Scaling_%28geometry%29#Matrix_representation)
|
100
|
+
// defined by `scale`.
|
101
|
+
scaleBy: function (point) {
|
102
|
+
return new Point(this.x * point.x, this.y * point.y);
|
103
|
+
},
|
104
|
+
|
105
|
+
// @method unscaleBy(scale: Point): Point
|
106
|
+
// Inverse of `scaleBy`. Divide each coordinate of the current point by
|
107
|
+
// each coordinate of `scale`.
|
108
|
+
unscaleBy: function (point) {
|
109
|
+
return new Point(this.x / point.x, this.y / point.y);
|
110
|
+
},
|
111
|
+
|
112
|
+
// @method round(): Point
|
113
|
+
// Returns a copy of the current point with rounded coordinates.
|
114
|
+
round: function () {
|
115
|
+
return this.clone()._round();
|
116
|
+
},
|
117
|
+
|
118
|
+
_round: function () {
|
119
|
+
this.x = Math.round(this.x);
|
120
|
+
this.y = Math.round(this.y);
|
121
|
+
return this;
|
122
|
+
},
|
123
|
+
|
124
|
+
// @method floor(): Point
|
125
|
+
// Returns a copy of the current point with floored coordinates (rounded down).
|
126
|
+
floor: function () {
|
127
|
+
return this.clone()._floor();
|
128
|
+
},
|
129
|
+
|
130
|
+
_floor: function () {
|
131
|
+
this.x = Math.floor(this.x);
|
132
|
+
this.y = Math.floor(this.y);
|
133
|
+
return this;
|
134
|
+
},
|
135
|
+
|
136
|
+
// @method ceil(): Point
|
137
|
+
// Returns a copy of the current point with ceiled coordinates (rounded up).
|
138
|
+
ceil: function () {
|
139
|
+
return this.clone()._ceil();
|
140
|
+
},
|
141
|
+
|
142
|
+
_ceil: function () {
|
143
|
+
this.x = Math.ceil(this.x);
|
144
|
+
this.y = Math.ceil(this.y);
|
145
|
+
return this;
|
146
|
+
},
|
147
|
+
|
148
|
+
// @method trunc(): Point
|
149
|
+
// Returns a copy of the current point with truncated coordinates (rounded towards zero).
|
150
|
+
trunc: function () {
|
151
|
+
return this.clone()._trunc();
|
152
|
+
},
|
153
|
+
|
154
|
+
_trunc: function () {
|
155
|
+
this.x = trunc(this.x);
|
156
|
+
this.y = trunc(this.y);
|
157
|
+
return this;
|
158
|
+
},
|
159
|
+
|
160
|
+
// @method distanceTo(otherPoint: Point): Number
|
161
|
+
// Returns the cartesian distance between the current and the given points.
|
162
|
+
distanceTo: function (point) {
|
163
|
+
point = toPoint(point);
|
164
|
+
|
165
|
+
var x = point.x - this.x,
|
166
|
+
y = point.y - this.y;
|
167
|
+
|
168
|
+
return Math.sqrt(x * x + y * y);
|
169
|
+
},
|
170
|
+
|
171
|
+
// @method equals(otherPoint: Point): Boolean
|
172
|
+
// Returns `true` if the given point has the same coordinates.
|
173
|
+
equals: function (point) {
|
174
|
+
point = toPoint(point);
|
175
|
+
|
176
|
+
return point.x === this.x &&
|
177
|
+
point.y === this.y;
|
178
|
+
},
|
179
|
+
|
180
|
+
// @method contains(otherPoint: Point): Boolean
|
181
|
+
// Returns `true` if both coordinates of the given point are less than the corresponding current point coordinates (in absolute values).
|
182
|
+
contains: function (point) {
|
183
|
+
point = toPoint(point);
|
184
|
+
|
185
|
+
return Math.abs(point.x) <= Math.abs(this.x) &&
|
186
|
+
Math.abs(point.y) <= Math.abs(this.y);
|
187
|
+
},
|
188
|
+
|
189
|
+
// @method toString(): String
|
190
|
+
// Returns a string representation of the point for debugging purposes.
|
191
|
+
toString: function () {
|
192
|
+
return 'Point(' +
|
193
|
+
formatNum(this.x) + ', ' +
|
194
|
+
formatNum(this.y) + ')';
|
195
|
+
}
|
196
|
+
};
|
197
|
+
|
198
|
+
// @factory L.point(x: Number, y: Number, round?: Boolean)
|
199
|
+
// Creates a Point object with the given `x` and `y` coordinates. If optional `round` is set to true, rounds the `x` and `y` values.
|
200
|
+
|
201
|
+
// @alternative
|
202
|
+
// @factory L.point(coords: Number[])
|
203
|
+
// Expects an array of the form `[x, y]` instead.
|
204
|
+
|
205
|
+
// @alternative
|
206
|
+
// @factory L.point(coords: Object)
|
207
|
+
// Expects a plain object of the form `{x: Number, y: Number}` instead.
|
208
|
+
export function toPoint(x, y, round) {
|
209
|
+
if (x instanceof Point) {
|
210
|
+
return x;
|
211
|
+
}
|
212
|
+
if (isArray(x)) {
|
213
|
+
return new Point(x[0], x[1]);
|
214
|
+
}
|
215
|
+
if (x === undefined || x === null) {
|
216
|
+
return x;
|
217
|
+
}
|
218
|
+
if (typeof x === 'object' && 'x' in x && 'y' in x) {
|
219
|
+
return new Point(x.x, x.y);
|
220
|
+
}
|
221
|
+
return new Point(x, y, round);
|
222
|
+
}
|
@@ -0,0 +1,129 @@
|
|
1
|
+
import * as LineUtil from './LineUtil';
|
2
|
+
import {toLatLng} from '../geo/LatLng';
|
3
|
+
import {toPoint} from './Point';
|
4
|
+
import {toLatLngBounds} from '../geo/LatLngBounds';
|
5
|
+
/*
|
6
|
+
* @namespace PolyUtil
|
7
|
+
* Various utility functions for polygon geometries.
|
8
|
+
*/
|
9
|
+
|
10
|
+
/* @function clipPolygon(points: Point[], bounds: Bounds, round?: Boolean): Point[]
|
11
|
+
* Clips the polygon geometry defined by the given `points` by the given bounds (using the [Sutherland-Hodgman algorithm](https://en.wikipedia.org/wiki/Sutherland%E2%80%93Hodgman_algorithm)).
|
12
|
+
* Used by Leaflet to only show polygon points that are on the screen or near, increasing
|
13
|
+
* performance. Note that polygon points needs different algorithm for clipping
|
14
|
+
* than polyline, so there's a separate method for it.
|
15
|
+
*/
|
16
|
+
export function clipPolygon(points, bounds, round) {
|
17
|
+
var clippedPoints,
|
18
|
+
edges = [1, 4, 2, 8],
|
19
|
+
i, j, k,
|
20
|
+
a, b,
|
21
|
+
len, edge, p;
|
22
|
+
|
23
|
+
for (i = 0, len = points.length; i < len; i++) {
|
24
|
+
points[i]._code = LineUtil._getBitCode(points[i], bounds);
|
25
|
+
}
|
26
|
+
|
27
|
+
// for each edge (left, bottom, right, top)
|
28
|
+
for (k = 0; k < 4; k++) {
|
29
|
+
edge = edges[k];
|
30
|
+
clippedPoints = [];
|
31
|
+
|
32
|
+
for (i = 0, len = points.length, j = len - 1; i < len; j = i++) {
|
33
|
+
a = points[i];
|
34
|
+
b = points[j];
|
35
|
+
|
36
|
+
// if a is inside the clip window
|
37
|
+
if (!(a._code & edge)) {
|
38
|
+
// if b is outside the clip window (a->b goes out of screen)
|
39
|
+
if (b._code & edge) {
|
40
|
+
p = LineUtil._getEdgeIntersection(b, a, edge, bounds, round);
|
41
|
+
p._code = LineUtil._getBitCode(p, bounds);
|
42
|
+
clippedPoints.push(p);
|
43
|
+
}
|
44
|
+
clippedPoints.push(a);
|
45
|
+
|
46
|
+
// else if b is inside the clip window (a->b enters the screen)
|
47
|
+
} else if (!(b._code & edge)) {
|
48
|
+
p = LineUtil._getEdgeIntersection(b, a, edge, bounds, round);
|
49
|
+
p._code = LineUtil._getBitCode(p, bounds);
|
50
|
+
clippedPoints.push(p);
|
51
|
+
}
|
52
|
+
}
|
53
|
+
points = clippedPoints;
|
54
|
+
}
|
55
|
+
|
56
|
+
return points;
|
57
|
+
}
|
58
|
+
|
59
|
+
/* @function polygonCenter(latlngs: LatLng[], crs: CRS): LatLng
|
60
|
+
* Returns the center ([centroid](http://en.wikipedia.org/wiki/Centroid)) of the passed LatLngs (first ring) from a polygon.
|
61
|
+
*/
|
62
|
+
export function polygonCenter(latlngs, crs) {
|
63
|
+
var i, j, p1, p2, f, area, x, y, center;
|
64
|
+
|
65
|
+
if (!latlngs || latlngs.length === 0) {
|
66
|
+
throw new Error('latlngs not passed');
|
67
|
+
}
|
68
|
+
|
69
|
+
if (!LineUtil.isFlat(latlngs)) {
|
70
|
+
console.warn('latlngs are not flat! Only the first ring will be used');
|
71
|
+
latlngs = latlngs[0];
|
72
|
+
}
|
73
|
+
|
74
|
+
var centroidLatLng = toLatLng([0, 0]);
|
75
|
+
|
76
|
+
var bounds = toLatLngBounds(latlngs);
|
77
|
+
var areaBounds = bounds.getNorthWest().distanceTo(bounds.getSouthWest()) * bounds.getNorthEast().distanceTo(bounds.getNorthWest());
|
78
|
+
// tests showed that below 1700 rounding errors are happening
|
79
|
+
if (areaBounds < 1700) {
|
80
|
+
// getting a inexact center, to move the latlngs near to [0, 0] to prevent rounding errors
|
81
|
+
centroidLatLng = centroid(latlngs);
|
82
|
+
}
|
83
|
+
|
84
|
+
var len = latlngs.length;
|
85
|
+
var points = [];
|
86
|
+
for (i = 0; i < len; i++) {
|
87
|
+
var latlng = toLatLng(latlngs[i]);
|
88
|
+
points.push(crs.project(toLatLng([latlng.lat - centroidLatLng.lat, latlng.lng - centroidLatLng.lng])));
|
89
|
+
}
|
90
|
+
|
91
|
+
area = x = y = 0;
|
92
|
+
|
93
|
+
// polygon centroid algorithm;
|
94
|
+
for (i = 0, j = len - 1; i < len; j = i++) {
|
95
|
+
p1 = points[i];
|
96
|
+
p2 = points[j];
|
97
|
+
|
98
|
+
f = p1.y * p2.x - p2.y * p1.x;
|
99
|
+
x += (p1.x + p2.x) * f;
|
100
|
+
y += (p1.y + p2.y) * f;
|
101
|
+
area += f * 3;
|
102
|
+
}
|
103
|
+
|
104
|
+
if (area === 0) {
|
105
|
+
// Polygon is so small that all points are on same pixel.
|
106
|
+
center = points[0];
|
107
|
+
} else {
|
108
|
+
center = [x / area, y / area];
|
109
|
+
}
|
110
|
+
|
111
|
+
var latlngCenter = crs.unproject(toPoint(center));
|
112
|
+
return toLatLng([latlngCenter.lat + centroidLatLng.lat, latlngCenter.lng + centroidLatLng.lng]);
|
113
|
+
}
|
114
|
+
|
115
|
+
/* @function centroid(latlngs: LatLng[]): LatLng
|
116
|
+
* Returns the 'center of mass' of the passed LatLngs.
|
117
|
+
*/
|
118
|
+
export function centroid(coords) {
|
119
|
+
var latSum = 0;
|
120
|
+
var lngSum = 0;
|
121
|
+
var len = 0;
|
122
|
+
for (var i = 0; i < coords.length; i++) {
|
123
|
+
var latlng = toLatLng(coords[i]);
|
124
|
+
latSum += latlng.lat;
|
125
|
+
lngSum += latlng.lng;
|
126
|
+
len++;
|
127
|
+
}
|
128
|
+
return toLatLng([latSum / len, lngSum / len]);
|
129
|
+
}
|
@@ -0,0 +1,79 @@
|
|
1
|
+
import {Point} from './Point';
|
2
|
+
import * as Util from '../core/Util';
|
3
|
+
|
4
|
+
/*
|
5
|
+
* @class Transformation
|
6
|
+
* @aka L.Transformation
|
7
|
+
*
|
8
|
+
* Represents an affine transformation: a set of coefficients `a`, `b`, `c`, `d`
|
9
|
+
* for transforming a point of a form `(x, y)` into `(a*x + b, c*y + d)` and doing
|
10
|
+
* the reverse. Used by Leaflet in its projections code.
|
11
|
+
*
|
12
|
+
* @example
|
13
|
+
*
|
14
|
+
* ```js
|
15
|
+
* var transformation = L.transformation(2, 5, -1, 10),
|
16
|
+
* p = L.point(1, 2),
|
17
|
+
* p2 = transformation.transform(p), // L.point(7, 8)
|
18
|
+
* p3 = transformation.untransform(p2); // L.point(1, 2)
|
19
|
+
* ```
|
20
|
+
*/
|
21
|
+
|
22
|
+
|
23
|
+
// factory new L.Transformation(a: Number, b: Number, c: Number, d: Number)
|
24
|
+
// Creates a `Transformation` object with the given coefficients.
|
25
|
+
export function Transformation(a, b, c, d) {
|
26
|
+
if (Util.isArray(a)) {
|
27
|
+
// use array properties
|
28
|
+
this._a = a[0];
|
29
|
+
this._b = a[1];
|
30
|
+
this._c = a[2];
|
31
|
+
this._d = a[3];
|
32
|
+
return;
|
33
|
+
}
|
34
|
+
this._a = a;
|
35
|
+
this._b = b;
|
36
|
+
this._c = c;
|
37
|
+
this._d = d;
|
38
|
+
}
|
39
|
+
|
40
|
+
Transformation.prototype = {
|
41
|
+
// @method transform(point: Point, scale?: Number): Point
|
42
|
+
// Returns a transformed point, optionally multiplied by the given scale.
|
43
|
+
// Only accepts actual `L.Point` instances, not arrays.
|
44
|
+
transform: function (point, scale) { // (Point, Number) -> Point
|
45
|
+
return this._transform(point.clone(), scale);
|
46
|
+
},
|
47
|
+
|
48
|
+
// destructive transform (faster)
|
49
|
+
_transform: function (point, scale) {
|
50
|
+
scale = scale || 1;
|
51
|
+
point.x = scale * (this._a * point.x + this._b);
|
52
|
+
point.y = scale * (this._c * point.y + this._d);
|
53
|
+
return point;
|
54
|
+
},
|
55
|
+
|
56
|
+
// @method untransform(point: Point, scale?: Number): Point
|
57
|
+
// Returns the reverse transformation of the given point, optionally divided
|
58
|
+
// by the given scale. Only accepts actual `L.Point` instances, not arrays.
|
59
|
+
untransform: function (point, scale) {
|
60
|
+
scale = scale || 1;
|
61
|
+
return new Point(
|
62
|
+
(point.x / scale - this._b) / this._a,
|
63
|
+
(point.y / scale - this._d) / this._c);
|
64
|
+
}
|
65
|
+
};
|
66
|
+
|
67
|
+
// factory L.transformation(a: Number, b: Number, c: Number, d: Number)
|
68
|
+
|
69
|
+
// @factory L.transformation(a: Number, b: Number, c: Number, d: Number)
|
70
|
+
// Instantiates a Transformation object with the given coefficients.
|
71
|
+
|
72
|
+
// @alternative
|
73
|
+
// @factory L.transformation(coefficients: Array): Transformation
|
74
|
+
// Expects an coefficients array of the form
|
75
|
+
// `[a: Number, b: Number, c: Number, d: Number]`.
|
76
|
+
|
77
|
+
export function toTransformation(a, b, c, d) {
|
78
|
+
return new Transformation(a, b, c, d);
|
79
|
+
}
|
@@ -0,0 +1,8 @@
|
|
1
|
+
export {Point, toPoint as point} from './Point';
|
2
|
+
export {Bounds, toBounds as bounds} from './Bounds';
|
3
|
+
export {Transformation, toTransformation as transformation} from './Transformation';
|
4
|
+
|
5
|
+
import * as LineUtil from './LineUtil';
|
6
|
+
export {LineUtil};
|
7
|
+
import * as PolyUtil from './PolyUtil';
|
8
|
+
export {PolyUtil};
|
@@ -0,0 +1 @@
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" height="26" width="26"><path d="M.032 17.056l13-8 13 8-13 8-13-8" fill="#b9b9b9"/><path d="M.032 17.056l-.032.93 13 8 13-8 .032-.93-13 8z" fill="#737373"/><path d="M0 13.076l13-8 13 8-13 8-13-8" fill="#cdcdcd"/><path d="M0 13.076v.91l13 8 13-8v-.91l-13 8z" fill="#737373"/><path d="M0 8.986l13-8 13 8-13 8-13-8" fill-opacity=".585" stroke="#797979" stroke-width=".1" fill="#e9e9e9"/><path d="M0 8.986v1l13 8 13-8v-1l-13 8z" fill="#737373"/></svg>
|
@@ -0,0 +1 @@
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" width="909.493" height="241.328"><path fill="#6f6f6e" d="M138.146 154.633c-16.973 17.26-34.34 25.89-52.1 25.89-5.156 0-10.116-.665-14.878-1.99-4.764-1.323-10.564-3.56-17.402-6.712-6.84-3.15-12.874-5.44-18.1-6.87-9.67 10.6-18.407 15.9-26.212 15.9-2.723 0-4.98-.89-6.768-2.68C.896 176.37 0 174.19 0 171.61c0-5.44 2.667-10.225 8.003-14.34 5.334-4.12 12.872-6.967 22.612-8.54 4.082-5.59 6.695-11.05 7.842-16.386 1.145-5.33 2.04-14.12 2.686-26.37 1.217-25.203 7.966-44.952 20.25-59.24 12.28-14.286 25.62-21.43 40.014-21.43 9.883 0 17.993 3.134 24.33 9.4 6.34 6.267 9.508 14.27 9.508 24.01 0 11.242-3.33 21.09-9.99 29.54s-14.324 12.675-22.988 12.675c-4.512 0-8.057-1.24-10.635-3.71-2.578-2.47-3.867-5.86-3.867-10.15 0-2.22.43-4.8 1.29-7.74 1.933 2.22 4.366 3.33 7.304 3.33 4.86 0 9.13-2.9 12.78-8.7 3.65-5.8 5.48-12.71 5.48-20.74 0-6.16-1.4-11.01-4.19-14.56-2.79-3.55-6.62-5.32-11.48-5.32-5.87 0-10.43 2.11-13.69 6.34s-5.53 9.272-6.82 15.15c-1.29 5.87-2.66 15.36-4.12 28.47-1.46 13.1-3.89 24.72-7.3 34.852-3.42 10.13-9.79 20.065-19.13 29.8 6.09-.43 11.37-.07 15.84 1.08 4.47 1.143 10.88 3.31 19.23 6.495 8.34 3.19 15.52 4.78 21.53 4.78 11.74 0 22.95-6.01 33.62-18.04v12.35zm80.244 0c-9.096 8.953-17.26 15.56-24.492 19.818-7.234 4.26-15.22 6.4-23.955 6.4-9.74 0-17.6-3.11-23.58-9.34-5.98-6.23-8.97-14.43-8.97-24.6 0-15.18 5.265-28.91 15.792-41.19 10.527-12.28 22.2-18.42 35.02-18.42 6.66 0 11.994 1.72 16.006 5.16 4.01 3.44 6.02 7.95 6.02 13.54 0 14.83-15.75 26.86-47.26 36.1 2.87 13.97 10.35 20.95 22.45 20.95 4.73 0 9.24-1.27 13.54-3.81 4.3-2.54 10.78-8.18 19.45-16.92v12.36zM162.1 134.76c18.333-5.156 27.5-14.68 27.5-28.575 0-6.875-2.507-10.313-7.52-10.313-4.726 0-9.237 3.6-13.534 10.796-4.297 7.197-6.445 16.562-6.445 28.092zm171.017 19.873c-11.46 10.887-19.658 17.977-24.6 21.27-4.942 3.293-9.668 4.94-14.18 4.94-11.316 0-16.65-9.99-16.006-29.97-7.16 10.242-13.76 17.797-19.81 22.666-6.05 4.86-12.3 7.3-18.74 7.3-6.3 0-11.65-2.96-16.06-8.87-4.4-5.91-6.6-13.16-6.6-21.75 0-10.75 2.96-20.99 8.87-30.73 5.91-9.74 13.48-17.62 22.72-23.64 9.24-6.02 17.4-9.03 24.49-9.03 8.95 0 15.22 4.12 18.8 12.35l21.96-12.14h6.03l-9.47 31.48c-4.88 15.83-7.32 26.68-7.32 32.55 0 6.15 2.18 9.23 6.55 9.23 2.79 0 5.87-1.49 9.23-4.46 3.36-2.97 8.09-7.5 14.17-13.59v12.36zm-78.633 5.908c7.16 0 13.91-6.1 20.25-18.31 6.337-12.21 9.506-23.47 9.506-33.78 0-4.01-.896-7.14-2.686-9.4-1.79-2.25-4.19-3.38-7.197-3.38-7.162 0-13.948 6.09-20.356 18.27-6.41 12.18-9.61 23.39-9.61 33.63 0 3.87.95 7 2.85 9.4 1.9 2.4 4.31 3.6 7.25 3.6zm165.752-5.9c-7.44 8.38-14.808 14.84-22.104 19.39-7.296 4.55-13.806 6.82-19.53 6.82-2.718 0-6.437-1.03-11.157-3.1-3.02 15.75-5.682 32.76-7.983 51.01-7.456 1.01-16.417 2.55-26.882 4.63 2.29-19.62 6.266-45.08 11.922-76.37-.79-1.36-2.186-4.79-4.19-10.31l-7.195 7.95h-2.47v-9.67l20.478-21.23c3.892-19.21 7.056-33.12 9.492-41.71 2.434-8.59 5.836-18.1 10.205-28.52 4.367-10.42 7.125-16.4 8.27-17.94 1.146-1.54 3.922-3.01 8.326-4.4 4.404-1.39 9.112-2.72 14.126-3.97 5.012-1.25 7.697-1.88 8.057-1.88 2.73 0 4.95 1.77 6.66 5.32 1.72 3.54 2.58 8.21 2.58 14.007 0 10.02-2.64 19.677-7.93 28.977s-15.29 20.74-30 34.334l-9.03 44.9c3.5 7.51 8.76 11.267 15.76 11.267 10.01 0 20.88-7.27 32.6-21.81v12.357zM384.16 93.41c8.372-7.305 14.937-15.164 19.698-23.58 4.76-8.415 7.14-16.168 7.14-23.26 0-3.007-.554-5.478-1.66-7.41-1.107-1.935-2.48-2.9-4.122-2.9-3.142 0-6.338 4.12-9.586 12.36-3.25 8.24-7.073 23.17-11.47 44.79zm107.082 61.23c-9.74 8.95-18.28 15.56-25.62 19.816-7.342 4.26-14.34 6.395-21 6.395-7.665 0-13.842-2.97-18.53-8.91-4.692-5.94-7.037-13.93-7.037-23.95 0-15.04 3.258-33.08 9.775-54.14 6.516-21.05 14.43-40.46 23.74-58.22l27.285-10.1c.86-.28 1.504-.43 1.934-.43 2.07 0 3.77 1.53 5.1 4.57 1.32 3.05 1.98 7.15 1.98 12.3 0 14.61-3.37 28.76-10.1 42.44-6.73 13.68-17.26 28.29-31.58 43.83-.58 7.45-.86 12.57-.86 15.36 0 6.23 1.14 11.17 3.44 14.83 2.29 3.65 5.33 5.48 9.13 5.48 3.87 0 7.98-1.4 12.35-4.19 4.36-2.79 11.02-8.59 19.98-17.4v12.356zM450.1 112.63c9.093-10.11 16.47-21.442 22.128-33.994 5.656-12.55 8.486-23.342 8.486-32.38 0-2.653-.395-4.786-1.182-6.4-.79-1.614-1.79-2.42-3.008-2.42-2.65 0-6.5 6.597-11.548 19.793-5.048 13.19-10.008 31.66-14.877 55.4zm121.493 42.003c-9.096 8.953-17.26 15.56-24.492 19.818-7.23 4.26-15.21 6.4-23.95 6.4-9.74 0-17.6-3.11-23.58-9.34-5.98-6.23-8.97-14.43-8.97-24.6 0-15.18 5.27-28.91 15.79-41.19 10.53-12.28 22.2-18.42 35.02-18.42 6.66 0 12 1.72 16.01 5.16 4.01 3.44 6.02 7.95 6.02 13.54 0 14.83-15.75 26.86-47.26 36.1 2.87 13.97 10.35 20.95 22.45 20.95 4.73 0 9.24-1.27 13.54-3.81 4.3-2.54 10.78-8.18 19.45-16.92v12.36zm-56.29-19.873c18.333-5.156 27.5-14.68 27.5-28.575 0-6.875-2.507-10.313-7.52-10.313-4.726 0-9.237 3.6-13.534 10.796-4.3 7.197-6.45 16.562-6.45 28.092zm118.165 19.873c-9.023 8.953-16.83 15.56-23.418 19.818-6.59 4.26-12.855 6.4-18.8 6.4-6.16 0-11.154-2.59-14.984-7.79-3.832-5.19-5.747-12.01-5.747-20.46 0-7.44 1.83-17.28 5.51-29.5l4.56-16.26-8.25.43 3.44-16.86 10.21-.43 10.08-33.52 28.69-5.89-11.1 37.36 15.17-.86-3.55 16.55-16.67 1.29-7.16 24.07c-2.49 8.37-3.73 15.02-3.73 19.97 0 3.37.84 6.11 2.52 8.23 1.682 2.12 3.85 3.17 6.51 3.17 3.653 0 7.28-1.16 10.86-3.49 3.59-2.32 8.86-7.18 15.82-14.55v12.35z"/><linearGradient id="a" x1="1603.924" x2="1698.034" y1="1483.083" y2="1483.083" gradientUnits="userSpaceOnUse" gradientTransform="rotate(9.6 9049.018 -4722.716)"><stop offset="0" stop-color="#89C442"/><stop offset="1" stop-color="#74B844"/></linearGradient><path fill="url(#a)" d="M674.318 92.395c2.234 2.608 46.097 17.218 61.347 34.97 15.25 17.754 21.907 33.598 19.754 48.832-2.15 15.234-11.47 14.982-15.54 20.53-4.07 5.547-9.69 12.388-20.49 11.66-14.14-.948-28.72-8.014-39.25-32.54-10.53-24.527-9.72-47.567-8.88-60.35.84-12.78 3.04-23.102 3.04-23.102z"/><linearGradient id="b" x1="1606.047" x2="1687.254" y1="1478.166" y2="1478.166" gradientUnits="userSpaceOnUse" gradientTransform="rotate(9.6 1169.206 -709.023)"><stop offset="0" stop-color="#74B844"/><stop offset="1" stop-color="#4A9634"/></linearGradient><path fill="url(#b)" d="M1239.667 1476.602l65.69 97.927-3.028 3.38" transform="translate(-567.983 -1376)"/><path fill="#3c3c3b" fill-rule="evenodd" d="M419.922 236.713l.618-4.337c17.52-9.335 39.344-12.934 57.105-21.945 5.328 2.4 7.697-1.06 13.38-.74 2.062 1.86-2.594 4.35 2.974 3.97 12.65 1.68 24.97-.68 37.41-1.74 13.12-1.12 26.15.13 39.02-.63 4.11-.24 10.44-5.93 15.48-3.1 2.28 4.13-7.44 4.49-4.83 9.05 25.76 6.06 90.19 31.68 101.21 3.81.15 1.7-1.93 5.06 1.11 4.59 21.72-9.72 58.63-30.71 65.13-36.21 7.14-6.04 16.66-5.85 26-8 16.82-3.87 34.77-7.81 49.33-16.29 9 6.25 27.84 9.36 37.91 7.18 10.51-2.28 26.82-19.73 35.55-25.9 3.43-2.42 8.45-7.13 12.14-4.46-2.48 1.7.44 6.68-2.6 5.82-1.59-3.04-4.76.47-7.07-.12-8.79 7.21-17.92 13.96-26.88 20.94-4.18 2.57 4.03 5.23-.87 6.07-23.14 4.6-58.38-6.92-72.968 9.07-23.115 7.91-44.98 9.92-67.76 22.2-13.09 7.06-29.108 19.9-42.734 26.65-2.31 1.15-5.693 1.55-8.423 3.23-3.32 2.04-4.136 4.6-6.937 5.204-6.98 1.503-21.4-2.14-30.48-3.46-30.28-4.4-62.61-16.746-91.184-18.31-11.3-.62-24.64 1.17-37.412 1.744-27.15 1.226-44.13 1.87-65.9 9.19-8.9 2.997-22.59 10.93-28.364 6.58z" clip-rule="evenodd"/><linearGradient id="c" x1="1280.966" x2="1438.704" y1="1562.831" y2="1562.831" gradientUnits="userSpaceOnUse" gradientTransform="rotate(161.46 940.413 -772.15)"><stop offset="0" stop-color="#C1EA71"/><stop offset="1" stop-color="#ACDA55"/></linearGradient><path fill="url(#c)" d="M839.46 0c-3.05 4.944-72.6 40.807-93.475 74.472-20.873 33.665-26.828 60.172-19.26 85.09 7.566 24.914 22.03 23.792 30.275 32.008 8.246 8.22 19.432 18.193 37.3 14.166 23.395-5.275 45.94-20.89 57.155-64.65 11.214-43.762 3.86-82.083-.88-103.242C845.838 16.687 839.462 0 839.462 0z"/><linearGradient id="d" x1="1284.556" x2="1422.002" y1="1554.398" y2="1554.398" gradientUnits="userSpaceOnUse" gradientTransform="rotate(161.46 1112.102 -37.725)"><stop offset="0" stop-color="#ACDA55"/><stop offset="1" stop-color="#89C442"/></linearGradient><path fill="url(#d)" d="M1406.26 1383.39l-84.338 180.893 4.95 4.97" transform="translate(-567.983 -1376)"/></svg>
|
@@ -0,0 +1 @@
|
|
1
|
+
<svg viewBox="0 0 500 820" version="1.1" xmlns="http://www.w3.org/2000/svg" xml:space="preserve" style="fill-rule: evenodd; clip-rule: evenodd; stroke-linecap: round;"><defs><linearGradient x1="0" y1="0" x2="1" y2="0" gradientUnits="userSpaceOnUse" gradientTransform="matrix(2.30025e-15,-37.566,37.566,2.30025e-15,416.455,540.999)" id="map-marker-38-f"><stop offset="0" stop-color="rgb(18,111,198)"/><stop offset="1" stop-color="rgb(76,156,209)"/></linearGradient><linearGradient x1="0" y1="0" x2="1" y2="0" gradientUnits="userSpaceOnUse" gradientTransform="matrix(1.16666e-15,-19.053,19.053,1.16666e-15,414.482,522.486)" id="map-marker-38-s"><stop offset="0" stop-color="rgb(46,108,151)"/><stop offset="1" stop-color="rgb(56,131,183)"/></linearGradient></defs><g transform="matrix(19.5417,0,0,19.5417,-7889.1,-9807.44)"><path d="M416.544,503.612C409.971,503.612 404.5,509.303 404.5,515.478C404.5,518.256 406.064,521.786 407.194,524.224L416.5,542.096L425.762,524.224C426.892,521.786 428.5,518.433 428.5,515.478C428.5,509.303 423.117,503.612 416.544,503.612ZM416.544,510.767C419.128,510.784 421.223,512.889 421.223,515.477C421.223,518.065 419.128,520.14 416.544,520.156C413.96,520.139 411.865,518.066 411.865,515.477C411.865,512.889 413.96,510.784 416.544,510.767Z" stroke-width="1.1px" fill="url(#map-marker-38-f)" stroke="url(#map-marker-38-s)"/></g></svg>
|