@antv/l7-layers 2.9.18 → 2.9.21

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 (362) hide show
  1. package/es/Geometry/index.js +12 -2
  2. package/es/Geometry/index.js.map +1 -1
  3. package/es/Geometry/models/billboard.d.ts +3 -3
  4. package/es/Geometry/models/billboard.js +11 -6
  5. package/es/Geometry/models/billboard.js.map +1 -1
  6. package/es/Geometry/models/plane.d.ts +3 -3
  7. package/es/Geometry/models/plane.js +12 -7
  8. package/es/Geometry/models/plane.js.map +1 -1
  9. package/es/Geometry/models/sprite.d.ts +3 -3
  10. package/es/Geometry/models/sprite.js +11 -6
  11. package/es/Geometry/models/sprite.js.map +1 -1
  12. package/es/canvas/index.js +12 -2
  13. package/es/canvas/index.js.map +1 -1
  14. package/es/citybuliding/building.js +12 -2
  15. package/es/citybuliding/building.js.map +1 -1
  16. package/es/citybuliding/models/build.d.ts +2 -1
  17. package/es/citybuliding/models/build.js +16 -3
  18. package/es/citybuliding/models/build.js.map +1 -1
  19. package/es/core/BaseLayer.d.ts +1 -1
  20. package/es/core/BaseLayer.js +105 -62
  21. package/es/core/BaseLayer.js.map +1 -1
  22. package/es/core/BaseModel.d.ts +2 -2
  23. package/es/core/BaseModel.js +2 -2
  24. package/es/core/BaseModel.js.map +1 -1
  25. package/es/core/interface.d.ts +13 -1
  26. package/es/core/interface.js +14 -0
  27. package/es/core/interface.js.map +1 -1
  28. package/es/core/triangulation.d.ts +1 -0
  29. package/es/core/triangulation.js +37 -11
  30. package/es/core/triangulation.js.map +1 -1
  31. package/es/earth/index.js +8 -2
  32. package/es/earth/index.js.map +1 -1
  33. package/es/earth/models/atmosphere.d.ts +2 -2
  34. package/es/earth/models/atmosphere.js +11 -6
  35. package/es/earth/models/atmosphere.js.map +1 -1
  36. package/es/earth/models/base.d.ts +2 -2
  37. package/es/earth/models/base.js +11 -6
  38. package/es/earth/models/base.js.map +1 -1
  39. package/es/earth/models/bloomsphere.d.ts +2 -2
  40. package/es/earth/models/bloomsphere.js +11 -6
  41. package/es/earth/models/bloomsphere.js.map +1 -1
  42. package/es/heatmap/index.js +17 -5
  43. package/es/heatmap/index.js.map +1 -1
  44. package/es/heatmap/models/grid.d.ts +2 -2
  45. package/es/heatmap/models/grid.js +12 -8
  46. package/es/heatmap/models/grid.js.map +1 -1
  47. package/es/heatmap/models/grid3d.d.ts +2 -2
  48. package/es/heatmap/models/grid3d.js +12 -6
  49. package/es/heatmap/models/grid3d.js.map +1 -1
  50. package/es/heatmap/models/heatmap.d.ts +2 -2
  51. package/es/heatmap/models/heatmap.js +112 -62
  52. package/es/heatmap/models/heatmap.js.map +1 -1
  53. package/es/heatmap/models/hexagon.d.ts +2 -2
  54. package/es/heatmap/models/hexagon.js +11 -6
  55. package/es/heatmap/models/hexagon.js.map +1 -1
  56. package/es/image/index.js +12 -2
  57. package/es/image/index.js.map +1 -1
  58. package/es/image/models/dataImage.d.ts +3 -3
  59. package/es/image/models/dataImage.js +10 -5
  60. package/es/image/models/dataImage.js.map +1 -1
  61. package/es/image/models/image.d.ts +3 -3
  62. package/es/image/models/image.js +11 -7
  63. package/es/image/models/image.js.map +1 -1
  64. package/es/line/index.d.ts +0 -2
  65. package/es/line/index.js +12 -5
  66. package/es/line/index.js.map +1 -1
  67. package/es/line/models/arc.d.ts +2 -2
  68. package/es/line/models/arc.js +14 -9
  69. package/es/line/models/arc.js.map +1 -1
  70. package/es/line/models/arc_3d.d.ts +2 -2
  71. package/es/line/models/arc_3d.js +13 -8
  72. package/es/line/models/arc_3d.js.map +1 -1
  73. package/es/line/models/earthArc_3d.d.ts +2 -2
  74. package/es/line/models/earthArc_3d.js +17 -9
  75. package/es/line/models/earthArc_3d.js.map +1 -1
  76. package/es/line/models/great_circle.d.ts +2 -2
  77. package/es/line/models/great_circle.js +11 -6
  78. package/es/line/models/great_circle.js.map +1 -1
  79. package/es/line/models/half.d.ts +2 -2
  80. package/es/line/models/half.js +46 -29
  81. package/es/line/models/half.js.map +1 -1
  82. package/es/line/models/index.d.ts +1 -1
  83. package/es/line/models/index.js +0 -2
  84. package/es/line/models/index.js.map +1 -1
  85. package/es/line/models/line.d.ts +2 -2
  86. package/es/line/models/line.js +37 -18
  87. package/es/line/models/line.js.map +1 -1
  88. package/es/line/models/linearline.d.ts +2 -11
  89. package/es/line/models/linearline.js +21 -27
  90. package/es/line/models/linearline.js.map +1 -1
  91. package/es/line/models/simpleLine.d.ts +2 -2
  92. package/es/line/models/simpleLine.js +13 -8
  93. package/es/line/models/simpleLine.js.map +1 -1
  94. package/es/line/models/tile.d.ts +2 -11
  95. package/es/line/models/tile.js +45 -39
  96. package/es/line/models/tile.js.map +1 -1
  97. package/es/line/models/wall.d.ts +2 -2
  98. package/es/line/models/wall.js +13 -9
  99. package/es/line/models/wall.js.map +1 -1
  100. package/es/mask/index.js +12 -2
  101. package/es/mask/index.js.map +1 -1
  102. package/es/mask/models/fill.d.ts +2 -2
  103. package/es/mask/models/fill.js +53 -27
  104. package/es/mask/models/fill.js.map +1 -1
  105. package/es/plugins/DataMappingPlugin.js +29 -8
  106. package/es/plugins/DataMappingPlugin.js.map +1 -1
  107. package/es/plugins/DataSourcePlugin.js +14 -5
  108. package/es/plugins/DataSourcePlugin.js.map +1 -1
  109. package/es/plugins/LayerModelPlugin.d.ts +2 -0
  110. package/es/plugins/LayerModelPlugin.js +35 -7
  111. package/es/plugins/LayerModelPlugin.js.map +1 -1
  112. package/es/plugins/PixelPickingPlugin.js +16 -13
  113. package/es/plugins/PixelPickingPlugin.js.map +1 -1
  114. package/es/point/index.d.ts +1 -1
  115. package/es/point/index.js +26 -15
  116. package/es/point/index.js.map +1 -1
  117. package/es/point/models/earthExtrude.d.ts +2 -2
  118. package/es/point/models/earthExtrude.js +16 -14
  119. package/es/point/models/earthExtrude.js.map +1 -1
  120. package/es/point/models/earthFill.d.ts +2 -11
  121. package/es/point/models/earthFill.js +13 -22
  122. package/es/point/models/earthFill.js.map +1 -1
  123. package/es/point/models/extrude.d.ts +2 -2
  124. package/es/point/models/extrude.js +49 -27
  125. package/es/point/models/extrude.js.map +1 -1
  126. package/es/point/models/fill.d.ts +2 -2
  127. package/es/point/models/fill.js +59 -41
  128. package/es/point/models/fill.js.map +1 -1
  129. package/es/point/models/fillmage.d.ts +2 -7
  130. package/es/point/models/fillmage.js +13 -22
  131. package/es/point/models/fillmage.js.map +1 -1
  132. package/es/point/models/image.d.ts +2 -2
  133. package/es/point/models/image.js +11 -6
  134. package/es/point/models/image.js.map +1 -1
  135. package/es/point/models/index.d.ts +1 -1
  136. package/es/point/models/index.js +0 -2
  137. package/es/point/models/index.js.map +1 -1
  138. package/es/point/models/normal.d.ts +2 -2
  139. package/es/point/models/normal.js +11 -6
  140. package/es/point/models/normal.js.map +1 -1
  141. package/es/point/models/radar.d.ts +2 -11
  142. package/es/point/models/radar.js +13 -22
  143. package/es/point/models/radar.js.map +1 -1
  144. package/es/point/models/simplePoint.d.ts +2 -2
  145. package/es/point/models/simplePoint.js +11 -6
  146. package/es/point/models/simplePoint.js.map +1 -1
  147. package/es/point/models/text.d.ts +3 -2
  148. package/es/point/models/text.js +110 -75
  149. package/es/point/models/text.js.map +1 -1
  150. package/es/point/models/tile.d.ts +2 -11
  151. package/es/point/models/tile.js +22 -25
  152. package/es/point/models/tile.js.map +1 -1
  153. package/es/polygon/index.js +12 -2
  154. package/es/polygon/index.js.map +1 -1
  155. package/es/polygon/models/extrude.d.ts +2 -2
  156. package/es/polygon/models/extrude.js +10 -5
  157. package/es/polygon/models/extrude.js.map +1 -1
  158. package/es/polygon/models/fill.d.ts +2 -2
  159. package/es/polygon/models/fill.js +27 -13
  160. package/es/polygon/models/fill.js.map +1 -1
  161. package/es/polygon/models/ocean.d.ts +2 -2
  162. package/es/polygon/models/ocean.js +12 -6
  163. package/es/polygon/models/ocean.js.map +1 -1
  164. package/es/polygon/models/tile.d.ts +2 -3
  165. package/es/polygon/models/tile.js +17 -27
  166. package/es/polygon/models/tile.js.map +1 -1
  167. package/es/polygon/models/water.d.ts +2 -2
  168. package/es/polygon/models/water.js +12 -6
  169. package/es/polygon/models/water.js.map +1 -1
  170. package/es/raster/index.js +12 -2
  171. package/es/raster/index.js.map +1 -1
  172. package/es/raster/models/raster.d.ts +3 -3
  173. package/es/raster/models/raster.js +11 -7
  174. package/es/raster/models/raster.js.map +1 -1
  175. package/es/tile/manager/tileLayerManager.js +3 -0
  176. package/es/tile/manager/tileLayerManager.js.map +1 -1
  177. package/es/tile/manager/tilePickerManager.js +1 -0
  178. package/es/tile/manager/tilePickerManager.js.map +1 -1
  179. package/es/tile/tileFactory/base.js.map +1 -1
  180. package/es/tile/tileFactory/point.js.map +1 -1
  181. package/es/tile/tileFactory/rasterDataLayer.js +12 -2
  182. package/es/tile/tileFactory/rasterDataLayer.js.map +1 -1
  183. package/es/tile/tileFactory/vectorLayer.js +12 -2
  184. package/es/tile/tileFactory/vectorLayer.js.map +1 -1
  185. package/es/utils/extrude_polyline.d.ts +15 -0
  186. package/es/utils/extrude_polyline.js +146 -14
  187. package/es/utils/extrude_polyline.js.map +1 -1
  188. package/es/wind/index.js +12 -2
  189. package/es/wind/index.js.map +1 -1
  190. package/es/wind/models/wind.d.ts +4 -2
  191. package/es/wind/models/wind.js +50 -18
  192. package/es/wind/models/wind.js.map +1 -1
  193. package/es/wind/models/windRender.js +1 -1
  194. package/es/wind/models/windRender.js.map +1 -1
  195. package/lib/Geometry/index.js +12 -2
  196. package/lib/Geometry/index.js.map +1 -1
  197. package/lib/Geometry/models/billboard.js +11 -6
  198. package/lib/Geometry/models/billboard.js.map +1 -1
  199. package/lib/Geometry/models/plane.js +12 -7
  200. package/lib/Geometry/models/plane.js.map +1 -1
  201. package/lib/Geometry/models/sprite.js +11 -6
  202. package/lib/Geometry/models/sprite.js.map +1 -1
  203. package/lib/canvas/index.js +12 -2
  204. package/lib/canvas/index.js.map +1 -1
  205. package/lib/citybuliding/building.js +12 -2
  206. package/lib/citybuliding/building.js.map +1 -1
  207. package/lib/citybuliding/models/build.js +16 -3
  208. package/lib/citybuliding/models/build.js.map +1 -1
  209. package/lib/core/BaseLayer.js +104 -61
  210. package/lib/core/BaseLayer.js.map +1 -1
  211. package/lib/core/BaseModel.js +2 -2
  212. package/lib/core/BaseModel.js.map +1 -1
  213. package/lib/core/interface.js +17 -1
  214. package/lib/core/interface.js.map +1 -1
  215. package/lib/core/triangulation.js +40 -16
  216. package/lib/core/triangulation.js.map +1 -1
  217. package/lib/earth/index.js +8 -2
  218. package/lib/earth/index.js.map +1 -1
  219. package/lib/earth/models/atmosphere.js +11 -6
  220. package/lib/earth/models/atmosphere.js.map +1 -1
  221. package/lib/earth/models/base.js +11 -6
  222. package/lib/earth/models/base.js.map +1 -1
  223. package/lib/earth/models/bloomsphere.js +11 -6
  224. package/lib/earth/models/bloomsphere.js.map +1 -1
  225. package/lib/heatmap/index.js +17 -5
  226. package/lib/heatmap/index.js.map +1 -1
  227. package/lib/heatmap/models/grid.js +12 -8
  228. package/lib/heatmap/models/grid.js.map +1 -1
  229. package/lib/heatmap/models/grid3d.js +12 -6
  230. package/lib/heatmap/models/grid3d.js.map +1 -1
  231. package/lib/heatmap/models/heatmap.js +113 -62
  232. package/lib/heatmap/models/heatmap.js.map +1 -1
  233. package/lib/heatmap/models/hexagon.js +11 -6
  234. package/lib/heatmap/models/hexagon.js.map +1 -1
  235. package/lib/image/index.js +12 -2
  236. package/lib/image/index.js.map +1 -1
  237. package/lib/image/models/dataImage.js +10 -5
  238. package/lib/image/models/dataImage.js.map +1 -1
  239. package/lib/image/models/image.js +11 -7
  240. package/lib/image/models/image.js.map +1 -1
  241. package/lib/line/index.js +12 -5
  242. package/lib/line/index.js.map +1 -1
  243. package/lib/line/models/arc.js +14 -9
  244. package/lib/line/models/arc.js.map +1 -1
  245. package/lib/line/models/arc_3d.js +13 -8
  246. package/lib/line/models/arc_3d.js.map +1 -1
  247. package/lib/line/models/earthArc_3d.js +17 -9
  248. package/lib/line/models/earthArc_3d.js.map +1 -1
  249. package/lib/line/models/great_circle.js +11 -6
  250. package/lib/line/models/great_circle.js.map +1 -1
  251. package/lib/line/models/half.js +48 -29
  252. package/lib/line/models/half.js.map +1 -1
  253. package/lib/line/models/index.js +0 -3
  254. package/lib/line/models/index.js.map +1 -1
  255. package/lib/line/models/line.js +38 -19
  256. package/lib/line/models/line.js.map +1 -1
  257. package/lib/line/models/linearline.js +22 -27
  258. package/lib/line/models/linearline.js.map +1 -1
  259. package/lib/line/models/simpleLine.js +13 -8
  260. package/lib/line/models/simpleLine.js.map +1 -1
  261. package/lib/line/models/tile.js +47 -39
  262. package/lib/line/models/tile.js.map +1 -1
  263. package/lib/line/models/wall.js +13 -9
  264. package/lib/line/models/wall.js.map +1 -1
  265. package/lib/mask/index.js +12 -2
  266. package/lib/mask/index.js.map +1 -1
  267. package/lib/mask/models/fill.js +55 -27
  268. package/lib/mask/models/fill.js.map +1 -1
  269. package/lib/plugins/DataMappingPlugin.js +29 -8
  270. package/lib/plugins/DataMappingPlugin.js.map +1 -1
  271. package/lib/plugins/DataSourcePlugin.js +13 -4
  272. package/lib/plugins/DataSourcePlugin.js.map +1 -1
  273. package/lib/plugins/LayerModelPlugin.js +35 -7
  274. package/lib/plugins/LayerModelPlugin.js.map +1 -1
  275. package/lib/plugins/PixelPickingPlugin.js +16 -13
  276. package/lib/plugins/PixelPickingPlugin.js.map +1 -1
  277. package/lib/point/index.js +26 -15
  278. package/lib/point/index.js.map +1 -1
  279. package/lib/point/models/earthExtrude.js +16 -15
  280. package/lib/point/models/earthExtrude.js.map +1 -1
  281. package/lib/point/models/earthFill.js +13 -22
  282. package/lib/point/models/earthFill.js.map +1 -1
  283. package/lib/point/models/extrude.js +51 -28
  284. package/lib/point/models/extrude.js.map +1 -1
  285. package/lib/point/models/fill.js +61 -42
  286. package/lib/point/models/fill.js.map +1 -1
  287. package/lib/point/models/fillmage.js +13 -22
  288. package/lib/point/models/fillmage.js.map +1 -1
  289. package/lib/point/models/image.js +11 -6
  290. package/lib/point/models/image.js.map +1 -1
  291. package/lib/point/models/index.js +0 -3
  292. package/lib/point/models/index.js.map +1 -1
  293. package/lib/point/models/normal.js +11 -6
  294. package/lib/point/models/normal.js.map +1 -1
  295. package/lib/point/models/radar.js +13 -22
  296. package/lib/point/models/radar.js.map +1 -1
  297. package/lib/point/models/simplePoint.js +11 -6
  298. package/lib/point/models/simplePoint.js.map +1 -1
  299. package/lib/point/models/text.js +112 -78
  300. package/lib/point/models/text.js.map +1 -1
  301. package/lib/point/models/tile.js +22 -25
  302. package/lib/point/models/tile.js.map +1 -1
  303. package/lib/polygon/index.js +12 -2
  304. package/lib/polygon/index.js.map +1 -1
  305. package/lib/polygon/models/extrude.js +10 -5
  306. package/lib/polygon/models/extrude.js.map +1 -1
  307. package/lib/polygon/models/fill.js +25 -11
  308. package/lib/polygon/models/fill.js.map +1 -1
  309. package/lib/polygon/models/ocean.js +12 -6
  310. package/lib/polygon/models/ocean.js.map +1 -1
  311. package/lib/polygon/models/tile.js +17 -27
  312. package/lib/polygon/models/tile.js.map +1 -1
  313. package/lib/polygon/models/water.js +12 -6
  314. package/lib/polygon/models/water.js.map +1 -1
  315. package/lib/raster/index.js +12 -2
  316. package/lib/raster/index.js.map +1 -1
  317. package/lib/raster/models/raster.js +11 -7
  318. package/lib/raster/models/raster.js.map +1 -1
  319. package/lib/tile/manager/tileLayerManager.js +3 -0
  320. package/lib/tile/manager/tileLayerManager.js.map +1 -1
  321. package/lib/tile/manager/tilePickerManager.js +1 -0
  322. package/lib/tile/manager/tilePickerManager.js.map +1 -1
  323. package/lib/tile/tileFactory/base.js.map +1 -1
  324. package/lib/tile/tileFactory/point.js.map +1 -1
  325. package/lib/tile/tileFactory/rasterDataLayer.js +12 -2
  326. package/lib/tile/tileFactory/rasterDataLayer.js.map +1 -1
  327. package/lib/tile/tileFactory/vectorLayer.js +12 -2
  328. package/lib/tile/tileFactory/vectorLayer.js.map +1 -1
  329. package/lib/utils/extrude_polyline.js +148 -14
  330. package/lib/utils/extrude_polyline.js.map +1 -1
  331. package/lib/wind/index.js +12 -2
  332. package/lib/wind/index.js.map +1 -1
  333. package/lib/wind/models/wind.js +49 -18
  334. package/lib/wind/models/wind.js.map +1 -1
  335. package/lib/wind/models/windRender.js +1 -1
  336. package/lib/wind/models/windRender.js.map +1 -1
  337. package/package.json +9 -8
  338. package/es/line/models/arcmini.d.ts +0 -9
  339. package/es/line/models/arcmini.js +0 -145
  340. package/es/line/models/arcmini.js.map +0 -1
  341. package/es/point/models/icon-font.d.ts +0 -11
  342. package/es/point/models/icon-font.js +0 -181
  343. package/es/point/models/icon-font.js.map +0 -1
  344. package/es/raster/image.d.ts +0 -0
  345. package/es/raster/image.js +0 -2
  346. package/es/raster/image.js.map +0 -1
  347. package/es/raster/raster2d.d.ts +0 -27
  348. package/es/raster/raster2d.js +0 -158
  349. package/es/raster/raster2d.js.map +0 -1
  350. package/es/utils/geo.d.ts +0 -12
  351. package/es/utils/geo.js +0 -53
  352. package/es/utils/geo.js.map +0 -1
  353. package/lib/line/models/arcmini.js +0 -161
  354. package/lib/line/models/arcmini.js.map +0 -1
  355. package/lib/point/models/icon-font.js +0 -196
  356. package/lib/point/models/icon-font.js.map +0 -1
  357. package/lib/raster/image.js +0 -2
  358. package/lib/raster/image.js.map +0 -1
  359. package/lib/raster/raster2d.js +0 -172
  360. package/lib/raster/raster2d.js.map +0 -1
  361. package/lib/utils/geo.js +0 -65
  362. package/lib/utils/geo.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/line/models/tile.ts"],"names":["AttributeType","gl","getMask","rgb2arr","BaseModel","LineTriangulation","LineModel","createTexture2D","rendererService","texture","update","data","iconService","getCanvas","layer","render","mag","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","buildLayerModel","moduleName","vertexShader","fragmentShader","primitive","TRIANGLES","blend","getBlend","stencil","line_tile_frag","line_tile_vert","styleAttributeService","registerStyleAttribute","name","Attribute","descriptor","buffer","usage","STATIC_DRAW","size","feature","featureIdx","vertex","attributeIdx","normal","vertexIndex","DYNAMIC_DRAW","Array","isArray","iconMap","getIconMap","x","y"],"mappings":";;;;;;;;;;;;AAAA,SACEA,aADF,EAEEC,EAFF,QAQO,eARP;AAUA,SAASC,OAAT,EAAkBC,OAAlB,QAAiC,gBAAjC;AACA,OAAOC,SAAP,MAAsB,sBAAtB;AAEA,SAASC,iBAAT,QAAkC,0BAAlC;;;;IAKqBC,S;;;;;;;;;;;;;;;;;;oEA4RK,YAAM;AAC5B,UAAQC,eAAR,GAA4B,MAAKC,eAAjC,CAAQD,eAAR;;AACA,UAAI,MAAKE,OAAT,EAAkB;AAChB,cAAKA,OAAL,CAAaC,MAAb,CAAoB;AAClBC,UAAAA,IAAI,EAAE,MAAKC,WAAL,CAAiBC,SAAjB;AADY,SAApB;;AAGA,cAAKC,KAAL,CAAWC,MAAX;;AACA;AACD;;AACD,YAAKN,OAAL,GAAeF,eAAe,CAAC;AAC7BI,QAAAA,IAAI,EAAE,MAAKC,WAAL,CAAiBC,SAAjB,EADuB;AAE7BG,QAAAA,GAAG,EAAEf,EAAE,CAACgB,OAFqB;AAG7BC,QAAAA,GAAG,EAAEjB,EAAE,CAACgB,OAHqB;AAI7BE,Q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AI,EAAEtD,EAAE,CAACuD;AAJH,WAFE;AAQVqD,UAAAA,IAAI,EAAE,CARI;AASVnG,UAAAA,MAAM,EAAE,gBACNoG,OADM,EAENC,UAFM,EAGNC,MAHM,EAINC,YAJM,EAKH;AACH,mBAAO,CAACD,MAAM,CAAC,CAAD,CAAP,CAAP;AACD;AAhBS;AAHoC,OAAlD;AAuBA,WAAKX,qBAAL,CAA2BC,sBAA3B,CAAkD;AAChDC,QAAAA,IAAI,EAAE,IAD0C;AAEhDhD,QAAAA,IAAI,EAAEvD,aAAa,CAACwG,SAF4B;AAGhDC,QAAAA,UAAU,EAAE;AACVF,UAAAA,IAAI,EAAE,aADI;AAEVG,UAAAA,MAAM,EAAE;AAENC,YAAAA,KAAK,EAAE1G,EAAE,CAACmH,YAFJ;AAGNzG,YAAAA,IAAI,EAAE,EAHA;AAIN4C,YAAAA,IAAI,EAAEtD,EAAE,CAACuD;AAJH,WAFE;AAQVqD,UAAAA,IAAI,EAAE,CARI;AASVnG,UAAAA,MAAM,EAAE,gBACNoG,OADM,EAENC,UAFM,EAGNC,MAHM,EAINC,YAJM,EAKH;AACH,gBAAMM,OAAO,GAAG,MAAI,CAAC3G,WAAL,CAAiB4G,UAAjB,EAAhB;;AACA,gBAAQ/G,OAAR,GAAoBqG,OAApB,CAAQrG,OAAR;;AACA,wBAAiB8G,OAAO,CAAC9G,OAAD,CAAP,IAA8B;AAAEgH,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;;;;EA1RoCtH,S;;SAAlBE,S","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"}
