@antv/l7-layers 2.9.12 → 2.9.15

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 (185) hide show
  1. package/LICENSE.md +1 -1
  2. package/es/core/BaseLayer.d.ts +2 -5
  3. package/es/core/BaseLayer.js +4 -35
  4. package/es/core/BaseLayer.js.map +1 -1
  5. package/es/core/BaseModel.d.ts +1 -2
  6. package/es/core/BaseModel.js +0 -3
  7. package/es/core/BaseModel.js.map +1 -1
  8. package/es/core/LayerGroup.d.ts +9 -0
  9. package/es/{tile/tileFactory/rasterDataLayer.js → core/LayerGroup.js} +32 -39
  10. package/es/core/LayerGroup.js.map +1 -0
  11. package/es/core/interface.d.ts +1 -14
  12. package/es/core/interface.js.map +1 -1
  13. package/es/image/models/image.js.map +1 -1
  14. package/es/line/index.d.ts +1 -1
  15. package/es/line/index.js +1 -7
  16. package/es/line/index.js.map +1 -1
  17. package/es/line/models/index.d.ts +1 -1
  18. package/es/line/models/index.js +1 -5
  19. package/es/line/models/index.js.map +1 -1
  20. package/es/plugins/FeatureScalePlugin.js +9 -35
  21. package/es/plugins/FeatureScalePlugin.js.map +1 -1
  22. package/es/plugins/ShaderUniformPlugin.js +1 -3
  23. package/es/plugins/ShaderUniformPlugin.js.map +1 -1
  24. package/es/point/index.d.ts +1 -1
  25. package/es/point/index.js +2 -8
  26. package/es/point/index.js.map +1 -1
  27. package/es/point/models/fill.d.ts +1 -8
  28. package/es/point/models/fill.js +33 -49
  29. package/es/point/models/fill.js.map +1 -1
  30. package/es/point/models/index.d.ts +1 -1
  31. package/es/point/models/index.js +1 -5
  32. package/es/point/models/index.js.map +1 -1
  33. package/es/point/models/radar.js +6 -2
  34. package/es/point/models/radar.js.map +1 -1
  35. package/es/polygon/index.js +0 -6
  36. package/es/polygon/index.js.map +1 -1
  37. package/es/polygon/models/index.d.ts +1 -1
  38. package/es/polygon/models/index.js +1 -5
  39. package/es/polygon/models/index.js.map +1 -1
  40. package/es/raster/index.d.ts +2 -2
  41. package/es/raster/index.js +4 -4
  42. package/es/raster/index.js.map +1 -1
  43. package/es/raster/models/index.js +1 -1
  44. package/es/raster/models/index.js.map +1 -1
  45. package/es/raster/models/raste-tile.d.ts +23 -0
  46. package/es/raster/models/raste-tile.js +285 -0
  47. package/es/raster/models/raste-tile.js.map +1 -0
  48. package/es/raster/models/raster.d.ts +0 -2
  49. package/es/raster/models/raster.js +12 -24
  50. package/es/raster/models/raster.js.map +1 -1
  51. package/lib/core/BaseLayer.js +3 -33
  52. package/lib/core/BaseLayer.js.map +1 -1
  53. package/lib/core/BaseModel.js +0 -2
  54. package/lib/core/BaseModel.js.map +1 -1
  55. package/lib/{tile/tileFactory/rasterDataLayer.js → core/LayerGroup.js} +32 -40
  56. package/lib/core/LayerGroup.js.map +1 -0
  57. package/lib/core/interface.js.map +1 -1
  58. package/lib/image/models/image.js.map +1 -1
  59. package/lib/line/index.js +1 -7
  60. package/lib/line/index.js.map +1 -1
  61. package/lib/line/models/index.js +1 -7
  62. package/lib/line/models/index.js.map +1 -1
  63. package/lib/plugins/FeatureScalePlugin.js +9 -35
  64. package/lib/plugins/FeatureScalePlugin.js.map +1 -1
  65. package/lib/plugins/ShaderUniformPlugin.js +1 -3
  66. package/lib/plugins/ShaderUniformPlugin.js.map +1 -1
  67. package/lib/point/index.js +2 -8
  68. package/lib/point/index.js.map +1 -1
  69. package/lib/point/models/fill.js +32 -46
  70. package/lib/point/models/fill.js.map +1 -1
  71. package/lib/point/models/index.js +1 -7
  72. package/lib/point/models/index.js.map +1 -1
  73. package/lib/point/models/radar.js +5 -1
  74. package/lib/point/models/radar.js.map +1 -1
  75. package/lib/polygon/index.js +0 -6
  76. package/lib/polygon/index.js.map +1 -1
  77. package/lib/polygon/models/index.js +1 -7
  78. package/lib/polygon/models/index.js.map +1 -1
  79. package/lib/raster/index.js +4 -4
  80. package/lib/raster/index.js.map +1 -1
  81. package/lib/raster/models/index.js +2 -2
  82. package/lib/raster/models/index.js.map +1 -1
  83. package/lib/raster/models/raste-tile.js +294 -0
  84. package/lib/raster/models/raste-tile.js.map +1 -0
  85. package/lib/raster/models/raster.js +12 -24
  86. package/lib/raster/models/raster.js.map +1 -1
  87. package/package.json +7 -9
  88. package/es/line/models/tile.d.ts +0 -20
  89. package/es/line/models/tile.js +0 -327
  90. package/es/line/models/tile.js.map +0 -1
  91. package/es/point/models/tile.d.ts +0 -31
  92. package/es/point/models/tile.js +0 -291
  93. package/es/point/models/tile.js.map +0 -1
  94. package/es/polygon/models/tile.d.ts +0 -16
  95. package/es/polygon/models/tile.js +0 -137
  96. package/es/polygon/models/tile.js.map +0 -1
  97. package/es/tile/interface.d.ts +0 -28
  98. package/es/tile/interface.js +0 -2
  99. package/es/tile/interface.js.map +0 -1
  100. package/es/tile/manager/tileConfigManager.d.ts +0 -17
  101. package/es/tile/manager/tileConfigManager.js +0 -123
  102. package/es/tile/manager/tileConfigManager.js.map +0 -1
  103. package/es/tile/manager/tileLayerManager.d.ts +0 -35
  104. package/es/tile/manager/tileLayerManager.js +0 -297
  105. package/es/tile/manager/tileLayerManager.js.map +0 -1
  106. package/es/tile/manager/tilePickerManager.d.ts +0 -21
  107. package/es/tile/manager/tilePickerManager.js +0 -189
  108. package/es/tile/manager/tilePickerManager.js.map +0 -1
  109. package/es/tile/models/tileModel.d.ts +0 -8
  110. package/es/tile/models/tileModel.js +0 -61
  111. package/es/tile/models/tileModel.js.map +0 -1
  112. package/es/tile/tileFactory/base.d.ts +0 -44
  113. package/es/tile/tileFactory/base.js +0 -423
  114. package/es/tile/tileFactory/base.js.map +0 -1
  115. package/es/tile/tileFactory/index.d.ts +0 -5
  116. package/es/tile/tileFactory/index.js +0 -30
  117. package/es/tile/tileFactory/index.js.map +0 -1
  118. package/es/tile/tileFactory/line.d.ts +0 -12
  119. package/es/tile/tileFactory/line.js +0 -65
  120. package/es/tile/tileFactory/line.js.map +0 -1
  121. package/es/tile/tileFactory/point.d.ts +0 -12
  122. package/es/tile/tileFactory/point.js +0 -65
  123. package/es/tile/tileFactory/point.js.map +0 -1
  124. package/es/tile/tileFactory/polygon.d.ts +0 -12
  125. package/es/tile/tileFactory/polygon.js +0 -65
  126. package/es/tile/tileFactory/polygon.js.map +0 -1
  127. package/es/tile/tileFactory/raster.d.ts +0 -12
  128. package/es/tile/tileFactory/raster.js +0 -61
  129. package/es/tile/tileFactory/raster.js.map +0 -1
  130. package/es/tile/tileFactory/rasterData.d.ts +0 -12
  131. package/es/tile/tileFactory/rasterData.js +0 -86
  132. package/es/tile/tileFactory/rasterData.js.map +0 -1
  133. package/es/tile/tileFactory/rasterDataLayer.d.ts +0 -19
  134. package/es/tile/tileFactory/rasterDataLayer.js.map +0 -1
  135. package/es/tile/tileFactory/vectorLayer.d.ts +0 -27
  136. package/es/tile/tileFactory/vectorLayer.js +0 -131
  137. package/es/tile/tileFactory/vectorLayer.js.map +0 -1
  138. package/es/tile/tileLayer/baseTileLayer.d.ts +0 -47
  139. package/es/tile/tileLayer/baseTileLayer.js +0 -409
  140. package/es/tile/tileLayer/baseTileLayer.js.map +0 -1
  141. package/es/tile/tmsTileLayer.d.ts +0 -7
  142. package/es/tile/tmsTileLayer.js +0 -100
  143. package/es/tile/tmsTileLayer.js.map +0 -1
  144. package/es/tile/utils.d.ts +0 -11
  145. package/es/tile/utils.js +0 -125
  146. package/es/tile/utils.js.map +0 -1
  147. package/lib/line/models/tile.js +0 -342
  148. package/lib/line/models/tile.js.map +0 -1
  149. package/lib/point/models/tile.js +0 -308
  150. package/lib/point/models/tile.js.map +0 -1
  151. package/lib/polygon/models/tile.js +0 -152
  152. package/lib/polygon/models/tile.js.map +0 -1
  153. package/lib/tile/interface.js +0 -2
  154. package/lib/tile/interface.js.map +0 -1
  155. package/lib/tile/manager/tileConfigManager.js +0 -134
  156. package/lib/tile/manager/tileConfigManager.js.map +0 -1
  157. package/lib/tile/manager/tileLayerManager.js +0 -305
  158. package/lib/tile/manager/tileLayerManager.js.map +0 -1
  159. package/lib/tile/manager/tilePickerManager.js +0 -195
  160. package/lib/tile/manager/tilePickerManager.js.map +0 -1
  161. package/lib/tile/models/tileModel.js +0 -73
  162. package/lib/tile/models/tileModel.js.map +0 -1
  163. package/lib/tile/tileFactory/base.js +0 -436
  164. package/lib/tile/tileFactory/base.js.map +0 -1
  165. package/lib/tile/tileFactory/index.js +0 -60
  166. package/lib/tile/tileFactory/index.js.map +0 -1
  167. package/lib/tile/tileFactory/line.js +0 -76
  168. package/lib/tile/tileFactory/line.js.map +0 -1
  169. package/lib/tile/tileFactory/point.js +0 -76
  170. package/lib/tile/tileFactory/point.js.map +0 -1
  171. package/lib/tile/tileFactory/polygon.js +0 -76
  172. package/lib/tile/tileFactory/polygon.js.map +0 -1
  173. package/lib/tile/tileFactory/raster.js +0 -74
  174. package/lib/tile/tileFactory/raster.js.map +0 -1
  175. package/lib/tile/tileFactory/rasterData.js +0 -99
  176. package/lib/tile/tileFactory/rasterData.js.map +0 -1
  177. package/lib/tile/tileFactory/rasterDataLayer.js.map +0 -1
  178. package/lib/tile/tileFactory/vectorLayer.js +0 -145
  179. package/lib/tile/tileFactory/vectorLayer.js.map +0 -1
  180. package/lib/tile/tileLayer/baseTileLayer.js +0 -407
  181. package/lib/tile/tileLayer/baseTileLayer.js.map +0 -1
  182. package/lib/tile/tmsTileLayer.js +0 -116
  183. package/lib/tile/tmsTileLayer.js.map +0 -1
  184. package/lib/tile/utils.js +0 -147
  185. package/lib/tile/utils.js.map +0 -1
