@antv/l7-layers 2.5.36 → 2.5.37-mini12
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/lib/core/BaseLayer.js +10 -4
- package/lib/core/BaseLayer.js.map +1 -1
- package/lib/core/BaseModel.js +1 -1
- package/lib/core/BaseModel.js.map +1 -1
- package/lib/core/shape/Path.js +5 -4
- package/lib/core/shape/Path.js.map +1 -1
- package/lib/core/shape/extrude.js +1 -1
- package/lib/core/triangulation.js +13 -9
- package/lib/core/triangulation.js.map +1 -1
- package/lib/earth/utils.js +1 -1
- package/lib/heatmap/models/heatmap.js +13 -18
- package/lib/heatmap/models/heatmap.js.map +1 -1
- package/lib/image/models/image.js +28 -7
- package/lib/image/models/image.js.map +1 -1
- package/lib/imagetile/index.js +95 -0
- package/lib/imagetile/index.js.map +1 -0
- package/lib/imagetile/models/imagetile.js +177 -0
- package/lib/imagetile/models/imagetile.js.map +1 -0
- package/lib/imagetile/models/index.js +17 -0
- package/lib/imagetile/models/index.js.map +1 -0
- package/lib/imagetile/utils/ImageTile.js +99 -0
- package/lib/imagetile/utils/ImageTile.js.map +1 -0
- package/lib/imagetile/utils/Tile.js +324 -0
- package/lib/imagetile/utils/Tile.js.map +1 -0
- package/lib/imagetile/utils/lruCache.js +109 -0
- package/lib/imagetile/utils/lruCache.js.map +1 -0
- package/lib/imagetile/utils/tileCache.js +58 -0
- package/lib/imagetile/utils/tileCache.js.map +1 -0
- package/lib/index.js +16 -8
- package/lib/index.js.map +1 -1
- package/lib/line/index.js +3 -0
- package/lib/line/index.js.map +1 -1
- package/lib/line/models/arc.js +2 -2
- package/lib/line/models/arc_3d.js +2 -2
- package/lib/line/models/arcmini.js +160 -0
- package/lib/line/models/arcmini.js.map +1 -0
- package/lib/line/models/great_circle.js +2 -2
- package/lib/line/models/index.js +3 -0
- package/lib/line/models/index.js.map +1 -1
- package/lib/line/models/line.js +2 -2
- package/lib/plugins/DataMappingPlugin.js +1 -1
- package/lib/plugins/DataSourcePlugin.js +5 -1
- package/lib/plugins/DataSourcePlugin.js.map +1 -1
- package/lib/plugins/FeatureScalePlugin.js +5 -1
- package/lib/plugins/FeatureScalePlugin.js.map +1 -1
- package/lib/plugins/LayerAnimateStylePlugin.js +1 -1
- package/lib/plugins/LayerStylePlugin.js.map +1 -1
- package/lib/plugins/LightingPlugin.js +5 -3
- package/lib/plugins/LightingPlugin.js.map +1 -1
- package/lib/plugins/MultiPassRendererPlugin.js +1 -1
- package/lib/plugins/ShaderUniformPlugin.js +3 -1
- package/lib/plugins/ShaderUniformPlugin.js.map +1 -1
- package/lib/plugins/UpdateStyleAttributePlugin.js +6 -6
- package/lib/plugins/UpdateStyleAttributePlugin.js.map +1 -1
- package/lib/point/models/image.js.map +1 -1
- package/lib/point/shape/Path.js +5 -4
- package/lib/point/shape/Path.js.map +1 -1
- package/lib/raster/raster.js +1 -1
- package/lib/utils/dataMappingStyle.js +1 -1
- package/lib/utils/extrude_polyline.js +1 -1
- package/lib/utils/polylineNormal.js +1 -1
- package/lib/utils/symbol-layout.js +1 -1
- package/package.json +7 -6
- package/CHANGELOG.md +0 -492
- package/LICENSE.md +0 -21
- package/es/citybuliding/building.d.ts +0 -17
- package/es/citybuliding/building.js +0 -79
- package/es/citybuliding/building.js.map +0 -1
- package/es/citybuliding/models/build.d.ts +0 -13
- package/es/citybuliding/models/build.js +0 -124
- package/es/citybuliding/models/build.js.map +0 -1
- package/es/core/BaseLayer.d.ts +0 -174
- package/es/core/BaseLayer.js +0 -974
- package/es/core/BaseLayer.js.map +0 -1
- package/es/core/BaseModel.d.ts +0 -135
- package/es/core/BaseModel.js +0 -412
- package/es/core/BaseModel.js.map +0 -1
- package/es/core/interface.d.ts +0 -19
- package/es/core/interface.js +0 -7
- package/es/core/interface.js.map +0 -1
- package/es/core/schema.d.ts +0 -27
- package/es/core/schema.js +0 -23
- package/es/core/schema.js.map +0 -1
- package/es/core/shape/Path.d.ts +0 -39
- package/es/core/shape/Path.js +0 -57
- package/es/core/shape/Path.js.map +0 -1
- package/es/core/shape/extrude.d.ts +0 -17
- package/es/core/shape/extrude.js +0 -143
- package/es/core/shape/extrude.js.map +0 -1
- package/es/core/triangulation.d.ts +0 -109
- package/es/core/triangulation.js +0 -328
- package/es/core/triangulation.js.map +0 -1
- package/es/earth/index.d.ts +0 -17
- package/es/earth/index.js +0 -81
- package/es/earth/index.js.map +0 -1
- package/es/earth/models/atmosphere.d.ts +0 -9
- package/es/earth/models/atmosphere.js +0 -125
- package/es/earth/models/atmosphere.js.map +0 -1
- package/es/earth/models/base.d.ts +0 -16
- package/es/earth/models/base.js +0 -193
- package/es/earth/models/base.js.map +0 -1
- package/es/earth/models/bloomsphere.d.ts +0 -9
- package/es/earth/models/bloomsphere.js +0 -125
- package/es/earth/models/bloomsphere.js.map +0 -1
- package/es/earth/utils.d.ts +0 -26
- package/es/earth/utils.js +0 -81
- package/es/earth/utils.js.map +0 -1
- package/es/glsl.d.js +0 -2
- package/es/glsl.d.js.map +0 -1
- package/es/heatmap/index.d.ts +0 -22
- package/es/heatmap/index.js +0 -123
- package/es/heatmap/index.js.map +0 -1
- package/es/heatmap/models/grid.d.ts +0 -8
- package/es/heatmap/models/grid.js +0 -90
- package/es/heatmap/models/grid.js.map +0 -1
- package/es/heatmap/models/grid3d.d.ts +0 -8
- package/es/heatmap/models/grid3d.js +0 -122
- package/es/heatmap/models/grid3d.js.map +0 -1
- package/es/heatmap/models/heatmap.d.ts +0 -24
- package/es/heatmap/models/heatmap.js +0 -399
- package/es/heatmap/models/heatmap.js.map +0 -1
- package/es/heatmap/models/hexagon.d.ts +0 -8
- package/es/heatmap/models/hexagon.js +0 -90
- package/es/heatmap/models/hexagon.js.map +0 -1
- package/es/heatmap/models/index.d.ts +0 -5
- package/es/heatmap/models/index.js +0 -13
- package/es/heatmap/models/index.js.map +0 -1
- package/es/heatmap/triangulation.d.ts +0 -5
- package/es/heatmap/triangulation.js +0 -38
- package/es/heatmap/triangulation.js.map +0 -1
- package/es/image/index.d.ts +0 -22
- package/es/image/index.js +0 -82
- package/es/image/index.js.map +0 -1
- package/es/image/models/image.d.ts +0 -18
- package/es/image/models/image.js +0 -127
- package/es/image/models/image.js.map +0 -1
- package/es/image/models/index.d.ts +0 -5
- package/es/image/models/index.js +0 -6
- package/es/image/models/index.js.map +0 -1
- package/es/index.d.ts +0 -11
- package/es/index.js +0 -39
- package/es/index.js.map +0 -1
- package/es/line/index.d.ts +0 -25
- package/es/line/index.js +0 -95
- package/es/line/index.js.map +0 -1
- package/es/line/models/arc.d.ts +0 -12
- package/es/line/models/arc.js +0 -281
- package/es/line/models/arc.js.map +0 -1
- package/es/line/models/arc_3d.d.ts +0 -12
- package/es/line/models/arc_3d.js +0 -277
- package/es/line/models/arc_3d.js.map +0 -1
- package/es/line/models/great_circle.d.ts +0 -12
- package/es/line/models/great_circle.js +0 -269
- package/es/line/models/great_circle.js.map +0 -1
- package/es/line/models/index.d.ts +0 -5
- package/es/line/models/index.js +0 -12
- package/es/line/models/index.js.map +0 -1
- package/es/line/models/line.d.ts +0 -13
- package/es/line/models/line.js +0 -342
- package/es/line/models/line.js.map +0 -1
- package/es/plugins/DataMappingPlugin.d.ts +0 -13
- package/es/plugins/DataMappingPlugin.js +0 -199
- package/es/plugins/DataMappingPlugin.js.map +0 -1
- package/es/plugins/DataSourcePlugin.d.ts +0 -7
- package/es/plugins/DataSourcePlugin.js +0 -73
- package/es/plugins/DataSourcePlugin.js.map +0 -1
- package/es/plugins/FeatureScalePlugin.d.ts +0 -26
- package/es/plugins/FeatureScalePlugin.js +0 -270
- package/es/plugins/FeatureScalePlugin.js.map +0 -1
- package/es/plugins/LayerAnimateStylePlugin.d.ts +0 -7
- package/es/plugins/LayerAnimateStylePlugin.js +0 -50
- package/es/plugins/LayerAnimateStylePlugin.js.map +0 -1
- package/es/plugins/LayerModelPlugin.d.ts +0 -8
- package/es/plugins/LayerModelPlugin.js +0 -34
- package/es/plugins/LayerModelPlugin.js.map +0 -1
- package/es/plugins/LayerStylePlugin.d.ts +0 -8
- package/es/plugins/LayerStylePlugin.js +0 -35
- package/es/plugins/LayerStylePlugin.js.map +0 -1
- package/es/plugins/LightingPlugin.d.ts +0 -36
- package/es/plugins/LightingPlugin.js +0 -100
- package/es/plugins/LightingPlugin.js.map +0 -1
- package/es/plugins/MultiPassRendererPlugin.d.ts +0 -37
- package/es/plugins/MultiPassRendererPlugin.js +0 -79
- package/es/plugins/MultiPassRendererPlugin.js.map +0 -1
- package/es/plugins/PixelPickingPlugin.d.ts +0 -8
- package/es/plugins/PixelPickingPlugin.js +0 -112
- package/es/plugins/PixelPickingPlugin.js.map +0 -1
- package/es/plugins/RegisterStyleAttributePlugin.d.ts +0 -11
- package/es/plugins/RegisterStyleAttributePlugin.js +0 -98
- package/es/plugins/RegisterStyleAttributePlugin.js.map +0 -1
- package/es/plugins/ShaderUniformPlugin.d.ts +0 -16
- package/es/plugins/ShaderUniformPlugin.js +0 -78
- package/es/plugins/ShaderUniformPlugin.js.map +0 -1
- package/es/plugins/UpdateModelPlugin.d.ts +0 -8
- package/es/plugins/UpdateModelPlugin.js +0 -27
- package/es/plugins/UpdateModelPlugin.js.map +0 -1
- package/es/plugins/UpdateStyleAttributePlugin.d.ts +0 -12
- package/es/plugins/UpdateStyleAttributePlugin.js +0 -74
- package/es/plugins/UpdateStyleAttributePlugin.js.map +0 -1
- package/es/point/index.d.ts +0 -30
- package/es/point/index.js +0 -130
- package/es/point/index.js.map +0 -1
- package/es/point/models/extrude.d.ts +0 -14
- package/es/point/models/extrude.js +0 -180
- package/es/point/models/extrude.js.map +0 -1
- package/es/point/models/fill.d.ts +0 -17
- package/es/point/models/fill.js +0 -247
- package/es/point/models/fill.js.map +0 -1
- package/es/point/models/icon-font.d.ts +0 -11
- package/es/point/models/icon-font.js +0 -181
- package/es/point/models/icon-font.js.map +0 -1
- package/es/point/models/image.d.ts +0 -11
- package/es/point/models/image.js +0 -207
- package/es/point/models/image.js.map +0 -1
- package/es/point/models/index.d.ts +0 -5
- package/es/point/models/index.js +0 -16
- package/es/point/models/index.js.map +0 -1
- package/es/point/models/normal.d.ts +0 -21
- package/es/point/models/normal.js +0 -155
- package/es/point/models/normal.js.map +0 -1
- package/es/point/models/text.d.ts +0 -56
- package/es/point/models/text.js +0 -522
- package/es/point/models/text.js.map +0 -1
- package/es/point/shape/Path.d.ts +0 -40
- package/es/point/shape/Path.js +0 -57
- package/es/point/shape/Path.js.map +0 -1
- package/es/point/shape/extrude.d.ts +0 -15
- package/es/point/shape/extrude.js +0 -58
- package/es/point/shape/extrude.js.map +0 -1
- package/es/polygon/index.d.ts +0 -22
- package/es/polygon/index.js +0 -124
- package/es/polygon/index.js.map +0 -1
- package/es/polygon/models/extrude.d.ts +0 -13
- package/es/polygon/models/extrude.js +0 -139
- package/es/polygon/models/extrude.js.map +0 -1
- package/es/polygon/models/fill.d.ts +0 -13
- package/es/polygon/models/fill.js +0 -108
- package/es/polygon/models/fill.js.map +0 -1
- package/es/polygon/models/index.d.ts +0 -5
- package/es/polygon/models/index.js +0 -20
- package/es/polygon/models/index.js.map +0 -1
- package/es/raster/buffers/triangulation.d.ts +0 -6
- package/es/raster/buffers/triangulation.js +0 -28
- package/es/raster/buffers/triangulation.js.map +0 -1
- package/es/raster/image.d.ts +0 -0
- package/es/raster/image.js +0 -2
- package/es/raster/image.js.map +0 -1
- package/es/raster/index.d.ts +0 -28
- package/es/raster/index.js +0 -83
- package/es/raster/index.js.map +0 -1
- package/es/raster/models/index.d.ts +0 -5
- package/es/raster/models/index.js +0 -7
- package/es/raster/models/index.js.map +0 -1
- package/es/raster/models/raster.d.ts +0 -19
- package/es/raster/models/raster.js +0 -152
- package/es/raster/models/raster.js.map +0 -1
- package/es/raster/raster.d.ts +0 -30
- package/es/raster/raster.js +0 -178
- package/es/raster/raster.js.map +0 -1
- package/es/raster/raster2d.d.ts +0 -27
- package/es/raster/raster2d.js +0 -158
- package/es/raster/raster2d.js.map +0 -1
- package/es/utils/blend.d.ts +0 -2
- package/es/utils/blend.js +0 -55
- package/es/utils/blend.js.map +0 -1
- package/es/utils/collision-index.d.ts +0 -47
- package/es/utils/collision-index.js +0 -87
- package/es/utils/collision-index.js.map +0 -1
- package/es/utils/dataMappingStyle.d.ts +0 -30
- package/es/utils/dataMappingStyle.js +0 -88
- package/es/utils/dataMappingStyle.js.map +0 -1
- package/es/utils/extrude_polyline.d.ts +0 -48
- package/es/utils/extrude_polyline.js +0 -405
- package/es/utils/extrude_polyline.js.map +0 -1
- package/es/utils/geo.d.ts +0 -3
- package/es/utils/geo.js +0 -24
- package/es/utils/geo.js.map +0 -1
- package/es/utils/grid-index.d.ts +0 -28
- package/es/utils/grid-index.js +0 -193
- package/es/utils/grid-index.js.map +0 -1
- package/es/utils/polylineNormal.d.ts +0 -9
- package/es/utils/polylineNormal.js +0 -171
- package/es/utils/polylineNormal.js.map +0 -1
- package/es/utils/symbol-layout.d.ts +0 -43
- package/es/utils/symbol-layout.js +0 -260
- package/es/utils/symbol-layout.js.map +0 -1
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.default = void 0;
|
|
9
|
+
|
|
10
|
+
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
11
|
+
|
|
12
|
+
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
13
|
+
|
|
14
|
+
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
15
|
+
|
|
16
|
+
var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
|
|
17
|
+
|
|
18
|
+
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
|
|
19
|
+
|
|
20
|
+
var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
|
|
21
|
+
|
|
22
|
+
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
|
|
23
|
+
|
|
24
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
25
|
+
|
|
26
|
+
var _l7Core = require("@antv/l7-core");
|
|
27
|
+
|
|
28
|
+
var _BaseModel2 = _interopRequireDefault(require("../../core/BaseModel"));
|
|
29
|
+
|
|
30
|
+
var _triangulation = require("../../core/triangulation");
|
|
31
|
+
|
|
32
|
+
var _Tile = _interopRequireDefault(require("../utils/Tile"));
|
|
33
|
+
|
|
34
|
+
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2.default)(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2.default)(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2.default)(this, result); }; }
|
|
35
|
+
|
|
36
|
+
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
37
|
+
|
|
38
|
+
var ImageTileFrag = "precision mediump float;\nvoid main() {\n gl_FragColor = vec4(0.0, 0.0, 0.0, 1.0);\n}\n";
|
|
39
|
+
var ImageTileVert = "precision highp float;\nuniform mat4 u_ModelMatrix;\nuniform mat4 u_Mvp;\nattribute vec3 a_Position;\n#pragma include \"projection\"\nvoid main() {\n vec4 project_pos = project_position(vec4(a_Position, 1.0));\n // gl_Position = project_common_position_to_clipspace(vec4(project_pos.xy,0., 1.0));\n if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) { // gaode2.x\n gl_Position = u_Mvp * (vec4(project_pos.xy,0., 1.0));\n } else {\n gl_Position = project_common_position_to_clipspace(vec4(project_pos.xy,0., 1.0));\n }\n}\n";
|
|
40
|
+
|
|
41
|
+
var ImageTileModel = function (_BaseModel) {
|
|
42
|
+
(0, _inherits2.default)(ImageTileModel, _BaseModel);
|
|
43
|
+
|
|
44
|
+
var _super = _createSuper(ImageTileModel);
|
|
45
|
+
|
|
46
|
+
function ImageTileModel() {
|
|
47
|
+
var _this;
|
|
48
|
+
|
|
49
|
+
(0, _classCallCheck2.default)(this, ImageTileModel);
|
|
50
|
+
|
|
51
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
52
|
+
args[_key] = arguments[_key];
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
_this = _super.call.apply(_super, [this].concat(args));
|
|
56
|
+
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "tileLayer", void 0);
|
|
57
|
+
return _this;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
(0, _createClass2.default)(ImageTileModel, [{
|
|
61
|
+
key: "getUninforms",
|
|
62
|
+
value: function getUninforms() {
|
|
63
|
+
return {};
|
|
64
|
+
}
|
|
65
|
+
}, {
|
|
66
|
+
key: "tile",
|
|
67
|
+
value: function tile() {
|
|
68
|
+
var _this$mapService$getB = this.mapService.getBounds(),
|
|
69
|
+
_this$mapService$getB2 = (0, _slicedToArray2.default)(_this$mapService$getB, 2),
|
|
70
|
+
WS = _this$mapService$getB2[0],
|
|
71
|
+
EN = _this$mapService$getB2[1];
|
|
72
|
+
|
|
73
|
+
var NE = {
|
|
74
|
+
lng: EN[0],
|
|
75
|
+
lat: EN[1]
|
|
76
|
+
};
|
|
77
|
+
var SW = {
|
|
78
|
+
lng: WS[0],
|
|
79
|
+
lat: WS[1]
|
|
80
|
+
};
|
|
81
|
+
this.tileLayer.calCurrentTiles({
|
|
82
|
+
NE: NE,
|
|
83
|
+
SW: SW,
|
|
84
|
+
tileCenter: this.mapService.getCenter(),
|
|
85
|
+
currentZoom: this.mapService.getZoom(),
|
|
86
|
+
minSourceZoom: this.mapService.getMinZoom(),
|
|
87
|
+
minZoom: this.mapService.getMinZoom(),
|
|
88
|
+
maxZoom: this.mapService.getMaxZoom()
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
}, {
|
|
92
|
+
key: "initModels",
|
|
93
|
+
value: function initModels() {
|
|
94
|
+
var _this2 = this;
|
|
95
|
+
|
|
96
|
+
this.layer.zIndex = -999;
|
|
97
|
+
|
|
98
|
+
var _ref = this.layer.getLayerConfig(),
|
|
99
|
+
_ref$resolution = _ref.resolution,
|
|
100
|
+
resolution = _ref$resolution === void 0 ? 'low' : _ref$resolution,
|
|
101
|
+
_ref$maxSourceZoom = _ref.maxSourceZoom,
|
|
102
|
+
maxSourceZoom = _ref$maxSourceZoom === void 0 ? 17 : _ref$maxSourceZoom;
|
|
103
|
+
|
|
104
|
+
var source = this.layer.getSource();
|
|
105
|
+
|
|
106
|
+
if (source.data.tileurl) {
|
|
107
|
+
this.tileLayer = new _Tile.default({
|
|
108
|
+
url: source.data.tileurl,
|
|
109
|
+
layerService: this.layerService,
|
|
110
|
+
layer: this.layer,
|
|
111
|
+
resolution: resolution,
|
|
112
|
+
maxSourceZoom: maxSourceZoom,
|
|
113
|
+
crstype: 'epsg3857'
|
|
114
|
+
});
|
|
115
|
+
this.tile();
|
|
116
|
+
var t = new Date().getTime();
|
|
117
|
+
this.mapService.on('mapchange', function () {
|
|
118
|
+
var newT = new Date().getTime();
|
|
119
|
+
var cutT = newT - t;
|
|
120
|
+
t = newT;
|
|
121
|
+
|
|
122
|
+
if (cutT < 16) {
|
|
123
|
+
return;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
_this2.tile();
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
return [this.layer.buildLayerModel({
|
|
131
|
+
moduleName: 'ImageTileLayer',
|
|
132
|
+
vertexShader: ImageTileVert,
|
|
133
|
+
fragmentShader: ImageTileFrag,
|
|
134
|
+
triangulation: _triangulation.RasterImageTriangulation,
|
|
135
|
+
primitive: _l7Core.gl.TRIANGLES,
|
|
136
|
+
depth: {
|
|
137
|
+
enable: false
|
|
138
|
+
},
|
|
139
|
+
blend: this.getBlend()
|
|
140
|
+
})];
|
|
141
|
+
}
|
|
142
|
+
}, {
|
|
143
|
+
key: "clearModels",
|
|
144
|
+
value: function clearModels() {
|
|
145
|
+
this.tileLayer.removeTiles();
|
|
146
|
+
}
|
|
147
|
+
}, {
|
|
148
|
+
key: "buildModels",
|
|
149
|
+
value: function buildModels() {
|
|
150
|
+
return this.initModels();
|
|
151
|
+
}
|
|
152
|
+
}, {
|
|
153
|
+
key: "registerBuiltinAttributes",
|
|
154
|
+
value: function registerBuiltinAttributes() {
|
|
155
|
+
this.styleAttributeService.registerStyleAttribute({
|
|
156
|
+
name: 'uv',
|
|
157
|
+
type: _l7Core.AttributeType.Attribute,
|
|
158
|
+
descriptor: {
|
|
159
|
+
name: 'a_Uv',
|
|
160
|
+
buffer: {
|
|
161
|
+
usage: _l7Core.gl.DYNAMIC_DRAW,
|
|
162
|
+
data: [],
|
|
163
|
+
type: _l7Core.gl.FLOAT
|
|
164
|
+
},
|
|
165
|
+
size: 2,
|
|
166
|
+
update: function update(feature, featureIdx, vertex, attributeIdx) {
|
|
167
|
+
return [vertex[3], vertex[4]];
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
});
|
|
171
|
+
}
|
|
172
|
+
}]);
|
|
173
|
+
return ImageTileModel;
|
|
174
|
+
}(_BaseModel2.default);
|
|
175
|
+
|
|
176
|
+
exports.default = ImageTileModel;
|
|
177
|
+
//# sourceMappingURL=imagetile.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/imagetile/models/imagetile.ts"],"names":["ImageTileModel","mapService","getBounds","WS","EN","NE","lng","lat","SW","tileLayer","calCurrentTiles","tileCenter","getCenter","currentZoom","getZoom","minSourceZoom","getMinZoom","minZoom","maxZoom","getMaxZoom","layer","zIndex","getLayerConfig","resolution","maxSourceZoom","source","getSource","data","tileurl","Tile","url","layerService","crstype","tile","t","Date","getTime","on","newT","cutT","buildLayerModel","moduleName","vertexShader","ImageTileVert","fragmentShader","ImageTileFrag","triangulation","RasterImageTriangulation","primitive","gl","TRIANGLES","depth","enable","blend","getBlend","removeTiles","initModels","styleAttributeService","registerStyleAttribute","name","type","AttributeType","Attribute","descriptor","buffer","usage","DYNAMIC_DRAW","FLOAT","size","update","feature","featureIdx","vertex","attributeIdx","BaseModel"],"mappings":"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","sourcesContent":["import {\n AttributeType,\n gl,\n IEncodeFeature,\n ILayer,\n ILayerPlugin,\n IModel,\n IModelUniform,\n IRasterParserDataItem,\n IStyleAttributeService,\n ITexture2D,\n lazyInject,\n TYPES,\n} from '@antv/l7-core';\nimport BaseModel from '../../core/BaseModel';\nimport { RasterImageTriangulation } from '../../core/triangulation';\nimport ImageTileFrag from './shaders/imagetile_frag.glsl';\nimport ImageTileVert from './shaders/imagetile_vert.glsl';\n\nimport Tile from '../utils/Tile';\n\ninterface IImageLayerStyleOptions {\n resolution: string;\n maxSourceZoom: number;\n}\n\nexport default class ImageTileModel extends BaseModel {\n public tileLayer: any;\n public getUninforms(): IModelUniform {\n return {};\n }\n\n // 临时的瓦片测试方法\n public tile() {\n const [WS, EN] = this.mapService.getBounds();\n const NE = { lng: EN[0], lat: EN[1] };\n const SW = { lng: WS[0], lat: WS[1] };\n this.tileLayer.calCurrentTiles({\n NE,\n SW,\n tileCenter: this.mapService.getCenter(),\n currentZoom: this.mapService.getZoom(),\n minSourceZoom: this.mapService.getMinZoom(),\n minZoom: this.mapService.getMinZoom(),\n maxZoom: this.mapService.getMaxZoom(),\n });\n }\n\n public initModels() {\n // TODO: 瓦片组件默认在最下层\n this.layer.zIndex = -999;\n const {\n resolution = 'low',\n maxSourceZoom = 17,\n } = this.layer.getLayerConfig() as IImageLayerStyleOptions;\n const source = this.layer.getSource();\n // 当存在 url 的时候生效\n if (source.data.tileurl) {\n this.tileLayer = new Tile({\n url: source.data.tileurl,\n layerService: this.layerService,\n layer: this.layer,\n resolution,\n maxSourceZoom,\n // Tip: 当前为 default\n crstype: 'epsg3857',\n });\n\n this.tile();\n let t = new Date().getTime();\n this.mapService.on('mapchange', () => {\n const newT = new Date().getTime();\n const cutT = newT - t;\n t = newT;\n if (cutT < 16) {\n return;\n }\n this.tile();\n });\n }\n\n return [\n this.layer.buildLayerModel({\n moduleName: 'ImageTileLayer',\n vertexShader: ImageTileVert,\n fragmentShader: ImageTileFrag,\n triangulation: RasterImageTriangulation,\n primitive: gl.TRIANGLES,\n depth: { enable: false },\n blend: this.getBlend(),\n }),\n ];\n }\n\n public clearModels() {\n this.tileLayer.removeTiles();\n }\n\n public buildModels() {\n return this.initModels();\n }\n\n protected registerBuiltinAttributes() {\n // point layer size;\n this.styleAttributeService.registerStyleAttribute({\n name: 'uv',\n type: AttributeType.Attribute,\n descriptor: {\n name: 'a_Uv',\n buffer: {\n // give the WebGL driver a hint that this buffer may change\n usage: gl.DYNAMIC_DRAW,\n data: [],\n type: gl.FLOAT,\n },\n size: 2,\n update: (\n feature: IEncodeFeature,\n featureIdx: number,\n vertex: number[],\n attributeIdx: number,\n ) => {\n return [vertex[3], vertex[4]];\n },\n },\n });\n }\n}\n"],"file":"imagetile.js"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.default = void 0;
|
|
9
|
+
|
|
10
|
+
var _imagetile = _interopRequireDefault(require("./imagetile"));
|
|
11
|
+
|
|
12
|
+
var ImageTileModels = {
|
|
13
|
+
imageTile: _imagetile.default
|
|
14
|
+
};
|
|
15
|
+
var _default = ImageTileModels;
|
|
16
|
+
exports.default = _default;
|
|
17
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/imagetile/models/index.ts"],"names":["ImageTileModels","imageTile","ImageTileModel"],"mappings":";;;;;;;;;AAAA;;AAGA,IAAMA,eAAqD,GAAG;AAC5DC,EAAAA,SAAS,EAAEC;AADiD,CAA9D;eAIeF,e","sourcesContent":["import ImageTileModel from './imagetile';\nexport type ImageTileModelType = 'imageTile';\n\nconst ImageTileModels: { [key in ImageTileModelType]: any } = {\n imageTile: ImageTileModel,\n};\n\nexport default ImageTileModels;\n"],"file":"index.js"}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.default = void 0;
|
|
9
|
+
|
|
10
|
+
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
11
|
+
|
|
12
|
+
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
13
|
+
|
|
14
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
15
|
+
|
|
16
|
+
var _geoCoord = require("@antv/geo-coord");
|
|
17
|
+
|
|
18
|
+
var _image = _interopRequireDefault(require("../../image"));
|
|
19
|
+
|
|
20
|
+
var r2d = 180 / Math.PI;
|
|
21
|
+
var tileURLRegex = /\{([zxy])\}/g;
|
|
22
|
+
|
|
23
|
+
var ImageTile = function () {
|
|
24
|
+
function ImageTile(key, url, container, sceneContainer) {
|
|
25
|
+
(0, _classCallCheck2.default)(this, ImageTile);
|
|
26
|
+
(0, _defineProperty2.default)(this, "tile", void 0);
|
|
27
|
+
(0, _defineProperty2.default)(this, "name", void 0);
|
|
28
|
+
(0, _defineProperty2.default)(this, "imageLayer", void 0);
|
|
29
|
+
this.name = key;
|
|
30
|
+
this.tile = key.split('_').map(function (v) {
|
|
31
|
+
return Number(v);
|
|
32
|
+
});
|
|
33
|
+
var urlParams = {
|
|
34
|
+
x: this.tile[0],
|
|
35
|
+
y: this.tile[1],
|
|
36
|
+
z: this.tile[2]
|
|
37
|
+
};
|
|
38
|
+
var imageSrc = this.getTileURL(urlParams, url);
|
|
39
|
+
var lnglatBounds = this.tileLnglatBounds(this.tile);
|
|
40
|
+
var west = lnglatBounds.getWest();
|
|
41
|
+
var south = lnglatBounds.getSouth();
|
|
42
|
+
var east = lnglatBounds.getEast();
|
|
43
|
+
var north = lnglatBounds.getNorth();
|
|
44
|
+
var imageLayer = new _image.default({});
|
|
45
|
+
imageLayer.source(imageSrc, {
|
|
46
|
+
parser: {
|
|
47
|
+
type: 'image',
|
|
48
|
+
extent: [west, south, east, north]
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
imageLayer.setContainer(container, sceneContainer);
|
|
52
|
+
imageLayer.init();
|
|
53
|
+
this.imageLayer = imageLayer;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
(0, _createClass2.default)(ImageTile, [{
|
|
57
|
+
key: "destroy",
|
|
58
|
+
value: function destroy() {
|
|
59
|
+
this.imageLayer.clearModels();
|
|
60
|
+
this.imageLayer.destroy();
|
|
61
|
+
}
|
|
62
|
+
}, {
|
|
63
|
+
key: "getTileURL",
|
|
64
|
+
value: function getTileURL(urlParams, path) {
|
|
65
|
+
if (!urlParams.s) {
|
|
66
|
+
urlParams.s = String.fromCharCode(97 + Math.floor(Math.random() * 3));
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
tileURLRegex.lastIndex = 0;
|
|
70
|
+
return path.replace(tileURLRegex, function (value, key) {
|
|
71
|
+
return urlParams[key];
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
}, {
|
|
75
|
+
key: "tileLnglatBounds",
|
|
76
|
+
value: function tileLnglatBounds(tile) {
|
|
77
|
+
var e = this.tile2lng(tile[0] + 1, tile[2]);
|
|
78
|
+
var w = this.tile2lng(tile[0], tile[2]);
|
|
79
|
+
var s = this.tile2lat(tile[1] + 1, tile[2]);
|
|
80
|
+
var n = this.tile2lat(tile[1], tile[2]);
|
|
81
|
+
return (0, _geoCoord.toLngLatBounds)([w, n], [e, s]);
|
|
82
|
+
}
|
|
83
|
+
}, {
|
|
84
|
+
key: "tile2lng",
|
|
85
|
+
value: function tile2lng(x, z) {
|
|
86
|
+
return x / Math.pow(2, z) * 360 - 180;
|
|
87
|
+
}
|
|
88
|
+
}, {
|
|
89
|
+
key: "tile2lat",
|
|
90
|
+
value: function tile2lat(y, z) {
|
|
91
|
+
var n = Math.PI - 2 * Math.PI * y / Math.pow(2, z);
|
|
92
|
+
return r2d * Math.atan(0.5 * (Math.exp(n) - Math.exp(-n)));
|
|
93
|
+
}
|
|
94
|
+
}]);
|
|
95
|
+
return ImageTile;
|
|
96
|
+
}();
|
|
97
|
+
|
|
98
|
+
exports.default = ImageTile;
|
|
99
|
+
//# sourceMappingURL=ImageTile.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/imagetile/utils/ImageTile.ts"],"names":["r2d","Math","PI","tileURLRegex","ImageTile","key","url","container","sceneContainer","name","tile","split","map","v","Number","urlParams","x","y","z","imageSrc","getTileURL","lnglatBounds","tileLnglatBounds","west","getWest","south","getSouth","east","getEast","north","getNorth","imageLayer","ImageLayer","source","parser","type","extent","setContainer","init","clearModels","destroy","path","s","String","fromCharCode","floor","random","lastIndex","replace","value","e","tile2lng","w","tile2lat","n","pow","atan","exp"],"mappings":";;;;;;;;;;;;;;;AAAA;;AAEA;;AASA,IAAMA,GAAG,GAAG,MAAMC,IAAI,CAACC,EAAvB;AACA,IAAMC,YAAY,GAAG,cAArB;;IAEqBC,S;AAInB,qBACEC,GADF,EAEEC,GAFF,EAGEC,SAHF,EAIEC,cAJF,EAKE;AAAA;AAAA;AAAA;AAAA;AACA,SAAKC,IAAL,GAAYJ,GAAZ;AACA,SAAKK,IAAL,GAAYL,GAAG,CAACM,KAAJ,CAAU,GAAV,EAAeC,GAAf,CAAmB,UAACC,CAAD;AAAA,aAAOC,MAAM,CAACD,CAAD,CAAb;AAAA,KAAnB,CAAZ;AAEA,QAAME,SAAS,GAAG;AAChBC,MAAAA,CAAC,EAAE,KAAKN,IAAL,CAAU,CAAV,CADa;AAEhBO,MAAAA,CAAC,EAAE,KAAKP,IAAL,CAAU,CAAV,CAFa;AAGhBQ,MAAAA,CAAC,EAAE,KAAKR,IAAL,CAAU,CAAV;AAHa,KAAlB;AAKA,QAAMS,QAAQ,GAAG,KAAKC,UAAL,CAAgBL,SAAhB,EAA2BT,GAA3B,CAAjB;AAEA,QAAMe,YAAY,GAAG,KAAKC,gBAAL,CAAsB,KAAKZ,IAA3B,CAArB;AACA,QAAMa,IAAI,GAAGF,YAAY,CAACG,OAAb,EAAb;AACA,QAAMC,KAAK,GAAGJ,YAAY,CAACK,QAAb,EAAd;AACA,QAAMC,IAAI,GAAGN,YAAY,CAACO,OAAb,EAAb;AACA,QAAMC,KAAK,GAAGR,YAAY,CAACS,QAAb,EAAd;AAEA,QAAMC,UAAU,GAAG,IAAIC,cAAJ,CAAe,EAAf,CAAnB;AACAD,IAAAA,UAAU,CAACE,MAAX,CAEEd,QAFF,EAGE;AACEe,MAAAA,MAAM,EAAE;AACNC,QAAAA,IAAI,EAAE,OADA;AAGNC,QAAAA,MAAM,EAAE,CAACb,IAAD,EAAOE,KAAP,EAAcE,IAAd,EAAoBE,KAApB;AAHF;AADV,KAHF;AAYAE,IAAAA,UAAU,CAACM,YAAX,CAAwB9B,SAAxB,EAAmCC,cAAnC;AACAuB,IAAAA,UAAU,CAACO,IAAX;AAEA,SAAKP,UAAL,GAAkBA,UAAlB;AACD;;;;WAED,mBAAiB;AACf,WAAKA,UAAL,CAAgBQ,WAAhB;AACA,WAAKR,UAAL,CAAgBS,OAAhB;AACD;;;WAED,oBAAkBzB,SAAlB,EAAyC0B,IAAzC,EAAuD;AACrD,UAAI,CAAC1B,SAAS,CAAC2B,CAAf,EAAkB;AAEhB3B,QAAAA,SAAS,CAAC2B,CAAV,GAAcC,MAAM,CAACC,YAAP,CAAoB,KAAK3C,IAAI,CAAC4C,KAAL,CAAW5C,IAAI,CAAC6C,MAAL,KAAgB,CAA3B,CAAzB,CAAd;AACD;;AAED3C,MAAAA,YAAY,CAAC4C,SAAb,GAAyB,CAAzB;AACA,aAAON,IAAI,CAACO,OAAL,CAAa7C,YAAb,EAA2B,UAAC8C,KAAD,EAAQ5C,GAAR,EAAqB;AAErD,eAAOU,SAAS,CAACV,GAAD,CAAhB;AACD,OAHM,CAAP;AAID;;;WAGD,0BAAwBK,IAAxB,EAAwC;AACtC,UAAMwC,CAAC,GAAG,KAAKC,QAAL,CAAczC,IAAI,CAAC,CAAD,CAAJ,GAAU,CAAxB,EAA2BA,IAAI,CAAC,CAAD,CAA/B,CAAV;AACA,UAAM0C,CAAC,GAAG,KAAKD,QAAL,CAAczC,IAAI,CAAC,CAAD,CAAlB,EAAuBA,IAAI,CAAC,CAAD,CAA3B,CAAV;AACA,UAAMgC,CAAC,GAAG,KAAKW,QAAL,CAAc3C,IAAI,CAAC,CAAD,CAAJ,GAAU,CAAxB,EAA2BA,IAAI,CAAC,CAAD,CAA/B,CAAV;AACA,UAAM4C,CAAC,GAAG,KAAKD,QAAL,CAAc3C,IAAI,CAAC,CAAD,CAAlB,EAAuBA,IAAI,CAAC,CAAD,CAA3B,CAAV;AACA,aAAO,8BAAe,CAAC0C,CAAD,EAAIE,CAAJ,CAAf,EAAuB,CAACJ,CAAD,EAAIR,CAAJ,CAAvB,CAAP;AACD;;;WAED,kBAAgB1B,CAAhB,EAA2BE,CAA3B,EAAsC;AACpC,aAAQF,CAAC,GAAGf,IAAI,CAACsD,GAAL,CAAS,CAAT,EAAYrC,CAAZ,CAAL,GAAuB,GAAvB,GAA6B,GAApC;AACD;;;WAED,kBAAgBD,CAAhB,EAA2BC,CAA3B,EAAsC;AACpC,UAAMoC,CAAC,GAAGrD,IAAI,CAACC,EAAL,GAAW,IAAID,IAAI,CAACC,EAAT,GAAce,CAAf,GAAoBhB,IAAI,CAACsD,GAAL,CAAS,CAAT,EAAYrC,CAAZ,CAAxC;AACA,aAAOlB,GAAG,GAAGC,IAAI,CAACuD,IAAL,CAAU,OAAOvD,IAAI,CAACwD,GAAL,CAASH,CAAT,IAAcrD,IAAI,CAACwD,GAAL,CAAS,CAACH,CAAV,CAArB,CAAV,CAAb;AACD","sourcesContent":["import { LngLatBounds, toBounds, toLngLatBounds } from '@antv/geo-coord';\nimport { Container } from 'inversify';\nimport ImageLayer from '../../image';\n\ninterface IUrlParams {\n x: number;\n y: number;\n z: number;\n s?: string;\n}\n\nconst r2d = 180 / Math.PI;\nconst tileURLRegex = /\\{([zxy])\\}/g;\n\nexport default class ImageTile {\n public tile: number[]; // 当前图片瓦片的索引\n public name: string;\n public imageLayer: any;\n constructor(\n key: string,\n url: string,\n container: Container,\n sceneContainer: Container,\n ) {\n this.name = key;\n this.tile = key.split('_').map((v) => Number(v));\n\n const urlParams = {\n x: this.tile[0],\n y: this.tile[1],\n z: this.tile[2],\n };\n const imageSrc = this.getTileURL(urlParams, url);\n\n const lnglatBounds = this.tileLnglatBounds(this.tile);\n const west = lnglatBounds.getWest();\n const south = lnglatBounds.getSouth();\n const east = lnglatBounds.getEast();\n const north = lnglatBounds.getNorth();\n\n const imageLayer = new ImageLayer({});\n imageLayer.source(\n // 'https://gw.alipayobjects.com/zos/rmsportal/FnHFeFklTzKDdUESRNDv.jpg',\n imageSrc,\n {\n parser: {\n type: 'image',\n // extent: [121.168, 30.2828, 121.384, 30.4219],\n extent: [west, south, east, north],\n },\n },\n );\n\n imageLayer.setContainer(container, sceneContainer);\n imageLayer.init();\n\n this.imageLayer = imageLayer;\n }\n\n public destroy() {\n this.imageLayer.clearModels();\n this.imageLayer.destroy();\n }\n\n public getTileURL(urlParams: IUrlParams, path: string) {\n if (!urlParams.s) {\n // Default to a random choice of a, b or c\n urlParams.s = String.fromCharCode(97 + Math.floor(Math.random() * 3));\n }\n\n tileURLRegex.lastIndex = 0;\n return path.replace(tileURLRegex, (value, key: any) => {\n // @ts-ignore\n return urlParams[key];\n });\n }\n\n // Get tile bounds in WGS84 coordinates\n public tileLnglatBounds(tile: number[]) {\n const e = this.tile2lng(tile[0] + 1, tile[2]);\n const w = this.tile2lng(tile[0], tile[2]);\n const s = this.tile2lat(tile[1] + 1, tile[2]);\n const n = this.tile2lat(tile[1], tile[2]);\n return toLngLatBounds([w, n], [e, s]);\n }\n\n public tile2lng(x: number, z: number) {\n return (x / Math.pow(2, z)) * 360 - 180;\n }\n\n public tile2lat(y: number, z: number) {\n const n = Math.PI - (2 * Math.PI * y) / Math.pow(2, z);\n return r2d * Math.atan(0.5 * (Math.exp(n) - Math.exp(-n)));\n }\n}\n"],"file":"ImageTile.js"}
|
|
@@ -0,0 +1,324 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.default = void 0;
|
|
9
|
+
|
|
10
|
+
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
11
|
+
|
|
12
|
+
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
13
|
+
|
|
14
|
+
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
15
|
+
|
|
16
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
17
|
+
|
|
18
|
+
var _geoCoord = require("@antv/geo-coord");
|
|
19
|
+
|
|
20
|
+
var _l7Core = require("@antv/l7-core");
|
|
21
|
+
|
|
22
|
+
var _ImageTile = _interopRequireDefault(require("./ImageTile"));
|
|
23
|
+
|
|
24
|
+
var _tileCache = _interopRequireDefault(require("./tileCache"));
|
|
25
|
+
|
|
26
|
+
var CacheLimit = 30;
|
|
27
|
+
|
|
28
|
+
var Tile = function () {
|
|
29
|
+
function Tile(props) {
|
|
30
|
+
(0, _classCallCheck2.default)(this, Tile);
|
|
31
|
+
(0, _defineProperty2.default)(this, "tileList", {});
|
|
32
|
+
(0, _defineProperty2.default)(this, "tileCache", void 0);
|
|
33
|
+
(0, _defineProperty2.default)(this, "updateTileList", void 0);
|
|
34
|
+
(0, _defineProperty2.default)(this, "tileZoom", void 0);
|
|
35
|
+
(0, _defineProperty2.default)(this, "noPruneRange", void 0);
|
|
36
|
+
(0, _defineProperty2.default)(this, "url", void 0);
|
|
37
|
+
(0, _defineProperty2.default)(this, "resolution", void 0);
|
|
38
|
+
(0, _defineProperty2.default)(this, "maxSourceZoom", void 0);
|
|
39
|
+
(0, _defineProperty2.default)(this, "crstype", void 0);
|
|
40
|
+
(0, _defineProperty2.default)(this, "currentCrs", void 0);
|
|
41
|
+
(0, _defineProperty2.default)(this, "layerService", void 0);
|
|
42
|
+
(0, _defineProperty2.default)(this, "layer", void 0);
|
|
43
|
+
this.layerService = props.layerService;
|
|
44
|
+
this.layer = props.layer;
|
|
45
|
+
this.url = props.url;
|
|
46
|
+
this.resolution = props.resolution === 'low' ? -1 : 0;
|
|
47
|
+
this.maxSourceZoom = props.maxSourceZoom;
|
|
48
|
+
this.crstype = props.crstype;
|
|
49
|
+
this.currentCrs = new _geoCoord.GeoCoordinates.default({
|
|
50
|
+
start: {
|
|
51
|
+
x: 0,
|
|
52
|
+
y: 0
|
|
53
|
+
},
|
|
54
|
+
end: {
|
|
55
|
+
x: 0,
|
|
56
|
+
y: 0
|
|
57
|
+
},
|
|
58
|
+
projection: this.crstype
|
|
59
|
+
}).crs;
|
|
60
|
+
this.destroyTile = this.destroyTile.bind(this);
|
|
61
|
+
this.tileCache = new _tileCache.default(CacheLimit, this.destroyTile);
|
|
62
|
+
this.updateTileList = [];
|
|
63
|
+
this.removeTiles = this.removeTiles.bind(this);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
(0, _createClass2.default)(Tile, [{
|
|
67
|
+
key: "calCurrentTiles",
|
|
68
|
+
value: function calCurrentTiles(oprions) {
|
|
69
|
+
var _this = this;
|
|
70
|
+
|
|
71
|
+
var NE = oprions.NE,
|
|
72
|
+
SW = oprions.SW,
|
|
73
|
+
tileCenter = oprions.tileCenter,
|
|
74
|
+
currentZoom = oprions.currentZoom,
|
|
75
|
+
minSourceZoom = oprions.minSourceZoom,
|
|
76
|
+
minZoom = oprions.minZoom,
|
|
77
|
+
maxZoom = oprions.maxZoom;
|
|
78
|
+
|
|
79
|
+
if (currentZoom >= this.maxSourceZoom) {
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
var zoom = Math.floor(currentZoom) + this.resolution;
|
|
84
|
+
this.tileZoom = zoom > this.maxSourceZoom ? this.maxSourceZoom : zoom;
|
|
85
|
+
|
|
86
|
+
if (currentZoom < minZoom || currentZoom >= maxZoom || currentZoom < minSourceZoom) {
|
|
87
|
+
this.removeTiles();
|
|
88
|
+
return;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
this.updateTileList = [];
|
|
92
|
+
var centerPoint = this.currentCrs.lngLatToPoint((0, _geoCoord.toLngLat)(tileCenter.lng, tileCenter.lat), this.tileZoom);
|
|
93
|
+
var centerXY = centerPoint.divideBy(256).floor();
|
|
94
|
+
var pixelBounds = this.getPixelBounds(NE, SW, tileCenter, this.tileZoom, this.currentCrs);
|
|
95
|
+
var tileRange = this.pxBoundsToTileRange(pixelBounds);
|
|
96
|
+
var margin = 4;
|
|
97
|
+
this.noPruneRange = new _geoCoord.Bounds(tileRange.getBottomLeft().subtract([margin, -margin]), tileRange.getTopRight().add([margin, -margin]));
|
|
98
|
+
|
|
99
|
+
if (!(isFinite(tileRange.min.x) && isFinite(tileRange.min.y) && isFinite(tileRange.max.x) && isFinite(tileRange.max.y))) {
|
|
100
|
+
throw new Error('Attempted to load an infinite number of tiles');
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
for (var j = tileRange.min.y; j <= tileRange.max.y; j++) {
|
|
104
|
+
for (var i = tileRange.min.x; i <= tileRange.max.x; i++) {
|
|
105
|
+
var coords = [i, j, this.tileZoom];
|
|
106
|
+
var tile = this.tileList[coords.join('_')];
|
|
107
|
+
|
|
108
|
+
if (tile) {
|
|
109
|
+
tile.current = true;
|
|
110
|
+
} else {
|
|
111
|
+
this.tileList[coords.join('_')] = {
|
|
112
|
+
current: true,
|
|
113
|
+
coords: coords
|
|
114
|
+
};
|
|
115
|
+
this.updateTileList.push(coords);
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
this.updateTileList.sort(function (a, b) {
|
|
121
|
+
var tile1 = a;
|
|
122
|
+
var tile2 = b;
|
|
123
|
+
var d1 = Math.pow(tile1[0] * 1 - centerXY.x, 2) + Math.pow(tile1[1] * 1 - centerXY.y, 2);
|
|
124
|
+
var d2 = Math.pow(tile2[0] * 1 - centerXY.x, 2) + Math.pow(tile2[1] * 1 - centerXY.y, 2);
|
|
125
|
+
return d1 - d2;
|
|
126
|
+
});
|
|
127
|
+
this.pruneTiles();
|
|
128
|
+
this.updateTileList.forEach(function (coords) {
|
|
129
|
+
var key = coords.join('_');
|
|
130
|
+
|
|
131
|
+
if (_this.tileList[key].current) {
|
|
132
|
+
_this.requestTile(key);
|
|
133
|
+
}
|
|
134
|
+
});
|
|
135
|
+
}
|
|
136
|
+
}, {
|
|
137
|
+
key: "pxBoundsToTileRange",
|
|
138
|
+
value: function pxBoundsToTileRange(pixelBounds) {
|
|
139
|
+
return new _geoCoord.Bounds(pixelBounds.min.divideBy(256).floor(), pixelBounds.max.divideBy(256).ceil().subtract([1, 1]));
|
|
140
|
+
}
|
|
141
|
+
}, {
|
|
142
|
+
key: "getPixelBounds",
|
|
143
|
+
value: function getPixelBounds(NE, SW, tileCenter, tileZoom, crs) {
|
|
144
|
+
var zoom = tileZoom;
|
|
145
|
+
var NEPoint = crs.lngLatToPoint((0, _geoCoord.toLngLat)(NE.lng, NE.lat), zoom);
|
|
146
|
+
var SWPoint = crs.lngLatToPoint((0, _geoCoord.toLngLat)(SW.lng, SW.lat), zoom);
|
|
147
|
+
var centerPoint = crs.lngLatToPoint((0, _geoCoord.toLngLat)(tileCenter.lng, tileCenter.lat), zoom);
|
|
148
|
+
var topHeight = centerPoint.y - NEPoint.y;
|
|
149
|
+
var bottomHeight = SWPoint.y - centerPoint.y;
|
|
150
|
+
var leftWidth;
|
|
151
|
+
var rightWidth;
|
|
152
|
+
|
|
153
|
+
if (tileCenter.lng - NE.lng > 0 || tileCenter.lng - SW.lng < 0) {
|
|
154
|
+
var width = Math.pow(2, zoom) * 256 / 360 * (180 - NE.lng) + Math.pow(2, zoom) * 256 / 360 * (SW.lng + 180);
|
|
155
|
+
|
|
156
|
+
if (tileCenter.lng - NE.lng > 0) {
|
|
157
|
+
leftWidth = Math.pow(2, zoom) * 256 / 360 * (tileCenter.lng - NE.lng);
|
|
158
|
+
rightWidth = width - leftWidth;
|
|
159
|
+
} else {
|
|
160
|
+
rightWidth = Math.pow(2, zoom) * 256 / 360 * (SW.lng - tileCenter.lng);
|
|
161
|
+
leftWidth = width - rightWidth;
|
|
162
|
+
}
|
|
163
|
+
} else {
|
|
164
|
+
leftWidth = Math.pow(2, zoom) * 256 / 360 * (tileCenter.lng - SW.lng);
|
|
165
|
+
rightWidth = Math.pow(2, zoom) * 256 / 360 * (NE.lng - tileCenter.lng);
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
var pixelBounds = new _geoCoord.Bounds(centerPoint.subtract(leftWidth, topHeight), centerPoint.add(rightWidth, bottomHeight));
|
|
169
|
+
return pixelBounds;
|
|
170
|
+
}
|
|
171
|
+
}, {
|
|
172
|
+
key: "pruneTiles",
|
|
173
|
+
value: function pruneTiles() {
|
|
174
|
+
var _this2 = this;
|
|
175
|
+
|
|
176
|
+
Object.keys(this.tileList).map(function (key) {
|
|
177
|
+
var c = _this2.tileList[key].coords;
|
|
178
|
+
|
|
179
|
+
if (c[2] !== _this2.tileZoom || !_this2.noPruneRange.contains(new _geoCoord.Point(c[0], c[1]))) {
|
|
180
|
+
_this2.tileList[key].current = false;
|
|
181
|
+
}
|
|
182
|
+
});
|
|
183
|
+
Object.keys(this.tileList).map(function (key) {
|
|
184
|
+
var tile = _this2.tileList[key];
|
|
185
|
+
tile.retain = tile.current;
|
|
186
|
+
});
|
|
187
|
+
Object.keys(this.tileList).map(function (key) {
|
|
188
|
+
var tile = _this2.tileList[key];
|
|
189
|
+
|
|
190
|
+
if (tile.current && !tile.active) {
|
|
191
|
+
var _key$split$map = key.split('_').map(function (v) {
|
|
192
|
+
return Number(v);
|
|
193
|
+
}),
|
|
194
|
+
_key$split$map2 = (0, _slicedToArray2.default)(_key$split$map, 3),
|
|
195
|
+
x = _key$split$map2[0],
|
|
196
|
+
y = _key$split$map2[1],
|
|
197
|
+
z = _key$split$map2[2];
|
|
198
|
+
|
|
199
|
+
if (!_this2.retainParent(x, y, z, z - 5)) {
|
|
200
|
+
_this2.retainChildren(x, y, z, z + 2);
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
});
|
|
204
|
+
this.removeOutTiles();
|
|
205
|
+
}
|
|
206
|
+
}, {
|
|
207
|
+
key: "requestTile",
|
|
208
|
+
value: function requestTile(key) {
|
|
209
|
+
var t = this.tileList[key];
|
|
210
|
+
|
|
211
|
+
if (!t) {
|
|
212
|
+
return;
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
var tile = this.tileCache.getTile(key);
|
|
216
|
+
|
|
217
|
+
if (!tile) {
|
|
218
|
+
var container = (0, _l7Core.createLayerContainer)(this.layer.sceneContainer);
|
|
219
|
+
tile = new _ImageTile.default(key, this.url, container, this.layer.sceneContainer);
|
|
220
|
+
tile.name = key;
|
|
221
|
+
t.current = true;
|
|
222
|
+
t.retain = true;
|
|
223
|
+
t.active = true;
|
|
224
|
+
this.layer.layerChildren.push(tile.imageLayer);
|
|
225
|
+
this.tileCache.setTile(tile, key);
|
|
226
|
+
this.pruneTiles();
|
|
227
|
+
this.layerService.renderLayers();
|
|
228
|
+
} else {
|
|
229
|
+
tile.imageLayer.show();
|
|
230
|
+
t.current = true;
|
|
231
|
+
t.retain = true;
|
|
232
|
+
t.active = true;
|
|
233
|
+
this.pruneTiles();
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
}, {
|
|
237
|
+
key: "retainParent",
|
|
238
|
+
value: function retainParent(x, y, z, minZoom) {
|
|
239
|
+
var x2 = Math.floor(x / 2);
|
|
240
|
+
var y2 = Math.floor(y / 2);
|
|
241
|
+
var z2 = z - 1;
|
|
242
|
+
var tile = this.tileList[[x2, y2, z2].join('_')];
|
|
243
|
+
|
|
244
|
+
if (tile && tile.active) {
|
|
245
|
+
tile.retain = true;
|
|
246
|
+
return true;
|
|
247
|
+
} else if (tile && tile.loaded) {
|
|
248
|
+
tile.retain = true;
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
if (z2 > minZoom) {
|
|
252
|
+
return this.retainParent(x2, y2, z2, minZoom);
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
return false;
|
|
256
|
+
}
|
|
257
|
+
}, {
|
|
258
|
+
key: "retainChildren",
|
|
259
|
+
value: function retainChildren(x, y, z, maxZoom) {
|
|
260
|
+
for (var i = 2 * x; i < 2 * x + 2; i++) {
|
|
261
|
+
for (var j = 2 * y; j < 2 * y + 2; j++) {
|
|
262
|
+
var key = [i, j, z + 1].join('_');
|
|
263
|
+
var tile = this.tileList[key];
|
|
264
|
+
|
|
265
|
+
if (tile && tile.active) {
|
|
266
|
+
tile.retain = true;
|
|
267
|
+
continue;
|
|
268
|
+
} else if (tile && tile.loaded) {
|
|
269
|
+
tile.retain = true;
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
if (z + 1 < maxZoom) {
|
|
273
|
+
this.retainChildren(i, j, z + 1, maxZoom);
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
}, {
|
|
279
|
+
key: "destroyTile",
|
|
280
|
+
value: function destroyTile(tile) {
|
|
281
|
+
var layerIndex = this.layer.layerChildren.indexOf(tile.imageLayer);
|
|
282
|
+
|
|
283
|
+
if (layerIndex > -1) {
|
|
284
|
+
this.layer.layerChildren.splice(layerIndex, 1);
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
tile.imageLayer.emit('remove', null);
|
|
288
|
+
tile.imageLayer.destroy();
|
|
289
|
+
this.layerService.renderLayers();
|
|
290
|
+
tile = null;
|
|
291
|
+
}
|
|
292
|
+
}, {
|
|
293
|
+
key: "removeOutTiles",
|
|
294
|
+
value: function removeOutTiles() {
|
|
295
|
+
for (var key in this.tileList) {
|
|
296
|
+
if (!this.tileList[key].retain) {
|
|
297
|
+
var tile = this.tileCache.getTile(key);
|
|
298
|
+
|
|
299
|
+
if (tile) {
|
|
300
|
+
tile.imageLayer.hide();
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
delete this.tileList[key];
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
}, {
|
|
308
|
+
key: "removeTiles",
|
|
309
|
+
value: function removeTiles() {
|
|
310
|
+
this.layer.layerChildren.forEach(function (layer) {
|
|
311
|
+
layer.emit('remove', null);
|
|
312
|
+
layer.destroy();
|
|
313
|
+
});
|
|
314
|
+
this.layer.layerChildren = [];
|
|
315
|
+
this.layerService.renderLayers();
|
|
316
|
+
this.tileList = {};
|
|
317
|
+
this.tileCache.destory();
|
|
318
|
+
}
|
|
319
|
+
}]);
|
|
320
|
+
return Tile;
|
|
321
|
+
}();
|
|
322
|
+
|
|
323
|
+
exports.default = Tile;
|
|
324
|
+
//# sourceMappingURL=Tile.js.map
|