1
+ {"version":3,"sources":["../../../src/line/models/tile.ts"],"names":["AttributeType","gl","getMask","rgb2arr","BaseModel","LineTriangulation","LineModel","createTexture2D","rendererService","texture","update","data","iconService","getCanvas","layer","render","mag","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","callbackModel","updateTexture","on","buildModels","destroy","off","mask","maskInside","depth","triangulation","buildLayerModel","moduleName","vertexShader","line_tile_vert","fragmentShader","line_tile_frag","blend","getBlend","stencil","then","model","catch","err","console","warn","styleAttributeService","registerStyleAttribute","name","Attribute","descriptor","buffer","usage","STATIC_DRAW","size","feature","featureIdx","vertex","attributeIdx","normal","vertexIndex","DYNAMIC_DRAW","Array","isArray","iconMap","getIconMap","x","y"],"mappings":";;;;;;;;;;;;;;AAAA,SACEA,aADF,EAEEC,EAFF,QAQO,eARP;AAUA,SAASC,OAAT,EAAkBC,OAAlB,QAAiC,gBAAjC;AACA,OAAOC,SAAP,MAAsB,sBAAtB;AAEA,SAASC,iBAAT,QAAkC,0BAAlC;;;;IAKqBC,S;;;;;;;;;;;;;;;;;;oEAsRK,YAAM;AAC5B,UAAQC,eAAR,GAA4B,MAAKC,eAAjC,CAAQD,eAAR;;AACA,UAAI,MAAKE,OAAT,EAAkB;AAChB,cAAKA,OAAL,CAAaC,MAAb,CAAoB;AAClBC,UAAAA,IAAI,EAAE,MAAKC,WAAL,CAAiBC,SAAjB;AADY,SAApB;;AAGA,cAAKC,KAAL,CAAWC,MAAX;;AACA;AACD;;AACD,YAAKN,OAAL,GAAeF,eAAe,CAAC;AAC7BI,QAAAA,IAAI,EAAE,MAAKC,WAAL,CAAiBC,SAAjB,EADuB;AAE7BG,QAAAA,GAAG,EAAEf,EAAE,CAACgB,OAFqB;AAG7BC,QAAAA,GAAG,EAAEjB,EAAE,CAACgB,OAHqB;AAI7BE,QAAAA,gBAAgB,EAAE,KAJW;AAK7BC,QAAAA,KAAK,EAAE,IALsB;AAM7BC,QAAAA,MAAM,EAAE,MAAKT,WAAL,CAAiBU,YAAjB,IAAiC;AANZ,OAAD,CAA9B;AAQD,K;;;;;;;WArSD,wBAAqC;AACnC,iBAiBI,KAAKR,KAAL,CAAWS,cAAX,EAjBJ;AAAA,8BACEC,OADF;AAAA,UACEA,OADF,6BACY,CADZ;AAAA,mCAEEC,YAFF;AAAA,UAEEA,YAFF,kCAEiB,QAFjB;AAAA,kCAGEC,WAHF;AAAA,UAGEA,WAHF,iCAGgB,KAHhB;AAAA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,EAAE,aADI;AAEVG,UAAAA,MAAM,EAAE;AAENC,YAAAA,KAAK,EAAE5G,EAAE,CAACqH,YAFJ;AAGN3G,YAAAA,IAAI,EAAE,EAHA;AAIN4C,YAAAA,IAAI,EAAEtD,EAAE,CAACuD;AAJH,WAFE;AAQVuD,UAAAA,IAAI,EAAE,CARI;AASVrG,UAAAA,MAAM,EAAE,gBACNsG,OADM,EAENC,UAFM,EAGNC,MAHM,EAINC,YAJM,EAKH;AACH,gBAAMM,OAAO,GAAG,MAAI,CAAC7G,WAAL,CAAiB8G,UAAjB,EAAhB;;AACA,gBAAQjH,OAAR,GAAoBuG,OAApB,CAAQvG,OAAR;;AACA,wBAAiBgH,OAAO,CAAChH,OAAD,CAAP,IAA8B;AAAEkH,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;;;;EApRoCxH,S;;SAAlBE,S","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(callbackModel: (models: IModel[]) => void) {\n this.updateTexture();\n this.iconService.on('imageUpdate', this.updateTexture);\n\n this.buildModels(callbackModel);\n }\n\n public clearModels() {\n this.texture?.destroy();\n this.dataTexture?.destroy();\n this.iconService.off('imageUpdate', this.updateTexture);\n }\n\n public async buildModels(callbackModel: (models: IModel[]) => void) {\n const {\n mask = false,\n maskInside = true,\n depth = false,\n } = this.layer.getLayerConfig() as ILineLayerStyleOptions;\n\n this.layer.triangulation = LineTriangulation;\n\n this.layer\n .buildLayerModel({\n moduleName: 'lineTile',\n vertexShader: line_tile_vert,\n fragmentShader: line_tile_frag,\n triangulation: LineTriangulation,\n blend: this.getBlend(),\n depth: { enable: depth },\n // depth: { enable: true },\n stencil: getMask(mask, maskInside),\n })\n .then((model) => {\n callbackModel([model]);\n })\n .catch((err) => {\n console.warn(err);\n callbackModel([]);\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"}
@@ -4,9 +4,9 @@ export default class LineWallModel extends BaseModel {
4
4
  protected texture: ITexture2D;
5
5
  getUninforms(): IModelUniform;
6
6
  getAnimateUniforms(): IModelUniform;
7
- initModels(): IModel[];
7
+ initModels(callbackModel: (models: IModel[]) => void): void;
8
8
  clearModels(): void;
9
- buildModels(): IModel[];
9
+ buildModels(callbackModel: (models: IModel[]) => void): void;
10
10
  protected registerBuiltinAttributes(): void;
11
11
  private updateTexture;
12
12
  }
