@antv/l7-layers 2.5.34 → 2.5.37-mini10

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 (279) hide show
  1. package/lib/core/BaseLayer.js +10 -4
  2. package/lib/core/BaseLayer.js.map +1 -1
  3. package/lib/core/shape/Path.js +5 -4
  4. package/lib/core/shape/Path.js.map +1 -1
  5. package/lib/core/shape/extrude.js +1 -1
  6. package/lib/core/triangulation.js +13 -9
  7. package/lib/core/triangulation.js.map +1 -1
  8. package/lib/earth/utils.js +1 -1
  9. package/lib/heatmap/models/heatmap.js +1 -1
  10. package/lib/imagetile/index.js +95 -0
  11. package/lib/imagetile/index.js.map +1 -0
  12. package/lib/imagetile/models/imagetile.js +177 -0
  13. package/lib/imagetile/models/imagetile.js.map +1 -0
  14. package/lib/imagetile/models/index.js +17 -0
  15. package/lib/imagetile/models/index.js.map +1 -0
  16. package/lib/imagetile/utils/ImageTile.js +99 -0
  17. package/lib/imagetile/utils/ImageTile.js.map +1 -0
  18. package/lib/imagetile/utils/Tile.js +324 -0
  19. package/lib/imagetile/utils/Tile.js.map +1 -0
  20. package/lib/imagetile/utils/lruCache.js +109 -0
  21. package/lib/imagetile/utils/lruCache.js.map +1 -0
  22. package/lib/imagetile/utils/tileCache.js +58 -0
  23. package/lib/imagetile/utils/tileCache.js.map +1 -0
  24. package/lib/index.js +16 -8
  25. package/lib/index.js.map +1 -1
  26. package/lib/line/index.js +3 -0
  27. package/lib/line/index.js.map +1 -1
  28. package/lib/line/models/arc.js +2 -2
  29. package/lib/line/models/arc_3d.js +2 -2
  30. package/lib/line/models/arcmini.js +160 -0
  31. package/lib/line/models/arcmini.js.map +1 -0
  32. package/lib/line/models/great_circle.js +2 -2
  33. package/lib/line/models/index.js +3 -0
  34. package/lib/line/models/index.js.map +1 -1
  35. package/lib/line/models/line.js +2 -2
  36. package/lib/plugins/DataMappingPlugin.js +1 -1
  37. package/lib/plugins/DataSourcePlugin.js +5 -1
  38. package/lib/plugins/DataSourcePlugin.js.map +1 -1
  39. package/lib/plugins/FeatureScalePlugin.js +5 -1
  40. package/lib/plugins/FeatureScalePlugin.js.map +1 -1
  41. package/lib/plugins/LayerAnimateStylePlugin.js +1 -1
  42. package/lib/plugins/LightingPlugin.js +5 -3
  43. package/lib/plugins/LightingPlugin.js.map +1 -1
  44. package/lib/plugins/MultiPassRendererPlugin.js +1 -1
  45. package/lib/plugins/ShaderUniformPlugin.js +1 -1
  46. package/lib/plugins/ShaderUniformPlugin.js.map +1 -1
  47. package/lib/plugins/UpdateStyleAttributePlugin.js +6 -6
  48. package/lib/plugins/UpdateStyleAttributePlugin.js.map +1 -1
  49. package/lib/point/shape/Path.js +5 -4
  50. package/lib/point/shape/Path.js.map +1 -1
  51. package/lib/raster/raster.js +1 -1
  52. package/lib/utils/dataMappingStyle.js +1 -1
  53. package/lib/utils/extrude_polyline.js +1 -1
  54. package/lib/utils/polylineNormal.js +1 -1
  55. package/lib/utils/symbol-layout.js +1 -1
  56. package/package.json +6 -5
  57. package/CHANGELOG.md +0 -492
  58. package/LICENSE.md +0 -21
  59. package/es/citybuliding/building.d.ts +0 -17
  60. package/es/citybuliding/building.js +0 -79
  61. package/es/citybuliding/building.js.map +0 -1
  62. package/es/citybuliding/models/build.d.ts +0 -13
  63. package/es/citybuliding/models/build.js +0 -124
  64. package/es/citybuliding/models/build.js.map +0 -1
  65. package/es/core/BaseLayer.d.ts +0 -174
  66. package/es/core/BaseLayer.js +0 -974
  67. package/es/core/BaseLayer.js.map +0 -1
  68. package/es/core/BaseModel.d.ts +0 -135
  69. package/es/core/BaseModel.js +0 -412
  70. package/es/core/BaseModel.js.map +0 -1
  71. package/es/core/interface.d.ts +0 -19
  72. package/es/core/interface.js +0 -7
  73. package/es/core/interface.js.map +0 -1
  74. package/es/core/schema.d.ts +0 -27
  75. package/es/core/schema.js +0 -23
  76. package/es/core/schema.js.map +0 -1
  77. package/es/core/shape/Path.d.ts +0 -39
  78. package/es/core/shape/Path.js +0 -57
  79. package/es/core/shape/Path.js.map +0 -1
  80. package/es/core/shape/extrude.d.ts +0 -17
  81. package/es/core/shape/extrude.js +0 -143
  82. package/es/core/shape/extrude.js.map +0 -1
  83. package/es/core/triangulation.d.ts +0 -109
  84. package/es/core/triangulation.js +0 -328
  85. package/es/core/triangulation.js.map +0 -1
  86. package/es/earth/index.d.ts +0 -17
  87. package/es/earth/index.js +0 -81
  88. package/es/earth/index.js.map +0 -1
  89. package/es/earth/models/atmosphere.d.ts +0 -9
  90. package/es/earth/models/atmosphere.js +0 -125
  91. package/es/earth/models/atmosphere.js.map +0 -1
  92. package/es/earth/models/base.d.ts +0 -16
  93. package/es/earth/models/base.js +0 -193
  94. package/es/earth/models/base.js.map +0 -1
  95. package/es/earth/models/bloomsphere.d.ts +0 -9
  96. package/es/earth/models/bloomsphere.js +0 -125
  97. package/es/earth/models/bloomsphere.js.map +0 -1
  98. package/es/earth/utils.d.ts +0 -26
  99. package/es/earth/utils.js +0 -81
  100. package/es/earth/utils.js.map +0 -1
  101. package/es/glsl.d.js +0 -2
  102. package/es/glsl.d.js.map +0 -1
  103. package/es/heatmap/index.d.ts +0 -22
  104. package/es/heatmap/index.js +0 -123
  105. package/es/heatmap/index.js.map +0 -1
  106. package/es/heatmap/models/grid.d.ts +0 -8
  107. package/es/heatmap/models/grid.js +0 -90
  108. package/es/heatmap/models/grid.js.map +0 -1
  109. package/es/heatmap/models/grid3d.d.ts +0 -8
  110. package/es/heatmap/models/grid3d.js +0 -122
  111. package/es/heatmap/models/grid3d.js.map +0 -1
  112. package/es/heatmap/models/heatmap.d.ts +0 -24
  113. package/es/heatmap/models/heatmap.js +0 -399
  114. package/es/heatmap/models/heatmap.js.map +0 -1
  115. package/es/heatmap/models/hexagon.d.ts +0 -8
  116. package/es/heatmap/models/hexagon.js +0 -90
  117. package/es/heatmap/models/hexagon.js.map +0 -1
  118. package/es/heatmap/models/index.d.ts +0 -5
  119. package/es/heatmap/models/index.js +0 -13
  120. package/es/heatmap/models/index.js.map +0 -1
  121. package/es/heatmap/triangulation.d.ts +0 -5
  122. package/es/heatmap/triangulation.js +0 -38
  123. package/es/heatmap/triangulation.js.map +0 -1
  124. package/es/image/index.d.ts +0 -22
  125. package/es/image/index.js +0 -82
  126. package/es/image/index.js.map +0 -1
  127. package/es/image/models/image.d.ts +0 -18
  128. package/es/image/models/image.js +0 -127
  129. package/es/image/models/image.js.map +0 -1
  130. package/es/image/models/index.d.ts +0 -5
  131. package/es/image/models/index.js +0 -6
  132. package/es/image/models/index.js.map +0 -1
  133. package/es/index.d.ts +0 -11
  134. package/es/index.js +0 -39
  135. package/es/index.js.map +0 -1
  136. package/es/line/index.d.ts +0 -25
  137. package/es/line/index.js +0 -95
  138. package/es/line/index.js.map +0 -1
  139. package/es/line/models/arc.d.ts +0 -12
  140. package/es/line/models/arc.js +0 -281
  141. package/es/line/models/arc.js.map +0 -1
  142. package/es/line/models/arc_3d.d.ts +0 -12
  143. package/es/line/models/arc_3d.js +0 -277
  144. package/es/line/models/arc_3d.js.map +0 -1
  145. package/es/line/models/great_circle.d.ts +0 -12
  146. package/es/line/models/great_circle.js +0 -269
  147. package/es/line/models/great_circle.js.map +0 -1
  148. package/es/line/models/index.d.ts +0 -5
  149. package/es/line/models/index.js +0 -12
  150. package/es/line/models/index.js.map +0 -1
  151. package/es/line/models/line.d.ts +0 -13
  152. package/es/line/models/line.js +0 -342
  153. package/es/line/models/line.js.map +0 -1
  154. package/es/plugins/DataMappingPlugin.d.ts +0 -13
  155. package/es/plugins/DataMappingPlugin.js +0 -199
  156. package/es/plugins/DataMappingPlugin.js.map +0 -1
  157. package/es/plugins/DataSourcePlugin.d.ts +0 -7
  158. package/es/plugins/DataSourcePlugin.js +0 -73
  159. package/es/plugins/DataSourcePlugin.js.map +0 -1
  160. package/es/plugins/FeatureScalePlugin.d.ts +0 -26
  161. package/es/plugins/FeatureScalePlugin.js +0 -270
  162. package/es/plugins/FeatureScalePlugin.js.map +0 -1
  163. package/es/plugins/LayerAnimateStylePlugin.d.ts +0 -7
  164. package/es/plugins/LayerAnimateStylePlugin.js +0 -50
  165. package/es/plugins/LayerAnimateStylePlugin.js.map +0 -1
  166. package/es/plugins/LayerModelPlugin.d.ts +0 -8
  167. package/es/plugins/LayerModelPlugin.js +0 -34
  168. package/es/plugins/LayerModelPlugin.js.map +0 -1
  169. package/es/plugins/LayerStylePlugin.d.ts +0 -8
  170. package/es/plugins/LayerStylePlugin.js +0 -35
  171. package/es/plugins/LayerStylePlugin.js.map +0 -1
  172. package/es/plugins/LightingPlugin.d.ts +0 -36
  173. package/es/plugins/LightingPlugin.js +0 -100
  174. package/es/plugins/LightingPlugin.js.map +0 -1
  175. package/es/plugins/MultiPassRendererPlugin.d.ts +0 -37
  176. package/es/plugins/MultiPassRendererPlugin.js +0 -79
  177. package/es/plugins/MultiPassRendererPlugin.js.map +0 -1
  178. package/es/plugins/PixelPickingPlugin.d.ts +0 -8
  179. package/es/plugins/PixelPickingPlugin.js +0 -112
  180. package/es/plugins/PixelPickingPlugin.js.map +0 -1
  181. package/es/plugins/RegisterStyleAttributePlugin.d.ts +0 -11
  182. package/es/plugins/RegisterStyleAttributePlugin.js +0 -98
  183. package/es/plugins/RegisterStyleAttributePlugin.js.map +0 -1
  184. package/es/plugins/ShaderUniformPlugin.d.ts +0 -16
  185. package/es/plugins/ShaderUniformPlugin.js +0 -78
  186. package/es/plugins/ShaderUniformPlugin.js.map +0 -1
  187. package/es/plugins/UpdateModelPlugin.d.ts +0 -8
  188. package/es/plugins/UpdateModelPlugin.js +0 -27
  189. package/es/plugins/UpdateModelPlugin.js.map +0 -1
  190. package/es/plugins/UpdateStyleAttributePlugin.d.ts +0 -12
  191. package/es/plugins/UpdateStyleAttributePlugin.js +0 -74
  192. package/es/plugins/UpdateStyleAttributePlugin.js.map +0 -1
  193. package/es/point/index.d.ts +0 -30
  194. package/es/point/index.js +0 -130
  195. package/es/point/index.js.map +0 -1
  196. package/es/point/models/extrude.d.ts +0 -14
  197. package/es/point/models/extrude.js +0 -180
  198. package/es/point/models/extrude.js.map +0 -1
  199. package/es/point/models/fill.d.ts +0 -17
  200. package/es/point/models/fill.js +0 -247
  201. package/es/point/models/fill.js.map +0 -1
  202. package/es/point/models/icon-font.d.ts +0 -11
  203. package/es/point/models/icon-font.js +0 -181
  204. package/es/point/models/icon-font.js.map +0 -1
  205. package/es/point/models/image.d.ts +0 -11
  206. package/es/point/models/image.js +0 -207
  207. package/es/point/models/image.js.map +0 -1
  208. package/es/point/models/index.d.ts +0 -5
  209. package/es/point/models/index.js +0 -16
  210. package/es/point/models/index.js.map +0 -1
  211. package/es/point/models/normal.d.ts +0 -21
  212. package/es/point/models/normal.js +0 -155
  213. package/es/point/models/normal.js.map +0 -1
  214. package/es/point/models/text.d.ts +0 -56
  215. package/es/point/models/text.js +0 -522
  216. package/es/point/models/text.js.map +0 -1
  217. package/es/point/shape/Path.d.ts +0 -40
  218. package/es/point/shape/Path.js +0 -57
  219. package/es/point/shape/Path.js.map +0 -1
  220. package/es/point/shape/extrude.d.ts +0 -15
  221. package/es/point/shape/extrude.js +0 -58
  222. package/es/point/shape/extrude.js.map +0 -1
  223. package/es/polygon/index.d.ts +0 -22
  224. package/es/polygon/index.js +0 -124
  225. package/es/polygon/index.js.map +0 -1
  226. package/es/polygon/models/extrude.d.ts +0 -13
  227. package/es/polygon/models/extrude.js +0 -139
  228. package/es/polygon/models/extrude.js.map +0 -1
  229. package/es/polygon/models/fill.d.ts +0 -13
  230. package/es/polygon/models/fill.js +0 -108
  231. package/es/polygon/models/fill.js.map +0 -1
  232. package/es/polygon/models/index.d.ts +0 -5
  233. package/es/polygon/models/index.js +0 -20
  234. package/es/polygon/models/index.js.map +0 -1
  235. package/es/raster/buffers/triangulation.d.ts +0 -6
  236. package/es/raster/buffers/triangulation.js +0 -28
  237. package/es/raster/buffers/triangulation.js.map +0 -1
  238. package/es/raster/image.d.ts +0 -0
  239. package/es/raster/image.js +0 -2
  240. package/es/raster/image.js.map +0 -1
  241. package/es/raster/index.d.ts +0 -28
  242. package/es/raster/index.js +0 -83
  243. package/es/raster/index.js.map +0 -1
  244. package/es/raster/models/index.d.ts +0 -5
  245. package/es/raster/models/index.js +0 -7
  246. package/es/raster/models/index.js.map +0 -1
  247. package/es/raster/models/raster.d.ts +0 -19
  248. package/es/raster/models/raster.js +0 -152
  249. package/es/raster/models/raster.js.map +0 -1
  250. package/es/raster/raster.d.ts +0 -30
  251. package/es/raster/raster.js +0 -178
  252. package/es/raster/raster.js.map +0 -1
  253. package/es/raster/raster2d.d.ts +0 -27
  254. package/es/raster/raster2d.js +0 -158
  255. package/es/raster/raster2d.js.map +0 -1
  256. package/es/utils/blend.d.ts +0 -2
  257. package/es/utils/blend.js +0 -55
  258. package/es/utils/blend.js.map +0 -1
  259. package/es/utils/collision-index.d.ts +0 -47
  260. package/es/utils/collision-index.js +0 -87
  261. package/es/utils/collision-index.js.map +0 -1
  262. package/es/utils/dataMappingStyle.d.ts +0 -30
  263. package/es/utils/dataMappingStyle.js +0 -88
  264. package/es/utils/dataMappingStyle.js.map +0 -1
  265. package/es/utils/extrude_polyline.d.ts +0 -48
  266. package/es/utils/extrude_polyline.js +0 -405
  267. package/es/utils/extrude_polyline.js.map +0 -1
  268. package/es/utils/geo.d.ts +0 -3
  269. package/es/utils/geo.js +0 -24
  270. package/es/utils/geo.js.map +0 -1
  271. package/es/utils/grid-index.d.ts +0 -28
  272. package/es/utils/grid-index.js +0 -193
  273. package/es/utils/grid-index.js.map +0 -1
  274. package/es/utils/polylineNormal.d.ts +0 -9
  275. package/es/utils/polylineNormal.js +0 -171
  276. package/es/utils/polylineNormal.js.map +0 -1
  277. package/es/utils/symbol-layout.d.ts +0 -43
  278. package/es/utils/symbol-layout.js +0 -260
  279. package/es/utils/symbol-layout.js.map +0 -1
