@antv/l7-layers 2.5.36 → 2.5.37-mini12

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 (286) hide show
  1. package/lib/core/BaseLayer.js +10 -4
  2. package/lib/core/BaseLayer.js.map +1 -1
  3. package/lib/core/BaseModel.js +1 -1
  4. package/lib/core/BaseModel.js.map +1 -1
  5. package/lib/core/shape/Path.js +5 -4
  6. package/lib/core/shape/Path.js.map +1 -1
  7. package/lib/core/shape/extrude.js +1 -1
  8. package/lib/core/triangulation.js +13 -9
  9. package/lib/core/triangulation.js.map +1 -1
  10. package/lib/earth/utils.js +1 -1
  11. package/lib/heatmap/models/heatmap.js +13 -18
  12. package/lib/heatmap/models/heatmap.js.map +1 -1
  13. package/lib/image/models/image.js +28 -7
  14. package/lib/image/models/image.js.map +1 -1
  15. package/lib/imagetile/index.js +95 -0
  16. package/lib/imagetile/index.js.map +1 -0
  17. package/lib/imagetile/models/imagetile.js +177 -0
  18. package/lib/imagetile/models/imagetile.js.map +1 -0
  19. package/lib/imagetile/models/index.js +17 -0
  20. package/lib/imagetile/models/index.js.map +1 -0
  21. package/lib/imagetile/utils/ImageTile.js +99 -0
  22. package/lib/imagetile/utils/ImageTile.js.map +1 -0
  23. package/lib/imagetile/utils/Tile.js +324 -0
  24. package/lib/imagetile/utils/Tile.js.map +1 -0
  25. package/lib/imagetile/utils/lruCache.js +109 -0
  26. package/lib/imagetile/utils/lruCache.js.map +1 -0
  27. package/lib/imagetile/utils/tileCache.js +58 -0
  28. package/lib/imagetile/utils/tileCache.js.map +1 -0
  29. package/lib/index.js +16 -8
  30. package/lib/index.js.map +1 -1
  31. package/lib/line/index.js +3 -0
  32. package/lib/line/index.js.map +1 -1
  33. package/lib/line/models/arc.js +2 -2
  34. package/lib/line/models/arc_3d.js +2 -2
  35. package/lib/line/models/arcmini.js +160 -0
  36. package/lib/line/models/arcmini.js.map +1 -0
  37. package/lib/line/models/great_circle.js +2 -2
  38. package/lib/line/models/index.js +3 -0
  39. package/lib/line/models/index.js.map +1 -1
  40. package/lib/line/models/line.js +2 -2
  41. package/lib/plugins/DataMappingPlugin.js +1 -1
  42. package/lib/plugins/DataSourcePlugin.js +5 -1
  43. package/lib/plugins/DataSourcePlugin.js.map +1 -1
  44. package/lib/plugins/FeatureScalePlugin.js +5 -1
  45. package/lib/plugins/FeatureScalePlugin.js.map +1 -1
  46. package/lib/plugins/LayerAnimateStylePlugin.js +1 -1
  47. package/lib/plugins/LayerStylePlugin.js.map +1 -1
  48. package/lib/plugins/LightingPlugin.js +5 -3
  49. package/lib/plugins/LightingPlugin.js.map +1 -1
  50. package/lib/plugins/MultiPassRendererPlugin.js +1 -1
  51. package/lib/plugins/ShaderUniformPlugin.js +3 -1
  52. package/lib/plugins/ShaderUniformPlugin.js.map +1 -1
  53. package/lib/plugins/UpdateStyleAttributePlugin.js +6 -6
  54. package/lib/plugins/UpdateStyleAttributePlugin.js.map +1 -1
  55. package/lib/point/models/image.js.map +1 -1
  56. package/lib/point/shape/Path.js +5 -4
  57. package/lib/point/shape/Path.js.map +1 -1
  58. package/lib/raster/raster.js +1 -1
  59. package/lib/utils/dataMappingStyle.js +1 -1
  60. package/lib/utils/extrude_polyline.js +1 -1
  61. package/lib/utils/polylineNormal.js +1 -1
  62. package/lib/utils/symbol-layout.js +1 -1
  63. package/package.json +7 -6
  64. package/CHANGELOG.md +0 -492
  65. package/LICENSE.md +0 -21
  66. package/es/citybuliding/building.d.ts +0 -17
  67. package/es/citybuliding/building.js +0 -79
  68. package/es/citybuliding/building.js.map +0 -1
  69. package/es/citybuliding/models/build.d.ts +0 -13
  70. package/es/citybuliding/models/build.js +0 -124
  71. package/es/citybuliding/models/build.js.map +0 -1
  72. package/es/core/BaseLayer.d.ts +0 -174
  73. package/es/core/BaseLayer.js +0 -974
  74. package/es/core/BaseLayer.js.map +0 -1
  75. package/es/core/BaseModel.d.ts +0 -135
  76. package/es/core/BaseModel.js +0 -412
  77. package/es/core/BaseModel.js.map +0 -1
  78. package/es/core/interface.d.ts +0 -19
  79. package/es/core/interface.js +0 -7
  80. package/es/core/interface.js.map +0 -1
  81. package/es/core/schema.d.ts +0 -27
  82. package/es/core/schema.js +0 -23
  83. package/es/core/schema.js.map +0 -1
  84. package/es/core/shape/Path.d.ts +0 -39
  85. package/es/core/shape/Path.js +0 -57
  86. package/es/core/shape/Path.js.map +0 -1
  87. package/es/core/shape/extrude.d.ts +0 -17
  88. package/es/core/shape/extrude.js +0 -143
  89. package/es/core/shape/extrude.js.map +0 -1
  90. package/es/core/triangulation.d.ts +0 -109
  91. package/es/core/triangulation.js +0 -328
  92. package/es/core/triangulation.js.map +0 -1
  93. package/es/earth/index.d.ts +0 -17
  94. package/es/earth/index.js +0 -81
  95. package/es/earth/index.js.map +0 -1
  96. package/es/earth/models/atmosphere.d.ts +0 -9
  97. package/es/earth/models/atmosphere.js +0 -125
  98. package/es/earth/models/atmosphere.js.map +0 -1
  99. package/es/earth/models/base.d.ts +0 -16
  100. package/es/earth/models/base.js +0 -193
  101. package/es/earth/models/base.js.map +0 -1
  102. package/es/earth/models/bloomsphere.d.ts +0 -9
  103. package/es/earth/models/bloomsphere.js +0 -125
  104. package/es/earth/models/bloomsphere.js.map +0 -1
  105. package/es/earth/utils.d.ts +0 -26
  106. package/es/earth/utils.js +0 -81
  107. package/es/earth/utils.js.map +0 -1
  108. package/es/glsl.d.js +0 -2
  109. package/es/glsl.d.js.map +0 -1
  110. package/es/heatmap/index.d.ts +0 -22
  111. package/es/heatmap/index.js +0 -123
  112. package/es/heatmap/index.js.map +0 -1
  113. package/es/heatmap/models/grid.d.ts +0 -8
  114. package/es/heatmap/models/grid.js +0 -90
  115. package/es/heatmap/models/grid.js.map +0 -1
  116. package/es/heatmap/models/grid3d.d.ts +0 -8
  117. package/es/heatmap/models/grid3d.js +0 -122
  118. package/es/heatmap/models/grid3d.js.map +0 -1
  119. package/es/heatmap/models/heatmap.d.ts +0 -24
  120. package/es/heatmap/models/heatmap.js +0 -399
  121. package/es/heatmap/models/heatmap.js.map +0 -1
  122. package/es/heatmap/models/hexagon.d.ts +0 -8
  123. package/es/heatmap/models/hexagon.js +0 -90
  124. package/es/heatmap/models/hexagon.js.map +0 -1
  125. package/es/heatmap/models/index.d.ts +0 -5
  126. package/es/heatmap/models/index.js +0 -13
  127. package/es/heatmap/models/index.js.map +0 -1
  128. package/es/heatmap/triangulation.d.ts +0 -5
  129. package/es/heatmap/triangulation.js +0 -38
  130. package/es/heatmap/triangulation.js.map +0 -1
  131. package/es/image/index.d.ts +0 -22
  132. package/es/image/index.js +0 -82
  133. package/es/image/index.js.map +0 -1
  134. package/es/image/models/image.d.ts +0 -18
  135. package/es/image/models/image.js +0 -127
  136. package/es/image/models/image.js.map +0 -1
  137. package/es/image/models/index.d.ts +0 -5
  138. package/es/image/models/index.js +0 -6
  139. package/es/image/models/index.js.map +0 -1
  140. package/es/index.d.ts +0 -11
  141. package/es/index.js +0 -39
  142. package/es/index.js.map +0 -1
  143. package/es/line/index.d.ts +0 -25
  144. package/es/line/index.js +0 -95
  145. package/es/line/index.js.map +0 -1
  146. package/es/line/models/arc.d.ts +0 -12
  147. package/es/line/models/arc.js +0 -281
  148. package/es/line/models/arc.js.map +0 -1
  149. package/es/line/models/arc_3d.d.ts +0 -12
  150. package/es/line/models/arc_3d.js +0 -277
  151. package/es/line/models/arc_3d.js.map +0 -1
  152. package/es/line/models/great_circle.d.ts +0 -12
  153. package/es/line/models/great_circle.js +0 -269
  154. package/es/line/models/great_circle.js.map +0 -1
  155. package/es/line/models/index.d.ts +0 -5
  156. package/es/line/models/index.js +0 -12
  157. package/es/line/models/index.js.map +0 -1
  158. package/es/line/models/line.d.ts +0 -13
  159. package/es/line/models/line.js +0 -342
  160. package/es/line/models/line.js.map +0 -1
  161. package/es/plugins/DataMappingPlugin.d.ts +0 -13
  162. package/es/plugins/DataMappingPlugin.js +0 -199
  163. package/es/plugins/DataMappingPlugin.js.map +0 -1
  164. package/es/plugins/DataSourcePlugin.d.ts +0 -7
  165. package/es/plugins/DataSourcePlugin.js +0 -73
  166. package/es/plugins/DataSourcePlugin.js.map +0 -1
  167. package/es/plugins/FeatureScalePlugin.d.ts +0 -26
  168. package/es/plugins/FeatureScalePlugin.js +0 -270
  169. package/es/plugins/FeatureScalePlugin.js.map +0 -1
  170. package/es/plugins/LayerAnimateStylePlugin.d.ts +0 -7
  171. package/es/plugins/LayerAnimateStylePlugin.js +0 -50
  172. package/es/plugins/LayerAnimateStylePlugin.js.map +0 -1
  173. package/es/plugins/LayerModelPlugin.d.ts +0 -8
  174. package/es/plugins/LayerModelPlugin.js +0 -34
  175. package/es/plugins/LayerModelPlugin.js.map +0 -1
  176. package/es/plugins/LayerStylePlugin.d.ts +0 -8
  177. package/es/plugins/LayerStylePlugin.js +0 -35
  178. package/es/plugins/LayerStylePlugin.js.map +0 -1
  179. package/es/plugins/LightingPlugin.d.ts +0 -36
  180. package/es/plugins/LightingPlugin.js +0 -100
  181. package/es/plugins/LightingPlugin.js.map +0 -1
  182. package/es/plugins/MultiPassRendererPlugin.d.ts +0 -37
  183. package/es/plugins/MultiPassRendererPlugin.js +0 -79
  184. package/es/plugins/MultiPassRendererPlugin.js.map +0 -1
  185. package/es/plugins/PixelPickingPlugin.d.ts +0 -8
  186. package/es/plugins/PixelPickingPlugin.js +0 -112
  187. package/es/plugins/PixelPickingPlugin.js.map +0 -1
  188. package/es/plugins/RegisterStyleAttributePlugin.d.ts +0 -11
  189. package/es/plugins/RegisterStyleAttributePlugin.js +0 -98
  190. package/es/plugins/RegisterStyleAttributePlugin.js.map +0 -1
  191. package/es/plugins/ShaderUniformPlugin.d.ts +0 -16
  192. package/es/plugins/ShaderUniformPlugin.js +0 -78
  193. package/es/plugins/ShaderUniformPlugin.js.map +0 -1
  194. package/es/plugins/UpdateModelPlugin.d.ts +0 -8
  195. package/es/plugins/UpdateModelPlugin.js +0 -27
  196. package/es/plugins/UpdateModelPlugin.js.map +0 -1
  197. package/es/plugins/UpdateStyleAttributePlugin.d.ts +0 -12
  198. package/es/plugins/UpdateStyleAttributePlugin.js +0 -74
  199. package/es/plugins/UpdateStyleAttributePlugin.js.map +0 -1
  200. package/es/point/index.d.ts +0 -30
  201. package/es/point/index.js +0 -130
  202. package/es/point/index.js.map +0 -1
  203. package/es/point/models/extrude.d.ts +0 -14
  204. package/es/point/models/extrude.js +0 -180
  205. package/es/point/models/extrude.js.map +0 -1
  206. package/es/point/models/fill.d.ts +0 -17
  207. package/es/point/models/fill.js +0 -247
  208. package/es/point/models/fill.js.map +0 -1
  209. package/es/point/models/icon-font.d.ts +0 -11
  210. package/es/point/models/icon-font.js +0 -181
  211. package/es/point/models/icon-font.js.map +0 -1
  212. package/es/point/models/image.d.ts +0 -11
  213. package/es/point/models/image.js +0 -207
  214. package/es/point/models/image.js.map +0 -1
  215. package/es/point/models/index.d.ts +0 -5
  216. package/es/point/models/index.js +0 -16
  217. package/es/point/models/index.js.map +0 -1
  218. package/es/point/models/normal.d.ts +0 -21
  219. package/es/point/models/normal.js +0 -155
  220. package/es/point/models/normal.js.map +0 -1
  221. package/es/point/models/text.d.ts +0 -56
  222. package/es/point/models/text.js +0 -522
  223. package/es/point/models/text.js.map +0 -1
  224. package/es/point/shape/Path.d.ts +0 -40
  225. package/es/point/shape/Path.js +0 -57
  226. package/es/point/shape/Path.js.map +0 -1
  227. package/es/point/shape/extrude.d.ts +0 -15
  228. package/es/point/shape/extrude.js +0 -58
  229. package/es/point/shape/extrude.js.map +0 -1
  230. package/es/polygon/index.d.ts +0 -22
  231. package/es/polygon/index.js +0 -124
  232. package/es/polygon/index.js.map +0 -1
  233. package/es/polygon/models/extrude.d.ts +0 -13
  234. package/es/polygon/models/extrude.js +0 -139
  235. package/es/polygon/models/extrude.js.map +0 -1
  236. package/es/polygon/models/fill.d.ts +0 -13
  237. package/es/polygon/models/fill.js +0 -108
  238. package/es/polygon/models/fill.js.map +0 -1
  239. package/es/polygon/models/index.d.ts +0 -5
  240. package/es/polygon/models/index.js +0 -20
  241. package/es/polygon/models/index.js.map +0 -1
  242. package/es/raster/buffers/triangulation.d.ts +0 -6
  243. package/es/raster/buffers/triangulation.js +0 -28
  244. package/es/raster/buffers/triangulation.js.map +0 -1
  245. package/es/raster/image.d.ts +0 -0
  246. package/es/raster/image.js +0 -2
  247. package/es/raster/image.js.map +0 -1
  248. package/es/raster/index.d.ts +0 -28
  249. package/es/raster/index.js +0 -83
  250. package/es/raster/index.js.map +0 -1
  251. package/es/raster/models/index.d.ts +0 -5
  252. package/es/raster/models/index.js +0 -7
  253. package/es/raster/models/index.js.map +0 -1
  254. package/es/raster/models/raster.d.ts +0 -19
  255. package/es/raster/models/raster.js +0 -152
  256. package/es/raster/models/raster.js.map +0 -1
  257. package/es/raster/raster.d.ts +0 -30
  258. package/es/raster/raster.js +0 -178
  259. package/es/raster/raster.js.map +0 -1
  260. package/es/raster/raster2d.d.ts +0 -27
  261. package/es/raster/raster2d.js +0 -158
  262. package/es/raster/raster2d.js.map +0 -1
  263. package/es/utils/blend.d.ts +0 -2
  264. package/es/utils/blend.js +0 -55
  265. package/es/utils/blend.js.map +0 -1
  266. package/es/utils/collision-index.d.ts +0 -47
  267. package/es/utils/collision-index.js +0 -87
  268. package/es/utils/collision-index.js.map +0 -1
  269. package/es/utils/dataMappingStyle.d.ts +0 -30
  270. package/es/utils/dataMappingStyle.js +0 -88
  271. package/es/utils/dataMappingStyle.js.map +0 -1
  272. package/es/utils/extrude_polyline.d.ts +0 -48
  273. package/es/utils/extrude_polyline.js +0 -405
  274. package/es/utils/extrude_polyline.js.map +0 -1
  275. package/es/utils/geo.d.ts +0 -3
  276. package/es/utils/geo.js +0 -24
  277. package/es/utils/geo.js.map +0 -1
  278. package/es/utils/grid-index.d.ts +0 -28
  279. package/es/utils/grid-index.js +0 -193
  280. package/es/utils/grid-index.js.map +0 -1
  281. package/es/utils/polylineNormal.d.ts +0 -9
  282. package/es/utils/polylineNormal.js +0 -171
  283. package/es/utils/polylineNormal.js.map +0 -1
  284. package/es/utils/symbol-layout.d.ts +0 -43
  285. package/es/utils/symbol-layout.js +0 -260
  286. package/es/utils/symbol-layout.js.map +0 -1
