@antv/l7-layers 2.15.1 → 2.15.3

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.
Files changed (243) hide show
  1. package/es/Geometry/index.js +9 -31
  2. package/es/Geometry/models/billboard.js +51 -89
  3. package/es/Geometry/models/plane.js +81 -143
  4. package/es/Geometry/models/sprite.js +60 -118
  5. package/es/canvas/index.js +10 -33
  6. package/es/canvas/models/canvas.js +41 -97
  7. package/es/citybuliding/building.js +8 -27
  8. package/es/citybuliding/models/build.js +57 -82
  9. package/es/core/BaseLayer.js +320 -484
  10. package/es/core/BaseModel.js +97 -126
  11. package/es/core/LayerPickService.js +21 -32
  12. package/es/core/TextureService.js +0 -13
  13. package/es/core/interface.js +17 -24
  14. package/es/core/shape/Path.js +13 -20
  15. package/es/core/shape/extrude.js +10 -31
  16. package/es/core/triangulation.js +54 -114
  17. package/es/earth/index.js +9 -33
  18. package/es/earth/models/atmosphere.js +30 -54
  19. package/es/earth/models/base.js +47 -85
  20. package/es/earth/models/bloomsphere.js +30 -54
  21. package/es/earth/utils.js +9 -13
  22. package/es/heatmap/index.js +10 -40
  23. package/es/heatmap/models/grid.js +28 -52
  24. package/es/heatmap/models/grid3d.js +28 -52
  25. package/es/heatmap/models/heatmap.js +91 -146
  26. package/es/heatmap/models/hexagon.js +28 -52
  27. package/es/heatmap/triangulation.js +0 -4
  28. package/es/image/index.js +9 -28
  29. package/es/image/models/image.js +66 -100
  30. package/es/index.js +9 -17
  31. package/es/line/index.js +9 -34
  32. package/es/line/models/arc.js +66 -118
  33. package/es/line/models/arc_3d.js +60 -108
  34. package/es/line/models/earthArc_3d.js +63 -111
  35. package/es/line/models/great_circle.js +56 -100
  36. package/es/line/models/half.js +46 -77
  37. package/es/line/models/line.js +94 -148
  38. package/es/line/models/linearline.js +45 -80
  39. package/es/line/models/simpleLine.js +41 -74
  40. package/es/line/models/wall.js +52 -92
  41. package/es/mask/index.js +9 -28
  42. package/es/mask/models/fill.js +29 -54
  43. package/es/plugins/DataMappingPlugin.js +80 -117
  44. package/es/plugins/DataSourcePlugin.js +45 -68
  45. package/es/plugins/FeatureScalePlugin.js +67 -122
  46. package/es/plugins/LayerAnimateStylePlugin.js +0 -5
  47. package/es/plugins/LayerMaskPlugin.js +3 -11
  48. package/es/plugins/LayerModelPlugin.js +67 -104
  49. package/es/plugins/LayerStylePlugin.js +3 -9
  50. package/es/plugins/LightingPlugin.js +12 -18
  51. package/es/plugins/MultiPassRendererPlugin.js +11 -16
  52. package/es/plugins/PixelPickingPlugin.js +12 -21
  53. package/es/plugins/RegisterStyleAttributePlugin.js +5 -12
  54. package/es/plugins/ShaderUniformPlugin.js +13 -27
  55. package/es/plugins/UpdateModelPlugin.js +0 -5
  56. package/es/plugins/UpdateStyleAttributePlugin.js +5 -11
  57. package/es/point/index.js +26 -77
  58. package/es/point/models/earthExtrude.js +61 -102
  59. package/es/point/models/earthFill.js +57 -87
  60. package/es/point/models/extrude.js +60 -101
  61. package/es/point/models/fill.js +70 -100
  62. package/es/point/models/fillmage.js +63 -107
  63. package/es/point/models/image.js +48 -88
  64. package/es/point/models/index.js +2 -2
  65. package/es/point/models/normal.js +30 -54
  66. package/es/point/models/radar.js +40 -64
  67. package/es/point/models/simplePoint.js +41 -69
  68. package/es/point/models/text.d.ts +2 -0
  69. package/es/point/models/text.js +214 -295
  70. package/es/point/shape/extrude.js +4 -13
  71. package/es/polygon/index.js +11 -40
  72. package/es/polygon/models/extrude.js +48 -92
  73. package/es/polygon/models/fill.js +54 -88
  74. package/es/polygon/models/index.js +3 -2
  75. package/es/polygon/models/ocean.js +42 -76
  76. package/es/polygon/models/water.js +37 -71
  77. package/es/raster/buffers/triangulation.js +2 -4
  78. package/es/raster/index.js +9 -32
  79. package/es/raster/models/raster.js +80 -116
  80. package/es/raster/models/rasterRgb.js +84 -127
  81. package/es/raster/models/rasterTerrainRgb.js +56 -84
  82. package/es/tile/interaction/getRasterData.js +14 -20
  83. package/es/tile/interaction/utils.js +7 -9
  84. package/es/tile/manager/base.js +63 -96
  85. package/es/tile/service/TileLayerService.js +30 -52
  86. package/es/tile/service/TilePickService.js +26 -40
  87. package/es/tile/service/TileSourceService.js +3 -7
  88. package/es/tile/tileFactory/DebugTile.js +28 -45
  89. package/es/tile/tileFactory/ImageTile.js +20 -38
  90. package/es/tile/tileFactory/MaskTile.js +22 -43
  91. package/es/tile/tileFactory/RasterRGBTile.js +22 -42
  92. package/es/tile/tileFactory/RasterTerrainRGBTile.js +20 -38
  93. package/es/tile/tileFactory/RasterTile.js +30 -53
  94. package/es/tile/tileFactory/Tile.js +63 -97
  95. package/es/tile/tileFactory/VectorTile.js +41 -68
  96. package/es/tile/tileFactory/index.js +0 -11
  97. package/es/tile/tileFactory/layers/TileDebugLayer.js +6 -27
  98. package/es/tile/tileFactory/util.js +0 -3
  99. package/es/tile/tileLayer/BaseLayer.js +105 -146
  100. package/es/tile/utils.js +1 -1
  101. package/es/utils/blend.js +0 -2
  102. package/es/utils/collision-index.js +9 -16
  103. package/es/utils/dataMappingStyle.js +8 -18
  104. package/es/utils/extrude_polyline.js +101 -149
  105. package/es/utils/grid-index.js +2 -27
  106. package/es/utils/identityScale.js +0 -8
  107. package/es/utils/layerData.js +30 -44
  108. package/es/utils/multiPassRender.js +11 -13
  109. package/es/utils/polylineNormal.js +31 -37
  110. package/es/utils/simpleLine.js +2 -16
  111. package/es/utils/stencil.js +2 -3
  112. package/es/utils/symbol-layout.js +27 -53
  113. package/es/wind/index.js +9 -29
  114. package/es/wind/models/utils.js +26 -51
  115. package/es/wind/models/wind.js +101 -147
  116. package/es/wind/models/windRender.js +53 -66
  117. package/lib/Geometry/index.js +9 -38
  118. package/lib/Geometry/models/billboard.js +51 -97
  119. package/lib/Geometry/models/index.js +0 -5
  120. package/lib/Geometry/models/plane.js +79 -151
  121. package/lib/Geometry/models/sprite.js +60 -127
  122. package/lib/canvas/index.js +10 -40
  123. package/lib/canvas/models/canvas.js +41 -101
  124. package/lib/canvas/models/index.js +0 -3
  125. package/lib/citybuliding/building.js +8 -35
  126. package/lib/citybuliding/models/build.js +57 -92
  127. package/lib/core/BaseLayer.js +320 -478
  128. package/lib/core/BaseModel.js +97 -139
  129. package/lib/core/LayerPickService.js +21 -37
  130. package/lib/core/TextureService.js +0 -16
  131. package/lib/core/interface.js +21 -31
  132. package/lib/core/schema.js +0 -1
  133. package/lib/core/shape/Path.js +14 -31
  134. package/lib/core/shape/extrude.js +10 -54
  135. package/lib/core/triangulation.js +53 -153
  136. package/lib/earth/index.js +9 -43
  137. package/lib/earth/models/atmosphere.js +30 -63
  138. package/lib/earth/models/base.js +47 -90
  139. package/lib/earth/models/bloomsphere.js +30 -63
  140. package/lib/earth/utils.js +7 -31
  141. package/lib/heatmap/index.js +10 -48
  142. package/lib/heatmap/models/grid.js +28 -60
  143. package/lib/heatmap/models/grid3d.js +28 -60
  144. package/lib/heatmap/models/heatmap.js +91 -162
  145. package/lib/heatmap/models/hexagon.js +28 -60
  146. package/lib/heatmap/models/index.js +0 -6
  147. package/lib/heatmap/triangulation.js +0 -5
  148. package/lib/image/index.js +9 -36
  149. package/lib/image/models/image.js +66 -109
  150. package/lib/image/models/index.js +0 -3
  151. package/lib/index.js +7 -61
  152. package/lib/line/index.js +9 -40
  153. package/lib/line/models/arc.js +64 -128
  154. package/lib/line/models/arc_3d.js +58 -119
  155. package/lib/line/models/earthArc_3d.js +61 -122
  156. package/lib/line/models/great_circle.js +56 -111
  157. package/lib/line/models/half.js +46 -87
  158. package/lib/line/models/index.js +0 -11
  159. package/lib/line/models/line.js +92 -156
  160. package/lib/line/models/linearline.js +45 -92
  161. package/lib/line/models/simpleLine.js +41 -84
  162. package/lib/line/models/wall.js +52 -103
  163. package/lib/mask/index.js +9 -36
  164. package/lib/mask/models/fill.js +29 -63
  165. package/lib/mask/models/index.js +0 -3
  166. package/lib/plugins/DataMappingPlugin.js +80 -128
  167. package/lib/plugins/DataSourcePlugin.js +45 -76
  168. package/lib/plugins/FeatureScalePlugin.js +67 -138
  169. package/lib/plugins/LayerAnimateStylePlugin.js +0 -10
  170. package/lib/plugins/LayerMaskPlugin.js +4 -17
  171. package/lib/plugins/LayerModelPlugin.js +68 -113
  172. package/lib/plugins/LayerStylePlugin.js +4 -14
  173. package/lib/plugins/LightingPlugin.js +12 -25
  174. package/lib/plugins/MultiPassRendererPlugin.js +11 -22
  175. package/lib/plugins/PixelPickingPlugin.js +12 -27
  176. package/lib/plugins/RegisterStyleAttributePlugin.js +5 -19
  177. package/lib/plugins/ShaderUniformPlugin.js +13 -34
  178. package/lib/plugins/UpdateModelPlugin.js +1 -10
  179. package/lib/plugins/UpdateStyleAttributePlugin.js +5 -16
  180. package/lib/point/index.js +26 -83
  181. package/lib/point/models/earthExtrude.js +61 -113
  182. package/lib/point/models/earthFill.js +57 -117
  183. package/lib/point/models/extrude.js +60 -111
  184. package/lib/point/models/fill.js +68 -109
  185. package/lib/point/models/fillmage.js +61 -115
  186. package/lib/point/models/image.js +48 -98
  187. package/lib/point/models/index.js +1 -12
  188. package/lib/point/models/normal.js +30 -64
  189. package/lib/point/models/radar.js +40 -74
  190. package/lib/point/models/simplePoint.js +41 -79
  191. package/lib/point/models/text.js +214 -303
  192. package/lib/point/shape/extrude.js +4 -20
  193. package/lib/polygon/index.js +11 -48
  194. package/lib/polygon/models/extrude.js +48 -103
  195. package/lib/polygon/models/fill.js +54 -98
  196. package/lib/polygon/models/index.js +2 -14
  197. package/lib/polygon/models/ocean.js +42 -88
  198. package/lib/polygon/models/water.js +37 -82
  199. package/lib/raster/buffers/triangulation.js +3 -7
  200. package/lib/raster/index.js +9 -40
  201. package/lib/raster/models/index.js +0 -5
  202. package/lib/raster/models/raster.js +80 -125
  203. package/lib/raster/models/rasterRgb.js +84 -139
  204. package/lib/raster/models/rasterTerrainRgb.js +56 -93
  205. package/lib/tile/interaction/getRasterData.js +14 -25
  206. package/lib/tile/interaction/utils.js +7 -19
  207. package/lib/tile/manager/base.js +63 -104
  208. package/lib/tile/service/TileLayerService.js +30 -57
  209. package/lib/tile/service/TilePickService.js +26 -48
  210. package/lib/tile/service/TileSourceService.js +2 -16
  211. package/lib/tile/style/utils.js +0 -3
  212. package/lib/tile/tileFactory/DebugTile.js +28 -53
  213. package/lib/tile/tileFactory/ImageTile.js +20 -46
  214. package/lib/tile/tileFactory/MaskTile.js +22 -51
  215. package/lib/tile/tileFactory/RasterRGBTile.js +22 -50
  216. package/lib/tile/tileFactory/RasterTerrainRGBTile.js +20 -46
  217. package/lib/tile/tileFactory/RasterTile.js +30 -63
  218. package/lib/tile/tileFactory/Tile.js +63 -102
  219. package/lib/tile/tileFactory/VectorTile.js +41 -76
  220. package/lib/tile/tileFactory/index.js +0 -25
  221. package/lib/tile/tileFactory/layers/TileDebugLayer.js +6 -32
  222. package/lib/tile/tileFactory/util.js +0 -9
  223. package/lib/tile/tileLayer/BaseLayer.js +105 -153
  224. package/lib/tile/utils.js +1 -5
  225. package/lib/utils/blend.js +0 -5
  226. package/lib/utils/collision-index.js +9 -25
  227. package/lib/utils/dataMappingStyle.js +8 -19
  228. package/lib/utils/extrude_polyline.js +101 -181
  229. package/lib/utils/grid-index.js +2 -28
  230. package/lib/utils/identityScale.js +0 -9
  231. package/lib/utils/layerData.js +30 -49
  232. package/lib/utils/multiPassRender.js +11 -16
  233. package/lib/utils/polylineNormal.js +31 -66
  234. package/lib/utils/simpleLine.js +2 -21
  235. package/lib/utils/stencil.js +0 -4
  236. package/lib/utils/symbol-layout.js +27 -55
  237. package/lib/wind/index.js +9 -37
  238. package/lib/wind/models/index.js +0 -3
  239. package/lib/wind/models/utils.js +26 -62
  240. package/lib/wind/models/wind.js +101 -157
  241. package/lib/wind/models/windRender.js +53 -71
  242. package/lib/wind/models/windShader.js +0 -1
  243. package/package.json +7 -7
