@antv/l7-layers 2.12.1 → 2.13.0

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 (96) hide show
  1. package/es/core/BaseLayer.d.ts +1 -1
  2. package/es/core/BaseLayer.js +18 -7
  3. package/es/core/TextureService.d.ts +4 -3
  4. package/es/core/TextureService.js +32 -10
  5. package/es/core/interface.d.ts +5 -6
  6. package/es/core/interface.js +7 -0
  7. package/es/line/index.d.ts +1 -1
  8. package/es/line/models/index.d.ts +1 -1
  9. package/es/line/models/index.js +0 -2
  10. package/es/plugins/DataMappingPlugin.js +10 -7
  11. package/es/point/index.d.ts +1 -1
  12. package/es/point/models/fill.d.ts +0 -14
  13. package/es/point/models/fill.js +9 -100
  14. package/es/point/models/fillmage.d.ts +0 -5
  15. package/es/point/models/fillmage.js +15 -65
  16. package/es/point/models/index.d.ts +1 -1
  17. package/es/point/models/index.js +0 -4
  18. package/es/point/models/radar.d.ts +0 -7
  19. package/es/point/models/radar.js +13 -79
  20. package/es/point/models/text.js +1 -1
  21. package/es/point/shaders/fill_vert.glsl +9 -26
  22. package/es/point/shaders/image/fillImage_vert.glsl +8 -14
  23. package/es/point/shaders/radar/radar_vert.glsl +12 -19
  24. package/es/point/shaders/text_vert.glsl +1 -1
  25. package/es/polygon/index.js +0 -2
  26. package/es/polygon/models/index.d.ts +1 -1
  27. package/es/polygon/models/index.js +2 -4
  28. package/es/raster/models/raster.d.ts +0 -2
  29. package/es/raster/models/raster.js +6 -22
  30. package/es/raster/models/rasterTerrainRgb.js +6 -6
  31. package/es/raster/shaders/raster_2d_frag.glsl +1 -0
  32. package/es/tile/tileFactory/RasterRGBTile.js +0 -1
  33. package/es/tile/tileFactory/RasterTile.js +13 -8
  34. package/lib/core/BaseLayer.js +17 -6
  35. package/lib/core/TextureService.js +31 -9
  36. package/lib/core/interface.js +9 -1
  37. package/lib/line/models/index.js +0 -3
  38. package/lib/plugins/DataMappingPlugin.js +10 -7
  39. package/lib/point/models/fill.js +8 -98
  40. package/lib/point/models/fillmage.js +16 -67
  41. package/lib/point/models/index.js +0 -6
  42. package/lib/point/models/radar.js +13 -80
  43. package/lib/point/models/text.js +1 -1
  44. package/lib/point/shaders/fill_vert.glsl +9 -26
  45. package/lib/point/shaders/image/fillImage_vert.glsl +8 -14
  46. package/lib/point/shaders/radar/radar_vert.glsl +12 -19
  47. package/lib/point/shaders/text_vert.glsl +1 -1
  48. package/lib/polygon/index.js +0 -2
  49. package/lib/polygon/models/index.js +2 -5
  50. package/lib/raster/models/raster.js +5 -21
  51. package/lib/raster/models/rasterTerrainRgb.js +5 -5
  52. package/lib/raster/shaders/raster_2d_frag.glsl +1 -0
  53. package/lib/tile/tileFactory/RasterTile.js +14 -8
  54. package/package.json +6 -6
  55. package/es/line/models/tile.d.ts +0 -8
  56. package/es/line/models/tile.js +0 -201
  57. package/es/line/shaders/tile/line_tile_map_vert.glsl +0 -25
  58. package/es/line/shaders/tile/line_tile_vert.glsl +0 -52
  59. package/es/line/shaders/tile/simpleline_map_vert.glsl +0 -15
  60. package/es/line/shaders/tile/simpleline_vert.glsl +0 -21
  61. package/es/point/models/tile.d.ts +0 -15
  62. package/es/point/models/tile.js +0 -217
  63. package/es/point/models/tileText.d.ts +0 -52
  64. package/es/point/models/tileText.js +0 -544
  65. package/es/point/shaders/tile/fill_tile_frag.glsl +0 -76
  66. package/es/point/shaders/tile/fill_tile_vert.glsl +0 -78
  67. package/es/point/shaders/tile/text_frag.glsl +0 -33
  68. package/es/point/shaders/tile/text_map_frag.glsl +0 -31
  69. package/es/point/shaders/tile/text_map_vert.glsl +0 -38
  70. package/es/point/shaders/tile/text_vert.glsl +0 -48
  71. package/es/polygon/models/tile.d.ts +0 -12
  72. package/es/polygon/models/tile.js +0 -141
  73. package/es/polygon/shaders/tile/polygon_tile_map_vert.glsl +0 -16
  74. package/es/polygon/shaders/tile/polygon_tile_vert.glsl +0 -42
  75. package/es/raster/models/rasterTile.d.ts +0 -18
  76. package/es/raster/models/rasterTile.js +0 -180
  77. package/es/tile/tileFactory/layers/RasterDataLayer.d.ts +0 -11
  78. package/es/tile/tileFactory/layers/RasterDataLayer.js +0 -89
  79. package/lib/line/models/tile.js +0 -217
  80. package/lib/line/shaders/tile/line_tile_map_vert.glsl +0 -25
  81. package/lib/line/shaders/tile/line_tile_vert.glsl +0 -52
  82. package/lib/line/shaders/tile/simpleline_map_vert.glsl +0 -15
  83. package/lib/line/shaders/tile/simpleline_vert.glsl +0 -21
  84. package/lib/point/models/tile.js +0 -233
  85. package/lib/point/models/tileText.js +0 -560
  86. package/lib/point/shaders/tile/fill_tile_frag.glsl +0 -76
  87. package/lib/point/shaders/tile/fill_tile_vert.glsl +0 -78
  88. package/lib/point/shaders/tile/text_frag.glsl +0 -33
  89. package/lib/point/shaders/tile/text_map_frag.glsl +0 -31
  90. package/lib/point/shaders/tile/text_map_vert.glsl +0 -38
  91. package/lib/point/shaders/tile/text_vert.glsl +0 -48
  92. package/lib/polygon/models/tile.js +0 -156
  93. package/lib/polygon/shaders/tile/polygon_tile_map_vert.glsl +0 -16
  94. package/lib/polygon/shaders/tile/polygon_tile_vert.glsl +0 -42
  95. package/lib/raster/models/rasterTile.js +0 -196
  96. package/lib/tile/tileFactory/layers/RasterDataLayer.js +0 -105