@@ -0,0 +1,160 @@
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 _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
15
+
16
+ var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
17
+
18
+ var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
19
+
20
+ var _isNumber2 = _interopRequireDefault(require("lodash/isNumber"));
21
+
22
+ var _l7Core = require("@antv/l7-core");
23
+
24
+ var _l7Utils = require("@antv/l7-utils");
25
+
26
+ var _BaseModel2 = _interopRequireDefault(require("../../core/BaseModel"));
27
+
28
+ var _triangulation = require("../../core/triangulation");
29
+
30
+ 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); }; }
31
+
32
+ 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; } }
33
+
34
+ var line_arcmini_frag = "#define LineTypeSolid 0.0\n#define Animate 0.0\n\nuniform float u_opacity;\nuniform float u_blur : 0.9;\n// varying vec2 v_normal;\nvarying vec4 v_color;\n\nuniform float u_time;\nuniform vec4 u_aimate: [ 0, 2., 1.0, 0.2 ];\n\nuniform float segmentNumber;\nvarying float v_distance_ratio;\n\nuniform float u_linearColor: 0;\nuniform vec4 u_sourceColor;\nuniform vec4 u_targetColor;\n\n#pragma include \"picking\"\n\nvoid main() {\n\n // \u8BBE\u7F6E\u5F27\u7EBF\u7684\u5E95\u8272\n if(u_linearColor == 1.0) { // \u4F7F\u7528\u6E10\u53D8\u989C\u8272\n gl_FragColor = mix(u_sourceColor, u_targetColor, v_distance_ratio);\n } else { // \u4F7F\u7528 color \u65B9\u6CD5\u4F20\u5165\u7684\u989C\u8272\n gl_FragColor = v_color;\n }\n \n \n gl_FragColor.a *= u_opacity;\n\n if(u_aimate.x == Animate) {\n float animateSpeed = u_time / u_aimate.y; // \u8FD0\u52A8\u901F\u5EA6\n float alpha =1.0 - fract( mod(1.0- v_distance_ratio, u_aimate.z)* (1.0/ u_aimate.z) + u_time / u_aimate.y);\n alpha = (alpha + u_aimate.w -1.0) / u_aimate.w;\n // alpha = smoothstep(0., 1., alpha);\n alpha = clamp(alpha, 0.0, 1.0);\n gl_FragColor.a *= alpha;\n }\n gl_FragColor = filterColor(gl_FragColor);\n}";
35
+ var line_arcmini_vert = "#define LineTypeSolid 0.0\n#define LineTypeDash 1.0\n#define Animate 0.0\n\nattribute vec4 a_Color;\nattribute vec3 a_Position;\nattribute vec4 a_Instance;\nattribute float a_Size;\nuniform mat4 u_ModelMatrix;\nuniform mat4 u_Mvp;\nuniform float segmentNumber;\nuniform vec4 u_aimate: [ 0, 2., 1.0, 0.2 ];\nvarying vec4 v_color;\n// varying vec2 v_normal;\n\nuniform float u_lineDir: 1.0;\n\n// \u504F\u79FB\u91CF\nuniform float u_thetaOffset: 0.314;\n\nuniform float u_opacity: 1.0;\nvarying float v_distance_ratio;\n\n#pragma include \"projection\"\n#pragma include \"project\"\n#pragma include \"picking\"\n\nfloat bezier3(vec3 arr, float t) {\n float ut = 1. - t;\n return (arr.x * ut + arr.y * t) * ut + (arr.y * ut + arr.z * t) * t;\n}\nvec2 midPoint(vec2 source, vec2 target) {\n vec2 center = target - source;\n float r = length(center);\n float theta = atan(center.y, center.x);\n float thetaOffset = u_thetaOffset;\n float r2 = r / 2.0 / cos(thetaOffset);\n float theta2 = theta + thetaOffset;\n vec2 mid = vec2(r2*cos(theta2) + source.x, r2*sin(theta2) + source.y);\n if(u_lineDir == 1.0) { // \u6B63\u5411\n return mid;\n } else { // \u9006\u5411\n // (mid + vmin)/2 = (s + t)/2\n vec2 vmid = source + target - mid;\n return vmid;\n }\n // return mid;\n}\nfloat getSegmentRatio(float index) {\n return smoothstep(0.0, 1.0, index / (segmentNumber - 1.));\n}\nvec2 interpolate (vec2 source, vec2 target, float t) {\n // if the angularDist is PI, linear interpolation is applied. otherwise, use spherical interpolation\n vec2 mid = midPoint(source, target);\n vec3 x = vec3(source.x, mid.x, target.x);\n vec3 y = vec3(source.y, mid.y, target.y);\n return vec2(bezier3(x ,t), bezier3(y,t));\n}\nvec2 getExtrusionOffset(vec2 line_clipspace, float offset_direction) {\n // normalized direction of the line\n vec2 dir_screenspace = normalize(line_clipspace);\n // rotate by 90 degrees\n dir_screenspace = vec2(-dir_screenspace.y, dir_screenspace.x);\n vec2 offset = dir_screenspace * offset_direction * setPickingSize(a_Size) / 2.0;\n return offset;\n}\nvec2 getNormal(vec2 line_clipspace, float offset_direction) {\n // normalized direction of the line\n vec2 dir_screenspace = normalize(line_clipspace);\n // rotate by 90 degrees\n dir_screenspace = vec2(-dir_screenspace.y, dir_screenspace.x);\n return reverse_offset_normal(vec3(dir_screenspace,1.0)).xy * sign(offset_direction);\n}\n\nvoid main() {\n v_color = a_Color;\n \n vec2 source = a_Instance.rg; // \u8D77\u59CB\u70B9\n vec2 target = a_Instance.ba; // \u7EC8\u70B9\n float segmentIndex = a_Position.x;\n float segmentRatio = getSegmentRatio(segmentIndex);\n\n float indexDir = mix(-1.0, 1.0, step(segmentIndex, 0.0));\n float nextSegmentRatio = getSegmentRatio(segmentIndex + indexDir);\n\n v_distance_ratio = segmentIndex / segmentNumber;\n \n if(u_aimate.x == Animate && u_lineDir != 1.0) {\n v_distance_ratio = 1.0 - v_distance_ratio;\n }\n\n vec4 curr = project_position(vec4(interpolate(source, target, segmentRatio), 0.0, 1.0));\n vec4 next = project_position(vec4(interpolate(source, target, nextSegmentRatio), 0.0, 1.0));\n // v_normal = getNormal((next.xy - curr.xy) * indexDir, a_Position.y);\n //unProjCustomCoord\n \n vec2 offset = project_pixel(getExtrusionOffset((next.xy - curr.xy) * indexDir, a_Position.y));\n\n if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) { // gaode2.x\n gl_Position = u_Mvp * (vec4(curr.xy + offset, 0, 1.0));\n } else {\n gl_Position = project_common_position_to_clipspace(vec4(curr.xy + offset, 0, 1.0));\n }\n setPickingColor(a_PickingColor);\n}\n";
36
+
37
+ var ArcMiniModel = function (_BaseModel) {
38
+ (0, _inherits2.default)(ArcMiniModel, _BaseModel);
39
+
40
+ var _super = _createSuper(ArcMiniModel);
41
+
42
+ function ArcMiniModel() {
43
+ (0, _classCallCheck2.default)(this, ArcMiniModel);
44
+ return _super.apply(this, arguments);
45
+ }
46
+
47
+ (0, _createClass2.default)(ArcMiniModel, [{
48
+ key: "getUninforms",
49
+ value: function getUninforms() {
50
+ var _ref = this.layer.getLayerConfig(),
51
+ opacity = _ref.opacity,
52
+ sourceColor = _ref.sourceColor,
53
+ targetColor = _ref.targetColor,
54
+ _ref$forward = _ref.forward,
55
+ forward = _ref$forward === void 0 ? true : _ref$forward,
56
+ _ref$segmentNumber = _ref.segmentNumber,
57
+ segmentNumber = _ref$segmentNumber === void 0 ? 30 : _ref$segmentNumber,
58
+ _ref$thetaOffset = _ref.thetaOffset,
59
+ thetaOffset = _ref$thetaOffset === void 0 ? 0.314 : _ref$thetaOffset;
60
+
61
+ var useLinearColor = 0;
62
+ var sourceColorArr = [0, 0, 0, 0];
63
+ var targetColorArr = [0, 0, 0, 0];
64
+
65
+ if (sourceColor && targetColor) {
66
+ sourceColorArr = (0, _l7Utils.rgb2arr)(sourceColor);
67
+ targetColorArr = (0, _l7Utils.rgb2arr)(targetColor);
68
+ useLinearColor = 1;
69
+ }
70
+
71
+ return {
72
+ u_thetaOffset: thetaOffset,
73
+ u_opacity: (0, _isNumber2.default)(opacity) ? opacity : 1.0,
74
+ segmentNumber: segmentNumber,
75
+ u_blur: 0.9,
76
+ u_lineDir: forward ? 1 : -1,
77
+ u_linearColor: useLinearColor,
78
+ u_sourceColor: sourceColorArr,
79
+ u_targetColor: targetColorArr
80
+ };
81
+ }
82
+ }, {
83
+ key: "getAnimateUniforms",
84
+ value: function getAnimateUniforms() {
85
+ var _ref2 = this.layer.getLayerConfig(),
86
+ animateOption = _ref2.animateOption;
87
+
88
+ return {
89
+ u_aimate: this.animateOption2Array(animateOption),
90
+ u_time: this.layer.getLayerAnimateTime()
91
+ };
92
+ }
93
+ }, {
94
+ key: "initModels",
95
+ value: function initModels() {
96
+ return this.buildModels();
97
+ }
98
+ }, {
99
+ key: "buildModels",
100
+ value: function buildModels() {
101
+ var _ref3 = this.layer.getLayerConfig(),
102
+ _ref3$segmentNumber = _ref3.segmentNumber,
103
+ segmentNumber = _ref3$segmentNumber === void 0 ? 30 : _ref3$segmentNumber;
104
+
105
+ return [this.layer.buildLayerModel({
106
+ moduleName: 'arc2dminiline',
107
+ vertexShader: line_arcmini_vert,
108
+ fragmentShader: line_arcmini_frag,
109
+ triangulation: _triangulation.LineArcTriangulation,
110
+ depth: {
111
+ enable: false
112
+ },
113
+ blend: this.getBlend(),
114
+ segmentNumber: segmentNumber
115
+ })];
116
+ }
117
+ }, {
118
+ key: "registerBuiltinAttributes",
119
+ value: function registerBuiltinAttributes() {
120
+ this.styleAttributeService.registerStyleAttribute({
121
+ name: 'size',
122
+ type: _l7Core.AttributeType.Attribute,
123
+ descriptor: {
124
+ name: 'a_Size',
125
+ buffer: {
126
+ usage: _l7Core.gl.DYNAMIC_DRAW,
127
+ data: [],
128
+ type: _l7Core.gl.FLOAT
129
+ },
130
+ size: 1,
131
+ update: function update(feature, featureIdx, vertex, attributeIdx) {
132
+ var _feature$size = feature.size,
133
+ size = _feature$size === void 0 ? 1 : _feature$size;
134
+ return Array.isArray(size) ? [size[0]] : [size];
135
+ }
136
+ }
137
+ });
138
+ this.styleAttributeService.registerStyleAttribute({
139
+ name: 'instance',
140
+ type: _l7Core.AttributeType.Attribute,
141
+ descriptor: {
142
+ name: 'a_Instance',
143
+ buffer: {
144
+ usage: _l7Core.gl.STATIC_DRAW,
145
+ data: [],
146
+ type: _l7Core.gl.FLOAT
147
+ },
148
+ size: 4,
149
+ update: function update(feature, featureIdx, vertex, attributeIdx) {
150
+ return [vertex[3], vertex[4], vertex[5], vertex[6]];
151
+ }
152
+ }
153
+ });
154
+ }
155
+ }]);
156
+ return ArcMiniModel;
157
+ }(_BaseModel2.default);
158
+
159
+ exports.default = ArcMiniModel;
160
+ //# sourceMappingURL=arcmini.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/line/models/arcmini.ts"],"names":["ArcMiniModel","layer","getLayerConfig","opacity","sourceColor","targetColor","forward","segmentNumber","thetaOffset","useLinearColor","sourceColorArr","targetColorArr","u_thetaOffset","u_opacity","u_blur","u_lineDir","u_linearColor","u_sourceColor","u_targetColor","animateOption","u_aimate","animateOption2Array","u_time","getLayerAnimateTime","buildModels","buildLayerModel","moduleName","vertexShader","line_arcmini_vert","fragmentShader","line_arcmini_frag","triangulation","LineArcTriangulation","depth","enable","blend","getBlend","styleAttributeService","registerStyleAttribute","name","type","AttributeType","Attribute","descriptor","buffer","usage","gl","DYNAMIC_DRAW","data","FLOAT","size","update","feature","featureIdx","vertex","attributeIdx","Array","isArray","STATIC_DRAW","BaseModel"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;;AAUA;;AAEA;;AAEA;;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AACA,IAAD,CAAzC;AACD;AAjBS;AAHoC,OAAlD;AAwBA,WAAKb,qBAAL,CAA2BC,sBAA3B,CAAkD;AAChDC,QAAAA,IAAI,EAAE,UAD0C;AAEhDC,QAAAA,IAAI,EAAEC,sBAAcC,SAF4B;AAGhDC,QAAAA,UAAU,EAAE;AACVJ,UAAAA,IAAI,EAAE,YADI;AAEVK,UAAAA,MAAM,EAAE;AACNC,YAAAA,KAAK,EAAEC,WAAGY,WADJ;AAENV,YAAAA,IAAI,EAAE,EAFA;AAGNR,YAAAA,IAAI,EAAEM,WAAGG;AAHH,WAFE;AAOVC,UAAAA,IAAI,EAAE,CAPI;AAQVC,UAAAA,MAAM,EAAE,gBACNC,OADM,EAENC,UAFM,EAGNC,MAHM,EAINC,YAJM,EAKH;AACH,mBAAO,CAACD,MAAM,CAAC,CAAD,CAAP,EAAYA,MAAM,CAAC,CAAD,CAAlB,EAAuBA,MAAM,CAAC,CAAD,CAA7B,EAAkCA,MAAM,CAAC,CAAD,CAAxC,CAAP;AACD;AAfS;AAHoC,OAAlD;AAqBD;;;EAlHuCK,mB","sourcesContent":["import {\n AttributeType,\n gl,\n IAnimateOption,\n IEncodeFeature,\n ILayerConfig,\n IModel,\n IModelUniform,\n} from '@antv/l7-core';\n\nimport { rgb2arr } from '@antv/l7-utils';\nimport { isNumber } from 'lodash';\nimport BaseModel from '../../core/BaseModel';\nimport { ILineLayerStyleOptions } from '../../core/interface';\nimport { LineArcTriangulation } from '../../core/triangulation';\nimport line_arcmini_frag from '../shaders/line_arcmini_frag.glsl';\nimport line_arcmini_vert from '../shaders/line_arcmini_vert.glsl';\n\nexport default class ArcMiniModel extends BaseModel {\n public getUninforms(): IModelUniform {\n const {\n opacity,\n sourceColor,\n targetColor,\n forward = true,\n segmentNumber = 30,\n thetaOffset = 0.314,\n } = this.layer.getLayerConfig() as ILineLayerStyleOptions;\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 return {\n u_thetaOffset: thetaOffset,\n\n u_opacity: isNumber(opacity) ? opacity : 1.0,\n\n segmentNumber,\n u_blur: 0.9,\n u_lineDir: forward ? 1 : -1,\n\n // 渐变色支持参数\n u_linearColor: useLinearColor,\n u_sourceColor: sourceColorArr,\n u_targetColor: targetColorArr,\n };\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 return this.buildModels();\n }\n\n public buildModels(): IModel[] {\n const {\n segmentNumber = 30,\n } = this.layer.getLayerConfig() as ILineLayerStyleOptions;\n\n return [\n this.layer.buildLayerModel({\n moduleName: 'arc2dminiline',\n vertexShader: line_arcmini_vert,\n fragmentShader: line_arcmini_frag,\n triangulation: LineArcTriangulation,\n depth: { enable: false },\n blend: this.getBlend(),\n segmentNumber,\n }),\n ];\n }\n\n protected registerBuiltinAttributes() {\n // point layer size;\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: 1,\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 as number];\n },\n },\n });\n\n this.styleAttributeService.registerStyleAttribute({\n name: 'instance', // 弧线起始点信息\n type: AttributeType.Attribute,\n descriptor: {\n name: 'a_Instance',\n buffer: {\n usage: gl.STATIC_DRAW,\n data: [],\n type: gl.FLOAT,\n },\n size: 4,\n update: (\n feature: IEncodeFeature,\n featureIdx: number,\n vertex: number[],\n attributeIdx: number,\n ) => {\n return [vertex[3], vertex[4], vertex[5], vertex[6]];\n },\n },\n });\n }\n}\n"],"file":"arcmini.js"}
@@ -35,8 +35,8 @@ function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflec
35
35
 