@@ -9,66 +9,50 @@ import { updateLayersConfig } from "../style/utils";
9
9
  export var Base = /*#__PURE__*/function () {
10
10
  function Base() {
11
11
  _classCallCheck(this, Base);
12
-
13
12
  _defineProperty(this, "tileCache", new Map());
14
-
15
13
  _defineProperty(this, "tileLayerCache", new Map());
16
14
  }
17
-
18
15
  _createClass(Base, [{
19
16
  key: "initTileLayers",
20
17
  value: function () {
21
18
  var _initTileLayers = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(layers, tile) {
22
19
  var _this = this;
23
-
24
20
  return _regeneratorRuntime.wrap(function _callee2$(_context2) {
25
- while (1) {
26
- switch (_context2.prev = _context2.next) {
27
- case 0:
28
- return _context2.abrupt("return", Promise.all(layers.map( /*#__PURE__*/function () {
29
- var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(layer) {
30
- var container;
31
- return _regeneratorRuntime.wrap(function _callee$(_context) {
32
- while (1) {
33
- switch (_context.prev = _context.next) {
34
- case 0:
35
- container = createLayerContainer(_this.parent.sceneContainer);
36
- layer.setContainer(container, _this.parent.sceneContainer);
37
- _context.next = 4;
38
- return layer.init();
39
-
40
- case 4:
41
- _this.addChild(layer);
42
-
43
- tile.layerLoad();
44
-
45
- _this.render();
46
-
47
- case 7:
48
- case "end":
49
- return _context.stop();
50
- }
51
- }
52
- }, _callee);
53
- }));
54
-
55
- return function (_x3) {
56
- return _ref.apply(this, arguments);
57
- };
58
- }())));
59
-
60
- case 1:
61
- case "end":
62
- return _context2.stop();
63
- }
21
+ while (1) switch (_context2.prev = _context2.next) {
22
+ case 0:
23
+ return _context2.abrupt("return", Promise.all(layers.map( /*#__PURE__*/function () {
24
+ var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(layer) {
25
+ var container;
26
+ return _regeneratorRuntime.wrap(function _callee$(_context) {
27
+ while (1) switch (_context.prev = _context.next) {
28
+ case 0:
29
+ container = createLayerContainer(_this.parent.sceneContainer);
30
+ layer.setContainer(container, _this.parent.sceneContainer);
31
+ _context.next = 4;
32
+ return layer.init();
33
+ case 4:
34
+ _this.addChild(layer);
35
+ tile.layerLoad();
36
+ _this.render();
37
+ case 7:
38
+ case "end":
39
+ return _context.stop();
40
+ }
41
+ }, _callee);
42
+ }));
43
+ return function (_x3) {
44
+ return _ref.apply(this, arguments);
45
+ };
46
+ }())));
47
+ case 1:
48
+ case "end":
49
+ return _context2.stop();
64
50
  }
65
51
  }, _callee2);
66
52
  }));
