@antv/l7-layers 2.9.25-alpha.0 → 2.9.25

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 (125) hide show
  1. package/es/heatmap/models/heatmap.js +1 -1
  2. package/es/tile/utils.js +1 -1
  3. package/lib/Geometry/index.js +114 -77
  4. package/lib/Geometry/models/billboard.js +232 -181
  5. package/lib/Geometry/models/index.js +18 -34
  6. package/lib/Geometry/models/plane.js +407 -278
  7. package/lib/Geometry/models/sprite.js +291 -189
  8. package/lib/canvas/index.js +101 -66
  9. package/lib/canvas/models/canvas.js +207 -140
  10. package/lib/canvas/models/index.js +12 -30
  11. package/lib/citybuliding/building.js +98 -63
  12. package/lib/citybuliding/models/build.js +192 -146
  13. package/lib/core/BaseLayer.js +1331 -814
  14. package/lib/core/BaseModel.js +457 -279
  15. package/lib/core/interface.js +40 -53
  16. package/lib/core/schema.js +21 -39
  17. package/lib/core/shape/Path.js +67 -79
  18. package/lib/core/shape/extrude.js +132 -91
  19. package/lib/core/triangulation.js +378 -196
  20. package/lib/earth/index.js +100 -62
  21. package/lib/earth/models/atmosphere.js +146 -112
  22. package/lib/earth/models/base.js +210 -150
  23. package/lib/earth/models/bloomsphere.js +146 -112
  24. package/lib/earth/utils.js +111 -91
  25. package/lib/heatmap/index.js +149 -92
  26. package/lib/heatmap/models/grid.js +118 -91
  27. package/lib/heatmap/models/grid3d.js +155 -123
  28. package/lib/heatmap/models/heatmap.js +475 -338
  29. package/lib/heatmap/models/hexagon.js +121 -92
  30. package/lib/heatmap/models/index.js +22 -37
  31. package/lib/heatmap/triangulation.js +31 -47
  32. package/lib/image/index.js +111 -74
  33. package/lib/image/models/dataImage.js +232 -174
  34. package/lib/image/models/image.js +175 -128
  35. package/lib/image/models/index.js +15 -32
  36. package/lib/index.js +263 -97
  37. package/lib/line/index.js +131 -85
  38. package/lib/line/models/arc.js +352 -237
  39. package/lib/line/models/arc_3d.js +334 -228
  40. package/lib/line/models/earthArc_3d.js +336 -228
  41. package/lib/line/models/great_circle.js +291 -200
  42. package/lib/line/models/half.js +286 -201
  43. package/lib/line/models/index.js +42 -50
  44. package/lib/line/models/line.js +428 -299
  45. package/lib/line/models/linearline.js +277 -203
  46. package/lib/line/models/simpleLine.js +239 -175
  47. package/lib/line/models/tile.js +348 -237
  48. package/lib/line/models/wall.js +327 -235
  49. package/lib/mask/index.js +92 -59
  50. package/lib/mask/models/fill.js +134 -82
  51. package/lib/mask/models/index.js +12 -30
  52. package/lib/plugins/DataMappingPlugin.js +342 -224
  53. package/lib/plugins/DataSourcePlugin.js +102 -87
  54. package/lib/plugins/FeatureScalePlugin.js +330 -240
  55. package/lib/plugins/LayerAnimateStylePlugin.js +61 -55
  56. package/lib/plugins/LayerModelPlugin.js +80 -73
  57. package/lib/plugins/LayerStylePlugin.js +48 -51
  58. package/lib/plugins/LightingPlugin.js +80 -68
  59. package/lib/plugins/MultiPassRendererPlugin.js +91 -65
  60. package/lib/plugins/PixelPickingPlugin.js +150 -109
  61. package/lib/plugins/RegisterStyleAttributePlugin.js +110 -110
  62. package/lib/plugins/ShaderUniformPlugin.js +118 -99
  63. package/lib/plugins/UpdateModelPlugin.js +40 -47
  64. package/lib/plugins/UpdateStyleAttributePlugin.js +93 -75
  65. package/lib/point/index.js +226 -150
  66. package/lib/point/models/earthExtrude.js +279 -201
  67. package/lib/point/models/earthFill.js +287 -202
  68. package/lib/point/models/extrude.js +299 -203
  69. package/lib/point/models/fill.js +406 -275
  70. package/lib/point/models/fillmage.js +365 -256
  71. package/lib/point/models/image.js +241 -168
  72. package/lib/point/models/index.js +46 -52
  73. package/lib/point/models/normal.js +183 -134
  74. package/lib/point/models/radar.js +304 -211
  75. package/lib/point/models/simplePoint.js +194 -142
  76. package/lib/point/models/text.js +608 -385
  77. package/lib/point/models/tile.js +314 -223
  78. package/lib/point/shape/extrude.js +56 -52
  79. package/lib/polygon/index.js +154 -102
  80. package/lib/polygon/models/extrude.js +311 -223
  81. package/lib/polygon/models/fill.js +215 -153
  82. package/lib/polygon/models/index.js +46 -52
  83. package/lib/polygon/models/ocean.js +244 -173
  84. package/lib/polygon/models/tile.js +144 -100
  85. package/lib/polygon/models/water.js +222 -153
  86. package/lib/raster/buffers/triangulation.js +27 -40
  87. package/lib/raster/index.js +115 -75
  88. package/lib/raster/models/index.js +16 -33
  89. package/lib/raster/models/raster.js +178 -135
  90. package/lib/raster/raster.js +187 -132
  91. package/lib/tile/interface.js +4 -16
  92. package/lib/tile/manager/tileConfigManager.js +125 -86
  93. package/lib/tile/manager/tileLayerManager.js +313 -229
  94. package/lib/tile/manager/tilePickerManager.js +192 -123
  95. package/lib/tile/models/tileModel.js +71 -52
  96. package/lib/tile/tileFactory/base.js +432 -309
  97. package/lib/tile/tileFactory/index.js +51 -49
  98. package/lib/tile/tileFactory/line.js +65 -50
  99. package/lib/tile/tileFactory/point.js +65 -50
  100. package/lib/tile/tileFactory/polygon.js +65 -50
  101. package/lib/tile/tileFactory/raster.js +66 -54
  102. package/lib/tile/tileFactory/rasterData.js +88 -76
  103. package/lib/tile/tileFactory/rasterDataLayer.js +97 -62
  104. package/lib/tile/tileFactory/vectorLayer.js +168 -109
  105. package/lib/tile/tileLayer/baseTileLayer.js +420 -221
  106. package/lib/tile/tmsTileLayer.js +110 -67
  107. package/lib/tile/utils.js +110 -92
  108. package/lib/utils/blend.js +59 -79
  109. package/lib/utils/collision-index.js +107 -64
  110. package/lib/utils/dataMappingStyle.js +105 -60
  111. package/lib/utils/extrude_polyline.js +600 -398
  112. package/lib/utils/grid-index.js +163 -111
  113. package/lib/utils/layerData.js +130 -99
  114. package/lib/utils/multiPassRender.js +49 -41
  115. package/lib/utils/polylineNormal.js +148 -96
  116. package/lib/utils/simpleLine.js +100 -85
  117. package/lib/utils/symbol-layout.js +219 -116
  118. package/lib/utils/updateShape.js +15 -41
  119. package/lib/wind/index.js +109 -71
  120. package/lib/wind/models/index.js +12 -30
  121. package/lib/wind/models/utils.js +144 -105
  122. package/lib/wind/models/wind.js +333 -224
  123. package/lib/wind/models/windRender.js +329 -218
  124. package/lib/wind/models/windShader.js +23 -181
  125. package/package.json +6 -6
