vislite 1.3.0 → 1.4.0-alpha.0
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/AUTHORS.txt +6 -6
- package/CHANGELOG +307 -300
- package/LICENSE +20 -20
- package/README.md +284 -284
- package/lib/BarLayout/index.es.d.ts +3 -0
- package/lib/BarLayout/index.es.js +467 -0
- package/lib/BarLayout/index.es.min.d.ts +3 -0
- package/lib/BarLayout/index.es.min.js +10 -0
- package/lib/Buffer/index.es.js +35 -35
- package/lib/Buffer/index.es.min.js +1 -1
- package/lib/Canvas/index.es.js +774 -774
- package/lib/Canvas/index.es.min.js +1 -1
- package/lib/Cardinal/index.es.js +90 -90
- package/lib/Cardinal/index.es.min.js +1 -1
- package/lib/Eoap/index.es.js +33 -33
- package/lib/Eoap/index.es.min.js +1 -1
- package/lib/Hermite/index.es.js +35 -35
- package/lib/Hermite/index.es.min.js +1 -1
- package/lib/MapCoordinate/index.es.js +199 -199
- package/lib/MapCoordinate/index.es.min.js +1 -1
- package/lib/Matrix4/index.es.js +124 -124
- package/lib/Matrix4/index.es.min.js +1 -1
- package/lib/Mercator/index.es.js +19 -19
- package/lib/Mercator/index.es.min.js +1 -1
- package/lib/PieLayout/index.es.d.ts +3 -0
- package/lib/PieLayout/index.es.js +234 -0
- package/lib/PieLayout/index.es.min.d.ts +3 -0
- package/lib/PieLayout/index.es.min.js +9 -0
- package/lib/RawCanvas/index.es.js +704 -704
- package/lib/RawCanvas/index.es.min.js +1 -1
- package/lib/SVG/index.es.js +514 -491
- package/lib/SVG/index.es.min.js +2 -2
- package/lib/Shader/index.es.js +35 -35
- package/lib/Shader/index.es.min.js +1 -1
- package/lib/Texture/index.es.js +53 -53
- package/lib/Texture/index.es.min.js +1 -1
- package/lib/TreeLayout/index.es.js +316 -309
- package/lib/TreeLayout/index.es.min.js +6 -2
- package/lib/animation/index.es.js +16 -9
- package/lib/animation/index.es.min.js +6 -2
- package/lib/assemble/index.es.js +17 -17
- package/lib/assemble/index.es.min.js +1 -1
- package/lib/getLoopColors/index.es.js +35 -35
- package/lib/getLoopColors/index.es.min.js +1 -1
- package/lib/getWebGLContext/index.es.js +62 -62
- package/lib/getWebGLContext/index.es.min.js +1 -1
- package/lib/index.umd.js +2675 -2327
- package/lib/index.umd.min.js +12 -2
- package/lib/initOption/index.es.js +6 -6
- package/lib/initOption/index.es.min.js +1 -1
- package/lib/mergeOption/index.es.js +34 -34
- package/lib/mergeOption/index.es.min.js +1 -1
- package/lib/move/index.es.js +7 -7
- package/lib/move/index.es.min.js +1 -1
- package/lib/rotate/index.es.js +7 -7
- package/lib/rotate/index.es.min.js +1 -1
- package/lib/ruler/index.es.js +137 -137
- package/lib/ruler/index.es.min.js +1 -1
- package/lib/scale/index.es.js +6 -6
- package/lib/scale/index.es.min.js +1 -1
- package/lib/throttle/index.es.js +7 -2
- package/lib/throttle/index.es.min.js +5 -1
- package/minialipay/ui-canvas/drawImage.js +35 -35
- package/minialipay/ui-canvas/index.acss +4 -4
- package/minialipay/ui-canvas/index.axml +3 -3
- package/minialipay/ui-canvas/index.d.ts +1 -1
- package/minialipay/ui-canvas/index.js +100 -100
- package/minialipay/ui-canvas/index.json +6 -6
- package/miniprogram/ui-canvas/drawImage.js +35 -35
- package/miniprogram/ui-canvas/index.js +117 -117
- package/miniprogram/ui-canvas/index.json +4 -4
- package/miniprogram/ui-canvas/index.wxml +4 -4
- package/miniprogram/ui-canvas/index.wxss +5 -5
- package/package/BarLayout/index.ts +3 -0
- package/package/Buffer/index.ts +2 -2
- package/package/Canvas/index.ts +2 -2
- package/package/Cardinal/index.ts +2 -2
- package/package/Eoap/index.ts +2 -2
- package/package/Hermite/index.ts +2 -2
- package/package/MapCoordinate/index.ts +2 -2
- package/package/Matrix4/index.ts +2 -2
- package/package/Mercator/index.ts +2 -2
- package/package/PieLayout/index.ts +3 -0
- package/package/RawCanvas/index.ts +2 -2
- package/package/SVG/index.ts +2 -2
- package/package/Shader/index.ts +2 -2
- package/package/Texture/index.ts +2 -2
- package/package/TreeLayout/index.ts +2 -2
- package/package/animation/index.ts +2 -2
- package/package/assemble/index.ts +2 -2
- package/package/getLoopColors/index.ts +2 -2
- package/package/getWebGLContext/index.ts +40 -40
- package/package/index.ts +84 -80
- package/package/initOption/index.ts +2 -2
- package/package/mergeOption/index.ts +2 -2
- package/package/move/index.ts +2 -2
- package/package/rotate/index.ts +2 -2
- package/package/ruler/index.ts +2 -2
- package/package/scale/index.ts +2 -2
- package/package/throttle/index.ts +2 -2
- package/package.json +75 -75
- package/src/Canvas.ts +84 -84
- package/src/Eoap.ts +66 -66
- package/src/Matrix4/index.ts +84 -84
- package/src/Matrix4/move.ts +12 -12
- package/src/Matrix4/rotate.ts +15 -15
- package/src/Matrix4/scale.ts +11 -11
- package/src/Matrix4/transform.ts +64 -64
- package/src/Mercator.ts +27 -27
- package/src/SVG.ts +55 -24
- package/src/common/assemble.ts +22 -22
- package/src/common/canvas/arc.ts +51 -51
- package/src/common/canvas/config.ts +176 -176
- package/src/common/canvas/default.ts +64 -64
- package/src/common/canvas/gradient.ts +31 -31
- package/src/common/canvas/index.ts +188 -188
- package/src/common/canvas/painter.ts +443 -443
- package/src/common/canvas/texts.ts +18 -18
- package/src/common/map/getBoundary.ts +15 -15
- package/src/common/map/tool.ts +29 -29
- package/src/common/option.ts +29 -29
- package/src/common/setStyle.ts +5 -5
- package/src/common/svg/config.ts +213 -213
- package/src/common/svg/default.ts +29 -29
- package/src/common/svg/gradient.ts +53 -53
- package/src/common/svg/index.ts +332 -332
- package/src/common/svg/tool.ts +51 -51
- package/src/common/tree/index.ts +25 -25
- package/src/common/tree/toInnerTree.ts +61 -61
- package/src/common/tree/toPlainTree.ts +135 -132
- package/src/common/type.ts +26 -26
- package/src/common/webgl/buffer.ts +79 -79
- package/src/common/webgl/getWebGLContext.ts +45 -45
- package/src/common/webgl/shader.ts +75 -75
- package/src/common/webgl/texture.ts +98 -97
- package/src/coordinate/MapCoordinate.ts +80 -80
- package/src/getLoopColors.ts +42 -42
- package/src/interpolation/Cardinal.ts +110 -110
- package/src/interpolation/Hermite.ts +65 -65
- package/src/layout/BarLayout.ts +249 -0
- package/src/layout/PieLayout.ts +142 -0
- package/src/layout/TreeLayout.ts +197 -194
- package/src/move.ts +7 -7
- package/src/rotate.ts +7 -7
- package/src/ruler.ts +209 -209
- package/src/scale.ts +6 -6
- package/types/Bar.d.ts +92 -0
- package/types/BarConfig.d.ts +5 -0
- package/types/BarLayout.d.ts +49 -0
- package/types/BarOption.d.ts +32 -0
- package/types/Buffer.d.ts +23 -23
- package/types/Canvas.d.ts +352 -352
- package/types/CanvasConfig.d.ts +88 -88
- package/types/CanvasOption.d.ts +8 -8
- package/types/CanvasOpts.d.ts +9 -9
- package/types/Cardinal.d.ts +13 -13
- package/types/Gradient.d.ts +14 -14
- package/types/Hermite.d.ts +18 -18
- package/types/Map.d.ts +9 -9
- package/types/MapConfig.d.ts +27 -27
- package/types/MapCoordinate.d.ts +22 -22
- package/types/Matrix4.d.ts +47 -47
- package/types/Pie.d.ts +74 -0
- package/types/PieConfig.d.ts +27 -0
- package/types/PieLayout.d.ts +41 -0
- package/types/PieOption.d.ts +22 -0
- package/types/SVG.d.ts +247 -243
- package/types/SVGConfig.d.ts +71 -71
- package/types/Shader.d.ts +16 -16
- package/types/Texture.d.ts +16 -16
- package/types/Tree.d.ts +74 -74
- package/types/TreeConfig.d.ts +36 -36
- package/types/TreeLayout.d.ts +59 -59
- package/types/TreeOption.d.ts +48 -48
- package/types/animation.d.ts +5 -5
- package/types/assemble.d.ts +5 -5
- package/types/getLoopColors.d.ts +5 -5
- package/types/getWebGLContext.d.ts +7 -7
- package/types/index.d.ts +195 -179
- package/types/move.d.ts +5 -5
- package/types/option.d.ts +12 -12
- package/types/painterConfig.d.ts +4 -4
- package/types/rotate.d.ts +5 -5
- package/types/ruler.d.ts +10 -10
- package/types/scale.d.ts +5 -5
- package/types/throttle.d.ts +5 -5
- package/types/throttleOption.d.ts +1 -1
- package/types/ui-canvas.d.ts +4 -4
- package/types/uni-canvas.d.ts +3 -3
- package/uni-app/drawImage.js +19 -19
- package/uni-app/ui-canvas.vue +284 -284
|
@@ -1,217 +1,217 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* MapCoordinate of VISLite JavaScript Library v1.
|
|
2
|
+
* MapCoordinate of VISLite JavaScript Library v1.4.0-alpha.0
|
|
3
3
|
* git+https://github.com/oi-contrib/VISLite.git
|
|
4
4
|
*/
|
|
5
|
-
var toString = Object.prototype.toString;
|
|
6
|
-
function getType(value) {
|
|
7
|
-
if (value == null) {
|
|
8
|
-
return value === undefined ? '[object Undefined]' : '[object Null]';
|
|
9
|
-
}
|
|
10
|
-
return toString.call(value);
|
|
11
|
-
}
|
|
12
|
-
function isPlainObject(value) {
|
|
13
|
-
if (value === null || typeof value !== 'object' || getType(value) != '[object Object]') {
|
|
14
|
-
return false;
|
|
15
|
-
}
|
|
16
|
-
if (Object.getPrototypeOf(value) === null) {
|
|
17
|
-
return true;
|
|
18
|
-
}
|
|
19
|
-
var proto = value;
|
|
20
|
-
while (Object.getPrototypeOf(proto) !== null) {
|
|
21
|
-
proto = Object.getPrototypeOf(proto);
|
|
22
|
-
}
|
|
23
|
-
return Object.getPrototypeOf(value) === proto;
|
|
5
|
+
var toString = Object.prototype.toString;
|
|
6
|
+
function getType(value) {
|
|
7
|
+
if (value == null) {
|
|
8
|
+
return value === undefined ? '[object Undefined]' : '[object Null]';
|
|
9
|
+
}
|
|
10
|
+
return toString.call(value);
|
|
11
|
+
}
|
|
12
|
+
function isPlainObject(value) {
|
|
13
|
+
if (value === null || typeof value !== 'object' || getType(value) != '[object Object]') {
|
|
14
|
+
return false;
|
|
15
|
+
}
|
|
16
|
+
if (Object.getPrototypeOf(value) === null) {
|
|
17
|
+
return true;
|
|
18
|
+
}
|
|
19
|
+
var proto = value;
|
|
20
|
+
while (Object.getPrototypeOf(proto) !== null) {
|
|
21
|
+
proto = Object.getPrototypeOf(proto);
|
|
22
|
+
}
|
|
23
|
+
return Object.getPrototypeOf(value) === proto;
|
|
24
24
|
}
|
|
25
25
|
|
|
26
|
-
function initOption(setOption, defaultOption) {
|
|
27
|
-
for (var key in setOption) {
|
|
28
|
-
defaultOption[key] = setOption[key];
|
|
29
|
-
}
|
|
30
|
-
return defaultOption;
|
|
31
|
-
}
|
|
32
|
-
function mergeOption(oldOption, newOption) {
|
|
33
|
-
(function doit(oldOption, newOption) {
|
|
34
|
-
for (var key in newOption) {
|
|
35
|
-
var value = newOption[key];
|
|
36
|
-
if (isPlainObject(value)) {
|
|
37
|
-
if (!oldOption[key])
|
|
38
|
-
oldOption[key] = {};
|
|
39
|
-
doit(oldOption[key], newOption[key]);
|
|
40
|
-
}
|
|
41
|
-
else {
|
|
42
|
-
oldOption[key] = value;
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
})(oldOption, newOption);
|
|
26
|
+
function initOption(setOption, defaultOption) {
|
|
27
|
+
for (var key in setOption) {
|
|
28
|
+
defaultOption[key] = setOption[key];
|
|
29
|
+
}
|
|
30
|
+
return defaultOption;
|
|
31
|
+
}
|
|
32
|
+
function mergeOption(oldOption, newOption) {
|
|
33
|
+
(function doit(oldOption, newOption) {
|
|
34
|
+
for (var key in newOption) {
|
|
35
|
+
var value = newOption[key];
|
|
36
|
+
if (isPlainObject(value)) {
|
|
37
|
+
if (!oldOption[key])
|
|
38
|
+
oldOption[key] = {};
|
|
39
|
+
doit(oldOption[key], newOption[key]);
|
|
40
|
+
}
|
|
41
|
+
else {
|
|
42
|
+
oldOption[key] = value;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
})(oldOption, newOption);
|
|
46
46
|
}
|
|
47
47
|
|
|
48
|
-
function mllData(geoJson) {
|
|
49
|
-
var minLongitude = null, maxLongitude = null, minLatitude = null, maxLatitude = null;
|
|
50
|
-
var forPolygon = function (coordinates) {
|
|
51
|
-
for (var j = 0; j < coordinates.length; j++) {
|
|
52
|
-
for (var k = 0; k < coordinates[j].length; k++) {
|
|
53
|
-
var longitude = coordinates[j][k][0], latitude = coordinates[j][k][1];
|
|
54
|
-
if (minLongitude == void 0 || minLongitude > longitude)
|
|
55
|
-
minLongitude = longitude;
|
|
56
|
-
if (maxLongitude == void 0 || maxLongitude < longitude)
|
|
57
|
-
maxLongitude = longitude;
|
|
58
|
-
if (minLatitude == void 0 || minLatitude > latitude)
|
|
59
|
-
minLatitude = latitude;
|
|
60
|
-
if (maxLatitude == void 0 || maxLatitude < latitude)
|
|
61
|
-
maxLatitude = latitude;
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
};
|
|
65
|
-
var features = geoJson.features;
|
|
66
|
-
for (var i = 0; i < features.length; i++) {
|
|
67
|
-
if (features[i].geometry.type == "Polygon") {
|
|
68
|
-
forPolygon(features[i].geometry.coordinates);
|
|
69
|
-
}
|
|
70
|
-
else if (features[i].geometry.type == "MultiPolygon") {
|
|
71
|
-
for (var j = 0; j < features[i].geometry.coordinates.length; j++) {
|
|
72
|
-
forPolygon(features[i].geometry.coordinates[j]);
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
return [minLongitude, maxLongitude, minLatitude, maxLatitude];
|
|
48
|
+
function mllData(geoJson) {
|
|
49
|
+
var minLongitude = null, maxLongitude = null, minLatitude = null, maxLatitude = null;
|
|
50
|
+
var forPolygon = function (coordinates) {
|
|
51
|
+
for (var j = 0; j < coordinates.length; j++) {
|
|
52
|
+
for (var k = 0; k < coordinates[j].length; k++) {
|
|
53
|
+
var longitude = coordinates[j][k][0], latitude = coordinates[j][k][1];
|
|
54
|
+
if (minLongitude == void 0 || minLongitude > longitude)
|
|
55
|
+
minLongitude = longitude;
|
|
56
|
+
if (maxLongitude == void 0 || maxLongitude < longitude)
|
|
57
|
+
maxLongitude = longitude;
|
|
58
|
+
if (minLatitude == void 0 || minLatitude > latitude)
|
|
59
|
+
minLatitude = latitude;
|
|
60
|
+
if (maxLatitude == void 0 || maxLatitude < latitude)
|
|
61
|
+
maxLatitude = latitude;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
};
|
|
65
|
+
var features = geoJson.features;
|
|
66
|
+
for (var i = 0; i < features.length; i++) {
|
|
67
|
+
if (features[i].geometry.type == "Polygon") {
|
|
68
|
+
forPolygon(features[i].geometry.coordinates);
|
|
69
|
+
}
|
|
70
|
+
else if (features[i].geometry.type == "MultiPolygon") {
|
|
71
|
+
for (var j = 0; j < features[i].geometry.coordinates.length; j++) {
|
|
72
|
+
forPolygon(features[i].geometry.coordinates[j]);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
return [minLongitude, maxLongitude, minLatitude, maxLatitude];
|
|
77
77
|
}
|
|
78
78
|
|
|
79
|
-
function getBoundary () {
|
|
80
|
-
var geos = [];
|
|
81
|
-
for (var _i = 0; _i < arguments.length; _i++) {
|
|
82
|
-
geos[_i] = arguments[_i];
|
|
83
|
-
}
|
|
84
|
-
var minLongitude = null, maxLongitude = null, minLatitude = null, maxLatitude = null;
|
|
85
|
-
for (var _a = 0, geos_1 = geos; _a < geos_1.length; _a++) {
|
|
86
|
-
var geoJson = geos_1[_a];
|
|
87
|
-
var _b = mllData(geoJson), _minLongitude = _b[0], _maxLongitude = _b[1], _minLatitude = _b[2], _maxLatitude = _b[3];
|
|
88
|
-
if (minLongitude == void 0 || _minLongitude < minLongitude)
|
|
89
|
-
minLongitude = _minLongitude;
|
|
90
|
-
if (maxLongitude == void 0 || _maxLongitude > maxLongitude)
|
|
91
|
-
maxLongitude = _maxLongitude;
|
|
92
|
-
if (minLatitude == void 0 || _minLatitude < minLatitude)
|
|
93
|
-
minLatitude = _minLatitude;
|
|
94
|
-
if (maxLatitude == void 0 || _maxLatitude > maxLatitude)
|
|
95
|
-
maxLatitude = _maxLatitude;
|
|
96
|
-
}
|
|
97
|
-
return [minLongitude, maxLongitude, minLatitude, maxLatitude];
|
|
79
|
+
function getBoundary () {
|
|
80
|
+
var geos = [];
|
|
81
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
82
|
+
geos[_i] = arguments[_i];
|
|
83
|
+
}
|
|
84
|
+
var minLongitude = null, maxLongitude = null, minLatitude = null, maxLatitude = null;
|
|
85
|
+
for (var _a = 0, geos_1 = geos; _a < geos_1.length; _a++) {
|
|
86
|
+
var geoJson = geos_1[_a];
|
|
87
|
+
var _b = mllData(geoJson), _minLongitude = _b[0], _maxLongitude = _b[1], _minLatitude = _b[2], _maxLatitude = _b[3];
|
|
88
|
+
if (minLongitude == void 0 || _minLongitude < minLongitude)
|
|
89
|
+
minLongitude = _minLongitude;
|
|
90
|
+
if (maxLongitude == void 0 || _maxLongitude > maxLongitude)
|
|
91
|
+
maxLongitude = _maxLongitude;
|
|
92
|
+
if (minLatitude == void 0 || _minLatitude < minLatitude)
|
|
93
|
+
minLatitude = _minLatitude;
|
|
94
|
+
if (maxLatitude == void 0 || _maxLatitude > maxLatitude)
|
|
95
|
+
maxLatitude = _maxLatitude;
|
|
96
|
+
}
|
|
97
|
+
return [minLongitude, maxLongitude, minLatitude, maxLatitude];
|
|
98
98
|
}
|
|
99
99
|
|
|
100
|
-
var Mercator = (function () {
|
|
101
|
-
function Mercator(scale, center) {
|
|
102
|
-
if (scale === void 0) { scale = 7; }
|
|
103
|
-
if (center === void 0) { center = [107, 36]; }
|
|
104
|
-
this.name = 'Mercator';
|
|
105
|
-
var perimeter = 100 * scale * Math.PI;
|
|
106
|
-
var help = perimeter / 180;
|
|
107
|
-
var cx = help * center[0];
|
|
108
|
-
var cy = -1 * help * center[1];
|
|
109
|
-
this.use = function (λ, φ) {
|
|
110
|
-
return [
|
|
111
|
-
(help * λ - cx) * 0.8,
|
|
112
|
-
-1 * help * φ - cy,
|
|
113
|
-
0
|
|
114
|
-
];
|
|
115
|
-
};
|
|
116
|
-
}
|
|
117
|
-
return Mercator;
|
|
100
|
+
var Mercator = (function () {
|
|
101
|
+
function Mercator(scale, center) {
|
|
102
|
+
if (scale === void 0) { scale = 7; }
|
|
103
|
+
if (center === void 0) { center = [107, 36]; }
|
|
104
|
+
this.name = 'Mercator';
|
|
105
|
+
var perimeter = 100 * scale * Math.PI;
|
|
106
|
+
var help = perimeter / 180;
|
|
107
|
+
var cx = help * center[0];
|
|
108
|
+
var cy = -1 * help * center[1];
|
|
109
|
+
this.use = function (λ, φ) {
|
|
110
|
+
return [
|
|
111
|
+
(help * λ - cx) * 0.8,
|
|
112
|
+
-1 * help * φ - cy,
|
|
113
|
+
0
|
|
114
|
+
];
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
return Mercator;
|
|
118
118
|
}());
|
|
119
119
|
|
|
120
|
-
var rotateX = function (deg, x, y, z) {
|
|
121
|
-
var cos = Math.cos(deg), sin = Math.sin(deg);
|
|
122
|
-
return [x, y * cos - z * sin, y * sin + z * cos];
|
|
123
|
-
};
|
|
124
|
-
var rotateY = function (deg, x, y, z) {
|
|
125
|
-
var cos = Math.cos(deg), sin = Math.sin(deg);
|
|
126
|
-
return [z * sin + x * cos, y, z * cos - x * sin];
|
|
127
|
-
};
|
|
128
|
-
var rotateZ = function (deg, x, y, z) {
|
|
129
|
-
var cos = Math.cos(deg), sin = Math.sin(deg);
|
|
130
|
-
return [x * cos - y * sin, x * sin + y * cos, z];
|
|
131
|
-
};
|
|
132
|
-
var Eoap = (function () {
|
|
133
|
-
function Eoap(scale, center) {
|
|
134
|
-
if (scale === void 0) { scale = 7; }
|
|
135
|
-
if (center === void 0) { center = [107, 36]; }
|
|
136
|
-
this.name = 'Eoap';
|
|
137
|
-
this.__scale = scale;
|
|
138
|
-
this.__center = center;
|
|
139
|
-
}
|
|
140
|
-
Eoap.prototype.use = function (λ, φ) {
|
|
141
|
-
var p = rotateY((360 - φ) / 180 * Math.PI, 100 * this.__scale, 0, 0);
|
|
142
|
-
p = rotateZ(λ / 180 * Math.PI, p[0], p[1], p[2]);
|
|
143
|
-
p = rotateZ((90 - this.__center[0]) / 180 * Math.PI, p[0], p[1], p[2]);
|
|
144
|
-
p = rotateX((90 - this.__center[1]) / 180 * Math.PI, p[0], p[1], p[2]);
|
|
145
|
-
return [
|
|
146
|
-
-p[0],
|
|
147
|
-
p[1],
|
|
148
|
-
p[2]
|
|
149
|
-
];
|
|
150
|
-
};
|
|
151
|
-
return Eoap;
|
|
120
|
+
var rotateX = function (deg, x, y, z) {
|
|
121
|
+
var cos = Math.cos(deg), sin = Math.sin(deg);
|
|
122
|
+
return [x, y * cos - z * sin, y * sin + z * cos];
|
|
123
|
+
};
|
|
124
|
+
var rotateY = function (deg, x, y, z) {
|
|
125
|
+
var cos = Math.cos(deg), sin = Math.sin(deg);
|
|
126
|
+
return [z * sin + x * cos, y, z * cos - x * sin];
|
|
127
|
+
};
|
|
128
|
+
var rotateZ = function (deg, x, y, z) {
|
|
129
|
+
var cos = Math.cos(deg), sin = Math.sin(deg);
|
|
130
|
+
return [x * cos - y * sin, x * sin + y * cos, z];
|
|
131
|
+
};
|
|
132
|
+
var Eoap = (function () {
|
|
133
|
+
function Eoap(scale, center) {
|
|
134
|
+
if (scale === void 0) { scale = 7; }
|
|
135
|
+
if (center === void 0) { center = [107, 36]; }
|
|
136
|
+
this.name = 'Eoap';
|
|
137
|
+
this.__scale = scale;
|
|
138
|
+
this.__center = center;
|
|
139
|
+
}
|
|
140
|
+
Eoap.prototype.use = function (λ, φ) {
|
|
141
|
+
var p = rotateY((360 - φ) / 180 * Math.PI, 100 * this.__scale, 0, 0);
|
|
142
|
+
p = rotateZ(λ / 180 * Math.PI, p[0], p[1], p[2]);
|
|
143
|
+
p = rotateZ((90 - this.__center[0]) / 180 * Math.PI, p[0], p[1], p[2]);
|
|
144
|
+
p = rotateX((90 - this.__center[1]) / 180 * Math.PI, p[0], p[1], p[2]);
|
|
145
|
+
return [
|
|
146
|
+
-p[0],
|
|
147
|
+
p[1],
|
|
148
|
+
p[2]
|
|
149
|
+
];
|
|
150
|
+
};
|
|
151
|
+
return Eoap;
|
|
152
152
|
}());
|
|
153
153
|
|
|
154
|
-
var MapCoordinate = (function () {
|
|
155
|
-
function MapCoordinate(config) {
|
|
156
|
-
if (config === void 0) { config = {}; }
|
|
157
|
-
this.name = 'MapCoordinate';
|
|
158
|
-
this.__config = initOption(config, {
|
|
159
|
-
api: "Mercator",
|
|
160
|
-
width: 400,
|
|
161
|
-
height: 300,
|
|
162
|
-
left: 0,
|
|
163
|
-
top: 0
|
|
164
|
-
});
|
|
165
|
-
}
|
|
166
|
-
MapCoordinate.prototype.$$updateMap = function () {
|
|
167
|
-
var _a = this.__boundary, minLongitude = _a[0], maxLongitude = _a[1], minLatitude = _a[2], maxLatitude = _a[3];
|
|
168
|
-
if (this.__config.api == "Eoap") {
|
|
169
|
-
var xScale = this.__config.width * 0.836 / (maxLongitude - minLongitude);
|
|
170
|
-
var yScale = this.__config.height * 0.557 / (maxLatitude - minLatitude);
|
|
171
|
-
this.__map = new Eoap(xScale < yScale ? xScale : yScale, [
|
|
172
|
-
(minLongitude + maxLongitude) * 0.5 * 0.9778,
|
|
173
|
-
(minLatitude + maxLatitude) * 0.5 * 1.025
|
|
174
|
-
]);
|
|
175
|
-
}
|
|
176
|
-
else if (this.__config.api == "Mercator") {
|
|
177
|
-
var xScale = this.__config.width * 0.72 / (maxLongitude - minLongitude);
|
|
178
|
-
var yScale = this.__config.height * 0.575 / (maxLatitude - minLatitude);
|
|
179
|
-
this.__map = new Mercator(xScale < yScale ? xScale : yScale, [
|
|
180
|
-
(minLongitude + maxLongitude) * 0.5,
|
|
181
|
-
(minLatitude + maxLatitude) * 0.5
|
|
182
|
-
]);
|
|
183
|
-
}
|
|
184
|
-
else {
|
|
185
|
-
throw new Error("Unexpected API types:" + this.__config.api);
|
|
186
|
-
}
|
|
187
|
-
};
|
|
188
|
-
MapCoordinate.prototype.setConfig = function (config) {
|
|
189
|
-
mergeOption(this.__config, config);
|
|
190
|
-
this.$$updateMap();
|
|
191
|
-
return this;
|
|
192
|
-
};
|
|
193
|
-
MapCoordinate.prototype.setGeos = function () {
|
|
194
|
-
var geos = [];
|
|
195
|
-
for (var _i = 0; _i < arguments.length; _i++) {
|
|
196
|
-
geos[_i] = arguments[_i];
|
|
197
|
-
}
|
|
198
|
-
this.__boundary = getBoundary.apply(void 0, geos);
|
|
199
|
-
this.$$updateMap();
|
|
200
|
-
return this;
|
|
201
|
-
};
|
|
202
|
-
MapCoordinate.prototype.use = function (λ, φ) {
|
|
203
|
-
if (this.__map) {
|
|
204
|
-
var dxyz = this.__map.use(λ, φ);
|
|
205
|
-
return [
|
|
206
|
-
this.__config.left + this.__config.width * 0.5 + dxyz[0],
|
|
207
|
-
this.__config.top + this.__config.height * 0.5 + dxyz[1],
|
|
208
|
-
];
|
|
209
|
-
}
|
|
210
|
-
else {
|
|
211
|
-
throw new Error("Geographic data not set");
|
|
212
|
-
}
|
|
213
|
-
};
|
|
214
|
-
return MapCoordinate;
|
|
154
|
+
var MapCoordinate = (function () {
|
|
155
|
+
function MapCoordinate(config) {
|
|
156
|
+
if (config === void 0) { config = {}; }
|
|
157
|
+
this.name = 'MapCoordinate';
|
|
158
|
+
this.__config = initOption(config, {
|
|
159
|
+
api: "Mercator",
|
|
160
|
+
width: 400,
|
|
161
|
+
height: 300,
|
|
162
|
+
left: 0,
|
|
163
|
+
top: 0
|
|
164
|
+
});
|
|
165
|
+
}
|
|
166
|
+
MapCoordinate.prototype.$$updateMap = function () {
|
|
167
|
+
var _a = this.__boundary, minLongitude = _a[0], maxLongitude = _a[1], minLatitude = _a[2], maxLatitude = _a[3];
|
|
168
|
+
if (this.__config.api == "Eoap") {
|
|
169
|
+
var xScale = this.__config.width * 0.836 / (maxLongitude - minLongitude);
|
|
170
|
+
var yScale = this.__config.height * 0.557 / (maxLatitude - minLatitude);
|
|
171
|
+
this.__map = new Eoap(xScale < yScale ? xScale : yScale, [
|
|
172
|
+
(minLongitude + maxLongitude) * 0.5 * 0.9778,
|
|
173
|
+
(minLatitude + maxLatitude) * 0.5 * 1.025
|
|
174
|
+
]);
|
|
175
|
+
}
|
|
176
|
+
else if (this.__config.api == "Mercator") {
|
|
177
|
+
var xScale = this.__config.width * 0.72 / (maxLongitude - minLongitude);
|
|
178
|
+
var yScale = this.__config.height * 0.575 / (maxLatitude - minLatitude);
|
|
179
|
+
this.__map = new Mercator(xScale < yScale ? xScale : yScale, [
|
|
180
|
+
(minLongitude + maxLongitude) * 0.5,
|
|
181
|
+
(minLatitude + maxLatitude) * 0.5
|
|
182
|
+
]);
|
|
183
|
+
}
|
|
184
|
+
else {
|
|
185
|
+
throw new Error("Unexpected API types:" + this.__config.api);
|
|
186
|
+
}
|
|
187
|
+
};
|
|
188
|
+
MapCoordinate.prototype.setConfig = function (config) {
|
|
189
|
+
mergeOption(this.__config, config);
|
|
190
|
+
this.$$updateMap();
|
|
191
|
+
return this;
|
|
192
|
+
};
|
|
193
|
+
MapCoordinate.prototype.setGeos = function () {
|
|
194
|
+
var geos = [];
|
|
195
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
196
|
+
geos[_i] = arguments[_i];
|
|
197
|
+
}
|
|
198
|
+
this.__boundary = getBoundary.apply(void 0, geos);
|
|
199
|
+
this.$$updateMap();
|
|
200
|
+
return this;
|
|
201
|
+
};
|
|
202
|
+
MapCoordinate.prototype.use = function (λ, φ) {
|
|
203
|
+
if (this.__map) {
|
|
204
|
+
var dxyz = this.__map.use(λ, φ);
|
|
205
|
+
return [
|
|
206
|
+
this.__config.left + this.__config.width * 0.5 + dxyz[0],
|
|
207
|
+
this.__config.top + this.__config.height * 0.5 + dxyz[1],
|
|
208
|
+
];
|
|
209
|
+
}
|
|
210
|
+
else {
|
|
211
|
+
throw new Error("Geographic data not set");
|
|
212
|
+
}
|
|
213
|
+
};
|
|
214
|
+
return MapCoordinate;
|
|
215
215
|
}());
|
|
216
216
|
|
|
217
217
|
export { MapCoordinate as default };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* MapCoordinate of VISLite JavaScript Library v1.
|
|
2
|
+
* MapCoordinate of VISLite JavaScript Library v1.4.0-alpha.0
|
|
3
3
|
* git+https://github.com/oi-contrib/VISLite.git
|
|
4
4
|
*/
|
|
5
5
|
var t=Object.prototype.toString;function n(n){if(null===n||"object"!=typeof n||"[object Object]"!=function(n){return null==n?void 0===n?"[object Undefined]":"[object Null]":t.call(n)}(n))return!1;if(null===Object.getPrototypeOf(n))return!0;for(var e=n;null!==Object.getPrototypeOf(e);)e=Object.getPrototypeOf(e);return Object.getPrototypeOf(n)===e}function e(t){for(var n=null,e=null,o=null,r=null,i=function(t){for(var i=0;i<t.length;i++)for(var a=0;a<t[i].length;a++){var u=t[i][a][0],h=t[i][a][1];(null==n||n>u)&&(n=u),(null==e||e<u)&&(e=u),(null==o||o>h)&&(o=h),(null==r||r<h)&&(r=h)}},a=t.features,u=0;u<a.length;u++)if("Polygon"==a[u].geometry.type)i(a[u].geometry.coordinates);else if("MultiPolygon"==a[u].geometry.type)for(var h=0;h<a[u].geometry.coordinates.length;h++)i(a[u].geometry.coordinates[h]);return[n,e,o,r]}function o(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];for(var o=null,r=null,i=null,a=null,u=0,h=t;u<h.length;u++){var l=e(h[u]),f=l[0],c=l[1],s=l[2],_=l[3];(null==o||f<o)&&(o=f),(null==r||c>r)&&(r=c),(null==i||s<i)&&(i=s),(null==a||_>a)&&(a=_)}return[o,r,i,a]}var r=function(t,n){void 0===t&&(t=7),void 0===n&&(n=[107,36]),this.name="Mercator";var e=100*t*Math.PI/180,o=e*n[0],r=-1*e*n[1];this.use=function(t,n){return[.8*(e*t-o),-1*e*n-r,0]}},i=function(t,n,e,o){var r=Math.cos(t),i=Math.sin(t);return[n*r-e*i,n*i+e*r,o]},a=function(){function t(t,n){void 0===t&&(t=7),void 0===n&&(n=[107,36]),this.name="Eoap",this.__scale=t,this.__center=n}return t.prototype.use=function(t,n){var e,o,r,a,u,h,l=(e=(360-n)/180*Math.PI,o=100*this.__scale,r=0,a=0,u=Math.cos(e),h=Math.sin(e),[a*h+o*u,r,a*u-o*h]);return l=i(t/180*Math.PI,l[0],l[1],l[2]),l=i((90-this.__center[0])/180*Math.PI,l[0],l[1],l[2]),l=function(t,n,e,o){var r=Math.cos(t),i=Math.sin(t);return[n,e*r-o*i,e*i+o*r]}((90-this.__center[1])/180*Math.PI,l[0],l[1],l[2]),[-l[0],l[1],l[2]]},t}(),u=function(){function t(t){void 0===t&&(t={}),this.name="MapCoordinate",this.__config=function(t,n){for(var e in t)n[e]=t[e];return n}(t,{api:"Mercator",width:400,height:300,left:0,top:0})}return t.prototype.$$updateMap=function(){var t=this.__boundary,n=t[0],e=t[1],o=t[2],i=t[3];if("Eoap"==this.__config.api){var u=.836*this.__config.width/(e-n),h=.557*this.__config.height/(i-o);this.__map=new a(u<h?u:h,[.5*(n+e)*.9778,.5*(o+i)*1.025])}else{if("Mercator"!=this.__config.api)throw new Error("Unexpected API types:"+this.__config.api);u=.72*this.__config.width/(e-n),h=.575*this.__config.height/(i-o);this.__map=new r(u<h?u:h,[.5*(n+e),.5*(o+i)])}},t.prototype.setConfig=function(t){return function t(e,o){for(var r in o){var i=o[r];n(i)?(e[r]||(e[r]={}),t(e[r],o[r])):e[r]=i}}(this.__config,t),this.$$updateMap(),this},t.prototype.setGeos=function(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];return this.__boundary=o.apply(void 0,t),this.$$updateMap(),this},t.prototype.use=function(t,n){if(this.__map){var e=this.__map.use(t,n);return[this.__config.left+.5*this.__config.width+e[0],this.__config.top+.5*this.__config.height+e[1]]}throw new Error("Geographic data not set")},t}();export{u as default};
|