package/es/tile/utils.js DELETED
@@ -1,125 +0,0 @@
1
- import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
2
- import { createLayerContainer } from '@antv/l7-core';
3
- import { DOM } from '@antv/l7-utils';
4
- export function registerLayers(parentLayer, layers) {
5
- layers.map(function (layer) {
6
- var container = createLayerContainer(parentLayer.sceneContainer);
7
- layer.setContainer(container, parentLayer.sceneContainer);
8
- layer.init();
9
- });
10
- }
11
- export function getLayerShape(layerType, layer) {
12
- var _layerShape$scale;
13
-
14
- var layerShape = layer.getAttribute('shape');
15
-
16
- if (layerShape && (_layerShape$scale = layerShape.scale) !== null && _layerShape$scale !== void 0 && _layerShape$scale.field) {
17
- var _layerShape$scale2;
18
-
19
- if (((_layerShape$scale2 = layerShape.scale) === null || _layerShape$scale2 === void 0 ? void 0 : _layerShape$scale2.values) === 'text') {
20
- return [layerShape.scale.field, layerShape.scale.values];
21
- }
22
-
23
- return layerShape.scale.field;
24
- }
25
-
26
- switch (layerType) {
27
- case 'PolygonLayer':
28
- return 'fill';
29
-
30
- case 'LineLayer':
31
- return 'tileline';
32
-
33
- case 'PointLayer':
34
- return 'circle';
35
-
36
- case 'RasterLayer':
37
- return 'image';
38
-
39
- default:
40
- return '';
41
- }
42
- }
43
- export function getMaskValue(layerType, mask) {
44
- switch (layerType) {
45
- case 'PolygonLayer':
46
- return true;
47
-
48
- case 'LineLayer':
49
- return true;
50
-
51
- case 'PointLayer':
52
- return false;
53
-
54
- case 'RasterLayer':
55
- return mask;
56
-
57
- default:
58
- return mask;
59
- }
60
- }
61
- export function getContainerSize(container) {
62
- if (!!container.getContext) {
63
- return {
64
- width: container.width / DOM.DPR,
65
- height: container.height / DOM.DPR
66
- };
67
- } else {
68
- return container.getBoundingClientRect();
69
- }
70
- }
71
- export function readRasterValue(tile, mapService, x, y) {
72
- var _tile$bboxPolygon, _tile$data, _tile$data2, _tile$data3;
73
-
74
- var bbox = (tile === null || tile === void 0 ? void 0 : (_tile$bboxPolygon = tile.bboxPolygon) === null || _tile$bboxPolygon === void 0 ? void 0 : _tile$bboxPolygon.bbox) || [0, 0, 10, -10];
75
-
76
- var _bbox = _slicedToArray(bbox, 4),
77
- _bbox$ = _bbox[0],
78
- minLng = _bbox$ === void 0 ? 0 : _bbox$,
79
- _bbox$2 = _bbox[1],
80
- minLat = _bbox$2 === void 0 ? 0 : _bbox$2,
81
- _bbox$3 = _bbox[2],
82
- maxLng = _bbox$3 === void 0 ? 10 : _bbox$3,
83
- _bbox$4 = _bbox[3],
84
- maxLat = _bbox$4 === void 0 ? -10 : _bbox$4;
85
-
86
- var tileXY = mapService.lngLatToContainer([minLng, minLat]);
87
- var tileMaxXY = mapService.lngLatToContainer([maxLng, maxLat]);
88
- var tilePixelWidth = tileMaxXY.x - tileXY.x;
89
- var tilePixelHeight = tileXY.y - tileMaxXY.y;
90
- var pos = [(x - tileXY.x) / tilePixelWidth, (y - tileMaxXY.y) / tilePixelHeight];
91
- var tileWidth = (tile === null || tile === void 0 ? void 0 : (_tile$data = tile.data) === null || _tile$data === void 0 ? void 0 : _tile$data.width) || 1;
92
- var tileHeight = (tile === null || tile === void 0 ? void 0 : (_tile$data2 = tile.data) === null || _tile$data2 === void 0 ? void 0 : _tile$data2.height) || 1;
93
- var indexX = Math.floor(pos[0] * tileWidth);
94
- var indexY = Math.floor(pos[1] * tileHeight);
95
- var index = Math.max(0, indexY - 1) * tileWidth + indexX;
96
- var data = tile === null || tile === void 0 ? void 0 : (_tile$data3 = tile.data) === null || _tile$data3 === void 0 ? void 0 : _tile$data3.data[index];
97
- return data;
98
- }
99
- export function readPixel(x, y, rendererService) {
100
- var readPixels = rendererService.readPixels,
101
- getContainer = rendererService.getContainer;
102
- var xInDevicePixel = x * DOM.DPR;
103
- var yInDevicePixel = y * DOM.DPR;
104
-
105
- var _getContainerSize = getContainerSize(getContainer()),
106
- width = _getContainerSize.width,
107
- height = _getContainerSize.height;
108
-
109
- width *= DOM.DPR;
110
- height *= DOM.DPR;
111
-
112
- if (xInDevicePixel > width - 1 * DOM.DPR || xInDevicePixel < 0 || yInDevicePixel > height - 1 * DOM.DPR || yInDevicePixel < 0) {
113
- return false;
114
- }
115
-
116
- var pickedColors = readPixels({
117
- x: Math.floor(xInDevicePixel),
118
- y: Math.floor(height - (y + 1) * DOM.DPR),
119
- width: 1,
120
- height: 1,
121
- data: new Uint8Array(1 * 1 * 4)
122
- });
123
- return pickedColors;
124
- }
125
- //# sourceMappingURL=utils.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/tile/utils.ts"],"names":["createLayerContainer","DOM","registerLayers","parentLayer","layers","map","layer","container","sceneContainer","setContainer","init","getLayerShape","layerType","layerShape","getAttribute","scale","field","values","getMaskValue","mask","getContainerSize","getContext","width","DPR","height","getBoundingClientRect","readRasterValue","tile","mapService","x","y","bbox","bboxPolygon","minLng","minLat","maxLng","maxLat","tileXY","lngLatToContainer","tileMaxXY","tilePixelWidth","tilePixelHeight","pos","tileWidth","data","tileHeight","indexX","Math","floor","indexY","index","max","readPixel","rendererService","readPixels","getContainer","xInDevicePixel","yInDevicePixel","pickedColors","Uint8Array"],"mappings":";AAAA,SACEA,oBADF,QAKO,eALP;AAMA,SAASC,GAAT,QAA0B,gBAA1B;AAEA,OAAO,SAASC,cAAT,CAAwBC,WAAxB,EAA6CC,MAA7C,EAA+D;AACpEA,EAAAA,MAAM,CAACC,GAAP,CAAW,UAACC,KAAD,EAAW;AACpB,QAAMC,SAAS,GAAGP,oBAAoB,CACpCG,WAAW,CAACK,cADwB,CAAtC;AAGAF,IAAAA,KAAK,CAACG,YAAN,CAAmBF,SAAnB,EAA8BJ,WAAW,CAACK,cAA1C;AACAF,IAAAA,KAAK,CAACI,IAAN;AACD,GAND;AAOD;AAED,OAAO,SAASC,aAAT,CAAuBC,SAAvB,EAA0CN,KAA1C,EAAyD;AAAA;;AAC9D,MAAMO,UAAU,GAAGP,KAAK,CAACQ,YAAN,CAAmB,OAAnB,CAAnB;;AACA,MAAID,UAAU,yBAAIA,UAAU,CAACE,KAAf,8CAAI,kBAAkBC,KAApC,EAA2C;AAAA;;AACzC,QAAI,uBAAAH,UAAU,CAACE,KAAX,0EAAkBE,MAAlB,MAA6B,MAAjC,EAAyC;AACvC,aAAO,CAACJ,UAAU,CAACE,KAAX,CAAiBC,KAAlB,EAAyBH,UAAU,CAACE,KAAX,CAAiBE,MAA1C,CAAP;AACD;;AACD,WAAOJ,UAAU,CAACE,KAAX,CAAiBC,KAAxB;AACD;;AACD,UAAQJ,SAAR;AACE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eAHK,EAIL;AACA,MAAQC,UAAR,GAAqCD,eAArC,CAAQC,UAAR;AAAA,MAAoBC,YAApB,GAAqCF,eAArC,CAAoBE,YAApB;AACA,MAAMC,cAAc,GAAG3B,CAAC,GAAG5B,GAAG,CAACsB,GAA/B;AACA,MAAMkC,cAAc,GAAG3B,CAAC,GAAG7B,GAAG,CAACsB,GAA/B;;AACA,0BAAwBH,gBAAgB,CACtCmC,YAAY,EAD0B,CAAxC;AAAA,MAAMjC,KAAN,qBAAMA,KAAN;AAAA,MAAaE,MAAb,qBAAaA,MAAb;;AAGAF,EAAAA,KAAK,IAAIrB,GAAG,CAACsB,GAAb;AACAC,EAAAA,MAAM,IAAIvB,GAAG,CAACsB,GAAd;;AACA,MACEiC,cAAc,GAAGlC,KAAK,GAAG,IAAIrB,GAAG,CAACsB,GAAjC,IACAiC,cAAc,GAAG,CADjB,IAEAC,cAAc,GAAGjC,MAAM,GAAG,IAAIvB,GAAG,CAACsB,GAFlC,IAGAkC,cAAc,GAAG,CAJnB,EAKE;AACA,WAAO,KAAP;AACD;;AAED,MAAMC,YAAY,GAAGJ,UAAU,CAAC;AAC9BzB,IAAAA,CAAC,EAAEkB,IAAI,CAACC,KAAL,CAAWQ,cAAX,CAD2B;AAG9B1B,IAAAA,CAAC,EAAEiB,IAAI,CAACC,KAAL,CAAWxB,MAAM,GAAG,CAACM,CAAC,GAAG,CAAL,IAAU7B,GAAG,CAACsB,GAAlC,CAH2B;AAI9BD,IAAAA,KAAK,EAAE,CAJuB;AAK9BE,IAAAA,MAAM,EAAE,CALsB;AAM9BoB,IAAAA,IAAI,EAAE,IAAIe,UAAJ,CAAe,IAAI,CAAJ,GAAQ,CAAvB;AANwB,GAAD,CAA/B;AAQA,SAAOD,YAAP;AACD","sourcesContent":["import {\n createLayerContainer,\n ILayer,\n IMapService,\n IRendererService,\n} from '@antv/l7-core';\nimport { DOM, Tile } from '@antv/l7-utils';\nimport { Container } from 'inversify';\nexport function registerLayers(parentLayer: ILayer, layers: ILayer[]) {\n layers.map((layer) => {\n const container = createLayerContainer(\n parentLayer.sceneContainer as Container,\n );\n layer.setContainer(container, parentLayer.sceneContainer as Container);\n layer.init();\n });\n}\n\nexport function getLayerShape(layerType: string, layer: ILayer) {\n const layerShape = layer.getAttribute('shape');\n if (layerShape && layerShape.scale?.field) {\n if (layerShape.scale?.values === 'text') {\n return [layerShape.scale.field, layerShape.scale.values] as string[];\n }\n return layerShape.scale.field as string;\n }\n switch (layerType) {\n case 'PolygonLayer':\n return 'fill';\n case 'LineLayer':\n return 'tileline';\n case 'PointLayer':\n return 'circle';\n case 'RasterLayer':\n return 'image';\n default:\n return '';\n }\n}\n\nexport function getMaskValue(layerType: string, mask: boolean) {\n switch (layerType) {\n case 'PolygonLayer':\n return true;\n case 'LineLayer':\n return true;\n case 'PointLayer':\n return false;\n case 'RasterLayer':\n return mask;\n default:\n return mask;\n }\n}\n\nexport function getContainerSize(container: HTMLCanvasElement | HTMLElement) {\n if (!!(container as HTMLCanvasElement).getContext) {\n return {\n width: (container as HTMLCanvasElement).width / DOM.DPR,\n height: (container as HTMLCanvasElement).height / DOM.DPR,\n };\n } else {\n return container.getBoundingClientRect();\n }\n}\n\nexport function readRasterValue(\n tile: Tile,\n mapService: IMapService,\n x: number,\n y: number,\n) {\n const bbox = tile?.bboxPolygon?.bbox || [0, 0, 10, -10];\n\n const [minLng = 0, minLat = 0, maxLng = 10, maxLat = -10] = bbox;\n\n const tileXY = mapService.lngLatToContainer([minLng, minLat]);\n const tileMaxXY = mapService.lngLatToContainer([maxLng, maxLat]);\n\n const tilePixelWidth = tileMaxXY.x - tileXY.x;\n const tilePixelHeight = tileXY.y - tileMaxXY.y;\n const pos = [\n (x - tileXY.x) / tilePixelWidth, // x\n (y - tileMaxXY.y) / tilePixelHeight, // y\n ];\n\n const tileWidth = tile?.data?.width || 1;\n const tileHeight = tile?.data?.height || 1;\n\n const indexX = Math.floor(pos[0] * tileWidth);\n const indexY = Math.floor(pos[1] * tileHeight);\n const index = Math.max(0, indexY - 1) * tileWidth + indexX;\n\n const data = tile?.data?.data[index];\n\n return data;\n}\n\nexport function readPixel(\n x: number,\n y: number,\n rendererService: IRendererService,\n) {\n const { readPixels, getContainer } = rendererService;\n const xInDevicePixel = x * DOM.DPR;\n const yInDevicePixel = y * DOM.DPR;\n let { width, height } = getContainerSize(\n getContainer() as HTMLCanvasElement | HTMLElement,\n );\n width *= DOM.DPR;\n height *= DOM.DPR;\n if (\n xInDevicePixel > width - 1 * DOM.DPR ||\n xInDevicePixel < 0 ||\n yInDevicePixel > height - 1 * DOM.DPR ||\n yInDevicePixel < 0\n ) {\n return false;\n }\n\n const pickedColors = readPixels({\n x: Math.floor(xInDevicePixel),\n // 视口坐标系原点在左上,而 WebGL 在左下,需要翻转 Y 轴\n y: Math.floor(height - (y + 1) * DOM.DPR),\n width: 1,\n height: 1,\n data: new Uint8Array(1 * 1 * 4),\n });\n return pickedColors;\n}\n"],"file":"utils.js"}
@@ -1,342 +0,0 @@
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 _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
15
-
16
- var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
17
-
18
- var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
19
-
20
- var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
21
-
22
- var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
23
-
24
- var _l7Core = require("@antv/l7-core");
25
-
26
- var _l7Utils = require("@antv/l7-utils");
27
-
28
- var _BaseModel2 = _interopRequireDefault(require("../../core/BaseModel"));
29
-
30
- var _triangulation = require("../../core/triangulation");
31
-
32
- 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); }; }
33
-
34
- 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; } }
35
-
36
- var line_tile_frag = "#define LineTexture 1.0\nuniform float u_blur : 0.99;\nuniform float u_opacity : 1.0;\nuniform float u_textureBlend;\n\nuniform float u_borderWidth: 0.0;\nuniform vec4 u_borderColor;\nvarying vec4 v_color;\n\n// line texture\nuniform float u_line_texture;\nuniform sampler2D u_texture;\nuniform vec2 u_textSize;\n\nvarying vec2 v_iconMapUV;\n\n#pragma include \"picking\"\n\nvarying mat4 styleMappingMat;\n\nvoid main() {\n float opacity = styleMappingMat[0][0];\n float d_distance_ratio = styleMappingMat[3].r; // \u5F53\u524D\u70B9\u4F4D\u8DDD\u79BB\u5360\u7EBF\u603B\u957F\u7684\u6BD4\u4F8B\n gl_FragColor = v_color;\n // anti-alias\n // float blur = 1.0 - smoothstep(u_blur, 1., length(v_normal.xy));\n gl_FragColor.a *= opacity; // \u5168\u5C40\u900F\u660E\u5EA6\n\n\n if(u_line_texture == LineTexture) { // while load texture\n float aDistance = styleMappingMat[3].g; // \u5F53\u524D\u9876\u70B9\u7684\u8DDD\u79BB\n float d_texPixelLen = styleMappingMat[3].b; // \u8D34\u56FE\u7684\u50CF\u7D20\u957F\u5EA6\uFF0C\u6839\u636E\u5730\u56FE\u5C42\u7EA7\u7F29\u653E\n float u = fract(mod(aDistance, d_texPixelLen)/d_texPixelLen);\n float v = styleMappingMat[3].a; // \u7EBF\u56FE\u5C42\u8D34\u56FE\u90E8\u5206\u7684 v \u5750\u6807\u503C\n\n // v = max(smoothstep(0.95, 1.0, v), v);\n vec2 uv= v_iconMapUV / u_textSize + vec2(u, v) / u_textSize * 64.;\n \n // gl_FragColor = filterColor(gl_FragColor + texture2D(u_texture, vec2(u, v)));\n // gl_FragColor = filterColor(gl_FragColor + texture2D(u_texture, uv));\n vec4 pattern = texture2D(u_texture, uv);\n\n if(u_textureBlend == 0.0) { // normal\n pattern.a = 0.0;\n gl_FragColor += pattern;\n } else { // replace\n pattern.a *= opacity;\n if(gl_FragColor.a <= 0.0) {\n pattern.a = 0.0;\n }\n gl_FragColor = pattern;\n }\n } \n\n float v = styleMappingMat[3].a;\n float borderWidth = min(0.5, u_borderWidth);\n // \u7ED8\u5236 border\n if(borderWidth > 0.01) {\n float borderOuterWidth = borderWidth/2.0;\n\n if(v >= 1.0 - borderWidth || v <= borderWidth) {\n if(v > borderWidth) {\n float linear = smoothstep(0.0, 1.0, (v - (1.0 - borderWidth))/borderWidth);\n gl_FragColor.rgb = mix(gl_FragColor.rgb, u_borderColor.rgb, linear);\n } else if(v <= borderWidth) {\n float linear = smoothstep(0.0, 1.0, v/borderWidth);\n gl_FragColor.rgb = mix(u_borderColor.rgb, gl_FragColor.rgb, linear);\n }\n }\n\n if(v < borderOuterWidth) {\n gl_FragColor.a = mix(0.0, gl_FragColor.a, v/borderOuterWidth);\n } else if(v > 1.0 - borderOuterWidth) {\n gl_FragColor.a = mix(gl_FragColor.a, 0.0, (v - (1.0 - borderOuterWidth))/borderOuterWidth);\n }\n }\n\n gl_FragColor = filterColor(gl_FragColor);\n}\n";
37
- var line_tile_vert = "\nattribute float a_Miter;\nattribute vec4 a_Color;\nattribute vec2 a_Size;\nattribute vec3 a_Normal;\nattribute vec3 a_Position;\n\nattribute vec2 a_iconMapUV;\n\n// dash line\nattribute float a_Total_Distance;\nattribute vec2 a_DistanceAndIndex;\n\nuniform vec2 u_tileOrigin;\nuniform float u_coord;\n\nuniform mat4 u_ModelMatrix;\nuniform mat4 u_Mvp;\nuniform float u_icon_step: 100;\n\nuniform float u_heightfixed: 0.0;\nuniform float u_vertexScale: 1.0;\n\n#pragma include \"projection\"\n#pragma include \"picking\"\n\nvarying vec4 v_color;\n\n// texV \u7EBF\u56FE\u5C42 - \u8D34\u56FE\u90E8\u5206\u7684 v \u5750\u6807\uFF08\u7EBF\u7684\u5BBD\u5EA6\u65B9\u5411\uFF09\nvarying vec2 v_iconMapUV;\n\n\nuniform float u_linearColor: 0;\nuniform float u_arrow: 0.0;\nuniform float u_arrowHeight: 3.0;\nuniform float u_arrowWidth: 2.0;\nuniform float u_tailWidth: 1.0;\n\nuniform float u_opacity: 1.0;\nvarying mat4 styleMappingMat; // \u7528\u4E8E\u5C06\u5728\u9876\u70B9\u7740\u8272\u5668\u4E2D\u8BA1\u7B97\u597D\u7684\u6837\u5F0F\u503C\u4F20\u9012\u7ED9\u7247\u5143\n\n#pragma include \"styleMapping\"\n#pragma include \"styleMappingCalOpacity\"\n\nvec2 calculateArrow(vec2 offset) {\n /*\n * \u5728\u652F\u6301\u7BAD\u5934\u7684\u65F6\u5019\uFF0C\u7B2C\u4E8C\u3001\u7B2C\u4E09\u7EC4\u9876\u70B9\u662F\u989D\u5916\u63D2\u5165\u7528\u4E8E\u6784\u5EFA\u9876\u70B9\u7684\n */\n float arrowFlag = -1.0;\n if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) {\n // \u9AD8\u5FB7 2.0 \u7684\u65CB\u8F6C\u89D2\u5EA6\u4E0D\u540C\n arrowFlag = 1.0;\n }\n float pi = arrowFlag * 3.1415926/2.;\n if(a_Miter < 0.) {\n // \u6839\u636E\u7EBF\u7684\u4E24\u4FA7\u504F\u79FB\u4E0D\u540C\u3001\u65CB\u8F6C\u7684\u65B9\u5411\u76F8\u53CD\n pi = -pi;\n }\n highp float angle_sin = sin(pi);\n highp float angle_cos = cos(pi);\n // \u8BA1\u7B97\u5782\u76F4\u4E0E\u7EBF\u65B9\u5411\u7684\u65CB\u8F6C\u77E9\u9635\n mat2 rotation_matrix = mat2(angle_cos, -1.0 * angle_sin, angle_sin, angle_cos);\n float arrowWidth = u_arrowWidth;\n float arrowHeight = u_arrowHeight;\n\n vec2 arrowOffset = vec2(0.0);\n /*\n * a_DistanceAndIndex.y \u7528\u4E8E\u6807\u8BB0\u5F53\u524D\u9876\u70B9\u5C5E\u4E8E\u54EA\u4E00\u7EC4\uFF08\u4E24\u4E2A\u9876\u70B9\u4E00\u7EC4\uFF0C\u6784\u6210\u7EBF\u7684\u5176\u5B9E\u662F\u77E9\u5F62\uFF0C\u6700\u7B80\u9700\u8981\u56DB\u4E2A\u9876\u70B9\u3001\u4E24\u7EC4\u9876\u70B9\u6784\u6210\uFF09\n */\n if(a_DistanceAndIndex.y == 0.0) {\n // \u7BAD\u5934\u5C16\u90E8\n offset = vec2(0.0);\n } else if(a_DistanceAndIndex.y == 1.0) {\n // \u7BAD\u5934\u4E24\u4FA7\n arrowOffset = rotation_matrix*(offset * arrowHeight);\n offset += arrowOffset; // \u6CBF\u7EBF\u504F\u79FB\n offset = offset * arrowWidth; // \u5782\u76F4\u7EBF\u5411\u5916\u504F\u79FB\uFF08\u662F\u6784\u5EFA\u7BAD\u5934\u4E24\u4FA7\u7684\u9876\u70B9\uFF09\n } else if(a_DistanceAndIndex.y == 2.0 || a_DistanceAndIndex.y == 3.0 || a_DistanceAndIndex.y == 4.0) {\n // \u504F\u79FB\u5176\u4F59\u7684\u70B9\u4F4D\uFF08\u5C06\u957F\u5EA6\u8BA9\u4F4D\u7ED9\u7BAD\u5934\uFF09\n arrowOffset = rotation_matrix*(offset * arrowHeight) * arrowWidth;\n offset += arrowOffset;// \u6CBF\u7EBF\u504F\u79FB\n }\n\n return offset;\n}\n\nvoid main() {\n // cal style mapping - \u6570\u636E\u7EB9\u7406\u6620\u5C04\u90E8\u5206\u7684\u8BA1\u7B97\n styleMappingMat = mat4(\n 0.0, 0.0, 0.0, 0.0, // opacity - strokeOpacity - strokeWidth - empty\n 0.0, 0.0, 0.0, 0.0, // strokeR - strokeG - strokeB - strokeA\n 0.0, 0.0, 0.0, 0.0, // offsets[0] - offsets[1]\n 0.0, 0.0, 0.0, 0.0 // distance_ratio/distance/pixelLen/texV\n );\n\n float rowCount = u_cellTypeLayout[0][0]; // \u5F53\u524D\u7684\u6570\u636E\u7EB9\u7406\u6709\u51E0\u884C\n float columnCount = u_cellTypeLayout[0][1]; // \u5F53\u770B\u5230\u6570\u636E\u7EB9\u7406\u6709\u51E0\u5217\n float columnWidth = 1.0/columnCount; // \u5217\u5BBD\n float rowHeight = 1.0/rowCount; // \u884C\u9AD8\n float cellCount = calCellCount(); // opacity - strokeOpacity - strokeWidth - stroke - offsets\n float id = a_vertexId; // \u7B2Cn\u4E2A\u9876\u70B9\n float cellCurrentRow = floor(id * cellCount / columnCount) + 1.0; // \u8D77\u59CB\u70B9\u5728\u7B2C\u51E0\u884C\n float cellCurrentColumn = mod(id * cellCount, columnCount) + 1.0; // \u8D77\u59CB\u70B9\u5728\u7B2C\u51E0\u5217\n \n // cell \u56FA\u5B9A\u987A\u5E8F opacity -> strokeOpacity -> strokeWidth -> stroke ... \n // \u6309\u987A\u5E8F\u4ECE cell \u4E2D\u53D6\u503C\u3001\u82E5\u6CA1\u6709\u5219\u81EA\u52A8\u5F80\u4E0B\u53D6\u503C\n float textureOffset = 0.0; // \u5728 cell \u4E2D\u53D6\u503C\u7684\u504F\u79FB\u91CF\n\n vec2 opacityAndOffset = calOpacityAndOffset(cellCurrentRow, cellCurrentColumn, columnCount, textureOffset, columnWidth, rowHeight);\n styleMappingMat[0][0] = opacityAndOffset.r;\n textureOffset = opacityAndOffset.g;\n // cal style mapping - \u6570\u636E\u7EB9\u7406\u6620\u5C04\u90E8\u5206\u7684\u8BA1\u7B97\n\n float d_texPixelLen; // \u8D34\u56FE\u7684\u50CF\u7D20\u957F\u5EA6\uFF0C\u6839\u636E\u5730\u56FE\u5C42\u7EA7\u7F29\u653E\n\n v_iconMapUV = a_iconMapUV;\n d_texPixelLen = project_float_pixel(u_icon_step);\n if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) {\n d_texPixelLen *= 10.0;\n }\n\n v_color = a_Color;\n\n vec3 size = a_Miter * setPickingSize(a_Size.x) * reverse_offset_normal(a_Normal);\n \n vec2 offset = project_pixel(size.xy);\n\n float lineDistance = a_DistanceAndIndex.x;\n float currentLinePointRatio = lineDistance / a_Total_Distance;\n \n if(u_arrow > 0.0) {\n // \u8BA1\u7B97\u7BAD\u5934\n offset = calculateArrow(offset);\n\n if(a_DistanceAndIndex.y > 4.0) {\n offset *= mix(1.0, u_tailWidth, currentLinePointRatio);\n }\n }\n\n float lineOffsetWidth = length(offset + offset * sign(a_Miter)); // \u7EBF\u6A2A\u5411\u504F\u79FB\u7684\u8DDD\u79BB\uFF08\u5411\u4E24\u4FA7\u504F\u79FB\u7684\u548C\uFF09\n float linePixelSize = project_pixel(a_Size.x) * 2.0; // \u5B9A\u70B9\u4F4D\u7F6E\u504F\u79FB\uFF0C\u6309\u5730\u56FE\u7B49\u7EA7\u7F29\u653E\u540E\u7684\u8DDD\u79BB \u5355\u4FA7 * 2\n float texV = lineOffsetWidth/linePixelSize; // \u7EBF\u56FE\u5C42\u8D34\u56FE\u90E8\u5206\u7684 v \u5750\u6807\u503C\n\n // \u8BBE\u7F6E\u6570\u636E\u96C6\u7684\u53C2\u6570\n styleMappingMat[3][0] = currentLinePointRatio; // \u5F53\u524D\u70B9\u4F4D\u8DDD\u79BB\u5360\u7EBF\u603B\u957F\u7684\u6BD4\u4F8B\n styleMappingMat[3][1] = lineDistance; // \u5F53\u524D\u9876\u70B9\u7684\u8DDD\u79BB\n styleMappingMat[3][2] = d_texPixelLen; // \u8D34\u56FE\u7684\u50CF\u7D20\u957F\u5EA6\uFF0C\u6839\u636E\u5730\u56FE\u5C42\u7EA7\u7F29\u653E\n styleMappingMat[3][3] = texV; // \u7EBF\u56FE\u5C42\u8D34\u56FE\u90E8\u5206\u7684 v \u5750\u6807\u503C\n\n vec4 project_pos = project_position(vec4(a_Position.xy, 0, 1.0));\n\n // gl_Position = project_common_position_to_clipspace(vec4(project_pos.xy + offset, a_Size.y, 1.0));\n\n float h = float(a_Position.z) * u_vertexScale; // \u7EBF\u9876\u70B9\u7684\u9AD8\u5EA6 - \u517C\u5BB9\u4E0D\u5B58\u5728\u7B2C\u4E09\u4E2A\u6570\u503C\u7684\u60C5\u51B5 vertex height\n float lineHeight = a_Size.y; // size \u7B2C\u4E8C\u4E2A\u53C2\u6570\u4EE3\u8868\u7684\u9AD8\u5EA6 [linewidth, lineheight]\n\nif(u_coord > 0.0) {\n if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) { // gaode2.x\n lineHeight *= 0.2; // \u4FDD\u6301\u548C amap/mapbox \u4E00\u81F4\u7684\u6548\u679C\n h *= 0.2;\n if(u_heightfixed < 1.0) {\n lineHeight = project_pixel(a_Size.y);\n }\n gl_Position = u_Mvp * (vec4(project_pos.xy + offset, lineHeight + h, 1.0));\n } else {\n // mapbox - amap\n \n // \u517C\u5BB9 mapbox \u5728\u7EBF\u9AD8\u5EA6\u4E0A\u7684\u6548\u679C\u8868\u73B0\u57FA\u672C\u4E00\u81F4\n if(u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT || u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT_OFFSET) {\n // mapbox\n // \u4FDD\u6301\u9AD8\u5EA6\u76F8\u5BF9\u4E0D\u53D8\n float mapboxZoomScale = 4.0/pow(2.0, 21.0 - u_Zoom);\n h *= mapboxZoomScale;\n if(u_heightfixed > 0.0) {\n lineHeight *= mapboxZoomScale;\n }\n \n } else {\n // amap\n // lineHeight \u9876\u70B9\u504F\u79FB\u9AD8\u5EA6\n if(u_heightfixed < 1.0) {\n lineHeight *= pow(2.0, 20.0 - u_Zoom);\n }\n }\n\n gl_Position = project_common_position_to_clipspace(vec4(project_pos.xy + offset, lineHeight + h, 1.0));\n }\n} else {\n vec2 pointPos = a_Position.xy;\n vec4 tileWorld = vec4(project_mvt_offset_position(vec4(u_tileOrigin, 0.0, 1.0)).xyz, 1.0); // \u74E6\u7247\u8D77\u59CB\u70B9\u7684\u4E16\u754C\u5750\u6807\n\n vec2 pointOffset = pointPos * pow(2.0, u_Zoom); // \u74E6\u7247\u5185\u7684\u70B9\u7684\u504F\u79FB\u5750\u6807\n \n tileWorld.xy += pointOffset;\n\n tileWorld.xy += offset;\n\n if (u_CoordinateSystem == COORDINATE_SYSTEM_METER_OFFSET || u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT_OFFSET) {\n // Needs to be divided with project_uCommonUnitsPerMeter\n tileWorld.w *= u_PixelsPerMeter.z;\n }\n\n gl_Position = u_ViewProjectionMatrix * tileWorld + u_ViewportCenterProjection;\n}\n\n\n setPickingColor(a_PickingColor);\n\n\n}\n";
38
-
39
- var LineModel = function (_BaseModel) {
40
- (0, _inherits2.default)(LineModel, _BaseModel);
41
-
42
- var _super = _createSuper(LineModel);
43
-
44
- function LineModel() {
45
- var _this;
46
-
47
- (0, _classCallCheck2.default)(this, LineModel);
48
-
49
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
50
- args[_key] = arguments[_key];
51
- }
52
-
53
- _this = _super.call.apply(_super, [this].concat(args));
54
- (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "texture", void 0);
55
- (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "updateTexture", function () {
56
- var createTexture2D = _this.rendererService.createTexture2D;
57
-
58
- if (_this.texture) {
59
- _this.texture.update({
60
- data: _this.iconService.getCanvas()
61
- });
62
-
63
- _this.layer.render();
64
-
65
- return;
66
- }
67
-
68
- _this.texture = createTexture2D({
69
- data: _this.iconService.getCanvas(),
70
- mag: _l7Core.gl.NEAREST,
71
- min: _l7Core.gl.NEAREST,
72
- premultiplyAlpha: false,
73
- width: 1024,
74
- height: _this.iconService.canvasHeight || 128
75
- });
76
- });
77
- return _this;
78
- }
79
-
80
- (0, _createClass2.default)(LineModel, [{
81
- key: "getUninforms",
82
- value: function getUninforms() {
83
- var _ref = this.layer.getLayerConfig(),
84
- _ref$opacity = _ref.opacity,
85
- opacity = _ref$opacity === void 0 ? 1 : _ref$opacity,
86
- _ref$textureBlend = _ref.textureBlend,
87
- textureBlend = _ref$textureBlend === void 0 ? 'normal' : _ref$textureBlend,
88
- _ref$lineTexture = _ref.lineTexture,
89
- lineTexture = _ref$lineTexture === void 0 ? false : _ref$lineTexture,
90
- _ref$iconStep = _ref.iconStep,
91
- iconStep = _ref$iconStep === void 0 ? 100 : _ref$iconStep,
92
- _ref$vertexHeightScal = _ref.vertexHeightScale,
93
- vertexHeightScale = _ref$vertexHeightScal === void 0 ? 20.0 : _ref$vertexHeightScal,
94
- _ref$borderWidth = _ref.borderWidth,
95
- borderWidth = _ref$borderWidth === void 0 ? 0.0 : _ref$borderWidth,
96
- _ref$borderColor = _ref.borderColor,
97
- borderColor = _ref$borderColor === void 0 ? '#ccc' : _ref$borderColor,
98
- _ref$heightfixed = _ref.heightfixed,
99
- heightfixed = _ref$heightfixed === void 0 ? false : _ref$heightfixed,
100
- _ref$arrow = _ref.arrow,
101
- arrow = _ref$arrow === void 0 ? {
102
- enable: false,
103
- arrowWidth: 2,
104
- arrowHeight: 3,
105
- tailWidth: 1
106
- } : _ref$arrow,
107
- _ref$coord = _ref.coord,
108
- coord = _ref$coord === void 0 ? 'lnglat' : _ref$coord,
109
- tileOrigin = _ref.tileOrigin;
110
-
111
- if (this.rendererService.getDirty()) {
112
- this.texture.bind();
113
- }
114
-
115
- if (this.dataTextureTest && this.dataTextureNeedUpdate({
116
- opacity: opacity
117
- })) {
118
- this.judgeStyleAttributes({
119
- opacity: opacity
120
- });
121
- var encodeData = this.layer.getEncodedData();
122
-
123
- var _this$calDataFrame = this.calDataFrame(this.cellLength, encodeData, this.cellProperties),
124
- data = _this$calDataFrame.data,
125
- width = _this$calDataFrame.width,
126
- height = _this$calDataFrame.height;
127
-
128
- this.rowCount = height;
129
- this.dataTexture = this.cellLength > 0 && data.length > 0 ? this.createTexture2D({
130
- flipY: true,
131
- data: data,
132
- format: _l7Core.gl.LUMINANCE,
133
- type: _l7Core.gl.FLOAT,
134
- width: width,
135
- height: height
136
- }) : this.createTexture2D({
137
- flipY: true,
138
- data: [1],
139
- format: _l7Core.gl.LUMINANCE,
140
- type: _l7Core.gl.FLOAT,
141
- width: 1,
142
- height: 1
143
- });
144
- }
145
-
146
- return {
147
- u_tileOrigin: tileOrigin || [0, 0],
148
- u_coord: coord === 'lnglat' ? 1.0 : 0.0,
149
- u_dataTexture: this.dataTexture,
150
- u_cellTypeLayout: this.getCellTypeLayout(),
151
- u_opacity: Number(opacity),
152
- u_textureBlend: textureBlend === 'normal' ? 0.0 : 1.0,
153
- u_texture: this.texture,
154
- u_line_texture: lineTexture ? 1.0 : 0.0,
155
- u_icon_step: iconStep,
156
- u_textSize: [1024, this.iconService.canvasHeight || 128],
157
- u_borderWidth: borderWidth,
158
- u_borderColor: (0, _l7Utils.rgb2arr)(borderColor),
159
- u_heightfixed: Number(heightfixed),
160
- u_vertexScale: vertexHeightScale,
161
- u_arrow: Number(arrow.enable),
162
- u_arrowHeight: arrow.arrowHeight || 3,
163
- u_arrowWidth: arrow.arrowWidth || 2,
164
- u_tailWidth: arrow.tailWidth === undefined ? 1 : arrow.tailWidth
165
- };
166
- }
167
- }, {
168
- key: "initModels",
169
- value: function initModels() {
170
- this.updateTexture();
171
- this.iconService.on('imageUpdate', this.updateTexture);
172
- return this.buildModels();
173
- }
174
- }, {
175
- key: "clearModels",
176
- value: function clearModels() {
177
- var _this$texture, _this$dataTexture;
178
-
179
- (_this$texture = this.texture) === null || _this$texture === void 0 ? void 0 : _this$texture.destroy();
180
- (_this$dataTexture = this.dataTexture) === null || _this$dataTexture === void 0 ? void 0 : _this$dataTexture.destroy();
181
- this.iconService.off('imageUpdate', this.updateTexture);
182
- }
183
- }, {
184
- key: "buildModels",
185
- value: function buildModels() {
186
- var _ref2 = this.layer.getLayerConfig(),
187
- _ref2$mask = _ref2.mask,
188
- mask = _ref2$mask === void 0 ? false : _ref2$mask,
189
- _ref2$maskInside = _ref2.maskInside,
190
- maskInside = _ref2$maskInside === void 0 ? true : _ref2$maskInside,
191
- _ref2$depth = _ref2.depth,
192
- depth = _ref2$depth === void 0 ? false : _ref2$depth;
193
-
194
- var _this$getShaders = this.getShaders(),
195
- frag = _this$getShaders.frag,
196
- vert = _this$getShaders.vert,
197
- type = _this$getShaders.type;
198
-
199
- this.layer.triangulation = _triangulation.LineTriangulation;
200
- return [this.layer.buildLayerModel({
201
- moduleName: type,
202
- vertexShader: vert,
203
- fragmentShader: frag,
204
- triangulation: _triangulation.LineTriangulation,
205
- primitive: _l7Core.gl.TRIANGLES,
206
- blend: this.getBlend(),
207
- depth: {
208
- enable: depth
209
- },
210
- stencil: (0, _l7Utils.getMask)(mask, maskInside)
211
- })];
212
- }
213
- }, {
214
- key: "getShaders",
215
- value: function getShaders() {
216
- return {
217
- frag: line_tile_frag,
218
- vert: line_tile_vert,
219
- type: 'line_tile'
220
- };
221
- }
222
- }, {
223
- key: "registerBuiltinAttributes",
224
- value: function registerBuiltinAttributes() {
225
- var _this2 = this;
226
-
227
- this.styleAttributeService.registerStyleAttribute({
228
- name: 'distanceAndIndex',
229
- type: _l7Core.AttributeType.Attribute,
230
- descriptor: {
231
- name: 'a_DistanceAndIndex',
232
- buffer: {
233
- usage: _l7Core.gl.STATIC_DRAW,
234
- data: [],
235
- type: _l7Core.gl.FLOAT
236
- },
237
- size: 2,
238
- update: function update(feature, featureIdx, vertex, attributeIdx, normal, vertexIndex) {
239
- return vertexIndex === undefined ? [vertex[3], 10] : [vertex[3], vertexIndex];
240
- }
241
- }
242
- });
243
- this.styleAttributeService.registerStyleAttribute({
244
- name: 'total_distance',
245
- type: _l7Core.AttributeType.Attribute,
246
- descriptor: {
247
- name: 'a_Total_Distance',
248
- buffer: {
249
- usage: _l7Core.gl.STATIC_DRAW,
250
- data: [],
251
- type: _l7Core.gl.FLOAT
252
- },
253
- size: 1,
254
- update: function update(feature, featureIdx, vertex, attributeIdx) {
255
- return [vertex[5]];
256
- }
257
- }
258
- });
259
- this.styleAttributeService.registerStyleAttribute({
260
- name: 'size',
261
- type: _l7Core.AttributeType.Attribute,
262
- descriptor: {
263
- name: 'a_Size',
264
- buffer: {
265
- usage: _l7Core.gl.DYNAMIC_DRAW,
266
- data: [],
267
- type: _l7Core.gl.FLOAT
268
- },
269
- size: 2,
270
- update: function update(feature, featureIdx, vertex, attributeIdx) {
271
- var _feature$size = feature.size,
272
- size = _feature$size === void 0 ? 1 : _feature$size;
273
- return Array.isArray(size) ? [size[0], size[1]] : [size, 0];
274
- }
275
- }
276
- });
277
- this.styleAttributeService.registerStyleAttribute({
278
- name: 'normal',
279
- type: _l7Core.AttributeType.Attribute,
280
- descriptor: {
281
- name: 'a_Normal',
282
- buffer: {
283
- usage: _l7Core.gl.STATIC_DRAW,
284
- data: [],
285
- type: _l7Core.gl.FLOAT
286
- },
287
- size: 3,
288
- update: function update(feature, featureIdx, vertex, attributeIdx, normal) {
289
- return normal;
290
- }
291
- }
292
- });
293
- this.styleAttributeService.registerStyleAttribute({
294
- name: 'miter',
295
- type: _l7Core.AttributeType.Attribute,
296
- descriptor: {
297
- name: 'a_Miter',
298
- buffer: {
299
- usage: _l7Core.gl.STATIC_DRAW,
300
- data: [],
301
- type: _l7Core.gl.FLOAT
302
- },
303
- size: 1,
304
- update: function update(feature, featureIdx, vertex, attributeIdx) {
305
- return [vertex[4]];
306
- }
307
- }
308
- });
309
- this.styleAttributeService.registerStyleAttribute({
310
- name: 'uv',
311
- type: _l7Core.AttributeType.Attribute,
312
- descriptor: {
313
- name: 'a_iconMapUV',
314
- buffer: {
315
- usage: _l7Core.gl.DYNAMIC_DRAW,
316
- data: [],
317
- type: _l7Core.gl.FLOAT
318
- },
319
- size: 2,
320
- update: function update(feature, featureIdx, vertex, attributeIdx) {
321
- var iconMap = _this2.iconService.getIconMap();
322
-
323
- var texture = feature.texture;
324
-
325
- var _ref3 = iconMap[texture] || {
326
- x: 0,
327
- y: 0
328
- },
329
- x = _ref3.x,
330
- y = _ref3.y;
331
-
332
- return [x, y];
333
- }
334
- }
335
- });
336
- }
337
- }]);
338
- return LineModel;
339
- }(_BaseModel2.default);
340
-
341
- exports.default = LineModel;
342
- //# sourceMappingURL=tile.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../src/line/models/tile.ts"],"names":["LineModel","createTexture2D","rendererService","texture","update","data","iconService","getCanvas","layer","render","mag","gl","NEAREST","min","premultiplyAlpha","width","height","canvasHeight","getLayerConfig","opacity","textureBlend","lineTexture","iconStep","vertexHeightScale","borderWidth","borderColor","heightfixed","arrow","enable","arrowWidth","arrowHeight","tailWidth","coord","tileOrigin","getDirty","bind","dataTextureTest","dataTextureNeedUpdate","judgeStyleAttributes","encodeData","getEncodedData","calDataFrame","cellLength","cellProperties","rowCount","dataTexture","length","flipY","format","LUMINANCE","type","FLOAT","u_tileOrigin","u_coord","u_dataTexture","u_cellTypeLayout","getCellTypeLayout","u_opacity","Number","u_textureBlend","u_texture","u_line_texture","u_icon_step","u_textSize","u_borderWidth","u_borderColor","u_heightfixed","u_vertexScale","u_arrow","u_arrowHeight","u_arrowWidth","u_tailWidth","undefined","updateTexture","on","buildModels","destroy","off","mask","maskInside","depth","getShaders","frag","vert","triangulation","LineTriangulation","buildLayerModel","moduleName","vertexShader","fragmentShader","primitive","TRIANGLES","blend","getBlend","stencil","line_tile_frag","line_tile_vert","styleAttributeService","registerStyleAttribute","name","AttributeType","Attribute","descriptor","buffer","usage","STATIC_DRAW","size","feature","featureIdx","vertex","attributeIdx","normal","vertexIndex","DYNAMIC_DRAW","Array","isArray","iconMap","getIconMap","x","y","BaseModel"],"mappings":";;;;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BiH,OAAO,CAACjH,OAAD,CAAP,IAA8B;AAAEmH,cAAAA,CAAC,EAAE,CAAL;AAAQC,cAAAA,CAAC,EAAE;AAAX,aAA/C;AAAA,gBAAQD,CAAR,SAAQA,CAAR;AAAA,gBAAWC,CAAX,SAAWA,CAAX;;AACA,mBAAO,CAACD,CAAD,EAAIC,CAAJ,CAAP;AACD;AAnBS;AAHoC,OAAlD;AAyBD;;;EA1RoCC,mB","sourcesContent":["import {\n AttributeType,\n gl,\n IEncodeFeature,\n ILayerConfig,\n IModel,\n IModelUniform,\n ITexture2D,\n} from '@antv/l7-core';\n\nimport { getMask, rgb2arr } from '@antv/l7-utils';\nimport BaseModel from '../../core/BaseModel';\nimport { ILineLayerStyleOptions } from '../../core/interface';\nimport { LineTriangulation } from '../../core/triangulation';\n\nimport line_tile_frag from '../shaders/tile/line_tile_frag.glsl';\nimport line_tile_vert from '../shaders/tile/line_tile_vert.glsl';\n\nexport default class LineModel extends BaseModel {\n protected texture: ITexture2D;\n public getUninforms(): IModelUniform {\n const {\n opacity = 1,\n textureBlend = 'normal',\n lineTexture = false,\n iconStep = 100,\n vertexHeightScale = 20.0,\n borderWidth = 0.0,\n borderColor = '#ccc',\n heightfixed = false,\n arrow = {\n enable: false,\n arrowWidth: 2,\n arrowHeight: 3,\n tailWidth: 1,\n },\n coord = 'lnglat',\n tileOrigin,\n } = this.layer.getLayerConfig() as ILineLayerStyleOptions;\n\n if (this.rendererService.getDirty()) {\n this.texture.bind();\n }\n\n if (this.dataTextureTest && this.dataTextureNeedUpdate({ opacity })) {\n this.judgeStyleAttributes({ opacity });\n const encodeData = this.layer.getEncodedData();\n const { data, width, height } = this.calDataFrame(\n this.cellLength,\n encodeData,\n this.cellProperties,\n );\n this.rowCount = height; // 当前数据纹理有多少行\n\n this.dataTexture =\n this.cellLength > 0 && data.length > 0\n ? this.createTexture2D({\n flipY: true,\n data,\n format: gl.LUMINANCE,\n type: gl.FLOAT,\n width,\n height,\n })\n : this.createTexture2D({\n flipY: true,\n data: [1],\n format: gl.LUMINANCE,\n type: gl.FLOAT,\n width: 1,\n height: 1,\n });\n }\n return {\n u_tileOrigin: tileOrigin || [0, 0],\n u_coord: coord === 'lnglat' ? 1.0 : 0.0,\n u_dataTexture: this.dataTexture, // 数据纹理 - 有数据映射的时候纹理中带数据,若没有任何数据映射时纹理是 [1]\n u_cellTypeLayout: this.getCellTypeLayout(),\n u_opacity: Number(opacity),\n u_textureBlend: textureBlend === 'normal' ? 0.0 : 1.0,\n\n // 纹理支持参数\n u_texture: this.texture, // 贴图\n u_line_texture: lineTexture ? 1.0 : 0.0, // 传入线的标识\n u_icon_step: iconStep,\n u_textSize: [1024, this.iconService.canvasHeight || 128],\n\n // line border 参数\n u_borderWidth: borderWidth,\n u_borderColor: rgb2arr(borderColor),\n\n // 是否固定高度\n u_heightfixed: Number(heightfixed),\n\n // 顶点高度 scale\n u_vertexScale: vertexHeightScale,\n\n // arrow\n u_arrow: Number(arrow.enable),\n u_arrowHeight: arrow.arrowHeight || 3,\n u_arrowWidth: arrow.arrowWidth || 2,\n u_tailWidth: arrow.tailWidth === undefined ? 1 : arrow.tailWidth,\n };\n }\n\n public initModels(): IModel[] {\n this.updateTexture();\n this.iconService.on('imageUpdate', this.updateTexture);\n\n return this.buildModels();\n }\n\n public clearModels() {\n this.texture?.destroy();\n this.dataTexture?.destroy();\n this.iconService.off('imageUpdate', this.updateTexture);\n }\n\n public buildModels(): IModel[] {\n const {\n mask = false,\n maskInside = true,\n depth = false,\n } = this.layer.getLayerConfig() as ILineLayerStyleOptions;\n const { frag, vert, type } = this.getShaders();\n this.layer.triangulation = LineTriangulation;\n return [\n this.layer.buildLayerModel({\n moduleName: type,\n vertexShader: vert,\n fragmentShader: frag,\n triangulation: LineTriangulation,\n primitive: gl.TRIANGLES,\n blend: this.getBlend(),\n depth: { enable: depth },\n // depth: { enable: true },\n stencil: getMask(mask, maskInside),\n }),\n ];\n }\n\n /**\n * 根据参数获取不同的 shader 代码\n * @returns\n */\n public getShaders(): { frag: string; vert: string; type: string } {\n return {\n frag: line_tile_frag,\n vert: line_tile_vert,\n type: 'line_tile',\n };\n }\n\n protected registerBuiltinAttributes() {\n this.styleAttributeService.registerStyleAttribute({\n name: 'distanceAndIndex',\n type: AttributeType.Attribute,\n descriptor: {\n name: 'a_DistanceAndIndex',\n buffer: {\n // give the WebGL driver a hint that this buffer may change\n usage: gl.STATIC_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 normal: number[],\n vertexIndex?: number,\n ) => {\n return vertexIndex === undefined\n ? [vertex[3], 10]\n : [vertex[3], vertexIndex];\n },\n },\n });\n this.styleAttributeService.registerStyleAttribute({\n name: 'total_distance',\n type: AttributeType.Attribute,\n descriptor: {\n name: 'a_Total_Distance',\n buffer: {\n // give the WebGL driver a hint that this buffer may change\n usage: gl.STATIC_DRAW,\n data: [],\n type: gl.FLOAT,\n },\n size: 1,\n update: (\n feature: IEncodeFeature,\n featureIdx: number,\n vertex: number[],\n attributeIdx: number,\n ) => {\n return [vertex[5]];\n },\n },\n });\n\n this.styleAttributeService.registerStyleAttribute({\n name: 'size',\n type: AttributeType.Attribute,\n descriptor: {\n name: 'a_Size',\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 const { size = 1 } = feature;\n return Array.isArray(size) ? [size[0], size[1]] : [size as number, 0];\n },\n },\n });\n\n // point layer size;\n this.styleAttributeService.registerStyleAttribute({\n name: 'normal',\n type: AttributeType.Attribute,\n descriptor: {\n name: 'a_Normal',\n buffer: {\n // give the WebGL driver a hint that this buffer may change\n usage: gl.STATIC_DRAW,\n data: [],\n type: gl.FLOAT,\n },\n size: 3,\n update: (\n feature: IEncodeFeature,\n featureIdx: number,\n vertex: number[],\n attributeIdx: number,\n normal: number[],\n ) => {\n return normal;\n },\n },\n });\n\n this.styleAttributeService.registerStyleAttribute({\n name: 'miter',\n type: AttributeType.Attribute,\n descriptor: {\n name: 'a_Miter',\n buffer: {\n // give the WebGL driver a hint that this buffer may change\n usage: gl.STATIC_DRAW,\n data: [],\n type: gl.FLOAT,\n },\n size: 1,\n update: (\n feature: IEncodeFeature,\n featureIdx: number,\n vertex: number[],\n attributeIdx: number,\n ) => {\n return [vertex[4]];\n },\n },\n });\n\n this.styleAttributeService.registerStyleAttribute({\n name: 'uv',\n type: AttributeType.Attribute,\n descriptor: {\n name: 'a_iconMapUV',\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 const iconMap = this.iconService.getIconMap();\n const { texture } = feature;\n const { x, y } = iconMap[texture as string] || { x: 0, y: 0 };\n return [x, y];\n },\n },\n });\n }\n\n private updateTexture = () => {\n const { createTexture2D } = this.rendererService;\n if (this.texture) {\n this.texture.update({\n data: this.iconService.getCanvas(),\n });\n this.layer.render();\n return;\n }\n this.texture = createTexture2D({\n data: this.iconService.getCanvas(),\n mag: gl.NEAREST,\n min: gl.NEAREST,\n premultiplyAlpha: false,\n width: 1024,\n height: this.iconService.canvasHeight || 128,\n });\n };\n}\n"],"file":"tile.js"}