@@ -1,234 +1,325 @@
1
- var __create = Object.create;
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __getProtoOf = Object.getPrototypeOf;
6
- var __hasOwnProp = Object.prototype.hasOwnProperty;
7
- var __export = (target, all) => {
8
- for (var name in all)
9
- __defProp(target, name, { get: all[name], enumerable: true });
10
- };
11
- var __copyProps = (to, from, except, desc) => {
12
- if (from && typeof from === "object" || typeof from === "function") {
13
- for (let key of __getOwnPropNames(from))
14
- if (!__hasOwnProp.call(to, key) && key !== except)
15
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
- }
17
- return to;
18
- };
19
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod));
20
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
21
-
22
- // src/point/models/tile.ts
23
- var tile_exports = {};
24
- __export(tile_exports, {
25
- default: () => FillModel
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
26
7
  });
27
- module.exports = __toCommonJS(tile_exports);
28
- var import_l7_core = require("@antv/l7-core");
29
- var import_l7_utils = require("@antv/l7-utils");
30
- var import_BaseModel = __toESM(require("../../core/BaseModel"));
31
- var import_triangulation = require("../../core/triangulation");
32
- var import_fill_tile_frag = __toESM(require("../shaders/tile/fill_tile_frag.glsl"));
33
- var import_fill_tile_vert = __toESM(require("../shaders/tile/fill_tile_vert.glsl"));
34
- var import_l7_maps = require("@antv/l7-maps");
35
- var FillModel = class extends import_BaseModel.default {
36
- constructor() {
37
- super(...arguments);
38
- this.meter2coord = 1;
39
- this.isMeter = false;
40
- }
41
- getUninforms() {
42
- const {
43
- opacity = 1,
44
- strokeOpacity = 1,
45
- strokeWidth = 0,
46
- stroke = "rgba(0,0,0,0)",
47
- offsets = [0, 0],
48
- blend,
49
- blur = 0,
50
- coord = "lnglat",
51
- tileOrigin
52
- } = this.layer.getLayerConfig();
53
- if (this.dataTextureTest && this.dataTextureNeedUpdate({
54
- opacity,
55
- strokeOpacity,
56
- strokeWidth,
57
- stroke,
58
- offsets
59
- })) {
60
- this.judgeStyleAttributes({
61
- opacity,
62
- strokeOpacity,
63
- strokeWidth,
64
- stroke,
65
- offsets
66
- });
67
- const encodeData = this.layer.getEncodedData();
68
- const { data, width, height } = this.calDataFrame(this.cellLength, encodeData, this.cellProperties);
69
- this.rowCount = height;
70
- this.dataTexture = this.cellLength > 0 && data.length > 0 ? this.createTexture2D({
71
- flipY: true,
72
- data,
73
- format: import_l7_core.gl.LUMINANCE,
74
- type: import_l7_core.gl.FLOAT,
75
- width,
76
- height
77
- }) : this.createTexture2D({
78
- flipY: true,
79
- data: [1],
80
- format: import_l7_core.gl.LUMINANCE,
81
- type: import_l7_core.gl.FLOAT,
82
- width: 1,
83
- height: 1
84
- });
8
+ exports.default = void 0;
9
+
10
+ var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
11
+
12
+ var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
13
+
14
+ var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
15
+
16
+ var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
17
+
18
+ var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
19
+
20
+ var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
21
+
22
+ var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
23
+
24
+ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
25
+
26
+ var _l7Core = require("@antv/l7-core");
27
+
28
+ var _l7Utils = require("@antv/l7-utils");
29
+
30
+ var _BaseModel2 = _interopRequireDefault(require("../../core/BaseModel"));
31
+
32
+ var _triangulation = require("../../core/triangulation");
33
+
34
+ var _l7Maps = require("@antv/l7-maps");
35
+
36
+ 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); }; }
37
+
38
+ 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; } }
39
+
40
+ /* babel-plugin-inline-import '../shaders/tile/fill_tile_frag.glsl' */
41
+ var point_tile_frag = "uniform float u_additive;\nvarying mat4 styleMappingMat; // \u4F20\u9012\u4ECE\u7247\u5143\u4E2D\u4F20\u9012\u7684\u6620\u5C04\u6570\u636E\n\nvarying vec4 v_data;\nvarying vec4 v_color;\nvarying float v_radius;\n\n#pragma include \"sdf_2d\"\n#pragma include \"picking\"\n\nvoid main() {\n int shape = int(floor(v_data.w + 0.5));\n\n vec4 textrueStroke = vec4(\n styleMappingMat[1][0],\n styleMappingMat[1][1],\n styleMappingMat[1][2],\n styleMappingMat[1][3]\n );\n\n float opacity = styleMappingMat[0][0];\n float stroke_opacity = styleMappingMat[0][1];\n float strokeWidth = styleMappingMat[0][2];\n vec4 strokeColor = textrueStroke == vec4(0) ? v_color : textrueStroke;\n\n lowp float antialiasblur = v_data.z;\n float r = v_radius / (v_radius + strokeWidth);\n\n float outer_df;\n float inner_df;\n // 'circle', 'triangle', 'square', 'pentagon', 'hexagon', 'octogon', 'hexagram', 'rhombus', 'vesica'\n if (shape == 0) {\n outer_df = sdCircle(v_data.xy, 1.0);\n inner_df = sdCircle(v_data.xy, r);\n } else if (shape == 1) {\n outer_df = sdEquilateralTriangle(1.1 * v_data.xy);\n inner_df = sdEquilateralTriangle(1.1 / r * v_data.xy);\n } else if (shape == 2) {\n outer_df = sdBox(v_data.xy, vec2(1.));\n inner_df = sdBox(v_data.xy, vec2(r));\n } else if (shape == 3) {\n outer_df = sdPentagon(v_data.xy, 0.8);\n inner_df = sdPentagon(v_data.xy, r * 0.8);\n } else if (shape == 4) {\n outer_df = sdHexagon(v_data.xy, 0.8);\n inner_df = sdHexagon(v_data.xy, r * 0.8);\n } else if (shape == 5) {\n outer_df = sdOctogon(v_data.xy, 1.0);\n inner_df = sdOctogon(v_data.xy, r);\n } else if (shape == 6) {\n outer_df = sdHexagram(v_data.xy, 0.52);\n inner_df = sdHexagram(v_data.xy, r * 0.52);\n } else if (shape == 7) {\n outer_df = sdRhombus(v_data.xy, vec2(1.0));\n inner_df = sdRhombus(v_data.xy, vec2(r));\n } else if (shape == 8) {\n outer_df = sdVesica(v_data.xy, 1.1, 0.8);\n inner_df = sdVesica(v_data.xy, r * 1.1, r * 0.8);\n }\n\n\n float opacity_t = smoothstep(0.0, antialiasblur, outer_df);\n\n float color_t = strokeWidth < 0.01 ? 0.0 : smoothstep(\n antialiasblur,\n 0.0,\n inner_df\n );\n\n if(strokeWidth < 0.01) {\n gl_FragColor = vec4(v_color.rgb, v_color.a * opacity);\n } else {\n gl_FragColor = mix(vec4(v_color.rgb, v_color.a * opacity), strokeColor * stroke_opacity, color_t);\n }\n\n if(u_additive > 0.0) {\n gl_FragColor *= opacity_t;\n gl_FragColor = filterColorAlpha(gl_FragColor, gl_FragColor.a);\n } else {\n gl_FragColor.a *= opacity_t;\n gl_FragColor = filterColor(gl_FragColor);\n }\n}\n";
42
+
43
+ /* babel-plugin-inline-import '../shaders/tile/fill_tile_vert.glsl' */
44
+ var point_tile_vert = "attribute vec4 a_Color;\nattribute vec3 a_Position;\nattribute vec3 a_Extrude;\nattribute float a_Size;\nattribute float a_Shape;\n\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\nuniform mat4 u_ModelMatrix;\nuniform mat4 u_Mvp;\nuniform float u_isMeter;\n\nuniform vec2 u_tileOrigin;\nuniform float u_coord;\n\nvarying vec4 v_data;\nvarying vec4 v_color;\nvarying float v_radius;\n\nuniform float u_opacity : 1;\nuniform float u_stroke_opacity : 1;\nuniform float u_stroke_width : 2;\nuniform vec4 u_stroke_color : [0.0, 0.0, 0.0, 0.0];\nuniform vec2 u_offsets;\n\nuniform float u_blur : 0.0;\n\n#pragma include \"styleMapping\"\n#pragma include \"styleMappingCalOpacity\"\n#pragma include \"styleMappingCalStrokeOpacity\"\n#pragma include \"styleMappingCalStrokeWidth\"\n\n#pragma include \"projection\"\n#pragma include \"picking\"\n\nvoid main() {\n vec3 extrude = a_Extrude;\n float shape_type = a_Shape;\n float newSize = setPickingSize(a_Size);\n\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\n vec2 strokeOpacityAndOffset = calStrokeOpacityAndOffset(cellCurrentRow, cellCurrentColumn, columnCount, textureOffset, columnWidth, rowHeight);\n styleMappingMat[0][1] = strokeOpacityAndOffset.r;\n textureOffset = strokeOpacityAndOffset.g;\n\n vec2 strokeWidthAndOffset = calStrokeWidthAndOffset(cellCurrentRow, cellCurrentColumn, columnCount, textureOffset, columnWidth, rowHeight);\n styleMappingMat[0][2] = strokeWidthAndOffset.r;\n textureOffset = strokeWidthAndOffset.g;\n\n vec4 textrueStroke = vec4(-1.0, -1.0, -1.0, -1.0);\n if(hasStroke()) {\n vec2 valueRPos = nextPos(cellCurrentRow, cellCurrentColumn, columnCount, textureOffset);\n styleMappingMat[1][0] = pos2value(valueRPos, columnWidth, rowHeight); // R\n textureOffset += 1.0;\n\n vec2 valueGPos = nextPos(cellCurrentRow, cellCurrentColumn, columnCount, textureOffset);\n styleMappingMat[1][1] = pos2value(valueGPos, columnWidth, rowHeight); // G\n textureOffset += 1.0;\n\n vec2 valueBPos = nextPos(cellCurrentRow, cellCurrentColumn, columnCount, textureOffset);\n styleMappingMat[1][2] = pos2value(valueBPos, columnWidth, rowHeight); // B\n textureOffset += 1.0;\n\n vec2 valueAPos = nextPos(cellCurrentRow, cellCurrentColumn, columnCount, textureOffset);\n styleMappingMat[1][3] = pos2value(valueAPos, columnWidth, rowHeight); // A\n textureOffset += 1.0;\n } else {\n if(u_stroke_color == vec4(0.0)) {\n styleMappingMat[1][0] = v_color.r;\n styleMappingMat[1][1] = v_color.g;\n styleMappingMat[1][2] = v_color.b;\n styleMappingMat[1][3] = v_color.a;\n } else {\n styleMappingMat[1][0] = u_stroke_color.r;\n styleMappingMat[1][1] = u_stroke_color.g;\n styleMappingMat[1][2] = u_stroke_color.b;\n styleMappingMat[1][3] = u_stroke_color.a;\n }\n }\n\n vec2 textrueOffsets = vec2(0.0, 0.0);\n if(hasOffsets()) {\n vec2 valueXPos = nextPos(cellCurrentRow, cellCurrentColumn, columnCount, textureOffset);\n textrueOffsets.r = pos2value(valueXPos, columnWidth, rowHeight); // x\n textureOffset += 1.0;\n\n vec2 valueYPos = nextPos(cellCurrentRow, cellCurrentColumn, columnCount, textureOffset);\n textrueOffsets.g = pos2value(valueYPos, columnWidth, rowHeight); // x\n textureOffset += 1.0;\n } else {\n textrueOffsets = u_offsets;\n }\n\n // cal style mapping\n\n v_color = a_Color;\n v_radius = newSize;\n\n // anti-alias\n // float antialiased_blur = -max(u_blur, antialiasblur);\n float antialiasblur = -max(2.0 / u_DevicePixelRatio / a_Size, u_blur);\n\n vec2 offset = (extrude.xy * (newSize + u_stroke_width) + textrueOffsets);\n vec3 aPosition = a_Position;\n if(u_isMeter < 1.0) {\n // \u4E0D\u4EE5\u7C73\u4E3A\u5B9E\u9645\u5355\u4F4D\n offset = project_pixel(offset);\n } else {\n // \u4EE5\u7C73\u4E3A\u5B9E\u9645\u5355\u4F4D\n antialiasblur *= pow(19.0 - u_Zoom, 2.0);\n antialiasblur = max(antialiasblur, -0.01);\n // offset *= 0.5;\n\n if(u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT || u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT_OFFSET) {\n aPosition.xy += offset;\n offset.x = 0.0;\n offset.y = 0.0;\n }\n }\n\n v_data = vec4(extrude.x, extrude.y, antialiasblur,shape_type);\n\n vec4 project_pos = project_position(vec4(aPosition.xy, 0.0, 1.0));\n\n if(u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT || u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT_OFFSET) {\n float mapboxZoomScale = 4.0/pow(2.0, 21.0 - u_Zoom);\n }\n\nif(u_coord > 0.0) {\n if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) { // gaode2.x\n gl_Position = u_Mvp * vec4(project_pos.xy + offset, 0.0, 1.0);\n } else {\n gl_Position = project_common_position_to_clipspace(vec4(project_pos.xy + offset, 0.0, 1.0));\n }\n} else {\n gl_PointSize = 24.0;\n vec2 pointPos = a_Position.xy;\n vec4 world = vec4(project_mvt_offset_position(vec4(u_tileOrigin, 0.0, 1.0)).xyz, 1.0); // \u74E6\u7247\u8D77\u59CB\u70B9\u7684\u4E16\u754C\u5750\u6807\n\n vec2 pointOffset = pointPos * pow(2.0, u_Zoom); // \u74E6\u7247\u5185\u7684\u70B9\u7684\u504F\u79FB\u5750\u6807\n \n world.xy += offset;\n world.xy += pointOffset;\n\n if (u_CoordinateSystem == COORDINATE_SYSTEM_METER_OFFSET || u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT_OFFSET) {\n // Needs to be divided with project_uCommonUnitsPerMeter\n world.w *= u_PixelsPerMeter.z;\n }\n\n gl_Position = u_ViewProjectionMatrix * world + u_ViewportCenterProjection;\n}\n\n \n setPickingColor(a_PickingColor);\n\n\n}\n";
45
+
46
+ var FillModel = /*#__PURE__*/function (_BaseModel) {
47
+ (0, _inherits2.default)(FillModel, _BaseModel);
48
+
49
+ var _super = _createSuper(FillModel);
50
+
51
+ function FillModel() {
52
+ var _this;
53
+
54
+ (0, _classCallCheck2.default)(this, FillModel);
55
+
56
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
57
+ args[_key] = arguments[_key];
85
58
  }
86
- return {
87
- u_tileOrigin: tileOrigin || [0, 0],
88
- u_coord: coord === "lnglat" ? 1 : 0,
89
- u_isMeter: Number(this.isMeter),
90
- u_blur: blur,
91
- u_additive: blend === "additive" ? 1 : 0,
92
- u_dataTexture: this.dataTexture,
93
- u_cellTypeLayout: this.getCellTypeLayout(),
94
- u_opacity: Number(opacity),
95
- u_stroke_opacity: Number(strokeOpacity),
96
- u_stroke_width: Number(strokeWidth),
97
- u_stroke_color: this.getStrokeColor(stroke),
98
- u_offsets: this.isOffsetStatic(offsets) ? offsets : [0, 0]
99
- };
100
- }
101
- getAttribute() {
102
- return this.styleAttributeService.createAttributesAndIndices(this.layer.getEncodedData(), import_triangulation.PointFillTriangulation);
59
+
60
+ _this = _super.call.apply(_super, [this].concat(args));
61
+ (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "meter2coord", 1);
62
+ (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "isMeter", false);
63
+ return _this;
103
64
  }
