@antv/l7-layers 2.9.15 → 2.9.16

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 (218) hide show
  1. package/LICENSE.md +1 -1
  2. package/es/core/BaseLayer.d.ts +4 -2
  3. package/es/core/BaseLayer.js +47 -21
  4. package/es/core/BaseLayer.js.map +1 -1
  5. package/es/core/BaseModel.d.ts +2 -1
  6. package/es/core/BaseModel.js +3 -0
  7. package/es/core/BaseModel.js.map +1 -1
  8. package/es/core/interface.d.ts +14 -1
  9. package/es/core/interface.js.map +1 -1
  10. package/es/image/models/image.js.map +1 -1
  11. package/es/line/index.d.ts +1 -1
  12. package/es/line/index.js +13 -1
  13. package/es/line/index.js.map +1 -1
  14. package/es/line/models/earthArc_3d.d.ts +17 -0
  15. package/es/line/models/earthArc_3d.js +311 -0
  16. package/es/line/models/earthArc_3d.js.map +1 -0
  17. package/es/line/models/half.d.ts +18 -0
  18. package/es/line/models/half.js +244 -0
  19. package/es/line/models/half.js.map +1 -0
  20. package/es/line/models/index.d.ts +1 -1
  21. package/es/line/models/index.js +9 -1
  22. package/es/line/models/index.js.map +1 -1
  23. package/es/line/models/tile.d.ts +20 -0
  24. package/es/line/models/tile.js +327 -0
  25. package/es/line/models/tile.js.map +1 -0
  26. package/es/plugins/DataMappingPlugin.js +1 -1
  27. package/es/plugins/DataMappingPlugin.js.map +1 -1
  28. package/es/plugins/DataSourcePlugin.js +7 -6
  29. package/es/plugins/DataSourcePlugin.js.map +1 -1
  30. package/es/plugins/FeatureScalePlugin.js +35 -9
  31. package/es/plugins/FeatureScalePlugin.js.map +1 -1
  32. package/es/plugins/ShaderUniformPlugin.js +3 -1
  33. package/es/plugins/ShaderUniformPlugin.js.map +1 -1
  34. package/es/point/index.d.ts +1 -1
  35. package/es/point/index.js +10 -2
  36. package/es/point/index.js.map +1 -1
  37. package/es/point/models/earthExtrude.d.ts +24 -0
  38. package/es/point/models/earthExtrude.js +259 -0
  39. package/es/point/models/earthExtrude.js.map +1 -0
  40. package/es/point/models/earthFill.d.ts +20 -0
  41. package/es/point/models/earthFill.js +255 -0
  42. package/es/point/models/earthFill.js.map +1 -0
  43. package/es/point/models/extrude.d.ts +0 -1
  44. package/es/point/models/extrude.js +2 -10
  45. package/es/point/models/extrude.js.map +1 -1
  46. package/es/point/models/fill.d.ts +8 -1
  47. package/es/point/models/fill.js +55 -75
  48. package/es/point/models/fill.js.map +1 -1
  49. package/es/point/models/index.d.ts +1 -1
  50. package/es/point/models/index.js +9 -1
  51. package/es/point/models/index.js.map +1 -1
  52. package/es/point/models/radar.js +2 -6
  53. package/es/point/models/radar.js.map +1 -1
  54. package/es/point/models/tile.d.ts +31 -0
  55. package/es/point/models/tile.js +291 -0
  56. package/es/point/models/tile.js.map +1 -0
  57. package/es/polygon/index.js +6 -0
  58. package/es/polygon/index.js.map +1 -1
  59. package/es/polygon/models/index.d.ts +1 -1
  60. package/es/polygon/models/index.js +5 -1
  61. package/es/polygon/models/index.js.map +1 -1
  62. package/es/polygon/models/tile.d.ts +16 -0
  63. package/es/polygon/models/tile.js +137 -0
  64. package/es/polygon/models/tile.js.map +1 -0
  65. package/es/raster/index.d.ts +2 -2
  66. package/es/raster/index.js +4 -4
  67. package/es/raster/index.js.map +1 -1
  68. package/es/raster/models/index.js +1 -1
  69. package/es/raster/models/index.js.map +1 -1
  70. package/es/raster/models/raster.d.ts +2 -0
  71. package/es/raster/models/raster.js +24 -12
  72. package/es/raster/models/raster.js.map +1 -1
  73. package/es/tile/interface.d.ts +28 -0
  74. package/es/tile/interface.js +2 -0
  75. package/es/tile/interface.js.map +1 -0
  76. package/es/tile/manager/tileConfigManager.d.ts +17 -0
  77. package/es/tile/manager/tileConfigManager.js +123 -0
  78. package/es/tile/manager/tileConfigManager.js.map +1 -0
  79. package/es/tile/manager/tileLayerManager.d.ts +35 -0
  80. package/es/tile/manager/tileLayerManager.js +297 -0
  81. package/es/tile/manager/tileLayerManager.js.map +1 -0
  82. package/es/tile/manager/tilePickerManager.d.ts +21 -0
  83. package/es/tile/manager/tilePickerManager.js +189 -0
  84. package/es/tile/manager/tilePickerManager.js.map +1 -0
  85. package/es/tile/models/tileModel.d.ts +8 -0
  86. package/es/tile/models/tileModel.js +61 -0
  87. package/es/tile/models/tileModel.js.map +1 -0
  88. package/es/tile/tileFactory/base.d.ts +44 -0
  89. package/es/tile/tileFactory/base.js +423 -0
  90. package/es/tile/tileFactory/base.js.map +1 -0
  91. package/es/tile/tileFactory/index.d.ts +5 -0
  92. package/es/tile/tileFactory/index.js +30 -0
  93. package/es/tile/tileFactory/index.js.map +1 -0
  94. package/es/tile/tileFactory/line.d.ts +12 -0
  95. package/es/tile/tileFactory/line.js +65 -0
  96. package/es/tile/tileFactory/line.js.map +1 -0
  97. package/es/tile/tileFactory/point.d.ts +12 -0
  98. package/es/tile/tileFactory/point.js +65 -0
  99. package/es/tile/tileFactory/point.js.map +1 -0
  100. package/es/tile/tileFactory/polygon.d.ts +12 -0
  101. package/es/tile/tileFactory/polygon.js +65 -0
  102. package/es/tile/tileFactory/polygon.js.map +1 -0
  103. package/es/tile/tileFactory/raster.d.ts +12 -0
  104. package/es/tile/tileFactory/raster.js +61 -0
  105. package/es/tile/tileFactory/raster.js.map +1 -0
  106. package/es/tile/tileFactory/rasterData.d.ts +12 -0
  107. package/es/tile/tileFactory/rasterData.js +86 -0
  108. package/es/tile/tileFactory/rasterData.js.map +1 -0
  109. package/es/tile/tileFactory/rasterDataLayer.d.ts +19 -0
  110. package/es/{core/LayerGroup.js → tile/tileFactory/rasterDataLayer.js} +39 -32
  111. package/es/tile/tileFactory/rasterDataLayer.js.map +1 -0
  112. package/es/tile/tileFactory/vectorLayer.d.ts +27 -0
  113. package/es/tile/tileFactory/vectorLayer.js +131 -0
  114. package/es/tile/tileFactory/vectorLayer.js.map +1 -0
  115. package/es/tile/tileLayer/baseTileLayer.d.ts +47 -0
  116. package/es/tile/tileLayer/baseTileLayer.js +409 -0
  117. package/es/tile/tileLayer/baseTileLayer.js.map +1 -0
  118. package/es/tile/tmsTileLayer.d.ts +7 -0
  119. package/es/tile/tmsTileLayer.js +100 -0
  120. package/es/tile/tmsTileLayer.js.map +1 -0
  121. package/es/tile/utils.d.ts +11 -0
  122. package/es/tile/utils.js +125 -0
  123. package/es/tile/utils.js.map +1 -0
  124. package/lib/core/BaseLayer.js +45 -20
  125. package/lib/core/BaseLayer.js.map +1 -1
  126. package/lib/core/BaseModel.js +2 -0
  127. package/lib/core/BaseModel.js.map +1 -1
  128. package/lib/core/interface.js.map +1 -1
  129. package/lib/image/models/image.js.map +1 -1
  130. package/lib/line/index.js +13 -1
  131. package/lib/line/index.js.map +1 -1
  132. package/lib/line/models/earthArc_3d.js +328 -0
  133. package/lib/line/models/earthArc_3d.js.map +1 -0
  134. package/lib/line/models/half.js +260 -0
  135. package/lib/line/models/half.js.map +1 -0
  136. package/lib/line/models/index.js +13 -1
  137. package/lib/line/models/index.js.map +1 -1
  138. package/lib/line/models/tile.js +342 -0
  139. package/lib/line/models/tile.js.map +1 -0
  140. package/lib/plugins/DataMappingPlugin.js +1 -1
  141. package/lib/plugins/DataMappingPlugin.js.map +1 -1
  142. package/lib/plugins/DataSourcePlugin.js +7 -6
  143. package/lib/plugins/DataSourcePlugin.js.map +1 -1
  144. package/lib/plugins/FeatureScalePlugin.js +35 -9
  145. package/lib/plugins/FeatureScalePlugin.js.map +1 -1
  146. package/lib/plugins/ShaderUniformPlugin.js +3 -1
  147. package/lib/plugins/ShaderUniformPlugin.js.map +1 -1
  148. package/lib/point/index.js +10 -2
  149. package/lib/point/index.js.map +1 -1
  150. package/lib/point/models/earthExtrude.js +277 -0
  151. package/lib/point/models/earthExtrude.js.map +1 -0
  152. package/lib/point/models/earthFill.js +291 -0
  153. package/lib/point/models/earthFill.js.map +1 -0
  154. package/lib/point/models/extrude.js +2 -11
  155. package/lib/point/models/extrude.js.map +1 -1
  156. package/lib/point/models/fill.js +51 -93
  157. package/lib/point/models/fill.js.map +1 -1
  158. package/lib/point/models/index.js +13 -1
  159. package/lib/point/models/index.js.map +1 -1
  160. package/lib/point/models/radar.js +1 -5
  161. package/lib/point/models/radar.js.map +1 -1
  162. package/lib/point/models/tile.js +308 -0
  163. package/lib/point/models/tile.js.map +1 -0
  164. package/lib/polygon/index.js +6 -0
  165. package/lib/polygon/index.js.map +1 -1
  166. package/lib/polygon/models/index.js +7 -1
  167. package/lib/polygon/models/index.js.map +1 -1
  168. package/lib/polygon/models/tile.js +152 -0
  169. package/lib/polygon/models/tile.js.map +1 -0
  170. package/lib/raster/index.js +4 -4
  171. package/lib/raster/index.js.map +1 -1
  172. package/lib/raster/models/index.js +2 -2
  173. package/lib/raster/models/index.js.map +1 -1
  174. package/lib/raster/models/raster.js +24 -12
  175. package/lib/raster/models/raster.js.map +1 -1
  176. package/lib/tile/interface.js +2 -0
  177. package/lib/tile/interface.js.map +1 -0
  178. package/lib/tile/manager/tileConfigManager.js +134 -0
  179. package/lib/tile/manager/tileConfigManager.js.map +1 -0
  180. package/lib/tile/manager/tileLayerManager.js +305 -0
  181. package/lib/tile/manager/tileLayerManager.js.map +1 -0
  182. package/lib/tile/manager/tilePickerManager.js +195 -0
  183. package/lib/tile/manager/tilePickerManager.js.map +1 -0
  184. package/lib/tile/models/tileModel.js +73 -0
  185. package/lib/tile/models/tileModel.js.map +1 -0
  186. package/lib/tile/tileFactory/base.js +436 -0
  187. package/lib/tile/tileFactory/base.js.map +1 -0
  188. package/lib/tile/tileFactory/index.js +60 -0
  189. package/lib/tile/tileFactory/index.js.map +1 -0
  190. package/lib/tile/tileFactory/line.js +76 -0
  191. package/lib/tile/tileFactory/line.js.map +1 -0
  192. package/lib/tile/tileFactory/point.js +76 -0
  193. package/lib/tile/tileFactory/point.js.map +1 -0
  194. package/lib/tile/tileFactory/polygon.js +76 -0
  195. package/lib/tile/tileFactory/polygon.js.map +1 -0
  196. package/lib/tile/tileFactory/raster.js +74 -0
  197. package/lib/tile/tileFactory/raster.js.map +1 -0
  198. package/lib/tile/tileFactory/rasterData.js +99 -0
  199. package/lib/tile/tileFactory/rasterData.js.map +1 -0
  200. package/lib/{core/LayerGroup.js → tile/tileFactory/rasterDataLayer.js} +40 -32
  201. package/lib/tile/tileFactory/rasterDataLayer.js.map +1 -0
  202. package/lib/tile/tileFactory/vectorLayer.js +145 -0
  203. package/lib/tile/tileFactory/vectorLayer.js.map +1 -0
  204. package/lib/tile/tileLayer/baseTileLayer.js +407 -0
  205. package/lib/tile/tileLayer/baseTileLayer.js.map +1 -0
  206. package/lib/tile/tmsTileLayer.js +116 -0
  207. package/lib/tile/tmsTileLayer.js.map +1 -0
  208. package/lib/tile/utils.js +147 -0
  209. package/lib/tile/utils.js.map +1 -0
  210. package/package.json +8 -6
  211. package/es/core/LayerGroup.d.ts +0 -9
  212. package/es/core/LayerGroup.js.map +0 -1
  213. package/es/raster/models/raste-tile.d.ts +0 -23
  214. package/es/raster/models/raste-tile.js +0 -285
  215. package/es/raster/models/raste-tile.js.map +0 -1
  216. package/lib/core/LayerGroup.js.map +0 -1
  217. package/lib/raster/models/raste-tile.js +0 -294
  218. package/lib/raster/models/raste-tile.js.map +0 -1