@@ -1,342 +0,0 @@
1
- import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
2
- import _createClass from "@babel/runtime/helpers/createClass";
3
- import _assertThisInitialized from "@babel/runtime/helpers/assertThisInitialized";
4
- import _inherits from "@babel/runtime/helpers/inherits";
5
- import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
6
- import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
7
- import _defineProperty from "@babel/runtime/helpers/defineProperty";
8
- import _isNumber from "lodash/isNumber";
9
-
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); }; }
11
-
12
- function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
13
-
14
- import { AttributeType, gl } from '@antv/l7-core';
15
- import { rgb2arr } from '@antv/l7-utils';
16
- import BaseModel from '../../core/BaseModel';
17
- import { LineTriangulation } from '../../core/triangulation';
18
- var line_frag = "#define LineTypeSolid 0.0\n#define LineTypeDash 1.0\n#define Animate 0.0\n#define LineTexture 1.0\nuniform float u_blur : 0.99;\nuniform float u_line_type: 0.0;\nuniform float u_opacity : 1.0;\nuniform float u_textureBlend;\nvarying vec4 v_color;\nvarying vec2 v_normal;\n\n// line texture\nuniform float u_line_texture;\nuniform sampler2D u_texture;\nuniform vec2 u_textSize;\n\n// dash\nuniform float u_dash_offset : 0.0;\nuniform float u_dash_ratio : 0.1;\nvarying vec4 v_dash_array;\n\nvarying vec4 v_dataset; // \u6570\u636E\u96C6 - distance_ratio/distance/pixelLen/texV\n\nvarying vec2 v_iconMapUV;\n\nuniform float u_linearColor: 0;\nuniform vec4 u_sourceColor;\nuniform vec4 u_targetColor;\n\n#pragma include \"picking\"\n\nuniform float u_time;\nuniform vec4 u_aimate: [ 0, 2., 1.0, 0.2 ]; // \u63A7\u5236\u8FD0\u52A8\n\nvarying mat4 styleMappingMat;\n// [animate, duration, interval, trailLength],\nvoid main() {\n float opacity = styleMappingMat[0][0];\n float animateSpeed = 0.0; // \u8FD0\u52A8\u901F\u5EA6\n float d_distance_ratio = v_dataset.r; // \u5F53\u524D\u70B9\u4F4D\u8DDD\u79BB\u5360\u7EBF\u603B\u957F\u7684\u6BD4\u4F8B\n\n if(u_linearColor == 1.0) { // \u4F7F\u7528\u6E10\u53D8\u989C\u8272\n gl_FragColor = mix(u_sourceColor, u_targetColor, d_distance_ratio);\n } else { // \u4F7F\u7528 color \u65B9\u6CD5\u4F20\u5165\u7684\u989C\u8272\n gl_FragColor = v_color;\n }\n\n // anti-alias\n // float blur = 1.0 - smoothstep(u_blur, 1., length(v_normal.xy));\n gl_FragColor.a *= opacity; // \u5168\u5C40\u900F\u660E\u5EA6\n if(u_aimate.x == Animate) {\n animateSpeed = u_time / u_aimate.y;\n float alpha =1.0 - fract( mod(1.0- d_distance_ratio, u_aimate.z)* (1.0/ u_aimate.z) + animateSpeed);\n alpha = (alpha + u_aimate.w -1.0) / u_aimate.w;\n alpha = smoothstep(0., 1., alpha);\n gl_FragColor.a *= alpha;\n }\n // dash line\n if(u_line_type == LineTypeDash) {\n float flag = 0.;\n float dashLength = mod(d_distance_ratio, v_dash_array.x + v_dash_array.y + v_dash_array.z + v_dash_array.w);\n if(dashLength < v_dash_array.x || (dashLength > (v_dash_array.x + v_dash_array.y) && dashLength < v_dash_array.x + v_dash_array.y + v_dash_array.z)) {\n flag = 1.;\n }\n gl_FragColor.a *=flag;\n }\n\n if(u_line_texture == LineTexture && u_line_type != LineTypeDash) { // while load texture\n float aDistance = v_dataset.g; // \u5F53\u524D\u9876\u70B9\u7684\u8DDD\u79BB\n float d_texPixelLen = v_dataset.b; // \u8D34\u56FE\u7684\u50CF\u7D20\u957F\u5EA6\uFF0C\u6839\u636E\u5730\u56FE\u5C42\u7EA7\u7F29\u653E\n float u = fract(mod(aDistance, d_texPixelLen)/d_texPixelLen - animateSpeed);\n float v = v_dataset.a; // \u7EBF\u56FE\u5C42\u8D34\u56FE\u90E8\u5206\u7684 v \u5750\u6807\u503C\n\n v = max(smoothstep(0.95, 1.0, v), v);\n vec2 uv= v_iconMapUV / u_textSize + vec2(u, v) / u_textSize * 64.;\n // gl_FragColor = filterColor(gl_FragColor + texture2D(u_texture, vec2(u, v)));\n // gl_FragColor = filterColor(gl_FragColor + texture2D(u_texture, uv));\n vec4 pattern = texture2D(u_texture, uv);\n\n if(u_textureBlend == 0.0) { // normal\n pattern.a = 0.0;\n gl_FragColor = filterColor(gl_FragColor + pattern);\n } else { // replace\n pattern.a *= opacity;\n if(gl_FragColor.a <= 0.0) {\n pattern.a = 0.0;\n }\n gl_FragColor = filterColor(pattern);\n }\n } else {\n gl_FragColor = filterColor(gl_FragColor);\n }\n // gl_FragColor = filterColor(vec4(1.0, 0.0, 0.0, 1.0));\n \n // if(rV < r || rV > 1.0 - r) {\n // gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0);\n // } \n // if(v > 0.9) {\n // gl_FragColor = vec4(0.17647, 0.43921568, 0.2, 1.0);\n // } else if(v < 0.1) {\n // gl_FragColor = vec4(0.17647, 0.43921568, 0.2, 1.0);\n // }\n\n // gl_FragColor = filterColor(gl_FragColor);\n}\n";
19
- var line_vert = "#define LineTypeSolid 0.0\n#define LineTypeDash 1.0\n#define Animate 0.0\n\nattribute float a_Miter;\nattribute vec4 a_Color;\nattribute vec2 a_Size;\nattribute vec3 a_Normal;\nattribute vec3 a_Position;\n\nattribute vec2 a_iconMapUV;\n\n// dash line\nattribute float a_Total_Distance;\nattribute float a_Distance;\n\nuniform mat4 u_ModelMatrix;\nuniform mat4 u_Mvp;\nuniform float u_line_type: 0.0;\nuniform vec4 u_dash_array: [10.0, 5., 0, 0];\nuniform vec4 u_aimate: [ 0, 2., 1.0, 0.2 ];\nuniform float u_icon_step: 100;\n\n#pragma include \"projection\"\n#pragma include \"picking\"\n\nvarying vec4 v_color;\nvarying vec4 v_dash_array;\nvarying vec2 v_normal;\n\nvarying vec4 v_dataset; // \u6570\u636E\u96C6 - distance_ratio/distance/pixelLen/texV\n// texV \u7EBF\u56FE\u5C42 - \u8D34\u56FE\u90E8\u5206\u7684 v \u5750\u6807\uFF08\u7EBF\u7684\u5BBD\u5EA6\u65B9\u5411\uFF09\nvarying vec2 v_iconMapUV;\nuniform float u_linearColor: 0;\n\nuniform float u_opacity: 1.0;\nvarying mat4 styleMappingMat; // \u7528\u4E8E\u5C06\u5728\u9876\u70B9\u7740\u8272\u5668\u4E2D\u8BA1\u7B97\u597D\u7684\u6837\u5F0F\u503C\u4F20\u9012\u7ED9\u7247\u5143\n\n#pragma include \"styleMapping\"\n#pragma include \"styleMappingCalOpacity\"\n\nvoid main() {\n // cal style mapping - \u6570\u636E\u7EB9\u7406\u6620\u5C04\u90E8\u5206\u7684\u8BA1\u7B97\n styleMappingMat = mat4(\n 0.0, 0.0, 0.0, 0.0, // opacity - strokeOpacity - strokeWidth - empty\n 0.0, 0.0, 0.0, 0.0, // strokeR - strokeG - strokeB - strokeA\n 0.0, 0.0, 0.0, 0.0, // offsets[0] - offsets[1]\n 0.0, 0.0, 0.0, 0.0\n );\n\n float rowCount = u_cellTypeLayout[0][0]; // \u5F53\u524D\u7684\u6570\u636E\u7EB9\u7406\u6709\u51E0\u884C\n float columnCount = u_cellTypeLayout[0][1]; // \u5F53\u770B\u5230\u6570\u636E\u7EB9\u7406\u6709\u51E0\u5217\n float columnWidth = 1.0/columnCount; // \u5217\u5BBD\n float rowHeight = 1.0/rowCount; // \u884C\u9AD8\n float cellCount = calCellCount(); // opacity - strokeOpacity - strokeWidth - stroke - offsets\n float id = a_vertexId; // \u7B2Cn\u4E2A\u9876\u70B9\n float cellCurrentRow = floor(id * cellCount / columnCount) + 1.0; // \u8D77\u59CB\u70B9\u5728\u7B2C\u51E0\u884C\n float cellCurrentColumn = mod(id * cellCount, columnCount) + 1.0; // \u8D77\u59CB\u70B9\u5728\u7B2C\u51E0\u5217\n \n // cell \u56FA\u5B9A\u987A\u5E8F opacity -> strokeOpacity -> strokeWidth -> stroke ... \n // \u6309\u987A\u5E8F\u4ECE cell \u4E2D\u53D6\u503C\u3001\u82E5\u6CA1\u6709\u5219\u81EA\u52A8\u5F80\u4E0B\u53D6\u503C\n float textureOffset = 0.0; // \u5728 cell \u4E2D\u53D6\u503C\u7684\u504F\u79FB\u91CF\n\n vec2 opacityAndOffset = calOpacityAndOffset(cellCurrentRow, cellCurrentColumn, columnCount, textureOffset, columnWidth, rowHeight);\n styleMappingMat[0][0] = opacityAndOffset.r;\n textureOffset = opacityAndOffset.g;\n // cal style mapping - \u6570\u636E\u7EB9\u7406\u6620\u5C04\u90E8\u5206\u7684\u8BA1\u7B97\n\n float d_distance_ratio; // \u5F53\u524D\u70B9\u4F4D\u8DDD\u79BB\u5360\u7EBF\u603B\u957F\u7684\u6BD4\u4F8B\n float d_texPixelLen; // \u8D34\u56FE\u7684\u50CF\u7D20\u957F\u5EA6\uFF0C\u6839\u636E\u5730\u56FE\u5C42\u7EA7\u7F29\u653E\n\n v_iconMapUV = a_iconMapUV;\n d_texPixelLen = project_pixel(u_icon_step);\n if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) {\n d_texPixelLen *= 10.0;\n }\n\n if(u_line_type == LineTypeDash) {\n d_distance_ratio = a_Distance / a_Total_Distance;\n v_dash_array = pow(2.0, 20.0 - u_Zoom) * u_dash_array / a_Total_Distance;\n }\n if(u_aimate.x == Animate || u_linearColor == 1.0) {\n d_distance_ratio = a_Distance / a_Total_Distance;\n }\n v_normal = vec2(reverse_offset_normal(a_Normal) * sign(a_Miter));\n\n\n v_color = a_Color;\n\n vec3 size = a_Miter * setPickingSize(a_Size.x) * reverse_offset_normal(a_Normal);\n\n vec2 offset = project_pixel(size.xy);\n\n float lineOffsetWidth = length(offset + offset * sign(a_Miter)); // \u7EBF\u6A2A\u5411\u504F\u79FB\u7684\u8DDD\u79BB\uFF08\u5411\u4E24\u4FA7\u504F\u79FB\u7684\u548C\uFF09\n float linePixelSize = project_pixel(a_Size.x) * 2.0; // \u5B9A\u70B9\u4F4D\u7F6E\u504F\u79FB\uFF0C\u6309\u5730\u56FE\u7B49\u7EA7\u7F29\u653E\u540E\u7684\u8DDD\u79BB \u5355\u4FA7 * 2\n float texV = lineOffsetWidth/linePixelSize; // \u7EBF\u56FE\u5C42\u8D34\u56FE\u90E8\u5206\u7684 v \u5750\u6807\u503C\n\n // \u8BBE\u7F6E\u6570\u636E\u96C6\u7684\u53C2\u6570\n v_dataset.r = d_distance_ratio; // \u5F53\u524D\u70B9\u4F4D\u8DDD\u79BB\u5360\u7EBF\u603B\u957F\u7684\u6BD4\u4F8B\n v_dataset.g = a_Distance; // \u5F53\u524D\u9876\u70B9\u7684\u8DDD\u79BB\n v_dataset.b = d_texPixelLen; // \u8D34\u56FE\u7684\u50CF\u7D20\u957F\u5EA6\uFF0C\u6839\u636E\u5730\u56FE\u5C42\u7EA7\u7F29\u653E\n v_dataset.a = texV; // \u7EBF\u56FE\u5C42\u8D34\u56FE\u90E8\u5206\u7684 v \u5750\u6807\u503C\n\n vec4 project_pos = project_position(vec4(a_Position.xy, 0, 1.0));\n\n // gl_Position = project_common_position_to_clipspace(vec4(project_pos.xy + offset, a_Size.y, 1.0));\n\n if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) { // gaode2.x\n // gl_Position = u_Mvp * (vec4(project_pos.xy + offset, a_Size.y, 1.0));\n gl_Position = u_Mvp * (vec4(project_pos.xy + offset, a_Size.y / 8.0, 1.0)); // \u989D\u5916\u9664 8.0 \u662F\u4E3A\u4E86\u548Cgaode1.x\u7684\u9AD8\u5EA6\u517C\u5BB9\n } else {\n float lineHeight = a_Size.y;\n // \u517C\u5BB9 mapbox \u5728\u7EBF\u9AD8\u5EA6\u4E0A\u7684\u6548\u679C\u8868\u73B0\u57FA\u672C\u4E00\u81F4\n if(u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT || u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT_OFFSET) {\n lineHeight = lineHeight*2.0/pow(2.0, 20.0 - u_Zoom);\n }\n gl_Position = project_common_position_to_clipspace(vec4(project_pos.xy + offset, lineHeight, 1.0));\n }\n\n setPickingColor(a_PickingColor);\n}\n";
20
- var lineStyleObj = {
21
- solid: 0.0,
22
- dash: 1.0
23
- };
24
-
25
- var LineModel = function (_BaseModel) {
26
- _inherits(LineModel, _BaseModel);
27
-
28
- var _super = _createSuper(LineModel);
29
-
30
- function LineModel() {
31
- var _this;
32
-
33
- _classCallCheck(this, LineModel);
34
-
35
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
36
- args[_key] = arguments[_key];
37
- }
38
-
39
- _this = _super.call.apply(_super, [this].concat(args));
40
-
41
- _defineProperty(_assertThisInitialized(_this), "texture", void 0);
42
-
43
- _defineProperty(_assertThisInitialized(_this), "updateTexture", function () {
44
- var createTexture2D = _this.rendererService.createTexture2D;
45
-
46
- if (_this.texture) {
47
- _this.texture.update({
48
- data: _this.iconService.getCanvas()
49
- });
50
-
51
- _this.layer.render();
52
-
53
- return;
54
- }
55
-
56
- _this.texture = createTexture2D({
57
- data: _this.iconService.getCanvas(),
58
- mag: gl.NEAREST,
59
- min: gl.NEAREST,
60
- premultiplyAlpha: false,
61
- width: 1024,
62
- height: _this.iconService.canvasHeight || 128
63
- });
64
- });
65
-
66
- return _this;
67
- }
68
-
69
- _createClass(LineModel, [{
70
- key: "getUninforms",
71
- value: function getUninforms() {
72
- var _ref = this.layer.getLayerConfig(),
73
- opacity = _ref.opacity,
74
- sourceColor = _ref.sourceColor,
75
- targetColor = _ref.targetColor,
76
- _ref$textureBlend = _ref.textureBlend,
77
- textureBlend = _ref$textureBlend === void 0 ? 'normal' : _ref$textureBlend,
78
- _ref$lineType = _ref.lineType,
79
- lineType = _ref$lineType === void 0 ? 'solid' : _ref$lineType,
80
- _ref$dashArray = _ref.dashArray,
81
- dashArray = _ref$dashArray === void 0 ? [10, 5, 0, 0] : _ref$dashArray,
82
- _ref$lineTexture = _ref.lineTexture,
83
- lineTexture = _ref$lineTexture === void 0 ? false : _ref$lineTexture,
84
- _ref$iconStep = _ref.iconStep,
85
- iconStep = _ref$iconStep === void 0 ? 100 : _ref$iconStep;
86
-
87
- if (dashArray.length === 2) {
88
- dashArray.push(0, 0);
89
- }
90
-
91
- if (this.rendererService.getDirty()) {
92
- this.texture.bind();
93
- }
94
-
95
- var useLinearColor = 0;
96
- var sourceColorArr = [0, 0, 0, 0];
97
- var targetColorArr = [0, 0, 0, 0];
98
-
99
- if (sourceColor && targetColor) {
100
- sourceColorArr = rgb2arr(sourceColor);
101
- targetColorArr = rgb2arr(targetColor);
102
- useLinearColor = 1;
103
- }
104
-
105
- if (this.dataTextureTest && this.dataTextureNeedUpdate({
106
- opacity: opacity
107
- })) {
108
- this.judgeStyleAttributes({
109
- opacity: opacity
110
- });
111
- var encodeData = this.layer.getEncodedData();
112
-
113
- var _this$calDataFrame = this.calDataFrame(this.cellLength, encodeData, this.cellProperties),
114
- data = _this$calDataFrame.data,
115
- width = _this$calDataFrame.width,
116
- height = _this$calDataFrame.height;
117
-
118
- this.rowCount = height;
119
- this.dataTexture = this.cellLength > 0 && data.length > 0 ? this.createTexture2D({
120
- flipY: true,
121
- data: data,
122
- format: gl.LUMINANCE,
123
- type: gl.FLOAT,
124
- width: width,
125
- height: height
126
- }) : this.createTexture2D({
127
- flipY: true,
128
- data: [1],
129
- format: gl.LUMINANCE,
130
- type: gl.FLOAT,
131
- width: 1,
132
- height: 1
133
- });
134
- }
135
-
136
- return {
137
- u_dataTexture: this.dataTexture,
138
- u_cellTypeLayout: this.getCellTypeLayout(),
139
- u_opacity: _isNumber(opacity) ? opacity : 1.0,
140
- u_textureBlend: textureBlend === 'normal' ? 0.0 : 1.0,
141
- u_line_type: lineStyleObj[lineType],
142
- u_dash_array: dashArray,
143
- u_texture: this.texture,
144
- u_line_texture: lineTexture ? 1.0 : 0.0,
145
- u_icon_step: iconStep,
146
- u_textSize: [1024, this.iconService.canvasHeight || 128],
147
- u_linearColor: useLinearColor,
148
- u_sourceColor: sourceColorArr,
149
- u_targetColor: targetColorArr
150
- };
151
- }
152
- }, {
153
- key: "getAnimateUniforms",
154
- value: function getAnimateUniforms() {
155
- var _ref2 = this.layer.getLayerConfig(),
156
- animateOption = _ref2.animateOption;
157
-
158
- return {
159
- u_aimate: this.animateOption2Array(animateOption),
160
- u_time: this.layer.getLayerAnimateTime()
161
- };
162
- }
163
- }, {
164
- key: "initModels",
165
- value: function initModels() {
166
- this.updateTexture();
167
- this.iconService.on('imageUpdate', this.updateTexture);
168
- return this.buildModels();
169
- }
170
- }, {
171
- key: "clearModels",
172
- value: function clearModels() {
173
- var _this$texture, _this$dataTexture;
174
-
175
- (_this$texture = this.texture) === null || _this$texture === void 0 ? void 0 : _this$texture.destroy();
176
- (_this$dataTexture = this.dataTexture) === null || _this$dataTexture === void 0 ? void 0 : _this$dataTexture.destroy();
177
- this.iconService.off('imageUpdate', this.updateTexture);
178
- }
179
- }, {
180
- key: "buildModels",
181
- value: function buildModels() {
182
- return [this.layer.buildLayerModel({
183
- moduleName: 'line',
184
- vertexShader: line_vert,
185
- fragmentShader: line_frag,
186
- triangulation: LineTriangulation,
187
- primitive: gl.TRIANGLES,
188
- blend: this.getBlend(),
189
- depth: {
190
- enable: false
191
- }
192
- })];
193
- }
194
- }, {
195
- key: "registerBuiltinAttributes",
196
- value: function registerBuiltinAttributes() {
197
- var _this2 = this;
198
-
199
- var _ref3 = this.layer.getLayerConfig(),
200
- _ref3$lineType = _ref3.lineType,
201
- lineType = _ref3$lineType === void 0 ? 'solid' : _ref3$lineType;
202
-
203
- this.styleAttributeService.registerStyleAttribute({
204
- name: 'distance',
205
- type: AttributeType.Attribute,
206
- descriptor: {
207
- name: 'a_Distance',
208
- buffer: {
209
- usage: gl.STATIC_DRAW,
210
- data: [],
211
- type: gl.FLOAT
212
- },
213
- size: 1,
214
- update: function update(feature, featureIdx, vertex, attributeIdx) {
215
- return [vertex[3]];
216
- }
217
- }
218
- });
219
- this.styleAttributeService.registerStyleAttribute({
220
- name: 'total_distance',
221
- type: AttributeType.Attribute,
222
- descriptor: {
223
- name: 'a_Total_Distance',
224
- buffer: {
225
- usage: gl.STATIC_DRAW,
226
- data: [],
227
- type: gl.FLOAT
228
- },
229
- size: 1,
230
- update: function update(feature, featureIdx, vertex, attributeIdx) {
231
- return [vertex[5]];
232
- }
233
- }
234
- });
235
- this.styleAttributeService.registerStyleAttribute({
236
- name: 'size',
237
- type: AttributeType.Attribute,
238
- descriptor: {
239
- name: 'a_Size',
240
- buffer: {
241
- usage: gl.DYNAMIC_DRAW,
242
- data: [],
243
- type: gl.FLOAT
244
- },
245
- size: 2,
246
- update: function update(feature, featureIdx, vertex, attributeIdx) {
247
- var _feature$size = feature.size,
248
- size = _feature$size === void 0 ? 1 : _feature$size;
249
- return Array.isArray(size) ? [size[0], size[1]] : [size, 0];
250
- }
251
- }
252
- });
253
- this.styleAttributeService.registerStyleAttribute({
254
- name: 'normal',
255
- type: AttributeType.Attribute,
256
- descriptor: {
257
- name: 'a_Normal',
258
- buffer: {
259
- usage: gl.STATIC_DRAW,
260
- data: [],
261
- type: gl.FLOAT
262
- },
263
- size: 3,
264
- update: function update(feature, featureIdx, vertex, attributeIdx, normal) {
265
- return normal;
266
- }
267
- }
268
- });
269
- this.styleAttributeService.registerStyleAttribute({
270
- name: 'miter',
271
- type: AttributeType.Attribute,
272
- descriptor: {
273
- name: 'a_Miter',
274
- buffer: {
275
- usage: gl.STATIC_DRAW,
276
- data: [],
277
- type: gl.FLOAT
278
- },
279
- size: 1,
280
- update: function update(feature, featureIdx, vertex, attributeIdx) {
281
- return [vertex[4]];
282
- }
283
- }
284
- });
285
- this.styleAttributeService.registerStyleAttribute({
286
- name: 'uv',
287
- type: AttributeType.Attribute,
288
- descriptor: {
289
- name: 'a_iconMapUV',
290
- buffer: {
291
- usage: gl.DYNAMIC_DRAW,
292
- data: [],
293
- type: gl.FLOAT
294
- },
295
- size: 2,
296
- update: function update(feature, featureIdx, vertex, attributeIdx) {
297
- var iconMap = _this2.iconService.getIconMap();
298
-
299
- var texture = feature.texture;
300
-
301
- var _ref4 = iconMap[texture] || {
302
- x: 0,
303
- y: 0
304
- },
305
- x = _ref4.x,
306
- y = _ref4.y;
307
-
308
- return [x, y];
309
- }
310
- }
311
- });
312
- }
313
- }, {
314
- key: "loadImage",
315
- value: function loadImage(url) {
316
- return new Promise(function (resolve, reject) {
317
- if (url instanceof HTMLImageElement) {
318
- resolve(url);
319
- return;
320
- }
321
-
322
- var image = new Image();
323
- image.crossOrigin = 'anonymous';
324
-
325
- image.onload = function () {
326
- resolve(image);
327
- };
328
-
329
- image.onerror = function () {
330
- reject(new Error('Could not load image at ' + url));
331
- };
332
-
333
- image.src = url instanceof File ? URL.createObjectURL(url) : url;
334
- });
335
- }
336
- }]);
337
-
338
- return LineModel;
339
- }(BaseModel);
340
-
341
- export { LineModel as default };
342
- //# sourceMappingURL=line.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../src/line/models/line.ts"],"names":["AttributeType","gl","rgb2arr","BaseModel","LineTriangulation","lineStyleObj","solid","dash","LineModel","createTexture2D","rendererService","texture","update","data","iconService","getCanvas","layer","render","mag","NEAREST","min","premultiplyAlpha","width","height","canvasHeight","getLayerConfig","opacity","sourceColor","targetColor","textureBlend","lineType","dashArray","lineTexture","iconStep","length","push","getDirty","bind","useLinearColor","sourceColorArr","targetColorArr","dataTextureTest","dataTextureNeedUpdate","judgeStyleAttributes","encodeData","getEncodedData","calDataFrame","cellLength","cellProperties","rowCount","dataTexture","flipY","format","LUMINANCE","type","FLOAT","u_dataTexture","u_cellTypeLayout","getCellTypeLayout","u_opacity","u_textureBlend","u_line_type","u_dash_array","u_texture","u_line_texture","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","url","Promise","resolve","reject","HTMLImageElement","image","Image","crossOrigin","onload","onerror","Error","src","File","URL","createObjectURL"],"mappings":";;;;;;;;;;;;;AAAA,SACEA,aADF,EAEEC,EAFF,QAUO,eAVP;AAYA,SAASC,OAAT,QAAwB,gBAAxB;AAEA,OAAOC,SAAP,MAAsB,sBAAtB;AAEA,SAASC,iBAAT,QAAkC,0BAAlC;;;AAGA,IAAMC,YAAuC,GAAG;AAC9CC,EAAAA,KAAK,EAAE,GADuC;AAE9CC,EAAAA,IAAI,EAAE;AAFwC,CAAhD;;IAIqBC,S;;;;;;;;;;;;;;;;;;oEA4SK,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,EAAEjB,EAAE,CAACkB,OAFqB;AAG7BC,QAAAA,GAAG,EAAEnB,EAAE,CAACkB,OAHqB;AAI7BE,QAAAA,gBAAgB,EAAE,KAJW;AAK7BC,QAAAA,KAAK,EAAE,IALsB;AAM7BC,QAAAA,MAAM,EAAE,MAAKT,WAAL,CAAiBU,YAAjB,IAAiC;AANZ,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hB;;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;;;WAED,mBAAkBC,GAAlB,EAA+B;AAC7B,aAAO,IAAIC,OAAJ,CAAY,UAACC,OAAD,EAAUC,MAAV,EAAqB;AACtC,YAAIH,GAAG,YAAYI,gBAAnB,EAAqC;AACnCF,UAAAA,OAAO,CAACF,GAAD,CAAP;AACA;AACD;;AACD,YAAMK,KAAK,GAAG,IAAIC,KAAJ,EAAd;AACAD,QAAAA,KAAK,CAACE,WAAN,GAAoB,WAApB;;AACAF,QAAAA,KAAK,CAACG,MAAN,GAAe,YAAM;AACnBN,UAAAA,OAAO,CAACG,KAAD,CAAP;AACD,SAFD;;AAGAA,QAAAA,KAAK,CAACI,OAAN,GAAgB,YAAM;AACpBN,UAAAA,MAAM,CAAC,IAAIO,KAAJ,CAAU,6BAA6BV,GAAvC,CAAD,CAAN;AACD,SAFD;;AAGAK,QAAAA,KAAK,CAACM,GAAN,GAAYX,GAAG,YAAYY,IAAf,GAAsBC,GAAG,CAACC,eAAJ,CAAoBd,GAApB,CAAtB,GAAiDA,GAA7D;AACD,OAdM,CAAP;AAeD;;;;EA1SoC/G,S;;SAAlBK,S","sourcesContent":["import {\n AttributeType,\n gl,\n IAnimateOption,\n IEncodeFeature,\n IImage,\n ILayerConfig,\n IModel,\n IModelUniform,\n ITexture2D,\n} from '@antv/l7-core';\n\nimport { rgb2arr } from '@antv/l7-utils';\nimport { isNumber } from 'lodash';\nimport BaseModel from '../../core/BaseModel';\nimport { ILineLayerStyleOptions, lineStyleType } from '../../core/interface';\nimport { LineTriangulation } from '../../core/triangulation';\nimport line_frag from '../shaders/line_frag.glsl';\nimport line_vert from '../shaders/line_vert.glsl';\nconst lineStyleObj: { [key: string]: number } = {\n solid: 0.0,\n dash: 1.0,\n};\nexport default class LineModel extends BaseModel {\n protected texture: ITexture2D;\n public getUninforms(): IModelUniform {\n const {\n opacity,\n sourceColor,\n targetColor,\n textureBlend = 'normal',\n lineType = 'solid',\n dashArray = [10, 5, 0, 0],\n lineTexture = false,\n iconStep = 100,\n } = this.layer.getLayerConfig() as ILineLayerStyleOptions;\n if (dashArray.length === 2) {\n dashArray.push(0, 0);\n }\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_dataTexture: this.dataTexture, // 数据纹理 - 有数据映射的时候纹理中带数据,若没有任何数据映射时纹理是 [1]\n u_cellTypeLayout: this.getCellTypeLayout(),\n // u_opacity: opacity === undefined ? 1 : opacity,\n u_opacity: isNumber(opacity) ? opacity : 1.0,\n u_textureBlend: textureBlend === 'normal' ? 0.0 : 1.0,\n u_line_type: lineStyleObj[lineType],\n u_dash_array: dashArray,\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 // 渐变色支持参数\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 // const { createTexture2D } = this.rendererService;\n // this.texture = createTexture2D({\n // height: 0,\n // width: 0,\n // });\n // let url = 'https://gw-office.alipayobjects.com/bmw-prod/e91c3630-b79e-45a3-a2b9-feee4b4ccd41.svg'\n // this.loadImage(url).then((img) => {\n // this.texture = createTexture2D({\n // data: img as HTMLImageElement,\n // width: (img as HTMLImageElement).width,\n // height: (img as HTMLImageElement).height,\n // });\n // this.layerService.renderLayers();\n // })\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: 'line',\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 // const lineType = this\n // point layer size;\n const {\n lineType = 'solid',\n } = this.layer.getLayerConfig() as ILineLayerStyleOptions;\n // if (lineType === 'dash') {\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\n private loadImage(url: IImage) {\n return new Promise((resolve, reject) => {\n if (url instanceof HTMLImageElement) {\n resolve(url);\n return;\n }\n const image = new Image();\n image.crossOrigin = 'anonymous';\n image.onload = () => {\n resolve(image);\n };\n image.onerror = () => {\n reject(new Error('Could not load image at ' + url));\n };\n image.src = url instanceof File ? URL.createObjectURL(url) : url;\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":"line.js"}
@@ -1,13 +0,0 @@
1
- import { ILayer, ILayerPlugin, IStyleAttributeService } from '@antv/l7-core';
2
- import 'reflect-metadata';
3
- export default class DataMappingPlugin implements ILayerPlugin {
4
- private readonly configService;
5
- private readonly mapService;
6
- private readonly fontService;
7
- apply(layer: ILayer, { styleAttributeService, }: {
8
- styleAttributeService: IStyleAttributeService;
9
- }): void;
10
- private generateMaping;
11
- private mapping;
12
- private applyAttributeMapping;
13
- }
@@ -1,199 +0,0 @@
1
- import _initializerDefineProperty from "@babel/runtime/helpers/initializerDefineProperty";
2
- import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
3
- import _createClass from "@babel/runtime/helpers/createClass";
4
- import _defineProperty from "@babel/runtime/helpers/defineProperty";
5
- import _applyDecoratedDescriptor from "@babel/runtime/helpers/applyDecoratedDescriptor";
6
- import _initializerWarningHelper from "@babel/runtime/helpers/initializerWarningHelper";
7
- import _cloneDeep from "lodash/cloneDeep";
8
-
9
- var _dec, _dec2, _dec3, _dec4, _class, _class2, _descriptor, _descriptor2, _descriptor3;
10
-
11
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
12
-
13
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
14
-
15
- import { TYPES } from '@antv/l7-core';
16
- import { rgb2arr } from '@antv/l7-utils';
17
- import { inject, injectable } from 'inversify';
18
- import 'reflect-metadata';
19
- var DataMappingPlugin = (_dec = injectable(), _dec2 = inject(TYPES.IGlobalConfigService), _dec3 = inject(TYPES.IMapService), _dec4 = inject(TYPES.IFontService), _dec(_class = (_class2 = function () {
20
- function DataMappingPlugin() {
21
- _classCallCheck(this, DataMappingPlugin);
22
-
23
- _initializerDefineProperty(this, "configService", _descriptor, this);
24
-
25
- _initializerDefineProperty(this, "mapService", _descriptor2, this);
26
-
27
- _initializerDefineProperty(this, "fontService", _descriptor3, this);
28
- }
29
-
30
- _createClass(DataMappingPlugin, [{
31
- key: "apply",
32
- value: function apply(layer, _ref) {
33
- var _this = this;
34
-
35
- var styleAttributeService = _ref.styleAttributeService;
36
- layer.hooks.init.tap('DataMappingPlugin', function () {
37
- _this.generateMaping(layer, {
38
- styleAttributeService: styleAttributeService
39
- });
40
- });
41
- layer.hooks.beforeRenderData.tap('DataMappingPlugin', function () {
42
- layer.dataState.dataMappingNeedUpdate = false;
43
-
44
- _this.generateMaping(layer, {
45
- styleAttributeService: styleAttributeService
46
- });
47
-
48
- return true;
49
- });
50
- layer.hooks.beforeRender.tap('DataMappingPlugin', function () {
51
- if (layer.layerModelNeedUpdate) {
52
- return;
53
- }
54
-
55
- var attributes = styleAttributeService.getLayerStyleAttributes() || [];
56
- var filter = styleAttributeService.getLayerStyleAttribute('filter');
57
- var dataArray = layer.getSource().data.dataArray;
58
- var attributesToRemapping = attributes.filter(function (attribute) {
59
- return attribute.needRemapping;
60
- });
61
- var filterData = dataArray;
62
-
63
- if (filter !== null && filter !== void 0 && filter.needRemapping && filter !== null && filter !== void 0 && filter.scale) {
64
- filterData = dataArray.filter(function (record) {
65
- return _this.applyAttributeMapping(filter, record)[0];
66
- });
67
- }
68
-
69
- if (attributesToRemapping.length) {
70
- if (filter !== null && filter !== void 0 && filter.needRemapping) {
71
- layer.setEncodedData(_this.mapping(attributes, filterData));
72
- filter.needRemapping = false;
73
- } else {
74
- layer.setEncodedData(_this.mapping(attributesToRemapping, filterData, layer.getEncodedData()));
75
- }
76
-
77
- layer.emit('remapping', null);
78
- }
79
- });
80
- }
81
- }, {
82
- key: "generateMaping",
83
- value: function generateMaping(layer, _ref2) {
84
- var _this2 = this;
85
-
86
- var styleAttributeService = _ref2.styleAttributeService;
87
- var attributes = styleAttributeService.getLayerStyleAttributes() || [];
88
- var filter = styleAttributeService.getLayerStyleAttribute('filter');
89
- var dataArray = layer.getSource().data.dataArray;
90
- var filterData = dataArray;
91
-
92
- if (filter !== null && filter !== void 0 && filter.scale) {
93
- filterData = dataArray.filter(function (record) {
94
- return _this2.applyAttributeMapping(filter, record)[0];
95
- });
96
- }
97
-
98
- layer.setEncodedData(this.mapping(attributes, filterData));
99
- }
100
- }, {
101
- key: "mapping",
102
- value: function mapping(attributes, data, predata) {
103
- var _this3 = this;
104
-
105
- var mappedData = data.map(function (record, i) {
106
- var preRecord = predata ? predata[i] : {};
107
-
108
- var encodeRecord = _objectSpread({
109
- id: record._id,
110
- coordinates: record.coordinates
111
- }, preRecord);
112
-
113
- attributes.filter(function (attribute) {
114
- return attribute.scale !== undefined;
115
- }).forEach(function (attribute) {
116
- var values = _this3.applyAttributeMapping(attribute, record);
117
-
118
- attribute.needRemapping = false;
119
-
120
- if (attribute.name === 'color') {
121
- values = values.map(function (c) {
122
- return rgb2arr(c);
123
- });
124
- }
125
-
126
- encodeRecord[attribute.name] = Array.isArray(values) && values.length === 1 ? values[0] : values;
127
-
128
- if (attribute.name === 'shape') {
129
- encodeRecord.shape = _this3.fontService.getIconFontKey(encodeRecord[attribute.name]);
130
- }
131
- });
132
- return encodeRecord;
133
- });
134
-
135
- if (mappedData.length > 0 && this.mapService.version === 'GAODE2.x') {
136
- if (typeof mappedData[0].coordinates[0] === 'number') {
137
- mappedData.filter(function (d) {
138
- return !d.originCoordinates;
139
- }).map(function (d) {
140
- d.version = 'GAODE2.x';
141
- d.originCoordinates = _cloneDeep(d.coordinates);
142
- d.coordinates = _this3.mapService.lngLatToCoord(d.coordinates);
143
- });
144
- } else {
145
- mappedData.filter(function (d) {
146
- return !d.originCoordinates;
147
- }).map(function (d) {
148
- d.version = 'GAODE2.x';
149
- d.originCoordinates = _cloneDeep(d.coordinates);
150
- d.coordinates = _this3.mapService.lngLatToCoords(d.coordinates);
151
- });
152
- }
153
- }
154
-
155
- return mappedData;
156
- }
157
- }, {
158
- key: "applyAttributeMapping",
159
- value: function applyAttributeMapping(attribute, record) {
160
- var _attribute$scale;
161
-
162
- if (!attribute.scale) {
163
- return [];
164
- }
165
-
166
- var scalers = (attribute === null || attribute === void 0 ? void 0 : (_attribute$scale = attribute.scale) === null || _attribute$scale === void 0 ? void 0 : _attribute$scale.scalers) || [];
167
- var params = [];
168
- scalers.forEach(function (_ref3) {
169
- var _attribute$scale2;
170
-
171
- var field = _ref3.field;
172
-
173
- if (record.hasOwnProperty(field) || ((_attribute$scale2 = attribute.scale) === null || _attribute$scale2 === void 0 ? void 0 : _attribute$scale2.type) === 'variable') {
174
- params.push(record[field]);
175
- }
176
- });
177
- return attribute.mapping ? attribute.mapping(params) : [];
178
- }
179
- }]);
180
-
181
- return DataMappingPlugin;
182
- }(), (_descriptor = _applyDecoratedDescriptor(_class2.prototype, "configService", [_dec2], {
183
- configurable: true,
184
- enumerable: true,
185
- writable: true,
186
- initializer: null
187
- }), _descriptor2 = _applyDecoratedDescriptor(_class2.prototype, "mapService", [_dec3], {
188
- configurable: true,
189
- enumerable: true,
190
- writable: true,
191
- initializer: null
192
- }), _descriptor3 = _applyDecoratedDescriptor(_class2.prototype, "fontService", [_dec4], {
193
- configurable: true,
194
- enumerable: true,
195
- writable: true,
196
- initializer: null
197
- })), _class2)) || _class);
198
- export { DataMappingPlugin as default };
199
- //# sourceMappingURL=DataMappingPlugin.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/plugins/DataMappingPlugin.ts"],"names":["TYPES","rgb2arr","inject","injectable","DataMappingPlugin","IGlobalConfigService","IMapService","IFontService","layer","styleAttributeService","hooks","init","tap","generateMaping","beforeRenderData","dataState","dataMappingNeedUpdate","beforeRender","layerModelNeedUpdate","attributes","getLayerStyleAttributes","filter","getLayerStyleAttribute","dataArray","getSource","data","attributesToRemapping","attribute","needRemapping","filterData","scale","record","applyAttributeMapping","length","setEncodedData","mapping","getEncodedData","emit","predata","mappedData","map","i","preRecord","encodeRecord","id","_id","coordinates","undefined","forEach","values","name","c","Array","isArray","shape","fontService","getIconFontKey","mapService","version","d","originCoordinates","lngLatToCoord","lngLatToCoords","scalers","params","field","hasOwnProperty","type","push"],"mappings":";;;;;;;;;;;;;;AAAA,SAWEA,KAXF,QAYO,eAZP;AAaA,SAASC,OAAT,QAAuC,gBAAvC;AACA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K,cAAhB,CAA+BH,CAAC,CAACb,WAAjC,CAAhB;AACD,WATH;AAUD;AACF;;AAED,aAAOP,UAAP;AACD;;;WAED,+BACEZ,SADF,EAEEI,MAFF,EAGE;AAAA;;AACA,UAAI,CAACJ,SAAS,CAACG,KAAf,EAAsB;AACpB,eAAO,EAAP;AACD;;AACD,UAAMiC,OAAO,GAAG,CAAApC,SAAS,SAAT,IAAAA,SAAS,WAAT,gCAAAA,SAAS,CAAEG,KAAX,sEAAkBiC,OAAlB,KAA6B,EAA7C;AACA,UAAMC,MAAiB,GAAG,EAA1B;AAEAD,MAAAA,OAAO,CAACf,OAAR,CAAgB,iBAAe;AAAA;;AAAA,YAAZiB,KAAY,SAAZA,KAAY;;AAC7B,YACElC,MAAM,CAACmC,cAAP,CAAsBD,KAAtB,KACA,sBAAAtC,SAAS,CAACG,KAAV,wEAAiBqC,IAAjB,MAA0B,UAF5B,EAGE;AAEAH,UAAAA,MAAM,CAACI,IAAP,CAAYrC,MAAM,CAACkC,KAAD,CAAlB;AACD;AACF,OARD;AAYA,aAAOtC,SAAS,CAACQ,OAAV,GAAoBR,SAAS,CAACQ,OAAV,CAAkB6B,MAAlB,CAApB,GAAgD,EAAvD;AACD;;;;;;;;;;;;;;;;;;;;SA1LkB5D,iB","sourcesContent":["import {\n IEncodeFeature,\n IFontService,\n IGlobalConfigService,\n ILayer,\n ILayerPlugin,\n ILngLat,\n IMapService,\n IParseDataItem,\n IStyleAttribute,\n IStyleAttributeService,\n TYPES,\n} from '@antv/l7-core';\nimport { rgb2arr, unProjectFlat } from '@antv/l7-utils';\nimport { inject, injectable } from 'inversify';\nimport { cloneDeep } from 'lodash';\nimport 'reflect-metadata';\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 attributes = styleAttributeService.getLayerStyleAttributes() || [];\n const filter = styleAttributeService.getLayerStyleAttribute('filter');\n const { dataArray } = layer.getSource().data;\n const attributesToRemapping = attributes.filter(\n (attribute) => attribute.needRemapping, // 如果filter变化\n );\n let filterData = dataArray;\n // 数据过滤完 再执行数据映射\n if (filter?.needRemapping && filter?.scale) {\n filterData = dataArray.filter((record: IParseDataItem) => {\n return this.applyAttributeMapping(filter, record)[0];\n });\n }\n if (attributesToRemapping.length) {\n // 过滤数据\n if (filter?.needRemapping) {\n layer.setEncodedData(this.mapping(attributes, filterData));\n filter.needRemapping = false;\n } else {\n layer.setEncodedData(\n this.mapping(\n attributesToRemapping,\n filterData,\n layer.getEncodedData(),\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 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)[0];\n });\n }\n layer.setEncodedData(this.mapping(attributes, filterData));\n }\n\n private mapping(\n attributes: IStyleAttribute[],\n data: IParseDataItem[],\n predata?: IEncodeFeature[],\n ): IEncodeFeature[] {\n // console.log('data', data)\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 // console.log('attributes', attributes)\n attributes\n .filter((attribute) => attribute.scale !== undefined)\n .forEach((attribute: IStyleAttribute) => {\n // console.log('attribute', attribute)\n // console.log('record', record)\n let values = this.applyAttributeMapping(attribute, record);\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 return encodeRecord;\n }) as IEncodeFeature[];\n // console.log('mappedData', mappedData)\n\n // 根据地图的类型判断是否需要对点位数据进行处理, 若是高德2.0则需要对坐标进行相对偏移\n if (mappedData.length > 0 && this.mapService.version === 'GAODE2.x') {\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 = '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.lngLatToCoord(unProjectFlat(d.coordinates));\n });\n } else {\n // 连续的线、面数据\n // @ts-ignore\n mappedData\n // TODO: 避免经纬度被重复计算导致坐标位置偏移\n .filter((d) => !d.originCoordinates)\n .map((d) => {\n d.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 });\n }\n }\n // console.log('mappedData', mappedData)\n return mappedData;\n }\n\n private applyAttributeMapping(\n attribute: IStyleAttribute,\n record: { [key: string]: unknown },\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 // console.log('mapping',attribute.mapping ? attribute.mapping(params) : [])\n return attribute.mapping ? attribute.mapping(params) : [];\n }\n}\n"],"file":"DataMappingPlugin.js"}
@@ -1,7 +0,0 @@
1
- import { ILayer, ILayerPlugin, IMapService } from '@antv/l7-core';
2
- import 'reflect-metadata';
3
- export default class DataSourcePlugin implements ILayerPlugin {
4
- protected mapService: IMapService;
5
- apply(layer: ILayer): void;
6
- private updateClusterData;
7
- }