104
- initModels(callbackModel) {
105
- const {
106
- unit = "l7size"
107
- } = this.layer.getLayerConfig();
108
- const { version } = this.mapService;
109
- if (unit === "meter" && version !== import_l7_maps.Version.L7MAP && version !== import_l7_maps.Version.GLOBEL) {
110
- this.isMeter = true;
111
- this.calMeter2Coord();
65
+
66
+ (0, _createClass2.default)(FillModel, [{
67
+ key: "getUninforms",
68
+ value: function getUninforms() {
69
+ var _ref = this.layer.getLayerConfig(),
70
+ _ref$opacity = _ref.opacity,
71
+ opacity = _ref$opacity === void 0 ? 1 : _ref$opacity,
72
+ _ref$strokeOpacity = _ref.strokeOpacity,
73
+ strokeOpacity = _ref$strokeOpacity === void 0 ? 1 : _ref$strokeOpacity,
74
+ _ref$strokeWidth = _ref.strokeWidth,
75
+ strokeWidth = _ref$strokeWidth === void 0 ? 0 : _ref$strokeWidth,
76
+ _ref$stroke = _ref.stroke,
77
+ stroke = _ref$stroke === void 0 ? 'rgba(0,0,0,0)' : _ref$stroke,
78
+ _ref$offsets = _ref.offsets,
79
+ offsets = _ref$offsets === void 0 ? [0, 0] : _ref$offsets,
80
+ blend = _ref.blend,
81
+ _ref$blur = _ref.blur,
82
+ blur = _ref$blur === void 0 ? 0 : _ref$blur,
83
+ _ref$coord = _ref.coord,
84
+ coord = _ref$coord === void 0 ? 'lnglat' : _ref$coord,
85
+ tileOrigin = _ref.tileOrigin;
86
+
87
+ if (this.dataTextureTest && this.dataTextureNeedUpdate({
88
+ opacity: opacity,
89
+ strokeOpacity: strokeOpacity,
90
+ strokeWidth: strokeWidth,
91
+ stroke: stroke,
92
+ offsets: offsets
93
+ })) {
94
+ // 判断当前的样式中哪些是需要进行数据映射的,哪些是常量,同时计算用于构建数据纹理的一些中间变量
95
+ this.judgeStyleAttributes({
96
+ opacity: opacity,
97
+ strokeOpacity: strokeOpacity,
98
+ strokeWidth: strokeWidth,
99
+ stroke: stroke,
100
+ offsets: offsets
101
+ });
102
+ var encodeData = this.layer.getEncodedData();
103
+
104
+ var _this$calDataFrame = this.calDataFrame(this.cellLength, encodeData, this.cellProperties),
105
+ data = _this$calDataFrame.data,
106
+ width = _this$calDataFrame.width,
107
+ height = _this$calDataFrame.height;
108
+
109
+ this.rowCount = height; // 当前数据纹理有多少行
110
+
111
+ this.dataTexture = this.cellLength > 0 && data.length > 0 ? this.createTexture2D({
112
+ flipY: true,
113
+ data: data,
114
+ format: _l7Core.gl.LUMINANCE,
115
+ type: _l7Core.gl.FLOAT,
116
+ width: width,
117
+ height: height
118
+ }) : this.createTexture2D({
119
+ flipY: true,
120
+ data: [1],
121
+ format: _l7Core.gl.LUMINANCE,
122
+ type: _l7Core.gl.FLOAT,
123
+ width: 1,
124
+ height: 1
125
+ });
126
+ }
127
+
128
+ return {
129
+ u_tileOrigin: tileOrigin || [0, 0],
130
+ u_coord: coord === 'lnglat' ? 1.0 : 0.0,
131
+ u_isMeter: Number(this.isMeter),
132
+ u_blur: blur,
133
+ u_additive: blend === 'additive' ? 1.0 : 0.0,
134
+ u_dataTexture: this.dataTexture,
135
+ // 数据纹理 - 有数据映射的时候纹理中带数据,若没有任何数据映射时纹理是 [1]
136
+ u_cellTypeLayout: this.getCellTypeLayout(),
137
+ u_opacity: Number(opacity),
138
+ u_stroke_opacity: Number(strokeOpacity),
139
+ u_stroke_width: Number(strokeWidth),
140
+ u_stroke_color: this.getStrokeColor(stroke),
141
+ u_offsets: this.isOffsetStatic(offsets) ? offsets : [0, 0]
142
+ };
112
143
  }
113
- this.buildModels(callbackModel);
114
- }
115
- calMeter2Coord() {
116
- const [minLng, minLat, maxLng, maxLat] = this.layer.getSource().extent;
117
- const center = [(minLng + maxLng) / 2, (minLat + maxLat) / 2];
118
- const { version } = this.mapService;
119
- if (version === import_l7_maps.Version.MAPBOX && window.mapboxgl.MercatorCoordinate) {
120
- const coord = window.mapboxgl.MercatorCoordinate.fromLngLat({ lng: center[0], lat: center[1] }, 0);
121
- const offsetInMeters = 1;
122
- const offsetInMercatorCoordinateUnits = offsetInMeters * coord.meterInMercatorCoordinateUnits();
123
- const westCoord = new window.mapboxgl.MercatorCoordinate(coord.x - offsetInMercatorCoordinateUnits, coord.y, coord.z);
124
- const westLnglat = westCoord.toLngLat();
125
- this.meter2coord = center[0] - westLnglat.lng;
126
- return;
144
+ }, {
145
+ key: "getAttribute",
146
+ value: function getAttribute() {
147
+ return this.styleAttributeService.createAttributesAndIndices(this.layer.getEncodedData(), _triangulation.PointFillTriangulation);
127
148
  }
128
- const m1 = this.mapService.meterToCoord(center, [minLng, minLat]);
129
- const m2 = this.mapService.meterToCoord(center, [
130
- maxLng === minLng ? maxLng + 0.1 : maxLng,
131
- maxLat === minLat ? minLat + 0.1 : maxLat
132
- ]);
133
- this.meter2coord = (m1 + m2) / 2;
134
- if (!this.meter2coord) {
135
- this.meter2coord = 7.70681090738883;
149
+ }, {
150
+ key: "initModels",
151
+ value: function initModels(callbackModel) {
152
+ var _ref2 = this.layer.getLayerConfig(),
153
+ _ref2$unit = _ref2.unit,
154
+ unit = _ref2$unit === void 0 ? 'l7size' : _ref2$unit;
155
+
156
+ var version = this.mapService.version;
157
+
158
+ if (unit === 'meter' && version !== _l7Maps.Version.L7MAP && version !== _l7Maps.Version.GLOBEL) {
159
+ this.isMeter = true;
160
+ this.calMeter2Coord();
161
+ }
162
+
163
+ this.buildModels(callbackModel);
136
164
  }
137
- }
138
- buildModels(callbackModel) {
139
- const {
140
- mask = false,
141
- maskInside = true,
142
- workerEnabled = false
143
- } = this.layer.getLayerConfig();
144
- this.layer.triangulation = import_triangulation.PointFillTriangulation;
145
- this.layer.buildLayerModel({
146
- moduleName: "pointTile",
147
- vertexShader: import_fill_tile_vert.default,
148
- fragmentShader: import_fill_tile_frag.default,
149
- triangulation: import_triangulation.PointFillTriangulation,
150
- depth: { enable: false },
151
- cull: {
152
- enable: true,
153
- face: (0, import_l7_utils.getCullFace)(this.mapService.version)
154
- },
155
- blend: this.getBlend(),
156
- stencil: (0, import_l7_utils.getMask)(mask, maskInside),
157
- workerEnabled,
158
- workerOptions: {
159
- modelType: "pointTile"
165
+ /**
166
+ * 计算等面积点图层(unit meter)笛卡尔坐标标度与世界坐标标度的比例
167
+ * @returns
168
+ */
169
+
170
+ }, {
171
+ key: "calMeter2Coord",
172
+ value: function calMeter2Coord() {
173
+ var _this$layer$getSource = (0, _slicedToArray2.default)(this.layer.getSource().extent, 4),
174
+ minLng = _this$layer$getSource[0],
175
+ minLat = _this$layer$getSource[1],
176
+ maxLng = _this$layer$getSource[2],
177
+ maxLat = _this$layer$getSource[3];
178
+
179
+ var center = [(minLng + maxLng) / 2, (minLat + maxLat) / 2];
180
+ var version = this.mapService.version;
181
+
182
+ if (version === _l7Maps.Version.MAPBOX && window.mapboxgl.MercatorCoordinate) {
183
+ var coord = window.mapboxgl.MercatorCoordinate.fromLngLat({
184
+ lng: center[0],
185
+ lat: center[1]
186
+ }, 0);
187
+ var offsetInMeters = 1;
188
+ var offsetInMercatorCoordinateUnits = offsetInMeters * coord.meterInMercatorCoordinateUnits();
189
+ var westCoord = new window.mapboxgl.MercatorCoordinate(coord.x - offsetInMercatorCoordinateUnits, coord.y, coord.z);
190
+ var westLnglat = westCoord.toLngLat();
191
+ this.meter2coord = center[0] - westLnglat.lng;
192
+ return;
193
+ } // @ts-ignore
194
+
195
+
196
+ var m1 = this.mapService.meterToCoord(center, [minLng, minLat]); // @ts-ignore
197
+
198
+ var m2 = this.mapService.meterToCoord(center, [maxLng === minLng ? maxLng + 0.1 : maxLng, maxLat === minLat ? minLat + 0.1 : maxLat]);
199
+ this.meter2coord = (m1 + m2) / 2;
200
+
201
+ if (!this.meter2coord) {
202
+ // Tip: 兼容单个数据导致的 m1、m2 为 NaN
203
+ this.meter2coord = 7.70681090738883;
160
204
  }
161
- }).then((model) => {
162
- callbackModel([model]);
163
- }).catch((err) => {
164
- console.warn(err);
165
- callbackModel([]);
166
- });
167
- }
168
- clearModels() {
169
- var _a;
170
- (_a = this.dataTexture) == null ? void 0 : _a.destroy();
171
- }
172
- registerBuiltinAttributes() {
173
- this.styleAttributeService.registerStyleAttribute({
174
- name: "extrude",
175
- type: import_l7_core.AttributeType.Attribute,
176
- descriptor: {
177
- name: "a_Extrude",
178
- buffer: {
179
- usage: import_l7_core.gl.DYNAMIC_DRAW,
180
- data: [],
181
- type: import_l7_core.gl.FLOAT
205
+ }
206
+ }, {
207
+ key: "buildModels",
208
+ value: function buildModels(callbackModel) {
209
+ var _ref3 = this.layer.getLayerConfig(),
210
+ _ref3$mask = _ref3.mask,
211
+ mask = _ref3$mask === void 0 ? false : _ref3$mask,
212
+ _ref3$maskInside = _ref3.maskInside,
213
+ maskInside = _ref3$maskInside === void 0 ? true : _ref3$maskInside,
214
+ _ref3$workerEnabled = _ref3.workerEnabled,
215
+ workerEnabled = _ref3$workerEnabled === void 0 ? false : _ref3$workerEnabled;
216
+
217
+ this.layer.triangulation = _triangulation.PointFillTriangulation;
218
+ this.layer.buildLayerModel({
219
+ moduleName: 'pointTile',
220
+ vertexShader: point_tile_vert,
221
+ fragmentShader: point_tile_frag,
222
+ triangulation: _triangulation.PointFillTriangulation,
223
+ depth: {
224
+ enable: false
182
225
  },
183
- size: 3,
184
- update: (feature, featureIdx, vertex, attributeIdx) => {
185
- const extrude = [1, 1, 0, -1, 1, 0, -1, -1, 0, 1, -1, 0];
186
- const extrudeIndex = attributeIdx % 4 * 3;
187
- return [
188
- extrude[extrudeIndex],
189
- extrude[extrudeIndex + 1],
190
- extrude[extrudeIndex + 2]
191
- ];
192
- }
193
- }
194
- });
195
- this.styleAttributeService.registerStyleAttribute({
196
- name: "size",
197
- type: import_l7_core.AttributeType.Attribute,
198
- descriptor: {
199
- name: "a_Size",
200
- buffer: {
201
- usage: import_l7_core.gl.DYNAMIC_DRAW,
202
- data: [],
203
- type: import_l7_core.gl.FLOAT
226
+ cull: {
227
+ enable: true,
228
+ face: (0, _l7Utils.getCullFace)(this.mapService.version)
204
229
  },
205
- size: 1,
206
- update: (feature, featureIdx, vertex, attributeIdx) => {
207
- const { size = 5 } = feature;
208
- return Array.isArray(size) ? [size[0] * this.meter2coord] : [size * this.meter2coord];
230
+ blend: this.getBlend(),
231
+ stencil: (0, _l7Utils.getMask)(mask, maskInside),
232
+ workerEnabled: workerEnabled,
233
+ workerOptions: {
234
+ modelType: 'pointTile'
209
235
  }
210
- }
211
- });
212
- this.styleAttributeService.registerStyleAttribute({
213
- name: "shape",
214
- type: import_l7_core.AttributeType.Attribute,
215
- descriptor: {
216
- name: "a_Shape",
217
- buffer: {
218
- usage: import_l7_core.gl.DYNAMIC_DRAW,
219
- data: [],
220
- type: import_l7_core.gl.FLOAT
221
- },
222
- size: 1,
223
- update: (feature, featureIdx, vertex, attributeIdx) => {
224
- const { shape = 2 } = feature;
225
- const shape2d = this.layer.getLayerConfig().shape2d;
226
- const shapeIndex = shape2d.indexOf(shape);
227
- return [shapeIndex];
236
+ }).then(function (model) {
237
+ callbackModel([model]);
238
+ }).catch(function (err) {
239
+ console.warn(err);
240
+ callbackModel([]);
241
+ });
242
+ }
243
+ }, {
244
+ key: "clearModels",
245
+ value: function clearModels() {
246
+ var _this$dataTexture;
247
+
248
+ (_this$dataTexture = this.dataTexture) === null || _this$dataTexture === void 0 ? void 0 : _this$dataTexture.destroy();
249
+ } // overwrite baseModel func
250
+
251
+ }, {
252
+ key: "registerBuiltinAttributes",
253
+ value: function registerBuiltinAttributes() {
254
+ var _this2 = this;
255
+
256
+ this.styleAttributeService.registerStyleAttribute({
257
+ name: 'extrude',
258
+ type: _l7Core.AttributeType.Attribute,
259
+ descriptor: {
260
+ name: 'a_Extrude',
261
+ buffer: {
262
+ // give the WebGL driver a hint that this buffer may change
263
+ usage: _l7Core.gl.DYNAMIC_DRAW,
264
+ data: [],
265
+ type: _l7Core.gl.FLOAT
266
+ },
267
+ size: 3,
268
+ update: function update(feature, featureIdx, vertex, attributeIdx) {
269
+ var extrude = [1, 1, 0, -1, 1, 0, -1, -1, 0, 1, -1, 0];
270
+ var extrudeIndex = attributeIdx % 4 * 3;
271
+ return [extrude[extrudeIndex], extrude[extrudeIndex + 1], extrude[extrudeIndex + 2]];
272
+ }
228
273
  }
229
- }
230
- });
231
- }
232
- };
233
- // Annotate the CommonJS export names for ESM import in node:
234
- 0 && (module.exports = {});
274
+ }); // point layer size;
275
+
276
+ this.styleAttributeService.registerStyleAttribute({
277
+ name: 'size',
278
+ type: _l7Core.AttributeType.Attribute,
279
+ descriptor: {
280
+ name: 'a_Size',
281
+ buffer: {
282
+ // give the WebGL driver a hint that this buffer may change
283
+ usage: _l7Core.gl.DYNAMIC_DRAW,
284
+ data: [],
285
+ type: _l7Core.gl.FLOAT
286
+ },
287
+ size: 1,
288
+ update: function update(feature, featureIdx, vertex, attributeIdx) {
289
+ var _feature$size = feature.size,
290
+ size = _feature$size === void 0 ? 5 : _feature$size; // console.log('featureIdx', featureIdx, feature)
291
+
292
+ return Array.isArray(size) ? [size[0] * _this2.meter2coord] : [size * _this2.meter2coord];
293
+ }
294
+ }
295
+ }); // point layer size;
296
+
297
+ this.styleAttributeService.registerStyleAttribute({
298
+ name: 'shape',
299
+ type: _l7Core.AttributeType.Attribute,
300
+ descriptor: {
301
+ name: 'a_Shape',
302
+ buffer: {
303
+ // give the WebGL driver a hint that this buffer may change
304
+ usage: _l7Core.gl.DYNAMIC_DRAW,
305
+ data: [],
306
+ type: _l7Core.gl.FLOAT
307
+ },
308
+ size: 1,
309
+ update: function update(feature, featureIdx, vertex, attributeIdx) {
310
+ var _feature$shape = feature.shape,
311
+ shape = _feature$shape === void 0 ? 2 : _feature$shape;
312
+
313
+ var shape2d = _this2.layer.getLayerConfig().shape2d;
314
+
315
+ var shapeIndex = shape2d.indexOf(shape);
316
+ return [shapeIndex];
317
+ }
318
+ }
319
+ });
320
+ }
321
+ }]);
322
+ return FillModel;
323
+ }(_BaseModel2.default);
324
+
325
+ exports.default = FillModel;