@@ -0,0 +1,342 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports.default = void 0;
9
+
10
+ var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
11
+
12
+ var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
13
+
14
+ var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
15
+
16
+ var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
17
+
18
+ var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
19
+
20
+ var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
21
+
22
+ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
23
+
24
+ var _l7Core = require("@antv/l7-core");
25
+
26
+ var _l7Utils = require("@antv/l7-utils");
27
+
28
+ var _BaseModel2 = _interopRequireDefault(require("../../core/BaseModel"));
29
+
30
+ var _triangulation = require("../../core/triangulation");
31
+
32
+ function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2.default)(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2.default)(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2.default)(this, result); }; }
33
+
34
+ function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
35
+
36
+ var line_tile_frag = "#define LineTexture 1.0\nuniform float u_blur : 0.99;\nuniform float u_opacity : 1.0;\nuniform float u_textureBlend;\n\nuniform float u_borderWidth: 0.0;\nuniform vec4 u_borderColor;\nvarying vec4 v_color;\n\n// line texture\nuniform float u_line_texture;\nuniform sampler2D u_texture;\nuniform vec2 u_textSize;\n\nvarying vec2 v_iconMapUV;\n\n#pragma include \"picking\"\n\nvarying mat4 styleMappingMat;\n\nvoid main() {\n float opacity = styleMappingMat[0][0];\n float d_distance_ratio = styleMappingMat[3].r; // \u5F53\u524D\u70B9\u4F4D\u8DDD\u79BB\u5360\u7EBF\u603B\u957F\u7684\u6BD4\u4F8B\n gl_FragColor = v_color;\n // anti-alias\n // float blur = 1.0 - smoothstep(u_blur, 1., length(v_normal.xy));\n gl_FragColor.a *= opacity; // \u5168\u5C40\u900F\u660E\u5EA6\n\n\n if(u_line_texture == LineTexture) { // while load texture\n float aDistance = styleMappingMat[3].g; // \u5F53\u524D\u9876\u70B9\u7684\u8DDD\u79BB\n float d_texPixelLen = styleMappingMat[3].b; // \u8D34\u56FE\u7684\u50CF\u7D20\u957F\u5EA6\uFF0C\u6839\u636E\u5730\u56FE\u5C42\u7EA7\u7F29\u653E\n float u = fract(mod(aDistance, d_texPixelLen)/d_texPixelLen);\n float v = styleMappingMat[3].a; // \u7EBF\u56FE\u5C42\u8D34\u56FE\u90E8\u5206\u7684 v \u5750\u6807\u503C\n\n // v = max(smoothstep(0.95, 1.0, v), v);\n vec2 uv= v_iconMapUV / u_textSize + vec2(u, v) / u_textSize * 64.;\n \n // gl_FragColor = filterColor(gl_FragColor + texture2D(u_texture, vec2(u, v)));\n // gl_FragColor = filterColor(gl_FragColor + texture2D(u_texture, uv));\n vec4 pattern = texture2D(u_texture, uv);\n\n if(u_textureBlend == 0.0) { // normal\n pattern.a = 0.0;\n gl_FragColor += pattern;\n } else { // replace\n pattern.a *= opacity;\n if(gl_FragColor.a <= 0.0) {\n pattern.a = 0.0;\n }\n gl_FragColor = pattern;\n }\n } \n\n float v = styleMappingMat[3].a;\n float borderWidth = min(0.5, u_borderWidth);\n // \u7ED8\u5236 border\n if(borderWidth > 0.01) {\n float borderOuterWidth = borderWidth/2.0;\n\n if(v >= 1.0 - borderWidth || v <= borderWidth) {\n if(v > borderWidth) {\n float linear = smoothstep(0.0, 1.0, (v - (1.0 - borderWidth))/borderWidth);\n gl_FragColor.rgb = mix(gl_FragColor.rgb, u_borderColor.rgb, linear);\n } else if(v <= borderWidth) {\n float linear = smoothstep(0.0, 1.0, v/borderWidth);\n gl_FragColor.rgb = mix(u_borderColor.rgb, gl_FragColor.rgb, linear);\n }\n }\n\n if(v < borderOuterWidth) {\n gl_FragColor.a = mix(0.0, gl_FragColor.a, v/borderOuterWidth);\n } else if(v > 1.0 - borderOuterWidth) {\n gl_FragColor.a = mix(gl_FragColor.a, 0.0, (v - (1.0 - borderOuterWidth))/borderOuterWidth);\n }\n }\n\n gl_FragColor = filterColor(gl_FragColor);\n}\n";
37
+ var line_tile_vert = "\nattribute float a_Miter;\nattribute vec4 a_Color;\nattribute vec2 a_Size;\nattribute vec3 a_Normal;\nattribute vec3 a_Position;\n\nattribute vec2 a_iconMapUV;\n\n// dash line\nattribute float a_Total_Distance;\nattribute vec2 a_DistanceAndIndex;\n\nuniform vec2 u_tileOrigin;\nuniform float u_coord;\n\nuniform mat4 u_ModelMatrix;\nuniform mat4 u_Mvp;\nuniform float u_icon_step: 100;\n\nuniform float u_heightfixed: 0.0;\nuniform float u_vertexScale: 1.0;\n\n#pragma include \"projection\"\n#pragma include \"picking\"\n\nvarying vec4 v_color;\n\n// texV \u7EBF\u56FE\u5C42 - \u8D34\u56FE\u90E8\u5206\u7684 v \u5750\u6807\uFF08\u7EBF\u7684\u5BBD\u5EA6\u65B9\u5411\uFF09\nvarying vec2 v_iconMapUV;\n\n\nuniform float u_linearColor: 0;\nuniform float u_arrow: 0.0;\nuniform float u_arrowHeight: 3.0;\nuniform float u_arrowWidth: 2.0;\nuniform float u_tailWidth: 1.0;\n\nuniform float u_opacity: 1.0;\nvarying mat4 styleMappingMat; // \u7528\u4E8E\u5C06\u5728\u9876\u70B9\u7740\u8272\u5668\u4E2D\u8BA1\u7B97\u597D\u7684\u6837\u5F0F\u503C\u4F20\u9012\u7ED9\u7247\u5143\n\n#pragma include \"styleMapping\"\n#pragma include \"styleMappingCalOpacity\"\n\nvec2 calculateArrow(vec2 offset) {\n /*\n * \u5728\u652F\u6301\u7BAD\u5934\u7684\u65F6\u5019\uFF0C\u7B2C\u4E8C\u3001\u7B2C\u4E09\u7EC4\u9876\u70B9\u662F\u989D\u5916\u63D2\u5165\u7528\u4E8E\u6784\u5EFA\u9876\u70B9\u7684\n */\n float arrowFlag = -1.0;\n if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) {\n // \u9AD8\u5FB7 2.0 \u7684\u65CB\u8F6C\u89D2\u5EA6\u4E0D\u540C\n arrowFlag = 1.0;\n }\n float pi = arrowFlag * 3.1415926/2.;\n if(a_Miter < 0.) {\n // \u6839\u636E\u7EBF\u7684\u4E24\u4FA7\u504F\u79FB\u4E0D\u540C\u3001\u65CB\u8F6C\u7684\u65B9\u5411\u76F8\u53CD\n pi = -pi;\n }\n highp float angle_sin = sin(pi);\n highp float angle_cos = cos(pi);\n // \u8BA1\u7B97\u5782\u76F4\u4E0E\u7EBF\u65B9\u5411\u7684\u65CB\u8F6C\u77E9\u9635\n mat2 rotation_matrix = mat2(angle_cos, -1.0 * angle_sin, angle_sin, angle_cos);\n float arrowWidth = u_arrowWidth;\n float arrowHeight = u_arrowHeight;\n\n vec2 arrowOffset = vec2(0.0);\n /*\n * a_DistanceAndIndex.y \u7528\u4E8E\u6807\u8BB0\u5F53\u524D\u9876\u70B9\u5C5E\u4E8E\u54EA\u4E00\u7EC4\uFF08\u4E24\u4E2A\u9876\u70B9\u4E00\u7EC4\uFF0C\u6784\u6210\u7EBF\u7684\u5176\u5B9E\u662F\u77E9\u5F62\uFF0C\u6700\u7B80\u9700\u8981\u56DB\u4E2A\u9876\u70B9\u3001\u4E24\u7EC4\u9876\u70B9\u6784\u6210\uFF09\n */\n if(a_DistanceAndIndex.y == 0.0) {\n // \u7BAD\u5934\u5C16\u90E8\n offset = vec2(0.0);\n } else if(a_DistanceAndIndex.y == 1.0) {\n // \u7BAD\u5934\u4E24\u4FA7\n arrowOffset = rotation_matrix*(offset * arrowHeight);\n offset += arrowOffset; // \u6CBF\u7EBF\u504F\u79FB\n offset = offset * arrowWidth; // \u5782\u76F4\u7EBF\u5411\u5916\u504F\u79FB\uFF08\u662F\u6784\u5EFA\u7BAD\u5934\u4E24\u4FA7\u7684\u9876\u70B9\uFF09\n } else if(a_DistanceAndIndex.y == 2.0 || a_DistanceAndIndex.y == 3.0 || a_DistanceAndIndex.y == 4.0) {\n // \u504F\u79FB\u5176\u4F59\u7684\u70B9\u4F4D\uFF08\u5C06\u957F\u5EA6\u8BA9\u4F4D\u7ED9\u7BAD\u5934\uFF09\n arrowOffset = rotation_matrix*(offset * arrowHeight) * arrowWidth;\n offset += arrowOffset;// \u6CBF\u7EBF\u504F\u79FB\n }\n\n return offset;\n}\n\nvoid main() {\n // cal style mapping - \u6570\u636E\u7EB9\u7406\u6620\u5C04\u90E8\u5206\u7684\u8BA1\u7B97\n styleMappingMat = mat4(\n 0.0, 0.0, 0.0, 0.0, // opacity - strokeOpacity - strokeWidth - empty\n 0.0, 0.0, 0.0, 0.0, // strokeR - strokeG - strokeB - strokeA\n 0.0, 0.0, 0.0, 0.0, // offsets[0] - offsets[1]\n 0.0, 0.0, 0.0, 0.0 // distance_ratio/distance/pixelLen/texV\n );\n\n float rowCount = u_cellTypeLayout[0][0]; // \u5F53\u524D\u7684\u6570\u636E\u7EB9\u7406\u6709\u51E0\u884C\n float columnCount = u_cellTypeLayout[0][1]; // \u5F53\u770B\u5230\u6570\u636E\u7EB9\u7406\u6709\u51E0\u5217\n float columnWidth = 1.0/columnCount; // \u5217\u5BBD\n float rowHeight = 1.0/rowCount; // \u884C\u9AD8\n float cellCount = calCellCount(); // opacity - strokeOpacity - strokeWidth - stroke - offsets\n float id = a_vertexId; // \u7B2Cn\u4E2A\u9876\u70B9\n float cellCurrentRow = floor(id * cellCount / columnCount) + 1.0; // \u8D77\u59CB\u70B9\u5728\u7B2C\u51E0\u884C\n float cellCurrentColumn = mod(id * cellCount, columnCount) + 1.0; // \u8D77\u59CB\u70B9\u5728\u7B2C\u51E0\u5217\n \n // cell \u56FA\u5B9A\u987A\u5E8F opacity -> strokeOpacity -> strokeWidth -> stroke ... \n // \u6309\u987A\u5E8F\u4ECE cell \u4E2D\u53D6\u503C\u3001\u82E5\u6CA1\u6709\u5219\u81EA\u52A8\u5F80\u4E0B\u53D6\u503C\n float textureOffset = 0.0; // \u5728 cell \u4E2D\u53D6\u503C\u7684\u504F\u79FB\u91CF\n\n vec2 opacityAndOffset = calOpacityAndOffset(cellCurrentRow, cellCurrentColumn, columnCount, textureOffset, columnWidth, rowHeight);\n styleMappingMat[0][0] = opacityAndOffset.r;\n textureOffset = opacityAndOffset.g;\n // cal style mapping - \u6570\u636E\u7EB9\u7406\u6620\u5C04\u90E8\u5206\u7684\u8BA1\u7B97\n\n float d_texPixelLen; // \u8D34\u56FE\u7684\u50CF\u7D20\u957F\u5EA6\uFF0C\u6839\u636E\u5730\u56FE\u5C42\u7EA7\u7F29\u653E\n\n v_iconMapUV = a_iconMapUV;\n d_texPixelLen = project_float_pixel(u_icon_step);\n if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) {\n d_texPixelLen *= 10.0;\n }\n\n v_color = a_Color;\n\n vec3 size = a_Miter * setPickingSize(a_Size.x) * reverse_offset_normal(a_Normal);\n \n vec2 offset = project_pixel(size.xy);\n\n float lineDistance = a_DistanceAndIndex.x;\n float currentLinePointRatio = lineDistance / a_Total_Distance;\n \n if(u_arrow > 0.0) {\n // \u8BA1\u7B97\u7BAD\u5934\n offset = calculateArrow(offset);\n\n if(a_DistanceAndIndex.y > 4.0) {\n offset *= mix(1.0, u_tailWidth, currentLinePointRatio);\n }\n }\n\n float lineOffsetWidth = length(offset + offset * sign(a_Miter)); // \u7EBF\u6A2A\u5411\u504F\u79FB\u7684\u8DDD\u79BB\uFF08\u5411\u4E24\u4FA7\u504F\u79FB\u7684\u548C\uFF09\n float linePixelSize = project_pixel(a_Size.x) * 2.0; // \u5B9A\u70B9\u4F4D\u7F6E\u504F\u79FB\uFF0C\u6309\u5730\u56FE\u7B49\u7EA7\u7F29\u653E\u540E\u7684\u8DDD\u79BB \u5355\u4FA7 * 2\n float texV = lineOffsetWidth/linePixelSize; // \u7EBF\u56FE\u5C42\u8D34\u56FE\u90E8\u5206\u7684 v \u5750\u6807\u503C\n\n // \u8BBE\u7F6E\u6570\u636E\u96C6\u7684\u53C2\u6570\n styleMappingMat[3][0] = currentLinePointRatio; // \u5F53\u524D\u70B9\u4F4D\u8DDD\u79BB\u5360\u7EBF\u603B\u957F\u7684\u6BD4\u4F8B\n styleMappingMat[3][1] = lineDistance; // \u5F53\u524D\u9876\u70B9\u7684\u8DDD\u79BB\n styleMappingMat[3][2] = d_texPixelLen; // \u8D34\u56FE\u7684\u50CF\u7D20\u957F\u5EA6\uFF0C\u6839\u636E\u5730\u56FE\u5C42\u7EA7\u7F29\u653E\n styleMappingMat[3][3] = texV; // \u7EBF\u56FE\u5C42\u8D34\u56FE\u90E8\u5206\u7684 v \u5750\u6807\u503C\n\n vec4 project_pos = project_position(vec4(a_Position.xy, 0, 1.0));\n\n // gl_Position = project_common_position_to_clipspace(vec4(project_pos.xy + offset, a_Size.y, 1.0));\n\n float h = float(a_Position.z) * u_vertexScale; // \u7EBF\u9876\u70B9\u7684\u9AD8\u5EA6 - \u517C\u5BB9\u4E0D\u5B58\u5728\u7B2C\u4E09\u4E2A\u6570\u503C\u7684\u60C5\u51B5 vertex height\n float lineHeight = a_Size.y; // size \u7B2C\u4E8C\u4E2A\u53C2\u6570\u4EE3\u8868\u7684\u9AD8\u5EA6 [linewidth, lineheight]\n\nif(u_coord > 0.0) {\n if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) { // gaode2.x\n lineHeight *= 0.2; // \u4FDD\u6301\u548C amap/mapbox \u4E00\u81F4\u7684\u6548\u679C\n h *= 0.2;\n if(u_heightfixed < 1.0) {\n lineHeight = project_pixel(a_Size.y);\n }\n gl_Position = u_Mvp * (vec4(project_pos.xy + offset, lineHeight + h, 1.0));\n } else {\n // mapbox - amap\n \n // \u517C\u5BB9 mapbox \u5728\u7EBF\u9AD8\u5EA6\u4E0A\u7684\u6548\u679C\u8868\u73B0\u57FA\u672C\u4E00\u81F4\n if(u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT || u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT_OFFSET) {\n // mapbox\n // \u4FDD\u6301\u9AD8\u5EA6\u76F8\u5BF9\u4E0D\u53D8\n float mapboxZoomScale = 4.0/pow(2.0, 21.0 - u_Zoom);\n h *= mapboxZoomScale;\n if(u_heightfixed > 0.0) {\n lineHeight *= mapboxZoomScale;\n }\n \n } else {\n // amap\n // lineHeight \u9876\u70B9\u504F\u79FB\u9AD8\u5EA6\n if(u_heightfixed < 1.0) {\n lineHeight *= pow(2.0, 20.0 - u_Zoom);\n }\n }\n\n gl_Position = project_common_position_to_clipspace(vec4(project_pos.xy + offset, lineHeight + h, 1.0));\n }\n} else {\n vec2 pointPos = a_Position.xy;\n vec4 tileWorld = vec4(project_mvt_offset_position(vec4(u_tileOrigin, 0.0, 1.0)).xyz, 1.0); // \u74E6\u7247\u8D77\u59CB\u70B9\u7684\u4E16\u754C\u5750\u6807\n\n vec2 pointOffset = pointPos * pow(2.0, u_Zoom); // \u74E6\u7247\u5185\u7684\u70B9\u7684\u504F\u79FB\u5750\u6807\n \n tileWorld.xy += pointOffset;\n\n tileWorld.xy += offset;\n\n if (u_CoordinateSystem == COORDINATE_SYSTEM_METER_OFFSET || u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT_OFFSET) {\n // Needs to be divided with project_uCommonUnitsPerMeter\n tileWorld.w *= u_PixelsPerMeter.z;\n }\n\n gl_Position = u_ViewProjectionMatrix * tileWorld + u_ViewportCenterProjection;\n}\n\n\n setPickingColor(a_PickingColor);\n\n\n}\n";
38
+
39
+ var LineModel = function (_BaseModel) {
40
+ (0, _inherits2.default)(LineModel, _BaseModel);
41
+
42
+ var _super = _createSuper(LineModel);
43
+
44
+ function LineModel() {
45
+ var _this;
46
+
47
+ (0, _classCallCheck2.default)(this, LineModel);
48
+
49
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
50
+ args[_key] = arguments[_key];
51
+ }
52
+
53
+ _this = _super.call.apply(_super, [this].concat(args));
54
+ (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "texture", void 0);
55
+ (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "updateTexture", function () {
56
+ var createTexture2D = _this.rendererService.createTexture2D;
57
+
58
+ if (_this.texture) {
59
+ _this.texture.update({
60
+ data: _this.iconService.getCanvas()
61
+ });
62
+
63
+ _this.layer.render();
64
+
65
+ return;
66
+ }
67
+
68
+ _this.texture = createTexture2D({
69
+ data: _this.iconService.getCanvas(),
70
+ mag: _l7Core.gl.NEAREST,
71
+ min: _l7Core.gl.NEAREST,
72
+ premultiplyAlpha: false,
73
+ width: 1024,
74
+ height: _this.iconService.canvasHeight || 128
75
+ });
76
+ });
77
+ return _this;
78
+ }
79
+
80
+ (0, _createClass2.default)(LineModel, [{
81
+ key: "getUninforms",
82
+ value: function getUninforms() {
83
+ var _ref = this.layer.getLayerConfig(),
84
+ _ref$opacity = _ref.opacity,
85
+ opacity = _ref$opacity === void 0 ? 1 : _ref$opacity,
86
+ _ref$textureBlend = _ref.textureBlend,
87
+ textureBlend = _ref$textureBlend === void 0 ? 'normal' : _ref$textureBlend,
88
+ _ref$lineTexture = _ref.lineTexture,
89
+ lineTexture = _ref$lineTexture === void 0 ? false : _ref$lineTexture,
90
+ _ref$iconStep = _ref.iconStep,
91
+ iconStep = _ref$iconStep === void 0 ? 100 : _ref$iconStep,
92
+ _ref$vertexHeightScal = _ref.vertexHeightScale,
93
+ vertexHeightScale = _ref$vertexHeightScal === void 0 ? 20.0 : _ref$vertexHeightScal,
94
+ _ref$borderWidth = _ref.borderWidth,
95
+ borderWidth = _ref$borderWidth === void 0 ? 0.0 : _ref$borderWidth,
96
+ _ref$borderColor = _ref.borderColor,
97
+ borderColor = _ref$borderColor === void 0 ? '#ccc' : _ref$borderColor,
98
+ _ref$heightfixed = _ref.heightfixed,
99
+ heightfixed = _ref$heightfixed === void 0 ? false : _ref$heightfixed,
100
+ _ref$arrow = _ref.arrow,
101
+ arrow = _ref$arrow === void 0 ? {
102
+ enable: false,
103
+ arrowWidth: 2,
104
+ arrowHeight: 3,
105
+ tailWidth: 1
106
+ } : _ref$arrow,
107
+ _ref$coord = _ref.coord,
108
+ coord = _ref$coord === void 0 ? 'lnglat' : _ref$coord,
109
+ tileOrigin = _ref.tileOrigin;
110
+
111
+ if (this.rendererService.getDirty()) {
112
+ this.texture.bind();
113
+ }
114
+
115
+ if (this.dataTextureTest && this.dataTextureNeedUpdate({
116
+ opacity: opacity
117
+ })) {
118
+ this.judgeStyleAttributes({
119
+ opacity: opacity
120
+ });
121
+ var encodeData = this.layer.getEncodedData();
122
+
123
+ var _this$calDataFrame = this.calDataFrame(this.cellLength, encodeData, this.cellProperties),
124
+ data = _this$calDataFrame.data,
125
+ width = _this$calDataFrame.width,
126
+ height = _this$calDataFrame.height;
127
+
128
+ this.rowCount = height;
129
+ this.dataTexture = this.cellLength > 0 && data.length > 0 ? this.createTexture2D({
130
+ flipY: true,
131
+ data: data,
132
+ format: _l7Core.gl.LUMINANCE,
133
+ type: _l7Core.gl.FLOAT,
134
+ width: width,
135
+ height: height
136
+ }) : this.createTexture2D({
137
+ flipY: true,
138
+ data: [1],
139
+ format: _l7Core.gl.LUMINANCE,
140
+ type: _l7Core.gl.FLOAT,
141
+ width: 1,
142
+ height: 1
143
+ });
144
+ }
145
+
146
+ return {
147
+ u_tileOrigin: tileOrigin || [0, 0],
148
+ u_coord: coord === 'lnglat' ? 1.0 : 0.0,
149
+ u_dataTexture: this.dataTexture,
150
+ u_cellTypeLayout: this.getCellTypeLayout(),
151
+ u_opacity: Number(opacity),
152
+ u_textureBlend: textureBlend === 'normal' ? 0.0 : 1.0,
153
+ u_texture: this.texture,
154
+ u_line_texture: lineTexture ? 1.0 : 0.0,
155
+ u_icon_step: iconStep,
156
+ u_textSize: [1024, this.iconService.canvasHeight || 128],
157
+ u_borderWidth: borderWidth,
158
+ u_borderColor: (0, _l7Utils.rgb2arr)(borderColor),
159
+ u_heightfixed: Number(heightfixed),
160
+ u_vertexScale: vertexHeightScale,
161
+ u_arrow: Number(arrow.enable),
162
+ u_arrowHeight: arrow.arrowHeight || 3,
163
+ u_arrowWidth: arrow.arrowWidth || 2,
164
+ u_tailWidth: arrow.tailWidth === undefined ? 1 : arrow.tailWidth
165
+ };
166
+ }
167
+ }, {
168
+ key: "initModels",
169
+ value: function initModels() {
170
+ this.updateTexture();
171
+ this.iconService.on('imageUpdate', this.updateTexture);
172
+ return this.buildModels();
173
+ }
174
+ }, {
175
+ key: "clearModels",
176
+ value: function clearModels() {
177
+ var _this$texture, _this$dataTexture;
178
+
179
+ (_this$texture = this.texture) === null || _this$texture === void 0 ? void 0 : _this$texture.destroy();
180
+ (_this$dataTexture = this.dataTexture) === null || _this$dataTexture === void 0 ? void 0 : _this$dataTexture.destroy();
181
+ this.iconService.off('imageUpdate', this.updateTexture);
182
+ }
183
+ }, {
184
+ key: "buildModels",
185
+ value: function buildModels() {
186
+ var _ref2 = this.layer.getLayerConfig(),
187
+ _ref2$mask = _ref2.mask,
188
+ mask = _ref2$mask === void 0 ? false : _ref2$mask,
189
+ _ref2$maskInside = _ref2.maskInside,
190
+ maskInside = _ref2$maskInside === void 0 ? true : _ref2$maskInside,
191
+ _ref2$depth = _ref2.depth,
192
+ depth = _ref2$depth === void 0 ? false : _ref2$depth;
193
+
194
+ var _this$getShaders = this.getShaders(),
195
+ frag = _this$getShaders.frag,
196
+ vert = _this$getShaders.vert,
197
+ type = _this$getShaders.type;
198
+
199
+ this.layer.triangulation = _triangulation.LineTriangulation;
200
+ return [this.layer.buildLayerModel({
201
+ moduleName: type,
202
+ vertexShader: vert,
203
+ fragmentShader: frag,
204
+ triangulation: _triangulation.LineTriangulation,
205
+ primitive: _l7Core.gl.TRIANGLES,
206
+ blend: this.getBlend(),
207
+ depth: {
208
+ enable: depth
209
+ },
210
+ stencil: (0, _l7Utils.getMask)(mask, maskInside)
211
+ })];
212
+ }
213
+ }, {
214
+ key: "getShaders",
215
+ value: function getShaders() {
216
+ return {
217
+ frag: line_tile_frag,
218
+ vert: line_tile_vert,
219
+ type: 'line_tile'
220
+ };
221
+ }
222
+ }, {
223
+ key: "registerBuiltinAttributes",
224
+ value: function registerBuiltinAttributes() {
225
+ var _this2 = this;
226
+
227
+ this.styleAttributeService.registerStyleAttribute({
228
+ name: 'distanceAndIndex',
229
+ type: _l7Core.AttributeType.Attribute,
230
+ descriptor: {
231
+ name: 'a_DistanceAndIndex',
232
+ buffer: {
233
+ usage: _l7Core.gl.STATIC_DRAW,
234
+ data: [],
235
+ type: _l7Core.gl.FLOAT
236
+ },
237
+ size: 2,
238
+ update: function update(feature, featureIdx, vertex, attributeIdx, normal, vertexIndex) {
239
+ return vertexIndex === undefined ? [vertex[3], 10] : [vertex[3], vertexIndex];
240
+ }
241
+ }
242
+ });
243
+ this.styleAttributeService.registerStyleAttribute({
244
+ name: 'total_distance',
245
+ type: _l7Core.AttributeType.Attribute,
246
+ descriptor: {
247
+ name: 'a_Total_Distance',
248
+ buffer: {
249
+ usage: _l7Core.gl.STATIC_DRAW,
250
+ data: [],
251
+ type: _l7Core.gl.FLOAT
252
+ },
253
+ size: 1,
254
+ update: function update(feature, featureIdx, vertex, attributeIdx) {
255
+ return [vertex[5]];
256
+ }
257
+ }
258
+ });
259
+ this.styleAttributeService.registerStyleAttribute({
260
+ name: 'size',
261
+ type: _l7Core.AttributeType.Attribute,
262
+ descriptor: {
263
+ name: 'a_Size',
264
+ buffer: {
265
+ usage: _l7Core.gl.DYNAMIC_DRAW,
266
+ data: [],
267
+ type: _l7Core.gl.FLOAT
268
+ },
269
+ size: 2,
270
+ update: function update(feature, featureIdx, vertex, attributeIdx) {
271
+ var _feature$size = feature.size,
272
+ size = _feature$size === void 0 ? 1 : _feature$size;
273
+ return Array.isArray(size) ? [size[0], size[1]] : [size, 0];
274
+ }
275
+ }
276
+ });
277
+ this.styleAttributeService.registerStyleAttribute({
278
+ name: 'normal',
279
+ type: _l7Core.AttributeType.Attribute,
280
+ descriptor: {
281
+ name: 'a_Normal',
282
+ buffer: {
283
+ usage: _l7Core.gl.STATIC_DRAW,
284
+ data: [],
285
+ type: _l7Core.gl.FLOAT
286
+ },
287
+ size: 3,
288
+ update: function update(feature, featureIdx, vertex, attributeIdx, normal) {
289
+ return normal;
290
+ }
291
+ }
292
+ });
293
+ this.styleAttributeService.registerStyleAttribute({
294
+ name: 'miter',
295
+ type: _l7Core.AttributeType.Attribute,
296
+ descriptor: {
297
+ name: 'a_Miter',
298
+ buffer: {
299
+ usage: _l7Core.gl.STATIC_DRAW,
300
+ data: [],
301
+ type: _l7Core.gl.FLOAT
302
+ },
303
+ size: 1,
304
+ update: function update(feature, featureIdx, vertex, attributeIdx) {
305
+ return [vertex[4]];
306
+ }
307
+ }
308
+ });
309
+ this.styleAttributeService.registerStyleAttribute({
310
+ name: 'uv',
311
+ type: _l7Core.AttributeType.Attribute,
312
+ descriptor: {
313
+ name: 'a_iconMapUV',
314
+ buffer: {
315
+ usage: _l7Core.gl.DYNAMIC_DRAW,
316
+ data: [],
317
+ type: _l7Core.gl.FLOAT
318
+ },
319
+ size: 2,
320
+ update: function update(feature, featureIdx, vertex, attributeIdx) {
321
+ var iconMap = _this2.iconService.getIconMap();
322
+
323
+ var texture = feature.texture;
324
+
325
+ var _ref3 = iconMap[texture] || {
326
+ x: 0,
327
+ y: 0
328
+ },
329
+ x = _ref3.x,
330
+ y = _ref3.y;
331
+
332
+ return [x, y];
333
+ }
334
+ }
335
+ });
336
+ }
337
+ }]);
338
+ return LineModel;
339
+ }(_BaseModel2.default);
340
+
341
+ exports.default = LineModel;
342
+ //# sourceMappingURL=tile.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/line/models/tile.ts"],"names":["LineModel","createTexture2D","rendererService","texture","update","data","iconService","getCanvas","layer","render","mag","gl","NEAREST","min","premultiplyAlpha","width","height","canvasHeight","getLayerConfig","opacity","textureBlend","lineTexture","iconStep","vertexHeightScale","borderWidth","borderColor","heightfixed","arrow","enable","arrowWidth","arrowHeight","tailWidth","coord","tileOrigin","getDirty","bind","dataTextureTest","dataTextureNeedUpdate","judgeStyleAttributes","encodeData","getEncodedData","calDataFrame","cellLength","cellProperties","rowCount","dataTexture","length","flipY","format","LUMINANCE","type","FLOAT","u_tileOrigin","u_coord","u_dataTexture","u_cellTypeLayout","getCellTypeLayout","u_opacity","Number","u_textureBlend","u_texture","u_line_texture","u_icon_step","u_textSize","u_borderWidth","u_borderColor","u_heightfixed","u_vertexScale","u_arrow","u_arrowHeight","u_arrowWidth","u_tailWidth","undefined","updateTexture","on","buildModels","destroy","off","mask","maskInside","depth","getShaders","frag","vert","triangulation","LineTriangulation","buildLayerModel","moduleName","vertexShader","fragmentShader","primitive","TRIANGLES","blend","getBlend","stencil","line_tile_frag","line_tile_vert","styleAttributeService","registerStyleAttribute","name","AttributeType","Attribute","descriptor","buffer","usage","STATIC_DRAW","size","feature","featureIdx","vertex","attributeIdx","normal","vertexIndex","DYNAMIC_DRAW","Array","isArray","iconMap","getIconMap","x","y","BaseModel"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAAA;;AAUA;;AACA;;AAEA;;;;;;;;;IAKqBA,S;;;;;;;;;;;;;;;;gGA4RK,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,EAAEC,WAAGC,OAFqB;AAG7BC,QAAAA,GAAG,EAAEF,WAAGC,OAHqB;AAI7BE,QAAAA,gBAAgB,EAAE,KAJW;AAK7BC,QAAAA,KAAK,EAAE,IALsB;AAM7BC,QAAAA,MAAM,EAAE,MAAKV,WAAL,CAAiBW,YAAjB,IAAiC;AANZ,OAAD,CAA9B;AAQD,K;;;;;;WA3SD,wBAAqC;AACnC,iBAiBI,KAAKT,KAAL,CAAWU,c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EAAEkD,sBAAcC,SAF4B;AAGhDC,QAAAA,UAAU,EAAE;AACVH,UAAAA,IAAI,EAAE,aADI;AAEVI,UAAAA,MAAM,EAAE;AAENC,YAAAA,KAAK,EAAE7F,WAAGsG,YAFJ;AAGN5G,YAAAA,IAAI,EAAE,EAHA;AAIN6C,YAAAA,IAAI,EAAEvC,WAAGwC;AAJH,WAFE;AAQVuD,UAAAA,IAAI,EAAE,CARI;AASVtG,UAAAA,MAAM,EAAE,gBACNuG,OADM,EAENC,UAFM,EAGNC,MAHM,EAINC,YAJM,EAKH;AACH,gBAAMM,OAAO,GAAG,MAAI,CAAC9G,WAAL,CAAiB+G,UAAjB,EAAhB;;AACA,gBAAQlH,OAAR,GAAoBwG,OAApB,CAAQxG,OAAR;;AACA,wBAAiBiH,OAAO,CAACjH,OAAD,CAAP,IAA8B;AAAEmH,cAAAA,CAAC,EAAE,CAAL;AAAQC,cAAAA,CAAC,EAAE;AAAX,aAA/C;AAAA,gBAAQD,CAAR,SAAQA,CAAR;AAAA,gBAAWC,CAAX,SAAWA,CAAX;;AACA,mBAAO,CAACD,CAAD,EAAIC,CAAJ,CAAP;AACD;AAnBS;AAHoC,OAAlD;AAyBD;;;EA1RoCC,mB","sourcesContent":["import {\n AttributeType,\n gl,\n IEncodeFeature,\n ILayerConfig,\n IModel,\n IModelUniform,\n ITexture2D,\n} from '@antv/l7-core';\n\nimport { getMask, rgb2arr } from '@antv/l7-utils';\nimport BaseModel from '../../core/BaseModel';\nimport { ILineLayerStyleOptions } from '../../core/interface';\nimport { LineTriangulation } from '../../core/triangulation';\n\nimport line_tile_frag from '../shaders/tile/line_tile_frag.glsl';\nimport line_tile_vert from '../shaders/tile/line_tile_vert.glsl';\n\nexport default class LineModel extends BaseModel {\n protected texture: ITexture2D;\n public getUninforms(): IModelUniform {\n const {\n opacity = 1,\n textureBlend = 'normal',\n lineTexture = false,\n iconStep = 100,\n vertexHeightScale = 20.0,\n borderWidth = 0.0,\n borderColor = '#ccc',\n heightfixed = false,\n arrow = {\n enable: false,\n arrowWidth: 2,\n arrowHeight: 3,\n tailWidth: 1,\n },\n coord = 'lnglat',\n tileOrigin,\n } = this.layer.getLayerConfig() as ILineLayerStyleOptions;\n\n if (this.rendererService.getDirty()) {\n this.texture.bind();\n }\n\n if (this.dataTextureTest && this.dataTextureNeedUpdate({ opacity })) {\n this.judgeStyleAttributes({ opacity });\n const encodeData = this.layer.getEncodedData();\n const { data, width, height } = this.calDataFrame(\n this.cellLength,\n encodeData,\n this.cellProperties,\n );\n this.rowCount = height; // 当前数据纹理有多少行\n\n this.dataTexture =\n this.cellLength > 0 && data.length > 0\n ? this.createTexture2D({\n flipY: true,\n data,\n format: gl.LUMINANCE,\n type: gl.FLOAT,\n width,\n height,\n })\n : this.createTexture2D({\n flipY: true,\n data: [1],\n format: gl.LUMINANCE,\n type: gl.FLOAT,\n width: 1,\n height: 1,\n });\n }\n return {\n u_tileOrigin: tileOrigin || [0, 0],\n u_coord: coord === 'lnglat' ? 1.0 : 0.0,\n u_dataTexture: this.dataTexture, // 数据纹理 - 有数据映射的时候纹理中带数据,若没有任何数据映射时纹理是 [1]\n u_cellTypeLayout: this.getCellTypeLayout(),\n u_opacity: Number(opacity),\n u_textureBlend: textureBlend === 'normal' ? 0.0 : 1.0,\n\n // 纹理支持参数\n u_texture: this.texture, // 贴图\n u_line_texture: lineTexture ? 1.0 : 0.0, // 传入线的标识\n u_icon_step: iconStep,\n u_textSize: [1024, this.iconService.canvasHeight || 128],\n\n // line border 参数\n u_borderWidth: borderWidth,\n u_borderColor: rgb2arr(borderColor),\n\n // 是否固定高度\n u_heightfixed: Number(heightfixed),\n\n // 顶点高度 scale\n u_vertexScale: vertexHeightScale,\n\n // arrow\n u_arrow: Number(arrow.enable),\n u_arrowHeight: arrow.arrowHeight || 3,\n u_arrowWidth: arrow.arrowWidth || 2,\n u_tailWidth: arrow.tailWidth === undefined ? 1 : arrow.tailWidth,\n };\n }\n\n public initModels(): IModel[] {\n this.updateTexture();\n this.iconService.on('imageUpdate', this.updateTexture);\n\n return this.buildModels();\n }\n\n public clearModels() {\n this.texture?.destroy();\n this.dataTexture?.destroy();\n this.iconService.off('imageUpdate', this.updateTexture);\n }\n\n public buildModels(): IModel[] {\n const {\n mask = false,\n maskInside = true,\n depth = false,\n } = this.layer.getLayerConfig() as ILineLayerStyleOptions;\n const { frag, vert, type } = this.getShaders();\n this.layer.triangulation = LineTriangulation;\n return [\n this.layer.buildLayerModel({\n moduleName: type,\n vertexShader: vert,\n fragmentShader: frag,\n triangulation: LineTriangulation,\n primitive: gl.TRIANGLES,\n blend: this.getBlend(),\n depth: { enable: depth },\n // depth: { enable: true },\n stencil: getMask(mask, maskInside),\n }),\n ];\n }\n\n /**\n * 根据参数获取不同的 shader 代码\n * @returns\n */\n public getShaders(): { frag: string; vert: string; type: string } {\n return {\n frag: line_tile_frag,\n vert: line_tile_vert,\n type: 'line_tile',\n };\n }\n\n protected registerBuiltinAttributes() {\n this.styleAttributeService.registerStyleAttribute({\n name: 'distanceAndIndex',\n type: AttributeType.Attribute,\n descriptor: {\n name: 'a_DistanceAndIndex',\n buffer: {\n // give the WebGL driver a hint that this buffer may change\n usage: gl.STATIC_DRAW,\n data: [],\n type: gl.FLOAT,\n },\n size: 2,\n update: (\n feature: IEncodeFeature,\n featureIdx: number,\n vertex: number[],\n attributeIdx: number,\n normal: number[],\n vertexIndex?: number,\n ) => {\n return vertexIndex === undefined\n ? [vertex[3], 10]\n : [vertex[3], vertexIndex];\n },\n },\n });\n this.styleAttributeService.registerStyleAttribute({\n name: 'total_distance',\n type: AttributeType.Attribute,\n descriptor: {\n name: 'a_Total_Distance',\n buffer: {\n // give the WebGL driver a hint that this buffer may change\n usage: gl.STATIC_DRAW,\n data: [],\n type: gl.FLOAT,\n },\n size: 1,\n update: (\n feature: IEncodeFeature,\n featureIdx: number,\n vertex: number[],\n attributeIdx: number,\n ) => {\n return [vertex[5]];\n },\n },\n });\n\n this.styleAttributeService.registerStyleAttribute({\n name: 'size',\n type: AttributeType.Attribute,\n descriptor: {\n name: 'a_Size',\n buffer: {\n // give the WebGL driver a hint that this buffer may change\n usage: gl.DYNAMIC_DRAW,\n data: [],\n type: gl.FLOAT,\n },\n size: 2,\n update: (\n feature: IEncodeFeature,\n featureIdx: number,\n vertex: number[],\n attributeIdx: number,\n ) => {\n const { size = 1 } = feature;\n return Array.isArray(size) ? [size[0], size[1]] : [size as number, 0];\n },\n },\n });\n\n // point layer size;\n this.styleAttributeService.registerStyleAttribute({\n name: 'normal',\n type: AttributeType.Attribute,\n descriptor: {\n name: 'a_Normal',\n buffer: {\n // give the WebGL driver a hint that this buffer may change\n usage: gl.STATIC_DRAW,\n data: [],\n type: gl.FLOAT,\n },\n size: 3,\n update: (\n feature: IEncodeFeature,\n featureIdx: number,\n vertex: number[],\n attributeIdx: number,\n normal: number[],\n ) => {\n return normal;\n },\n },\n });\n\n this.styleAttributeService.registerStyleAttribute({\n name: 'miter',\n type: AttributeType.Attribute,\n descriptor: {\n name: 'a_Miter',\n buffer: {\n // give the WebGL driver a hint that this buffer may change\n usage: gl.STATIC_DRAW,\n data: [],\n type: gl.FLOAT,\n },\n size: 1,\n update: (\n feature: IEncodeFeature,\n featureIdx: number,\n vertex: number[],\n attributeIdx: number,\n ) => {\n return [vertex[4]];\n },\n },\n });\n\n this.styleAttributeService.registerStyleAttribute({\n name: 'uv',\n type: AttributeType.Attribute,\n descriptor: {\n name: 'a_iconMapUV',\n buffer: {\n // give the WebGL driver a hint that this buffer may change\n usage: gl.DYNAMIC_DRAW,\n data: [],\n type: gl.FLOAT,\n },\n size: 2,\n update: (\n feature: IEncodeFeature,\n featureIdx: number,\n vertex: number[],\n attributeIdx: number,\n ) => {\n const iconMap = this.iconService.getIconMap();\n const { texture } = feature;\n const { x, y } = iconMap[texture as string] || { x: 0, y: 0 };\n return [x, y];\n },\n },\n });\n }\n\n private updateTexture = () => {\n const { createTexture2D } = this.rendererService;\n if (this.texture) {\n this.texture.update({\n data: this.iconService.getCanvas(),\n });\n this.layer.render();\n return;\n }\n this.texture = createTexture2D({\n data: this.iconService.getCanvas(),\n mag: gl.NEAREST,\n min: gl.NEAREST,\n premultiplyAlpha: false,\n width: 1024,\n height: this.iconService.canvasHeight || 128,\n });\n };\n}\n"],"file":"tile.js"}
@@ -165,7 +165,7 @@ var DataMappingPlugin = (_dec = (0, _inversify.injectable)(), _dec2 = (0, _inver
165
165
  }
166
166
  });
