@vaadin/bundles 23.0.9 → 23.0.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/node_modules_ol_ImageCanvas_js.js +121 -0
- package/node_modules_ol_ImageCanvas_js.js.map +1 -0
- package/node_modules_ol_ImageTile_js.js +177 -0
- package/node_modules_ol_ImageTile_js.js.map +1 -0
- package/node_modules_ol_TileRange_js.js +154 -0
- package/node_modules_ol_TileRange_js.js.map +1 -0
- package/node_modules_ol_VectorRenderTile_js.js +182 -0
- package/node_modules_ol_VectorRenderTile_js.js.map +1 -0
- package/node_modules_ol_VectorTile_js.js +158 -0
- package/node_modules_ol_VectorTile_js.js.map +1 -0
- package/node_modules_ol_geom_flat_geodesic_js.js +171 -0
- package/node_modules_ol_geom_flat_geodesic_js.js.map +1 -0
- package/node_modules_ol_render_js.js +131 -0
- package/node_modules_ol_render_js.js.map +1 -0
- package/node_modules_ol_structs_LRUCache_js.js +275 -0
- package/node_modules_ol_structs_LRUCache_js.js.map +1 -0
- package/node_modules_ol_style_js.js +47 -0
- package/node_modules_ol_style_js.js.map +1 -0
- package/node_modules_ol_tilecoord_js.js +115 -0
- package/node_modules_ol_tilecoord_js.js.map +1 -0
- package/package.json +146 -119
- package/vaadin-bundle.json +2571 -949
- package/vaadin.js +83552 -36675
- package/vaadin.js.map +1 -1
- package/vendors-node_modules_ol_Geolocation_js.js +379 -0
- package/vendors-node_modules_ol_Geolocation_js.js.map +1 -0
- package/vendors-node_modules_ol_TileCache_js.js +461 -0
- package/vendors-node_modules_ol_TileCache_js.js.map +1 -0
- package/vendors-node_modules_ol_Tile_js.js +330 -0
- package/vendors-node_modules_ol_Tile_js.js.map +1 -0
- package/vendors-node_modules_ol_index_js.js +874 -0
- package/vendors-node_modules_ol_index_js.js.map +1 -0
- package/vendors-node_modules_ol_layer_Graticule_js.js +1359 -0
- package/vendors-node_modules_ol_layer_Graticule_js.js.map +1 -0
- package/vendors-node_modules_ol_style_Text_js.js +509 -0
- package/vendors-node_modules_ol_style_Text_js.js.map +1 -0
- package/vendors-node_modules_rbush_index_js.js +531 -0
- package/vendors-node_modules_rbush_index_js.js.map +1 -0
|
@@ -0,0 +1,1359 @@
|
|
|
1
|
+
(self["webpackChunk_vaadin_bundles"] = self["webpackChunk_vaadin_bundles"] || []).push([["vendors-node_modules_ol_layer_Graticule_js"],{
|
|
2
|
+
|
|
3
|
+
/***/ "./node_modules/ol/geom/flat/geodesic.js":
|
|
4
|
+
/*!***********************************************!*\
|
|
5
|
+
!*** ./node_modules/ol/geom/flat/geodesic.js ***!
|
|
6
|
+
\***********************************************/
|
|
7
|
+
/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
|
|
8
|
+
|
|
9
|
+
__webpack_require__.r(__webpack_exports__);
|
|
10
|
+
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
11
|
+
/* harmony export */ "greatCircleArc": () => (/* binding */ greatCircleArc),
|
|
12
|
+
/* harmony export */ "meridian": () => (/* binding */ meridian),
|
|
13
|
+
/* harmony export */ "parallel": () => (/* binding */ parallel)
|
|
14
|
+
/* harmony export */ });
|
|
15
|
+
/* harmony import */ var _proj_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../proj.js */ "./node_modules/ol/proj.js");
|
|
16
|
+
/* harmony import */ var _math_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../math.js */ "./node_modules/ol/math.js");
|
|
17
|
+
/**
|
|
18
|
+
* @module ol/geom/flat/geodesic
|
|
19
|
+
*/
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* @param {function(number): import("../../coordinate.js").Coordinate} interpolate Interpolate function.
|
|
24
|
+
* @param {import("../../proj.js").TransformFunction} transform Transform from longitude/latitude to
|
|
25
|
+
* projected coordinates.
|
|
26
|
+
* @param {number} squaredTolerance Squared tolerance.
|
|
27
|
+
* @return {Array<number>} Flat coordinates.
|
|
28
|
+
*/
|
|
29
|
+
function line(interpolate, transform, squaredTolerance) {
|
|
30
|
+
// FIXME reduce garbage generation
|
|
31
|
+
// FIXME optimize stack operations
|
|
32
|
+
/** @type {Array<number>} */
|
|
33
|
+
var flatCoordinates = [];
|
|
34
|
+
var geoA = interpolate(0);
|
|
35
|
+
var geoB = interpolate(1);
|
|
36
|
+
var a = transform(geoA);
|
|
37
|
+
var b = transform(geoB);
|
|
38
|
+
/** @type {Array<import("../../coordinate.js").Coordinate>} */
|
|
39
|
+
var geoStack = [geoB, geoA];
|
|
40
|
+
/** @type {Array<import("../../coordinate.js").Coordinate>} */
|
|
41
|
+
var stack = [b, a];
|
|
42
|
+
/** @type {Array<number>} */
|
|
43
|
+
var fractionStack = [1, 0];
|
|
44
|
+
/** @type {!Object<string, boolean>} */
|
|
45
|
+
var fractions = {};
|
|
46
|
+
var maxIterations = 1e5;
|
|
47
|
+
var geoM, m, fracA, fracB, fracM, key;
|
|
48
|
+
while (--maxIterations > 0 && fractionStack.length > 0) {
|
|
49
|
+
// Pop the a coordinate off the stack
|
|
50
|
+
fracA = fractionStack.pop();
|
|
51
|
+
geoA = geoStack.pop();
|
|
52
|
+
a = stack.pop();
|
|
53
|
+
// Add the a coordinate if it has not been added yet
|
|
54
|
+
key = fracA.toString();
|
|
55
|
+
if (!(key in fractions)) {
|
|
56
|
+
flatCoordinates.push(a[0], a[1]);
|
|
57
|
+
fractions[key] = true;
|
|
58
|
+
}
|
|
59
|
+
// Pop the b coordinate off the stack
|
|
60
|
+
fracB = fractionStack.pop();
|
|
61
|
+
geoB = geoStack.pop();
|
|
62
|
+
b = stack.pop();
|
|
63
|
+
// Find the m point between the a and b coordinates
|
|
64
|
+
fracM = (fracA + fracB) / 2;
|
|
65
|
+
geoM = interpolate(fracM);
|
|
66
|
+
m = transform(geoM);
|
|
67
|
+
if ((0,_math_js__WEBPACK_IMPORTED_MODULE_1__.squaredSegmentDistance)(m[0], m[1], a[0], a[1], b[0], b[1]) <
|
|
68
|
+
squaredTolerance) {
|
|
69
|
+
// If the m point is sufficiently close to the straight line, then we
|
|
70
|
+
// discard it. Just use the b coordinate and move on to the next line
|
|
71
|
+
// segment.
|
|
72
|
+
flatCoordinates.push(b[0], b[1]);
|
|
73
|
+
key = fracB.toString();
|
|
74
|
+
fractions[key] = true;
|
|
75
|
+
}
|
|
76
|
+
else {
|
|
77
|
+
// Otherwise, we need to subdivide the current line segment. Split it
|
|
78
|
+
// into two and push the two line segments onto the stack.
|
|
79
|
+
fractionStack.push(fracB, fracM, fracM, fracA);
|
|
80
|
+
stack.push(b, m, m, a);
|
|
81
|
+
geoStack.push(geoB, geoM, geoM, geoA);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
return flatCoordinates;
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Generate a great-circle arcs between two lat/lon points.
|
|
88
|
+
* @param {number} lon1 Longitude 1 in degrees.
|
|
89
|
+
* @param {number} lat1 Latitude 1 in degrees.
|
|
90
|
+
* @param {number} lon2 Longitude 2 in degrees.
|
|
91
|
+
* @param {number} lat2 Latitude 2 in degrees.
|
|
92
|
+
* @param {import("../../proj/Projection.js").default} projection Projection.
|
|
93
|
+
* @param {number} squaredTolerance Squared tolerance.
|
|
94
|
+
* @return {Array<number>} Flat coordinates.
|
|
95
|
+
*/
|
|
96
|
+
function greatCircleArc(lon1, lat1, lon2, lat2, projection, squaredTolerance) {
|
|
97
|
+
var geoProjection = (0,_proj_js__WEBPACK_IMPORTED_MODULE_0__.get)('EPSG:4326');
|
|
98
|
+
var cosLat1 = Math.cos((0,_math_js__WEBPACK_IMPORTED_MODULE_1__.toRadians)(lat1));
|
|
99
|
+
var sinLat1 = Math.sin((0,_math_js__WEBPACK_IMPORTED_MODULE_1__.toRadians)(lat1));
|
|
100
|
+
var cosLat2 = Math.cos((0,_math_js__WEBPACK_IMPORTED_MODULE_1__.toRadians)(lat2));
|
|
101
|
+
var sinLat2 = Math.sin((0,_math_js__WEBPACK_IMPORTED_MODULE_1__.toRadians)(lat2));
|
|
102
|
+
var cosDeltaLon = Math.cos((0,_math_js__WEBPACK_IMPORTED_MODULE_1__.toRadians)(lon2 - lon1));
|
|
103
|
+
var sinDeltaLon = Math.sin((0,_math_js__WEBPACK_IMPORTED_MODULE_1__.toRadians)(lon2 - lon1));
|
|
104
|
+
var d = sinLat1 * sinLat2 + cosLat1 * cosLat2 * cosDeltaLon;
|
|
105
|
+
return line(
|
|
106
|
+
/**
|
|
107
|
+
* @param {number} frac Fraction.
|
|
108
|
+
* @return {import("../../coordinate.js").Coordinate} Coordinate.
|
|
109
|
+
*/
|
|
110
|
+
function (frac) {
|
|
111
|
+
if (1 <= d) {
|
|
112
|
+
return [lon2, lat2];
|
|
113
|
+
}
|
|
114
|
+
var D = frac * Math.acos(d);
|
|
115
|
+
var cosD = Math.cos(D);
|
|
116
|
+
var sinD = Math.sin(D);
|
|
117
|
+
var y = sinDeltaLon * cosLat2;
|
|
118
|
+
var x = cosLat1 * sinLat2 - sinLat1 * cosLat2 * cosDeltaLon;
|
|
119
|
+
var theta = Math.atan2(y, x);
|
|
120
|
+
var lat = Math.asin(sinLat1 * cosD + cosLat1 * sinD * Math.cos(theta));
|
|
121
|
+
var lon = (0,_math_js__WEBPACK_IMPORTED_MODULE_1__.toRadians)(lon1) +
|
|
122
|
+
Math.atan2(Math.sin(theta) * sinD * cosLat1, cosD - sinLat1 * Math.sin(lat));
|
|
123
|
+
return [(0,_math_js__WEBPACK_IMPORTED_MODULE_1__.toDegrees)(lon), (0,_math_js__WEBPACK_IMPORTED_MODULE_1__.toDegrees)(lat)];
|
|
124
|
+
}, (0,_proj_js__WEBPACK_IMPORTED_MODULE_0__.getTransform)(geoProjection, projection), squaredTolerance);
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* Generate a meridian (line at constant longitude).
|
|
128
|
+
* @param {number} lon Longitude.
|
|
129
|
+
* @param {number} lat1 Latitude 1.
|
|
130
|
+
* @param {number} lat2 Latitude 2.
|
|
131
|
+
* @param {import("../../proj/Projection.js").default} projection Projection.
|
|
132
|
+
* @param {number} squaredTolerance Squared tolerance.
|
|
133
|
+
* @return {Array<number>} Flat coordinates.
|
|
134
|
+
*/
|
|
135
|
+
function meridian(lon, lat1, lat2, projection, squaredTolerance) {
|
|
136
|
+
var epsg4326Projection = (0,_proj_js__WEBPACK_IMPORTED_MODULE_0__.get)('EPSG:4326');
|
|
137
|
+
return line(
|
|
138
|
+
/**
|
|
139
|
+
* @param {number} frac Fraction.
|
|
140
|
+
* @return {import("../../coordinate.js").Coordinate} Coordinate.
|
|
141
|
+
*/
|
|
142
|
+
function (frac) {
|
|
143
|
+
return [lon, lat1 + (lat2 - lat1) * frac];
|
|
144
|
+
}, (0,_proj_js__WEBPACK_IMPORTED_MODULE_0__.getTransform)(epsg4326Projection, projection), squaredTolerance);
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
147
|
+
* Generate a parallel (line at constant latitude).
|
|
148
|
+
* @param {number} lat Latitude.
|
|
149
|
+
* @param {number} lon1 Longitude 1.
|
|
150
|
+
* @param {number} lon2 Longitude 2.
|
|
151
|
+
* @param {import("../../proj/Projection.js").default} projection Projection.
|
|
152
|
+
* @param {number} squaredTolerance Squared tolerance.
|
|
153
|
+
* @return {Array<number>} Flat coordinates.
|
|
154
|
+
*/
|
|
155
|
+
function parallel(lat, lon1, lon2, projection, squaredTolerance) {
|
|
156
|
+
var epsg4326Projection = (0,_proj_js__WEBPACK_IMPORTED_MODULE_0__.get)('EPSG:4326');
|
|
157
|
+
return line(
|
|
158
|
+
/**
|
|
159
|
+
* @param {number} frac Fraction.
|
|
160
|
+
* @return {import("../../coordinate.js").Coordinate} Coordinate.
|
|
161
|
+
*/
|
|
162
|
+
function (frac) {
|
|
163
|
+
return [lon1 + (lon2 - lon1) * frac, lat];
|
|
164
|
+
}, (0,_proj_js__WEBPACK_IMPORTED_MODULE_0__.getTransform)(epsg4326Projection, projection), squaredTolerance);
|
|
165
|
+
}
|
|
166
|
+
//# sourceMappingURL=geodesic.js.map
|
|
167
|
+
|
|
168
|
+
/***/ }),
|
|
169
|
+
|
|
170
|
+
/***/ "./node_modules/ol/layer/Graticule.js":
|
|
171
|
+
/*!********************************************!*\
|
|
172
|
+
!*** ./node_modules/ol/layer/Graticule.js ***!
|
|
173
|
+
\********************************************/
|
|
174
|
+
/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
|
|
175
|
+
|
|
176
|
+
__webpack_require__.r(__webpack_exports__);
|
|
177
|
+
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
178
|
+
/* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
|
|
179
|
+
/* harmony export */ });
|
|
180
|
+
/* harmony import */ var _Collection_js__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Collection.js */ "./node_modules/ol/Collection.js");
|
|
181
|
+
/* harmony import */ var _render_EventType_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../render/EventType.js */ "./node_modules/ol/render/EventType.js");
|
|
182
|
+
/* harmony import */ var _Feature_js__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../Feature.js */ "./node_modules/ol/Feature.js");
|
|
183
|
+
/* harmony import */ var _style_Fill_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../style/Fill.js */ "./node_modules/ol/style/Fill.js");
|
|
184
|
+
/* harmony import */ var _geom_GeometryLayout_js__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ../geom/GeometryLayout.js */ "./node_modules/ol/geom/GeometryLayout.js");
|
|
185
|
+
/* harmony import */ var _geom_LineString_js__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ../geom/LineString.js */ "./node_modules/ol/geom/LineString.js");
|
|
186
|
+
/* harmony import */ var _geom_Point_js__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../geom/Point.js */ "./node_modules/ol/geom/Point.js");
|
|
187
|
+
/* harmony import */ var _style_Stroke_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../style/Stroke.js */ "./node_modules/ol/style/Stroke.js");
|
|
188
|
+
/* harmony import */ var _style_Style_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../style/Style.js */ "./node_modules/ol/style/Style.js");
|
|
189
|
+
/* harmony import */ var _style_Text_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../style/Text.js */ "./node_modules/ol/style/Text.js");
|
|
190
|
+
/* harmony import */ var _Vector_js__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ./Vector.js */ "./node_modules/ol/layer/Vector.js");
|
|
191
|
+
/* harmony import */ var _source_Vector_js__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../source/Vector.js */ "./node_modules/ol/source/Vector.js");
|
|
192
|
+
/* harmony import */ var _extent_js__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../extent.js */ "./node_modules/ol/extent.js");
|
|
193
|
+
/* harmony import */ var _obj_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../obj.js */ "./node_modules/ol/obj.js");
|
|
194
|
+
/* harmony import */ var _math_js__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../math.js */ "./node_modules/ol/math.js");
|
|
195
|
+
/* harmony import */ var _coordinate_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../coordinate.js */ "./node_modules/ol/coordinate.js");
|
|
196
|
+
/* harmony import */ var _proj_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../proj.js */ "./node_modules/ol/proj.js");
|
|
197
|
+
/* harmony import */ var _render_js__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../render.js */ "./node_modules/ol/render.js");
|
|
198
|
+
/* harmony import */ var _geom_flat_geodesic_js__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ../geom/flat/geodesic.js */ "./node_modules/ol/geom/flat/geodesic.js");
|
|
199
|
+
var __extends = (undefined && undefined.__extends) || (function () {
|
|
200
|
+
var extendStatics = function (d, b) {
|
|
201
|
+
extendStatics = Object.setPrototypeOf ||
|
|
202
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
203
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
204
|
+
return extendStatics(d, b);
|
|
205
|
+
};
|
|
206
|
+
return function (d, b) {
|
|
207
|
+
if (typeof b !== "function" && b !== null)
|
|
208
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
209
|
+
extendStatics(d, b);
|
|
210
|
+
function __() { this.constructor = d; }
|
|
211
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
212
|
+
};
|
|
213
|
+
})();
|
|
214
|
+
/**
|
|
215
|
+
* @module ol/layer/Graticule
|
|
216
|
+
*/
|
|
217
|
+
|
|
218
|
+
|
|
219
|
+
|
|
220
|
+
|
|
221
|
+
|
|
222
|
+
|
|
223
|
+
|
|
224
|
+
|
|
225
|
+
|
|
226
|
+
|
|
227
|
+
|
|
228
|
+
|
|
229
|
+
|
|
230
|
+
|
|
231
|
+
|
|
232
|
+
|
|
233
|
+
|
|
234
|
+
|
|
235
|
+
|
|
236
|
+
/**
|
|
237
|
+
* @type {Stroke}
|
|
238
|
+
* @private
|
|
239
|
+
* @const
|
|
240
|
+
*/
|
|
241
|
+
var DEFAULT_STROKE_STYLE = new _style_Stroke_js__WEBPACK_IMPORTED_MODULE_1__["default"]({
|
|
242
|
+
color: 'rgba(0,0,0,0.2)',
|
|
243
|
+
});
|
|
244
|
+
/**
|
|
245
|
+
* @type {Array<number>}
|
|
246
|
+
* @private
|
|
247
|
+
*/
|
|
248
|
+
var INTERVALS = [
|
|
249
|
+
90, 45, 30, 20, 10, 5, 2, 1, 0.5, 0.2, 0.1, 0.05, 0.01, 0.005, 0.002, 0.001,
|
|
250
|
+
];
|
|
251
|
+
/**
|
|
252
|
+
* @typedef {Object} GraticuleLabelDataType
|
|
253
|
+
* @property {Point} geom Geometry.
|
|
254
|
+
* @property {string} text Text.
|
|
255
|
+
*/
|
|
256
|
+
/**
|
|
257
|
+
* @typedef {Object} Options
|
|
258
|
+
* @property {string} [className='ol-layer'] A CSS class name to set to the layer element.
|
|
259
|
+
* @property {number} [opacity=1] Opacity (0, 1).
|
|
260
|
+
* @property {boolean} [visible=true] Visibility.
|
|
261
|
+
* @property {import("../extent.js").Extent} [extent] The bounding extent for layer rendering. The layer will not be
|
|
262
|
+
* rendered outside of this extent.
|
|
263
|
+
* @property {number} [zIndex] The z-index for layer rendering. At rendering time, the layers
|
|
264
|
+
* will be ordered, first by Z-index and then by position. When `undefined`, a `zIndex` of 0 is assumed
|
|
265
|
+
* for layers that are added to the map's `layers` collection, or `Infinity` when the layer's `setMap()`
|
|
266
|
+
* method was used.
|
|
267
|
+
* @property {number} [minResolution] The minimum resolution (inclusive) at which this layer will be
|
|
268
|
+
* visible.
|
|
269
|
+
* @property {number} [maxResolution] The maximum resolution (exclusive) below which this layer will
|
|
270
|
+
* be visible.
|
|
271
|
+
* @property {number} [minZoom] The minimum view zoom level (exclusive) above which this layer will be
|
|
272
|
+
* visible.
|
|
273
|
+
* @property {number} [maxZoom] The maximum view zoom level (inclusive) at which this layer will
|
|
274
|
+
* be visible.
|
|
275
|
+
* @property {number} [maxLines=100] The maximum number of meridians and
|
|
276
|
+
* parallels from the center of the map. The default value of 100 means that at
|
|
277
|
+
* most 200 meridians and 200 parallels will be displayed. The default value is
|
|
278
|
+
* appropriate for conformal projections like Spherical Mercator. If you
|
|
279
|
+
* increase the value, more lines will be drawn and the drawing performance will
|
|
280
|
+
* decrease.
|
|
281
|
+
* @property {Stroke} [strokeStyle] The
|
|
282
|
+
* stroke style to use for drawing the graticule. If not provided, the following stroke will be used:
|
|
283
|
+
* ```js
|
|
284
|
+
* new Stroke({
|
|
285
|
+
* color: 'rgba(0, 0, 0, 0.2)' // a not fully opaque black
|
|
286
|
+
* });
|
|
287
|
+
* ```
|
|
288
|
+
* @property {number} [targetSize=100] The target size of the graticule cells,
|
|
289
|
+
* in pixels.
|
|
290
|
+
* @property {boolean} [showLabels=false] Render a label with the respective
|
|
291
|
+
* latitude/longitude for each graticule line.
|
|
292
|
+
* @property {function(number):string} [lonLabelFormatter] Label formatter for
|
|
293
|
+
* longitudes. This function is called with the longitude as argument, and
|
|
294
|
+
* should return a formatted string representing the longitude. By default,
|
|
295
|
+
* labels are formatted as degrees, minutes, seconds and hemisphere.
|
|
296
|
+
* @property {function(number):string} [latLabelFormatter] Label formatter for
|
|
297
|
+
* latitudes. This function is called with the latitude as argument, and
|
|
298
|
+
* should return a formatted string representing the latitude. By default,
|
|
299
|
+
* labels are formatted as degrees, minutes, seconds and hemisphere.
|
|
300
|
+
* @property {number} [lonLabelPosition=0] Longitude label position in fractions
|
|
301
|
+
* (0..1) of view extent. 0 means at the bottom of the viewport, 1 means at the
|
|
302
|
+
* top.
|
|
303
|
+
* @property {number} [latLabelPosition=1] Latitude label position in fractions
|
|
304
|
+
* (0..1) of view extent. 0 means at the left of the viewport, 1 means at the
|
|
305
|
+
* right.
|
|
306
|
+
* @property {Text} [lonLabelStyle] Longitude label text
|
|
307
|
+
* style. If not provided, the following style will be used:
|
|
308
|
+
* ```js
|
|
309
|
+
* new Text({
|
|
310
|
+
* font: '12px Calibri,sans-serif',
|
|
311
|
+
* textBaseline: 'bottom',
|
|
312
|
+
* fill: new Fill({
|
|
313
|
+
* color: 'rgba(0,0,0,1)'
|
|
314
|
+
* }),
|
|
315
|
+
* stroke: new Stroke({
|
|
316
|
+
* color: 'rgba(255,255,255,1)',
|
|
317
|
+
* width: 3
|
|
318
|
+
* })
|
|
319
|
+
* });
|
|
320
|
+
* ```
|
|
321
|
+
* Note that the default's `textBaseline` configuration will not work well for
|
|
322
|
+
* `lonLabelPosition` configurations that position labels close to the top of
|
|
323
|
+
* the viewport.
|
|
324
|
+
* @property {Text} [latLabelStyle] Latitude label text style.
|
|
325
|
+
* If not provided, the following style will be used:
|
|
326
|
+
* ```js
|
|
327
|
+
* new Text({
|
|
328
|
+
* font: '12px Calibri,sans-serif',
|
|
329
|
+
* textAlign: 'end',
|
|
330
|
+
* fill: new Fill({
|
|
331
|
+
* color: 'rgba(0,0,0,1)'
|
|
332
|
+
* }),
|
|
333
|
+
* stroke: Stroke({
|
|
334
|
+
* color: 'rgba(255,255,255,1)',
|
|
335
|
+
* width: 3
|
|
336
|
+
* })
|
|
337
|
+
* });
|
|
338
|
+
* ```
|
|
339
|
+
* Note that the default's `textAlign` configuration will not work well for
|
|
340
|
+
* `latLabelPosition` configurations that position labels close to the left of
|
|
341
|
+
* the viewport.
|
|
342
|
+
* @property {Array<number>} [intervals=[90, 45, 30, 20, 10, 5, 2, 1, 0.5, 0.2, 0.1, 0.05, 0.01, 0.005, 0.002, 0.001]]
|
|
343
|
+
* Intervals (in degrees) for the graticule. Example to limit graticules to 30 and 10 degrees intervals:
|
|
344
|
+
* ```js
|
|
345
|
+
* [30, 10]
|
|
346
|
+
* ```
|
|
347
|
+
* @property {boolean} [wrapX=true] Whether to repeat the graticule horizontally.
|
|
348
|
+
* @property {Object<string, *>} [properties] Arbitrary observable properties. Can be accessed with `#get()` and `#set()`.
|
|
349
|
+
*/
|
|
350
|
+
/**
|
|
351
|
+
* @classdesc
|
|
352
|
+
* Layer that renders a grid for a coordinate system (currently only EPSG:4326 is supported).
|
|
353
|
+
* Note that the view projection must define both extent and worldExtent.
|
|
354
|
+
*
|
|
355
|
+
* @fires import("../render/Event.js").RenderEvent
|
|
356
|
+
* @extends {VectorLayer<import("../source/Vector.js").default>}
|
|
357
|
+
* @api
|
|
358
|
+
*/
|
|
359
|
+
var Graticule = /** @class */ (function (_super) {
|
|
360
|
+
__extends(Graticule, _super);
|
|
361
|
+
/**
|
|
362
|
+
* @param {Options} [opt_options] Options.
|
|
363
|
+
*/
|
|
364
|
+
function Graticule(opt_options) {
|
|
365
|
+
var _this = this;
|
|
366
|
+
var options = opt_options ? opt_options : {};
|
|
367
|
+
var baseOptions = (0,_obj_js__WEBPACK_IMPORTED_MODULE_2__.assign)({
|
|
368
|
+
updateWhileAnimating: true,
|
|
369
|
+
updateWhileInteracting: true,
|
|
370
|
+
renderBuffer: 0,
|
|
371
|
+
}, options);
|
|
372
|
+
delete baseOptions.maxLines;
|
|
373
|
+
delete baseOptions.strokeStyle;
|
|
374
|
+
delete baseOptions.targetSize;
|
|
375
|
+
delete baseOptions.showLabels;
|
|
376
|
+
delete baseOptions.lonLabelFormatter;
|
|
377
|
+
delete baseOptions.latLabelFormatter;
|
|
378
|
+
delete baseOptions.lonLabelPosition;
|
|
379
|
+
delete baseOptions.latLabelPosition;
|
|
380
|
+
delete baseOptions.lonLabelStyle;
|
|
381
|
+
delete baseOptions.latLabelStyle;
|
|
382
|
+
delete baseOptions.intervals;
|
|
383
|
+
_this = _super.call(this, baseOptions) || this;
|
|
384
|
+
/**
|
|
385
|
+
* @type {import("../proj/Projection.js").default}
|
|
386
|
+
*/
|
|
387
|
+
_this.projection_ = null;
|
|
388
|
+
/**
|
|
389
|
+
* @type {number}
|
|
390
|
+
* @private
|
|
391
|
+
*/
|
|
392
|
+
_this.maxLat_ = Infinity;
|
|
393
|
+
/**
|
|
394
|
+
* @type {number}
|
|
395
|
+
* @private
|
|
396
|
+
*/
|
|
397
|
+
_this.maxLon_ = Infinity;
|
|
398
|
+
/**
|
|
399
|
+
* @type {number}
|
|
400
|
+
* @private
|
|
401
|
+
*/
|
|
402
|
+
_this.minLat_ = -Infinity;
|
|
403
|
+
/**
|
|
404
|
+
* @type {number}
|
|
405
|
+
* @private
|
|
406
|
+
*/
|
|
407
|
+
_this.minLon_ = -Infinity;
|
|
408
|
+
/**
|
|
409
|
+
* @type {number}
|
|
410
|
+
* @private
|
|
411
|
+
*/
|
|
412
|
+
_this.maxX_ = Infinity;
|
|
413
|
+
/**
|
|
414
|
+
* @type {number}
|
|
415
|
+
* @private
|
|
416
|
+
*/
|
|
417
|
+
_this.maxY_ = Infinity;
|
|
418
|
+
/**
|
|
419
|
+
* @type {number}
|
|
420
|
+
* @private
|
|
421
|
+
*/
|
|
422
|
+
_this.minX_ = -Infinity;
|
|
423
|
+
/**
|
|
424
|
+
* @type {number}
|
|
425
|
+
* @private
|
|
426
|
+
*/
|
|
427
|
+
_this.minY_ = -Infinity;
|
|
428
|
+
/**
|
|
429
|
+
* @type {number}
|
|
430
|
+
* @private
|
|
431
|
+
*/
|
|
432
|
+
_this.targetSize_ =
|
|
433
|
+
options.targetSize !== undefined ? options.targetSize : 100;
|
|
434
|
+
/**
|
|
435
|
+
* @type {number}
|
|
436
|
+
* @private
|
|
437
|
+
*/
|
|
438
|
+
_this.maxLines_ = options.maxLines !== undefined ? options.maxLines : 100;
|
|
439
|
+
/**
|
|
440
|
+
* @type {Array<LineString>}
|
|
441
|
+
* @private
|
|
442
|
+
*/
|
|
443
|
+
_this.meridians_ = [];
|
|
444
|
+
/**
|
|
445
|
+
* @type {Array<LineString>}
|
|
446
|
+
* @private
|
|
447
|
+
*/
|
|
448
|
+
_this.parallels_ = [];
|
|
449
|
+
/**
|
|
450
|
+
* @type {Stroke}
|
|
451
|
+
* @private
|
|
452
|
+
*/
|
|
453
|
+
_this.strokeStyle_ =
|
|
454
|
+
options.strokeStyle !== undefined
|
|
455
|
+
? options.strokeStyle
|
|
456
|
+
: DEFAULT_STROKE_STYLE;
|
|
457
|
+
/**
|
|
458
|
+
* @type {import("../proj.js").TransformFunction|undefined}
|
|
459
|
+
* @private
|
|
460
|
+
*/
|
|
461
|
+
_this.fromLonLatTransform_ = undefined;
|
|
462
|
+
/**
|
|
463
|
+
* @type {import("../proj.js").TransformFunction|undefined}
|
|
464
|
+
* @private
|
|
465
|
+
*/
|
|
466
|
+
_this.toLonLatTransform_ = undefined;
|
|
467
|
+
/**
|
|
468
|
+
* @type {import("../coordinate.js").Coordinate}
|
|
469
|
+
* @private
|
|
470
|
+
*/
|
|
471
|
+
_this.projectionCenterLonLat_ = null;
|
|
472
|
+
/**
|
|
473
|
+
* @type {import("../coordinate.js").Coordinate}
|
|
474
|
+
* @private
|
|
475
|
+
*/
|
|
476
|
+
_this.bottomLeft_ = null;
|
|
477
|
+
/**
|
|
478
|
+
* @type {import("../coordinate.js").Coordinate}
|
|
479
|
+
* @private
|
|
480
|
+
*/
|
|
481
|
+
_this.bottomRight_ = null;
|
|
482
|
+
/**
|
|
483
|
+
* @type {import("../coordinate.js").Coordinate}
|
|
484
|
+
* @private
|
|
485
|
+
*/
|
|
486
|
+
_this.topLeft_ = null;
|
|
487
|
+
/**
|
|
488
|
+
* @type {import("../coordinate.js").Coordinate}
|
|
489
|
+
* @private
|
|
490
|
+
*/
|
|
491
|
+
_this.topRight_ = null;
|
|
492
|
+
/**
|
|
493
|
+
* @type {Array<GraticuleLabelDataType>}
|
|
494
|
+
* @private
|
|
495
|
+
*/
|
|
496
|
+
_this.meridiansLabels_ = null;
|
|
497
|
+
/**
|
|
498
|
+
* @type {Array<GraticuleLabelDataType>}
|
|
499
|
+
* @private
|
|
500
|
+
*/
|
|
501
|
+
_this.parallelsLabels_ = null;
|
|
502
|
+
if (options.showLabels) {
|
|
503
|
+
/**
|
|
504
|
+
* @type {null|function(number):string}
|
|
505
|
+
* @private
|
|
506
|
+
*/
|
|
507
|
+
_this.lonLabelFormatter_ =
|
|
508
|
+
options.lonLabelFormatter == undefined
|
|
509
|
+
? _coordinate_js__WEBPACK_IMPORTED_MODULE_3__.degreesToStringHDMS.bind(_this, 'EW')
|
|
510
|
+
: options.lonLabelFormatter;
|
|
511
|
+
/**
|
|
512
|
+
* @type {function(number):string}
|
|
513
|
+
* @private
|
|
514
|
+
*/
|
|
515
|
+
_this.latLabelFormatter_ =
|
|
516
|
+
options.latLabelFormatter == undefined
|
|
517
|
+
? _coordinate_js__WEBPACK_IMPORTED_MODULE_3__.degreesToStringHDMS.bind(_this, 'NS')
|
|
518
|
+
: options.latLabelFormatter;
|
|
519
|
+
/**
|
|
520
|
+
* Longitude label position in fractions (0..1) of view extent. 0 means
|
|
521
|
+
* bottom, 1 means top.
|
|
522
|
+
* @type {number}
|
|
523
|
+
* @private
|
|
524
|
+
*/
|
|
525
|
+
_this.lonLabelPosition_ =
|
|
526
|
+
options.lonLabelPosition == undefined ? 0 : options.lonLabelPosition;
|
|
527
|
+
/**
|
|
528
|
+
* Latitude Label position in fractions (0..1) of view extent. 0 means left, 1
|
|
529
|
+
* means right.
|
|
530
|
+
* @type {number}
|
|
531
|
+
* @private
|
|
532
|
+
*/
|
|
533
|
+
_this.latLabelPosition_ =
|
|
534
|
+
options.latLabelPosition == undefined ? 1 : options.latLabelPosition;
|
|
535
|
+
/**
|
|
536
|
+
* @type {Style}
|
|
537
|
+
* @private
|
|
538
|
+
*/
|
|
539
|
+
_this.lonLabelStyleBase_ = new _style_Style_js__WEBPACK_IMPORTED_MODULE_4__["default"]({
|
|
540
|
+
text: options.lonLabelStyle !== undefined
|
|
541
|
+
? options.lonLabelStyle.clone()
|
|
542
|
+
: new _style_Text_js__WEBPACK_IMPORTED_MODULE_5__["default"]({
|
|
543
|
+
font: '12px Calibri,sans-serif',
|
|
544
|
+
textBaseline: 'bottom',
|
|
545
|
+
fill: new _style_Fill_js__WEBPACK_IMPORTED_MODULE_6__["default"]({
|
|
546
|
+
color: 'rgba(0,0,0,1)',
|
|
547
|
+
}),
|
|
548
|
+
stroke: new _style_Stroke_js__WEBPACK_IMPORTED_MODULE_1__["default"]({
|
|
549
|
+
color: 'rgba(255,255,255,1)',
|
|
550
|
+
width: 3,
|
|
551
|
+
}),
|
|
552
|
+
}),
|
|
553
|
+
});
|
|
554
|
+
/**
|
|
555
|
+
* @private
|
|
556
|
+
* @param {import("../Feature").default} feature Feature
|
|
557
|
+
* @return {Style} style
|
|
558
|
+
*/
|
|
559
|
+
_this.lonLabelStyle_ = function (feature) {
|
|
560
|
+
var label = feature.get('graticule_label');
|
|
561
|
+
this.lonLabelStyleBase_.getText().setText(label);
|
|
562
|
+
return this.lonLabelStyleBase_;
|
|
563
|
+
}.bind(_this);
|
|
564
|
+
/**
|
|
565
|
+
* @type {Style}
|
|
566
|
+
* @private
|
|
567
|
+
*/
|
|
568
|
+
_this.latLabelStyleBase_ = new _style_Style_js__WEBPACK_IMPORTED_MODULE_4__["default"]({
|
|
569
|
+
text: options.latLabelStyle !== undefined
|
|
570
|
+
? options.latLabelStyle.clone()
|
|
571
|
+
: new _style_Text_js__WEBPACK_IMPORTED_MODULE_5__["default"]({
|
|
572
|
+
font: '12px Calibri,sans-serif',
|
|
573
|
+
textAlign: 'right',
|
|
574
|
+
fill: new _style_Fill_js__WEBPACK_IMPORTED_MODULE_6__["default"]({
|
|
575
|
+
color: 'rgba(0,0,0,1)',
|
|
576
|
+
}),
|
|
577
|
+
stroke: new _style_Stroke_js__WEBPACK_IMPORTED_MODULE_1__["default"]({
|
|
578
|
+
color: 'rgba(255,255,255,1)',
|
|
579
|
+
width: 3,
|
|
580
|
+
}),
|
|
581
|
+
}),
|
|
582
|
+
});
|
|
583
|
+
/**
|
|
584
|
+
* @private
|
|
585
|
+
* @param {import("../Feature").default} feature Feature
|
|
586
|
+
* @return {Style} style
|
|
587
|
+
*/
|
|
588
|
+
_this.latLabelStyle_ = function (feature) {
|
|
589
|
+
var label = feature.get('graticule_label');
|
|
590
|
+
this.latLabelStyleBase_.getText().setText(label);
|
|
591
|
+
return this.latLabelStyleBase_;
|
|
592
|
+
}.bind(_this);
|
|
593
|
+
_this.meridiansLabels_ = [];
|
|
594
|
+
_this.parallelsLabels_ = [];
|
|
595
|
+
_this.addEventListener(_render_EventType_js__WEBPACK_IMPORTED_MODULE_7__["default"].POSTRENDER, _this.drawLabels_.bind(_this));
|
|
596
|
+
}
|
|
597
|
+
/**
|
|
598
|
+
* @type {Array<number>}
|
|
599
|
+
* @private
|
|
600
|
+
*/
|
|
601
|
+
_this.intervals_ =
|
|
602
|
+
options.intervals !== undefined ? options.intervals : INTERVALS;
|
|
603
|
+
// use a source with a custom loader for lines & text
|
|
604
|
+
_this.setSource(new _source_Vector_js__WEBPACK_IMPORTED_MODULE_8__["default"]({
|
|
605
|
+
loader: _this.loaderFunction.bind(_this),
|
|
606
|
+
strategy: _this.strategyFunction.bind(_this),
|
|
607
|
+
features: new _Collection_js__WEBPACK_IMPORTED_MODULE_9__["default"](),
|
|
608
|
+
overlaps: false,
|
|
609
|
+
useSpatialIndex: false,
|
|
610
|
+
wrapX: options.wrapX,
|
|
611
|
+
}));
|
|
612
|
+
/**
|
|
613
|
+
* feature pool to use when updating graticule
|
|
614
|
+
* @type {Array<Feature>}
|
|
615
|
+
* @private
|
|
616
|
+
*/
|
|
617
|
+
_this.featurePool_ = [];
|
|
618
|
+
/**
|
|
619
|
+
* @type {Style}
|
|
620
|
+
* @private
|
|
621
|
+
*/
|
|
622
|
+
_this.lineStyle_ = new _style_Style_js__WEBPACK_IMPORTED_MODULE_4__["default"]({
|
|
623
|
+
stroke: _this.strokeStyle_,
|
|
624
|
+
});
|
|
625
|
+
/**
|
|
626
|
+
* @type {?import("../extent.js").Extent}
|
|
627
|
+
* @private
|
|
628
|
+
*/
|
|
629
|
+
_this.loadedExtent_ = null;
|
|
630
|
+
/**
|
|
631
|
+
* @type {?import("../extent.js").Extent}
|
|
632
|
+
* @private
|
|
633
|
+
*/
|
|
634
|
+
_this.renderedExtent_ = null;
|
|
635
|
+
/**
|
|
636
|
+
* @type {?number}
|
|
637
|
+
* @private
|
|
638
|
+
*/
|
|
639
|
+
_this.renderedResolution_ = null;
|
|
640
|
+
_this.setRenderOrder(null);
|
|
641
|
+
return _this;
|
|
642
|
+
}
|
|
643
|
+
/**
|
|
644
|
+
* Strategy function for loading features based on the view's extent and
|
|
645
|
+
* resolution.
|
|
646
|
+
* @param {import("../extent.js").Extent} extent Extent.
|
|
647
|
+
* @param {number} resolution Resolution.
|
|
648
|
+
* @return {Array<import("../extent.js").Extent>} Extents.
|
|
649
|
+
*/
|
|
650
|
+
Graticule.prototype.strategyFunction = function (extent, resolution) {
|
|
651
|
+
// extents may be passed in different worlds, to avoid endless loop we use only one
|
|
652
|
+
var realWorldExtent = extent.slice();
|
|
653
|
+
if (this.projection_ && this.getSource().getWrapX()) {
|
|
654
|
+
(0,_extent_js__WEBPACK_IMPORTED_MODULE_10__.wrapX)(realWorldExtent, this.projection_);
|
|
655
|
+
}
|
|
656
|
+
if (this.loadedExtent_) {
|
|
657
|
+
if ((0,_extent_js__WEBPACK_IMPORTED_MODULE_10__.approximatelyEquals)(this.loadedExtent_, realWorldExtent, resolution)) {
|
|
658
|
+
// make sure result is exactly equal to previous extent
|
|
659
|
+
realWorldExtent = this.loadedExtent_.slice();
|
|
660
|
+
}
|
|
661
|
+
else {
|
|
662
|
+
// we should not keep track of loaded extents
|
|
663
|
+
this.getSource().removeLoadedExtent(this.loadedExtent_);
|
|
664
|
+
}
|
|
665
|
+
}
|
|
666
|
+
return [realWorldExtent];
|
|
667
|
+
};
|
|
668
|
+
/**
|
|
669
|
+
* Update geometries in the source based on current view
|
|
670
|
+
* @param {import("../extent").Extent} extent Extent
|
|
671
|
+
* @param {number} resolution Resolution
|
|
672
|
+
* @param {import("../proj/Projection.js").default} projection Projection
|
|
673
|
+
*/
|
|
674
|
+
Graticule.prototype.loaderFunction = function (extent, resolution, projection) {
|
|
675
|
+
this.loadedExtent_ = extent;
|
|
676
|
+
var source = this.getSource();
|
|
677
|
+
// only consider the intersection between our own extent & the requested one
|
|
678
|
+
var layerExtent = this.getExtent() || [
|
|
679
|
+
-Infinity,
|
|
680
|
+
-Infinity,
|
|
681
|
+
Infinity,
|
|
682
|
+
Infinity,
|
|
683
|
+
];
|
|
684
|
+
var renderExtent = (0,_extent_js__WEBPACK_IMPORTED_MODULE_10__.getIntersection)(layerExtent, extent);
|
|
685
|
+
if (this.renderedExtent_ &&
|
|
686
|
+
(0,_extent_js__WEBPACK_IMPORTED_MODULE_10__.equals)(this.renderedExtent_, renderExtent) &&
|
|
687
|
+
this.renderedResolution_ === resolution) {
|
|
688
|
+
return;
|
|
689
|
+
}
|
|
690
|
+
this.renderedExtent_ = renderExtent;
|
|
691
|
+
this.renderedResolution_ = resolution;
|
|
692
|
+
// bail out if nothing to render
|
|
693
|
+
if ((0,_extent_js__WEBPACK_IMPORTED_MODULE_10__.isEmpty)(renderExtent)) {
|
|
694
|
+
return;
|
|
695
|
+
}
|
|
696
|
+
// update projection info
|
|
697
|
+
var center = (0,_extent_js__WEBPACK_IMPORTED_MODULE_10__.getCenter)(renderExtent);
|
|
698
|
+
var squaredTolerance = (resolution * resolution) / 4;
|
|
699
|
+
var updateProjectionInfo = !this.projection_ || !(0,_proj_js__WEBPACK_IMPORTED_MODULE_0__.equivalent)(this.projection_, projection);
|
|
700
|
+
if (updateProjectionInfo) {
|
|
701
|
+
this.updateProjectionInfo_(projection);
|
|
702
|
+
}
|
|
703
|
+
this.createGraticule_(renderExtent, center, resolution, squaredTolerance);
|
|
704
|
+
// first make sure we have enough features in the pool
|
|
705
|
+
var featureCount = this.meridians_.length + this.parallels_.length;
|
|
706
|
+
if (this.meridiansLabels_) {
|
|
707
|
+
featureCount += this.meridians_.length;
|
|
708
|
+
}
|
|
709
|
+
if (this.parallelsLabels_) {
|
|
710
|
+
featureCount += this.parallels_.length;
|
|
711
|
+
}
|
|
712
|
+
var feature;
|
|
713
|
+
while (featureCount > this.featurePool_.length) {
|
|
714
|
+
feature = new _Feature_js__WEBPACK_IMPORTED_MODULE_11__["default"]();
|
|
715
|
+
this.featurePool_.push(feature);
|
|
716
|
+
}
|
|
717
|
+
var featuresColl = source.getFeaturesCollection();
|
|
718
|
+
featuresColl.clear();
|
|
719
|
+
var poolIndex = 0;
|
|
720
|
+
// add features for the lines & labels
|
|
721
|
+
var i, l;
|
|
722
|
+
for (i = 0, l = this.meridians_.length; i < l; ++i) {
|
|
723
|
+
feature = this.featurePool_[poolIndex++];
|
|
724
|
+
feature.setGeometry(this.meridians_[i]);
|
|
725
|
+
feature.setStyle(this.lineStyle_);
|
|
726
|
+
featuresColl.push(feature);
|
|
727
|
+
}
|
|
728
|
+
for (i = 0, l = this.parallels_.length; i < l; ++i) {
|
|
729
|
+
feature = this.featurePool_[poolIndex++];
|
|
730
|
+
feature.setGeometry(this.parallels_[i]);
|
|
731
|
+
feature.setStyle(this.lineStyle_);
|
|
732
|
+
featuresColl.push(feature);
|
|
733
|
+
}
|
|
734
|
+
};
|
|
735
|
+
/**
|
|
736
|
+
* @param {number} lon Longitude.
|
|
737
|
+
* @param {number} minLat Minimal latitude.
|
|
738
|
+
* @param {number} maxLat Maximal latitude.
|
|
739
|
+
* @param {number} squaredTolerance Squared tolerance.
|
|
740
|
+
* @param {import("../extent.js").Extent} extent Extent.
|
|
741
|
+
* @param {number} index Index.
|
|
742
|
+
* @return {number} Index.
|
|
743
|
+
* @private
|
|
744
|
+
*/
|
|
745
|
+
Graticule.prototype.addMeridian_ = function (lon, minLat, maxLat, squaredTolerance, extent, index) {
|
|
746
|
+
var lineString = this.getMeridian_(lon, minLat, maxLat, squaredTolerance, index);
|
|
747
|
+
if ((0,_extent_js__WEBPACK_IMPORTED_MODULE_10__.intersects)(lineString.getExtent(), extent)) {
|
|
748
|
+
if (this.meridiansLabels_) {
|
|
749
|
+
var text = this.lonLabelFormatter_(lon);
|
|
750
|
+
if (index in this.meridiansLabels_) {
|
|
751
|
+
this.meridiansLabels_[index].text = text;
|
|
752
|
+
}
|
|
753
|
+
else {
|
|
754
|
+
this.meridiansLabels_[index] = {
|
|
755
|
+
geom: new _geom_Point_js__WEBPACK_IMPORTED_MODULE_12__["default"]([]),
|
|
756
|
+
text: text,
|
|
757
|
+
};
|
|
758
|
+
}
|
|
759
|
+
}
|
|
760
|
+
this.meridians_[index++] = lineString;
|
|
761
|
+
}
|
|
762
|
+
return index;
|
|
763
|
+
};
|
|
764
|
+
/**
|
|
765
|
+
* @param {number} lat Latitude.
|
|
766
|
+
* @param {number} minLon Minimal longitude.
|
|
767
|
+
* @param {number} maxLon Maximal longitude.
|
|
768
|
+
* @param {number} squaredTolerance Squared tolerance.
|
|
769
|
+
* @param {import("../extent.js").Extent} extent Extent.
|
|
770
|
+
* @param {number} index Index.
|
|
771
|
+
* @return {number} Index.
|
|
772
|
+
* @private
|
|
773
|
+
*/
|
|
774
|
+
Graticule.prototype.addParallel_ = function (lat, minLon, maxLon, squaredTolerance, extent, index) {
|
|
775
|
+
var lineString = this.getParallel_(lat, minLon, maxLon, squaredTolerance, index);
|
|
776
|
+
if ((0,_extent_js__WEBPACK_IMPORTED_MODULE_10__.intersects)(lineString.getExtent(), extent)) {
|
|
777
|
+
if (this.parallelsLabels_) {
|
|
778
|
+
var text = this.latLabelFormatter_(lat);
|
|
779
|
+
if (index in this.parallelsLabels_) {
|
|
780
|
+
this.parallelsLabels_[index].text = text;
|
|
781
|
+
}
|
|
782
|
+
else {
|
|
783
|
+
this.parallelsLabels_[index] = {
|
|
784
|
+
geom: new _geom_Point_js__WEBPACK_IMPORTED_MODULE_12__["default"]([]),
|
|
785
|
+
text: text,
|
|
786
|
+
};
|
|
787
|
+
}
|
|
788
|
+
}
|
|
789
|
+
this.parallels_[index++] = lineString;
|
|
790
|
+
}
|
|
791
|
+
return index;
|
|
792
|
+
};
|
|
793
|
+
/**
|
|
794
|
+
* @param {import("../render/Event.js").default} event Render event.
|
|
795
|
+
* @private
|
|
796
|
+
*/
|
|
797
|
+
Graticule.prototype.drawLabels_ = function (event) {
|
|
798
|
+
var rotation = event.frameState.viewState.rotation;
|
|
799
|
+
var resolution = event.frameState.viewState.resolution;
|
|
800
|
+
var size = event.frameState.size;
|
|
801
|
+
var extent = event.frameState.extent;
|
|
802
|
+
var rotationCenter = (0,_extent_js__WEBPACK_IMPORTED_MODULE_10__.getCenter)(extent);
|
|
803
|
+
var rotationExtent = extent;
|
|
804
|
+
if (rotation) {
|
|
805
|
+
var unrotatedWidth = size[0] * resolution;
|
|
806
|
+
var unrotatedHeight = size[1] * resolution;
|
|
807
|
+
rotationExtent = [
|
|
808
|
+
rotationCenter[0] - unrotatedWidth / 2,
|
|
809
|
+
rotationCenter[1] - unrotatedHeight / 2,
|
|
810
|
+
rotationCenter[0] + unrotatedWidth / 2,
|
|
811
|
+
rotationCenter[1] + unrotatedHeight / 2,
|
|
812
|
+
];
|
|
813
|
+
}
|
|
814
|
+
var startWorld = 0;
|
|
815
|
+
var endWorld = 0;
|
|
816
|
+
var labelsAtStart = this.latLabelPosition_ < 0.5;
|
|
817
|
+
var projectionExtent = this.projection_.getExtent();
|
|
818
|
+
var worldWidth = (0,_extent_js__WEBPACK_IMPORTED_MODULE_10__.getWidth)(projectionExtent);
|
|
819
|
+
if (this.getSource().getWrapX() &&
|
|
820
|
+
this.projection_.canWrapX() &&
|
|
821
|
+
!(0,_extent_js__WEBPACK_IMPORTED_MODULE_10__.containsExtent)(projectionExtent, extent)) {
|
|
822
|
+
startWorld = Math.floor((extent[0] - projectionExtent[0]) / worldWidth);
|
|
823
|
+
endWorld = Math.ceil((extent[2] - projectionExtent[2]) / worldWidth);
|
|
824
|
+
var inverted = Math.abs(rotation) > Math.PI / 2;
|
|
825
|
+
labelsAtStart = labelsAtStart !== inverted;
|
|
826
|
+
}
|
|
827
|
+
var vectorContext = (0,_render_js__WEBPACK_IMPORTED_MODULE_13__.getVectorContext)(event);
|
|
828
|
+
for (var world = startWorld; world <= endWorld; ++world) {
|
|
829
|
+
var poolIndex = this.meridians_.length + this.parallels_.length;
|
|
830
|
+
var feature = void 0, index = void 0, l = void 0, textPoint = void 0;
|
|
831
|
+
if (this.meridiansLabels_) {
|
|
832
|
+
for (index = 0, l = this.meridiansLabels_.length; index < l; ++index) {
|
|
833
|
+
var lineString = this.meridians_[index];
|
|
834
|
+
if (!rotation && world === 0) {
|
|
835
|
+
textPoint = this.getMeridianPoint_(lineString, extent, index);
|
|
836
|
+
}
|
|
837
|
+
else {
|
|
838
|
+
var clone = lineString.clone();
|
|
839
|
+
clone.translate(world * worldWidth, 0);
|
|
840
|
+
clone.rotate(-rotation, rotationCenter);
|
|
841
|
+
textPoint = this.getMeridianPoint_(clone, rotationExtent, index);
|
|
842
|
+
textPoint.rotate(rotation, rotationCenter);
|
|
843
|
+
}
|
|
844
|
+
feature = this.featurePool_[poolIndex++];
|
|
845
|
+
feature.setGeometry(textPoint);
|
|
846
|
+
feature.set('graticule_label', this.meridiansLabels_[index].text);
|
|
847
|
+
vectorContext.drawFeature(feature, this.lonLabelStyle_(feature));
|
|
848
|
+
}
|
|
849
|
+
}
|
|
850
|
+
if (this.parallelsLabels_) {
|
|
851
|
+
if ((world === startWorld && labelsAtStart) ||
|
|
852
|
+
(world === endWorld && !labelsAtStart)) {
|
|
853
|
+
for (index = 0, l = this.parallels_.length; index < l; ++index) {
|
|
854
|
+
var lineString = this.parallels_[index];
|
|
855
|
+
if (!rotation && world === 0) {
|
|
856
|
+
textPoint = this.getParallelPoint_(lineString, extent, index);
|
|
857
|
+
}
|
|
858
|
+
else {
|
|
859
|
+
var clone = lineString.clone();
|
|
860
|
+
clone.translate(world * worldWidth, 0);
|
|
861
|
+
clone.rotate(-rotation, rotationCenter);
|
|
862
|
+
textPoint = this.getParallelPoint_(clone, rotationExtent, index);
|
|
863
|
+
textPoint.rotate(rotation, rotationCenter);
|
|
864
|
+
}
|
|
865
|
+
feature = this.featurePool_[poolIndex++];
|
|
866
|
+
feature.setGeometry(textPoint);
|
|
867
|
+
feature.set('graticule_label', this.parallelsLabels_[index].text);
|
|
868
|
+
vectorContext.drawFeature(feature, this.latLabelStyle_(feature));
|
|
869
|
+
}
|
|
870
|
+
}
|
|
871
|
+
}
|
|
872
|
+
}
|
|
873
|
+
};
|
|
874
|
+
/**
|
|
875
|
+
* @param {import("../extent.js").Extent} extent Extent.
|
|
876
|
+
* @param {import("../coordinate.js").Coordinate} center Center.
|
|
877
|
+
* @param {number} resolution Resolution.
|
|
878
|
+
* @param {number} squaredTolerance Squared tolerance.
|
|
879
|
+
* @private
|
|
880
|
+
*/
|
|
881
|
+
Graticule.prototype.createGraticule_ = function (extent, center, resolution, squaredTolerance) {
|
|
882
|
+
var interval = this.getInterval_(resolution);
|
|
883
|
+
if (interval == -1) {
|
|
884
|
+
this.meridians_.length = 0;
|
|
885
|
+
this.parallels_.length = 0;
|
|
886
|
+
if (this.meridiansLabels_) {
|
|
887
|
+
this.meridiansLabels_.length = 0;
|
|
888
|
+
}
|
|
889
|
+
if (this.parallelsLabels_) {
|
|
890
|
+
this.parallelsLabels_.length = 0;
|
|
891
|
+
}
|
|
892
|
+
return;
|
|
893
|
+
}
|
|
894
|
+
var wrapX = false;
|
|
895
|
+
var projectionExtent = this.projection_.getExtent();
|
|
896
|
+
var worldWidth = (0,_extent_js__WEBPACK_IMPORTED_MODULE_10__.getWidth)(projectionExtent);
|
|
897
|
+
if (this.getSource().getWrapX() &&
|
|
898
|
+
this.projection_.canWrapX() &&
|
|
899
|
+
!(0,_extent_js__WEBPACK_IMPORTED_MODULE_10__.containsExtent)(projectionExtent, extent)) {
|
|
900
|
+
if ((0,_extent_js__WEBPACK_IMPORTED_MODULE_10__.getWidth)(extent) >= worldWidth) {
|
|
901
|
+
extent[0] = projectionExtent[0];
|
|
902
|
+
extent[2] = projectionExtent[2];
|
|
903
|
+
}
|
|
904
|
+
else {
|
|
905
|
+
wrapX = true;
|
|
906
|
+
}
|
|
907
|
+
}
|
|
908
|
+
// Constrain the center to fit into the extent available to the graticule
|
|
909
|
+
var validCenterP = [
|
|
910
|
+
(0,_math_js__WEBPACK_IMPORTED_MODULE_14__.clamp)(center[0], this.minX_, this.maxX_),
|
|
911
|
+
(0,_math_js__WEBPACK_IMPORTED_MODULE_14__.clamp)(center[1], this.minY_, this.maxY_),
|
|
912
|
+
];
|
|
913
|
+
// Transform the center to lon lat
|
|
914
|
+
// Some projections may have a void area at the poles
|
|
915
|
+
// so replace any NaN latitudes with the min or max value closest to a pole
|
|
916
|
+
var centerLonLat = this.toLonLatTransform_(validCenterP);
|
|
917
|
+
if (isNaN(centerLonLat[1])) {
|
|
918
|
+
centerLonLat[1] =
|
|
919
|
+
Math.abs(this.maxLat_) >= Math.abs(this.minLat_)
|
|
920
|
+
? this.maxLat_
|
|
921
|
+
: this.minLat_;
|
|
922
|
+
}
|
|
923
|
+
var centerLon = (0,_math_js__WEBPACK_IMPORTED_MODULE_14__.clamp)(centerLonLat[0], this.minLon_, this.maxLon_);
|
|
924
|
+
var centerLat = (0,_math_js__WEBPACK_IMPORTED_MODULE_14__.clamp)(centerLonLat[1], this.minLat_, this.maxLat_);
|
|
925
|
+
var maxLines = this.maxLines_;
|
|
926
|
+
var cnt, idx, lat, lon;
|
|
927
|
+
// Limit the extent to fit into the extent available to the graticule
|
|
928
|
+
var validExtentP = extent;
|
|
929
|
+
if (!wrapX) {
|
|
930
|
+
validExtentP = [
|
|
931
|
+
(0,_math_js__WEBPACK_IMPORTED_MODULE_14__.clamp)(extent[0], this.minX_, this.maxX_),
|
|
932
|
+
(0,_math_js__WEBPACK_IMPORTED_MODULE_14__.clamp)(extent[1], this.minY_, this.maxY_),
|
|
933
|
+
(0,_math_js__WEBPACK_IMPORTED_MODULE_14__.clamp)(extent[2], this.minX_, this.maxX_),
|
|
934
|
+
(0,_math_js__WEBPACK_IMPORTED_MODULE_14__.clamp)(extent[3], this.minY_, this.maxY_),
|
|
935
|
+
];
|
|
936
|
+
}
|
|
937
|
+
// Transform the extent to get the lon lat ranges for the edges of the extent
|
|
938
|
+
var validExtent = (0,_extent_js__WEBPACK_IMPORTED_MODULE_10__.applyTransform)(validExtentP, this.toLonLatTransform_, undefined, 8);
|
|
939
|
+
var maxLat = validExtent[3];
|
|
940
|
+
var maxLon = validExtent[2];
|
|
941
|
+
var minLat = validExtent[1];
|
|
942
|
+
var minLon = validExtent[0];
|
|
943
|
+
if (!wrapX) {
|
|
944
|
+
// Check if extremities of the world extent lie inside the extent
|
|
945
|
+
// (for example the pole in a polar projection)
|
|
946
|
+
// and extend the extent as appropriate
|
|
947
|
+
if ((0,_extent_js__WEBPACK_IMPORTED_MODULE_10__.containsCoordinate)(validExtentP, this.bottomLeft_)) {
|
|
948
|
+
minLon = this.minLon_;
|
|
949
|
+
minLat = this.minLat_;
|
|
950
|
+
}
|
|
951
|
+
if ((0,_extent_js__WEBPACK_IMPORTED_MODULE_10__.containsCoordinate)(validExtentP, this.bottomRight_)) {
|
|
952
|
+
maxLon = this.maxLon_;
|
|
953
|
+
minLat = this.minLat_;
|
|
954
|
+
}
|
|
955
|
+
if ((0,_extent_js__WEBPACK_IMPORTED_MODULE_10__.containsCoordinate)(validExtentP, this.topLeft_)) {
|
|
956
|
+
minLon = this.minLon_;
|
|
957
|
+
maxLat = this.maxLat_;
|
|
958
|
+
}
|
|
959
|
+
if ((0,_extent_js__WEBPACK_IMPORTED_MODULE_10__.containsCoordinate)(validExtentP, this.topRight_)) {
|
|
960
|
+
maxLon = this.maxLon_;
|
|
961
|
+
maxLat = this.maxLat_;
|
|
962
|
+
}
|
|
963
|
+
// The transformed center may also extend the lon lat ranges used for rendering
|
|
964
|
+
maxLat = (0,_math_js__WEBPACK_IMPORTED_MODULE_14__.clamp)(maxLat, centerLat, this.maxLat_);
|
|
965
|
+
maxLon = (0,_math_js__WEBPACK_IMPORTED_MODULE_14__.clamp)(maxLon, centerLon, this.maxLon_);
|
|
966
|
+
minLat = (0,_math_js__WEBPACK_IMPORTED_MODULE_14__.clamp)(minLat, this.minLat_, centerLat);
|
|
967
|
+
minLon = (0,_math_js__WEBPACK_IMPORTED_MODULE_14__.clamp)(minLon, this.minLon_, centerLon);
|
|
968
|
+
}
|
|
969
|
+
// Create meridians
|
|
970
|
+
centerLon = Math.floor(centerLon / interval) * interval;
|
|
971
|
+
lon = (0,_math_js__WEBPACK_IMPORTED_MODULE_14__.clamp)(centerLon, this.minLon_, this.maxLon_);
|
|
972
|
+
idx = this.addMeridian_(lon, minLat, maxLat, squaredTolerance, extent, 0);
|
|
973
|
+
cnt = 0;
|
|
974
|
+
if (wrapX) {
|
|
975
|
+
while ((lon -= interval) >= minLon && cnt++ < maxLines) {
|
|
976
|
+
idx = this.addMeridian_(lon, minLat, maxLat, squaredTolerance, extent, idx);
|
|
977
|
+
}
|
|
978
|
+
}
|
|
979
|
+
else {
|
|
980
|
+
while (lon != this.minLon_ && cnt++ < maxLines) {
|
|
981
|
+
lon = Math.max(lon - interval, this.minLon_);
|
|
982
|
+
idx = this.addMeridian_(lon, minLat, maxLat, squaredTolerance, extent, idx);
|
|
983
|
+
}
|
|
984
|
+
}
|
|
985
|
+
lon = (0,_math_js__WEBPACK_IMPORTED_MODULE_14__.clamp)(centerLon, this.minLon_, this.maxLon_);
|
|
986
|
+
cnt = 0;
|
|
987
|
+
if (wrapX) {
|
|
988
|
+
while ((lon += interval) <= maxLon && cnt++ < maxLines) {
|
|
989
|
+
idx = this.addMeridian_(lon, minLat, maxLat, squaredTolerance, extent, idx);
|
|
990
|
+
}
|
|
991
|
+
}
|
|
992
|
+
else {
|
|
993
|
+
while (lon != this.maxLon_ && cnt++ < maxLines) {
|
|
994
|
+
lon = Math.min(lon + interval, this.maxLon_);
|
|
995
|
+
idx = this.addMeridian_(lon, minLat, maxLat, squaredTolerance, extent, idx);
|
|
996
|
+
}
|
|
997
|
+
}
|
|
998
|
+
this.meridians_.length = idx;
|
|
999
|
+
if (this.meridiansLabels_) {
|
|
1000
|
+
this.meridiansLabels_.length = idx;
|
|
1001
|
+
}
|
|
1002
|
+
// Create parallels
|
|
1003
|
+
centerLat = Math.floor(centerLat / interval) * interval;
|
|
1004
|
+
lat = (0,_math_js__WEBPACK_IMPORTED_MODULE_14__.clamp)(centerLat, this.minLat_, this.maxLat_);
|
|
1005
|
+
idx = this.addParallel_(lat, minLon, maxLon, squaredTolerance, extent, 0);
|
|
1006
|
+
cnt = 0;
|
|
1007
|
+
while (lat != this.minLat_ && cnt++ < maxLines) {
|
|
1008
|
+
lat = Math.max(lat - interval, this.minLat_);
|
|
1009
|
+
idx = this.addParallel_(lat, minLon, maxLon, squaredTolerance, extent, idx);
|
|
1010
|
+
}
|
|
1011
|
+
lat = (0,_math_js__WEBPACK_IMPORTED_MODULE_14__.clamp)(centerLat, this.minLat_, this.maxLat_);
|
|
1012
|
+
cnt = 0;
|
|
1013
|
+
while (lat != this.maxLat_ && cnt++ < maxLines) {
|
|
1014
|
+
lat = Math.min(lat + interval, this.maxLat_);
|
|
1015
|
+
idx = this.addParallel_(lat, minLon, maxLon, squaredTolerance, extent, idx);
|
|
1016
|
+
}
|
|
1017
|
+
this.parallels_.length = idx;
|
|
1018
|
+
if (this.parallelsLabels_) {
|
|
1019
|
+
this.parallelsLabels_.length = idx;
|
|
1020
|
+
}
|
|
1021
|
+
};
|
|
1022
|
+
/**
|
|
1023
|
+
* @param {number} resolution Resolution.
|
|
1024
|
+
* @return {number} The interval in degrees.
|
|
1025
|
+
* @private
|
|
1026
|
+
*/
|
|
1027
|
+
Graticule.prototype.getInterval_ = function (resolution) {
|
|
1028
|
+
var centerLon = this.projectionCenterLonLat_[0];
|
|
1029
|
+
var centerLat = this.projectionCenterLonLat_[1];
|
|
1030
|
+
var interval = -1;
|
|
1031
|
+
var target = Math.pow(this.targetSize_ * resolution, 2);
|
|
1032
|
+
/** @type {Array<number>} **/
|
|
1033
|
+
var p1 = [];
|
|
1034
|
+
/** @type {Array<number>} **/
|
|
1035
|
+
var p2 = [];
|
|
1036
|
+
for (var i = 0, ii = this.intervals_.length; i < ii; ++i) {
|
|
1037
|
+
var delta = (0,_math_js__WEBPACK_IMPORTED_MODULE_14__.clamp)(this.intervals_[i] / 2, 0, 90);
|
|
1038
|
+
// Don't attempt to transform latitudes beyond the poles!
|
|
1039
|
+
var clampedLat = (0,_math_js__WEBPACK_IMPORTED_MODULE_14__.clamp)(centerLat, -90 + delta, 90 - delta);
|
|
1040
|
+
p1[0] = centerLon - delta;
|
|
1041
|
+
p1[1] = clampedLat - delta;
|
|
1042
|
+
p2[0] = centerLon + delta;
|
|
1043
|
+
p2[1] = clampedLat + delta;
|
|
1044
|
+
this.fromLonLatTransform_(p1, p1);
|
|
1045
|
+
this.fromLonLatTransform_(p2, p2);
|
|
1046
|
+
var dist = Math.pow(p2[0] - p1[0], 2) + Math.pow(p2[1] - p1[1], 2);
|
|
1047
|
+
if (dist <= target) {
|
|
1048
|
+
break;
|
|
1049
|
+
}
|
|
1050
|
+
interval = this.intervals_[i];
|
|
1051
|
+
}
|
|
1052
|
+
return interval;
|
|
1053
|
+
};
|
|
1054
|
+
/**
|
|
1055
|
+
* @param {number} lon Longitude.
|
|
1056
|
+
* @param {number} minLat Minimal latitude.
|
|
1057
|
+
* @param {number} maxLat Maximal latitude.
|
|
1058
|
+
* @param {number} squaredTolerance Squared tolerance.
|
|
1059
|
+
* @return {LineString} The meridian line string.
|
|
1060
|
+
* @param {number} index Index.
|
|
1061
|
+
* @private
|
|
1062
|
+
*/
|
|
1063
|
+
Graticule.prototype.getMeridian_ = function (lon, minLat, maxLat, squaredTolerance, index) {
|
|
1064
|
+
var flatCoordinates = (0,_geom_flat_geodesic_js__WEBPACK_IMPORTED_MODULE_15__.meridian)(lon, minLat, maxLat, this.projection_, squaredTolerance);
|
|
1065
|
+
var lineString = this.meridians_[index];
|
|
1066
|
+
if (!lineString) {
|
|
1067
|
+
lineString = new _geom_LineString_js__WEBPACK_IMPORTED_MODULE_16__["default"](flatCoordinates, _geom_GeometryLayout_js__WEBPACK_IMPORTED_MODULE_17__["default"].XY);
|
|
1068
|
+
this.meridians_[index] = lineString;
|
|
1069
|
+
}
|
|
1070
|
+
else {
|
|
1071
|
+
lineString.setFlatCoordinates(_geom_GeometryLayout_js__WEBPACK_IMPORTED_MODULE_17__["default"].XY, flatCoordinates);
|
|
1072
|
+
lineString.changed();
|
|
1073
|
+
}
|
|
1074
|
+
return lineString;
|
|
1075
|
+
};
|
|
1076
|
+
/**
|
|
1077
|
+
* @param {LineString} lineString Meridian
|
|
1078
|
+
* @param {import("../extent.js").Extent} extent Extent.
|
|
1079
|
+
* @param {number} index Index.
|
|
1080
|
+
* @return {Point} Meridian point.
|
|
1081
|
+
* @private
|
|
1082
|
+
*/
|
|
1083
|
+
Graticule.prototype.getMeridianPoint_ = function (lineString, extent, index) {
|
|
1084
|
+
var flatCoordinates = lineString.getFlatCoordinates();
|
|
1085
|
+
var bottom = 1;
|
|
1086
|
+
var top = flatCoordinates.length - 1;
|
|
1087
|
+
if (flatCoordinates[bottom] > flatCoordinates[top]) {
|
|
1088
|
+
bottom = top;
|
|
1089
|
+
top = 1;
|
|
1090
|
+
}
|
|
1091
|
+
var clampedBottom = Math.max(extent[1], flatCoordinates[bottom]);
|
|
1092
|
+
var clampedTop = Math.min(extent[3], flatCoordinates[top]);
|
|
1093
|
+
var lat = (0,_math_js__WEBPACK_IMPORTED_MODULE_14__.clamp)(extent[1] + Math.abs(extent[1] - extent[3]) * this.lonLabelPosition_, clampedBottom, clampedTop);
|
|
1094
|
+
var coordinate0 = flatCoordinates[bottom - 1] +
|
|
1095
|
+
((flatCoordinates[top - 1] - flatCoordinates[bottom - 1]) *
|
|
1096
|
+
(lat - flatCoordinates[bottom])) /
|
|
1097
|
+
(flatCoordinates[top] - flatCoordinates[bottom]);
|
|
1098
|
+
var coordinate = [coordinate0, lat];
|
|
1099
|
+
var point = this.meridiansLabels_[index].geom;
|
|
1100
|
+
point.setCoordinates(coordinate);
|
|
1101
|
+
return point;
|
|
1102
|
+
};
|
|
1103
|
+
/**
|
|
1104
|
+
* Get the list of meridians. Meridians are lines of equal longitude.
|
|
1105
|
+
* @return {Array<LineString>} The meridians.
|
|
1106
|
+
* @api
|
|
1107
|
+
*/
|
|
1108
|
+
Graticule.prototype.getMeridians = function () {
|
|
1109
|
+
return this.meridians_;
|
|
1110
|
+
};
|
|
1111
|
+
/**
|
|
1112
|
+
* @param {number} lat Latitude.
|
|
1113
|
+
* @param {number} minLon Minimal longitude.
|
|
1114
|
+
* @param {number} maxLon Maximal longitude.
|
|
1115
|
+
* @param {number} squaredTolerance Squared tolerance.
|
|
1116
|
+
* @return {LineString} The parallel line string.
|
|
1117
|
+
* @param {number} index Index.
|
|
1118
|
+
* @private
|
|
1119
|
+
*/
|
|
1120
|
+
Graticule.prototype.getParallel_ = function (lat, minLon, maxLon, squaredTolerance, index) {
|
|
1121
|
+
var flatCoordinates = (0,_geom_flat_geodesic_js__WEBPACK_IMPORTED_MODULE_15__.parallel)(lat, minLon, maxLon, this.projection_, squaredTolerance);
|
|
1122
|
+
var lineString = this.parallels_[index];
|
|
1123
|
+
if (!lineString) {
|
|
1124
|
+
lineString = new _geom_LineString_js__WEBPACK_IMPORTED_MODULE_16__["default"](flatCoordinates, _geom_GeometryLayout_js__WEBPACK_IMPORTED_MODULE_17__["default"].XY);
|
|
1125
|
+
}
|
|
1126
|
+
else {
|
|
1127
|
+
lineString.setFlatCoordinates(_geom_GeometryLayout_js__WEBPACK_IMPORTED_MODULE_17__["default"].XY, flatCoordinates);
|
|
1128
|
+
lineString.changed();
|
|
1129
|
+
}
|
|
1130
|
+
return lineString;
|
|
1131
|
+
};
|
|
1132
|
+
/**
|
|
1133
|
+
* @param {LineString} lineString Parallels.
|
|
1134
|
+
* @param {import("../extent.js").Extent} extent Extent.
|
|
1135
|
+
* @param {number} index Index.
|
|
1136
|
+
* @return {Point} Parallel point.
|
|
1137
|
+
* @private
|
|
1138
|
+
*/
|
|
1139
|
+
Graticule.prototype.getParallelPoint_ = function (lineString, extent, index) {
|
|
1140
|
+
var flatCoordinates = lineString.getFlatCoordinates();
|
|
1141
|
+
var left = 0;
|
|
1142
|
+
var right = flatCoordinates.length - 2;
|
|
1143
|
+
if (flatCoordinates[left] > flatCoordinates[right]) {
|
|
1144
|
+
left = right;
|
|
1145
|
+
right = 0;
|
|
1146
|
+
}
|
|
1147
|
+
var clampedLeft = Math.max(extent[0], flatCoordinates[left]);
|
|
1148
|
+
var clampedRight = Math.min(extent[2], flatCoordinates[right]);
|
|
1149
|
+
var lon = (0,_math_js__WEBPACK_IMPORTED_MODULE_14__.clamp)(extent[0] + Math.abs(extent[0] - extent[2]) * this.latLabelPosition_, clampedLeft, clampedRight);
|
|
1150
|
+
var coordinate1 = flatCoordinates[left + 1] +
|
|
1151
|
+
((flatCoordinates[right + 1] - flatCoordinates[left + 1]) *
|
|
1152
|
+
(lon - flatCoordinates[left])) /
|
|
1153
|
+
(flatCoordinates[right] - flatCoordinates[left]);
|
|
1154
|
+
var coordinate = [lon, coordinate1];
|
|
1155
|
+
var point = this.parallelsLabels_[index].geom;
|
|
1156
|
+
point.setCoordinates(coordinate);
|
|
1157
|
+
return point;
|
|
1158
|
+
};
|
|
1159
|
+
/**
|
|
1160
|
+
* Get the list of parallels. Parallels are lines of equal latitude.
|
|
1161
|
+
* @return {Array<LineString>} The parallels.
|
|
1162
|
+
* @api
|
|
1163
|
+
*/
|
|
1164
|
+
Graticule.prototype.getParallels = function () {
|
|
1165
|
+
return this.parallels_;
|
|
1166
|
+
};
|
|
1167
|
+
/**
|
|
1168
|
+
* @param {import("../proj/Projection.js").default} projection Projection.
|
|
1169
|
+
* @private
|
|
1170
|
+
*/
|
|
1171
|
+
Graticule.prototype.updateProjectionInfo_ = function (projection) {
|
|
1172
|
+
var epsg4326Projection = (0,_proj_js__WEBPACK_IMPORTED_MODULE_0__.get)('EPSG:4326');
|
|
1173
|
+
var worldExtent = projection.getWorldExtent();
|
|
1174
|
+
this.maxLat_ = worldExtent[3];
|
|
1175
|
+
this.maxLon_ = worldExtent[2];
|
|
1176
|
+
this.minLat_ = worldExtent[1];
|
|
1177
|
+
this.minLon_ = worldExtent[0];
|
|
1178
|
+
// If the world extent crosses the dateline define a custom transform to
|
|
1179
|
+
// return longitudes which wrap the dateline
|
|
1180
|
+
var toLonLatTransform = (0,_proj_js__WEBPACK_IMPORTED_MODULE_0__.getTransform)(projection, epsg4326Projection);
|
|
1181
|
+
if (this.minLon_ < this.maxLon_) {
|
|
1182
|
+
this.toLonLatTransform_ = toLonLatTransform;
|
|
1183
|
+
}
|
|
1184
|
+
else {
|
|
1185
|
+
var split_1 = this.minLon_ + this.maxLon_ / 2;
|
|
1186
|
+
this.maxLon_ += 360;
|
|
1187
|
+
this.toLonLatTransform_ = function (coordinates, opt_output, opt_dimension) {
|
|
1188
|
+
var dimension = opt_dimension || 2;
|
|
1189
|
+
var lonLatCoordinates = toLonLatTransform(coordinates, opt_output, dimension);
|
|
1190
|
+
for (var i = 0, l = lonLatCoordinates.length; i < l; i += dimension) {
|
|
1191
|
+
if (lonLatCoordinates[i] < split_1) {
|
|
1192
|
+
lonLatCoordinates[i] += 360;
|
|
1193
|
+
}
|
|
1194
|
+
}
|
|
1195
|
+
return lonLatCoordinates;
|
|
1196
|
+
};
|
|
1197
|
+
}
|
|
1198
|
+
// Transform the extent to get the limits of the view projection extent
|
|
1199
|
+
// which should be available to the graticule
|
|
1200
|
+
this.fromLonLatTransform_ = (0,_proj_js__WEBPACK_IMPORTED_MODULE_0__.getTransform)(epsg4326Projection, projection);
|
|
1201
|
+
var worldExtentP = (0,_extent_js__WEBPACK_IMPORTED_MODULE_10__.applyTransform)([this.minLon_, this.minLat_, this.maxLon_, this.maxLat_], this.fromLonLatTransform_, undefined, 8);
|
|
1202
|
+
this.minX_ = worldExtentP[0];
|
|
1203
|
+
this.maxX_ = worldExtentP[2];
|
|
1204
|
+
this.minY_ = worldExtentP[1];
|
|
1205
|
+
this.maxY_ = worldExtentP[3];
|
|
1206
|
+
// Determine the view projection coordinates of the extremities of the world extent
|
|
1207
|
+
// as these may lie inside a view extent (for example the pole in a polar projection)
|
|
1208
|
+
this.bottomLeft_ = this.fromLonLatTransform_([this.minLon_, this.minLat_]);
|
|
1209
|
+
this.bottomRight_ = this.fromLonLatTransform_([this.maxLon_, this.minLat_]);
|
|
1210
|
+
this.topLeft_ = this.fromLonLatTransform_([this.minLon_, this.maxLat_]);
|
|
1211
|
+
this.topRight_ = this.fromLonLatTransform_([this.maxLon_, this.maxLat_]);
|
|
1212
|
+
// Transform the projection center to lon lat
|
|
1213
|
+
// Some projections may have a void area at the poles
|
|
1214
|
+
// so replace any NaN latitudes with the min or max value closest to a pole
|
|
1215
|
+
this.projectionCenterLonLat_ = this.toLonLatTransform_((0,_extent_js__WEBPACK_IMPORTED_MODULE_10__.getCenter)(projection.getExtent()));
|
|
1216
|
+
if (isNaN(this.projectionCenterLonLat_[1])) {
|
|
1217
|
+
this.projectionCenterLonLat_[1] =
|
|
1218
|
+
Math.abs(this.maxLat_) >= Math.abs(this.minLat_)
|
|
1219
|
+
? this.maxLat_
|
|
1220
|
+
: this.minLat_;
|
|
1221
|
+
}
|
|
1222
|
+
this.projection_ = projection;
|
|
1223
|
+
};
|
|
1224
|
+
return Graticule;
|
|
1225
|
+
}(_Vector_js__WEBPACK_IMPORTED_MODULE_18__["default"]));
|
|
1226
|
+
/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (Graticule);
|
|
1227
|
+
//# sourceMappingURL=Graticule.js.map
|
|
1228
|
+
|
|
1229
|
+
/***/ }),
|
|
1230
|
+
|
|
1231
|
+
/***/ "./node_modules/ol/render.js":
|
|
1232
|
+
/*!***********************************!*\
|
|
1233
|
+
!*** ./node_modules/ol/render.js ***!
|
|
1234
|
+
\***********************************/
|
|
1235
|
+
/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
|
|
1236
|
+
|
|
1237
|
+
__webpack_require__.r(__webpack_exports__);
|
|
1238
|
+
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
1239
|
+
/* harmony export */ "getRenderPixel": () => (/* binding */ getRenderPixel),
|
|
1240
|
+
/* harmony export */ "getVectorContext": () => (/* binding */ getVectorContext),
|
|
1241
|
+
/* harmony export */ "toContext": () => (/* binding */ toContext)
|
|
1242
|
+
/* harmony export */ });
|
|
1243
|
+
/* harmony import */ var _render_canvas_Immediate_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./render/canvas/Immediate.js */ "./node_modules/ol/render/canvas/Immediate.js");
|
|
1244
|
+
/* harmony import */ var _has_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./has.js */ "./node_modules/ol/has.js");
|
|
1245
|
+
/* harmony import */ var _transform_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./transform.js */ "./node_modules/ol/transform.js");
|
|
1246
|
+
/* harmony import */ var _renderer_vector_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./renderer/vector.js */ "./node_modules/ol/renderer/vector.js");
|
|
1247
|
+
/* harmony import */ var _proj_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./proj.js */ "./node_modules/ol/proj.js");
|
|
1248
|
+
/**
|
|
1249
|
+
* @module ol/render
|
|
1250
|
+
*/
|
|
1251
|
+
|
|
1252
|
+
|
|
1253
|
+
|
|
1254
|
+
|
|
1255
|
+
|
|
1256
|
+
/**
|
|
1257
|
+
* @typedef {Object} State
|
|
1258
|
+
* @property {CanvasRenderingContext2D} context Canvas context that the layer is being rendered to.
|
|
1259
|
+
* @property {import("./Feature.js").FeatureLike} feature Feature.
|
|
1260
|
+
* @property {import("./geom/SimpleGeometry.js").default} geometry Geometry.
|
|
1261
|
+
* @property {number} pixelRatio Pixel ratio used by the layer renderer.
|
|
1262
|
+
* @property {number} resolution Resolution that the render batch was created and optimized for.
|
|
1263
|
+
* This is not the view's resolution that is being rendered.
|
|
1264
|
+
* @property {number} rotation Rotation of the rendered layer in radians.
|
|
1265
|
+
*/
|
|
1266
|
+
/**
|
|
1267
|
+
* A function to be used when sorting features before rendering.
|
|
1268
|
+
* It takes two instances of {@link module:ol/Feature~Feature} or
|
|
1269
|
+
* {@link module:ol/render/Feature~RenderFeature} and returns a `{number}`.
|
|
1270
|
+
*
|
|
1271
|
+
* @typedef {function(import("./Feature.js").FeatureLike, import("./Feature.js").FeatureLike):number} OrderFunction
|
|
1272
|
+
*/
|
|
1273
|
+
/**
|
|
1274
|
+
* @typedef {Object} ToContextOptions
|
|
1275
|
+
* @property {import("./size.js").Size} [size] Desired size of the canvas in css
|
|
1276
|
+
* pixels. When provided, both canvas and css size will be set according to the
|
|
1277
|
+
* `pixelRatio`. If not provided, the current canvas and css sizes will not be
|
|
1278
|
+
* altered.
|
|
1279
|
+
* @property {number} [pixelRatio=window.devicePixelRatio] Pixel ratio (canvas
|
|
1280
|
+
* pixel to css pixel ratio) for the canvas.
|
|
1281
|
+
*/
|
|
1282
|
+
/**
|
|
1283
|
+
* Binds a Canvas Immediate API to a canvas context, to allow drawing geometries
|
|
1284
|
+
* to the context's canvas.
|
|
1285
|
+
*
|
|
1286
|
+
* The units for geometry coordinates are css pixels relative to the top left
|
|
1287
|
+
* corner of the canvas element.
|
|
1288
|
+
* ```js
|
|
1289
|
+
* import {toContext} from 'ol/render';
|
|
1290
|
+
* import Fill from 'ol/style/Fill';
|
|
1291
|
+
* import Polygon from 'ol/geom/Polygon';
|
|
1292
|
+
*
|
|
1293
|
+
* var canvas = document.createElement('canvas');
|
|
1294
|
+
* var render = toContext(canvas.getContext('2d'),
|
|
1295
|
+
* { size: [100, 100] });
|
|
1296
|
+
* render.setFillStrokeStyle(new Fill({ color: blue }));
|
|
1297
|
+
* render.drawPolygon(
|
|
1298
|
+
* new Polygon([[[0, 0], [100, 100], [100, 0], [0, 0]]]));
|
|
1299
|
+
* ```
|
|
1300
|
+
*
|
|
1301
|
+
* @param {CanvasRenderingContext2D} context Canvas context.
|
|
1302
|
+
* @param {ToContextOptions} [opt_options] Options.
|
|
1303
|
+
* @return {CanvasImmediateRenderer} Canvas Immediate.
|
|
1304
|
+
* @api
|
|
1305
|
+
*/
|
|
1306
|
+
function toContext(context, opt_options) {
|
|
1307
|
+
var canvas = context.canvas;
|
|
1308
|
+
var options = opt_options ? opt_options : {};
|
|
1309
|
+
var pixelRatio = options.pixelRatio || _has_js__WEBPACK_IMPORTED_MODULE_1__.DEVICE_PIXEL_RATIO;
|
|
1310
|
+
var size = options.size;
|
|
1311
|
+
if (size) {
|
|
1312
|
+
canvas.width = size[0] * pixelRatio;
|
|
1313
|
+
canvas.height = size[1] * pixelRatio;
|
|
1314
|
+
canvas.style.width = size[0] + 'px';
|
|
1315
|
+
canvas.style.height = size[1] + 'px';
|
|
1316
|
+
}
|
|
1317
|
+
var extent = [0, 0, canvas.width, canvas.height];
|
|
1318
|
+
var transform = (0,_transform_js__WEBPACK_IMPORTED_MODULE_2__.scale)((0,_transform_js__WEBPACK_IMPORTED_MODULE_2__.create)(), pixelRatio, pixelRatio);
|
|
1319
|
+
return new _render_canvas_Immediate_js__WEBPACK_IMPORTED_MODULE_3__["default"](context, pixelRatio, extent, transform, 0);
|
|
1320
|
+
}
|
|
1321
|
+
/**
|
|
1322
|
+
* Gets a vector context for drawing to the event's canvas.
|
|
1323
|
+
* @param {import("./render/Event.js").default} event Render event.
|
|
1324
|
+
* @return {CanvasImmediateRenderer} Vector context.
|
|
1325
|
+
* @api
|
|
1326
|
+
*/
|
|
1327
|
+
function getVectorContext(event) {
|
|
1328
|
+
if (!(event.context instanceof CanvasRenderingContext2D)) {
|
|
1329
|
+
throw new Error('Only works for render events from Canvas 2D layers');
|
|
1330
|
+
}
|
|
1331
|
+
// canvas may be at a different pixel ratio than frameState.pixelRatio
|
|
1332
|
+
var canvasPixelRatio = event.inversePixelTransform[0];
|
|
1333
|
+
var frameState = event.frameState;
|
|
1334
|
+
var transform = (0,_transform_js__WEBPACK_IMPORTED_MODULE_2__.multiply)(event.inversePixelTransform.slice(), frameState.coordinateToPixelTransform);
|
|
1335
|
+
var squaredTolerance = (0,_renderer_vector_js__WEBPACK_IMPORTED_MODULE_4__.getSquaredTolerance)(frameState.viewState.resolution, canvasPixelRatio);
|
|
1336
|
+
var userTransform;
|
|
1337
|
+
var userProjection = (0,_proj_js__WEBPACK_IMPORTED_MODULE_0__.getUserProjection)();
|
|
1338
|
+
if (userProjection) {
|
|
1339
|
+
userTransform = (0,_proj_js__WEBPACK_IMPORTED_MODULE_0__.getTransformFromProjections)(userProjection, frameState.viewState.projection);
|
|
1340
|
+
}
|
|
1341
|
+
return new _render_canvas_Immediate_js__WEBPACK_IMPORTED_MODULE_3__["default"](event.context, canvasPixelRatio, frameState.extent, transform, frameState.viewState.rotation, squaredTolerance, userTransform);
|
|
1342
|
+
}
|
|
1343
|
+
/**
|
|
1344
|
+
* Gets the pixel of the event's canvas context from the map viewport's CSS pixel.
|
|
1345
|
+
* @param {import("./render/Event.js").default} event Render event.
|
|
1346
|
+
* @param {import("./pixel.js").Pixel} pixel CSS pixel relative to the top-left
|
|
1347
|
+
* corner of the map viewport.
|
|
1348
|
+
* @return {import("./pixel.js").Pixel} Pixel on the event's canvas context.
|
|
1349
|
+
* @api
|
|
1350
|
+
*/
|
|
1351
|
+
function getRenderPixel(event, pixel) {
|
|
1352
|
+
return (0,_transform_js__WEBPACK_IMPORTED_MODULE_2__.apply)(event.inversePixelTransform, pixel.slice(0));
|
|
1353
|
+
}
|
|
1354
|
+
//# sourceMappingURL=render.js.map
|
|
1355
|
+
|
|
1356
|
+
/***/ })
|
|
1357
|
+
|
|
1358
|
+
}])
|
|
1359
|
+
//# sourceMappingURL=vendors-node_modules_ol_layer_Graticule_js.js.map
|