@progress/kendo-charts 1.21.0 → 1.23.0-dev.202201120958
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/dist/cdn/js/kendo-charts.js +1 -1
- package/dist/cdn/main.js +1 -1
- package/dist/es/barcode/barcode-validator.js +50 -0
- package/dist/es/barcode.js +1 -0
- package/dist/es/common/keys.js +25 -0
- package/dist/es/common.js +1 -0
- package/dist/es/drawing-utils.js +27 -3
- package/dist/es/main.js +1 -0
- package/dist/es/map/attribution.js +157 -0
- package/dist/es/map/crs.js +277 -0
- package/dist/es/map/datums.js +16 -0
- package/dist/es/map/extent.js +129 -0
- package/dist/es/map/layers/bubble.js +185 -0
- package/dist/es/map/layers/layer.js +140 -0
- package/dist/es/map/layers/marker.js +348 -0
- package/dist/es/map/layers/shape.js +390 -0
- package/dist/es/map/layers/tile.js +481 -0
- package/dist/es/map/location.js +201 -0
- package/dist/es/map/map.js +929 -0
- package/dist/es/map/navigator.js +174 -0
- package/dist/es/map/scroller/draggable.js +454 -0
- package/dist/es/map/scroller/fx.js +119 -0
- package/dist/es/map/scroller/observable.js +151 -0
- package/dist/es/map/scroller/scroller.js +746 -0
- package/dist/es/map/scroller/user-events.js +712 -0
- package/dist/es/map/utils.js +450 -0
- package/dist/es/map/zoom.js +139 -0
- package/dist/es/map.js +1 -0
- package/dist/es/qrcode/qrcode-validator.js +24 -0
- package/dist/es/qrcode.js +1 -0
- package/dist/es/services/map-service.js +15 -0
- package/dist/es2015/barcode/barcode-validator.js +48 -0
- package/dist/es2015/barcode.js +1 -0
- package/dist/es2015/common/keys.js +25 -0
- package/dist/es2015/common.js +1 -0
- package/dist/es2015/drawing-utils.js +43 -3
- package/dist/es2015/main.js +1 -0
- package/dist/es2015/map/attribution.js +147 -0
- package/dist/es2015/map/crs.js +233 -0
- package/dist/es2015/map/datums.js +16 -0
- package/dist/es2015/map/extent.js +115 -0
- package/dist/es2015/map/layers/bubble.js +167 -0
- package/dist/es2015/map/layers/layer.js +134 -0
- package/dist/es2015/map/layers/marker.js +328 -0
- package/dist/es2015/map/layers/shape.js +370 -0
- package/dist/es2015/map/layers/tile.js +455 -0
- package/dist/es2015/map/location.js +193 -0
- package/dist/es2015/map/map.js +905 -0
- package/dist/es2015/map/navigator.js +169 -0
- package/dist/es2015/map/scroller/draggable.js +418 -0
- package/dist/es2015/map/scroller/fx.js +112 -0
- package/dist/es2015/map/scroller/observable.js +143 -0
- package/dist/es2015/map/scroller/scroller.js +716 -0
- package/dist/es2015/map/scroller/user-events.js +694 -0
- package/dist/es2015/map/utils.js +450 -0
- package/dist/es2015/map/zoom.js +134 -0
- package/dist/es2015/map.js +1 -0
- package/dist/es2015/qrcode/qrcode-validator.js +22 -0
- package/dist/es2015/qrcode.js +1 -0
- package/dist/es2015/services/map-service.js +15 -0
- package/dist/npm/barcode.d.ts +4 -1
- package/dist/npm/main.d.ts +2 -0
- package/dist/npm/main.js +6227 -329
- package/dist/npm/map.d.ts +4 -0
- package/dist/npm/qrcode.d.ts +3 -0
- package/dist/npm/validation.d.ts +9 -0
- package/dist/systemjs/kendo-charts.js +1 -1
- package/package.json +3 -3
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
let keys = {
|
|
2
|
+
INSERT: 45,
|
|
3
|
+
DELETE: 46,
|
|
4
|
+
BACKSPACE: 8,
|
|
5
|
+
TAB: 9,
|
|
6
|
+
ENTER: 13,
|
|
7
|
+
ESC: 27,
|
|
8
|
+
LEFT: 37,
|
|
9
|
+
UP: 38,
|
|
10
|
+
RIGHT: 39,
|
|
11
|
+
DOWN: 40,
|
|
12
|
+
END: 35,
|
|
13
|
+
HOME: 36,
|
|
14
|
+
SPACEBAR: 32,
|
|
15
|
+
PAGEUP: 33,
|
|
16
|
+
PAGEDOWN: 34,
|
|
17
|
+
F2: 113,
|
|
18
|
+
F10: 121,
|
|
19
|
+
F12: 123,
|
|
20
|
+
NUMPAD_PLUS: 107,
|
|
21
|
+
NUMPAD_MINUS: 109,
|
|
22
|
+
NUMPAD_DOT: 110
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
export default keys;
|
package/dist/es2015/common.js
CHANGED
|
@@ -30,5 +30,6 @@ export { default as elementScale } from './common/element-scale';
|
|
|
30
30
|
export { default as autoTextColor } from './common/auto-text-color';
|
|
31
31
|
export { default as createHashSet } from './common/create-hash-set';
|
|
32
32
|
export { default as defaultErrorHandler } from './common/default-error-handler';
|
|
33
|
+
export { default as keys } from './common/keys';
|
|
33
34
|
|
|
34
35
|
export * from './drawing-utils';
|
|
@@ -1,5 +1,45 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
drawing,
|
|
3
|
+
Class,
|
|
4
|
+
logToConsole
|
|
5
|
+
} from '@progress/kendo-drawing';
|
|
2
6
|
|
|
3
|
-
const {
|
|
7
|
+
const {
|
|
8
|
+
append,
|
|
9
|
+
bindEvents,
|
|
10
|
+
defined,
|
|
11
|
+
deg,
|
|
12
|
+
elementOffset,
|
|
13
|
+
elementSize,
|
|
14
|
+
eventCoordinates,
|
|
15
|
+
eventElement,
|
|
16
|
+
hashKey,
|
|
17
|
+
last,
|
|
18
|
+
limitValue,
|
|
19
|
+
objectKey,
|
|
20
|
+
rad,
|
|
21
|
+
round,
|
|
22
|
+
unbindEvents,
|
|
23
|
+
valueOrDefault
|
|
24
|
+
} = drawing.util;
|
|
4
25
|
|
|
5
|
-
export {
|
|
26
|
+
export {
|
|
27
|
+
append,
|
|
28
|
+
bindEvents,
|
|
29
|
+
Class,
|
|
30
|
+
defined,
|
|
31
|
+
deg,
|
|
32
|
+
elementOffset,
|
|
33
|
+
elementSize,
|
|
34
|
+
eventCoordinates,
|
|
35
|
+
eventElement,
|
|
36
|
+
hashKey,
|
|
37
|
+
last,
|
|
38
|
+
limitValue,
|
|
39
|
+
logToConsole,
|
|
40
|
+
objectKey,
|
|
41
|
+
rad,
|
|
42
|
+
round,
|
|
43
|
+
unbindEvents,
|
|
44
|
+
valueOrDefault
|
|
45
|
+
};
|
package/dist/es2015/main.js
CHANGED
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Class,
|
|
3
|
+
addClass,
|
|
4
|
+
defined,
|
|
5
|
+
valueOrDefault,
|
|
6
|
+
deepExtend,
|
|
7
|
+
setDefaultOptions
|
|
8
|
+
} from '../common';
|
|
9
|
+
|
|
10
|
+
import TemplateService from '../services/template-service';
|
|
11
|
+
|
|
12
|
+
import {
|
|
13
|
+
appendHtml,
|
|
14
|
+
removeChildren
|
|
15
|
+
} from './utils';
|
|
16
|
+
|
|
17
|
+
let template = TemplateService.compile;
|
|
18
|
+
|
|
19
|
+
export class Attribution extends Class {
|
|
20
|
+
constructor(element, options) {
|
|
21
|
+
super();
|
|
22
|
+
this.element = element;
|
|
23
|
+
|
|
24
|
+
this._initOptions(options);
|
|
25
|
+
this.items = [];
|
|
26
|
+
|
|
27
|
+
addClass(this.element, 'k-widget k-attribution');
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
_initOptions(options) {
|
|
31
|
+
this.options = deepExtend({}, this.options, options);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
filter(extent, zoom) {
|
|
35
|
+
this._extent = extent;
|
|
36
|
+
this._zoom = zoom;
|
|
37
|
+
this._render();
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
add(item) {
|
|
41
|
+
let newItem = item;
|
|
42
|
+
|
|
43
|
+
if (defined(item)) {
|
|
44
|
+
if (typeof item === 'string') {
|
|
45
|
+
newItem = {
|
|
46
|
+
text: item
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
this.items.push(newItem);
|
|
51
|
+
this._render();
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
remove(text) {
|
|
56
|
+
let result = [];
|
|
57
|
+
|
|
58
|
+
for (let i = 0; i < this.items.length; i++) {
|
|
59
|
+
let item = this.items[i];
|
|
60
|
+
|
|
61
|
+
if (item.text !== text) {
|
|
62
|
+
result.push(item);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
this.items = result;
|
|
67
|
+
this._render();
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
clear() {
|
|
71
|
+
this.items = [];
|
|
72
|
+
removeChildren(this.element);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
_render() {
|
|
76
|
+
let result = [];
|
|
77
|
+
let itemTemplate = template(this.options.itemTemplate);
|
|
78
|
+
|
|
79
|
+
for (let i = 0; i < this.items.length; i++) {
|
|
80
|
+
let item = this.items[i];
|
|
81
|
+
let text = this._itemText(item);
|
|
82
|
+
|
|
83
|
+
if (text !== '') {
|
|
84
|
+
result.push(itemTemplate({
|
|
85
|
+
text: text
|
|
86
|
+
}));
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
if (result.length > 0) {
|
|
91
|
+
removeChildren(this.element);
|
|
92
|
+
|
|
93
|
+
const html = result.join(this.options.separator);
|
|
94
|
+
appendHtml(html, this.element);
|
|
95
|
+
|
|
96
|
+
this.showElement();
|
|
97
|
+
} else {
|
|
98
|
+
this.hideElement();
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
hideElement() {
|
|
103
|
+
this.element.style.display = "none";
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
showElement() {
|
|
107
|
+
this.element.style.display = "";
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
_itemText(item) {
|
|
111
|
+
let text = '';
|
|
112
|
+
let inZoomLevel = this._inZoomLevel(item.minZoom, item.maxZoom);
|
|
113
|
+
let inArea = this._inArea(item.extent);
|
|
114
|
+
|
|
115
|
+
if (inZoomLevel && inArea) {
|
|
116
|
+
text += item.text;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
return text;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
_inZoomLevel(min, max) {
|
|
123
|
+
let result = true;
|
|
124
|
+
let newMin = valueOrDefault(min, -Number.MAX_VALUE);
|
|
125
|
+
let newMax = valueOrDefault(max, Number.MAX_VALUE);
|
|
126
|
+
|
|
127
|
+
result = this._zoom > newMin && this._zoom < newMax;
|
|
128
|
+
return result;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
_inArea(area) {
|
|
132
|
+
let result = true;
|
|
133
|
+
|
|
134
|
+
if (area) {
|
|
135
|
+
result = area.contains(this._extent);
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
return result;
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
setDefaultOptions(Attribution, {
|
|
143
|
+
name: 'Attribution',
|
|
144
|
+
separator: ' | ',
|
|
145
|
+
itemTemplate: '#= text #'
|
|
146
|
+
});
|
|
147
|
+
|
|
@@ -0,0 +1,233 @@
|
|
|
1
|
+
import {
|
|
2
|
+
geometry as g
|
|
3
|
+
} from '@progress/kendo-drawing';
|
|
4
|
+
|
|
5
|
+
import {
|
|
6
|
+
Class,
|
|
7
|
+
setDefaultOptions,
|
|
8
|
+
limitValue,
|
|
9
|
+
rad,
|
|
10
|
+
deg,
|
|
11
|
+
deepExtend
|
|
12
|
+
} from '../common';
|
|
13
|
+
|
|
14
|
+
import {
|
|
15
|
+
Location
|
|
16
|
+
} from './location';
|
|
17
|
+
|
|
18
|
+
import {
|
|
19
|
+
datums
|
|
20
|
+
} from './datums';
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
let math = Math,
|
|
24
|
+
atan = math.atan,
|
|
25
|
+
exp = math.exp,
|
|
26
|
+
pow = math.pow,
|
|
27
|
+
sin = math.sin,
|
|
28
|
+
log = math.log,
|
|
29
|
+
tan = math.tan,
|
|
30
|
+
Point = g.Point;
|
|
31
|
+
|
|
32
|
+
let PI = math.PI,
|
|
33
|
+
PI_DIV_2 = PI / 2,
|
|
34
|
+
PI_DIV_4 = PI / 4,
|
|
35
|
+
DEG_TO_RAD = PI / 180;
|
|
36
|
+
|
|
37
|
+
let WGS84 = datums.WGS84;
|
|
38
|
+
|
|
39
|
+
// WGS 84 / World Mercator
|
|
40
|
+
export class Mercator extends Class {
|
|
41
|
+
constructor(options) {
|
|
42
|
+
super();
|
|
43
|
+
this.initProperties();
|
|
44
|
+
this._initOptions(options);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
_initOptions(options) {
|
|
48
|
+
this.options = deepExtend({}, this.options, options);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
initProperties() {
|
|
52
|
+
// super.initProperties();
|
|
53
|
+
|
|
54
|
+
deepExtend(this, {
|
|
55
|
+
MAX_LNG: 180,
|
|
56
|
+
MAX_LAT: 85.0840590501,
|
|
57
|
+
INVERSE_ITERATIONS: 15,
|
|
58
|
+
INVERSE_CONVERGENCE: 1e-12
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
forward(loc, clamp) {
|
|
63
|
+
let proj = this,
|
|
64
|
+
options = proj.options,
|
|
65
|
+
datum = options.datum,
|
|
66
|
+
r = datum.a,
|
|
67
|
+
lng0 = options.centralMeridian,
|
|
68
|
+
lat = limitValue(loc.lat, -proj.MAX_LAT, proj.MAX_LAT),
|
|
69
|
+
lng = clamp ? limitValue(loc.lng, -proj.MAX_LNG, proj.MAX_LNG) : loc.lng,
|
|
70
|
+
x = rad(lng - lng0) * r,
|
|
71
|
+
y = proj._projectLat(lat);
|
|
72
|
+
return new Point(x, y);
|
|
73
|
+
}
|
|
74
|
+
_projectLat(lat) {
|
|
75
|
+
let datum = this.options.datum,
|
|
76
|
+
ecc = datum.e,
|
|
77
|
+
r = datum.a,
|
|
78
|
+
y = rad(lat),
|
|
79
|
+
ts = tan(PI_DIV_4 + y / 2),
|
|
80
|
+
con = ecc * sin(y),
|
|
81
|
+
p = pow((1 - con) / (1 + con), ecc / 2);
|
|
82
|
+
|
|
83
|
+
// See: http://en.wikipedia.org/wiki/Mercator_projection#Generalization_to_the_ellipsoid
|
|
84
|
+
return r * log(ts * p);
|
|
85
|
+
}
|
|
86
|
+
inverse(point, clamp) {
|
|
87
|
+
let proj = this,
|
|
88
|
+
options = proj.options,
|
|
89
|
+
datum = options.datum,
|
|
90
|
+
r = datum.a,
|
|
91
|
+
lng0 = options.centralMeridian,
|
|
92
|
+
lng = point.x / (DEG_TO_RAD * r) + lng0,
|
|
93
|
+
lat = limitValue(proj._inverseY(point.y), -proj.MAX_LAT, proj.MAX_LAT);
|
|
94
|
+
if (clamp) {
|
|
95
|
+
lng = limitValue(lng, -proj.MAX_LNG, proj.MAX_LNG);
|
|
96
|
+
}
|
|
97
|
+
return new Location(lat, lng);
|
|
98
|
+
}
|
|
99
|
+
_inverseY(y) {
|
|
100
|
+
let proj = this,
|
|
101
|
+
datum = proj.options.datum,
|
|
102
|
+
r = datum.a,
|
|
103
|
+
ecc = datum.e,
|
|
104
|
+
ecch = ecc / 2,
|
|
105
|
+
ts = exp(-y / r),
|
|
106
|
+
phi = PI_DIV_2 - 2 * atan(ts),
|
|
107
|
+
i;
|
|
108
|
+
for (i = 0; i <= proj.INVERSE_ITERATIONS; i++) {
|
|
109
|
+
let con = ecc * sin(phi),
|
|
110
|
+
p = pow((1 - con) / (1 + con), ecch),
|
|
111
|
+
dphi = PI_DIV_2 - 2 * atan(ts * p) - phi;
|
|
112
|
+
phi += dphi;
|
|
113
|
+
if (math.abs(dphi) <= proj.INVERSE_CONVERGENCE) {
|
|
114
|
+
break;
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
return deg(phi);
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
setDefaultOptions(Mercator, {
|
|
122
|
+
centralMeridian: 0,
|
|
123
|
+
datum: WGS84
|
|
124
|
+
});
|
|
125
|
+
|
|
126
|
+
|
|
127
|
+
// WGS 84 / Pseudo-Mercator
|
|
128
|
+
// Used by Google Maps, Bing, OSM, etc.
|
|
129
|
+
// Spherical projection of ellipsoidal coordinates.
|
|
130
|
+
export class SphericalMercator extends Mercator {
|
|
131
|
+
initProperties() {
|
|
132
|
+
super.initProperties();
|
|
133
|
+
|
|
134
|
+
deepExtend(this, {
|
|
135
|
+
MAX_LAT: 85.0511287798
|
|
136
|
+
});
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
_projectLat(lat) {
|
|
140
|
+
let r = this.options.datum.a,
|
|
141
|
+
y = rad(lat),
|
|
142
|
+
ts = tan(PI_DIV_4 + y / 2);
|
|
143
|
+
return r * log(ts);
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
_inverseY(y) {
|
|
147
|
+
let r = this.options.datum.a,
|
|
148
|
+
ts = exp(-y / r);
|
|
149
|
+
return deg(PI_DIV_2 - 2 * atan(ts));
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
export class Equirectangular extends Class {
|
|
154
|
+
forward(loc) {
|
|
155
|
+
return new Point(loc.lng, loc.lat);
|
|
156
|
+
}
|
|
157
|
+
inverse(point) {
|
|
158
|
+
return new Location(point.y, point.x);
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
// This is the projected coordinate system used for rendering maps in Google Maps, OpenStreetMap, etc
|
|
163
|
+
// Unit: metre
|
|
164
|
+
// Geodetic CRS: WGS 84
|
|
165
|
+
// Scope: Certain Web mapping and visualisation applications. It is not a recognised geodetic system: for that see ellipsoidal Mercator CRS code 3395 (WGS 84 / World Mercator).
|
|
166
|
+
// Remarks: Uses spherical development of ellipsoidal coordinates. Relative to WGS 84 / World Mercator (CRS code 3395) errors of 0.7 percent in scale and differences in northing of up to 43km in the map (equivalent to 21km on the ground) may arise.
|
|
167
|
+
// Area of use: World between 85.06°S and 85.06°N.
|
|
168
|
+
// Coordinate system: Cartesian 2D CS. Axes: easting, northing (X,Y). Orientations: east, north. UoM: m.
|
|
169
|
+
// https://epsg.io/3857
|
|
170
|
+
export class EPSG3857 extends Class {
|
|
171
|
+
constructor() {
|
|
172
|
+
super();
|
|
173
|
+
let crs = this,
|
|
174
|
+
proj = crs._proj = new SphericalMercator();
|
|
175
|
+
let c = this.c = 2 * PI * proj.options.datum.a;
|
|
176
|
+
|
|
177
|
+
// transfrom matrix
|
|
178
|
+
// Scale circumference to 1, mirror Y and shift origin to top left
|
|
179
|
+
this._tm = g.transform().translate(0.5, 0.5).scale(1 / c, -1 / c);
|
|
180
|
+
|
|
181
|
+
// Inverse transform matrix
|
|
182
|
+
this._itm = g.transform().scale(c, -c).translate(-0.5, -0.5);
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
// Location <-> Point (screen coordinates for a given scale)
|
|
186
|
+
toPoint(loc, scale, clamp) {
|
|
187
|
+
let point = this._proj.forward(loc, clamp);
|
|
188
|
+
return point.transform(this._tm).scale(scale || 1);
|
|
189
|
+
}
|
|
190
|
+
toLocation(point, scale, clamp) {
|
|
191
|
+
let newPoint = point.clone().scale(1 / (scale || 1)).transform(this._itm);
|
|
192
|
+
return this._proj.inverse(newPoint, clamp);
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
// Unit: metre
|
|
197
|
+
// Geodetic CRS: WGS 84
|
|
198
|
+
// Scope: Very small scale mapping.
|
|
199
|
+
// Remarks: Euro-centric view of world excluding polar areas.
|
|
200
|
+
// Area of use: World between 80°S and 84°N.
|
|
201
|
+
// Coordinate system: Cartesian 2D CS. Axes: easting, northing (E,N). Orientations: east, north. UoM: m.
|
|
202
|
+
// https://epsg.io/3395
|
|
203
|
+
export class EPSG3395 extends Class {
|
|
204
|
+
constructor() {
|
|
205
|
+
super();
|
|
206
|
+
this._proj = new Mercator();
|
|
207
|
+
}
|
|
208
|
+
toPoint(loc) {
|
|
209
|
+
return this._proj.forward(loc);
|
|
210
|
+
}
|
|
211
|
+
toLocation(point) {
|
|
212
|
+
return this._proj.inverse(point);
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
// Unit: degree
|
|
217
|
+
// Geodetic CRS: WGS 84
|
|
218
|
+
// Scope: Horizontal component of 3D system. Used by the GPS satellite navigation system and for NATO military geodetic surveying.
|
|
219
|
+
// Area of use: World.
|
|
220
|
+
// Coordinate system: Ellipsoidal 2D CS. Axes: latitude, longitude. Orientations: north, east. UoM: degree
|
|
221
|
+
// https://epsg.io/4326
|
|
222
|
+
export class EPSG4326 extends Class {
|
|
223
|
+
constructor() {
|
|
224
|
+
super();
|
|
225
|
+
this._proj = new Equirectangular();
|
|
226
|
+
}
|
|
227
|
+
toPoint(loc) {
|
|
228
|
+
return this._proj.forward(loc);
|
|
229
|
+
}
|
|
230
|
+
toLocation(point) {
|
|
231
|
+
return this._proj.inverse(point);
|
|
232
|
+
}
|
|
233
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
// Coordinate reference system
|
|
2
|
+
// World Geodetic System of 1984
|
|
3
|
+
const WGS84 = {
|
|
4
|
+
a: 6378137, // Semi-major radius
|
|
5
|
+
b: 6356752.314245179, // Semi-minor radius
|
|
6
|
+
f: 0.0033528106647474805, // Flattening
|
|
7
|
+
e: 0.08181919084262149 // Eccentricity
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
// Geographic coordinate systems use a spheroid to calculate positions on the earth.
|
|
11
|
+
// A datum defines the position of the spheroid relative to the center of the earth
|
|
12
|
+
// it provides a frame of reference for measuring locations on the surface of the earth
|
|
13
|
+
// and defines the origin and orientation of latitude and longitude lines.
|
|
14
|
+
export const datums = {
|
|
15
|
+
WGS84
|
|
16
|
+
};
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Class,
|
|
3
|
+
valueOrDefault
|
|
4
|
+
} from '../common';
|
|
5
|
+
|
|
6
|
+
import { Location } from './location';
|
|
7
|
+
|
|
8
|
+
let math = Math,
|
|
9
|
+
max = math.max,
|
|
10
|
+
min = math.min;
|
|
11
|
+
|
|
12
|
+
export class Extent extends Class {
|
|
13
|
+
constructor(initialNw, initialSe) {
|
|
14
|
+
super();
|
|
15
|
+
let nw = Location.create(initialNw);
|
|
16
|
+
let se = Location.create(initialSe);
|
|
17
|
+
|
|
18
|
+
if (nw.lng + 180 > se.lng + 180 && nw.lat + 90 < se.lat + 90) {
|
|
19
|
+
this.se = nw;
|
|
20
|
+
this.nw = se;
|
|
21
|
+
} else {
|
|
22
|
+
this.se = se;
|
|
23
|
+
this.nw = nw;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
contains(loc) {
|
|
28
|
+
let nw = this.nw, se = this.se, lng = valueOrDefault(loc.lng, loc[1]), lat = valueOrDefault(loc.lat, loc[0]);
|
|
29
|
+
|
|
30
|
+
return loc &&
|
|
31
|
+
lng + 180 >= nw.lng + 180 && lng + 180 <= se.lng + 180 &&
|
|
32
|
+
lat + 90 >= se.lat + 90 && lat + 90 <= nw.lat + 90;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
center() {
|
|
36
|
+
let nw = this.nw;
|
|
37
|
+
let se = this.se;
|
|
38
|
+
let lng = nw.lng + (se.lng - nw.lng) / 2;
|
|
39
|
+
let lat = nw.lat + (se.lat - nw.lat) / 2;
|
|
40
|
+
|
|
41
|
+
return new Location(lat, lng);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
containsAny(locs) {
|
|
45
|
+
let result = false;
|
|
46
|
+
|
|
47
|
+
for (let i = 0; i < locs.length; i++) {
|
|
48
|
+
result = result || this.contains(locs[i]);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
return result;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
include(loc) {
|
|
55
|
+
let nw = this.nw, se = this.se, lng = valueOrDefault(loc.lng, loc[1]), lat = valueOrDefault(loc.lat, loc[0]);
|
|
56
|
+
|
|
57
|
+
nw.lng = min(nw.lng, lng);
|
|
58
|
+
nw.lat = max(nw.lat, lat);
|
|
59
|
+
se.lng = max(se.lng, lng);
|
|
60
|
+
se.lat = min(se.lat, lat);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
includeAll(locs) {
|
|
64
|
+
for (let i = 0; i < locs.length; i++) {
|
|
65
|
+
this.include(locs[i]);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
edges() {
|
|
70
|
+
let nw = this.nw, se = this.se;
|
|
71
|
+
|
|
72
|
+
return {
|
|
73
|
+
nw: this.nw,
|
|
74
|
+
ne: new Location(nw.lat, se.lng),
|
|
75
|
+
se: this.se,
|
|
76
|
+
sw: new Location(se.lat, nw.lng)
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
toArray() {
|
|
81
|
+
let nw = this.nw, se = this.se;
|
|
82
|
+
|
|
83
|
+
return [
|
|
84
|
+
nw,
|
|
85
|
+
new Location(nw.lat, se.lng),
|
|
86
|
+
se,
|
|
87
|
+
new Location(se.lat, nw.lng)
|
|
88
|
+
];
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
overlaps(extent) {
|
|
92
|
+
return this.containsAny(extent.toArray()) ||
|
|
93
|
+
extent.containsAny(this.toArray());
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
static create(a, b) {
|
|
97
|
+
if (a instanceof Extent) {
|
|
98
|
+
return a;
|
|
99
|
+
} else if (a && b) {
|
|
100
|
+
return new Extent(a, b);
|
|
101
|
+
} else if (a && a.length === 4 && !b) {
|
|
102
|
+
return new Extent([
|
|
103
|
+
a[0],
|
|
104
|
+
a[1]
|
|
105
|
+
], [
|
|
106
|
+
a[2],
|
|
107
|
+
a[3]
|
|
108
|
+
]);
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
static get World() {
|
|
113
|
+
return new Extent([ 90, -180 ], [ -90, 180 ]);
|
|
114
|
+
}
|
|
115
|
+
}
|