36
36
  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; } }
37
37
 
38
- var line_arc_frag = "#define LineTypeSolid 0.0\n#define LineTypeDash 1.0\n#define Animate 0.0\n#define LineTexture 1.0\n\nuniform float u_opacity;\nuniform float u_textureBlend;\nuniform float u_blur : 0.9;\nuniform float u_line_type: 0.0;\n// varying vec2 v_normal;\nvarying vec4 v_dash_array;\nvarying float v_distance_ratio;\nvarying vec4 v_color;\n\nuniform float u_time;\nuniform vec4 u_aimate: [ 0, 2., 1.0, 0.2 ];\n\nuniform float u_line_texture: 0.0;\nuniform sampler2D u_texture;\nuniform vec2 u_textSize;\nuniform float segmentNumber;\n\nvarying vec4 v_dataset; // \u6570\u636E\u96C6\n\nvarying vec2 v_iconMapUV;\n\nuniform float u_linearColor: 0;\nuniform vec4 u_sourceColor;\nuniform vec4 u_targetColor;\n\nvarying mat4 styleMappingMat;\n\n#pragma include \"picking\"\n#pragma include \"project\"\n#pragma include \"projection\"\n\nvoid main() {\n float opacity = styleMappingMat[0][0];\n float animateSpeed = 0.0;\n float d_segmentIndex = v_dataset.g;\n \n // \u8BBE\u7F6E\u5F27\u7EBF\u7684\u5E95\u8272\n if(u_linearColor == 1.0) { // \u4F7F\u7528\u6E10\u53D8\u989C\u8272\n gl_FragColor = mix(u_sourceColor, u_targetColor, d_segmentIndex/segmentNumber);\n } else { // \u4F7F\u7528 color \u65B9\u6CD5\u4F20\u5165\u7684\u989C\u8272\n gl_FragColor = v_color;\n }\n\n // float blur = 1.- smoothstep(u_blur, 1., length(v_normal.xy));\n // float blur = smoothstep(1.0, u_blur, length(v_normal.xy));\n gl_FragColor.a *= opacity;\n if(u_line_type == LineTypeDash) {\n float flag = 0.;\n float dashLength = mod(v_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 // \u8BBE\u7F6E\u5F27\u7EBF\u7684\u52A8\u753B\u6A21\u5F0F\n if(u_aimate.x == Animate) {\n animateSpeed = u_time / u_aimate.y;\n float alpha =1.0 - fract( mod(1.0- smoothstep(0.0, 1.0, v_distance_ratio), u_aimate.z)* (1.0/ u_aimate.z) + u_time / u_aimate.y);\n alpha = (alpha + u_aimate.w -1.0) / u_aimate.w;\n alpha = smoothstep(0., 1., alpha);\n gl_FragColor.a *= alpha;\n }\n\n // \u8BBE\u7F6E\u5F27\u7EBF\u7684\u8D34\u56FE\n if(LineTexture == u_line_texture && u_line_type != LineTypeDash) { \n float arcRadio = smoothstep( 0.0, 1.0, (d_segmentIndex / (segmentNumber - 1.0)));\n // float arcRadio = d_segmentIndex / (segmentNumber - 1.0);\n float count = v_dataset.b; // \u8D34\u56FE\u5728\u5F27\u7EBF\u4E0A\u91CD\u590D\u7684\u6570\u91CF\n float u = fract(arcRadio * count - animateSpeed * count);\n // float u = fract(arcRadio * count - animateSpeed);\n if(u_aimate.x == Animate) {\n u = gl_FragColor.a/opacity;\n }\n\n float v = v_dataset.a; // \u7EBF\u56FE\u5C42\u8D34\u56FE\u90E8\u5206\u7684 v \u5750\u6807\u503C\n\n vec2 uv= v_iconMapUV / u_textSize + vec2(u, v) / u_textSize * 64.;\n vec4 pattern = texture2D(u_texture, uv);\n \n // \u8BBE\u7F6E\u8D34\u56FE\u548C\u5E95\u8272\u7684\u53E0\u52A0\u6A21\u5F0F\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\n // gl_FragColor = filterColor(gl_FragColor);\n}";
39
- var line_arc2d_vert = "#define LineTypeSolid 0.0\n#define LineTypeDash 1.0\n#define Animate 0.0\n#define LineTexture 1.0\n\nattribute vec4 a_Color;\nattribute vec3 a_Position;\nattribute vec4 a_Instance;\nattribute float a_Size;\nuniform mat4 u_ModelMatrix;\nuniform mat4 u_Mvp;\nuniform float segmentNumber;\nuniform vec4 u_aimate: [ 0, 2., 1.0, 0.2 ];\nvarying vec4 v_color;\n// varying vec2 v_normal;\n\nvarying float v_distance_ratio;\nuniform float u_line_type: 0.0;\nuniform vec4 u_dash_array: [10.0, 5., 0, 0];\nvarying vec4 v_dash_array;\n\nuniform float u_icon_step: 100;\nuniform float u_line_texture: 0.0;\n\nvarying vec4 v_dataset; // \u6570\u636E\u96C6\n\nattribute vec2 a_iconMapUV;\nvarying vec2 v_iconMapUV;\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\n#pragma include \"projection\"\n#pragma include \"project\"\n#pragma include \"picking\"\n\nfloat maps (float value, float start1, float stop1, float start2, float stop2) {\n return start2 + (stop2 - start2) * ((value - start1) / (stop1 - start1));\n}\n\nfloat getSegmentRatio(float index) {\n return smoothstep(0.0, 1.0, index / (segmentNumber - 1.));\n}\n\nfloat paraboloid(vec2 source, vec2 target, float ratio) {\n vec2 x = mix(source, target, ratio);\n vec2 center = mix(source, target, 0.5);\n float dSourceCenter = distance(source, center);\n float dXCenter = distance(x, center);\n return (dSourceCenter + dXCenter) * (dSourceCenter - dXCenter);\n}\n\nvec3 getPos(vec2 source, vec2 target, float segmentRatio) {\n float vertex_height = paraboloid(source, target, segmentRatio);\n\n return vec3(\n mix(source, target, segmentRatio),\n sqrt(max(0.0, vertex_height))\n );\n}\nvec2 getExtrusionOffset(vec2 line_clipspace, float offset_direction) {\n // normalized direction of the line\n vec2 dir_screenspace = normalize(line_clipspace);\n // rotate by 90 degrees\n dir_screenspace = vec2(-dir_screenspace.y, dir_screenspace.x);\n vec2 offset = dir_screenspace * offset_direction * setPickingSize(a_Size)/ 2.0;\n return offset;\n}\nvec2 getNormal(vec2 line_clipspace, float offset_direction) {\n // normalized direction of the line\n vec2 dir_screenspace = normalize(line_clipspace);\n // rotate by 90 degrees\n dir_screenspace = vec2(-dir_screenspace.y, dir_screenspace.x);\n return reverse_offset_normal(vec3(dir_screenspace,1.0)).xy * sign(offset_direction);\n}\nfloat getAngularDist (vec2 source, vec2 target) {\n vec2 delta = source - target;\n vec2 sin_half_delta = sin(delta / 2.0);\n float a =\n sin_half_delta.y * sin_half_delta.y +\n cos(source.y) * cos(target.y) *\n sin_half_delta.x * sin_half_delta.x;\n return 2.0 * atan(sqrt(a), sqrt(1.0 - a));\n}\n\nvec2 midPoint(vec2 source, vec2 target) {\n vec2 center = target - source;\n float r = length(center);\n float theta = atan(center.y, center.x);\n float thetaOffset = 0.314;\n float r2 = r / 2.0 / cos(thetaOffset);\n float theta2 = theta + thetaOffset;\n vec2 mid = vec2(r2*cos(theta2) + source.x, r2*sin(theta2) + source.y);\n return mid;\n}\nfloat bezier3(vec3 arr, float t) {\n float ut = 1. - t;\n return (arr.x * ut + arr.y * t) * ut + (arr.y * ut + arr.z * t) * t;\n}\n\nvec2 interpolate (vec2 source, vec2 target, float angularDist, float t) {\n // if the angularDist is PI, linear interpolation is applied. otherwise, use spherical interpolation\n if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) { // gaode2.x\n vec2 mid = midPoint(source, target);\n vec3 x = vec3(source.x, mid.x, target.x);\n vec3 y = vec3(source.y, mid.y, target.y);\n return vec2(bezier3(x ,t), bezier3(y,t));\n }else {\n if(abs(angularDist - PI) < 0.001) {\n return (1.0 - t) * source + t * target;\n }\n float a = sin((1.0 - t) * angularDist) / sin(angularDist);\n float b = sin(t * angularDist) / sin(angularDist);\n vec2 sin_source = sin(source);\n vec2 cos_source = cos(source);\n vec2 sin_target = sin(target);\n vec2 cos_target = cos(target);\n float x = a * cos_source.y * cos_source.x + b * cos_target.y * cos_target.x;\n float y = a * cos_source.y * sin_source.x + b * cos_target.y * sin_target.x;\n float z = a * sin_source.y + b * sin_target.y;\n return vec2(atan(y, x), atan(z, sqrt(x * x + y * y)));\n }\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\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 v_color = a_Color;\n vec2 source = radians(a_Instance.rg);\n vec2 target = radians(a_Instance.ba);\n float angularDist = getAngularDist(source, target);\n float segmentIndex = a_Position.x;\n float segmentRatio = getSegmentRatio(segmentIndex);\n float indexDir = mix(-1.0, 1.0, step(segmentIndex, 0.0));\n if(u_line_type == LineTypeDash) {\n v_distance_ratio = segmentIndex / segmentNumber;\n vec2 s = source;\n vec2 t = target;\n \n if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) { // gaode2.x\n s = unProjCustomCoord(source);\n t = unProjCustomCoord(target);\n }\n float total_Distance = pixelDistance(s, t) / 2.0 * PI;\n total_Distance = total_Distance*8.0;\n // float total_Distance = pixelDistance(a_Instance.rg, a_Instance.ba);\n v_dash_array = pow(2.0, 20.0 - u_Zoom) * u_dash_array / (total_Distance / segmentNumber * segmentIndex);\n }\n if(u_aimate.x == Animate) {\n v_distance_ratio = segmentIndex / segmentNumber;\n }\n float nextSegmentRatio = getSegmentRatio(segmentIndex + indexDir);\n v_distance_ratio = segmentIndex / segmentNumber;\n vec4 curr = project_position(vec4(degrees(interpolate(source, target, angularDist, segmentRatio)), 0.0, 1.0));\n vec4 next = project_position(vec4(degrees(interpolate(source, target, angularDist, nextSegmentRatio)), 0.0, 1.0));\n // v_normal = getNormal((next.xy - curr.xy) * indexDir, a_Position.y);\n vec2 offset = project_pixel(getExtrusionOffset((next.xy - curr.xy) * indexDir, a_Position.y));\n // vec4 project_pos = project_position(vec4(curr.xy, 0, 1.0));\n // gl_Position = project_common_position_to_clipspace(vec4(curr.xy + offset, curr.z, 1.0));\n\n v_dataset.g = a_Position.x; // \u8BE5\u9876\u70B9\u5728\u5F27\u7EBF\u4E0A\u7684\u5206\u6BB5\u6392\u5E8F\n if(LineTexture == u_line_texture) { // \u5F00\u542F\u8D34\u56FE\u6A21\u5F0F \n // float mapZoomScale = u_CoordinateSystem !== COORDINATE_SYSTEM_P20_2?10000000.0:1.0;\n float d_arcDistrance = length(source - target);\n if(u_CoordinateSystem == COORDINATE_SYSTEM_P20) { // amap\n d_arcDistrance = d_arcDistrance * 1000000.0;\n }\n if(u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT || u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT_OFFSET) { // mapbox\n d_arcDistrance = project_pixel_allmap(d_arcDistrance);\n }\n float d_pixelLen = project_pixel(u_icon_step)/8.0;\n v_dataset.b = floor(d_arcDistrance/d_pixelLen); // \u8D34\u56FE\u5728\u5F27\u7EBF\u4E0A\u91CD\u590D\u7684\u6570\u91CF\n\n float lineOffsetWidth = length(offset + offset * sign(a_Position.y)); // \u7EBF\u6A2A\u5411\u504F\u79FB\u7684\u8DDD\u79BB\n float linePixelSize = project_pixel(a_Size); // \u5B9A\u70B9\u4F4D\u7F6E\u504F\u79FB\uFF0C\u6309\u5730\u56FE\u7B49\u7EA7\u7F29\u653E\u540E\u7684\u8DDD\u79BB\n v_dataset.a = lineOffsetWidth/linePixelSize; // \u7EBF\u56FE\u5C42\u8D34\u56FE\u90E8\u5206\u7684 v \u5750\u6807\u503C\n\n v_iconMapUV = a_iconMapUV;\n }\n\n if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) { // gaode2.x\n gl_Position = u_Mvp * (vec4(curr.xy + offset, curr.z, 1.0));\n } else {\n gl_Position = project_common_position_to_clipspace(vec4(curr.xy + offset, curr.z, 1.0));\n }\n setPickingColor(a_PickingColor);\n}\n\n";
38
+ var line_arc_frag = "#define LineTypeSolid 0.0\n#define LineTypeDash 1.0\n#define Animate 0.0\n#define LineTexture 1.0\n\nuniform float u_opacity;\nuniform float u_textureBlend;\nuniform float u_blur : 0.9;\nuniform float u_line_type: 0.0;\n// varying vec2 v_normal;\nvarying vec4 v_dash_array;\nvarying float v_distance_ratio;\nvarying vec4 v_color;\n\nuniform float u_time;\nuniform vec4 u_aimate: [ 0, 2., 1.0, 0.2 ];\n\nuniform float u_line_texture: 0.0;\nuniform sampler2D u_texture;\nuniform vec2 u_textSize;\nuniform float segmentNumber;\n\nvarying vec2 v_iconMapUV;\n\nuniform float u_linearColor: 0;\nuniform vec4 u_sourceColor;\nuniform vec4 u_targetColor;\n\nvarying mat4 styleMappingMat;\n\n#pragma include \"picking\"\n#pragma include \"project\"\n#pragma include \"projection\"\n\nvoid main() {\n float opacity = styleMappingMat[0][0];\n float animateSpeed = 0.0;\n float d_segmentIndex = styleMappingMat[3].g;\n \n // \u8BBE\u7F6E\u5F27\u7EBF\u7684\u5E95\u8272\n if(u_linearColor == 1.0) { // \u4F7F\u7528\u6E10\u53D8\u989C\u8272\n gl_FragColor = mix(u_sourceColor, u_targetColor, d_segmentIndex/segmentNumber);\n } else { // \u4F7F\u7528 color \u65B9\u6CD5\u4F20\u5165\u7684\u989C\u8272\n gl_FragColor = v_color;\n }\n\n // float blur = 1.- smoothstep(u_blur, 1., length(v_normal.xy));\n // float blur = smoothstep(1.0, u_blur, length(v_normal.xy));\n gl_FragColor.a *= opacity;\n if(u_line_type == LineTypeDash) {\n float flag = 0.;\n float dashLength = mod(v_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 // \u8BBE\u7F6E\u5F27\u7EBF\u7684\u52A8\u753B\u6A21\u5F0F\n if(u_aimate.x == Animate) {\n animateSpeed = u_time / u_aimate.y;\n float alpha =1.0 - fract( mod(1.0- smoothstep(0.0, 1.0, v_distance_ratio), u_aimate.z)* (1.0/ u_aimate.z) + u_time / u_aimate.y);\n alpha = (alpha + u_aimate.w -1.0) / u_aimate.w;\n alpha = smoothstep(0., 1., alpha);\n gl_FragColor.a *= alpha;\n }\n\n // \u8BBE\u7F6E\u5F27\u7EBF\u7684\u8D34\u56FE\n if(LineTexture == u_line_texture && u_line_type != LineTypeDash) { \n float arcRadio = smoothstep( 0.0, 1.0, (d_segmentIndex / (segmentNumber - 1.0)));\n // float arcRadio = d_segmentIndex / (segmentNumber - 1.0);\n float count = styleMappingMat[3].b; // \u8D34\u56FE\u5728\u5F27\u7EBF\u4E0A\u91CD\u590D\u7684\u6570\u91CF\n float u = fract(arcRadio * count - animateSpeed * count);\n // float u = fract(arcRadio * count - animateSpeed);\n if(u_aimate.x == Animate) {\n u = gl_FragColor.a/opacity;\n }\n\n float v = styleMappingMat[3].a; // \u7EBF\u56FE\u5C42\u8D34\u56FE\u90E8\u5206\u7684 v \u5750\u6807\u503C\n\n vec2 uv= v_iconMapUV / u_textSize + vec2(u, v) / u_textSize * 64.;\n vec4 pattern = texture2D(u_texture, uv);\n \n // \u8BBE\u7F6E\u8D34\u56FE\u548C\u5E95\u8272\u7684\u53E0\u52A0\u6A21\u5F0F\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\n // gl_FragColor = filterColor(gl_FragColor);\n}";
39
+ var line_arc2d_vert = "#define LineTypeSolid 0.0\n#define LineTypeDash 1.0\n#define Animate 0.0\n#define LineTexture 1.0\n\nattribute vec4 a_Color;\nattribute vec3 a_Position;\nattribute vec4 a_Instance;\nattribute float a_Size;\nuniform mat4 u_ModelMatrix;\nuniform mat4 u_Mvp;\nuniform float segmentNumber;\nuniform vec4 u_aimate: [ 0, 2., 1.0, 0.2 ];\nvarying vec4 v_color;\n// varying vec2 v_normal;\n\nvarying float v_distance_ratio;\nuniform float u_line_type: 0.0;\nuniform vec4 u_dash_array: [10.0, 5., 0, 0];\nvarying vec4 v_dash_array;\n\nuniform float u_icon_step: 100;\nuniform float u_line_texture: 0.0;\n\nattribute vec2 a_iconMapUV;\nvarying vec2 v_iconMapUV;\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\n#pragma include \"projection\"\n#pragma include \"project\"\n#pragma include \"picking\"\n\nfloat maps (float value, float start1, float stop1, float start2, float stop2) {\n return start2 + (stop2 - start2) * ((value - start1) / (stop1 - start1));\n}\n\nfloat getSegmentRatio(float index) {\n return smoothstep(0.0, 1.0, index / (segmentNumber - 1.));\n}\n\nfloat paraboloid(vec2 source, vec2 target, float ratio) {\n vec2 x = mix(source, target, ratio);\n vec2 center = mix(source, target, 0.5);\n float dSourceCenter = distance(source, center);\n float dXCenter = distance(x, center);\n return (dSourceCenter + dXCenter) * (dSourceCenter - dXCenter);\n}\n\nvec3 getPos(vec2 source, vec2 target, float segmentRatio) {\n float vertex_height = paraboloid(source, target, segmentRatio);\n\n return vec3(\n mix(source, target, segmentRatio),\n sqrt(max(0.0, vertex_height))\n );\n}\nvec2 getExtrusionOffset(vec2 line_clipspace, float offset_direction) {\n // normalized direction of the line\n vec2 dir_screenspace = normalize(line_clipspace);\n // rotate by 90 degrees\n dir_screenspace = vec2(-dir_screenspace.y, dir_screenspace.x);\n vec2 offset = dir_screenspace * offset_direction * setPickingSize(a_Size)/ 2.0;\n return offset;\n}\nvec2 getNormal(vec2 line_clipspace, float offset_direction) {\n // normalized direction of the line\n vec2 dir_screenspace = normalize(line_clipspace);\n // rotate by 90 degrees\n dir_screenspace = vec2(-dir_screenspace.y, dir_screenspace.x);\n return reverse_offset_normal(vec3(dir_screenspace,1.0)).xy * sign(offset_direction);\n}\nfloat getAngularDist (vec2 source, vec2 target) {\n vec2 delta = source - target;\n vec2 sin_half_delta = sin(delta / 2.0);\n float a =\n sin_half_delta.y * sin_half_delta.y +\n cos(source.y) * cos(target.y) *\n sin_half_delta.x * sin_half_delta.x;\n return 2.0 * atan(sqrt(a), sqrt(1.0 - a));\n}\n\nvec2 midPoint(vec2 source, vec2 target) {\n vec2 center = target - source;\n float r = length(center);\n float theta = atan(center.y, center.x);\n float thetaOffset = 0.314;\n float r2 = r / 2.0 / cos(thetaOffset);\n float theta2 = theta + thetaOffset;\n vec2 mid = vec2(r2*cos(theta2) + source.x, r2*sin(theta2) + source.y);\n return mid;\n}\nfloat bezier3(vec3 arr, float t) {\n float ut = 1. - t;\n return (arr.x * ut + arr.y * t) * ut + (arr.y * ut + arr.z * t) * t;\n}\n\nvec2 interpolate (vec2 source, vec2 target, float angularDist, float t) {\n // if the angularDist is PI, linear interpolation is applied. otherwise, use spherical interpolation\n if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) { // gaode2.x\n vec2 mid = midPoint(source, target);\n vec3 x = vec3(source.x, mid.x, target.x);\n vec3 y = vec3(source.y, mid.y, target.y);\n return vec2(bezier3(x ,t), bezier3(y,t));\n }else {\n if(abs(angularDist - PI) < 0.001) {\n return (1.0 - t) * source + t * target;\n }\n float a = sin((1.0 - t) * angularDist) / sin(angularDist);\n float b = sin(t * angularDist) / sin(angularDist);\n vec2 sin_source = sin(source);\n vec2 cos_source = cos(source);\n vec2 sin_target = sin(target);\n vec2 cos_target = cos(target);\n float x = a * cos_source.y * cos_source.x + b * cos_target.y * cos_target.x;\n float y = a * cos_source.y * sin_source.x + b * cos_target.y * sin_target.x;\n float z = a * sin_source.y + b * sin_target.y;\n return vec2(atan(y, x), atan(z, sqrt(x * x + y * y)));\n }\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 // dataset \u6570\u636E\u96C6\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 v_color = a_Color;\n vec2 source = radians(a_Instance.rg);\n vec2 target = radians(a_Instance.ba);\n float angularDist = getAngularDist(source, target);\n float segmentIndex = a_Position.x;\n float segmentRatio = getSegmentRatio(segmentIndex);\n float indexDir = mix(-1.0, 1.0, step(segmentIndex, 0.0));\n if(u_line_type == LineTypeDash) {\n v_distance_ratio = segmentIndex / segmentNumber;\n vec2 s = source;\n vec2 t = target;\n \n if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) { // gaode2.x\n s = unProjCustomCoord(source);\n t = unProjCustomCoord(target);\n }\n float total_Distance = pixelDistance(s, t) / 2.0 * PI;\n total_Distance = total_Distance*8.0;\n // float total_Distance = pixelDistance(a_Instance.rg, a_Instance.ba);\n v_dash_array = pow(2.0, 20.0 - u_Zoom) * u_dash_array / (total_Distance / segmentNumber * segmentIndex);\n }\n if(u_aimate.x == Animate) {\n v_distance_ratio = segmentIndex / segmentNumber;\n }\n float nextSegmentRatio = getSegmentRatio(segmentIndex + indexDir);\n v_distance_ratio = segmentIndex / segmentNumber;\n vec4 curr = project_position(vec4(degrees(interpolate(source, target, angularDist, segmentRatio)), 0.0, 1.0));\n vec4 next = project_position(vec4(degrees(interpolate(source, target, angularDist, nextSegmentRatio)), 0.0, 1.0));\n // v_normal = getNormal((next.xy - curr.xy) * indexDir, a_Position.y);\n vec2 offset = project_pixel(getExtrusionOffset((next.xy - curr.xy) * indexDir, a_Position.y));\n // vec4 project_pos = project_position(vec4(curr.xy, 0, 1.0));\n // gl_Position = project_common_position_to_clipspace(vec4(curr.xy + offset, curr.z, 1.0));\n\n styleMappingMat[3].g = a_Position.x; // \u8BE5\u9876\u70B9\u5728\u5F27\u7EBF\u4E0A\u7684\u5206\u6BB5\u6392\u5E8F\n if(LineTexture == u_line_texture) { // \u5F00\u542F\u8D34\u56FE\u6A21\u5F0F \n // float mapZoomScale = u_CoordinateSystem !== COORDINATE_SYSTEM_P20_2?10000000.0:1.0;\n float d_arcDistrance = length(source - target);\n if(u_CoordinateSystem == COORDINATE_SYSTEM_P20) { // amap\n d_arcDistrance = d_arcDistrance * 1000000.0;\n }\n if(u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT || u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT_OFFSET) { // mapbox\n d_arcDistrance = project_pixel_allmap(d_arcDistrance);\n }\n float d_pixelLen = project_pixel(u_icon_step)/8.0;\n styleMappingMat[3].b = floor(d_arcDistrance/d_pixelLen); // \u8D34\u56FE\u5728\u5F27\u7EBF\u4E0A\u91CD\u590D\u7684\u6570\u91CF\n\n float lineOffsetWidth = length(offset + offset * sign(a_Position.y)); // \u7EBF\u6A2A\u5411\u504F\u79FB\u7684\u8DDD\u79BB\n float linePixelSize = project_pixel(a_Size); // \u5B9A\u70B9\u4F4D\u7F6E\u504F\u79FB\uFF0C\u6309\u5730\u56FE\u7B49\u7EA7\u7F29\u653E\u540E\u7684\u8DDD\u79BB\n styleMappingMat[3].a = lineOffsetWidth/linePixelSize; // \u7EBF\u56FE\u5C42\u8D34\u56FE\u90E8\u5206\u7684 v \u5750\u6807\u503C\n\n v_iconMapUV = a_iconMapUV;\n }\n\n if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) { // gaode2.x\n gl_Position = u_Mvp * (vec4(curr.xy + offset, curr.z, 1.0));\n } else {\n gl_Position = project_common_position_to_clipspace(vec4(curr.xy + offset, curr.z, 1.0));\n }\n setPickingColor(a_PickingColor);\n}\n\n";
40
40
  var lineStyleObj = {
41
41
  solid: 0.0,
42
42
  dash: 1.0
@@ -11,12 +11,15 @@ var _arc = _interopRequireDefault(require("./arc"));
11
11
 
12
12
  var _arc_3d = _interopRequireDefault(require("./arc_3d"));
13
13
 
14
+ var _arcmini = _interopRequireDefault(require("./arcmini"));
15
+
14
16
  var _great_circle = _interopRequireDefault(require("./great_circle"));
15
17
 
16
18
  var _line = _interopRequireDefault(require("./line"));
17
19
 
18
20
  var LineModels = {
19
21
  arc: _arc.default,
22
+ arcmini: _arcmini.default,
20
23
  arc3d: _arc_3d.default,
21
24
  greatcircle: _great_circle.default,
22
25
  line: _line.default
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/line/models/index.ts"],"names":["LineModels","arc","ArcModel","arc3d","Arc3DModel","greatcircle","GreatCircleModel","line","LineModel"],"mappings":";;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AAIA,IAAMA,UAA2C,GAAG;AAClDC,EAAAA,GAAG,EAAEC,YAD6C;AAElDC,EAAAA,KAAK,EAAEC,eAF2C;AAGlDC,EAAAA,WAAW,EAAEC,qBAHqC;AAIlDC,EAAAA,IAAI,EAAEC;AAJ4C,CAApD;eAOeR,U","sourcesContent":["import ArcModel from './arc';\nimport Arc3DModel from './arc_3d';\nimport GreatCircleModel from './great_circle';\nimport LineModel from './line';\n\nexport type LineModelType = 'arc' | 'arc3d' | 'greatcircle' | 'line';\n\nconst LineModels: { [key in LineModelType]: any } = {\n arc: ArcModel,\n arc3d: Arc3DModel,\n greatcircle: GreatCircleModel,\n line: LineModel,\n};\n\nexport default LineModels;\n"],"file":"index.js"}
1
+ {"version":3,"sources":["../../../src/line/models/index.ts"],"names":["LineModels","arc","ArcModel","arcmini","ArcMiniModel","arc3d","Arc3DModel","greatcircle","GreatCircleModel","line","LineModel"],"mappings":";;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AASA,IAAMA,UAA2C,GAAG;AAClDC,EAAAA,GAAG,EAAEC,YAD6C;AAElDC,EAAAA,OAAO,EAAEC,gBAFyC;AAGlDC,EAAAA,KAAK,EAAEC,eAH2C;AAIlDC,EAAAA,WAAW,EAAEC,qBAJqC;AAKlDC,EAAAA,IAAI,EAAEC;AAL4C,CAApD;eAQeV,U","sourcesContent":["import ArcModel from './arc';\nimport Arc3DModel from './arc_3d';\nimport ArcMiniModel from './arcmini';\nimport GreatCircleModel from './great_circle';\nimport LineModel from './line';\n\nexport type LineModelType =\n | 'arc'\n | 'arcmini'\n | 'arc3d'\n | 'greatcircle'\n | 'line';\n\nconst LineModels: { [key in LineModelType]: any } = {\n arc: ArcModel,\n arcmini: ArcMiniModel,\n arc3d: Arc3DModel,\n greatcircle: GreatCircleModel,\n line: LineModel,\n};\n\nexport default LineModels;\n"],"file":"index.js"}
@@ -35,8 +35,8 @@ function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflec
35
35
 
36
36
  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; } }