167
167
 
168
- if (encodeRecord.shape === 'line' && arrow.enable) {
168
+ if (arrow.enable && (encodeRecord.shape === 'line' || encodeRecord.shape === 'halfLine')) {
169
169
  var coords = encodeRecord.coordinates;
170
170
 
171
171
  var arrowPoint = _this3.getArrowPoints(coords[0], coords[1]);
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/plugins/DataMappingPlugin.ts"],"names":["DataMappingPlugin","TYPES","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","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;;AAcA;;AACA;;AACA;;AAEA;;;;;;;;IAIqBA,iB,WADpB,4B,UAE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D,MAAlB,CAApB,GAAgD,EAAtE;;AACA,UAAIjE,SAAS,CAACgC,IAAV,KAAmB,OAAnB,IAA8B,CAAC,sBAAQqC,aAAa,CAAC,CAAD,CAArB,CAAnC,EAA8D;AAC5D,eAAO,CAACnD,YAAD,CAAP;AACD;;AACD,aAAOmD,aAAP;AAED","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 (encodeRecord.shape === 'line' && arrow.enable) {\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":["DataMappingPlugin","TYPES","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","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;;AAcA;;AACA;;AACA;;AAEA;;;;;;;;IAIqBA,iB,WADpB,4B,UAEE,uBAAOC,cAAMC,oBAAb,C,UAGA,uBAAOD,cAAME,WAA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,GAAgD,EAAtE;;AACA,UAAIjE,SAAS,CAACgC,IAAV,KAAmB,OAAnB,IAA8B,CAAC,sBAAQqC,aAAa,CAAC,CAAD,CAArB,CAAnC,EAA8D;AAC5D,eAAO,CAACnD,YAAD,CAAP;AACD;;AACD,aAAOmD,aAAP;AAED","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"}
@@ -70,15 +70,16 @@ var DataSourcePlugin = (_dec = (0, _inversify.injectable)(), _dec(_class = funct
70
70
  value: function updateClusterData(layer) {
71
71
  var source = layer.getSource();
72
72
  var cluster = source.cluster;
73
- var _source$clusterOption = source.clusterOptions,
74
- _source$clusterOption2 = _source$clusterOption.zoom,
75
- zoom = _source$clusterOption2 === void 0 ? 0 : _source$clusterOption2,
76
- _source$clusterOption3 = _source$clusterOption.maxZoom,
77
- maxZoom = _source$clusterOption3 === void 0 ? 16 : _source$clusterOption3;
73
+ var _source$clusterOption = source.clusterOptions.zoom,
74
+ zoom = _source$clusterOption === void 0 ? 0 : _source$clusterOption;
78
75
  var newZoom = this.mapService.getZoom() - 1;
79
76
  var dataSourceNeedUpdate = layer.dataState.dataSourceNeedUpdate;
80
77
 
81
- if (cluster && (dataSourceNeedUpdate || Math.abs(layer.clusterZoom - newZoom) >= 1)) {
78
+ if (cluster && dataSourceNeedUpdate) {
79
+ source.updateClusterData(Math.floor(newZoom));
80
+ }
81
+
82
+ if (cluster && Math.abs(layer.clusterZoom - newZoom) >= 1) {
82
83
  if (zoom !== Math.floor(newZoom)) {
83
84
  source.updateClusterData(Math.floor(newZoom));
84
85
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/plugins/DataSourcePlugin.ts"],"names":["DataSourcePlugin","layer","mapService","getContainer","get","TYPES","IMapService","hooks","init","tap","source","getSource","sourceOption","data","DEFAULT_DATA","options","DEFAULT_PARSER","setSource","Source","updateClusterData","beforeRenderData","neeUpdateCluster","dataSourceNeedUpdate","dataState","cluster","clusterOptions","zoom","maxZoom","newZoom","getZoom","Math","abs","clusterZoom","floor"],"mappings":";;;;;;;;;;;;;;;;;AAAA;;AAOA;;AACA;;AACA;;;;;;;;IAGqBA,gB,WADpB,4B;;;;;;;;WAGC,eAAaC,KAAb,EAA4B;AAAA;;AAC1B,WAAKC,UAAL,GAAkBD,KAAK,CAACE,YAAN,GAAqBC,GAArB,CAAsCC,cAAMC,WAA5C,CAAlB;AACAL,MAAAA,KAAK,CAACM,KAAN,CAAYC,IAAZ,CAAiBC,GAAjB,CAAqB,kBAArB,EAAyC,YAAM;AAC7C,YAAMC,MAAM,GAAGT,KAAK,CAACU,SAAN,EAAf;;AACA,YAAI,CAACD,MAAL,EAAa;AAEX,qBAA0BT,KAAK,CAACW,YAAN,IAAsB;AAC9CC,YAAAA,IAAI,EAAEC,sBADwC;AAE9CC,YAAAA,OAAO,EAAEC;AAFqC,WAAhD;AAAA,cAAQH,IAAR,QAAQA,IAAR;AAAA,cAAcE,OAAd,QAAcA,OAAd;;AAIAd,UAAAA,KAAK,CAACgB,SAAN,CAAgB,IAAIC,iBAAJ,CAAWL,IAAX,EAAiBE,OAAjB,CAAhB;AACD;;AAED,QAAA,KAAI,CAACI,iBAAL,CAAuBlB,KAAvB;AACD,OAZD;AAeAA,MAAAA,KAAK,CAACM,KAAN,CAAYa,gBAAZ,CAA6BX,GAA7B,CAAiC,kBAAjC,EAAqD,YAAM;AACzD,YAAMY,gBAAgB,GAAG,KAAI,CAACF,iBAAL,CAAuBlB,KAAvB,CAAzB;;AACA,YAAMqB,oBAAoB,GAAGrB,KAAK,CAACsB,SAAN,CAAgBD,oBAA7C;AACArB,QAAAA,KAAK,CAACsB,SAAN,CAAgBD,oBAAhB,GAAuC,KAAvC;AACA,eAAOD,gBAAgB,IAAIC,oBAA3B;AACD,OALD;AAMD;;;WAED,2BAA0BrB,KAA1B,EAAkD;AAChD,UAAMS,MAAM,GAAGT,KAAK,CAACU,SAAN,EAAf;AACA,UAAMa,OAAO,GAAGd,MAAM,CAACc,OAAvB;AACA,kCAAmCd,MAAM,CAACe,cAA1C;AAAA,yDAAQC,IAAR;AAAA,UAAQA,IAAR,uCAAe,CAAf;AAAA,yDAAkBC,OAAlB;AAAA,UAAkBA,OAAlB,uCAA4B,EAA5B;AACA,UAAMC,OAAO,GAAG,KAAK1B,UAAL,CAAgB2B,OAAhB,KAA4B,CAA5C;AACA,UAAMP,oBAAoB,GAAGrB,KAAK,CAACsB,SAAN,CAAgBD,oBAA7C;;AAEA,UACEE,OAAO,KACNF,oBAAoB,IAAIQ,IAAI,CAACC,GAAL,CAAS9B,KAAK,CAAC+B,WAAN,GAAoBJ,OAA7B,KAAyC,CAD3D,CADT,EAGE;AAEA,YAAIF,IAAI,KAAKI,IAAI,CAACG,KAAL,CAAWL,OAAX,CAAb,EAAkC;AAChClB,UAAAA,MAAM,CAACS,iBAAP,CAAyBW,IAAI,CAACG,KAAL,CAAWL,OAAX,CAAzB;AACD;;AACD3B,QAAAA,KAAK,CAAC+B,WAAN,GAAoBJ,OAApB;AACA,eAAO,IAAP;AACD;;AACD,aAAO,KAAP;AACD","sourcesContent":["import {\n ILayer,\n ILayerPlugin,\n ILngLat,\n IMapService,\n TYPES,\n} from '@antv/l7-core';\nimport Source, { DEFAULT_DATA, DEFAULT_PARSER } from '@antv/l7-source';\nimport { injectable } from 'inversify';\nimport 'reflect-metadata';\n\n@injectable()\nexport default class DataSourcePlugin implements ILayerPlugin {\n protected mapService: IMapService;\n public apply(layer: ILayer) {\n this.mapService = layer.getContainer().get<IMapService>(TYPES.IMapService);\n layer.hooks.init.tap('DataSourcePlugin', () => {\n const source = layer.getSource();\n if (!source) {\n // TODO: 允许用户不使用 layer 的 source 方法,在这里传入一个默认的替换的默认数据\n const { data, options } = layer.sourceOption || {\n data: DEFAULT_DATA,\n options: DEFAULT_PARSER,\n };\n layer.setSource(new Source(data, options));\n }\n\n this.updateClusterData(layer);\n });\n\n // 检测数据是否需要更新\n layer.hooks.beforeRenderData.tap('DataSourcePlugin', () => {\n const neeUpdateCluster = this.updateClusterData(layer);\n const dataSourceNeedUpdate = layer.dataState.dataSourceNeedUpdate;\n layer.dataState.dataSourceNeedUpdate = false;\n return neeUpdateCluster || dataSourceNeedUpdate;\n });\n }\n\n private updateClusterData(layer: ILayer): boolean {\n const source = layer.getSource();\n const cluster = source.cluster;\n const { zoom = 0, maxZoom = 16 } = source.clusterOptions;\n const newZoom = this.mapService.getZoom() - 1;\n const dataSourceNeedUpdate = layer.dataState.dataSourceNeedUpdate;\n // 如果 dataSource 有更新,跳过 zoom 的判断,直接更新一次\n if (\n cluster &&\n (dataSourceNeedUpdate || Math.abs(layer.clusterZoom - newZoom) >= 1)\n ) {\n // TODO 判断数据是否更新\n if (zoom !== Math.floor(newZoom)) {\n source.updateClusterData(Math.floor(newZoom));\n }\n layer.clusterZoom = newZoom;\n return true;\n }\n return false;\n }\n}\n"],"file":"DataSourcePlugin.js"}
1
+ {"version":3,"sources":["../../src/plugins/DataSourcePlugin.ts"],"names":["DataSourcePlugin","layer","mapService","getContainer","get","TYPES","IMapService","hooks","init","tap","source","getSource","sourceOption","data","DEFAULT_DATA","options","DEFAULT_PARSER","setSource","Source","updateClusterData","beforeRenderData","neeUpdateCluster","dataSourceNeedUpdate","dataState","cluster","clusterOptions","zoom","newZoom","getZoom","Math","floor","abs","clusterZoom"],"mappings":";;;;;;;;;;;;;;;;;AAAA;;AAOA;;AACA;;AACA;;;;;;;;IAGqBA,gB,WADpB,4B;;;;;;;;WAGC,eAAaC,KAAb,EAA4B;AAAA;;AAC1B,WAAKC,UAAL,GAAkBD,KAAK,CAACE,YAAN,GAAqBC,GAArB,CAAsCC,cAAMC,WAA5C,CAAlB;AACAL,MAAAA,KAA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Z,QAAAA,MAAM,CAACS,iBAAP,CAAyBU,IAAI,CAACC,KAAL,CAAWH,OAAX,CAAzB;AACD;;AAED,UAAIH,OAAO,IAAIK,IAAI,CAACE,GAAL,CAAS9B,KAAK,CAAC+B,WAAN,GAAoBL,OAA7B,KAAyC,CAAxD,EAA2D;AACzD,YAAID,IAAI,KAAKG,IAAI,CAACC,KAAL,CAAWH,OAAX,CAAb,EAAkC;AAChCjB,UAAAA,MAAM,CAACS,iBAAP,CAAyBU,IAAI,CAACC,KAAL,CAAWH,OAAX,CAAzB;AACD;;AACD1B,QAAAA,KAAK,CAAC+B,WAAN,GAAoBL,OAApB;AACA,eAAO,IAAP;AACD;;AACD,aAAO,KAAP;AACD","sourcesContent":["import {\n ILayer,\n ILayerPlugin,\n ILngLat,\n IMapService,\n TYPES,\n} from '@antv/l7-core';\nimport Source, { DEFAULT_DATA, DEFAULT_PARSER } from '@antv/l7-source';\nimport { injectable } from 'inversify';\nimport 'reflect-metadata';\n\n@injectable()\nexport default class DataSourcePlugin implements ILayerPlugin {\n protected mapService: IMapService;\n public apply(layer: ILayer) {\n this.mapService = layer.getContainer().get<IMapService>(TYPES.IMapService);\n layer.hooks.init.tap('DataSourcePlugin', () => {\n const source = layer.getSource();\n if (!source) {\n // TODO: 允许用户不使用 layer 的 source 方法,在这里传入一个默认的替换的默认数据\n const { data, options } = layer.sourceOption || {\n data: DEFAULT_DATA,\n options: DEFAULT_PARSER,\n };\n layer.setSource(new Source(data, options));\n }\n\n this.updateClusterData(layer);\n });\n\n // 检测数据是否需要更新\n layer.hooks.beforeRenderData.tap('DataSourcePlugin', () => {\n const neeUpdateCluster = this.updateClusterData(layer);\n const dataSourceNeedUpdate = layer.dataState.dataSourceNeedUpdate;\n layer.dataState.dataSourceNeedUpdate = false;\n return neeUpdateCluster || dataSourceNeedUpdate;\n });\n }\n\n private updateClusterData(layer: ILayer): boolean {\n const source = layer.getSource();\n const cluster = source.cluster;\n const { zoom = 0 } = source.clusterOptions;\n const newZoom = this.mapService.getZoom() - 1;\n const dataSourceNeedUpdate = layer.dataState.dataSourceNeedUpdate;\n if (cluster && dataSourceNeedUpdate) {\n // 数据发生更新\n source.updateClusterData(Math.floor(newZoom));\n }\n // 如果 dataSource 有更新,跳过 zoom 的判断,直接更新一次\n if (cluster && Math.abs(layer.clusterZoom - newZoom) >= 1) {\n if (zoom !== Math.floor(newZoom)) {\n source.updateClusterData(Math.floor(newZoom));\n }\n layer.clusterZoom = newZoom;\n return true;\n }\n return false;\n }\n}\n"],"file":"DataSourcePlugin.js"}
@@ -139,17 +139,43 @@ var FeatureScalePlugin = (_dec = (0, _inversify.injectable)(), _dec2 = (0, _inve
139
139
  })) {
140
140
  attributeScale.type = _l7Core.StyleScaleType.VARIABLE;
141
141
  scales.forEach(function (scale) {
142
- if (!attributeScale.callback) {
143
- var _scale$option, _scale$option2, _scale$option3, _scale$option4, _scale$option5;
144
-
145
- if (attributeScale.values && attributeScale.values !== 'text' && ((_scale$option = scale.option) === null || _scale$option === void 0 ? void 0 : _scale$option.type) !== _l7Core.ScaleTypes.DIVERGING && ((_scale$option2 = scale.option) === null || _scale$option2 === void 0 ? void 0 : _scale$option2.type) !== _l7Core.ScaleTypes.SEQUENTIAL) {
146
- scale.scale.range(attributeScale.values);
147
- } else if (((_scale$option3 = scale.option) === null || _scale$option3 === void 0 ? void 0 : _scale$option3.type) === _l7Core.ScaleTypes.CAT) {
148
- scale.scale.range(scale.option.domain);
149
- } else if (((_scale$option4 = scale.option) === null || _scale$option4 === void 0 ? void 0 : _scale$option4.type) === _l7Core.ScaleTypes.DIVERGING || ((_scale$option5 = scale.option) === null || _scale$option5 === void 0 ? void 0 : _scale$option5.type) === _l7Core.ScaleTypes.SEQUENTIAL) {
150
- scale.scale.interpolator(d3interpolate.interpolateRgbBasis(attributeScale.values));
142
+ var _scale$option;
143
+
144
+ if (!attributeScale.callback && attributeScale.values !== 'text') {
145
+ switch ((_scale$option = scale.option) === null || _scale$option === void 0 ? void 0 : _scale$option.type) {
146
+ case _l7Core.ScaleTypes.LOG:
147
+ case _l7Core.ScaleTypes.LINEAR:
148
+ case _l7Core.ScaleTypes.POWER:
149
+ if (attributeScale.values && attributeScale.values.length > 2) {
150
+ var tick = scale.scale.ticks(attributeScale.values.length);
151
+ scale.scale.domain(tick);
152
+ }
153
+
154
+ attributeScale.values ? scale.scale.range(attributeScale.values) : scale.scale.range(scale.option.domain);
155
+ break;
156
+
157
+ case _l7Core.ScaleTypes.QUANTILE:
158
+ case _l7Core.ScaleTypes.QUANTIZE:
159
+ case _l7Core.ScaleTypes.THRESHOLD:
160
+ scale.scale.range(attributeScale.values);
161
+ break;
162
+
163
+ case _l7Core.ScaleTypes.CAT:
164
+ attributeScale.values ? scale.scale.range(attributeScale.values) : scale.scale.range(scale.option.domain);
165
+ break;
166
+
167
+ case _l7Core.ScaleTypes.DIVERGING:
168
+ case _l7Core.ScaleTypes.SEQUENTIAL:
169
+ scale.scale.interpolator(d3interpolate.interpolateRgbBasis(attributeScale.values));
170
+ break;
151
171
  }
152
172
  }
173
+
174
+ if (attributeScale.values === 'text') {
175
+ var _scale$option2;
176
+
177
+ scale.scale.range((_scale$option2 = scale.option) === null || _scale$option2 === void 0 ? void 0 : _scale$option2.domain);
178
+ }
153
179
  });
154
180
  } else {
155
181
  attributeScale.type = _l7Core.StyleScaleType.CONSTANT;