@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.
- package/es/heatmap/models/heatmap.js +1 -1
- package/es/tile/utils.js +1 -1
- package/lib/Geometry/index.js +114 -77
- package/lib/Geometry/models/billboard.js +232 -181
- package/lib/Geometry/models/index.js +18 -34
- package/lib/Geometry/models/plane.js +407 -278
- package/lib/Geometry/models/sprite.js +291 -189
- package/lib/canvas/index.js +101 -66
- package/lib/canvas/models/canvas.js +207 -140
- package/lib/canvas/models/index.js +12 -30
- package/lib/citybuliding/building.js +98 -63
- package/lib/citybuliding/models/build.js +192 -146
- package/lib/core/BaseLayer.js +1331 -814
- package/lib/core/BaseModel.js +457 -279
- package/lib/core/interface.js +40 -53
- package/lib/core/schema.js +21 -39
- package/lib/core/shape/Path.js +67 -79
- package/lib/core/shape/extrude.js +132 -91
- package/lib/core/triangulation.js +378 -196
- package/lib/earth/index.js +100 -62
- package/lib/earth/models/atmosphere.js +146 -112
- package/lib/earth/models/base.js +210 -150
- package/lib/earth/models/bloomsphere.js +146 -112
- package/lib/earth/utils.js +111 -91
- package/lib/heatmap/index.js +149 -92
- package/lib/heatmap/models/grid.js +118 -91
- package/lib/heatmap/models/grid3d.js +155 -123
- package/lib/heatmap/models/heatmap.js +475 -338
- package/lib/heatmap/models/hexagon.js +121 -92
- package/lib/heatmap/models/index.js +22 -37
- package/lib/heatmap/triangulation.js +31 -47
- package/lib/image/index.js +111 -74
- package/lib/image/models/dataImage.js +232 -174
- package/lib/image/models/image.js +175 -128
- package/lib/image/models/index.js +15 -32
- package/lib/index.js +263 -97
- package/lib/line/index.js +131 -85
- package/lib/line/models/arc.js +352 -237
- package/lib/line/models/arc_3d.js +334 -228
- package/lib/line/models/earthArc_3d.js +336 -228
- package/lib/line/models/great_circle.js +291 -200
- package/lib/line/models/half.js +286 -201
- package/lib/line/models/index.js +42 -50
- package/lib/line/models/line.js +428 -299
- package/lib/line/models/linearline.js +277 -203
- package/lib/line/models/simpleLine.js +239 -175
- package/lib/line/models/tile.js +348 -237
- package/lib/line/models/wall.js +327 -235
- package/lib/mask/index.js +92 -59
- package/lib/mask/models/fill.js +134 -82
- package/lib/mask/models/index.js +12 -30
- package/lib/plugins/DataMappingPlugin.js +342 -224
- package/lib/plugins/DataSourcePlugin.js +102 -87
- package/lib/plugins/FeatureScalePlugin.js +330 -240
- package/lib/plugins/LayerAnimateStylePlugin.js +61 -55
- package/lib/plugins/LayerModelPlugin.js +80 -73
- package/lib/plugins/LayerStylePlugin.js +48 -51
- package/lib/plugins/LightingPlugin.js +80 -68
- package/lib/plugins/MultiPassRendererPlugin.js +91 -65
- package/lib/plugins/PixelPickingPlugin.js +150 -109
- package/lib/plugins/RegisterStyleAttributePlugin.js +110 -110
- package/lib/plugins/ShaderUniformPlugin.js +118 -99
- package/lib/plugins/UpdateModelPlugin.js +40 -47
- package/lib/plugins/UpdateStyleAttributePlugin.js +93 -75
- package/lib/point/index.js +226 -150
- package/lib/point/models/earthExtrude.js +279 -201
- package/lib/point/models/earthFill.js +287 -202
- package/lib/point/models/extrude.js +299 -203
- package/lib/point/models/fill.js +406 -275
- package/lib/point/models/fillmage.js +365 -256
- package/lib/point/models/image.js +241 -168
- package/lib/point/models/index.js +46 -52
- package/lib/point/models/normal.js +183 -134
- package/lib/point/models/radar.js +304 -211
- package/lib/point/models/simplePoint.js +194 -142
- package/lib/point/models/text.js +608 -385
- package/lib/point/models/tile.js +314 -223
- package/lib/point/shape/extrude.js +56 -52
- package/lib/polygon/index.js +154 -102
- package/lib/polygon/models/extrude.js +311 -223
- package/lib/polygon/models/fill.js +215 -153
- package/lib/polygon/models/index.js +46 -52
- package/lib/polygon/models/ocean.js +244 -173
- package/lib/polygon/models/tile.js +144 -100
- package/lib/polygon/models/water.js +222 -153
- package/lib/raster/buffers/triangulation.js +27 -40
- package/lib/raster/index.js +115 -75
- package/lib/raster/models/index.js +16 -33
- package/lib/raster/models/raster.js +178 -135
- package/lib/raster/raster.js +187 -132
- package/lib/tile/interface.js +4 -16
- package/lib/tile/manager/tileConfigManager.js +125 -86
- package/lib/tile/manager/tileLayerManager.js +313 -229
- package/lib/tile/manager/tilePickerManager.js +192 -123
- package/lib/tile/models/tileModel.js +71 -52
- package/lib/tile/tileFactory/base.js +432 -309
- package/lib/tile/tileFactory/index.js +51 -49
- package/lib/tile/tileFactory/line.js +65 -50
- package/lib/tile/tileFactory/point.js +65 -50
- package/lib/tile/tileFactory/polygon.js +65 -50
- package/lib/tile/tileFactory/raster.js +66 -54
- package/lib/tile/tileFactory/rasterData.js +88 -76
- package/lib/tile/tileFactory/rasterDataLayer.js +97 -62
- package/lib/tile/tileFactory/vectorLayer.js +168 -109
- package/lib/tile/tileLayer/baseTileLayer.js +420 -221
- package/lib/tile/tmsTileLayer.js +110 -67
- package/lib/tile/utils.js +110 -92
- package/lib/utils/blend.js +59 -79
- package/lib/utils/collision-index.js +107 -64
- package/lib/utils/dataMappingStyle.js +105 -60
- package/lib/utils/extrude_polyline.js +600 -398
- package/lib/utils/grid-index.js +163 -111
- package/lib/utils/layerData.js +130 -99
- package/lib/utils/multiPassRender.js +49 -41
- package/lib/utils/polylineNormal.js +148 -96
- package/lib/utils/simpleLine.js +100 -85
- package/lib/utils/symbol-layout.js +219 -116
- package/lib/utils/updateShape.js +15 -41
- package/lib/wind/index.js +109 -71
- package/lib/wind/models/index.js +12 -30
- package/lib/wind/models/utils.js +144 -105
- package/lib/wind/models/wind.js +333 -224
- package/lib/wind/models/windRender.js +329 -218
- package/lib/wind/models/windShader.js +23 -181
- package/package.json +6 -6
|
@@ -1,274 +1,383 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
var
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
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/fillmage.ts
|
|
23
|
-
var fillmage_exports = {};
|
|
24
|
-
__export(fillmage_exports, {
|
|
25
|
-
default: () => FillImageModel
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
26
7
|
});
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
var
|
|
30
|
-
|
|
31
|
-
var
|
|
32
|
-
|
|
33
|
-
var
|
|
34
|
-
|
|
35
|
-
var
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
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 _l7Maps = require("@antv/l7-maps");
|
|
29
|
+
|
|
30
|
+
var _l7Utils = require("@antv/l7-utils");
|
|
31
|
+
|
|
32
|
+
var _lodash = require("lodash");
|
|
33
|
+
|
|
34
|
+
var _BaseModel2 = _interopRequireDefault(require("../../core/BaseModel"));
|
|
35
|
+
|
|
36
|
+
var _triangulation = require("../../core/triangulation");
|
|
37
|
+
|
|
38
|
+
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); }; }
|
|
39
|
+
|
|
40
|
+
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; } }
|
|
41
|
+
|
|
42
|
+
/* babel-plugin-inline-import '../shaders/image/fillImage_frag.glsl' */
|
|
43
|
+
// static pointLayer shader - not support animate
|
|
44
|
+
var pointFillFrag = "uniform sampler2D u_texture;\nuniform vec2 u_textSize;\n\nvarying mat4 styleMappingMat; // \u4F20\u9012\u4ECE\u7247\u5143\u4E2D\u4F20\u9012\u7684\u6620\u5C04\u6570\u636E\n\n#pragma include \"sdf_2d\"\n#pragma include \"picking\"\nvarying vec2 v_uv; // \u672C\u8EAB\u7684 uv \u5750\u6807\nvarying vec2 v_Iconuv;\n\nvoid main() {\n\n float opacity = styleMappingMat[0][0];\n\n vec2 pos = v_Iconuv / u_textSize + v_uv / u_textSize * 64.;\n gl_FragColor = texture2D(u_texture, pos);\n gl_FragColor.a *= opacity;\n\n gl_FragColor = filterColor(gl_FragColor);\n}\n";
|
|
45
|
+
|
|
46
|
+
/* babel-plugin-inline-import '../shaders/image/fillImage_vert.glsl' */
|
|
47
|
+
var pointFillVert = "attribute vec4 a_Color;\nattribute vec3 a_Position;\nattribute vec3 a_Extrude;\nattribute float a_Size;\nattribute vec2 a_Uv;\nattribute float a_Rotate;\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 mat2 u_RotateMatrix;\nuniform float u_isMeter;\n\nvarying vec2 v_uv; // \u672C\u8EAB\u7684 uv \u5750\u6807\nvarying vec2 v_Iconuv; // icon \u8D34\u56FE\u7684 uv \u5750\u6807\n\nuniform float u_raisingHeight: 0.0;\nuniform float u_heightfixed: 0.0;\nuniform float u_opacity : 1;\nuniform vec2 u_offsets;\n\n#pragma include \"styleMapping\"\n#pragma include \"styleMappingCalOpacity\"\n\n#pragma include \"projection\"\n#pragma include \"picking\"\n\nvoid main() {\n vec3 extrude = a_Extrude;\n\n v_uv = (a_Extrude.xy + 1.0)/2.0;\n v_uv.y = 1.0 - v_uv.y;\n v_Iconuv = a_Uv;\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 - empty - empty - empty\n 0.0, 0.0, 0.0, 0.0, // empty - empty - empty - empty\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 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 highp float angle_sin = sin(a_Rotate);\n highp float angle_cos = cos(a_Rotate);\n mat2 rotation_matrix = mat2(angle_cos, -1.0 * angle_sin, angle_sin, angle_cos);\n\n // vec2 offset = (u_RotateMatrix * extrude.xy * (a_Size) + textrueOffsets);\n vec2 offset = (rotation_matrix * u_RotateMatrix * extrude.xy * (a_Size) + 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\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 vec4 project_pos = project_position(vec4(aPosition.xy, 0.0, 1.0));\n float raisingHeight = u_raisingHeight;\n if(u_heightfixed < 1.0) { // height fixed\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 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";
|
|
48
|
+
|
|
49
|
+
var FillImageModel = /*#__PURE__*/function (_BaseModel) {
|
|
50
|
+
(0, _inherits2.default)(FillImageModel, _BaseModel);
|
|
51
|
+
|
|
52
|
+
var _super = _createSuper(FillImageModel);
|
|
53
|
+
|
|
54
|
+
function FillImageModel() {
|
|
55
|
+
var _this;
|
|
56
|
+
|
|
57
|
+
(0, _classCallCheck2.default)(this, FillImageModel);
|
|
58
|
+
|
|
59
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
60
|
+
args[_key] = arguments[_key];
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
_this = _super.call.apply(_super, [this].concat(args));
|
|
64
|
+
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "meter2coord", 1);
|
|
65
|
+
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "isMeter", false);
|
|
66
|
+
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "radian", 0);
|
|
67
|
+
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "updateTexture", function () {
|
|
68
|
+
var createTexture2D = _this.rendererService.createTexture2D;
|
|
69
|
+
|
|
70
|
+
if (_this.texture) {
|
|
71
|
+
_this.texture.update({
|
|
72
|
+
data: _this.iconService.getCanvas(),
|
|
73
|
+
mag: 'linear',
|
|
74
|
+
min: 'linear mipmap nearest',
|
|
49
75
|
mipmap: true
|
|
50
|
-
});
|
|
51
|
-
|
|
76
|
+
}); // this.layer.render();
|
|
77
|
+
// TODO: 更新完纹理后在更新的图层的时候需要更新所有的图层
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
_this.layer.renderLayers();
|
|
81
|
+
|
|
52
82
|
return;
|
|
53
83
|
}
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
84
|
+
|
|
85
|
+
_this.texture = createTexture2D({
|
|
86
|
+
data: _this.iconService.getCanvas(),
|
|
87
|
+
mag: _l7Core.gl.LINEAR,
|
|
88
|
+
min: _l7Core.gl.LINEAR_MIPMAP_LINEAR,
|
|
58
89
|
premultiplyAlpha: false,
|
|
59
90
|
width: 1024,
|
|
60
|
-
height:
|
|
91
|
+
height: _this.iconService.canvasHeight || 128,
|
|
61
92
|
mipmap: true
|
|
62
93
|
});
|
|
63
|
-
};
|
|
64
|
-
|
|
65
|
-
getUninforms() {
|
|
66
|
-
const {
|
|
67
|
-
opacity = 1,
|
|
68
|
-
offsets = [0, 0],
|
|
69
|
-
rotation,
|
|
70
|
-
raisingHeight = 0,
|
|
71
|
-
heightfixed = false
|
|
72
|
-
} = this.layer.getLayerConfig();
|
|
73
|
-
if (this.rendererService.getDirty()) {
|
|
74
|
-
this.texture.bind();
|
|
75
|
-
}
|
|
76
|
-
let rotateFlag = 1;
|
|
77
|
-
if (this.mapService.version === "GAODE2.x" || this.mapService.version === "GAODE1.x") {
|
|
78
|
-
rotateFlag = -1;
|
|
79
|
-
}
|
|
80
|
-
this.radian = rotation !== void 0 ? rotateFlag * Math.PI * rotation / 180 : rotateFlag * Math.PI * (this.mapService.getRotation() % 360) / 180;
|
|
81
|
-
if (this.dataTextureTest && this.dataTextureNeedUpdate({
|
|
82
|
-
opacity,
|
|
83
|
-
offsets
|
|
84
|
-
})) {
|
|
85
|
-
this.judgeStyleAttributes({
|
|
86
|
-
opacity,
|
|
87
|
-
offsets
|
|
88
|
-
});
|
|
89
|
-
const encodeData = this.layer.getEncodedData();
|
|
90
|
-
const { data, width, height } = this.calDataFrame(this.cellLength, encodeData, this.cellProperties);
|
|
91
|
-
this.rowCount = height;
|
|
92
|
-
this.dataTexture = this.cellLength > 0 && data.length > 0 ? this.createTexture2D({
|
|
93
|
-
flipY: true,
|
|
94
|
-
data,
|
|
95
|
-
format: import_l7_core.gl.LUMINANCE,
|
|
96
|
-
type: import_l7_core.gl.FLOAT,
|
|
97
|
-
width,
|
|
98
|
-
height
|
|
99
|
-
}) : this.createTexture2D({
|
|
100
|
-
flipY: true,
|
|
101
|
-
data: [1],
|
|
102
|
-
format: import_l7_core.gl.LUMINANCE,
|
|
103
|
-
type: import_l7_core.gl.FLOAT,
|
|
104
|
-
width: 1,
|
|
105
|
-
height: 1
|
|
106
|
-
});
|
|
107
|
-
}
|
|
108
|
-
return {
|
|
109
|
-
u_raisingHeight: Number(raisingHeight),
|
|
110
|
-
u_heightfixed: Number(heightfixed),
|
|
111
|
-
u_isMeter: Number(this.isMeter),
|
|
112
|
-
u_RotateMatrix: new Float32Array([
|
|
113
|
-
Math.cos(this.radian),
|
|
114
|
-
Math.sin(this.radian),
|
|
115
|
-
-Math.sin(this.radian),
|
|
116
|
-
Math.cos(this.radian)
|
|
117
|
-
]),
|
|
118
|
-
u_dataTexture: this.dataTexture,
|
|
119
|
-
u_cellTypeLayout: this.getCellTypeLayout(),
|
|
120
|
-
u_texture: this.texture,
|
|
121
|
-
u_textSize: [1024, this.iconService.canvasHeight || 128],
|
|
122
|
-
u_opacity: (0, import_lodash.isNumber)(opacity) ? opacity : 1,
|
|
123
|
-
u_offsets: this.isOffsetStatic(offsets) ? offsets : [0, 0]
|
|
124
|
-
};
|
|
125
|
-
}
|
|
126
|
-
getAttribute() {
|
|
127
|
-
return this.styleAttributeService.createAttributesAndIndices(this.layer.getEncodedData(), import_triangulation.PointFillTriangulation);
|
|
94
|
+
});
|
|
95
|
+
return _this;
|
|
128
96
|
}
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
97
|
+
|
|
98
|
+
(0, _createClass2.default)(FillImageModel, [{
|
|
99
|
+
key: "getUninforms",
|
|
100
|
+
value: // 旋转的弧度
|
|
101
|
+
function getUninforms() {
|
|
102
|
+
var _ref = this.layer.getLayerConfig(),
|
|
103
|
+
_ref$opacity = _ref.opacity,
|
|
104
|
+
opacity = _ref$opacity === void 0 ? 1 : _ref$opacity,
|
|
105
|
+
_ref$offsets = _ref.offsets,
|
|
106
|
+
offsets = _ref$offsets === void 0 ? [0, 0] : _ref$offsets,
|
|
107
|
+
rotation = _ref.rotation,
|
|
108
|
+
_ref$raisingHeight = _ref.raisingHeight,
|
|
109
|
+
raisingHeight = _ref$raisingHeight === void 0 ? 0.0 : _ref$raisingHeight,
|
|
110
|
+
_ref$heightfixed = _ref.heightfixed,
|
|
111
|
+
heightfixed = _ref$heightfixed === void 0 ? false : _ref$heightfixed;
|
|
112
|
+
|
|
113
|
+
if (this.rendererService.getDirty()) {
|
|
114
|
+
this.texture.bind();
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* rotateFlag
|
|
118
|
+
* L7MAP 1
|
|
119
|
+
* MAPBOX 1
|
|
120
|
+
* GAODE2.x -1
|
|
121
|
+
* GAODE1.x -1
|
|
122
|
+
*/
|
|
123
|
+
|
|
124
|
+
|
|
125
|
+
var rotateFlag = 1;
|
|
126
|
+
|
|
127
|
+
if (this.mapService.version === 'GAODE2.x' || this.mapService.version === 'GAODE1.x') {
|
|
128
|
+
rotateFlag = -1;
|
|
129
|
+
} // 控制图标的旋转角度(绕 Z 轴旋转)
|
|
130
|
+
|
|
131
|
+
|
|
132
|
+
this.radian = rotation !== undefined ? rotateFlag * Math.PI * rotation / 180 : rotateFlag * Math.PI * (this.mapService.getRotation() % 360) / 180;
|
|
133
|
+
|
|
134
|
+
if (this.dataTextureTest && this.dataTextureNeedUpdate({
|
|
135
|
+
opacity: opacity,
|
|
136
|
+
offsets: offsets
|
|
137
|
+
})) {
|
|
138
|
+
// 判断当前的样式中哪些是需要进行数据映射的,哪些是常量,同时计算用于构建数据纹理的一些中间变量
|
|
139
|
+
this.judgeStyleAttributes({
|
|
140
|
+
opacity: opacity,
|
|
141
|
+
offsets: offsets
|
|
142
|
+
});
|
|
143
|
+
var encodeData = this.layer.getEncodedData();
|
|
144
|
+
|
|
145
|
+
var _this$calDataFrame = this.calDataFrame(this.cellLength, encodeData, this.cellProperties),
|
|
146
|
+
data = _this$calDataFrame.data,
|
|
147
|
+
width = _this$calDataFrame.width,
|
|
148
|
+
height = _this$calDataFrame.height;
|
|
149
|
+
|
|
150
|
+
this.rowCount = height; // 当前数据纹理有多少行
|
|
151
|
+
|
|
152
|
+
this.dataTexture = this.cellLength > 0 && data.length > 0 ? this.createTexture2D({
|
|
153
|
+
flipY: true,
|
|
154
|
+
data: data,
|
|
155
|
+
format: _l7Core.gl.LUMINANCE,
|
|
156
|
+
type: _l7Core.gl.FLOAT,
|
|
157
|
+
width: width,
|
|
158
|
+
height: height
|
|
159
|
+
}) : this.createTexture2D({
|
|
160
|
+
flipY: true,
|
|
161
|
+
data: [1],
|
|
162
|
+
format: _l7Core.gl.LUMINANCE,
|
|
163
|
+
type: _l7Core.gl.FLOAT,
|
|
164
|
+
width: 1,
|
|
165
|
+
height: 1
|
|
166
|
+
});
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
return {
|
|
170
|
+
u_raisingHeight: Number(raisingHeight),
|
|
171
|
+
u_heightfixed: Number(heightfixed),
|
|
172
|
+
u_isMeter: Number(this.isMeter),
|
|
173
|
+
u_RotateMatrix: new Float32Array([Math.cos(this.radian), Math.sin(this.radian), -Math.sin(this.radian), Math.cos(this.radian)]),
|
|
174
|
+
u_dataTexture: this.dataTexture,
|
|
175
|
+
// 数据纹理 - 有数据映射的时候纹理中带数据,若没有任何数据映射时纹理是 [1]
|
|
176
|
+
u_cellTypeLayout: this.getCellTypeLayout(),
|
|
177
|
+
u_texture: this.texture,
|
|
178
|
+
u_textSize: [1024, this.iconService.canvasHeight || 128],
|
|
179
|
+
u_opacity: (0, _lodash.isNumber)(opacity) ? opacity : 1.0,
|
|
180
|
+
u_offsets: this.isOffsetStatic(offsets) ? offsets : [0, 0]
|
|
181
|
+
};
|
|
139
182
|
}
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
const center = [(minLng + maxLng) / 2, (minLat + maxLat) / 2];
|
|
145
|
-
const { version } = this.mapService;
|
|
146
|
-
if (version === import_l7_maps.Version.MAPBOX && window.mapboxgl.MercatorCoordinate) {
|
|
147
|
-
const coord = window.mapboxgl.MercatorCoordinate.fromLngLat({ lng: center[0], lat: center[1] }, 0);
|
|
148
|
-
const offsetInMeters = 1;
|
|
149
|
-
const offsetInMercatorCoordinateUnits = offsetInMeters * coord.meterInMercatorCoordinateUnits();
|
|
150
|
-
const westCoord = new window.mapboxgl.MercatorCoordinate(coord.x - offsetInMercatorCoordinateUnits, coord.y, coord.z);
|
|
151
|
-
const westLnglat = westCoord.toLngLat();
|
|
152
|
-
this.meter2coord = center[0] - westLnglat.lng;
|
|
153
|
-
return;
|
|
183
|
+
}, {
|
|
184
|
+
key: "getAttribute",
|
|
185
|
+
value: function getAttribute() {
|
|
186
|
+
return this.styleAttributeService.createAttributesAndIndices(this.layer.getEncodedData(), _triangulation.PointFillTriangulation);
|
|
154
187
|
}
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
188
|
+
}, {
|
|
189
|
+
key: "initModels",
|
|
190
|
+
value: function initModels(callbackModel) {
|
|
191
|
+
this.updateTexture();
|
|
192
|
+
this.iconService.on('imageUpdate', this.updateTexture);
|
|
193
|
+
|
|
194
|
+
var _ref2 = this.layer.getLayerConfig(),
|
|
195
|
+
_ref2$unit = _ref2.unit,
|
|
196
|
+
unit = _ref2$unit === void 0 ? 'l7size' : _ref2$unit;
|
|
197
|
+
|
|
198
|
+
var version = this.mapService.version;
|
|
199
|
+
|
|
200
|
+
if (unit === 'meter' && version !== _l7Maps.Version.L7MAP && version !== _l7Maps.Version.GLOBEL) {
|
|
201
|
+
this.isMeter = true;
|
|
202
|
+
this.calMeter2Coord();
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
this.buildModels(callbackModel);
|
|
163
206
|
}
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
207
|
+
/**
|
|
208
|
+
* 计算等面积点图层(unit meter)笛卡尔坐标标度与世界坐标标度的比例
|
|
209
|
+
* @returns
|
|
210
|
+
*/
|
|
211
|
+
|
|
212
|
+
}, {
|
|
213
|
+
key: "calMeter2Coord",
|
|
214
|
+
value: function calMeter2Coord() {
|
|
215
|
+
var _this$layer$getSource = (0, _slicedToArray2.default)(this.layer.getSource().extent, 4),
|
|
216
|
+
minLng = _this$layer$getSource[0],
|
|
217
|
+
minLat = _this$layer$getSource[1],
|
|
218
|
+
maxLng = _this$layer$getSource[2],
|
|
219
|
+
maxLat = _this$layer$getSource[3];
|
|
220
|
+
|
|
221
|
+
var center = [(minLng + maxLng) / 2, (minLat + maxLat) / 2];
|
|
222
|
+
var version = this.mapService.version;
|
|
223
|
+
|
|
224
|
+
if (version === _l7Maps.Version.MAPBOX && window.mapboxgl.MercatorCoordinate) {
|
|
225
|
+
var coord = window.mapboxgl.MercatorCoordinate.fromLngLat({
|
|
226
|
+
lng: center[0],
|
|
227
|
+
lat: center[1]
|
|
228
|
+
}, 0);
|
|
229
|
+
var offsetInMeters = 1;
|
|
230
|
+
var offsetInMercatorCoordinateUnits = offsetInMeters * coord.meterInMercatorCoordinateUnits();
|
|
231
|
+
var westCoord = new window.mapboxgl.MercatorCoordinate(coord.x - offsetInMercatorCoordinateUnits, coord.y, coord.z);
|
|
232
|
+
var westLnglat = westCoord.toLngLat();
|
|
233
|
+
this.meter2coord = center[0] - westLnglat.lng;
|
|
234
|
+
return;
|
|
235
|
+
} // @ts-ignore
|
|
236
|
+
|
|
237
|
+
|
|
238
|
+
var m1 = this.mapService.meterToCoord(center, [minLng, minLat]); // @ts-ignore
|
|
239
|
+
|
|
240
|
+
var m2 = this.mapService.meterToCoord(center, [maxLng === minLng ? maxLng + 0.1 : maxLng, maxLat === minLat ? minLat + 0.1 : maxLat]);
|
|
241
|
+
this.meter2coord = (m1 + m2) / 2;
|
|
242
|
+
|
|
243
|
+
if (!this.meter2coord) {
|
|
244
|
+
// Tip: 兼容单个数据导致的 m1、m2 为 NaN
|
|
245
|
+
this.meter2coord = 7.70681090738883;
|
|
181
246
|
}
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
descriptor: {
|
|
200
|
-
name: "a_Rotate",
|
|
201
|
-
buffer: {
|
|
202
|
-
usage: import_l7_core.gl.DYNAMIC_DRAW,
|
|
203
|
-
data: [],
|
|
204
|
-
type: import_l7_core.gl.FLOAT
|
|
247
|
+
}
|
|
248
|
+
}, {
|
|
249
|
+
key: "buildModels",
|
|
250
|
+
value: function buildModels(callbackModel) {
|
|
251
|
+
var _ref3 = this.layer.getLayerConfig(),
|
|
252
|
+
_ref3$mask = _ref3.mask,
|
|
253
|
+
mask = _ref3$mask === void 0 ? false : _ref3$mask,
|
|
254
|
+
_ref3$maskInside = _ref3.maskInside,
|
|
255
|
+
maskInside = _ref3$maskInside === void 0 ? true : _ref3$maskInside;
|
|
256
|
+
|
|
257
|
+
this.layer.buildLayerModel({
|
|
258
|
+
moduleName: 'pointFillImage',
|
|
259
|
+
vertexShader: pointFillVert,
|
|
260
|
+
fragmentShader: pointFillFrag,
|
|
261
|
+
triangulation: _triangulation.PointFillTriangulation,
|
|
262
|
+
depth: {
|
|
263
|
+
enable: false
|
|
205
264
|
},
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
265
|
+
blend: this.getBlend(),
|
|
266
|
+
stencil: (0, _l7Utils.getMask)(mask, maskInside),
|
|
267
|
+
cull: {
|
|
268
|
+
enable: true,
|
|
269
|
+
face: (0, _l7Utils.getCullFace)(this.mapService.version)
|
|
210
270
|
}
|
|
211
|
-
}
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
271
|
+
}).then(function (model) {
|
|
272
|
+
callbackModel([model]);
|
|
273
|
+
}).catch(function (err) {
|
|
274
|
+
console.warn(err);
|
|
275
|
+
callbackModel([]);
|
|
276
|
+
});
|
|
277
|
+
}
|
|
278
|
+
}, {
|
|
279
|
+
key: "clearModels",
|
|
280
|
+
value: function clearModels() {
|
|
281
|
+
var _this$texture, _this$dataTexture;
|
|
282
|
+
|
|
283
|
+
this.iconService.off('imageUpdate', this.updateTexture);
|
|
284
|
+
(_this$texture = this.texture) === null || _this$texture === void 0 ? void 0 : _this$texture.destroy();
|
|
285
|
+
(_this$dataTexture = this.dataTexture) === null || _this$dataTexture === void 0 ? void 0 : _this$dataTexture.destroy();
|
|
286
|
+
} // overwrite baseModel func
|
|
287
|
+
|
|
288
|
+
}, {
|
|
289
|
+
key: "registerBuiltinAttributes",
|
|
290
|
+
value: function registerBuiltinAttributes() {
|
|
291
|
+
var _this2 = this;
|
|
292
|
+
|
|
293
|
+
this.styleAttributeService.registerStyleAttribute({
|
|
294
|
+
name: 'rotate',
|
|
295
|
+
type: _l7Core.AttributeType.Attribute,
|
|
296
|
+
descriptor: {
|
|
297
|
+
name: 'a_Rotate',
|
|
298
|
+
buffer: {
|
|
299
|
+
usage: _l7Core.gl.DYNAMIC_DRAW,
|
|
300
|
+
data: [],
|
|
301
|
+
type: _l7Core.gl.FLOAT
|
|
302
|
+
},
|
|
303
|
+
size: 1,
|
|
304
|
+
update: function update(feature, featureIdx, vertex, attributeIdx) {
|
|
305
|
+
var _feature$rotate = feature.rotate,
|
|
306
|
+
rotate = _feature$rotate === void 0 ? 0 : _feature$rotate;
|
|
307
|
+
return Array.isArray(rotate) ? [rotate[0]] : [rotate];
|
|
308
|
+
}
|
|
229
309
|
}
|
|
230
|
-
}
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
310
|
+
});
|
|
311
|
+
this.styleAttributeService.registerStyleAttribute({
|
|
312
|
+
name: 'uv',
|
|
313
|
+
type: _l7Core.AttributeType.Attribute,
|
|
314
|
+
descriptor: {
|
|
315
|
+
name: 'a_Uv',
|
|
316
|
+
buffer: {
|
|
317
|
+
// give the WebGL driver a hint that this buffer may change
|
|
318
|
+
usage: _l7Core.gl.DYNAMIC_DRAW,
|
|
319
|
+
data: [],
|
|
320
|
+
type: _l7Core.gl.FLOAT
|
|
321
|
+
},
|
|
322
|
+
size: 2,
|
|
323
|
+
update: function update(feature, featureIdx, vertex, attributeIdx) {
|
|
324
|
+
var iconMap = _this2.iconService.getIconMap();
|
|
325
|
+
|
|
326
|
+
var shape = feature.shape;
|
|
327
|
+
|
|
328
|
+
var _ref4 = iconMap[shape] || {
|
|
329
|
+
x: 0,
|
|
330
|
+
y: 0
|
|
331
|
+
},
|
|
332
|
+
x = _ref4.x,
|
|
333
|
+
y = _ref4.y;
|
|
334
|
+
|
|
335
|
+
return [x, y];
|
|
336
|
+
}
|
|
251
337
|
}
|
|
252
|
-
}
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
338
|
+
});
|
|
339
|
+
this.styleAttributeService.registerStyleAttribute({
|
|
340
|
+
name: 'extrude',
|
|
341
|
+
type: _l7Core.AttributeType.Attribute,
|
|
342
|
+
descriptor: {
|
|
343
|
+
name: 'a_Extrude',
|
|
344
|
+
buffer: {
|
|
345
|
+
// give the WebGL driver a hint that this buffer may change
|
|
346
|
+
usage: _l7Core.gl.DYNAMIC_DRAW,
|
|
347
|
+
data: [],
|
|
348
|
+
type: _l7Core.gl.FLOAT
|
|
349
|
+
},
|
|
350
|
+
size: 3,
|
|
351
|
+
update: function update(feature, featureIdx, vertex, attributeIdx) {
|
|
352
|
+
var extrude = [1, 1, 0, -1, 1, 0, -1, -1, 0, 1, -1, 0];
|
|
353
|
+
var extrudeIndex = attributeIdx % 4 * 3;
|
|
354
|
+
return [extrude[extrudeIndex], extrude[extrudeIndex + 1], extrude[extrudeIndex + 2]];
|
|
355
|
+
}
|
|
268
356
|
}
|
|
269
|
-
}
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
357
|
+
}); // point layer size;
|
|
358
|
+
|
|
359
|
+
this.styleAttributeService.registerStyleAttribute({
|
|
360
|
+
name: 'size',
|
|
361
|
+
type: _l7Core.AttributeType.Attribute,
|
|
362
|
+
descriptor: {
|
|
363
|
+
name: 'a_Size',
|
|
364
|
+
buffer: {
|
|
365
|
+
// give the WebGL driver a hint that this buffer may change
|
|
366
|
+
usage: _l7Core.gl.DYNAMIC_DRAW,
|
|
367
|
+
data: [],
|
|
368
|
+
type: _l7Core.gl.FLOAT
|
|
369
|
+
},
|
|
370
|
+
size: 1,
|
|
371
|
+
update: function update(feature, featureIdx, vertex, attributeIdx) {
|
|
372
|
+
var _feature$size = feature.size,
|
|
373
|
+
size = _feature$size === void 0 ? 5 : _feature$size;
|
|
374
|
+
return Array.isArray(size) ? [size[0] * _this2.meter2coord] : [size * _this2.meter2coord];
|
|
375
|
+
}
|
|
376
|
+
}
|
|
377
|
+
});
|
|
378
|
+
}
|
|
379
|
+
}]);
|
|
380
|
+
return FillImageModel;
|
|
381
|
+
}(_BaseModel2.default);
|
|
382
|
+
|
|
383
|
+
exports.default = FillImageModel;
|