67
-
68
53
  function initTileLayers(_x, _x2) {
69
54
  return _initTileLayers.apply(this, arguments);
70
55
  }
71
-
72
56
  return initTileLayers;
73
57
  }()
74
58
  }, {
@@ -80,55 +64,48 @@ export var Base = /*#__PURE__*/function () {
80
64
  key: "hasTile",
81
65
  value: function hasTile(tile) {
82
66
  return this.tileCache.has(tile.key);
83
- } // 添加图层
67
+ }
84
68
 
69
+ // 添加图层
85
70
  }, {
86
71
  key: "addTile",
87
72
  value: function () {
88
73
  var _addTile = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3(tile) {
89
74
  var layerCollections;
90
75
  return _regeneratorRuntime.wrap(function _callee3$(_context3) {
91
- while (1) {
92
- switch (_context3.prev = _context3.next) {
93
- case 0:
94
- if (!this.hasTile(tile)) {
95
- _context3.next = 2;
96
- break;
97
- }
98
-
99
- return _context3.abrupt("return", {
100
- layers: []
101
- });
102
-
103
- case 2:
104
- // 存储当前 tile
105
- this.tileCache.set(tile.key, tile); // 创建 tile 对应的 layers
106
-
107
- layerCollections = this.tileFactory.createTile(tile, this.initOptions); // // 初始化图层
108
-
109
- _context3.next = 6;
110
- return this.initTileLayers(layerCollections.layers, tile);
111
-
112
- case 6:
113
- this.tileLayerCache.set(tile.key, layerCollections.layers); // const visible = tile.parent ? tile.parent.children.every(t=>this.tileLayerCache.has(t.key)) : true
114
- // tile.parent?.children.forEach((t)=>{
115
- // updateLayersConfig(this.getLayers(t),'visible',visible)
116
- // })
117
-
118
- return _context3.abrupt("return", layerCollections);
119
-
120
- case 8:
121
- case "end":
122
- return _context3.stop();
123
- }
76
+ while (1) switch (_context3.prev = _context3.next) {
77
+ case 0:
78
+ if (!this.hasTile(tile)) {
79
+ _context3.next = 2;
80
+ break;
81
+ }
82
+ return _context3.abrupt("return", {
83
+ layers: []
84
+ });
85
+ case 2:
86
+ // 存储当前 tile
87
+ this.tileCache.set(tile.key, tile);
88
+
89
+ // 创建 tile 对应的 layers
90
+ layerCollections = this.tileFactory.createTile(tile, this.initOptions); // // 初始化图层
91
+ _context3.next = 6;
92
+ return this.initTileLayers(layerCollections.layers, tile);
93
+ case 6:
94
+ this.tileLayerCache.set(tile.key, layerCollections.layers);
95
+ // const visible = tile.parent ? tile.parent.children.every(t=>this.tileLayerCache.has(t.key)) : true
96
+ // tile.parent?.children.forEach((t)=>{
97
+ // updateLayersConfig(this.getLayers(t),'visible',visible)
98
+ // })
99
+ return _context3.abrupt("return", layerCollections);
100
+ case 8:
101
+ case "end":
102
+ return _context3.stop();
124
103
  }
125
104
  }, _callee3, this);
126
105
  }));
127
-
128
106
  function addTile(_x4) {
129
107
  return _addTile.apply(this, arguments);
130
108
  }
131
-
132
109
  return addTile;
133
110
  }()