@@ -7,7 +7,6 @@ import TextModel from "../../point/models/text";
7
7
  import ExtrudeModel from "./extrude";
8
8
  import FillModel from "./fill";
9
9
  import Ocean from "./ocean";
10
- import TilePolygonModel from "./tile";
11
10
  import Water from "./water";
12
11
  var PolygonModels = {
13
12
  fill: FillModel,
@@ -19,8 +18,7 @@ var PolygonModels = {
19
18
  point_normal: NormalModel,
20
19
  point_extrude: PointExtrudeModel,
21
20
  water: Water,
22
- ocean: Ocean,
23
- // point_fill: PointModels.fill,
24
- tile: TilePolygonModel
21
+ ocean: Ocean // point_fill: PointModels.fill,
22
+
25
23
  };
26
24
  export default PolygonModels;
@@ -3,7 +3,6 @@ import BaseModel from '../../core/BaseModel';
3
3
  export default class RasterModel extends BaseModel {
4
4
  protected texture: ITexture2D;
5
5
  protected colorTexture: ITexture2D;
6
- private rampColors;
7
6
  getUninforms(): {
8
7
  u_opacity: number;
9
8
  u_texture: ITexture2D;
@@ -18,5 +17,4 @@ export default class RasterModel extends BaseModel {
18
17
  buildModels(): Promise<IModel[]>;
19
18
  clearModels(): void;
20
19
  protected registerBuiltinAttributes(): void;
21
- private updateColorTexture;
22
20
  }
@@ -11,12 +11,12 @@ function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflec
11
11
  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; } }
12
12
 
13
13
  import { AttributeType, gl } from '@antv/l7-core';
14
- import { generateColorRamp, getMask } from '@antv/l7-utils';
14
+ import { getMask, getDefaultDomain } from '@antv/l7-utils';
15
15
  import BaseModel from "../../core/BaseModel";
16
16
  import { RasterImageTriangulation } from "../../core/triangulation";
17
17
 
18
18
  /* babel-plugin-inline-import '../shaders/raster_2d_frag.glsl' */
19
- var rasterFrag = "precision mediump float;\nuniform float u_opacity: 1.0;\nuniform sampler2D u_texture;\nuniform sampler2D u_colorTexture;\nuniform float u_min;\nuniform float u_max;\nuniform vec2 u_domain;\nuniform float u_noDataValue;\nuniform bool u_clampLow: true;\nuniform bool u_clampHigh: true;\nvarying vec2 v_texCoord;\nbool isnan_emu(float x) { return (x > 0.0 || x < 0.0) ? x != x : x != 0.0; }\n\n\nvoid main() {\n\n float value = texture2D(u_texture,vec2(v_texCoord.x,v_texCoord.y)).r;\n if (value == u_noDataValue || isnan_emu(value))\n gl_FragColor = vec4(0.0, 0, 0, 0.0);\n else if ((!u_clampLow && value < u_domain[0]) || (!u_clampHigh && value > u_domain[1]))\n gl_FragColor = vec4(0, 0, 0, 0);\n else {\n float normalisedValue =(value - u_domain[0]) / (u_domain[1] -u_domain[0]);\n vec4 color = texture2D(u_colorTexture,vec2(normalisedValue, 0));\n gl_FragColor = color;\n gl_FragColor.a = gl_FragColor.a * u_opacity ;\n }\n}\n";
19
+ var rasterFrag = "precision mediump float;\nuniform float u_opacity: 1.0;\nuniform sampler2D u_texture;\nuniform sampler2D u_colorTexture;\nuniform float u_min;\nuniform float u_max;\nuniform vec2 u_domain;\nuniform float u_noDataValue;\nuniform bool u_clampLow: true;\nuniform bool u_clampHigh: true;\nvarying vec2 v_texCoord;\nbool isnan_emu(float x) { return (x > 0.0 || x < 0.0) ? x != x : x != 0.0; }\n\n\nvoid main() {\n\n float value = texture2D(u_texture,vec2(v_texCoord.x,v_texCoord.y)).r;\n if (value == u_noDataValue || isnan_emu(value))\n gl_FragColor = vec4(0.0, 0, 0, 0.0);\n else if ((!u_clampLow && value < u_domain[0]) || (!u_clampHigh && value > u_domain[1]))\n gl_FragColor = vec4(0, 0, 0, 0);\n else {\n \n float normalisedValue =(value - u_domain[0]) / (u_domain[1] -u_domain[0]);\n vec4 color = texture2D(u_colorTexture,vec2(normalisedValue, 0));\n gl_FragColor = color;\n gl_FragColor.a = gl_FragColor.a * u_opacity ;\n }\n}\n";
20
20
 
21
21
  /* babel-plugin-inline-import '../shaders/raster_2d_vert.glsl' */
22
22
  var rasterVert = "precision highp float;\nuniform mat4 u_ModelMatrix;\nuniform mat4 u_Mvp;\nattribute vec3 a_Position;\nattribute vec2 a_Uv;\nvarying vec2 v_texCoord;\n#pragma include \"projection\"\nvoid main() {\n v_texCoord = a_Uv;\n vec4 project_pos = project_position(vec4(a_Position, 1.0));\n\n if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) { // gaode2.x\n gl_Position = u_Mvp * (vec4(project_pos.xy,0., 1.0));\n } else {\n gl_Position = project_common_position_to_clipspace(vec4(project_pos.xy,0., 1.0));\n }\n}\n";
@@ -44,15 +44,15 @@ var RasterModel = /*#__PURE__*/function (_BaseModel) {
44
44
  clampHigh = _ref$clampHigh === void 0 ? true : _ref$clampHigh,
45
45
  _ref$noDataValue = _ref.noDataValue,
46
46
  noDataValue = _ref$noDataValue === void 0 ? -9999999 : _ref$noDataValue,
47
- _ref$domain = _ref.domain,
48
- domain = _ref$domain === void 0 ? [0, 1] : _ref$domain,
47
+ domain = _ref.domain,
49
48
  rampColors = _ref.rampColors;
50
49
 
51
- this.colorTexture = this.layer.textureService.getColorTexture(rampColors);
50
+ var newdomain = domain || getDefaultDomain(rampColors);
51
+ this.colorTexture = this.layer.textureService.getColorTexture(rampColors, newdomain);
52
52
  return {
53
53
  u_opacity: opacity || 1,
54
54
  u_texture: this.texture,
55
- u_domain: domain,
55
+ u_domain: newdomain,
56
56
  u_clampLow: clampLow,
57
57
  u_clampHigh: typeof clampHigh !== 'undefined' ? clampHigh : clampLow,
58
58
  u_noDataValue: noDataValue,
@@ -228,22 +228,6 @@ var RasterModel = /*#__PURE__*/function (_BaseModel) {
228
228
  }
229
229
  });
230
230
  }
