vislite 1.4.0-alpha.0 → 1.4.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/CHANGELOG +307 -307
- package/lib/BarLayout/index.es.js +437 -437
- package/lib/BarLayout/index.es.min.js +2 -2
- 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.js +213 -213
- package/lib/PieLayout/index.es.min.js +2 -2
- package/lib/RawCanvas/index.es.js +704 -704
- package/lib/RawCanvas/index.es.min.js +1 -1
- package/lib/SVG/index.es.js +514 -514
- package/lib/SVG/index.es.min.js +1 -1
- 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 +397 -397
- package/lib/TreeLayout/index.es.min.js +2 -2
- package/lib/animation/index.es.js +110 -106
- package/lib/animation/index.es.min.js +3 -3
- 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 +2795 -2791
- package/lib/index.umd.min.js +5 -5
- 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 +51 -51
- package/lib/throttle/index.es.min.js +2 -2
- package/package/BarLayout/index.ts +2 -2
- package/package/PieLayout/index.ts +2 -2
- package/package/animation/index.ts +6 -3
- package/package/index.ts +84 -84
- package/package/throttle/index.ts +2 -2
- package/package.json +75 -75
- package/src/SVG.ts +55 -55
- package/src/common/canvas/gradient.ts +31 -31
- 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/tree/toPlainTree.ts +135 -135
- package/src/common/webgl/texture.ts +98 -98
- package/src/layout/BarLayout.ts +248 -248
- package/src/layout/PieLayout.ts +141 -141
- package/src/layout/TreeLayout.ts +197 -197
- package/types/Bar.d.ts +91 -91
- package/types/BarConfig.d.ts +4 -4
- package/types/BarLayout.d.ts +48 -48
- package/types/BarOption.d.ts +31 -31
- package/types/Pie.d.ts +73 -73
- package/types/PieConfig.d.ts +26 -26
- package/types/PieLayout.d.ts +40 -40
- package/types/PieOption.d.ts +21 -21
- package/types/SVG.d.ts +247 -247
- package/types/animation.d.ts +11 -5
- package/types/index.d.ts +195 -195
- package/types/throttle.d.ts +5 -5
|
@@ -1,217 +1,217 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* MapCoordinate of VISLite JavaScript Library v1.4.0
|
|
2
|
+
* MapCoordinate of VISLite JavaScript Library v1.4.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.4.0
|
|
2
|
+
* MapCoordinate of VISLite JavaScript Library v1.4.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};
|