@@ -155,10 +155,10 @@ var LineWallModel = function (_BaseModel) {
155
155
  }
156
156
  }, {
157
157
  key: "initModels",
158
- value: function initModels() {
158
+ value: function initModels(callbackModel) {
159
159
  this.updateTexture();
160
160
  this.iconService.on('imageUpdate', this.updateTexture);
161
- return this.buildModels();
161
+ this.buildModels(callbackModel);
162
162
  }
163
163
  }, {
164
164
  key: "clearModels",
@@ -171,18 +171,22 @@ var LineWallModel = function (_BaseModel) {
171
171
  }
172
172
  }, {
173
173
  key: "buildModels",
174
- value: function buildModels() {
175
- return [this.layer.buildLayerModel({
176
- moduleName: 'linewall',
174
+ value: function buildModels(callbackModel) {
175
+ this.layer.buildLayerModel({
176
+ moduleName: 'lineWall',
177
177
  vertexShader: line_vert,
178
178
  fragmentShader: line_frag,
179
179
  triangulation: LineTriangulation,
180
- primitive: gl.TRIANGLES,
181
- blend: this.getBlend(),
182
180
  depth: {
183
181
  enable: false
184
- }
185
- })];
182
+ },
183
+ blend: this.getBlend()
184
+ }).then(function (model) {
185
+ callbackModel([model]);
186
+ }).catch(function (err) {
187
+ console.warn(err);
188
+ callbackModel([]);
189
+ });
186
190
  }
187
191
  }, {
188
192
  key: "registerBuiltinAttributes",
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/line/models/wall.ts"],"names":["AttributeType","gl","rgb2arr","BaseModel","LineTriangulation","LineWallModel","createTexture2D","rendererService","texture","update","data","iconService","getCanvas","layer","render","mag","NEAREST","min","premultiplyAlpha","width","height","canvasHeight","getLayerConfig","opacity","sourceColor","targetColor","textureBlend","heightfixed","lineTexture","iconStep","iconStepCount","getDirty","bind","useLinearColor","sourceColorArr","targetColorArr","dataTextureTest","dataTextureNeedUpdate","judgeStyleAttributes","encodeData","getEncodedData","calDataFrame","cellLength","cellProperties","rowCount","dataTexture","length","flipY","format","LUMINANCE","type","FLOAT","u_heightfixed","Number","u_dataTexture","u_cellTypeLayout","getCellTypeLayout","u_opacity","u_textureBlend","u_texture","u_line_texture","u_iconStepCount","u_icon_step","u_textSize","u_linearColor","u_sourceColor","u_targetColor","animateOption","u_aimate","animateOption2Array","u_time","getLayerAnimateTime","updateTexture","on","buildModels","destroy","off","buildLayerModel","moduleName","vertexShader","line_vert","fragmentShader","line_frag","triangulation","primitive","TRIANGLES","blend","getBlend","depth","enable","styleAttributeService","registerStyleAttribute","name","Attribute","descriptor","buffer","usage","STATIC_DRAW","size","feature","featureIdx","vertex","attributeIdx","DYNAMIC_DRAW","Array","isArray","normal","iconMap","getIconMap","x","y"],"mappings":";;;;;;;;;;;;;AAAA,SACEA,aADF,EAEEC,EAFF,QASO,eATP;AAUA,SAASC,OAAT,QAAwB,gBAAxB;AAEA,OAAOC,SAAP,MAAsB,sBAAtB;AAEA,SAASC,iBAAT,QAAkC,0BAAlC;;;;IAIqBC,a;;;;;;;;;;;;;;;;;;oEAkQK,YAAM;AAC5B,UAAQC,eAAR,GAA4B,MAAKC,eAAjC,CAAQD,eAAR;;AACA,UAAI,MAAKE,OAAT,EAAkB;AAChB,cAAKA,OAAL,CAAaC,MAAb,CAAoB;AAClBC,UAAAA,IAAI,EAAE,MAAKC,WAAL,CAAiBC,SAAjB;AADY,SAApB;;AAGA,cAAKC,KAAL,CAAWC,MAAX;;AACA;AACD;;AACD,YAAKN,OAAL,GAAeF,eAAe,CAAC;AAC7BI,QAAAA,IAAI,EAAE,MAAKC,WAAL,CAAiBC,SAAjB,EADuB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UAAjB,EAAhB;;AACA,gBAAQpG,OAAR,GAAoB2F,OAApB,CAAQ3F,OAAR;;AACA,wBAAiBmG,OAAO,CAACnG,OAAD,CAAP,IAA8B;AAAEqG,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;;;;EAjQwC3G,S;;SAAtBE,a","sourcesContent":["import {\n AttributeType,\n gl,\n IAnimateOption,\n IEncodeFeature,\n ILayerConfig,\n IModel,\n IModelUniform,\n ITexture2D,\n} from '@antv/l7-core';\nimport { rgb2arr } from '@antv/l7-utils';\nimport { isNumber } from 'lodash';\nimport BaseModel from '../../core/BaseModel';\nimport { ILineLayerStyleOptions } from '../../core/interface';\nimport { LineTriangulation } from '../../core/triangulation';\nimport line_frag from '../shaders/wall_frag.glsl';\nimport line_vert from '../shaders/wall_vert.glsl';\n\nexport default class LineWallModel extends BaseModel {\n protected texture: ITexture2D;\n public getUninforms(): IModelUniform {\n const {\n opacity = 1,\n sourceColor,\n targetColor,\n textureBlend = 'normal',\n heightfixed = false,\n lineTexture = false,\n iconStep = 100,\n iconStepCount = 1,\n } = this.layer.getLayerConfig() as ILineLayerStyleOptions;\n\n if (this.rendererService.getDirty()) {\n this.texture.bind();\n }\n\n // 转化渐变色\n let useLinearColor = 0; // 默认不生效\n let sourceColorArr = [0, 0, 0, 0];\n let targetColorArr = [0, 0, 0, 0];\n if (sourceColor && targetColor) {\n sourceColorArr = rgb2arr(sourceColor);\n targetColorArr = rgb2arr(targetColor);\n useLinearColor = 1;\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\n return {\n u_heightfixed: Number(heightfixed),\n u_dataTexture: this.dataTexture, // 数据纹理 - 有数据映射的时候纹理中带数据,若没有任何数据映射时纹理是 [1]\n u_cellTypeLayout: this.getCellTypeLayout(),\n\n u_opacity: isNumber(opacity) ? opacity : 1.0,\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_iconStepCount: iconStepCount,\n u_icon_step: iconStep,\n u_textSize: [1024, this.iconService.canvasHeight || 128],\n\n // 渐变色支持参数\n u_linearColor: useLinearColor,\n u_sourceColor: sourceColorArr,\n u_targetColor: targetColorArr,\n };\n }\n public getAnimateUniforms(): IModelUniform {\n const { animateOption } = this.layer.getLayerConfig() as ILayerConfig;\n return {\n u_aimate: this.animateOption2Array(animateOption as IAnimateOption),\n u_time: this.layer.getLayerAnimateTime(),\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 return [\n this.layer.buildLayerModel({\n moduleName: 'linewall',\n vertexShader: line_vert,\n fragmentShader: line_frag,\n triangulation: LineTriangulation,\n primitive: gl.TRIANGLES,\n blend: this.getBlend(),\n depth: { enable: false },\n }),\n ];\n }\n protected registerBuiltinAttributes() {\n this.styleAttributeService.registerStyleAttribute({\n name: 'distance',\n type: AttributeType.Attribute,\n descriptor: {\n name: 'a_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[3]];\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 // @ts-ignore\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 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":"wall.js"}
1
+ {"version":3,"sources":["../../../src/line/models/wall.ts"],"names":["AttributeType","gl","rgb2arr","BaseModel","LineTriangulation","LineWallModel","createTexture2D","rendererService","texture","update","data","iconService","getCanvas","layer","render","mag","NEAREST","min","premultiplyAlpha","width","height","canvasHeight","getLayerConfig","opacity","sourceColor","targetColor","textureBlend","heightfixed","lineTexture","iconStep","iconStepCount","getDirty","bind","useLinearColor","sourceColorArr","targetColorArr","dataTextureTest","dataTextureNeedUpdate","judgeStyleAttributes","encodeData","getEncodedData","calDataFrame","cellLength","cellProperties","rowCount","dataTexture","length","flipY","format","LUMINANCE","type","FLOAT","u_heightfixed","Number","u_dataTexture","u_cellTypeLayout","getCellTypeLayout","u_opacity","u_textureBlend","u_texture","u_line_texture","u_iconStepCount","u_icon_step","u_textSize","u_linearColor","u_sourceColor","u_targetColor","animateOption","u_aimate","animateOption2Array","u_time","getLayerAnimateTime","callbackModel","updateTexture","on","buildModels","destroy","off","buildLayerModel","moduleName","vertexShader","line_vert","fragmentShader","line_frag","triangulation","depth","enable","blend","getBlend","then","model","catch","err","console","warn","styleAttributeService","registerStyleAttribute","name","Attribute","descriptor","buffer","usage","STATIC_DRAW","size","feature","featureIdx","vertex","attributeIdx","DYNAMIC_DRAW","Array","isArray","normal","iconMap","getIconMap","x","y"],"mappings":";;;;;;;;;;;;;AAAA,SACEA,aADF,EAEEC,EAFF,QASO,eATP;AAUA,SAASC,OAAT,QAAwB,gBAAxB;AAEA,OAAOC,SAAP,MAAsB,sBAAtB;AAEA,SAASC,iBAAT,QAAkC,0BAAlC;;;;IAIqBC,a;;;;;;;;;;;;;;;;;;oEAuQK,YAAM;AAC5B,UAAQC,eAAR,GAA4B,MAAKC,eAAjC,CAAQD,eAAR;;AACA,UAAI,MAAKE,OAAT,EAAkB;AAChB,cAAKA,OAAL,CAAaC,MAAb,CAAoB;AAClBC,UAAAA,IAAI,EAAE,MAAKC,WAAL,CAAiBC,SAAjB;AADY,SAApB;;AAGA,cAAKC,KAAL,CAAWC,MAAX;;AACA;AACD;;AACD,YAAKN,OAAL,GAAeF,eAAe,CAAC;AAC7BI,QAAAA,IAAI,EAAE,MAAKC,WAAL,CAAiBC,SAAjB,EADuB;AAE7BG,QAAAA,GAAG,EAAEd,EAAE,CAACe,OAFqB;AAG7BC,QAAAA,GAAG,EAAEhB,EAAE,CAACe,OAHqB;AAI7BE,QAAAA,gBAAgB,EAAE,KAJW;AAK7BC,QAAAA,KAAK,EAAE,IALsB;AAM7BC,QAAAA,MAAM,EAAE,MAAKT,WAAL,CAAiBU,YAAjB,IAAiC;AANZ,OAAD,CAA9B;AAQD,K;;;;;;;WAtRD,wBAAqC;AACnC,iBASI,KAAKR,KAAL,CAAWS,cAAX,EATJ;AAAA,8BACEC,OADF;AAAA,UACEA,OADF,6BACY,CADZ;AAAA,UAEEC,WAFF,QAEEA,WAFF;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AAWC,CAAX,SAAWA,CAAX;;AACA,mBAAO,CAACD,CAAD,EAAIC,CAAJ,CAAP;AACD;AAnBS;AAHoC,OAAlD;AAyBD;;;;EAtQwChH,S;;SAAtBE,a","sourcesContent":["import {\n AttributeType,\n gl,\n IAnimateOption,\n IEncodeFeature,\n ILayerConfig,\n IModel,\n IModelUniform,\n ITexture2D,\n} from '@antv/l7-core';\nimport { rgb2arr } from '@antv/l7-utils';\nimport { isNumber } from 'lodash';\nimport BaseModel from '../../core/BaseModel';\nimport { ILineLayerStyleOptions } from '../../core/interface';\nimport { LineTriangulation } from '../../core/triangulation';\nimport line_frag from '../shaders/wall_frag.glsl';\nimport line_vert from '../shaders/wall_vert.glsl';\n\nexport default class LineWallModel extends BaseModel {\n protected texture: ITexture2D;\n public getUninforms(): IModelUniform {\n const {\n opacity = 1,\n sourceColor,\n targetColor,\n textureBlend = 'normal',\n heightfixed = false,\n lineTexture = false,\n iconStep = 100,\n iconStepCount = 1,\n } = this.layer.getLayerConfig() as ILineLayerStyleOptions;\n\n if (this.rendererService.getDirty()) {\n this.texture.bind();\n }\n\n // 转化渐变色\n let useLinearColor = 0; // 默认不生效\n let sourceColorArr = [0, 0, 0, 0];\n let targetColorArr = [0, 0, 0, 0];\n if (sourceColor && targetColor) {\n sourceColorArr = rgb2arr(sourceColor);\n targetColorArr = rgb2arr(targetColor);\n useLinearColor = 1;\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\n return {\n u_heightfixed: Number(heightfixed),\n u_dataTexture: this.dataTexture, // 数据纹理 - 有数据映射的时候纹理中带数据,若没有任何数据映射时纹理是 [1]\n u_cellTypeLayout: this.getCellTypeLayout(),\n\n u_opacity: isNumber(opacity) ? opacity : 1.0,\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_iconStepCount: iconStepCount,\n u_icon_step: iconStep,\n u_textSize: [1024, this.iconService.canvasHeight || 128],\n\n // 渐变色支持参数\n u_linearColor: useLinearColor,\n u_sourceColor: sourceColorArr,\n u_targetColor: targetColorArr,\n };\n }\n public getAnimateUniforms(): IModelUniform {\n const { animateOption } = this.layer.getLayerConfig() as ILayerConfig;\n return {\n u_aimate: this.animateOption2Array(animateOption as IAnimateOption),\n u_time: this.layer.getLayerAnimateTime(),\n };\n }\n\n public initModels(callbackModel: (models: IModel[]) => void) {\n this.updateTexture();\n this.iconService.on('imageUpdate', this.updateTexture);\n\n this.buildModels(callbackModel);\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(callbackModel: (models: IModel[]) => void) {\n this.layer\n .buildLayerModel({\n moduleName: 'lineWall',\n vertexShader: line_vert,\n fragmentShader: line_frag,\n triangulation: LineTriangulation,\n depth: { enable: false },\n blend: this.getBlend(),\n })\n .then((model) => {\n callbackModel([model]);\n })\n .catch((err) => {\n console.warn(err);\n callbackModel([]);\n });\n }\n protected registerBuiltinAttributes() {\n this.styleAttributeService.registerStyleAttribute({\n name: 'distance',\n type: AttributeType.Attribute,\n descriptor: {\n name: 'a_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[3]];\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 // @ts-ignore\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 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":"wall.js"}
package/es/mask/index.js CHANGED
@@ -37,14 +37,24 @@ var MaskLayer = function (_BaseLayer) {
37
37
  _createClass(MaskLayer, [{
38
38
  key: "buildModels",
39
39
  value: function buildModels() {
40
+ var _this2 = this;
41
+
40
42
  var shape = this.getModelType();
41
43
  this.layerModel = new MaskModels[shape](this);
42
- this.models = this.layerModel.initModels();
44
+ this.layerModel.initModels(function (models) {
45
+ _this2.models = models;
46
+
47
+ _this2.renderLayers();
48
+ });
43
49
  }
44
50
  }, {
45
51
  key: "rebuildModels",
46
52
  value: function rebuildModels() {
47
- this.models = this.layerModel.buildModels();
53
+ var _this3 = this;
54
+
55
+ this.layerModel.buildModels(function (models) {
56
+ return _this3.models = models;
57
+ });
48
58
  }
49
59
  }, {
50
60
  key: "getConfigSchema",
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/mask/index.ts"],"names":["BaseLayer","MaskModels","MaskLayer","shape","getModelType","layerModel","models","initModels","buildModels","properties","opacity","type","minimum","maximum"],"mappings":";;;;;;;;;;;;AAAA,OAAOA,SAAP,MAAsB,mBAAtB;AAEA,OAAOC,UAAP,MAA0C,UAA1C;;IAEqBC,S;;;;;;;;;;;;;;;;2DACG,W;;;;;;;WACtB,uBAAqB;AACnB,UAAMC,KAAK,GAAG,KAAKC,YAAL,EAAd;AACA,WAAKC,UAAL,GAAkB,IAAIJ,UAAU,CAACE,KAAD,CAAd,CAAsB,IAAtB,CAAlB;AACA,WAAKG,MAAL,GAAc,KAAKD,UAAL,CAAgBE,UAAhB,EAAd;AACD;;;WACD,yBAAuB;AACrB,WAAKD,MAAL,GAAc,KAAKD,UAAL,CAAgBG,WAAhB,EAAd;AACD;;;WACD,2BAA4B;AAC1B,aAAO;AACLC,QAAAA,UAAU,EAAE;AACVC,UAAAA,OAAO,EAAE;AACPC,YAAAA,IAAI,EAAE,QADC;AAEPC,YAAAA,OAAO,EAAE,CAFF;AAGPC,YAAAA,OAAO,EAAE;AAHF;AADC;AADP,OAAP;AASD;;;WAED,wBAAwC;AACtC,aAAO,MAAP;AACD;;;;EAxBoCb,S;;SAAlBE,S","sourcesContent":["import BaseLayer from '../core/BaseLayer';\nimport { IMaskLayerStyleOptions } from '../core/interface';\nimport MaskModels, { MaskModelType } from './models';\n\nexport default class MaskLayer extends BaseLayer<IMaskLayerStyleOptions> {\n public type: string = 'MaskLayer';\n public buildModels() {\n const shape = this.getModelType();\n this.layerModel = new MaskModels[shape](this);\n this.models = this.layerModel.initModels();\n }\n public rebuildModels() {\n this.models = this.layerModel.buildModels();\n }\n protected getConfigSchema() {\n return {\n properties: {\n opacity: {\n type: 'number',\n minimum: 0,\n maximum: 1,\n },\n },\n };\n }\n\n protected getModelType(): MaskModelType {\n return 'fill';\n }\n}\n"],"file":"index.js"}
1
+ {"version":3,"sources":["../../src/mask/index.ts"],"names":["BaseLayer","MaskModels","MaskLayer","shape","getModelType","layerModel","initModels","models","renderLayers","buildModels","properties","opacity","type","minimum","maximum"],"mappings":";;;;;;;;;;;;AAAA,OAAOA,SAAP,MAAsB,mBAAtB;AAEA,OAAOC,UAAP,MAA0C,UAA1C;;IAEqBC,S;;;;;;;;;;;;;;;;2DACG,W;;;;;;;WACtB,uBAAqB;AAAA;;AACnB,UAAMC,KAAK,GAAG,KAAKC,YAAL,EAAd;AACA,WAAKC,UAAL,GAAkB,IAAIJ,UAAU,CAACE,KAAD,CAAd,CAAsB,IAAtB,CAAlB;AACA,WAAKE,UAAL,CAAgBC,UAAhB,CAA2B,UAACC,MAAD,EAAY;AACrC,QAAA,MAAI,CAACA,MAAL,GAAcA,MAAd;;AACA,QAAA,MAAI,CAACC,YAAL;AACD,OAHD;AAID;;;WACD,yBAAuB;AAAA;;AACrB,WAAKH,UAAL,CAAgBI,WAAhB,CAA4B,UAACF,MAAD;AAAA,eAAa,MAAI,CAACA,MAAL,GAAcA,MAA3B;AAAA,OAA5B;AACD;;;WACD,2BAA4B;AAC1B,aAAO;AACLG,QAAAA,UAAU,EAAE;AACVC,UAAAA,OAAO,EAAE;AACPC,YAAAA,IAAI,EAAE,QADC;AAEPC,YAAAA,OAAO,EAAE,CAFF;AAGPC,YAAAA,OAAO,EAAE;AAHF;AADC;AADP,OAAP;AASD;;;WAED,wBAAwC;AACtC,aAAO,MAAP;AACD;;;;EA3BoCd,S;;SAAlBE,S","sourcesContent":["import BaseLayer from '../core/BaseLayer';\nimport { IMaskLayerStyleOptions } from '../core/interface';\nimport MaskModels, { MaskModelType } from './models';\n\nexport default class MaskLayer extends BaseLayer<IMaskLayerStyleOptions> {\n public type: string = 'MaskLayer';\n public buildModels() {\n const shape = this.getModelType();\n this.layerModel = new MaskModels[shape](this);\n this.layerModel.initModels((models) => {\n this.models = models;\n this.renderLayers();\n });\n }\n public rebuildModels() {\n this.layerModel.buildModels((models) => (this.models = models));\n }\n protected getConfigSchema() {\n return {\n properties: {\n opacity: {\n type: 'number',\n minimum: 0,\n maximum: 1,\n },\n },\n };\n }\n\n protected getModelType(): MaskModelType {\n return 'fill';\n }\n}\n"],"file":"index.js"}
@@ -4,8 +4,8 @@ export default class MaskModel extends BaseModel {
4
4
  getUninforms(): {
5
5
  u_opacity: number;
6
6
  };
7
- initModels(): IModel[];
8
- buildModels(): IModel[];
7
+ initModels(callbackModel: (models: IModel[]) => void): void;
8
+ buildModels(callbackModel: (models: IModel[]) => void): Promise<void>;
9
9
  clearModels(): void;
10
10
  protected registerBuiltinAttributes(): string;
11
11
  }
@@ -1,9 +1,11 @@
1
+ import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
1
2
  import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
2
3
  import _createClass from "@babel/runtime/helpers/createClass";
3
4
  import _inherits from "@babel/runtime/helpers/inherits";
4
5
  import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
5
6
  import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
6
7
  import _isNumber from "lodash/isNumber";
8
+ import _regeneratorRuntime from "@babel/runtime/regenerator";
7
9
 
8
10
  function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
9
11
 
@@ -39,37 +41,61 @@ var MaskModel = function (_BaseModel) {
39
41
  }
40
42
  }, {
41
43
  key: "initModels",
42
- value: function initModels() {
43
- return this.buildModels();
44
+ value: function initModels(callbackModel) {
45
+ this.buildModels(callbackModel);
44
46
  }
45
47
  }, {
46
48
  key: "buildModels",
47
- value: function buildModels() {
48
- return [this.layer.buildLayerModel({
49
- moduleName: 'mask',
50
- vertexShader: mask_vert,
51
- fragmentShader: mask_frag,
52
- triangulation: polygonTriangulation,
53
- blend: this.getBlend(),
54
- depth: {
55
- enable: false
56
- },
57
- stencil: {
58
- enable: true,
59
- mask: 0xff,
60
- func: {
61
- cmp: gl.ALWAYS,
62
- ref: 1,
63
- mask: 0xff
64
- },
65
- opFront: {
66
- fail: gl.REPLACE,
67
- zfail: gl.REPLACE,
68
- zpass: gl.REPLACE
49
+ value: function () {
50
+ var _buildModels = _asyncToGenerator(_regeneratorRuntime.mark(function _callee(callbackModel) {
51
+ return _regeneratorRuntime.wrap(function _callee$(_context) {
52
+ while (1) {
53
+ switch (_context.prev = _context.next) {
54
+ case 0:
55
+ this.layer.buildLayerModel({
56
+ moduleName: 'mask',
57
+ vertexShader: mask_vert,
58
+ fragmentShader: mask_frag,
59
+ triangulation: polygonTriangulation,
60
+ depth: {
61
+ enable: false
62
+ },
63
+ blend: this.getBlend(),
64
+ stencil: {
65
+ enable: true,
66
+ mask: 0xff,
67
+ func: {
68
+ cmp: gl.ALWAYS,
69
+ ref: 1,
70
+ mask: 0xff
71
+ },
72
+ opFront: {
73
+ fail: gl.REPLACE,
74
+ zfail: gl.REPLACE,
75
+ zpass: gl.REPLACE
76
+ }
77
+ }
78
+ }).then(function (model) {
79
+ callbackModel([model]);
80
+ }).catch(function (err) {
81
+ console.warn(err);
82
+ callbackModel([]);
83
+ });
84
+
85
+ case 1:
86
+ case "end":
87
+ return _context.stop();
88
+ }
69
89
  }
70
- }
71
- })];
72
- }
90
+ }, _callee, this);
91
+ }));
92
+
93
+ function buildModels(_x) {
94
+ return _buildModels.apply(this, arguments);
95
+ }
96
+
97
+ return buildModels;
98
+ }()
73
99
  }, {
74
100
  key: "clearModels",
75
101
  value: function clearModels() {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/mask/models/fill.ts"],"names":["gl","BaseModel","polygonTriangulation","MaskModel","layer","getLayerConfig","opacity","u_opacity","buildModels","buildLayerModel","moduleName","vertexShader","mask_vert","fragmentShader","mask_frag","triangulation","blend","getBlend","depth","enable","stencil","mask","func","cmp","ALWAYS","ref","opFront","fail","REPLACE","zfail","zpass","dataTexture","destroy","layerService","clear"],"mappings":";;;;;;;;;;;AAAA,SAASA,EAAT,QAA2B,eAA3B;AAEA,OAAOC,SAAP,MAAsB,sBAAtB;AAEA,SAASC,oBAAT,QAAqC,0BAArC;;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antv/l7-core';\nimport { isNumber } from 'lodash';\nimport BaseModel from '../../core/BaseModel';\nimport { IMaskLayerStyleOptions } from '../../core/interface';\nimport { polygonTriangulation } from '../../core/triangulation';\nimport mask_frag from '../shaders/mask_frag.glsl';\nimport mask_vert from '../shaders/mask_vert.glsl';\n\nexport default class MaskModel extends BaseModel {\n public getUninforms() {\n const {\n opacity = 0,\n } = this.layer.getLayerConfig() as IMaskLayerStyleOptions;\n return {\n u_opacity: isNumber(opacity) ? opacity : 0.0,\n };\n }\n\n public initModels(): IModel[] {\n return this.buildModels();\n }\n\n public buildModels(): IModel[] {\n return [\n this.layer.buildLayerModel({\n moduleName: 'mask',\n vertexShader: mask_vert,\n fragmentShader: mask_frag,\n triangulation: polygonTriangulation,\n blend: this.getBlend(),\n depth: { enable: false },\n\n stencil: {\n enable: true,\n mask: 0xff,\n func: {\n cmp: gl.ALWAYS,\n ref: 1,\n mask: 0xff,\n },\n opFront: {\n fail: gl.REPLACE,\n zfail: gl.REPLACE,\n zpass: gl.REPLACE,\n },\n },\n }),\n ];\n }\n\n public clearModels() {\n this.dataTexture?.destroy();\n this.layerService.clear();\n }\n\n protected registerBuiltinAttributes() {\n return '';\n }\n}\n"],"file":"fill.js"}
1
+ {"version":3,"sources":["../../../src/mask/models/fill.ts"],"names":["gl","BaseModel","polygonTriangulation","MaskModel","layer","getLayerConfig","opacity","u_opacity","callbackModel","buildModels","buildLayerModel","moduleName","vertexShader","mask_vert","fragmentShader","mask_frag","triangulation","depth","enable","blend","getBlend","stencil","mask","func","cmp","ALWAYS","ref","opFront","fail","REPLACE","zfail","zpass","then","model","catch","err","console","warn","dataTexture","destroy","layerService","clear"],"mappings":";;;;;;;;;;;;;AAAA,SAASA,EAAT,QAA2B,eAA3B;AAEA,OAAOC,SAAP,MAAsB,sBAAtB;AAEA,SAASC,oBAAT,QAAqC,0BAArC;;;;IAIqBC,S;;;;;;;;;;;;;WACnB,wBAAsB;AACpB,iBAEI,KAAKC,KAAL,CAAWC,c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b;AACD,iBA7BH;;AADF;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,O;;;;;;;;;;WAiCA,uBAAqB;AAAA;;AACnB,gCAAK8B,WAAL,wEAAkBC,OAAlB;AACA,WAAKC,YAAL,CAAkBC,KAAlB;AACD;;;WAED,qCAAsC;AACpC,aAAO,EAAP;AACD;;;;EAtDoCxC,S;;SAAlBE,S","sourcesContent":["import { gl, IModel } from '@antv/l7-core';\nimport { isNumber } from 'lodash';\nimport BaseModel from '../../core/BaseModel';\nimport { IMaskLayerStyleOptions } from '../../core/interface';\nimport { polygonTriangulation } from '../../core/triangulation';\nimport mask_frag from '../shaders/mask_frag.glsl';\nimport mask_vert from '../shaders/mask_vert.glsl';\n\nexport default class MaskModel extends BaseModel {\n public getUninforms() {\n const {\n opacity = 0,\n } = this.layer.getLayerConfig() as IMaskLayerStyleOptions;\n return {\n u_opacity: isNumber(opacity) ? opacity : 0.0,\n };\n }\n\n public initModels(callbackModel: (models: IModel[]) => void) {\n this.buildModels(callbackModel);\n }\n\n public async buildModels(callbackModel: (models: IModel[]) => void) {\n this.layer\n .buildLayerModel({\n moduleName: 'mask',\n vertexShader: mask_vert,\n fragmentShader: mask_frag,\n triangulation: polygonTriangulation,\n depth: { enable: false },\n blend: this.getBlend(),\n stencil: {\n enable: true,\n mask: 0xff,\n func: {\n cmp: gl.ALWAYS,\n ref: 1,\n mask: 0xff,\n },\n opFront: {\n fail: gl.REPLACE,\n zfail: gl.REPLACE,\n zpass: gl.REPLACE,\n },\n },\n })\n .then((model) => {\n callbackModel([model]);\n })\n .catch((err) => {\n console.warn(err);\n callbackModel([]);\n });\n }\n\n public clearModels() {\n this.dataTexture?.destroy();\n this.layerService.clear();\n }\n\n protected registerBuiltinAttributes() {\n return '';\n }\n}\n"],"file":"fill.js"}
@@ -35,28 +35,49 @@ var DataMappingPlugin = (_dec = injectable(), _dec2 = inject(TYPES.IGlobalConfig
35
35
 
36
36
  var styleAttributeService = _ref.styleAttributeService;
37
37
  layer.hooks.init.tap('DataMappingPlugin', function () {
38
- _this.generateMaping(layer, {
39
- styleAttributeService: styleAttributeService
40
- });
38
+ var source = layer.getSource();
39
+
40
+ if (source.inited) {
41
+ _this.generateMaping(layer, {
42
+ styleAttributeService: styleAttributeService
43
+ });
44
+ } else {
45
+ source.once('sourceUpdate', function () {
46
+ _this.generateMaping(layer, {
47
+ styleAttributeService: styleAttributeService
48
+ });
49
+ });
50
+ }
41
51
  });
42
52
  layer.hooks.beforeRenderData.tap('DataMappingPlugin', function () {
43
53
  layer.dataState.dataMappingNeedUpdate = false;
54
+ var source = layer.getSource();
44
55
 
45
- _this.generateMaping(layer, {
46
- styleAttributeService: styleAttributeService
47
- });
56
+ if (source.inited) {
57
+ _this.generateMaping(layer, {
58
+ styleAttributeService: styleAttributeService
59
+ });
60
+ } else {
61
+ source.once('sourceUpdate', function () {
62
+ _this.generateMaping(layer, {
63
+ styleAttributeService: styleAttributeService
64
+ });
65
+ });
66
+ }
48
67
 
49
68
  return true;
50
69
  });
51
70
  layer.hooks.beforeRender.tap('DataMappingPlugin', function () {
52
- if (layer.layerModelNeedUpdate) {
71
+ var source = layer.getSource();
72
+
73
+ if (layer.layerModelNeedUpdate || !source || !source.inited) {
53
74
  return;
54
75
  }
55
76
 
56
77
  var bottomColor = layer.getBottomColor();
57
78
  var attributes = styleAttributeService.getLayerStyleAttributes() || [];
58
79
  var filter = styleAttributeService.getLayerStyleAttribute('filter');
59
- var dataArray = layer.getSource().data.dataArray;
80
+ var dataArray = source.data.dataArray;
60
81
  var attributesToRemapping = attributes.filter(function (attribute) {
61
82
  return attribute.needRemapping;
62
83
  });
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/plugins/DataMappingPlugin.ts"],"names":["TYPES","Version","isColor","normalize","rgb2arr","inject","injectable","DataMappingPlugin","IGlobalConfigService","IMapService","IFontService","layer","styleAttributeService","hooks","init","tap","generateMaping","beforeRenderData","dataState","dataMappingNeedUpdate","beforeRender","layerModelNeedUpdate","bottomColor","getBottomColor","attributes","getLayerStyleAttributes","filter","getLayerStyleAttribute","dataArray","getSource","data","attributesToRemapping","attribute","needRemapping","filterData","scale","record","applyAttributeMapping","length","setEncodedData","mapping","undefined","getEncodedData","emit","p1","p2","dir","normalizeDir","arrowPoint","predata","minimumColor","getLayerConfig","arrow","enable","mappedData","map","i","preRecord","encodeRecord","id","_id","coordinates","forEach","values","name","c","Array","isArray","shape","fontService","getIconFontKey","coords","getArrowPoints","splice","adjustData2Amap2Coordinates","adjustData2SimpleCoordinates","mapService","version","layerCenter","getLayerCenter","d","originCoordinates","lngLatToCoordByLayer","lngLatToCoordsByLayer","source","center","SIMPLE","simpleCoordinate","unProjectCoordinates","simpleMapCoord","unproject","coord","c1","co","push","scalers","params","field","hasOwnProperty","type","mappingResult"],"mappings":";;;;;;;;;;;;;;AAAA,SAYEA,KAZF,QAaO,eAbP;AAcA,SAASC,OAAT,QAAwB,eAAxB;AACA,SAASC,OAAT,EAAkBC,SAAlB,EAA6BC,OAA7B,QAA2D,gBAA3D;AACA,SAASC,MAAT,EAAiBC,UAAjB,QAAmC,WAAnC;AAEA,OAAO,kBAAP;IAIqBC,iB,WADpBD,UAAU,E,UAERD,MAAM,CAACL,KAAK,CAACQ,oBAAP,C,UAGNH,MAAM,CAACL,KAAK,CAACS,WAAP,C,UAGNJ,MAAM,CAACL,KAAK,CAACU,YAAP,C;;;;;;;;;;;;;WAGP,eACEC,KADF,QAKE;AAAA;;AAAA,UAFEC,qBAEF,QAFEA,qBAEF;AACAD,MAAAA,KAAK,CAACE,KAAN,CAAYC,IAAZ,CAAiBC,GAAjB,CAAqB,mBAArB,EAA0C,YAAM;AAE9C,QAAA,KAAI,CAACC,cAAL,CAAoBL,KAApB,EAA2B;AAAEC,UAAAA,qBAAqB,EAArBA;AAAF,SAA3B;AACD,OAHD;AAKAD,MAAAA,KAAK,CAACE,KAAN,CAAYI,gBAAZ,CAA6BF,GAA7B,CAAiC,mBAAjC,EAAsD,YAAM;AAC1DJ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Z,CAAgB,UAACoC,KAAD,EAAW;AACzBpB,UAAAA,OAAM,CAACuB,IAAP,CACE,MAAI,CAAClB,UAAL,CAAgBa,cAAhB,CAA+BC,SAA/B,CAAyCC,KAAzC,CADF;AAGD,SAJD;AAMA,eAAOpB,OAAP;AACD;AACF;;;WAED,+BACEvC,SADF,EAEEI,MAFF,EAGEc,YAHF,EAIE;AAAA;;AACA,UAAI,CAAClB,SAAS,CAACG,KAAf,EAAsB;AACpB,eAAO,EAAP;AACD;;AACD,UAAM4D,OAAO,GAAG,CAAA/D,SAAS,SAAT,IAAAA,SAAS,WAAT,gCAAAA,SAAS,CAAEG,KAAX,sEAAkB4D,OAAlB,KAA6B,EAA7C;AACA,UAAMC,MAAiB,GAAG,EAA1B;AAEAD,MAAAA,OAAO,CAACjC,OAAR,CAAgB,iBAAe;AAAA;;AAAA,YAAZmC,KAAY,SAAZA,KAAY;;AAC7B,YACE7D,MAAM,CAAC8D,cAAP,CAAsBD,KAAtB,KACA,sBAAAjE,SAAS,CAACG,KAAV,wEAAiBgE,IAAjB,MAA0B,UAF5B,EAGE;AAEAH,UAAAA,MAAM,CAACF,IAAP,CAAY1D,MAAM,CAAC6D,KAAD,CAAlB;AACD;AACF,OARD;AAYA,UAAMG,aAAa,GAAGpE,SAAS,CAACQ,OAAV,GAAoBR,SAAS,CAACQ,OAAV,CAAkBwD,MAAlB,CAApB,GAAgD,EAAtE;;AACA,UAAIhE,SAAS,CAACgC,IAAV,KAAmB,OAAnB,IAA8B,CAAC9D,OAAO,CAACkG,aAAa,CAAC,CAAD,CAAd,CAA1C,EAA8D;AAC5D,eAAO,CAAClD,YAAD,CAAP;AACD;;AACD,aAAOkD,aAAP;AAED;;;;;;;;;;;;;;;;;;;;SApTkB7F,iB","sourcesContent":["import {\n IEncodeFeature,\n IFontService,\n IGlobalConfigService,\n ILayer,\n ILayerPlugin,\n ILngLat,\n IMapService,\n IParseDataItem,\n IStyleAttribute,\n IStyleAttributeService,\n Position,\n TYPES,\n} from '@antv/l7-core';\nimport { Version } from '@antv/l7-maps';\nimport { isColor, normalize, rgb2arr, unProjectFlat } from '@antv/l7-utils';\nimport { inject, injectable } from 'inversify';\nimport { cloneDeep } from 'lodash';\nimport 'reflect-metadata';\nimport { ILineLayerStyleOptions } from '../core/interface';\n\n@injectable()\nexport default class DataMappingPlugin implements ILayerPlugin {\n @inject(TYPES.IGlobalConfigService)\n private readonly configService: IGlobalConfigService;\n\n @inject(TYPES.IMapService)\n private readonly mapService: IMapService;\n\n @inject(TYPES.IFontService)\n private readonly fontService: IFontService;\n\n public apply(\n layer: ILayer,\n {\n styleAttributeService,\n }: { styleAttributeService: IStyleAttributeService },\n ) {\n layer.hooks.init.tap('DataMappingPlugin', () => {\n // 初始化重新生成 map\n this.generateMaping(layer, { styleAttributeService });\n });\n\n layer.hooks.beforeRenderData.tap('DataMappingPlugin', () => {\n layer.dataState.dataMappingNeedUpdate = false;\n this.generateMaping(layer, { styleAttributeService });\n return true;\n });\n\n // remapping before render\n layer.hooks.beforeRender.tap('DataMappingPlugin', () => {\n if (layer.layerModelNeedUpdate) {\n return;\n }\n const bottomColor = layer.getBottomColor();\n const attributes = styleAttributeService.getLayerStyleAttributes() || [];\n const filter = styleAttributeService.getLayerStyleAttribute('filter');\n const { dataArray } = layer.getSource().data;\n\n const attributesToRemapping = attributes.filter(\n (attribute) => attribute.needRemapping, // 如果filter变化\n );\n let filterData = dataArray;\n\n // 数据过滤完 再执行数据映射\n if (filter?.needRemapping && filter?.scale) {\n filterData = dataArray.filter((record: IParseDataItem) => {\n return this.applyAttributeMapping(filter, record, bottomColor)[0];\n });\n }\n\n if (attributesToRemapping.length) {\n // 过滤数据\n if (filter?.needRemapping) {\n layer.setEncodedData(\n this.mapping(layer, attributes, filterData, undefined, bottomColor),\n );\n filter.needRemapping = false;\n } else {\n layer.setEncodedData(\n this.mapping(\n layer,\n attributesToRemapping,\n filterData,\n layer.getEncodedData(),\n bottomColor,\n ),\n );\n }\n // 处理文本更新\n layer.emit('remapping', null);\n }\n });\n }\n private generateMaping(\n layer: ILayer,\n {\n styleAttributeService,\n }: { styleAttributeService: IStyleAttributeService },\n ) {\n const bottomColor = layer.getBottomColor();\n const attributes = styleAttributeService.getLayerStyleAttributes() || [];\n const filter = styleAttributeService.getLayerStyleAttribute('filter');\n const { dataArray } = layer.getSource().data;\n let filterData = dataArray;\n // 数据过滤完 再执行数据映射\n if (filter?.scale) {\n filterData = dataArray.filter((record: IParseDataItem) => {\n return this.applyAttributeMapping(filter, record, bottomColor)[0];\n });\n }\n layer.setEncodedData(\n this.mapping(layer, attributes, filterData, undefined, bottomColor),\n );\n // 对外暴露事件\n layer.emit('dataUpdate', null);\n }\n\n private getArrowPoints(p1: Position, p2: Position) {\n const dir = [p2[0] - p1[0], p2[1] - p1[1]];\n const normalizeDir = normalize(dir);\n const arrowPoint = [\n p1[0] + normalizeDir[0] * 0.0001,\n p1[1] + normalizeDir[1] * 0.0001,\n ];\n return arrowPoint;\n }\n\n private mapping(\n layer: ILayer,\n attributes: IStyleAttribute[],\n data: IParseDataItem[],\n predata?: IEncodeFeature[],\n minimumColor?: string,\n ): IEncodeFeature[] {\n const {\n arrow = {\n enable: false,\n },\n } = layer.getLayerConfig() as ILineLayerStyleOptions;\n const mappedData = data.map((record: IParseDataItem, i) => {\n const preRecord = predata ? predata[i] : {};\n const encodeRecord: IEncodeFeature = {\n id: record._id,\n coordinates: record.coordinates,\n ...preRecord,\n };\n attributes\n .filter((attribute) => attribute.scale !== undefined)\n .forEach((attribute: IStyleAttribute) => {\n // console.log('record', record)\n let values = this.applyAttributeMapping(\n attribute,\n record,\n minimumColor,\n );\n // console.log('values', values)\n attribute.needRemapping = false;\n\n // TODO: 支持每个属性配置 postprocess\n if (attribute.name === 'color') {\n // console.log('attribute', attribute)\n values = values.map((c: unknown) => {\n return rgb2arr(c as string);\n });\n }\n // @ts-ignore\n encodeRecord[attribute.name] =\n Array.isArray(values) && values.length === 1 ? values[0] : values;\n\n // 增加对 layer/text/iconfont unicode 映射的解析\n if (attribute.name === 'shape') {\n encodeRecord.shape = this.fontService.getIconFontKey(\n encodeRecord[attribute.name] as string,\n );\n }\n });\n\n if (\n arrow.enable &&\n (encodeRecord.shape === 'line' || encodeRecord.shape === 'halfLine')\n ) {\n // 只有在线图层且支持配置箭头的时候进行插入顶点的处理\n const coords = encodeRecord.coordinates as Position[];\n const arrowPoint = this.getArrowPoints(coords[0], coords[1]);\n encodeRecord.coordinates.splice(1, 0, arrowPoint, arrowPoint);\n }\n return encodeRecord;\n }) as IEncodeFeature[];\n // console.log('mappedData', mappedData)\n\n // 调整数据兼容 Amap2.0\n this.adjustData2Amap2Coordinates(mappedData, layer);\n\n // 调整数据兼容 SimpleCoordinates\n this.adjustData2SimpleCoordinates(mappedData);\n\n return mappedData;\n }\n\n private adjustData2Amap2Coordinates(\n mappedData: IEncodeFeature[],\n layer: ILayer,\n ) {\n // 根据地图的类型判断是否需要对点位数据进行处理, 若是高德2.0则需要对坐标进行相对偏移\n if (\n mappedData.length > 0 &&\n this.mapService.version === Version['GAODE2.x']\n ) {\n const layerCenter = this.getLayerCenter(layer);\n if (typeof mappedData[0].coordinates[0] === 'number') {\n // 单个的点数据\n // @ts-ignore\n mappedData\n // TODO: 避免经纬度被重复计算导致坐标位置偏移\n .filter((d) => !d.originCoordinates)\n .map((d) => {\n d.version = Version['GAODE2.x'];\n // @ts-ignore\n d.originCoordinates = cloneDeep(d.coordinates); // 为了兼容高德1.x 需要保存一份原始的经纬度坐标数据(许多上层逻辑依赖经纬度数据)\n // @ts-ignore\n // d.coordinates = this.mapService.lngLatToCoord(d.coordinates);\n d.coordinates = this.mapService.lngLatToCoordByLayer(\n d.coordinates,\n layerCenter,\n );\n });\n } else {\n // 连续的线、面数据\n // @ts-ignore\n mappedData\n // TODO: 避免经纬度被重复计算导致坐标位置偏移\n .filter((d) => !d.originCoordinates)\n .map((d) => {\n d.version = Version['GAODE2.x'];\n // @ts-ignore\n d.originCoordinates = cloneDeep(d.coordinates); // 为了兼容高德1.x 需要保存一份原始的经纬度坐标数据(许多上层逻辑依赖经纬度数据)\n // @ts-ignore\n // d.coordinates = this.mapService.lngLatToCoords(d.coordinates);\n d.coordinates = this.mapService.lngLatToCoordsByLayer(\n d.coordinates,\n layerCenter,\n );\n });\n }\n }\n }\n\n private getLayerCenter(layer: ILayer) {\n const source = layer.getSource();\n return source.center;\n }\n\n private adjustData2SimpleCoordinates(mappedData: IEncodeFeature[]) {\n if (mappedData.length > 0 && this.mapService.version === Version.SIMPLE) {\n mappedData.map((d) => {\n if (!d.simpleCoordinate) {\n d.coordinates = this.unProjectCoordinates(d.coordinates);\n d.simpleCoordinate = true;\n }\n });\n }\n }\n\n private unProjectCoordinates(coordinates: any) {\n if (typeof coordinates[0] === 'number') {\n return this.mapService.simpleMapCoord.unproject(\n coordinates as [number, number],\n );\n }\n\n if (coordinates[0] && coordinates[0][0] instanceof Array) {\n // @ts-ignore\n const coords = [];\n coordinates.map((coord: any) => {\n // @ts-ignore\n const c1 = [];\n coord.map((co: any) => {\n c1.push(\n this.mapService.simpleMapCoord.unproject(co as [number, number]),\n );\n });\n // @ts-ignore\n coords.push(c1);\n });\n // @ts-ignore\n return coords;\n } else {\n // @ts-ignore\n const coords = [];\n // @ts-ignore\n coordinates.map((coord) => {\n coords.push(\n this.mapService.simpleMapCoord.unproject(coord as [number, number]),\n );\n });\n // @ts-ignore\n return coords;\n }\n }\n\n private applyAttributeMapping(\n attribute: IStyleAttribute,\n record: { [key: string]: unknown },\n minimumColor?: string,\n ) {\n if (!attribute.scale) {\n return [];\n }\n const scalers = attribute?.scale?.scalers || [];\n const params: unknown[] = [];\n\n scalers.forEach(({ field }) => {\n if (\n record.hasOwnProperty(field) ||\n attribute.scale?.type === 'variable'\n ) {\n // TODO:多字段,常量\n params.push(record[field]);\n }\n });\n // console.log('params', params)\n // console.log('attribute', attribute)\n\n const mappingResult = attribute.mapping ? attribute.mapping(params) : [];\n if (attribute.name === 'color' && !isColor(mappingResult[0])) {\n return [minimumColor];\n }\n return mappingResult;\n // return attribute.mapping ? attribute.mapping(params) : [];\n }\n}\n"],"file":"DataMappingPlugin.js"}
1
+ {"version":3,"sources":["../../src/plugins/DataMappingPlugin.ts"],"names":["TYPES","Version","isColor","normalize","rgb2arr","inject","injectable","DataMappingPlugin","IGlobalConfigService","IMapService","IFontService","layer","styleAttributeService","hooks","init","tap","source","getSource","inited","generateMaping","once","beforeRenderData","dataState","dataMappingNeedUpdate","beforeRender","layerModelNeedUpdate","bottomColor","getBottomColor","attributes","getLayerStyleAttributes","filter","getLayerStyleAttribute","dataArray","data","attributesToRemapping","attribute","needRemapping","filterData","scale","record","applyAttributeMapping","length","setEncodedData","mapping","undefined","getEncodedData","emit","p1","p2","dir","normalizeDir","arrowPoint","predata","minimumColor","getLayerConfig","arrow","enable","mappedData","map","i","preRecord","encodeRecord","id","_id","coordinates","forEach","values","name","c","Array","isArray","shape","fontService","getIconFontKey","coords","getArrowPoints","splice","adjustData2Amap2Coordinates","adjustData2SimpleCoordinates","mapService","version","layerCenter","getLayerCenter","d","originCoordinates","lngLatToCoordByLayer","lngLatToCoordsByLayer","center","SIMPLE","simpleCoordinate","unProjectCoordinates","simpleMapCoord","unproject","coord","c1","co","push","scalers","params","field","hasOwnProperty","type","mappingResult"],"mappings":";;;;;;;;;;;;;;AAAA,SAYEA,KAZF,QAaO,eAbP;AAcA,SAASC,OAAT,QAAwB,eAAxB;AACA,SAASC,OAAT,EAAkBC,SAAlB,EAA6BC,OAA7B,QAA2D,gBAA3D;AACA,SAASC,MAAT,EAAiBC,UAAjB,QAAmC,WAAnC;AAEA,OAAO,kBAAP;IAIqBC,iB,WADpBD,UAAU,E,UAERD,MAAM,CAACL,KAAK,CAACQ,oBAAP,C,UAGNH,MAAM,CAACL,KAAK,CAACS,WAAP,C,UAGNJ,MAAM,CAACL,KAAK,CAACU,YAAP,C;;;;;;;;;;;;;WAGP,eACEC,KADF,QAKE;AAAA;;AAAA,UAFEC,qBAEF,Q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Af,EAAsB;AACpB,eAAO,EAAP;AACD;;AACD,UAAM2D,OAAO,GAAG,CAAA9D,SAAS,SAAT,IAAAA,SAAS,WAAT,gCAAAA,SAAS,CAAEG,KAAX,sEAAkB2D,OAAlB,KAA6B,EAA7C;AACA,UAAMC,MAAiB,GAAG,EAA1B;AAEAD,MAAAA,OAAO,CAAChC,OAAR,CAAgB,iBAAe;AAAA;;AAAA,YAAZkC,KAAY,SAAZA,KAAY;;AAC7B,YACE5D,MAAM,CAAC6D,cAAP,CAAsBD,KAAtB,KACA,sBAAAhE,SAAS,CAACG,KAAV,wEAAiB+D,IAAjB,MAA0B,UAF5B,EAGE;AAEAH,UAAAA,MAAM,CAACF,IAAP,CAAYzD,MAAM,CAAC4D,KAAD,CAAlB;AACD;AACF,OARD;AAYA,UAAMG,aAAa,GAAGnE,SAAS,CAACQ,OAAV,GAAoBR,SAAS,CAACQ,OAAV,CAAkBuD,MAAlB,CAApB,GAAgD,EAAtE;;AACA,UAAI/D,SAAS,CAACgC,IAAV,KAAmB,OAAnB,IAA8B,CAACjE,OAAO,CAACoG,aAAa,CAAC,CAAD,CAAd,CAA1C,EAA8D;AAC5D,eAAO,CAACjD,YAAD,CAAP;AACD;;AACD,aAAOiD,aAAP;AAED;;;;;;;;;;;;;;;;;;;;SAvUkB/F,iB","sourcesContent":["import {\n IEncodeFeature,\n IFontService,\n IGlobalConfigService,\n ILayer,\n ILayerPlugin,\n ILngLat,\n IMapService,\n IParseDataItem,\n IStyleAttribute,\n IStyleAttributeService,\n Position,\n TYPES,\n} from '@antv/l7-core';\nimport { Version } from '@antv/l7-maps';\nimport { isColor, normalize, rgb2arr, unProjectFlat } from '@antv/l7-utils';\nimport { inject, injectable } from 'inversify';\nimport { cloneDeep } from 'lodash';\nimport 'reflect-metadata';\nimport { ILineLayerStyleOptions } from '../core/interface';\n\n@injectable()\nexport default class DataMappingPlugin implements ILayerPlugin {\n @inject(TYPES.IGlobalConfigService)\n private readonly configService: IGlobalConfigService;\n\n @inject(TYPES.IMapService)\n private readonly mapService: IMapService;\n\n @inject(TYPES.IFontService)\n private readonly fontService: IFontService;\n\n public apply(\n layer: ILayer,\n {\n styleAttributeService,\n }: { styleAttributeService: IStyleAttributeService },\n ) {\n layer.hooks.init.tap('DataMappingPlugin', () => {\n // 初始化重新生成 map\n const source = layer.getSource();\n if (source.inited) {\n this.generateMaping(layer, { styleAttributeService });\n } else {\n source.once('sourceUpdate', () => {\n this.generateMaping(layer, { styleAttributeService });\n });\n }\n // this.generateMaping(layer, { styleAttributeService });\n });\n\n layer.hooks.beforeRenderData.tap('DataMappingPlugin', () => {\n layer.dataState.dataMappingNeedUpdate = false;\n const source = layer.getSource();\n if (source.inited) {\n this.generateMaping(layer, { styleAttributeService });\n } else {\n source.once('sourceUpdate', () => {\n this.generateMaping(layer, { styleAttributeService });\n });\n }\n\n // this.generateMaping(layer, { styleAttributeService });\n\n return true;\n });\n\n // remapping before render\n layer.hooks.beforeRender.tap('DataMappingPlugin', () => {\n const source = layer.getSource();\n if (layer.layerModelNeedUpdate || !source || !source.inited) {\n return;\n }\n const bottomColor = layer.getBottomColor();\n const attributes = styleAttributeService.getLayerStyleAttributes() || [];\n const filter = styleAttributeService.getLayerStyleAttribute('filter');\n const { dataArray } = source.data;\n\n const attributesToRemapping = attributes.filter(\n (attribute) => attribute.needRemapping, // 如果filter变化\n );\n let filterData = dataArray;\n\n // 数据过滤完 再执行数据映射\n if (filter?.needRemapping && filter?.scale) {\n filterData = dataArray.filter((record: IParseDataItem) => {\n return this.applyAttributeMapping(filter, record, bottomColor)[0];\n });\n }\n\n if (attributesToRemapping.length) {\n // 过滤数据\n if (filter?.needRemapping) {\n layer.setEncodedData(\n this.mapping(layer, attributes, filterData, undefined, bottomColor),\n );\n filter.needRemapping = false;\n } else {\n layer.setEncodedData(\n this.mapping(\n layer,\n attributesToRemapping,\n filterData,\n layer.getEncodedData(),\n bottomColor,\n ),\n );\n }\n // 处理文本更新\n layer.emit('remapping', null);\n }\n });\n }\n private generateMaping(\n layer: ILayer,\n {\n styleAttributeService,\n }: { styleAttributeService: IStyleAttributeService },\n ) {\n const bottomColor = layer.getBottomColor();\n const attributes = styleAttributeService.getLayerStyleAttributes() || [];\n const filter = styleAttributeService.getLayerStyleAttribute('filter');\n const { dataArray } = layer.getSource().data;\n let filterData = dataArray;\n // 数据过滤完 再执行数据映射\n if (filter?.scale) {\n filterData = dataArray.filter((record: IParseDataItem) => {\n return this.applyAttributeMapping(filter, record, bottomColor)[0];\n });\n }\n layer.setEncodedData(\n this.mapping(layer, attributes, filterData, undefined, bottomColor),\n );\n // 对外暴露事件\n layer.emit('dataUpdate', null);\n }\n\n private getArrowPoints(p1: Position, p2: Position) {\n const dir = [p2[0] - p1[0], p2[1] - p1[1]];\n const normalizeDir = normalize(dir);\n const arrowPoint = [\n p1[0] + normalizeDir[0] * 0.0001,\n p1[1] + normalizeDir[1] * 0.0001,\n ];\n return arrowPoint;\n }\n\n private mapping(\n layer: ILayer,\n attributes: IStyleAttribute[],\n data: IParseDataItem[],\n predata?: IEncodeFeature[],\n minimumColor?: string,\n ): IEncodeFeature[] {\n const {\n arrow = {\n enable: false,\n },\n } = layer.getLayerConfig() as ILineLayerStyleOptions;\n const mappedData = data.map((record: IParseDataItem, i) => {\n const preRecord = predata ? predata[i] : {};\n const encodeRecord: IEncodeFeature = {\n id: record._id,\n coordinates: record.coordinates,\n ...preRecord,\n };\n attributes\n .filter((attribute) => attribute.scale !== undefined)\n .forEach((attribute: IStyleAttribute) => {\n // console.log('record', record)\n let values = this.applyAttributeMapping(\n attribute,\n record,\n minimumColor,\n );\n // console.log('values', values)\n attribute.needRemapping = false;\n\n // TODO: 支持每个属性配置 postprocess\n if (attribute.name === 'color') {\n // console.log('attribute', attribute)\n values = values.map((c: unknown) => {\n return rgb2arr(c as string);\n });\n }\n // @ts-ignore\n encodeRecord[attribute.name] =\n Array.isArray(values) && values.length === 1 ? values[0] : values;\n\n // 增加对 layer/text/iconfont unicode 映射的解析\n if (attribute.name === 'shape') {\n encodeRecord.shape = this.fontService.getIconFontKey(\n encodeRecord[attribute.name] as string,\n );\n }\n });\n\n if (\n arrow.enable &&\n (encodeRecord.shape === 'line' || encodeRecord.shape === 'halfLine')\n ) {\n // 只有在线图层且支持配置箭头的时候进行插入顶点的处理\n const coords = encodeRecord.coordinates as Position[];\n const arrowPoint = this.getArrowPoints(coords[0], coords[1]);\n encodeRecord.coordinates.splice(1, 0, arrowPoint, arrowPoint);\n }\n return encodeRecord;\n }) as IEncodeFeature[];\n // console.log('mappedData', mappedData)\n\n // 调整数据兼容 Amap2.0\n this.adjustData2Amap2Coordinates(mappedData, layer);\n\n // 调整数据兼容 SimpleCoordinates\n this.adjustData2SimpleCoordinates(mappedData);\n\n return mappedData;\n }\n\n private adjustData2Amap2Coordinates(\n mappedData: IEncodeFeature[],\n layer: ILayer,\n ) {\n // 根据地图的类型判断是否需要对点位数据进行处理, 若是高德2.0则需要对坐标进行相对偏移\n if (\n mappedData.length > 0 &&\n this.mapService.version === Version['GAODE2.x']\n ) {\n const layerCenter = this.getLayerCenter(layer);\n if (typeof mappedData[0].coordinates[0] === 'number') {\n // 单个的点数据\n // @ts-ignore\n mappedData\n // TODO: 避免经纬度被重复计算导致坐标位置偏移\n .filter((d) => !d.originCoordinates)\n .map((d) => {\n d.version = Version['GAODE2.x'];\n // @ts-ignore\n d.originCoordinates = cloneDeep(d.coordinates); // 为了兼容高德1.x 需要保存一份原始的经纬度坐标数据(许多上层逻辑依赖经纬度数据)\n // @ts-ignore\n // d.coordinates = this.mapService.lngLatToCoord(d.coordinates);\n d.coordinates = this.mapService.lngLatToCoordByLayer(\n d.coordinates,\n layerCenter,\n );\n });\n } else {\n // 连续的线、面数据\n // @ts-ignore\n mappedData\n // TODO: 避免经纬度被重复计算导致坐标位置偏移\n .filter((d) => !d.originCoordinates)\n .map((d) => {\n d.version = Version['GAODE2.x'];\n // @ts-ignore\n d.originCoordinates = cloneDeep(d.coordinates); // 为了兼容高德1.x 需要保存一份原始的经纬度坐标数据(许多上层逻辑依赖经纬度数据)\n // @ts-ignore\n // d.coordinates = this.mapService.lngLatToCoords(d.coordinates);\n d.coordinates = this.mapService.lngLatToCoordsByLayer(\n d.coordinates,\n layerCenter,\n );\n });\n }\n }\n }\n\n private getLayerCenter(layer: ILayer) {\n const source = layer.getSource();\n return source.center;\n }\n\n private adjustData2SimpleCoordinates(mappedData: IEncodeFeature[]) {\n if (mappedData.length > 0 && this.mapService.version === Version.SIMPLE) {\n mappedData.map((d) => {\n if (!d.simpleCoordinate) {\n d.coordinates = this.unProjectCoordinates(d.coordinates);\n d.simpleCoordinate = true;\n }\n });\n }\n }\n\n private unProjectCoordinates(coordinates: any) {\n if (typeof coordinates[0] === 'number') {\n return this.mapService.simpleMapCoord.unproject(\n coordinates as [number, number],\n );\n }\n\n if (coordinates[0] && coordinates[0][0] instanceof Array) {\n // @ts-ignore\n const coords = [];\n coordinates.map((coord: any) => {\n // @ts-ignore\n const c1 = [];\n coord.map((co: any) => {\n c1.push(\n this.mapService.simpleMapCoord.unproject(co as [number, number]),\n );\n });\n // @ts-ignore\n coords.push(c1);\n });\n // @ts-ignore\n return coords;\n } else {\n // @ts-ignore\n const coords = [];\n // @ts-ignore\n coordinates.map((coord) => {\n coords.push(\n this.mapService.simpleMapCoord.unproject(coord as [number, number]),\n );\n });\n // @ts-ignore\n return coords;\n }\n }\n\n private applyAttributeMapping(\n attribute: IStyleAttribute,\n record: { [key: string]: unknown },\n minimumColor?: string,\n ) {\n if (!attribute.scale) {\n return [];\n }\n const scalers = attribute?.scale?.scalers || [];\n const params: unknown[] = [];\n\n scalers.forEach(({ field }) => {\n if (\n record.hasOwnProperty(field) ||\n attribute.scale?.type === 'variable'\n ) {\n // TODO:多字段,常量\n params.push(record[field]);\n }\n });\n // console.log('params', params)\n // console.log('attribute', attribute)\n\n const mappingResult = attribute.mapping ? attribute.mapping(params) : [];\n if (attribute.name === 'color' && !isColor(mappingResult[0])) {\n return [minimumColor];\n }\n return mappingResult;\n // return attribute.mapping ? attribute.mapping(params) : [];\n }\n}\n"],"file":"DataMappingPlugin.js"}