231
- }, {
232
- key: "updateColorTexture",
233
- value: function updateColorTexture() {
234
- var createTexture2D = this.rendererService.createTexture2D;
235
-
236
- var _ref3 = this.layer.getLayerConfig(),
237
- rampColors = _ref3.rampColors;
238
-
239
- var imageData = generateColorRamp(rampColors);
240
- this.colorTexture = createTexture2D({
241
- data: imageData.data,
242
- width: imageData.width,
243
- height: imageData.height,
244
- flipY: false
245
- });
246
- }
247
231
  }]);
248
232
 
249
233
  return RasterModel;
@@ -11,7 +11,7 @@ function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflec
11
11
  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; } }
12
12
 
13
13
  import { AttributeType, gl } from '@antv/l7-core';
14
- import { getMask } from '@antv/l7-utils';
14
+ import { getMask, getDefaultDomain } from '@antv/l7-utils';
15
15
  import BaseModel from "../../core/BaseModel";
16
16
  import { RasterImageTriangulation } from "../../core/triangulation";
17
17
 
@@ -43,23 +43,23 @@ var RasterTerrainRGB = /*#__PURE__*/function (_BaseModel) {
43
43
  clampHigh = _ref$clampHigh === void 0 ? true : _ref$clampHigh,
44
44
  _ref$noDataValue = _ref.noDataValue,
45
45
  noDataValue = _ref$noDataValue === void 0 ? -9999999 : _ref$noDataValue,
46
- _ref$domain = _ref.domain,
47
- domain = _ref$domain === void 0 ? [0, 1] : _ref$domain,
46
+ domain = _ref.domain,
48
47
  rampColors = _ref.rampColors,
49
48
  colorTexture = _ref.colorTexture;
50
49
 
50
+ var newdomain = domain || getDefaultDomain(rampColors);
51
51
  var texture = colorTexture;
52
52
 
53
53
  if (!colorTexture) {
54
- texture = this.layer.textureService.getColorTexture(rampColors);
54
+ texture = this.layer.textureService.getColorTexture(rampColors, newdomain);
55
55
  } else {
56
- this.layer.textureService.setColorTexture(colorTexture, rampColors);
56
+ this.layer.textureService.setColorTexture(colorTexture, rampColors, newdomain);
57
57
  }
58
58
 
59
59
  return {
60
60
  u_opacity: opacity || 1,
61
61
  u_texture: this.texture,
62
- u_domain: domain,
62
+ u_domain: newdomain,
63
63
  u_clampLow: clampLow,
64
64
  u_clampHigh: typeof clampHigh !== 'undefined' ? clampHigh : clampLow,
65
65
  u_noDataValue: noDataValue,
@@ -20,6 +20,7 @@ void main() {
20
20
  else if ((!u_clampLow && value < u_domain[0]) || (!u_clampHigh && value > u_domain[1]))
21
21
  gl_FragColor = vec4(0, 0, 0, 0);
22
22
  else {
23
+
23
24
  float normalisedValue =(value - u_domain[0]) / (u_domain[1] -u_domain[0]);
24
25
  vec4 color = texture2D(u_colorTexture,vec2(normalisedValue, 0));
25
26
  gl_FragColor = color;
@@ -13,7 +13,6 @@ function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflec
13
13
 
14
14
  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; } }
15
15
 
16
- // import RasterLayer from './layers/RasterDataLayer';
17
16
  import RasterLayer from "../../raster";
18
17
  import Tile from "./Tile";
19
18
 
@@ -15,6 +15,7 @@ function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Re
15
15
 
16
16
  import RasterLayer from "../../raster";
17
17
  import Tile from "./Tile";
18
+ import { getDefaultDomain } from '@antv/l7-utils';
18
19
  var DEFAULT_COLOR_TEXTURE_OPTION = {
19
20
  positions: [0, 1],
20
21
  colors: ['#000', '#fff']
@@ -35,7 +36,8 @@ var RasterTile = /*#__PURE__*/function (_Tile) {
35
36
  key: "initTileLayer",
36
37
  value: function () {
37
38
  var _initTileLayer = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
38
- var attributes, layerOptions, sourceOptions, layer;
39
+ var attributes, layerOptions, sourceOptions, _ref, rampColors, domain, layer;
40
+
39
41
  return _regeneratorRuntime.wrap(function _callee$(_context) {
40
42
  while (1) {
41
43
  switch (_context.prev = _context.next) {
@@ -43,7 +45,8 @@ var RasterTile = /*#__PURE__*/function (_Tile) {
43
45
  attributes = this.parent.getLayerAttributeConfig();
44
46
  layerOptions = this.getLayerOptions();
45
47
  sourceOptions = this.getSourceOption();
46
- this.colorTexture = this.parent.textureService.getColorTexture(layerOptions.rampColors);
48
+ _ref = this.getLayerOptions(), rampColors = _ref.rampColors, domain = _ref.domain;
49
+ this.colorTexture = this.parent.textureService.getColorTexture(rampColors, domain);
47
50
  layer = new RasterLayer(_objectSpread(_objectSpread({}, layerOptions), {}, {
48
51
  colorTexture: this.colorTexture
49
52
  })).source(sourceOptions.data, sourceOptions.options); // 初始化数据映射
@@ -55,13 +58,13 @@ var RasterTile = /*#__PURE__*/function (_Tile) {
55
58
 
56
59
  layer[attr]((_attributes$attr = attributes[attr]) === null || _attributes$attr === void 0 ? void 0 : _attributes$attr.field, (_attributes$attr2 = attributes[attr]) === null || _attributes$attr2 === void 0 ? void 0 : _attributes$attr2.values);
57
60
  });
58
- _context.next = 8;
61
+ _context.next = 9;
59
62
  return this.addLayer(layer);
60
63
 
61
- case 8:
64
+ case 9:
62
65
  this.isLoaded = true;
63
66
 
64
- case 9:
67
+ case 10:
65
68
  case "end":
66
69
  return _context.stop();
67
70
  }
@@ -109,9 +112,11 @@ var RasterTile = /*#__PURE__*/function (_Tile) {
109
112
  arg[_key] = arguments[_key];
110
113
  }
111
114
 
112
- var _arg$rampColors = arg.rampColors,
113
- rampColors = _arg$rampColors === void 0 ? DEFAULT_COLOR_TEXTURE_OPTION : _arg$rampColors;
114
- this.colorTexture = this.parent.textureService.getColorTexture(rampColors);
115
+ var _ref2 = arg,
116
+ _ref2$rampColors = _ref2.rampColors,
117
+ rampColors = _ref2$rampColors === void 0 ? DEFAULT_COLOR_TEXTURE_OPTION : _ref2$rampColors,
118
+ domain = _ref2.domain;
119
+ this.colorTexture = this.parent.textureService.getColorTexture(rampColors, domain || getDefaultDomain(rampColors));
115
120
  this.layers.forEach(function (layer) {
116
121
  return layer.style({
117
122
  colorTexture: _this.colorTexture
@@ -471,8 +471,8 @@ var BaseLayer = (_dec = (0, _l7Core.lazyInject)(_l7Core.TYPES.IGlobalConfigServi
471
471
  }, {
472
472
  key: "filter",
473
473
  value: function filter(field, values, updateOptions) {
474
- this.updateStyleAttribute('filter', field, values, updateOptions);
475
- this.dataState.dataSourceNeedUpdate = true;
474
+ var flag = this.updateStyleAttribute('filter', field, values, updateOptions);
475
+ this.dataState.dataSourceNeedUpdate = flag;
476
476
  return this;
477
477
  }
478
478
  }, {
@@ -482,9 +482,8 @@ var BaseLayer = (_dec = (0, _l7Core.lazyInject)(_l7Core.TYPES.IGlobalConfigServi
482
482
  field: field,
483
483
  values: values
484
484
  };
485
- this.updateStyleAttribute('shape', field, values, updateOptions);
486
- this.dataState.dataSourceNeedUpdate = true; // 通过数据更新驱动shape 更新
487
-
485
+ var flag = this.updateStyleAttribute('shape', field, values, updateOptions);
486
+ this.dataState.dataSourceNeedUpdate = flag;
488
487
  return this;
489
488
  }
490
489
  }, {
@@ -1439,7 +1438,17 @@ var BaseLayer = (_dec = (0, _l7Core.lazyInject)(_l7Core.TYPES.IGlobalConfigServi
1439
1438
  }, {
1440
1439
  key: "updateStyleAttribute",
1441
1440
  value: function updateStyleAttribute(type, field, values, updateOptions) {
1442
- // 存储 Attribute
1441
+ // encode diff
1442
+ var preAttribute = this.configService.getAttributeConfig(this.id) || {}; // @ts-ignore
1443
+
1444
+ if ((0, _lodash.isEqual)(preAttribute[type], {
1445
+ field: field,
1446
+ values: values
1447
+ })) {
1448
+ return false;
1449
+ } // 存储 Attribute
1450
+
1451
+
1443
1452
  if (['color', 'size', 'texture', 'rotate', 'filter', 'label', 'shape'].indexOf(type) !== -1) {
1444
1453
  this.configService.setAttributeConfig(this.id, (0, _defineProperty2.default)({}, type, {
1445
1454
  field: field,
@@ -1466,6 +1475,8 @@ var BaseLayer = (_dec = (0, _l7Core.lazyInject)(_l7Core.TYPES.IGlobalConfigServi
1466
1475
  }, // @ts-ignore
1467
1476
  updateOptions);
1468
1477
  }
1478
+
1479
+ return true;
1469
1480
  }
1470
1481
  }, {
1471
1482
  key: "getLayerAttributeConfig",
@@ -25,14 +25,14 @@ var TextureService = /*#__PURE__*/function () {
25
25
 
26
26
  (0, _createClass2.default)(TextureService, [{
27
27
  key: "getColorTexture",
28
- value: function getColorTexture(colorRamp) {
28
+ value: function getColorTexture(colorRamp, domain) {
29
29
  // TODO 支持传入图片
30
- var currentkey = this.getTextureKey(colorRamp);
30
+ var currentkey = this.getTextureKey(colorRamp, domain);
31
31
 
32
32
  if (this.key === currentkey) {
33
33
  return this.colorTexture;
34
34
  } else {
35
- this.createColorTexture(colorRamp);
35
+ this.createColorTexture(colorRamp, domain);
36
36
  }
37
37
 
38
38
  this.key = currentkey;
@@ -40,9 +40,9 @@ var TextureService = /*#__PURE__*/function () {
40
40
  }
41
41
  }, {
42
42
  key: "createColorTexture",
43
- value: function createColorTexture(colorRamp) {
43
+ value: function createColorTexture(colorRamp, domain) {
44
44
  var createTexture2D = this.rendererService.createTexture2D;
45
- var imageData = (0, _l7Utils.generateColorRamp)(colorRamp);
45
+ var imageData = this.getColorRampBar(colorRamp, domain);
46
46
  var texture = createTexture2D({
47
47
  data: imageData.data,
48
48
  width: imageData.width,
@@ -54,8 +54,8 @@ var TextureService = /*#__PURE__*/function () {
54
54
  }
55
55
  }, {
56
56
  key: "setColorTexture",
57
- value: function setColorTexture(texture, colorRamp) {
58
- this.key = this.getTextureKey(colorRamp);
57
+ value: function setColorTexture(texture, colorRamp, domain) {
58
+ this.key = this.getTextureKey(colorRamp, domain);
59
59
  this.colorTexture = texture;
60
60
  }
61
61
  }, {
@@ -65,10 +65,32 @@ var TextureService = /*#__PURE__*/function () {
65
65
 
66
66
  (_this$colorTexture = this.colorTexture) === null || _this$colorTexture === void 0 ? void 0 : _this$colorTexture.destroy();
67
67
  }
68
+ }, {
69
+ key: "getColorRampBar",
70
+ value: function getColorRampBar(colorRamp, domain) {
71
+ switch (colorRamp.type) {
72
+ case 'cat':
73
+ return (0, _l7Utils.generateCatRamp)(colorRamp);
74
+
75
+ case 'quantize':
76
+ return (0, _l7Utils.generateQuantizeRamp)(colorRamp);
77
+
78
+ case 'custom':
79
+ return (0, _l7Utils.generateCustomRamp)(colorRamp, domain);
80
+
81
+ case 'linear':
82
+ return (0, _l7Utils.generateLinearRamp)(colorRamp, domain);
83
+
84
+ default:
85
+ return (0, _l7Utils.generateColorRamp)(colorRamp);
86
+ }
87
+ }
68
88
  }, {
69
89
  key: "getTextureKey",
70
- value: function getTextureKey(colorRamp) {
71
- return "".concat(colorRamp.colors.join('_'), "_").concat(colorRamp.positions.join('_'));
90
+ value: function getTextureKey(colorRamp, domain) {
91
+ var _colorRamp$positions;
92
+
93
+ return "".concat(colorRamp.colors.join('_'), "_").concat(colorRamp === null || colorRamp === void 0 ? void 0 : (_colorRamp$positions = colorRamp.positions) === null || _colorRamp$positions === void 0 ? void 0 : _colorRamp$positions.join('_'), "_").concat(colorRamp.type, "_").concat(domain === null || domain === void 0 ? void 0 : domain.join('_'));
72
94
  }
73
95
  }]);
74
96
  return TextureService;
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.lineStyleType = exports.TextureBlend = exports.LinearDir = exports.CanvasUpdateType = void 0;
6
+ exports.lineStyleType = exports.TextureBlend = exports.SizeUnitType = exports.LinearDir = exports.CanvasUpdateType = void 0;
7
7
  var lineStyleType;
8
8
  exports.lineStyleType = lineStyleType;
9
9
 
@@ -32,6 +32,14 @@ exports.TextureBlend = TextureBlend;
32
32
  TextureBlend["REPLACE"] = "replace";
33
33
  })(TextureBlend || (exports.TextureBlend = TextureBlend = {}));
34
34
 
35
+ var SizeUnitType;
36
+ exports.SizeUnitType = SizeUnitType;
37
+
38
+ (function (SizeUnitType) {
39
+ SizeUnitType[SizeUnitType["pixel"] = 0] = "pixel";
40
+ SizeUnitType[SizeUnitType["meter"] = 1] = "meter";
41
+ })(SizeUnitType || (exports.SizeUnitType = SizeUnitType = {}));
42
+
35
43
  var CanvasUpdateType;
36
44
  exports.CanvasUpdateType = CanvasUpdateType;
37
45
 
@@ -23,8 +23,6 @@ var _linearline = _interopRequireDefault(require("./linearline"));
23
23
 
24
24
  var _simpleLine = _interopRequireDefault(require("./simpleLine"));
25
25
 
26
- var _tile = _interopRequireDefault(require("./tile"));
27
-
28
26
  var _wall = _interopRequireDefault(require("./wall"));
29
27
 
30
28
  var LineModels = {
@@ -36,7 +34,6 @@ var LineModels = {
36
34
  halfLine: _half.default,
37
35
  simple: _simpleLine.default,
38
36
  linearline: _linearline.default,
39
- tileLine: _tile.default,
40
37
  earthArc3d: _earthArc_3d.default
41
38
  };
42
39
  var _default = LineModels;
@@ -84,14 +84,11 @@ var DataMappingPlugin = (_dec = (0, _inversify.injectable)(), _dec2 = (0, _inver
84
84
 
85
85
  case 2:
86
86
  layer.dataState.dataMappingNeedUpdate = false;
87
-
88
- _this.generateMaping(layer, {
87
+ return _context2.abrupt("return", _this.generateMaping(layer, {
89
88
  styleAttributeService: styleAttributeService
90
- });
91
-
92
- return _context2.abrupt("return", true);
89
+ }));
93
90
 
94
- case 5:
91
+ case 4:
95
92
  case "end":
96
93
  return _context2.stop();
97
94
  }
@@ -163,9 +160,15 @@ var DataMappingPlugin = (_dec = (0, _inversify.injectable)(), _dec2 = (0, _inver
163
160
 
164
161
  filterData = layer.processData(filterData);
165
162
  var encodeData = this.mapping(layer, attributes, filterData, undefined);
166
- layer.setEncodedData(encodeData); // 对外暴露事件
163
+ layer.setEncodedData(encodeData);
164
+
165
+ if (dataArray.length === 0 && layer.encodeDataLength === 0) {
166
+ return false;
167
+ } // 对外暴露事件
168
+
167
169
 
168
170
  layer.emit('dataUpdate', null);
171
+ return true;
169
172
  }
170
173
  }, {
171
174
  key: "mapping",
@@ -9,24 +9,18 @@ exports.default = void 0;
9
9
 
10
10
  var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
11
11
 
12
- var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
13
-
14
12
  var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
15
13
 
16
14
  var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
17
15
 
18
16
  var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
19
17
 
20
- var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
21
-
22
18
  var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
23
19
 
24
20
  var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
25
21
 
26
22
  var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
27
23
 
28
- var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
29
-
30
24
  var _l7Core = require("@antv/l7-core");
31
25
 
32
26
  var _l7Utils = require("@antv/l7-utils");
@@ -35,7 +29,7 @@ var _lodash = require("lodash");
35
29
 
36
30
  var _BaseModel2 = _interopRequireDefault(require("../../core/BaseModel"));
37
31
 
38
- var _l7Maps = require("@antv/l7-maps");
32
+ var _interface = require("../../core/interface");
39
33
 
40
34
  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); }; }
41
35
 
@@ -49,7 +43,7 @@ var waveFillFrag = "\nuniform float u_additive;\n\nvarying mat4 styleMappingMat;
49
43
  var pointFillFrag = "uniform float u_additive;\n\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\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 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";
50
44
 
51
45
  /* babel-plugin-inline-import '../shaders/fill_vert.glsl' */
52
- var pointFillVert = "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_meter2coord;\nuniform float u_meteryScale;\nuniform float u_isMeter;\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;\nuniform float u_raisingHeight: 0.0;\nuniform float u_heightfixed: 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\n\nvoid main() {\n vec3 extrude = a_Extrude;\n float shape_type = a_Shape;\n /*\n * setPickingSize \u8BBE\u7F6E\u62FE\u53D6\u5927\u5C0F\n * u_meter2coord \u5728\u7B49\u9762\u79EF\u5927\u5C0F\u7684\u65F6\u5019\u8BBE\u7F6E\u5355\u4F4D\n */\n float newSize = setPickingSize(a_Size) * u_meter2coord;\n // float newSize = setPickingSize(a_Size) * 0.00001038445708445579;\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 // unpack color(vec2)\n v_color = a_Color;\n\n // radius(16-bit)\n v_radius = newSize;\n\n // anti-alias\n // float antialiased_blur = -max(u_blur, antialiasblur);\n float antialiasblur = -max(2.0 / u_DevicePixelRatio / newSize, 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 if(newSize * pow(2.0, u_Zoom) < 48.0) {\n antialiasblur = max(antialiasblur, -0.05);\n } else if(newSize * pow(2.0, u_Zoom) < 128.0) {\n antialiasblur = max(antialiasblur, -0.6/pow(u_Zoom, 2.0));\n } else {\n antialiasblur = max(antialiasblur, -0.8/pow(u_Zoom, 2.0));\n }\n \n if(u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT || u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT_OFFSET) {\n aPosition.x += offset.x / u_meteryScale;\n aPosition.y += offset.y;\n offset = vec2(0.0);\n }\n }\n\n // TODP: /abs(extrude.x) \u662F\u4E3A\u4E86\u517C\u5BB9\u5730\u7403\u6A21\u5F0F\n v_data = vec4(extrude.x/abs(extrude.x), extrude.y/abs(extrude.y), antialiasblur,shape_type);\n\n\n // vec4 project_pos = project_position(vec4(a_Position.xy, 0.0, 1.0));\n vec4 project_pos = project_position(vec4(aPosition.xy, 0.0, 1.0));\n // gl_Position = project_common_position_to_clipspace(vec4(project_pos.xy + offset, project_pixel(setPickingOrder(0.0)), 1.0));\n\n float raisingHeight = u_raisingHeight;\n\n if(u_heightfixed < 1.0) { // false\n raisingHeight = project_pixel(u_raisingHeight);\n } else {\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 raisingHeight = u_raisingHeight * mapboxZoomScale;\n }\n }\n \n\n if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) { // gaode2.x\n gl_Position = u_Mvp * vec4(project_pos.xy + offset, raisingHeight, 1.0);\n } else {\n gl_Position = project_common_position_to_clipspace(vec4(project_pos.xy + offset, raisingHeight, 1.0));\n }\n \n // gl_Position = project_common_position_to_clipspace(vec4(project_pos.xy + offset, 0.0, 1.0));\n\n setPickingColor(a_PickingColor);\n}\n";
46
+ var pointFillVert = "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 int u_Size_Unit;\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;\nuniform float u_raisingHeight: 0.0;\nuniform float u_heightfixed: 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\n\nvoid main() {\n vec3 extrude = a_Extrude;\n float shape_type = a_Shape;\n /*\n * setPickingSize \u8BBE\u7F6E\u62FE\u53D6\u5927\u5C0F\n * u_meter2coord \u5728\u7B49\u9762\u79EF\u5927\u5C0F\u7684\u65F6\u5019\u8BBE\u7F6E\u5355\u4F4D\n */\n float newSize = setPickingSize(a_Size);\n // float newSize = setPickingSize(a_Size) * 0.00001038445708445579;\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 // unpack color(vec2)\n v_color = a_Color;\nif(u_Size_Unit == 1) {\n newSize = newSize * u_PixelsPerMeter.z;\n }\n\n v_radius = newSize;\n\n // anti-alias\n // float antialiased_blur = -max(u_blur, antialiasblur);\n float antialiasblur = -max(2.0 / u_DevicePixelRatio / newSize, u_blur);\n\n vec2 offset = (extrude.xy * (newSize + u_stroke_width) + textrueOffsets);\n vec3 aPosition = a_Position;\n\n offset = project_pixel(offset);\n \n // TODP: /abs(extrude.x) \u662F\u4E3A\u4E86\u517C\u5BB9\u5730\u7403\u6A21\u5F0F\n v_data = vec4(extrude.x/abs(extrude.x), extrude.y/abs(extrude.y), antialiasblur,shape_type);\n\n\n // vec4 project_pos = project_position(vec4(a_Position.xy, 0.0, 1.0));\n vec4 project_pos = project_position(vec4(aPosition.xy, 0.0, 1.0));\n // gl_Position = project_common_position_to_clipspace(vec4(project_pos.xy + offset, project_pixel(setPickingOrder(0.0)), 1.0));\n\n float raisingHeight = u_raisingHeight;\n\n if(u_heightfixed < 1.0) { // false\n raisingHeight = project_pixel(u_raisingHeight);\n } else {\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 raisingHeight = u_raisingHeight * mapboxZoomScale;\n }\n }\n \n\n if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) { // gaode2.x\n gl_Position = u_Mvp * vec4(project_pos.xy + offset, raisingHeight, 1.0);\n } else {\n gl_Position = project_common_position_to_clipspace(vec4(project_pos.xy + offset, raisingHeight, 1.0));\n }\n \n // gl_Position = project_common_position_to_clipspace(vec4(project_pos.xy + offset, 0.0, 1.0));\n\n setPickingColor(a_PickingColor);\n}\n";
53
47
 
54
48
  var FillModel = /*#__PURE__*/function (_BaseModel) {
55
49
  (0, _inherits2.default)(FillModel, _BaseModel);
@@ -57,20 +51,8 @@ var FillModel = /*#__PURE__*/function (_BaseModel) {
57
51
  var _super = _createSuper(FillModel);
58
52
 
59
53
  function FillModel() {
60
- var _this;
61
-
62
54
  (0, _classCallCheck2.default)(this, FillModel);
63
-
64
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
65
- args[_key] = arguments[_key];
66
- }
67
-
68
- _this = _super.call.apply(_super, [this].concat(args));
69
- (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "meter2coord", 1);
70
- (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "meterYScale", 1);
71
- (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "isMeter", false);
72
- (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "unit", 'l7size');
73
- return _this;
55
+ return _super.apply(this, arguments);
74
56
  }
75
57
 
76
58
  (0, _createClass2.default)(FillModel, [{
@@ -95,9 +77,7 @@ var FillModel = /*#__PURE__*/function (_BaseModel) {
95
77
  _ref$heightfixed = _ref.heightfixed,
96
78
  heightfixed = _ref$heightfixed === void 0 ? false : _ref$heightfixed,
97
79
  _ref$unit = _ref.unit,
98
- unit = _ref$unit === void 0 ? 'l7size' : _ref$unit;
99
-
100
- this.updateUnit(unit);
80
+ unit = _ref$unit === void 0 ? 'pixel' : _ref$unit;
101
81
 
102
82
  if (this.dataTextureTest && this.dataTextureNeedUpdate({
103
83
  opacity: opacity,
@@ -143,9 +123,6 @@ var FillModel = /*#__PURE__*/function (_BaseModel) {
143
123
  return {
144
124
  u_raisingHeight: Number(raisingHeight),
145
125
  u_heightfixed: Number(heightfixed),
146
- u_meter2coord: this.meter2coord,
147
- u_meteryScale: this.meterYScale,
148
- u_isMeter: Number(this.isMeter),
149
126
  u_blur: blur,
150
127
  u_additive: blend === 'additive' ? 1.0 : 0.0,
151
128
  u_dataTexture: this.dataTexture,
@@ -155,6 +132,7 @@ var FillModel = /*#__PURE__*/function (_BaseModel) {
155
132
  u_stroke_opacity: (0, _lodash.isNumber)(strokeOpacity) ? strokeOpacity : 1.0,
156
133
  u_stroke_width: (0, _lodash.isNumber)(strokeWidth) ? strokeWidth : 1.0,
157
134
  u_stroke_color: this.getStrokeColor(stroke),
135
+ u_Size_Unit: _interface.SizeUnitType[unit],
158
136
  u_offsets: this.isOffsetStatic(offsets) ? offsets : [0, 0]
159
137
  };
160
138
  }
@@ -185,14 +163,13 @@ var FillModel = /*#__PURE__*/function (_BaseModel) {
185
163
  while (1) {
186
164
  switch (_context.prev = _context.next) {
187
165
  case 0:
188
- this.updateUnit('l7size');
189
- _context.next = 3;
166
+ _context.next = 2;
190
167
  return this.buildModels();
191
168
 
192
- case 3:
169
+ case 2:
193
170
  return _context.abrupt("return", _context.sent);
194
171
 
195
- case 4:
172
+ case 3:
196
173
  case "end":
197
174
  return _context.stop();
198
175
  }
@@ -206,50 +183,6 @@ var FillModel = /*#__PURE__*/function (_BaseModel) {
206
183
 
207
184
  return initModels;
208
185
  }()
209
- /**
210
- * 计算等面积点图层(unit meter)笛卡尔坐标标度与世界坐标标度的比例
211
- * @returns
212
- */
213
-
214
- }, {
215
- key: "calMeter2Coord",
216
- value: function calMeter2Coord() {
217
- var _this$layer$getSource = (0, _slicedToArray2.default)(this.layer.getSource().extent, 4),
218
- minLng = _this$layer$getSource[0],
219
- minLat = _this$layer$getSource[1],
220
- maxLng = _this$layer$getSource[2],
221
- maxLat = _this$layer$getSource[3];
222
-
223
- var center = [(minLng + maxLng) / 2, (minLat + maxLat) / 2];
224
- var version = this.mapService.version;
225
- var mapboxContext = _l7Utils.$window === null || _l7Utils.$window === void 0 ? void 0 : _l7Utils.$window.mapboxgl;
226
-
227
- if (version === _l7Maps.Version.MAPBOX && mapboxContext !== null && mapboxContext !== void 0 && mapboxContext.MercatorCoordinate) {
228
- // 参考:
229
- // https://docs.mapbox.com/mapbox-gl-js/api/geography/#mercatorcoordinate#meterinmercatorcoordinateunits
230
- var coord = mapboxContext.MercatorCoordinate.fromLngLat({
231
- lng: center[0],
232
- lat: center[1]
233
- }, 0);
234
- var offsetInMercatorCoordinateUnits = coord.meterInMercatorCoordinateUnits();
235
- var westCoord = new mapboxContext.MercatorCoordinate(coord.x - offsetInMercatorCoordinateUnits, coord.y, coord.z);
236
- var westLnglat = westCoord.toLngLat();
237
- var southCoord = new mapboxContext.MercatorCoordinate(coord.x, coord.y - offsetInMercatorCoordinateUnits, coord.z);
238
- var southLnglat = southCoord.toLngLat();
239
- this.meter2coord = center[0] - westLnglat.lng;
240
- this.meterYScale = (southLnglat.lat - center[1]) / this.meter2coord;
241
- return;
242
- }
243
-
244
- var m1 = this.mapService.meterToCoord(center, [minLng, minLat]);
245
- var m2 = this.mapService.meterToCoord(center, [maxLng === minLng ? maxLng + 0.1 : maxLng, maxLat === minLat ? minLat + 0.1 : maxLat]);
246
- this.meter2coord = (m1 + m2) / 2;
247
-
248
- if (!this.meter2coord) {
249
- // Tip: 兼容单个数据导致的 m1、m2 为 NaN
250
- this.meter2coord = 7.70681090738883;
251
- }
252
- }
253
186
  }, {
254
187
  key: "buildModels",
255
188
  value: function () {
@@ -412,29 +345,6 @@ var FillModel = /*#__PURE__*/function (_BaseModel) {
412
345
  }
413
346
  });
414
347
  }
415
- /**
416
- * 判断是否更新点图层的计量单位
417
- * @param unit
418
- */
419
-
420
- }, {
421
- key: "updateUnit",
422
- value: function updateUnit(unit) {
423
- var version = this.mapService.version;
424
-
425
- if (this.unit !== unit) {
426
- // l7size => meter
427
- if (this.unit !== 'meter' && unit === 'meter' && version !== _l7Maps.Version.DEFUALT && version !== _l7Maps.Version.GLOBEL) {
428
- this.isMeter = true;
429
- this.calMeter2Coord(); // meter => l7size
430
- } else if (this.unit === 'meter' && unit !== 'meter') {
431
- this.isMeter = false;
432
- this.meter2coord = 1;
433
- }
434
-
435
- this.unit = unit;
436
- }
437
- }
438
348
  }]);
439
349
  return FillModel;
440
350
  }(_BaseModel2.default);