134
111
  }, {
@@ -148,7 +125,6 @@ export var Base = /*#__PURE__*/function () {
148
125
  key: "addChildren",
149
126
  value: function addChildren(layers) {
150
127
  var _this$children;
151
-
152
128
  (_this$children = this.children).push.apply(_this$children, _toConsumableArray(layers));
153
129
  }
154
130
  }, {
@@ -167,11 +143,9 @@ export var Base = /*#__PURE__*/function () {
167
143
  key: "removeChild",
168
144
  value: function removeChild(layer) {
169
145
  var layerIndex = this.children.indexOf(layer);
170
-
171
146
  if (layerIndex > -1) {
172
147
  this.children.splice(layerIndex, 1);
173
148
  }
174
-
175
149
  layer.destroy();
176
150
  }
177
151
  }, {
@@ -180,7 +154,6 @@ export var Base = /*#__PURE__*/function () {
180
154
  if (!tile) {
181
155
  return [];
182
156
  }
183
-
184
157
  return this.tileLayerCache.get(tile.key) || [];
185
158
  }
186
159
  }, {
@@ -205,7 +178,8 @@ export var Base = /*#__PURE__*/function () {
205
178
  }
206
179
  }, {
207
180
  key: "initTileFactory",
208
- value: function initTileFactory() {// this.tileFactory = new TileFactory({
181
+ value: function initTileFactory() {
182
+ // this.tileFactory = new TileFactory({
209
183
  // parent: this.parent,
210
184
  // mapService: this.mapService,
211
185
  // rendererService: this.rendererService,
@@ -226,11 +200,9 @@ export var Base = /*#__PURE__*/function () {
226
200
  key: "updateTileVisible",
227
201
  value: function updateTileVisible(tile, layerService) {
228
202
  var layers = this.getLayers(tile);
229
-
230
203
  if (layers.length === 0) {
231
204
  return;
232
205
  }
233
-
234
206
  if (tile.isVisible) {
235
207
  // 如果可见直接进行渲染,父级发
236
208
  updateLayersConfig(layers, 'visible', tile.isVisible);
@@ -243,16 +215,16 @@ export var Base = /*#__PURE__*/function () {
243
215
  // console.log(`${t.x}/${t.y}/${t.z}`)
244
216
  // })
245
217
  updateLayersConfig(layers, 'visible', tile.isVisible);
246
- } // this.listenLoad(tile, () => {
218
+ }
219
+
220
+ // this.listenLoad(tile, () => {
247
221
  // this.isTileAllLoad(tile) && updateLayersConfig(layers, 'visible', tile.isVisible);
248
222
  // })
249
-
250
223
  }
251
224
  }, {
252
225
  key: "listenLoad",
253
226
  value: function listenLoad(tile, callback) {
254
227
  var _tile$parent;
255
-
256
228
  tile.once('layerLoaded', function () {
257
229
  callback();
258
230
  });
@@ -271,7 +243,6 @@ export var Base = /*#__PURE__*/function () {
271
243
  if (tile.isLoad) {
272
244
  return true;
273
245
  }
274
-
275
246
  var isLoad = this.getLayers(tile).length === tile.loadedLayers;
276
247
  tile.isLoad = isLoad;
277
248
  return isLoad;
@@ -280,11 +251,9 @@ export var Base = /*#__PURE__*/function () {
280
251
  key: "isTileChildLoaded",
281
252
  value: function isTileChildLoaded(tile) {
282
253
  var _this2 = this;
283
-
284
254
  if (tile.isChildLoad) {
285
255
  return true;
286
256
  }
287
-
288
257
  var children = tile.children;
289
258
  var isLoad = children.filter(function (child) {
290
259
  return _this2.isTileLoaded(child);
@@ -296,7 +265,6 @@ export var Base = /*#__PURE__*/function () {
296
265
  key: "isTileParentLoaded",
297
266
  value: function isTileParentLoaded(tile) {
298
267
  var parent = tile.parent;
299
-
300
268
  if (!parent) {
301
269
  return true;
302
270
  } else {
@@ -318,6 +286,5 @@ export var Base = /*#__PURE__*/function () {
318
286
  this.tileLayerCache.clear();
319
287
  }
320
288
  }]);
321
-
322
289
  return Base;
323
290
  }();
@@ -9,22 +9,18 @@ export var TileLayerService = /*#__PURE__*/function () {
9
9
  /**
10
10
  * tileResource 用于存储瓦片的全局资源
11
11
  */
12
+
12
13
  function TileLayerService(_ref) {
13
14
  var rendererService = _ref.rendererService,
14
- layerService = _ref.layerService,
15
- parent = _ref.parent;
16
-
15
+ layerService = _ref.layerService,
16
+ parent = _ref.parent;
17
17
  _classCallCheck(this, TileLayerService);
18
-
19
18
  _defineProperty(this, "tileResource", new Map());
20
-
21
19
  _defineProperty(this, "layerTiles", []);
22
-
23
20
  this.rendererService = rendererService;
24
21
  this.layerService = layerService;
25
22
  this.parent = parent;
26
23
  }
27
-
28
24
  _createClass(TileLayerService, [{
29
25
  key: "tiles",
30
26
  get: function get() {
@@ -64,7 +60,6 @@ export var TileLayerService = /*#__PURE__*/function () {
64
60
  return t.key === tileKey;
65
61
  });
66
62
  var tile = this.layerTiles.splice(index, 1);
67
-
68
63
  if (tile[0]) {
69
64
  tile[0].destroy();
70
65
  }
@@ -72,7 +67,8 @@ export var TileLayerService = /*#__PURE__*/function () {
72
67
  }, {
73
68
  key: "updateTileVisible",
74
69
  value: function updateTileVisible(sourceTile) {
75
- var tile = this.getTile(sourceTile.key); // if(sourceTile.isVisible) {
70
+ var tile = this.getTile(sourceTile.key);
71
+ // if(sourceTile.isVisible) {
76
72
  // // 不可见 => 可见 兄弟节点加载完成
77
73
  // if(sourceTile.parent) {
78
74
  // const flag = this.isChildrenLoaded(sourceTile.parent)
@@ -80,6 +76,7 @@ export var TileLayerService = /*#__PURE__*/function () {
80
76
  // } else {
81
77
  // tile?.updateVisible(true);
82
78
  // }
79
+
83
80
  // } else {
84
81
  // // 可见 => 不可见 兄弟节点加载完成
85
82
  // if(sourceTile.parent) {
@@ -96,34 +93,26 @@ export var TileLayerService = /*#__PURE__*/function () {
96
93
  key: "isParentLoaded",
97
94
  value: function isParentLoaded(sourceTile) {
98
95
  var parentTile = sourceTile.parent;
99
-
100
96
  if (!parentTile) {
101
97
  return true;
102
98
  }
103
-
104
99
  var tile = this.getTile(parentTile === null || parentTile === void 0 ? void 0 : parentTile.key);
105
-
106
100
  if (tile !== null && tile !== void 0 && tile.isLoaded) {
107
101
  // 递归父级
108
102
  return true;
109
103
  }
110
-
111
104
  return false;
112
105
  }
113
106
  }, {
114
107
  key: "isChildrenLoaded",
115
108
  value: function isChildrenLoaded(sourceTile) {
116
109
  var _this = this;
117
-
118
110
  var childrenTile = sourceTile === null || sourceTile === void 0 ? void 0 : sourceTile.children;
119
-
120
111
  if (childrenTile.length === 0) {
121
112
  return true;
122
113
  }
123
-
124
114
  return childrenTile.some(function (tile) {
125
115
  var tileLayer = _this.getTile(tile === null || tile === void 0 ? void 0 : tile.key);
126
-
127
116
  return (tileLayer === null || tileLayer === void 0 ? void 0 : tileLayer.isLoaded) === false;
128
117
  });
129
118
  }
@@ -132,48 +121,38 @@ export var TileLayerService = /*#__PURE__*/function () {
132
121
  value: function () {
133
122
  var _render = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2() {
134
123
  var _this2 = this;
135
-
136
124
  var layers, renders;
137
125
  return _regeneratorRuntime.wrap(function _callee2$(_context2) {
138
- while (1) {
139
- switch (_context2.prev = _context2.next) {
140
- case 0:
141
- layers = this.getRenderLayers();
142
- renders = layers.map( /*#__PURE__*/function () {
143
- var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(layer) {
144
- return _regeneratorRuntime.wrap(function _callee$(_context) {
145
- while (1) {
146
- switch (_context.prev = _context.next) {
147
- case 0:
148
- _context.next = 2;
149
- return _this2.layerService.renderTileLayer(layer);
150
-
151
- case 2:
152
- case "end":
153
- return _context.stop();
154
- }
155
- }
156
- }, _callee);
157
- }));
158
-
159
- return function (_x) {
160
- return _ref2.apply(this, arguments);
161
- };
162
- }());
163
- Promise.all(renders);
164
-
165
- case 3:
166
- case "end":
167
- return _context2.stop();
168
- }
126
+ while (1) switch (_context2.prev = _context2.next) {
127
+ case 0:
128
+ layers = this.getRenderLayers();
129
+ renders = layers.map( /*#__PURE__*/function () {
130
+ var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(layer) {
131
+ return _regeneratorRuntime.wrap(function _callee$(_context) {
132
+ while (1) switch (_context.prev = _context.next) {
133
+ case 0:
134
+ _context.next = 2;
135
+ return _this2.layerService.renderTileLayer(layer);
136
+ case 2:
137
+ case "end":
138
+ return _context.stop();
139
+ }
140
+ }, _callee);
141
+ }));
142
+ return function (_x) {
143
+ return _ref2.apply(this, arguments);
144
+ };
145
+ }());
146
+ Promise.all(renders);
147
+ case 3:
148
+ case "end":
149
+ return _context2.stop();
169
150
  }
170
151
  }, _callee2, this);
171
152
  }));
172
-
173
153
  function render() {
174
154
  return _render.apply(this, arguments);
175
155
  }
176
-
177
156
  return render;
178
157
  }()
179
158
  }, {
@@ -214,6 +193,5 @@ export var TileLayerService = /*#__PURE__*/function () {
214
193
  this.tileResource.clear();
215
194
  }
216
195
  }]);
217
-
218
196
  return TileLayerService;
219
197
  }();
@@ -11,25 +11,20 @@ var ACTIVE = 'active';
11
11
  export var TilePickService = /*#__PURE__*/function () {
12
12
  function TilePickService(_ref) {
13
13
  var layerService = _ref.layerService,
14
- tileLayerService = _ref.tileLayerService,
15
- parent = _ref.parent;
16
-
14
+ tileLayerService = _ref.tileLayerService,
15
+ parent = _ref.parent;
17
16
  _classCallCheck(this, TilePickService);
18
-
19
17
  _defineProperty(this, "tilePickID", new Map());
20
-
21
18
  this.layerService = layerService;
22
19
  this.tileLayerService = tileLayerService;
23
20
  this.parent = parent;
24
21
  this.tileSourceService = new TileSourceService();
25
22
  }
26
-
27
23
  _createClass(TilePickService, [{
28
24
  key: "pickRender",
29
25
  value: function pickRender(target) {
30
26
  // 一个 TileLayer 有多个 Tile,但是会同时触发事件的只有一个 Tile
31
27
  var tile = this.tileLayerService.getVisibleTileBylngLat(target.lngLat);
32
-
33
28
  if (tile) {
34
29
  // TODO 多图层拾取
35
30
  var pickLayer = tile.getMainLayer();
@@ -41,18 +36,14 @@ export var TilePickService = /*#__PURE__*/function () {
41
36
  value: function pick(layer, target) {
42
37
  var container = this.parent.getContainer();
43
38
  var pickingService = container.get(TYPES.IPickingService);
44
-
45
39
  if (layer.type === 'RasterLayer') {
46
40
  var tile = this.tileLayerService.getVisibleTileBylngLat(target.lngLat);
47
-
48
41
  if (tile && tile.getMainLayer() !== undefined) {
49
42
  var pickLayer = tile.getMainLayer();
50
43
  return pickLayer.layerPickService.pickRasterLayer(pickLayer, target, this.parent);
51
44
  }
52
-
53
45
  return false;
54
46
  }
55
-
56
47
  this.pickRender(target);
57
48
  return pickingService.pickFromPickingFBO(layer, target);
58
49
  }
@@ -61,10 +52,9 @@ export var TilePickService = /*#__PURE__*/function () {
61
52
  value: function selectFeature(pickedColors) {
62
53
  // @ts-ignore
63
54
  var _pickedColors = _slicedToArray(pickedColors, 3),
64
- r = _pickedColors[0],
65
- g = _pickedColors[1],
66
- b = _pickedColors[2];
67
-
55
+ r = _pickedColors[0],
56
+ g = _pickedColors[1],
57
+ b = _pickedColors[2];
68
58
  var id = this.color2PickId(r, g, b);
69
59
  this.tilePickID.set(SELECT, id);
70
60
  this.updateHighLight(r, g, b, SELECT);
@@ -74,10 +64,9 @@ export var TilePickService = /*#__PURE__*/function () {
74
64
  value: function highlightPickedFeature(pickedColors) {
75
65
  // @ts-ignore
76
66
  var _pickedColors2 = _slicedToArray(pickedColors, 3),
77
- r = _pickedColors2[0],
78
- g = _pickedColors2[1],
79
- b = _pickedColors2[2];
80
-
67
+ r = _pickedColors2[0],
68
+ g = _pickedColors2[1],
69
+ b = _pickedColors2[2];
81
70
  var id = this.color2PickId(r, g, b);
82
71
  this.tilePickID.set(ACTIVE, id);
83
72
  this.updateHighLight(r, g, b, ACTIVE);
@@ -87,12 +76,10 @@ export var TilePickService = /*#__PURE__*/function () {
87
76
  value: function updateHighLight(r, g, b, type) {
88
77
  this.tileLayerService.tiles.map(function (tile) {
89
78
  var layer = tile.getMainLayer();
90
-
91
79
  switch (type) {
92
80
  case SELECT:
93
81
  layer === null || layer === void 0 ? void 0 : layer.hooks.beforeSelect.call([r, g, b]);
94
82
  break;
95
-
96
83
  case ACTIVE:
97
84
  layer === null || layer === void 0 ? void 0 : layer.hooks.beforeHighlight.call([r, g, b]);
98
85
  break;
@@ -104,25 +91,21 @@ export var TilePickService = /*#__PURE__*/function () {
104
91
  value: function setPickState() {
105
92
  var selectColor = this.tilePickID.get(SELECT);
106
93
  var activeColor = this.tilePickID.get(ACTIVE);
107
-
108
94
  if (selectColor) {
109
95
  var _this$pickId2Color = this.pickId2Color(selectColor),
110
- _this$pickId2Color2 = _slicedToArray(_this$pickId2Color, 3),
111
- r = _this$pickId2Color2[0],
112
- g = _this$pickId2Color2[1],
113
- b = _this$pickId2Color2[2];
114
-
96
+ _this$pickId2Color2 = _slicedToArray(_this$pickId2Color, 3),
97
+ r = _this$pickId2Color2[0],
98
+ g = _this$pickId2Color2[1],
99
+ b = _this$pickId2Color2[2];
115
100
  this.updateHighLight(r, g, b, SELECT);
116
101
  return;
117
102
  }
118
-
119
103
  if (activeColor) {
120
104
  var _this$pickId2Color3 = this.pickId2Color(activeColor),
121
- _this$pickId2Color4 = _slicedToArray(_this$pickId2Color3, 3),
122
- _r = _this$pickId2Color4[0],
123
- _g = _this$pickId2Color4[1],
124
- _b = _this$pickId2Color4[2];
125
-
105
+ _this$pickId2Color4 = _slicedToArray(_this$pickId2Color3, 3),
106
+ _r = _this$pickId2Color4[0],
107
+ _g = _this$pickId2Color4[1],
108
+ _b = _this$pickId2Color4[2];
126
109
  this.updateHighLight(_r, _g, _b, ACTIVE);
127
110
  return;
128
111
  }
@@ -137,33 +120,36 @@ export var TilePickService = /*#__PURE__*/function () {
137
120
  value: function pickId2Color(str) {
138
121
  return encodePickingColor(str);
139
122
  }
140
- /** 从瓦片中根据数据 */
141
123
 
124
+ /** 从瓦片中根据数据 */
142
125
  }, {
143
126
  key: "getFeatureById",
144
127
  value: function getFeatureById(pickedFeatureIdx) {
145
128
  // 提取当前可见瓦片
146
129
  var tiles = this.tileLayerService.getTiles().filter(function (tile) {
147
130
  return tile.visible;
148
- }); // 提取当前可见瓦片中匹配 ID 的 feature 列表
149
-
131
+ });
132
+ // 提取当前可见瓦片中匹配 ID 的 feature 列表
150
133
  var features = [];
151
134
  tiles.forEach(function (tile) {
152
135
  features.push.apply(features, _toConsumableArray(tile.getFeatureById(pickedFeatureIdx)));
153
- }); // 将 feature 列表合并后返回
136
+ });
137
+
138
+ // 将 feature 列表合并后返回
154
139
  // 统一返回成 polygon 的格式 点、线、面可以通用
140
+
155
141
  // const data = this.tileSourceService.getCombineFeature(features);
156
142
 
157
143
  return features;
158
- } // Tip: for interface define
159
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
144
+ }
160
145
 
146
+ // Tip: for interface define
147
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
161
148
  }, {
162
149
  key: "pickRasterLayer",
163
150
  value: function pickRasterLayer(layer, target, parent) {
164
151
  return false;
165
152
  }
166
153
  }]);
167
-
168
154
  return TilePickService;
169
155
  }();
@@ -3,37 +3,33 @@ import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
3
3
  import _createClass from "@babel/runtime/helpers/esm/createClass";
4
4
  import * as turf from '@turf/helpers';
5
5
  import union from '@turf/union';
6
+
6
7
  /**
7
8
  * 专门处理 Tile 数据相关
8
9
  */
9
-
10
10
  export var TileSourceService = /*#__PURE__*/function () {
11
11
  function TileSourceService() {
12
12
  _classCallCheck(this, TileSourceService);
13
13
  }
14
-
15
14
  _createClass(TileSourceService, [{
16
15
  key: "getCombineFeature",
17
16
  value: function getCombineFeature(features) {
18
17
  var p = null;
19
18
  var properties = features[0];
20
19
  features.map(function (feature) {
21
- var polygon = turf.polygon(feature.coordinates); // tslint:disable-next-line: prefer-conditional-expression
22
-
20
+ var polygon = turf.polygon(feature.coordinates);
21
+ // tslint:disable-next-line: prefer-conditional-expression
23
22
  if (p === null) {
24
23
  p = polygon;
25
24
  } else {
26
25
  p = union(p, polygon);
27
26
  }
28
27
  });
29
-
30
28
  if (properties) {
31
29
  p.properties = _objectSpread({}, properties);
32
30
  }
33
-
34
31
  return p;
35
32
  }
36
33
  }]);
37
-
38
34
  return TileSourceService;
39
35
  }();