37
37
 
38
- 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";
39
- 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";
38
+ 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;\n// varying 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 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 = styleMappingMat[3].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 = 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 - animateSpeed);\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 = 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\n // gl_FragColor = (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";
39
+ 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\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;\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 // 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_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 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 styleMappingMat[3][0] = d_distance_ratio; // \u5F53\u524D\u70B9\u4F4D\u8DDD\u79BB\u5360\u7EBF\u603B\u957F\u7684\u6BD4\u4F8B\n styleMappingMat[3][1] = a_Distance; // \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 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";
40
40
  var lineStyleObj = {
41
41
  solid: 0.0,
42
42
  dash: 1.0
@@ -31,7 +31,7 @@ require("reflect-metadata");
31
31
 
32
32
  var _dec, _dec2, _dec3, _dec4, _class, _class2, _descriptor, _descriptor2, _descriptor3;
33
33
 
34
- 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; }
34
+ 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; }
35
35
 
36
36
  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) { (0, _defineProperty2.default)(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; }
37
37
 
@@ -2,7 +2,7 @@
2
2
 
3
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
4
 
5
- var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard");
5
+ var _typeof = require("@babel/runtime/helpers/typeof");
6
6
 
7
7
  Object.defineProperty(exports, "__esModule", {
8
8
  value: true
@@ -25,6 +25,10 @@ require("reflect-metadata");
25
25
 
26
26
  var _dec, _class;
27
27
 
28
+ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
29
+
30
+ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
31
+
28
32
  var DataSourcePlugin = (_dec = (0, _inversify.injectable)(), _dec(_class = function () {
29
33
  function DataSourcePlugin() {
30
34
  (0, _classCallCheck2.default)(this, DataSourcePlugin);
@@ -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","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,CAASL,IAAI,GAAGE,OAAhB,IAA2B,CAD7C,CAAP,IAEAD,OAAO,GAAGD,IAHZ,EAIE;AACAhB,QAAAA,MAAM,CAACS,iBAAP,CAAyBW,IAAI,CAACE,KAAL,CAAWJ,OAAX,CAAzB;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(zoom - newZoom) > 1) &&\n maxZoom > zoom\n ) {\n source.updateClusterData(Math.floor(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","maxZoom","newZoom","getZoom","Math","abs","floor"],"mappings":";;;;;;;;;;;;;;;;;AAAA;;AAOA;;AACA;;AACA;;;;;;;;IAGqBA,gB,WADpB,4B;;;;;;;;WAG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,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,CAASL,IAAI,GAAGE,OAAhB,IAA2B,CAD7C,CAAP,IAEAD,OAAO,GAAGD,IAHZ,EAIE;AACAhB,QAAAA,MAAM,CAACS,iBAAP,CAAyBW,IAAI,CAACE,KAAL,CAAWJ,OAAX,CAAzB;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(zoom - newZoom) > 1) &&\n maxZoom > zoom\n ) {\n source.updateClusterData(Math.floor(newZoom));\n return true;\n }\n return false;\n }\n}\n"],"file":"DataSourcePlugin.js"}
@@ -2,7 +2,7 @@
2
2
 
3
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
4
 
5
- var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard");
5
+ var _typeof = require("@babel/runtime/helpers/typeof");
6
6
 
7
7
  Object.defineProperty(exports, "__esModule", {
8
8
  value: true
@@ -39,6 +39,10 @@ require("reflect-metadata");
39
39
 
40
40
  var _scaleMap, _dec, _dec2, _class, _class2, _descriptor;
41
41
 
42
+ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
43
+
44
+ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
45
+
42
46
  var dateRegex = /^(?:(?!0000)[0-9]{4}([-/.]+)(?:(?:0?[1-9]|1[0-2])\1(?:0?[1-9]|1[0-9]|2[0-8])|(?:0?[13-9]|1[0-2])\1(?:29|30)|(?:0?[13578]|1[02])\1(?:31))|(?:[0-9]{2}(?:0[48]|[2468][048]|[13579][26])|(?:0[48]|[2468][048]|[13579][26])00)([-/.]?)0?2\2(?:29))(\s+([01]|([01][0-9]|2[0-3])):([0-9]|[0-5][0-9]):([0-9]|[0-5][0-9]))?$/;
43
47
  var scaleMap = (_scaleMap = {}, (0, _defineProperty2.default)(_scaleMap, _l7Core.ScaleTypes.LINEAR, d3.scaleLinear), (0, _defineProperty2.default)(_scaleMap, _l7Core.ScaleTypes.POWER, d3.scalePow), (0, _defineProperty2.default)(_scaleMap, _l7Core.ScaleTypes.LOG, d3.scaleLog), (0, _defineProperty2.default)(_scaleMap, _l7Core.ScaleTypes.IDENTITY, d3.scaleIdentity), (0, _defineProperty2.default)(_scaleMap, _l7Core.ScaleTypes.TIME, d3.scaleTime), (0, _defineProperty2.default)(_scaleMap, _l7Core.ScaleTypes.QUANTILE, d3.scaleQuantile), (0, _defineProperty2.default)(_scaleMap, _l7Core.ScaleTypes.QUANTIZE, d3.scaleQuantize), (0, _defineProperty2.default)(_scaleMap, _l7Core.ScaleTypes.THRESHOLD, d3.scaleThreshold), (0, _defineProperty2.default)(_scaleMap, _l7Core.ScaleTypes.CAT, d3.scaleOrdinal), _scaleMap);
44
48
  var FeatureScalePlugin = (_dec = (0, _inversify.injectable)(), _dec2 = (0, _inversify.inject)(_l7Core.TYPES.IGlobalConfigService), _dec(_class = (_class2 = function () {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/plugins/FeatureScalePlugin.ts"],"names":["dateRegex","scaleMap","ScaleTypes","LINEAR","d3","scaleLinear","POWER","scalePow","LOG","scaleLog","IDENTITY","scaleIdentity","TIME","scaleTime","QUANTILE","scaleQuantile","QUANTIZE","scaleQuantize","THRESHOLD","scaleThreshold","CAT","scaleOrdinal","FeatureScalePlugin","TYPES","IGlobalConfigService","layer","styleAttributeService","hooks","init","tap","scaleOptions","getScaleOptions","attributes","getLayerStyleAttributes","dataArray","getSource","data","length","caculateScalesForAttributes","beforeRenderData","layerModelNeedUpdate","beforeRender","attributesToRescale","filter","attribute","needRescale","n","isNaN","parseFloat","isFinite","scaleCache","forEach","scale","attributeScale","type","name","names","parseFields","field","scales","push","getOrCreateScale","some","StyleScaleType","VARIABLE","callback","values","option","tick","ticks","domain","range","CONSTANT","defaultValues","map","index","scalers","func","scalekey","join","styleScale","createScale","Array","isArray","split","scaleOption","undefined","createDefaultScale","firstValue","find","d","isNumber","getDefaultType","cfg","createDefaultScaleConfig","Object","assign","test","item"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AAeA;;AACA;;AACA;;AAEA;;;;AAEA,IAAMA,SAAS,GAAG,sTAAlB;AAEA,IAAMC,QAAQ,6DACXC,mBAAWC,MADA,EACSC,EAAE,CAACC,WADZ,4CAEXH,mBAAWI,KAFA,EAEQF,EAAE,CAACG,QAFX,4CAGXL,mBAAWM,GAHA,EAGMJ,EAAE,CAACK,QAHT,4CAIXP,mBAAWQ,QAJA,EAIWN,EAAE,CAACO,aAJd,4CAKXT,mBAAWU,IALA,EAKOR,EAAE,CAACS,SALV,4CAMXX,mBAAWY,QANA,EAMWV,EAAE,CAACW,aANd,4CAOXb,mBAAWc,QAPA,EAOWZ,EAAE,CAACa,aAPd,4CAQXf,mBAAWgB,SARA,EAQYd,EAAE,CAACe,cARf,4CASXjB,mBAAWkB,GATA,EASMhB,EAAE,CAACiB,YATT,aAAd;IAgBqBC,kB,WADpB,4B,UAEE,uBAAOC,cAAMC,oBAAb,C;;;;sDAKG,E;wDAEkC,E;;;;;WAEtC,eACEC,KADF,QAKE;AAAA;;AAAA,UAFEC,qBAEF,QAFEA,qBAEF;AACAD,MAAAA,KAAK,CAACE,KAAN,CAAYC,IAAZ,CAAiBC,GAAjB,CAAqB,oBAArB,EAA2C,YAAM;AAC/C,QAA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SAAlBA,MAAkB;AAEnD,UAAMlB,KAAK,GAAGnD,QAAQ,CAACqD,IAAD,CAAR,EAAd;;AACA,UAAIgB,MAAJ,EAAY;AACVlB,QAAAA,KAAK,CAACkB,MAAN,CAAaA,MAAb;AACD;;AAED,aAAOlB,KAAP;AACD","sourcesContent":["import {\n IGlobalConfigService,\n ILayer,\n ILayerPlugin,\n IScale,\n IScaleOptions,\n IStyleAttribute,\n IStyleAttributeService,\n IStyleScale,\n ScaleTypeName,\n ScaleTypes,\n StyleScaleType,\n TYPES,\n} from '@antv/l7-core';\nimport { IParseDataItem } from '@antv/l7-source';\nimport { extent, ticks } from 'd3-array';\nimport * as d3 from 'd3-scale';\nimport { inject, injectable } from 'inversify';\nimport { isNil, isString, uniq } from 'lodash';\nimport 'reflect-metadata';\n\nconst dateRegex = /^(?:(?!0000)[0-9]{4}([-/.]+)(?:(?:0?[1-9]|1[0-2])\\1(?:0?[1-9]|1[0-9]|2[0-8])|(?:0?[13-9]|1[0-2])\\1(?:29|30)|(?:0?[13578]|1[02])\\1(?:31))|(?:[0-9]{2}(?:0[48]|[2468][048]|[13579][26])|(?:0[48]|[2468][048]|[13579][26])00)([-/.]?)0?2\\2(?:29))(\\s+([01]|([01][0-9]|2[0-3])):([0-9]|[0-5][0-9]):([0-9]|[0-5][0-9]))?$/;\n\nconst scaleMap = {\n [ScaleTypes.LINEAR]: d3.scaleLinear,\n [ScaleTypes.POWER]: d3.scalePow,\n [ScaleTypes.LOG]: d3.scaleLog,\n [ScaleTypes.IDENTITY]: d3.scaleIdentity,\n [ScaleTypes.TIME]: d3.scaleTime,\n [ScaleTypes.QUANTILE]: d3.scaleQuantile,\n [ScaleTypes.QUANTIZE]: d3.scaleQuantize,\n [ScaleTypes.THRESHOLD]: d3.scaleThreshold,\n [ScaleTypes.CAT]: d3.scaleOrdinal,\n};\n\n/**\n * 根据 Source 原始数据为指定字段创建 Scale,保存在 StyleAttribute 上,供下游插件使用\n */\n@injectable()\nexport default class FeatureScalePlugin implements ILayerPlugin {\n @inject(TYPES.IGlobalConfigService)\n private readonly configService: IGlobalConfigService;\n // key = field_attribute name\n private scaleCache: {\n [field: string]: IStyleScale;\n } = {};\n\n private scaleOptions: IScaleOptions = {};\n\n public apply(\n layer: ILayer,\n {\n styleAttributeService,\n }: { styleAttributeService: IStyleAttributeService },\n ) {\n layer.hooks.init.tap('FeatureScalePlugin', () => {\n this.scaleOptions = layer.getScaleOptions();\n const attributes = styleAttributeService.getLayerStyleAttributes();\n const { dataArray } = layer.getSource().data;\n if (dataArray.length === 0) {\n return;\n }\n this.caculateScalesForAttributes(attributes || [], dataArray);\n });\n\n // 检测数据是否需要更新\n layer.hooks.beforeRenderData.tap('FeatureScalePlugin', () => {\n this.scaleOptions = layer.getScaleOptions();\n const attributes = styleAttributeService.getLayerStyleAttributes();\n const { dataArray } = layer.getSource().data;\n // if (dataArray.length === 0) {\n // return;\n // }\n this.caculateScalesForAttributes(attributes || [], dataArray);\n layer.layerModelNeedUpdate = true;\n return true;\n });\n\n layer.hooks.beforeRender.tap('FeatureScalePlugin', () => {\n if (layer.layerModelNeedUpdate) {\n return;\n }\n this.scaleOptions = layer.getScaleOptions();\n const attributes = styleAttributeService.getLayerStyleAttributes();\n if (attributes) {\n const { dataArray } = layer.getSource().data;\n if (dataArray.length === 0) {\n return;\n }\n const attributesToRescale = attributes.filter(\n (attribute) => attribute.needRescale,\n );\n if (attributesToRescale.length) {\n this.caculateScalesForAttributes(attributesToRescale, dataArray);\n }\n }\n });\n }\n private isNumber(n: any) {\n return !isNaN(parseFloat(n)) && isFinite(n);\n }\n\n private caculateScalesForAttributes(\n attributes: IStyleAttribute[],\n dataArray: IParseDataItem[],\n ) {\n this.scaleCache = {};\n attributes.forEach((attribute) => {\n if (attribute.scale) {\n // 创建Scale\n const attributeScale = attribute.scale;\n const type = attribute.name;\n attributeScale.names = this.parseFields(attribute!.scale!.field || []);\n const scales: IStyleScale[] = [];\n attributeScale.names.forEach((field: string | number) => {\n scales.push(this.getOrCreateScale(field, attribute, dataArray));\n });\n\n // 为scales 设置值区间\n if (scales.some((scale) => scale.type === StyleScaleType.VARIABLE)) {\n attributeScale.type = StyleScaleType.VARIABLE;\n scales.forEach((scale) => {\n // 如果设置了回调, 这不需要设置让range\n if (!attributeScale.callback) {\n if (attributeScale.values && attributeScale.values !== 'text') {\n if (\n scale.option?.type === 'linear' &&\n attributeScale.values.length > 2\n ) {\n const tick = scale.scale.ticks(attributeScale.values.length);\n if (type === 'color') {\n scale.scale.domain(tick);\n }\n }\n scale.scale.range(attributeScale.values); // 判断常量, 默认值\n } else if (scale.option?.type === 'cat') {\n // 如果没有设置初值且 类型为cat,range ==domain;\n\n scale.scale.range(scale.option.domain);\n }\n }\n });\n } else {\n // 设置attribute 常量值 常量直接在value取值\n attributeScale.type = StyleScaleType.CONSTANT;\n attributeScale.defaultValues = scales.map((scale, index) => {\n return scale.scale(attributeScale.names[index]);\n });\n }\n attributeScale.scalers = scales.map((scale: IStyleScale) => {\n return {\n field: scale.field,\n func: scale.scale,\n option: scale.option,\n };\n });\n\n attribute.needRescale = false;\n }\n });\n }\n private getOrCreateScale(\n field: string | number,\n attribute: IStyleAttribute,\n dataArray: IParseDataItem[],\n ) {\n const scalekey = [field, attribute.name].join('_');\n const values = attribute.scale?.values;\n // if (this.scaleCache[scalekey]) {\n // return this.scaleCache[scalekey];\n // }\n const styleScale = this.createScale(\n field,\n attribute.name,\n values,\n dataArray,\n );\n // this.scaleCache[scalekey] = styleScale;\n return styleScale;\n }\n\n /**\n * @example\n * 'w*h' => ['w', 'h']\n * 'w' => ['w']\n */\n private parseFields(\n field: string[] | string | number[],\n ): string[] | number[] {\n if (Array.isArray(field)) {\n return field;\n }\n if (isString(field)) {\n return field.split('*');\n }\n return [field];\n }\n\n private createScale(\n field: string | number,\n name: string,\n values: unknown[] | string | undefined,\n data?: IParseDataItem[],\n ): IStyleScale {\n // scale 支持根据视觉通道和字段\n const scaleOption: IScale | undefined =\n this.scaleOptions[name] && this.scaleOptions[name]?.field === field\n ? this.scaleOptions[name]\n : this.scaleOptions[field];\n const styleScale: IStyleScale = {\n field,\n scale: undefined,\n type: StyleScaleType.VARIABLE,\n option: scaleOption,\n };\n\n if (!data || !data.length) {\n if (scaleOption && scaleOption.type) {\n styleScale.scale = this.createDefaultScale(scaleOption);\n } else {\n styleScale.scale = d3.scaleOrdinal([field]);\n styleScale.type = StyleScaleType.CONSTANT;\n }\n return styleScale;\n }\n const firstValue = data!.find((d) => !isNil(d[field]))?.[field];\n // 常量 Scale\n if (this.isNumber(field) || (isNil(firstValue) && !scaleOption)) {\n styleScale.scale = d3.scaleOrdinal([field]);\n styleScale.type = StyleScaleType.CONSTANT;\n } else {\n // 根据数据类型判断 默认等分位,时间,和枚举类型\n let type =\n (scaleOption && scaleOption.type) || this.getDefaultType(firstValue);\n if (values === 'text') {\n // text 为内置变 如果是文本则为cat\n type = ScaleTypes.CAT;\n }\n const cfg = this.createDefaultScaleConfig(type, field, data);\n Object.assign(cfg, scaleOption);\n styleScale.scale = this.createDefaultScale(cfg);\n styleScale.option = cfg;\n }\n return styleScale;\n }\n\n private getDefaultType(firstValue: unknown) {\n let type = ScaleTypes.LINEAR;\n if (typeof firstValue === 'string') {\n type = dateRegex.test(firstValue) ? ScaleTypes.TIME : ScaleTypes.CAT;\n }\n return type;\n }\n\n private createDefaultScaleConfig(\n type: ScaleTypeName,\n field: string | number,\n data?: IParseDataItem[],\n ) {\n const cfg: IScale = {\n type,\n };\n const values = data?.map((item) => item[field]) || [];\n // 默认类型为 Quantile Scales https://github.com/d3/d3-scale#quantile-scales\n if (type !== ScaleTypes.CAT && type !== ScaleTypes.QUANTILE) {\n cfg.domain = extent(values);\n } else if (type === ScaleTypes.CAT) {\n cfg.domain = uniq(values);\n } else if (type === ScaleTypes.QUANTILE) {\n cfg.domain = values;\n }\n return cfg;\n }\n\n private createDefaultScale({ type, domain }: IScale) {\n // @ts-ignore\n const scale = scaleMap[type]();\n if (domain) {\n scale.domain(domain);\n }\n // TODO 其他属性支持\n return scale;\n }\n}\n"],"file":"FeatureScalePlugin.js"}
1
+ {"version":3,"sources":["../../src/plugins/FeatureScalePlugin.ts"],"names":["dateRegex","scaleMap","ScaleTypes","LINEAR","d3","scaleLinear","POWER","scalePow","LOG","scaleLog","IDENTITY","scaleIdentity","TIME","scaleTime","QUANTILE","scaleQuantile","QUANTIZE","scaleQuantize","THRESHOLD","scaleThreshold","CAT","scaleOrdinal","FeatureScalePlugin","TYPES","IGlobalConfigService","layer","styleAttributeService","hooks","init","tap","scaleOptions","getScaleOptions","attributes","getLayerStyleAttributes","dataArray","getSource","data","length","caculateScalesForAttributes","beforeRenderData","layerModelNeedUpdate","beforeRender","attributesToRescale","filter","attribute","needRescale","n","isNaN","parseFloat","isFinite","scaleCache","forEach","scale","attributeScale","type","name","names","parseFields","field","scales","push","getOrCreateScale","some","StyleScaleType","VARIABLE","callback","values","option","tick","ticks","domain","range","CONSTANT","defaultValues","map","index","scalers","func","scalekey","join","styleScale","createScale","Array","isArray","split","scaleOption","undefined","createDefaultScale","firstValue","find","d","isNumber","getDefaultType","cfg","createDefaultScaleConfig","Object","assign","test","item"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AAeA;;AACA;;AACA;;AAEA;;;;;;;;AAEA,IAAMA,SAAS,GAAG,sTAAlB;AAEA,IAAMC,QAAQ,6DACXC,mBAAWC,MADA,EACSC,EAAE,CAACC,WADZ,4CAEXH,mBAAWI,KAFA,EAEQF,EAAE,CAACG,QAFX,4CAGXL,mBAAWM,GAHA,EAGMJ,EAAE,CAACK,QAHT,4CAIXP,mBAAWQ,QAJA,EAIWN,EAAE,CAACO,aAJd,4CAKXT,mBAAWU,IALA,EAKOR,EAAE,CAACS,SALV,4CAMXX,mBAAWY,QANA,EAMWV,EAAE,CAACW,aANd,4CAOXb,mBAAWc,QAPA,EAOWZ,EAAE,CAACa,aAPd,4CAQXf,mBAAWgB,SARA,EAQYd,EAAE,CAACe,cARf,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WkB,GAAxB,EAA6B;AAClCyE,QAAAA,GAAG,CAACvB,MAAJ,GAAa,oBAAKJ,MAAL,CAAb;AACD,OAFM,MAEA,IAAIZ,IAAI,KAAKpD,mBAAWY,QAAxB,EAAkC;AACvC+E,QAAAA,GAAG,CAACvB,MAAJ,GAAaJ,MAAb;AACD;;AACD,aAAO2B,GAAP;AACD;;;WAED,mCAAqD;AAAA,UAAxBvC,IAAwB,SAAxBA,IAAwB;AAAA,UAAlBgB,MAAkB,SAAlBA,MAAkB;AAEnD,UAAMlB,KAAK,GAAGnD,QAAQ,CAACqD,IAAD,CAAR,EAAd;;AACA,UAAIgB,MAAJ,EAAY;AACVlB,QAAAA,KAAK,CAACkB,MAAN,CAAaA,MAAb;AACD;;AAED,aAAOlB,KAAP;AACD","sourcesContent":["import {\n IGlobalConfigService,\n ILayer,\n ILayerPlugin,\n IScale,\n IScaleOptions,\n IStyleAttribute,\n IStyleAttributeService,\n IStyleScale,\n ScaleTypeName,\n ScaleTypes,\n StyleScaleType,\n TYPES,\n} from '@antv/l7-core';\nimport { IParseDataItem } from '@antv/l7-source';\nimport { extent, ticks } from 'd3-array';\nimport * as d3 from 'd3-scale';\nimport { inject, injectable } from 'inversify';\nimport { isNil, isString, uniq } from 'lodash';\nimport 'reflect-metadata';\n\nconst dateRegex = /^(?:(?!0000)[0-9]{4}([-/.]+)(?:(?:0?[1-9]|1[0-2])\\1(?:0?[1-9]|1[0-9]|2[0-8])|(?:0?[13-9]|1[0-2])\\1(?:29|30)|(?:0?[13578]|1[02])\\1(?:31))|(?:[0-9]{2}(?:0[48]|[2468][048]|[13579][26])|(?:0[48]|[2468][048]|[13579][26])00)([-/.]?)0?2\\2(?:29))(\\s+([01]|([01][0-9]|2[0-3])):([0-9]|[0-5][0-9]):([0-9]|[0-5][0-9]))?$/;\n\nconst scaleMap = {\n [ScaleTypes.LINEAR]: d3.scaleLinear,\n [ScaleTypes.POWER]: d3.scalePow,\n [ScaleTypes.LOG]: d3.scaleLog,\n [ScaleTypes.IDENTITY]: d3.scaleIdentity,\n [ScaleTypes.TIME]: d3.scaleTime,\n [ScaleTypes.QUANTILE]: d3.scaleQuantile,\n [ScaleTypes.QUANTIZE]: d3.scaleQuantize,\n [ScaleTypes.THRESHOLD]: d3.scaleThreshold,\n [ScaleTypes.CAT]: d3.scaleOrdinal,\n};\n\n/**\n * 根据 Source 原始数据为指定字段创建 Scale,保存在 StyleAttribute 上,供下游插件使用\n */\n@injectable()\nexport default class FeatureScalePlugin implements ILayerPlugin {\n @inject(TYPES.IGlobalConfigService)\n private readonly configService: IGlobalConfigService;\n // key = field_attribute name\n private scaleCache: {\n [field: string]: IStyleScale;\n } = {};\n\n private scaleOptions: IScaleOptions = {};\n\n public apply(\n layer: ILayer,\n {\n styleAttributeService,\n }: { styleAttributeService: IStyleAttributeService },\n ) {\n layer.hooks.init.tap('FeatureScalePlugin', () => {\n this.scaleOptions = layer.getScaleOptions();\n const attributes = styleAttributeService.getLayerStyleAttributes();\n const { dataArray } = layer.getSource().data;\n if (dataArray.length === 0) {\n return;\n }\n this.caculateScalesForAttributes(attributes || [], dataArray);\n });\n\n // 检测数据是否需要更新\n layer.hooks.beforeRenderData.tap('FeatureScalePlugin', () => {\n this.scaleOptions = layer.getScaleOptions();\n const attributes = styleAttributeService.getLayerStyleAttributes();\n const { dataArray } = layer.getSource().data;\n // if (dataArray.length === 0) {\n // return;\n // }\n this.caculateScalesForAttributes(attributes || [], dataArray);\n layer.layerModelNeedUpdate = true;\n return true;\n });\n\n layer.hooks.beforeRender.tap('FeatureScalePlugin', () => {\n if (layer.layerModelNeedUpdate) {\n return;\n }\n this.scaleOptions = layer.getScaleOptions();\n const attributes = styleAttributeService.getLayerStyleAttributes();\n if (attributes) {\n const { dataArray } = layer.getSource().data;\n if (dataArray.length === 0) {\n return;\n }\n const attributesToRescale = attributes.filter(\n (attribute) => attribute.needRescale,\n );\n if (attributesToRescale.length) {\n this.caculateScalesForAttributes(attributesToRescale, dataArray);\n }\n }\n });\n }\n private isNumber(n: any) {\n return !isNaN(parseFloat(n)) && isFinite(n);\n }\n\n private caculateScalesForAttributes(\n attributes: IStyleAttribute[],\n dataArray: IParseDataItem[],\n ) {\n this.scaleCache = {};\n attributes.forEach((attribute) => {\n if (attribute.scale) {\n // 创建Scale\n const attributeScale = attribute.scale;\n const type = attribute.name;\n attributeScale.names = this.parseFields(attribute!.scale!.field || []);\n const scales: IStyleScale[] = [];\n attributeScale.names.forEach((field: string | number) => {\n scales.push(this.getOrCreateScale(field, attribute, dataArray));\n });\n\n // 为scales 设置值区间\n if (scales.some((scale) => scale.type === StyleScaleType.VARIABLE)) {\n attributeScale.type = StyleScaleType.VARIABLE;\n scales.forEach((scale) => {\n // 如果设置了回调, 这不需要设置让range\n if (!attributeScale.callback) {\n if (attributeScale.values && attributeScale.values !== 'text') {\n if (\n scale.option?.type === 'linear' &&\n attributeScale.values.length > 2\n ) {\n const tick = scale.scale.ticks(attributeScale.values.length);\n if (type === 'color') {\n scale.scale.domain(tick);\n }\n }\n scale.scale.range(attributeScale.values); // 判断常量, 默认值\n } else if (scale.option?.type === 'cat') {\n // 如果没有设置初值且 类型为cat,range ==domain;\n\n scale.scale.range(scale.option.domain);\n }\n }\n });\n } else {\n // 设置attribute 常量值 常量直接在value取值\n attributeScale.type = StyleScaleType.CONSTANT;\n attributeScale.defaultValues = scales.map((scale, index) => {\n return scale.scale(attributeScale.names[index]);\n });\n }\n attributeScale.scalers = scales.map((scale: IStyleScale) => {\n return {\n field: scale.field,\n func: scale.scale,\n option: scale.option,\n };\n });\n\n attribute.needRescale = false;\n }\n });\n }\n private getOrCreateScale(\n field: string | number,\n attribute: IStyleAttribute,\n dataArray: IParseDataItem[],\n ) {\n const scalekey = [field, attribute.name].join('_');\n const values = attribute.scale?.values;\n // if (this.scaleCache[scalekey]) {\n // return this.scaleCache[scalekey];\n // }\n const styleScale = this.createScale(\n field,\n attribute.name,\n values,\n dataArray,\n );\n // this.scaleCache[scalekey] = styleScale;\n return styleScale;\n }\n\n /**\n * @example\n * 'w*h' => ['w', 'h']\n * 'w' => ['w']\n */\n private parseFields(\n field: string[] | string | number[],\n ): string[] | number[] {\n if (Array.isArray(field)) {\n return field;\n }\n if (isString(field)) {\n return field.split('*');\n }\n return [field];\n }\n\n private createScale(\n field: string | number,\n name: string,\n values: unknown[] | string | undefined,\n data?: IParseDataItem[],\n ): IStyleScale {\n // scale 支持根据视觉通道和字段\n const scaleOption: IScale | undefined =\n this.scaleOptions[name] && this.scaleOptions[name]?.field === field\n ? this.scaleOptions[name]\n : this.scaleOptions[field];\n const styleScale: IStyleScale = {\n field,\n scale: undefined,\n type: StyleScaleType.VARIABLE,\n option: scaleOption,\n };\n\n if (!data || !data.length) {\n if (scaleOption && scaleOption.type) {\n styleScale.scale = this.createDefaultScale(scaleOption);\n } else {\n styleScale.scale = d3.scaleOrdinal([field]);\n styleScale.type = StyleScaleType.CONSTANT;\n }\n return styleScale;\n }\n const firstValue = data!.find((d) => !isNil(d[field]))?.[field];\n // 常量 Scale\n if (this.isNumber(field) || (isNil(firstValue) && !scaleOption)) {\n styleScale.scale = d3.scaleOrdinal([field]);\n styleScale.type = StyleScaleType.CONSTANT;\n } else {\n // 根据数据类型判断 默认等分位,时间,和枚举类型\n let type =\n (scaleOption && scaleOption.type) || this.getDefaultType(firstValue);\n if (values === 'text') {\n // text 为内置变 如果是文本则为cat\n type = ScaleTypes.CAT;\n }\n const cfg = this.createDefaultScaleConfig(type, field, data);\n Object.assign(cfg, scaleOption);\n styleScale.scale = this.createDefaultScale(cfg);\n styleScale.option = cfg;\n }\n return styleScale;\n }\n\n private getDefaultType(firstValue: unknown) {\n let type = ScaleTypes.LINEAR;\n if (typeof firstValue === 'string') {\n type = dateRegex.test(firstValue) ? ScaleTypes.TIME : ScaleTypes.CAT;\n }\n return type;\n }\n\n private createDefaultScaleConfig(\n type: ScaleTypeName,\n field: string | number,\n data?: IParseDataItem[],\n ) {\n const cfg: IScale = {\n type,\n };\n const values = data?.map((item) => item[field]) || [];\n // 默认类型为 Quantile Scales https://github.com/d3/d3-scale#quantile-scales\n if (type !== ScaleTypes.CAT && type !== ScaleTypes.QUANTILE) {\n cfg.domain = extent(values);\n } else if (type === ScaleTypes.CAT) {\n cfg.domain = uniq(values);\n } else if (type === ScaleTypes.QUANTILE) {\n cfg.domain = values;\n }\n return cfg;\n }\n\n private createDefaultScale({ type, domain }: IScale) {\n // @ts-ignore\n const scale = scaleMap[type]();\n if (domain) {\n scale.domain(domain);\n }\n // TODO 其他属性支持\n return scale;\n }\n}\n"],"file":"FeatureScalePlugin.js"}
@@ -27,7 +27,7 @@ require("reflect-metadata");
27
27
 
28
28
  var _dec, _dec2, _dec3, _class, _class2, _descriptor, _descriptor2;
29
29
 
30
- 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; }
30
+ 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; }
31
31
 
32
32
  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) { (0, _defineProperty2.default)(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; }
33
33
 
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/plugins/LayerStylePlugin.ts"],"names":["LayerStylePlugin","layer","hooks","afterInit","tap","updateLayerConfig","getLayerConfig","autoFit","fitBoundsOptions","setTimeout","fitBounds"],"mappings":";;;;;;;;;;;;;AAGA;;AACA;;;;IAKqBA,gB,WADpB,4B;;;;;;;WAEC,eAAaC,KAAb,EAA4B;AAC1BA,MAAAA,KAAK,CAACC,KAAN,CAAYC,SAAZ,CAAsBC,GAAtB,CAA0B,kBAA1B,EAA8C,YAAM;AAElDH,QAAAA,KAAK,CAACI,iBAAN,CAAwB,EAAxB;;AACA,oCAAsCJ,KAAK,CAACK,cAAN,EAAtC;AAAA,YAAQC,OAAR,yBAAQA,OAAR;AAAA,YAAiBC,gBAAjB,yBAAiBA,gBAAjB;;AACA,YAAID,OAAJ,EAAa;AACXE,UAAAA,UAAU,CAAC,YAAM;AACfR,YAAAA,KAAK,CAACS,SAAN,CAAgBF,gBAAhB;AACD,WAFS,EAEP,GAFO,CAAV;AAGD;AACF,OATD;AAUD","sourcesContent":["import { ILayer, ILayerPlugin, IMapService, TYPES } from '@antv/l7-core';\nimport Source from '@antv/l7-source';\nimport { encodePickingColor, rgb2arr } from '@antv/l7-utils';\nimport { injectable } from 'inversify';\nimport 'reflect-metadata';\n/**\n * 更新图层样式,初始图层相关配置\n */\n@injectable()\nexport default class LayerStylePlugin implements ILayerPlugin {\n public apply(layer: ILayer) {\n layer.hooks.afterInit.tap('LayerStylePlugin', () => {\n // 更新图层默认状态\n layer.updateLayerConfig({});\n const { autoFit, fitBoundsOptions } = layer.getLayerConfig();\n if (autoFit) {\n setTimeout(() => {\n layer.fitBounds(fitBoundsOptions);\n }, 100);\n }\n });\n }\n}\n"],"file":"LayerStylePlugin.js"}
1
+ {"version":3,"sources":["../../src/plugins/LayerStylePlugin.ts"],"names":["LayerStylePlugin","layer","hooks","afterInit","tap","updateLayerConfig","getLayerConfig","autoFit","fitBoundsOptions","setTimeout","fitBounds"],"mappings":";;;;;;;;;;;;;AACA;;AACA;;;;IAKqBA,gB,WADpB,4B;;;;;;;WAEC,eAAaC,KAAb,EAA4B;AAC1BA,MAAAA,KAAK,CAACC,KAAN,CAAYC,SAAZ,CAAsBC,GAAtB,CAA0B,kBAA1B,EAA8C,YAAM;AAElDH,QAAAA,KAAK,CAACI,iBAAN,CAAwB,EAAxB;;AACA,oCAAsCJ,KAAK,CAACK,cAAN,EAAtC;AAAA,YAAQC,OAAR,yBAAQA,OAAR;AAAA,YAAiBC,gBAAjB,yBAAiBA,gBAAjB;;AACA,YAAID,OAAJ,EAAa;AACXE,UAAAA,UAAU,CAAC,YAAM;AACfR,YAAAA,KAAK,CAACS,SAAN,CAAgBF,gBAAhB;AACD,WAFS,EAEP,GAFO,CAAV;AAGD;AACF,OATD;AAUD","sourcesContent":["import { ILayer, ILayerPlugin, IMapService, TYPES } from '@antv/l7-core';\nimport { injectable } from 'inversify';\nimport 'reflect-metadata';\n/**\n * 更新图层样式,初始图层相关配置\n */\n@injectable()\nexport default class LayerStylePlugin implements ILayerPlugin {\n public apply(layer: ILayer) {\n layer.hooks.afterInit.tap('LayerStylePlugin', () => {\n // 更新图层默认状态\n layer.updateLayerConfig({});\n const { autoFit, fitBoundsOptions } = layer.getLayerConfig();\n if (autoFit) {\n setTimeout(() => {\n layer.fitBounds(fitBoundsOptions);\n }, 100);\n }\n });\n }\n}\n"],"file":"LayerStylePlugin.js"}
@@ -5,8 +5,8 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
5
5
  Object.defineProperty(exports, "__esModule", {
6
6
  value: true
7
7
  });
8
- exports.generateLightingUniforms = generateLightingUniforms;
9
8
  exports.default = void 0;
9
+ exports.generateLightingUniforms = generateLightingUniforms;
10
10
 
11
11
  var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
12
12
 
@@ -22,7 +22,9 @@ require("reflect-metadata");
22
22
 
23
23
  var _dec, _class;
24
24
 
25
- 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; }
25
+ var _excluded = ["type"];
26
+
27
+ 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; }
26
28
 
27
29
  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) { (0, _defineProperty2.default)(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; }
28
30
 
@@ -79,7 +81,7 @@ function generateLightingUniforms(lights) {
79
81
  lights.forEach(function (_ref, i) {
80
82
  var _ref$type = _ref.type,
81
83
  type = _ref$type === void 0 ? 'directional' : _ref$type,
82
- rest = (0, _objectWithoutProperties2.default)(_ref, ["type"]);
84
+ rest = (0, _objectWithoutProperties2.default)(_ref, _excluded);
83
85
  var lightsUniformName = lightTypeUniformMap[type].lights;
84
86
  var lightsNumUniformName = lightTypeUniformMap[type].num;
85
87
  var num = lightsMap[lightsNumUniformName];