@antv/l7-layers 2.9.18 → 2.9.19
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/Geometry/index.js +12 -2
- package/es/Geometry/index.js.map +1 -1
- package/es/Geometry/models/billboard.d.ts +3 -3
- package/es/Geometry/models/billboard.js +11 -6
- package/es/Geometry/models/billboard.js.map +1 -1
- package/es/Geometry/models/plane.d.ts +3 -3
- package/es/Geometry/models/plane.js +12 -7
- package/es/Geometry/models/plane.js.map +1 -1
- package/es/Geometry/models/sprite.d.ts +3 -3
- package/es/Geometry/models/sprite.js +11 -6
- package/es/Geometry/models/sprite.js.map +1 -1
- package/es/canvas/index.js +12 -2
- package/es/canvas/index.js.map +1 -1
- package/es/citybuliding/building.js +12 -2
- package/es/citybuliding/building.js.map +1 -1
- package/es/citybuliding/models/build.d.ts +2 -1
- package/es/citybuliding/models/build.js +16 -3
- package/es/citybuliding/models/build.js.map +1 -1
- package/es/core/BaseLayer.d.ts +1 -1
- package/es/core/BaseLayer.js +105 -62
- package/es/core/BaseLayer.js.map +1 -1
- package/es/core/BaseModel.d.ts +2 -2
- package/es/core/BaseModel.js +2 -2
- package/es/core/BaseModel.js.map +1 -1
- package/es/core/interface.d.ts +2 -0
- package/es/core/interface.js.map +1 -1
- package/es/core/triangulation.js +1 -2
- package/es/core/triangulation.js.map +1 -1
- package/es/earth/index.js +8 -2
- package/es/earth/index.js.map +1 -1
- package/es/earth/models/atmosphere.d.ts +2 -2
- package/es/earth/models/atmosphere.js +11 -6
- package/es/earth/models/atmosphere.js.map +1 -1
- package/es/earth/models/base.d.ts +2 -2
- package/es/earth/models/base.js +11 -6
- package/es/earth/models/base.js.map +1 -1
- package/es/earth/models/bloomsphere.d.ts +2 -2
- package/es/earth/models/bloomsphere.js +11 -6
- package/es/earth/models/bloomsphere.js.map +1 -1
- package/es/heatmap/index.js +17 -5
- package/es/heatmap/index.js.map +1 -1
- package/es/heatmap/models/grid.d.ts +2 -2
- package/es/heatmap/models/grid.js +12 -8
- package/es/heatmap/models/grid.js.map +1 -1
- package/es/heatmap/models/grid3d.d.ts +2 -2
- package/es/heatmap/models/grid3d.js +12 -6
- package/es/heatmap/models/grid3d.js.map +1 -1
- package/es/heatmap/models/heatmap.d.ts +2 -2
- package/es/heatmap/models/heatmap.js +112 -62
- package/es/heatmap/models/heatmap.js.map +1 -1
- package/es/heatmap/models/hexagon.d.ts +2 -2
- package/es/heatmap/models/hexagon.js +11 -6
- package/es/heatmap/models/hexagon.js.map +1 -1
- package/es/image/index.js +12 -2
- package/es/image/index.js.map +1 -1
- package/es/image/models/dataImage.d.ts +3 -3
- package/es/image/models/dataImage.js +10 -5
- package/es/image/models/dataImage.js.map +1 -1
- package/es/image/models/image.d.ts +3 -3
- package/es/image/models/image.js +11 -7
- package/es/image/models/image.js.map +1 -1
- package/es/line/index.d.ts +0 -2
- package/es/line/index.js +12 -5
- package/es/line/index.js.map +1 -1
- package/es/line/models/arc.d.ts +2 -2
- package/es/line/models/arc.js +14 -9
- package/es/line/models/arc.js.map +1 -1
- package/es/line/models/arc_3d.d.ts +2 -2
- package/es/line/models/arc_3d.js +13 -8
- package/es/line/models/arc_3d.js.map +1 -1
- package/es/line/models/earthArc_3d.d.ts +2 -2
- package/es/line/models/earthArc_3d.js +17 -9
- package/es/line/models/earthArc_3d.js.map +1 -1
- package/es/line/models/great_circle.d.ts +2 -2
- package/es/line/models/great_circle.js +11 -6
- package/es/line/models/great_circle.js.map +1 -1
- package/es/line/models/half.d.ts +2 -2
- package/es/line/models/half.js +46 -29
- package/es/line/models/half.js.map +1 -1
- package/es/line/models/index.d.ts +1 -1
- package/es/line/models/index.js +0 -2
- package/es/line/models/index.js.map +1 -1
- package/es/line/models/line.d.ts +2 -2
- package/es/line/models/line.js +27 -15
- package/es/line/models/line.js.map +1 -1
- package/es/line/models/linearline.d.ts +2 -11
- package/es/line/models/linearline.js +14 -24
- package/es/line/models/linearline.js.map +1 -1
- package/es/line/models/simpleLine.d.ts +2 -2
- package/es/line/models/simpleLine.js +13 -8
- package/es/line/models/simpleLine.js.map +1 -1
- package/es/line/models/tile.d.ts +2 -11
- package/es/line/models/tile.js +45 -39
- package/es/line/models/tile.js.map +1 -1
- package/es/line/models/wall.d.ts +2 -2
- package/es/line/models/wall.js +13 -9
- package/es/line/models/wall.js.map +1 -1
- package/es/mask/index.js +12 -2
- package/es/mask/index.js.map +1 -1
- package/es/mask/models/fill.d.ts +2 -2
- package/es/mask/models/fill.js +53 -27
- package/es/mask/models/fill.js.map +1 -1
- package/es/plugins/DataMappingPlugin.js +29 -8
- package/es/plugins/DataMappingPlugin.js.map +1 -1
- package/es/plugins/DataSourcePlugin.js +14 -5
- package/es/plugins/DataSourcePlugin.js.map +1 -1
- package/es/plugins/LayerModelPlugin.d.ts +2 -0
- package/es/plugins/LayerModelPlugin.js +35 -7
- package/es/plugins/LayerModelPlugin.js.map +1 -1
- package/es/plugins/PixelPickingPlugin.js +16 -13
- package/es/plugins/PixelPickingPlugin.js.map +1 -1
- package/es/point/index.d.ts +1 -1
- package/es/point/index.js +26 -15
- package/es/point/index.js.map +1 -1
- package/es/point/models/earthExtrude.d.ts +2 -2
- package/es/point/models/earthExtrude.js +16 -14
- package/es/point/models/earthExtrude.js.map +1 -1
- package/es/point/models/earthFill.d.ts +2 -11
- package/es/point/models/earthFill.js +13 -22
- package/es/point/models/earthFill.js.map +1 -1
- package/es/point/models/extrude.d.ts +2 -2
- package/es/point/models/extrude.js +49 -27
- package/es/point/models/extrude.js.map +1 -1
- package/es/point/models/fill.d.ts +2 -2
- package/es/point/models/fill.js +59 -41
- package/es/point/models/fill.js.map +1 -1
- package/es/point/models/fillmage.d.ts +2 -7
- package/es/point/models/fillmage.js +13 -22
- package/es/point/models/fillmage.js.map +1 -1
- package/es/point/models/image.d.ts +2 -2
- package/es/point/models/image.js +11 -6
- package/es/point/models/image.js.map +1 -1
- package/es/point/models/index.d.ts +1 -1
- package/es/point/models/index.js +0 -2
- package/es/point/models/index.js.map +1 -1
- package/es/point/models/normal.d.ts +2 -2
- package/es/point/models/normal.js +11 -6
- package/es/point/models/normal.js.map +1 -1
- package/es/point/models/radar.d.ts +2 -11
- package/es/point/models/radar.js +13 -22
- package/es/point/models/radar.js.map +1 -1
- package/es/point/models/simplePoint.d.ts +2 -2
- package/es/point/models/simplePoint.js +11 -6
- package/es/point/models/simplePoint.js.map +1 -1
- package/es/point/models/text.d.ts +3 -2
- package/es/point/models/text.js +110 -75
- package/es/point/models/text.js.map +1 -1
- package/es/point/models/tile.d.ts +2 -11
- package/es/point/models/tile.js +22 -25
- package/es/point/models/tile.js.map +1 -1
- package/es/polygon/index.js +12 -2
- package/es/polygon/index.js.map +1 -1
- package/es/polygon/models/extrude.d.ts +2 -2
- package/es/polygon/models/extrude.js +10 -5
- package/es/polygon/models/extrude.js.map +1 -1
- package/es/polygon/models/fill.d.ts +2 -2
- package/es/polygon/models/fill.js +27 -13
- package/es/polygon/models/fill.js.map +1 -1
- package/es/polygon/models/ocean.d.ts +2 -2
- package/es/polygon/models/ocean.js +12 -6
- package/es/polygon/models/ocean.js.map +1 -1
- package/es/polygon/models/tile.d.ts +2 -3
- package/es/polygon/models/tile.js +17 -27
- package/es/polygon/models/tile.js.map +1 -1
- package/es/polygon/models/water.d.ts +2 -2
- package/es/polygon/models/water.js +12 -6
- package/es/polygon/models/water.js.map +1 -1
- package/es/raster/index.js +12 -2
- package/es/raster/index.js.map +1 -1
- package/es/raster/models/raster.d.ts +3 -3
- package/es/raster/models/raster.js +11 -7
- package/es/raster/models/raster.js.map +1 -1
- package/es/tile/manager/tileLayerManager.js +3 -0
- package/es/tile/manager/tileLayerManager.js.map +1 -1
- package/es/tile/manager/tilePickerManager.js +1 -0
- package/es/tile/manager/tilePickerManager.js.map +1 -1
- package/es/tile/tileFactory/base.js.map +1 -1
- package/es/tile/tileFactory/point.js.map +1 -1
- package/es/tile/tileFactory/rasterDataLayer.js +12 -2
- package/es/tile/tileFactory/rasterDataLayer.js.map +1 -1
- package/es/tile/tileFactory/vectorLayer.js +12 -2
- package/es/tile/tileFactory/vectorLayer.js.map +1 -1
- package/es/wind/index.js +12 -2
- package/es/wind/index.js.map +1 -1
- package/es/wind/models/wind.d.ts +4 -2
- package/es/wind/models/wind.js +50 -18
- package/es/wind/models/wind.js.map +1 -1
- package/es/wind/models/windRender.js +1 -1
- package/es/wind/models/windRender.js.map +1 -1
- package/lib/Geometry/index.js +12 -2
- package/lib/Geometry/index.js.map +1 -1
- package/lib/Geometry/models/billboard.js +11 -6
- package/lib/Geometry/models/billboard.js.map +1 -1
- package/lib/Geometry/models/plane.js +12 -7
- package/lib/Geometry/models/plane.js.map +1 -1
- package/lib/Geometry/models/sprite.js +11 -6
- package/lib/Geometry/models/sprite.js.map +1 -1
- package/lib/canvas/index.js +12 -2
- package/lib/canvas/index.js.map +1 -1
- package/lib/citybuliding/building.js +12 -2
- package/lib/citybuliding/building.js.map +1 -1
- package/lib/citybuliding/models/build.js +16 -3
- package/lib/citybuliding/models/build.js.map +1 -1
- package/lib/core/BaseLayer.js +104 -61
- package/lib/core/BaseLayer.js.map +1 -1
- package/lib/core/BaseModel.js +2 -2
- package/lib/core/BaseModel.js.map +1 -1
- package/lib/core/interface.js.map +1 -1
- package/lib/core/triangulation.js +4 -6
- package/lib/core/triangulation.js.map +1 -1
- package/lib/earth/index.js +8 -2
- package/lib/earth/index.js.map +1 -1
- package/lib/earth/models/atmosphere.js +11 -6
- package/lib/earth/models/atmosphere.js.map +1 -1
- package/lib/earth/models/base.js +11 -6
- package/lib/earth/models/base.js.map +1 -1
- package/lib/earth/models/bloomsphere.js +11 -6
- package/lib/earth/models/bloomsphere.js.map +1 -1
- package/lib/heatmap/index.js +17 -5
- package/lib/heatmap/index.js.map +1 -1
- package/lib/heatmap/models/grid.js +12 -8
- package/lib/heatmap/models/grid.js.map +1 -1
- package/lib/heatmap/models/grid3d.js +12 -6
- package/lib/heatmap/models/grid3d.js.map +1 -1
- package/lib/heatmap/models/heatmap.js +113 -62
- package/lib/heatmap/models/heatmap.js.map +1 -1
- package/lib/heatmap/models/hexagon.js +11 -6
- package/lib/heatmap/models/hexagon.js.map +1 -1
- package/lib/image/index.js +12 -2
- package/lib/image/index.js.map +1 -1
- package/lib/image/models/dataImage.js +10 -5
- package/lib/image/models/dataImage.js.map +1 -1
- package/lib/image/models/image.js +11 -7
- package/lib/image/models/image.js.map +1 -1
- package/lib/line/index.js +12 -5
- package/lib/line/index.js.map +1 -1
- package/lib/line/models/arc.js +14 -9
- package/lib/line/models/arc.js.map +1 -1
- package/lib/line/models/arc_3d.js +13 -8
- package/lib/line/models/arc_3d.js.map +1 -1
- package/lib/line/models/earthArc_3d.js +17 -9
- package/lib/line/models/earthArc_3d.js.map +1 -1
- package/lib/line/models/great_circle.js +11 -6
- package/lib/line/models/great_circle.js.map +1 -1
- package/lib/line/models/half.js +48 -29
- package/lib/line/models/half.js.map +1 -1
- package/lib/line/models/index.js +0 -3
- package/lib/line/models/index.js.map +1 -1
- package/lib/line/models/line.js +28 -17
- package/lib/line/models/line.js.map +1 -1
- package/lib/line/models/linearline.js +14 -24
- package/lib/line/models/linearline.js.map +1 -1
- package/lib/line/models/simpleLine.js +13 -8
- package/lib/line/models/simpleLine.js.map +1 -1
- package/lib/line/models/tile.js +47 -39
- package/lib/line/models/tile.js.map +1 -1
- package/lib/line/models/wall.js +13 -9
- package/lib/line/models/wall.js.map +1 -1
- package/lib/mask/index.js +12 -2
- package/lib/mask/index.js.map +1 -1
- package/lib/mask/models/fill.js +55 -27
- package/lib/mask/models/fill.js.map +1 -1
- package/lib/plugins/DataMappingPlugin.js +29 -8
- package/lib/plugins/DataMappingPlugin.js.map +1 -1
- package/lib/plugins/DataSourcePlugin.js +13 -4
- package/lib/plugins/DataSourcePlugin.js.map +1 -1
- package/lib/plugins/LayerModelPlugin.js +35 -7
- package/lib/plugins/LayerModelPlugin.js.map +1 -1
- package/lib/plugins/PixelPickingPlugin.js +16 -13
- package/lib/plugins/PixelPickingPlugin.js.map +1 -1
- package/lib/point/index.js +26 -15
- package/lib/point/index.js.map +1 -1
- package/lib/point/models/earthExtrude.js +16 -15
- package/lib/point/models/earthExtrude.js.map +1 -1
- package/lib/point/models/earthFill.js +13 -22
- package/lib/point/models/earthFill.js.map +1 -1
- package/lib/point/models/extrude.js +51 -28
- package/lib/point/models/extrude.js.map +1 -1
- package/lib/point/models/fill.js +61 -42
- package/lib/point/models/fill.js.map +1 -1
- package/lib/point/models/fillmage.js +13 -22
- package/lib/point/models/fillmage.js.map +1 -1
- package/lib/point/models/image.js +11 -6
- package/lib/point/models/image.js.map +1 -1
- package/lib/point/models/index.js +0 -3
- package/lib/point/models/index.js.map +1 -1
- package/lib/point/models/normal.js +11 -6
- package/lib/point/models/normal.js.map +1 -1
- package/lib/point/models/radar.js +13 -22
- package/lib/point/models/radar.js.map +1 -1
- package/lib/point/models/simplePoint.js +11 -6
- package/lib/point/models/simplePoint.js.map +1 -1
- package/lib/point/models/text.js +112 -78
- package/lib/point/models/text.js.map +1 -1
- package/lib/point/models/tile.js +22 -25
- package/lib/point/models/tile.js.map +1 -1
- package/lib/polygon/index.js +12 -2
- package/lib/polygon/index.js.map +1 -1
- package/lib/polygon/models/extrude.js +10 -5
- package/lib/polygon/models/extrude.js.map +1 -1
- package/lib/polygon/models/fill.js +25 -11
- package/lib/polygon/models/fill.js.map +1 -1
- package/lib/polygon/models/ocean.js +12 -6
- package/lib/polygon/models/ocean.js.map +1 -1
- package/lib/polygon/models/tile.js +17 -27
- package/lib/polygon/models/tile.js.map +1 -1
- package/lib/polygon/models/water.js +12 -6
- package/lib/polygon/models/water.js.map +1 -1
- package/lib/raster/index.js +12 -2
- package/lib/raster/index.js.map +1 -1
- package/lib/raster/models/raster.js +11 -7
- package/lib/raster/models/raster.js.map +1 -1
- package/lib/tile/manager/tileLayerManager.js +3 -0
- package/lib/tile/manager/tileLayerManager.js.map +1 -1
- package/lib/tile/manager/tilePickerManager.js +1 -0
- package/lib/tile/manager/tilePickerManager.js.map +1 -1
- package/lib/tile/tileFactory/base.js.map +1 -1
- package/lib/tile/tileFactory/point.js.map +1 -1
- package/lib/tile/tileFactory/rasterDataLayer.js +12 -2
- package/lib/tile/tileFactory/rasterDataLayer.js.map +1 -1
- package/lib/tile/tileFactory/vectorLayer.js +12 -2
- package/lib/tile/tileFactory/vectorLayer.js.map +1 -1
- package/lib/wind/index.js +12 -2
- package/lib/wind/index.js.map +1 -1
- package/lib/wind/models/wind.js +49 -18
- package/lib/wind/models/wind.js.map +1 -1
- package/lib/wind/models/windRender.js +1 -1
- package/lib/wind/models/windRender.js.map +1 -1
- package/package.json +9 -8
- package/es/line/models/arcmini.d.ts +0 -9
- package/es/line/models/arcmini.js +0 -145
- package/es/line/models/arcmini.js.map +0 -1
- package/es/point/models/icon-font.d.ts +0 -11
- package/es/point/models/icon-font.js +0 -181
- package/es/point/models/icon-font.js.map +0 -1
- package/es/raster/image.d.ts +0 -0
- package/es/raster/image.js +0 -2
- package/es/raster/image.js.map +0 -1
- package/es/raster/raster2d.d.ts +0 -27
- package/es/raster/raster2d.js +0 -158
- package/es/raster/raster2d.js.map +0 -1
- package/es/utils/geo.d.ts +0 -12
- package/es/utils/geo.js +0 -53
- package/es/utils/geo.js.map +0 -1
- package/lib/line/models/arcmini.js +0 -161
- package/lib/line/models/arcmini.js.map +0 -1
- package/lib/point/models/icon-font.js +0 -196
- package/lib/point/models/icon-font.js.map +0 -1
- package/lib/raster/image.js +0 -2
- package/lib/raster/image.js.map +0 -1
- package/lib/raster/raster2d.js +0 -172
- package/lib/raster/raster2d.js.map +0 -1
- package/lib/utils/geo.js +0 -65
- package/lib/utils/geo.js.map +0 -1
package/lib/line/models/wall.js
CHANGED
|
@@ -172,10 +172,10 @@ var LineWallModel = function (_BaseModel) {
|
|
|
172
172
|
}
|
|
173
173
|
}, {
|
|
174
174
|
key: "initModels",
|
|
175
|
-
value: function initModels() {
|
|
175
|
+
value: function initModels(callbackModel) {
|
|
176
176
|
this.updateTexture();
|
|
177
177
|
this.iconService.on('imageUpdate', this.updateTexture);
|
|
178
|
-
|
|
178
|
+
this.buildModels(callbackModel);
|
|
179
179
|
}
|
|
180
180
|
}, {
|
|
181
181
|
key: "clearModels",
|
|
@@ -188,18 +188,22 @@ var LineWallModel = function (_BaseModel) {
|
|
|
188
188
|
}
|
|
189
189
|
}, {
|
|
190
190
|
key: "buildModels",
|
|
191
|
-
value: function buildModels() {
|
|
192
|
-
|
|
193
|
-
moduleName: '
|
|
191
|
+
value: function buildModels(callbackModel) {
|
|
192
|
+
this.layer.buildLayerModel({
|
|
193
|
+
moduleName: 'lineWall',
|
|
194
194
|
vertexShader: line_vert,
|
|
195
195
|
fragmentShader: line_frag,
|
|
196
196
|
triangulation: _triangulation.LineTriangulation,
|
|
197
|
-
primitive: _l7Core.gl.TRIANGLES,
|
|
198
|
-
blend: this.getBlend(),
|
|
199
197
|
depth: {
|
|
200
198
|
enable: false
|
|
201
|
-
}
|
|
202
|
-
|
|
199
|
+
},
|
|
200
|
+
blend: this.getBlend()
|
|
201
|
+
}).then(function (model) {
|
|
202
|
+
callbackModel([model]);
|
|
203
|
+
}).catch(function (err) {
|
|
204
|
+
console.warn(err);
|
|
205
|
+
callbackModel([]);
|
|
206
|
+
});
|
|
203
207
|
}
|
|
204
208
|
}, {
|
|
205
209
|
key: "registerBuiltinAttributes",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/line/models/wall.ts"],"names":["LineWallModel","createTexture2D","rendererService","texture","update","data","iconService","getCanvas","layer","render","mag","gl","NEAREST","min","premultiplyAlpha","width","height","canvasHeight","getLayerConfig","opacity","sourceColor","targetColor","textureBlend","heightfixed","lineTexture","iconStep","iconStepCount","getDirty","bind","useLinearColor","sourceColorArr","targetColorArr","dataTextureTest","dataTextureNeedUpdate","judgeStyleAttributes","encodeData","getEncodedData","calDataFrame","cellLength","cellProperties","rowCount","dataTexture","length","flipY","format","LUMINANCE","type","FLOAT","u_heightfixed","Number","u_dataTexture","u_cellTypeLayout","getCellTypeLayout","u_opacity","u_textureBlend","u_texture","u_line_texture","u_iconStepCount","u_icon_step","u_textSize","u_linearColor","u_sourceColor","u_targetColor","animateOption","u_aimate","animateOption2Array","u_time","getLayerAnimateTime","updateTexture","on","buildModels","destroy","off","buildLayerModel","moduleName","vertexShader","line_vert","fragmentShader","line_frag","triangulation","LineTriangulation","primitive","TRIANGLES","blend","getBlend","depth","enable","styleAttributeService","registerStyleAttribute","name","AttributeType","Attribute","descriptor","buffer","usage","STATIC_DRAW","size","feature","featureIdx","vertex","attributeIdx","DYNAMIC_DRAW","Array","isArray","normal","iconMap","getIconMap","x","y","BaseModel"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AAUA;;AAEA;;AAEA;;;;;;;;;IAIqBA,a;;;;;;;;;;;;;;;;gGAkQK,YAAM;AAC5B,UAAQC,eAAR,GAA4B,MAAKC,eAAjC,CAAQD,eAAR;;AACA,UAAI,MAAKE,OAAT,EAAkB;AAChB,cAAKA,OAAL,CAAaC,MAAb,CAAoB;AAClBC,UAAAA,IAAI,EAAE,MAAKC,WAAL,CAAiBC,SAAjB;AADY,SAApB;;AAGA,cAAKC,KAAL,CAAWC,MAAX;;AACA;AACD;;AACD,YAAKN,OAAL,GAAeF,eAAe,CAAC;AAC7BI,QAAAA,IAAI,EAAE,MAAKC,WAAL,CAAiBC,SAAjB,EADuB;AAE7BG,QAAAA,GAAG,EAAEC,WAAGC,OAFqB;AAG7BC,QAAAA,GAAG,EAAEF,WAAGC,OAHqB;AAI7BE,QAAAA,gBAAgB,EAAE,KAJW;AAK7BC,QAAAA,KAAK,EAAE,IALsB;AAM7BC,QAAAA,MAAM,EAAE,MAAKV,WAAL,CAAiBW,YAAjB,IAAiC;AANZ,OAAD,CAA9B;AAQD,K;;;;;;WAjRD,wBAAqC;AACnC,iBASI,KAAKT,KAAL,CAAWU,cAAX,EATJ;AAAA,8BACEC,OADF;AAAA,UACEA,OADF,6BAC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YAAAA,IAAI,EAAEnC,WAAGoC;AAJH,WAFE;AAQViD,UAAAA,IAAI,EAAE,CARI;AASV5F,UAAAA,MAAM,EAAE,gBACN6F,OADM,EAENC,UAFM,EAGNC,MAHM,EAINC,YAJM,EAKH;AACH,mBAAO,CAACD,MAAM,CAAC,CAAD,CAAP,CAAP;AACD;AAhBS;AAHoC,OAAlD;AAuBA,WAAKZ,qBAAL,CAA2BC,sBAA3B,CAAkD;AAChDC,QAAAA,IAAI,EAAE,IAD0C;AAEhD3C,QAAAA,IAAI,EAAE4C,sBAAcC,SAF4B;AAGhDC,QAAAA,UAAU,EAAE;AACVH,UAAAA,IAAI,EAAE,aADI;AAEVI,UAAAA,MAAM,EAAE;AAENC,YAAAA,KAAK,EAAEnF,WAAG0F,YAFJ;AAGNhG,YAAAA,IAAI,EAAE,EAHA;AAINyC,YAAAA,IAAI,EAAEnC,WAAGoC;AAJH,WAFE;AAQViD,UAAAA,IAAI,EAAE,CARI;AASV5F,UAAAA,MAAM,EAAE,gBACN6F,OADM,EAENC,UAFM,EAGNC,MAHM,EAINC,YAJM,EAKH;AACH,gBAAMK,OAAO,GAAG,MAAI,CAACnG,WAAL,CAAiBoG,UAAjB,EAAhB;;AACA,gBAAQvG,OAAR,GAAoB8F,OAApB,CAAQ9F,OAAR;;AACA,wBAAiBsG,OAAO,CAACtG,OAAD,CAAP,IAA8B;AAAEwG,cAAAA,CAAC,EAAE,CAAL;AAAQC,cAAAA,CAAC,EAAE;AAAX,aAA/C;AAAA,gBAAQD,CAAR,SAAQA,CAAR;AAAA,gBAAWC,CAAX,SAAWA,CAAX;;AACA,mBAAO,CAACD,CAAD,EAAIC,CAAJ,CAAP;AACD;AAnBS;AAHoC,OAAlD;AAyBD;;;EAjQwCC,mB","sourcesContent":["import {\n AttributeType,\n gl,\n IAnimateOption,\n IEncodeFeature,\n ILayerConfig,\n IModel,\n IModelUniform,\n ITexture2D,\n} from '@antv/l7-core';\nimport { rgb2arr } from '@antv/l7-utils';\nimport { isNumber } from 'lodash';\nimport BaseModel from '../../core/BaseModel';\nimport { ILineLayerStyleOptions } from '../../core/interface';\nimport { LineTriangulation } from '../../core/triangulation';\nimport line_frag from '../shaders/wall_frag.glsl';\nimport line_vert from '../shaders/wall_vert.glsl';\n\nexport default class LineWallModel extends BaseModel {\n protected texture: ITexture2D;\n public getUninforms(): IModelUniform {\n const {\n opacity = 1,\n sourceColor,\n targetColor,\n textureBlend = 'normal',\n heightfixed = false,\n lineTexture = false,\n iconStep = 100,\n iconStepCount = 1,\n } = this.layer.getLayerConfig() as ILineLayerStyleOptions;\n\n if (this.rendererService.getDirty()) {\n this.texture.bind();\n }\n\n // 转化渐变色\n let useLinearColor = 0; // 默认不生效\n let sourceColorArr = [0, 0, 0, 0];\n let targetColorArr = [0, 0, 0, 0];\n if (sourceColor && targetColor) {\n sourceColorArr = rgb2arr(sourceColor);\n targetColorArr = rgb2arr(targetColor);\n useLinearColor = 1;\n }\n\n if (this.dataTextureTest && this.dataTextureNeedUpdate({ opacity })) {\n this.judgeStyleAttributes({ opacity });\n const encodeData = this.layer.getEncodedData();\n const { data, width, height } = this.calDataFrame(\n this.cellLength,\n encodeData,\n this.cellProperties,\n );\n this.rowCount = height; // 当前数据纹理有多少行\n\n this.dataTexture =\n this.cellLength > 0 && data.length > 0\n ? this.createTexture2D({\n flipY: true,\n data,\n format: gl.LUMINANCE,\n type: gl.FLOAT,\n width,\n height,\n })\n : this.createTexture2D({\n flipY: true,\n data: [1],\n format: gl.LUMINANCE,\n type: gl.FLOAT,\n width: 1,\n height: 1,\n });\n }\n\n return {\n u_heightfixed: Number(heightfixed),\n u_dataTexture: this.dataTexture, // 数据纹理 - 有数据映射的时候纹理中带数据,若没有任何数据映射时纹理是 [1]\n u_cellTypeLayout: this.getCellTypeLayout(),\n\n u_opacity: isNumber(opacity) ? opacity : 1.0,\n u_textureBlend: textureBlend === 'normal' ? 0.0 : 1.0,\n\n // 纹理支持参数\n u_texture: this.texture, // 贴图\n u_line_texture: lineTexture ? 1.0 : 0.0, // 传入线的标识\n u_iconStepCount: iconStepCount,\n u_icon_step: iconStep,\n u_textSize: [1024, this.iconService.canvasHeight || 128],\n\n // 渐变色支持参数\n u_linearColor: useLinearColor,\n u_sourceColor: sourceColorArr,\n u_targetColor: targetColorArr,\n };\n }\n public getAnimateUniforms(): IModelUniform {\n const { animateOption } = this.layer.getLayerConfig() as ILayerConfig;\n return {\n u_aimate: this.animateOption2Array(animateOption as IAnimateOption),\n u_time: this.layer.getLayerAnimateTime(),\n };\n }\n\n public initModels(): IModel[] {\n this.updateTexture();\n this.iconService.on('imageUpdate', this.updateTexture);\n\n return this.buildModels();\n }\n\n public clearModels() {\n this.texture?.destroy();\n this.dataTexture?.destroy();\n this.iconService.off('imageUpdate', this.updateTexture);\n }\n\n public buildModels(): IModel[] {\n return [\n this.layer.buildLayerModel({\n moduleName: 'linewall',\n vertexShader: line_vert,\n fragmentShader: line_frag,\n triangulation: LineTriangulation,\n primitive: gl.TRIANGLES,\n blend: this.getBlend(),\n depth: { enable: false },\n }),\n ];\n }\n protected registerBuiltinAttributes() {\n this.styleAttributeService.registerStyleAttribute({\n name: 'distance',\n type: AttributeType.Attribute,\n descriptor: {\n name: 'a_Distance',\n buffer: {\n // give the WebGL driver a hint that this buffer may change\n usage: gl.STATIC_DRAW,\n data: [],\n type: gl.FLOAT,\n },\n size: 1,\n update: (\n feature: IEncodeFeature,\n featureIdx: number,\n vertex: number[],\n attributeIdx: number,\n ) => {\n return [vertex[3]];\n },\n },\n });\n this.styleAttributeService.registerStyleAttribute({\n name: 'total_distance',\n type: AttributeType.Attribute,\n descriptor: {\n name: 'a_Total_Distance',\n buffer: {\n // give the WebGL driver a hint that this buffer may change\n usage: gl.STATIC_DRAW,\n data: [],\n type: gl.FLOAT,\n },\n size: 1,\n update: (\n feature: IEncodeFeature,\n featureIdx: number,\n vertex: number[],\n attributeIdx: number,\n ) => {\n return [vertex[5]];\n },\n },\n });\n\n this.styleAttributeService.registerStyleAttribute({\n name: 'size',\n type: AttributeType.Attribute,\n descriptor: {\n name: 'a_Size',\n buffer: {\n // give the WebGL driver a hint that this buffer may change\n usage: gl.DYNAMIC_DRAW,\n data: [],\n type: gl.FLOAT,\n },\n size: 2,\n update: (\n feature: IEncodeFeature,\n featureIdx: number,\n vertex: number[],\n attributeIdx: number,\n ) => {\n const { size = 1 } = feature;\n return Array.isArray(size) ? [size[0], size[1]] : [size as number, 0];\n },\n },\n });\n\n // point layer size;\n this.styleAttributeService.registerStyleAttribute({\n name: 'normal',\n type: AttributeType.Attribute,\n descriptor: {\n name: 'a_Normal',\n buffer: {\n // give the WebGL driver a hint that this buffer may change\n usage: gl.STATIC_DRAW,\n data: [],\n type: gl.FLOAT,\n },\n size: 3,\n // @ts-ignore\n update: (\n feature: IEncodeFeature,\n featureIdx: number,\n vertex: number[],\n attributeIdx: number,\n normal: number[],\n ) => {\n return normal;\n },\n },\n });\n\n this.styleAttributeService.registerStyleAttribute({\n name: 'miter',\n type: AttributeType.Attribute,\n descriptor: {\n name: 'a_Miter',\n buffer: {\n // give the WebGL driver a hint that this buffer may change\n usage: gl.STATIC_DRAW,\n data: [],\n type: gl.FLOAT,\n },\n size: 1,\n update: (\n feature: IEncodeFeature,\n featureIdx: number,\n vertex: number[],\n attributeIdx: number,\n ) => {\n return [vertex[4]];\n },\n },\n });\n\n this.styleAttributeService.registerStyleAttribute({\n name: 'uv',\n type: AttributeType.Attribute,\n descriptor: {\n name: 'a_iconMapUV',\n buffer: {\n // give the WebGL driver a hint that this buffer may change\n usage: gl.DYNAMIC_DRAW,\n data: [],\n type: gl.FLOAT,\n },\n size: 2,\n update: (\n feature: IEncodeFeature,\n featureIdx: number,\n vertex: number[],\n attributeIdx: number,\n ) => {\n const iconMap = this.iconService.getIconMap();\n const { texture } = feature;\n const { x, y } = iconMap[texture as string] || { x: 0, y: 0 };\n return [x, y];\n },\n },\n });\n }\n private updateTexture = () => {\n const { createTexture2D } = this.rendererService;\n if (this.texture) {\n this.texture.update({\n data: this.iconService.getCanvas(),\n });\n this.layer.render();\n return;\n }\n this.texture = createTexture2D({\n data: this.iconService.getCanvas(),\n mag: gl.NEAREST,\n min: gl.NEAREST,\n premultiplyAlpha: false,\n width: 1024,\n height: this.iconService.canvasHeight || 128,\n });\n };\n}\n"],"file":"wall.js"}
|
|
1
|
+
{"version":3,"sources":["../../../src/line/models/wall.ts"],"names":["LineWallModel","createTexture2D","rendererService","texture","update","data","iconService","getCanvas","layer","render","mag","gl","NEAREST","min","premultiplyAlpha","width","height","canvasHeight","getLayerConfig","opacity","sourceColor","targetColor","textureBlend","heightfixed","lineTexture","iconStep","iconStepCount","getDirty","bind","useLinearColor","sourceColorArr","targetColorArr","dataTextureTest","dataTextureNeedUpdate","judgeStyleAttributes","encodeData","getEncodedData","calDataFrame","cellLength","cellProperties","rowCount","dataTexture","length","flipY","format","LUMINANCE","type","FLOAT","u_heightfixed","Number","u_dataTexture","u_cellTypeLayout","getCellTypeLayout","u_opacity","u_textureBlend","u_texture","u_line_texture","u_iconStepCount","u_icon_step","u_textSize","u_linearColor","u_sourceColor","u_targetColor","animateOption","u_aimate","animateOption2Array","u_time","getLayerAnimateTime","callbackModel","updateTexture","on","buildModels","destroy","off","buildLayerModel","moduleName","vertexShader","line_vert","fragmentShader","line_frag","triangulation","LineTriangulation","depth","enable","blend","getBlend","then","model","catch","err","console","warn","styleAttributeService","registerStyleAttribute","name","AttributeType","Attribute","descriptor","buffer","usage","STATIC_DRAW","size","feature","featureIdx","vertex","attributeIdx","DYNAMIC_DRAW","Array","isArray","normal","iconMap","getIconMap","x","y","BaseModel"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AAUA;;AAEA;;AAEA;;;;;;;;;IAIqBA,a;;;;;;;;;;;;;;;;gGAuQK,YAAM;AAC5B,UAAQC,eAAR,GAA4B,MAAKC,eAAjC,CAAQD,eAAR;;AACA,UAAI,MAAKE,OAAT,EAAkB;AAChB,cAAKA,OAAL,CAAaC,MAAb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G+F,YAFJ;AAGNrG,YAAAA,IAAI,EAAE,EAHA;AAINyC,YAAAA,IAAI,EAAEnC,WAAGoC;AAJH,WAFE;AAQVsD,UAAAA,IAAI,EAAE,CARI;AASVjG,UAAAA,MAAM,EAAE,gBACNkG,OADM,EAENC,UAFM,EAGNC,MAHM,EAINC,YAJM,EAKH;AACH,gBAAMK,OAAO,GAAG,MAAI,CAACxG,WAAL,CAAiByG,UAAjB,EAAhB;;AACA,gBAAQ5G,OAAR,GAAoBmG,OAApB,CAAQnG,OAAR;;AACA,wBAAiB2G,OAAO,CAAC3G,OAAD,CAAP,IAA8B;AAAE6G,cAAAA,CAAC,EAAE,CAAL;AAAQC,cAAAA,CAAC,EAAE;AAAX,aAA/C;AAAA,gBAAQD,CAAR,SAAQA,CAAR;AAAA,gBAAWC,CAAX,SAAWA,CAAX;;AACA,mBAAO,CAACD,CAAD,EAAIC,CAAJ,CAAP;AACD;AAnBS;AAHoC,OAAlD;AAyBD;;;EAtQwCC,mB","sourcesContent":["import {\n AttributeType,\n gl,\n IAnimateOption,\n IEncodeFeature,\n ILayerConfig,\n IModel,\n IModelUniform,\n ITexture2D,\n} from '@antv/l7-core';\nimport { rgb2arr } from '@antv/l7-utils';\nimport { isNumber } from 'lodash';\nimport BaseModel from '../../core/BaseModel';\nimport { ILineLayerStyleOptions } from '../../core/interface';\nimport { LineTriangulation } from '../../core/triangulation';\nimport line_frag from '../shaders/wall_frag.glsl';\nimport line_vert from '../shaders/wall_vert.glsl';\n\nexport default class LineWallModel extends BaseModel {\n protected texture: ITexture2D;\n public getUninforms(): IModelUniform {\n const {\n opacity = 1,\n sourceColor,\n targetColor,\n textureBlend = 'normal',\n heightfixed = false,\n lineTexture = false,\n iconStep = 100,\n iconStepCount = 1,\n } = this.layer.getLayerConfig() as ILineLayerStyleOptions;\n\n if (this.rendererService.getDirty()) {\n this.texture.bind();\n }\n\n // 转化渐变色\n let useLinearColor = 0; // 默认不生效\n let sourceColorArr = [0, 0, 0, 0];\n let targetColorArr = [0, 0, 0, 0];\n if (sourceColor && targetColor) {\n sourceColorArr = rgb2arr(sourceColor);\n targetColorArr = rgb2arr(targetColor);\n useLinearColor = 1;\n }\n\n if (this.dataTextureTest && this.dataTextureNeedUpdate({ opacity })) {\n this.judgeStyleAttributes({ opacity });\n const encodeData = this.layer.getEncodedData();\n const { data, width, height } = this.calDataFrame(\n this.cellLength,\n encodeData,\n this.cellProperties,\n );\n this.rowCount = height; // 当前数据纹理有多少行\n\n this.dataTexture =\n this.cellLength > 0 && data.length > 0\n ? this.createTexture2D({\n flipY: true,\n data,\n format: gl.LUMINANCE,\n type: gl.FLOAT,\n width,\n height,\n })\n : this.createTexture2D({\n flipY: true,\n data: [1],\n format: gl.LUMINANCE,\n type: gl.FLOAT,\n width: 1,\n height: 1,\n });\n }\n\n return {\n u_heightfixed: Number(heightfixed),\n u_dataTexture: this.dataTexture, // 数据纹理 - 有数据映射的时候纹理中带数据,若没有任何数据映射时纹理是 [1]\n u_cellTypeLayout: this.getCellTypeLayout(),\n\n u_opacity: isNumber(opacity) ? opacity : 1.0,\n u_textureBlend: textureBlend === 'normal' ? 0.0 : 1.0,\n\n // 纹理支持参数\n u_texture: this.texture, // 贴图\n u_line_texture: lineTexture ? 1.0 : 0.0, // 传入线的标识\n u_iconStepCount: iconStepCount,\n u_icon_step: iconStep,\n u_textSize: [1024, this.iconService.canvasHeight || 128],\n\n // 渐变色支持参数\n u_linearColor: useLinearColor,\n u_sourceColor: sourceColorArr,\n u_targetColor: targetColorArr,\n };\n }\n public getAnimateUniforms(): IModelUniform {\n const { animateOption } = this.layer.getLayerConfig() as ILayerConfig;\n return {\n u_aimate: this.animateOption2Array(animateOption as IAnimateOption),\n u_time: this.layer.getLayerAnimateTime(),\n };\n }\n\n public initModels(callbackModel: (models: IModel[]) => void) {\n this.updateTexture();\n this.iconService.on('imageUpdate', this.updateTexture);\n\n this.buildModels(callbackModel);\n }\n\n public clearModels() {\n this.texture?.destroy();\n this.dataTexture?.destroy();\n this.iconService.off('imageUpdate', this.updateTexture);\n }\n\n public buildModels(callbackModel: (models: IModel[]) => void) {\n this.layer\n .buildLayerModel({\n moduleName: 'lineWall',\n vertexShader: line_vert,\n fragmentShader: line_frag,\n triangulation: LineTriangulation,\n depth: { enable: false },\n blend: this.getBlend(),\n })\n .then((model) => {\n callbackModel([model]);\n })\n .catch((err) => {\n console.warn(err);\n callbackModel([]);\n });\n }\n protected registerBuiltinAttributes() {\n this.styleAttributeService.registerStyleAttribute({\n name: 'distance',\n type: AttributeType.Attribute,\n descriptor: {\n name: 'a_Distance',\n buffer: {\n // give the WebGL driver a hint that this buffer may change\n usage: gl.STATIC_DRAW,\n data: [],\n type: gl.FLOAT,\n },\n size: 1,\n update: (\n feature: IEncodeFeature,\n featureIdx: number,\n vertex: number[],\n attributeIdx: number,\n ) => {\n return [vertex[3]];\n },\n },\n });\n this.styleAttributeService.registerStyleAttribute({\n name: 'total_distance',\n type: AttributeType.Attribute,\n descriptor: {\n name: 'a_Total_Distance',\n buffer: {\n // give the WebGL driver a hint that this buffer may change\n usage: gl.STATIC_DRAW,\n data: [],\n type: gl.FLOAT,\n },\n size: 1,\n update: (\n feature: IEncodeFeature,\n featureIdx: number,\n vertex: number[],\n attributeIdx: number,\n ) => {\n return [vertex[5]];\n },\n },\n });\n\n this.styleAttributeService.registerStyleAttribute({\n name: 'size',\n type: AttributeType.Attribute,\n descriptor: {\n name: 'a_Size',\n buffer: {\n // give the WebGL driver a hint that this buffer may change\n usage: gl.DYNAMIC_DRAW,\n data: [],\n type: gl.FLOAT,\n },\n size: 2,\n update: (\n feature: IEncodeFeature,\n featureIdx: number,\n vertex: number[],\n attributeIdx: number,\n ) => {\n const { size = 1 } = feature;\n return Array.isArray(size) ? [size[0], size[1]] : [size as number, 0];\n },\n },\n });\n\n // point layer size;\n this.styleAttributeService.registerStyleAttribute({\n name: 'normal',\n type: AttributeType.Attribute,\n descriptor: {\n name: 'a_Normal',\n buffer: {\n // give the WebGL driver a hint that this buffer may change\n usage: gl.STATIC_DRAW,\n data: [],\n type: gl.FLOAT,\n },\n size: 3,\n // @ts-ignore\n update: (\n feature: IEncodeFeature,\n featureIdx: number,\n vertex: number[],\n attributeIdx: number,\n normal: number[],\n ) => {\n return normal;\n },\n },\n });\n\n this.styleAttributeService.registerStyleAttribute({\n name: 'miter',\n type: AttributeType.Attribute,\n descriptor: {\n name: 'a_Miter',\n buffer: {\n // give the WebGL driver a hint that this buffer may change\n usage: gl.STATIC_DRAW,\n data: [],\n type: gl.FLOAT,\n },\n size: 1,\n update: (\n feature: IEncodeFeature,\n featureIdx: number,\n vertex: number[],\n attributeIdx: number,\n ) => {\n return [vertex[4]];\n },\n },\n });\n\n this.styleAttributeService.registerStyleAttribute({\n name: 'uv',\n type: AttributeType.Attribute,\n descriptor: {\n name: 'a_iconMapUV',\n buffer: {\n // give the WebGL driver a hint that this buffer may change\n usage: gl.DYNAMIC_DRAW,\n data: [],\n type: gl.FLOAT,\n },\n size: 2,\n update: (\n feature: IEncodeFeature,\n featureIdx: number,\n vertex: number[],\n attributeIdx: number,\n ) => {\n const iconMap = this.iconService.getIconMap();\n const { texture } = feature;\n const { x, y } = iconMap[texture as string] || { x: 0, y: 0 };\n return [x, y];\n },\n },\n });\n }\n private updateTexture = () => {\n const { createTexture2D } = this.rendererService;\n if (this.texture) {\n this.texture.update({\n data: this.iconService.getCanvas(),\n });\n this.layer.render();\n return;\n }\n this.texture = createTexture2D({\n data: this.iconService.getCanvas(),\n mag: gl.NEAREST,\n min: gl.NEAREST,\n premultiplyAlpha: false,\n width: 1024,\n height: this.iconService.canvasHeight || 128,\n });\n };\n}\n"],"file":"wall.js"}
|
package/lib/mask/index.js
CHANGED
|
@@ -51,14 +51,24 @@ var MaskLayer = function (_BaseLayer) {
|
|
|
51
51
|
(0, _createClass2.default)(MaskLayer, [{
|
|
52
52
|
key: "buildModels",
|
|
53
53
|
value: function buildModels() {
|
|
54
|
+
var _this2 = this;
|
|
55
|
+
|
|
54
56
|
var shape = this.getModelType();
|
|
55
57
|
this.layerModel = new _models.default[shape](this);
|
|
56
|
-
this.
|
|
58
|
+
this.layerModel.initModels(function (models) {
|
|
59
|
+
_this2.models = models;
|
|
60
|
+
|
|
61
|
+
_this2.renderLayers();
|
|
62
|
+
});
|
|
57
63
|
}
|
|
58
64
|
}, {
|
|
59
65
|
key: "rebuildModels",
|
|
60
66
|
value: function rebuildModels() {
|
|
61
|
-
|
|
67
|
+
var _this3 = this;
|
|
68
|
+
|
|
69
|
+
this.layerModel.buildModels(function (models) {
|
|
70
|
+
return _this3.models = models;
|
|
71
|
+
});
|
|
62
72
|
}
|
|
63
73
|
}, {
|
|
64
74
|
key: "getConfigSchema",
|
package/lib/mask/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/mask/index.ts"],"names":["MaskLayer","shape","getModelType","layerModel","MaskModels","models","
|
|
1
|
+
{"version":3,"sources":["../../src/mask/index.ts"],"names":["MaskLayer","shape","getModelType","layerModel","MaskModels","initModels","models","renderLayers","buildModels","properties","opacity","type","minimum","maximum","BaseLayer"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAAA;;AAEA;;;;;;IAEqBA,S;;;;;;;;;;;;;;;uFACG,W;;;;;;WACtB,uBAAqB;AAAA;;AACnB,UAAMC,KAAK,GAAG,KAAKC,YAAL,EAAd;AACA,WAAKC,UAAL,GAAkB,IAAIC,gBAAWH,KAAX,CAAJ,CAAsB,IAAtB,CAAlB;AACA,WAAKE,UAAL,CAAgBE,UAAhB,CAA2B,UAACC,MAAD,EAAY;AACrC,QAAA,MAAI,CAACA,MAAL,GAAcA,MAAd;;AACA,QAAA,MAAI,CAACC,YAAL;AACD,OAHD;AAID;;;WACD,yBAAuB;AAAA;;AACrB,WAAKJ,UAAL,CAAgBK,WAAhB,CAA4B,UAACF,MAAD;AAAA,eAAa,MAAI,CAACA,MAAL,GAAcA,MAA3B;AAAA,OAA5B;AACD;;;WACD,2BAA4B;AAC1B,aAAO;AACLG,QAAAA,UAAU,EAAE;AACVC,UAAAA,OAAO,EAAE;AACPC,YAAAA,IAAI,EAAE,QADC;AAEPC,YAAAA,OAAO,EAAE,CAFF;AAGPC,YAAAA,OAAO,EAAE;AAHF;AADC;AADP,OAAP;AASD;;;WAED,wBAAwC;AACtC,aAAO,MAAP;AACD;;;EA3BoCC,mB","sourcesContent":["import BaseLayer from '../core/BaseLayer';\nimport { IMaskLayerStyleOptions } from '../core/interface';\nimport MaskModels, { MaskModelType } from './models';\n\nexport default class MaskLayer extends BaseLayer<IMaskLayerStyleOptions> {\n public type: string = 'MaskLayer';\n public buildModels() {\n const shape = this.getModelType();\n this.layerModel = new MaskModels[shape](this);\n this.layerModel.initModels((models) => {\n this.models = models;\n this.renderLayers();\n });\n }\n public rebuildModels() {\n this.layerModel.buildModels((models) => (this.models = models));\n }\n protected getConfigSchema() {\n return {\n properties: {\n opacity: {\n type: 'number',\n minimum: 0,\n maximum: 1,\n },\n },\n };\n }\n\n protected getModelType(): MaskModelType {\n return 'fill';\n }\n}\n"],"file":"index.js"}
|
package/lib/mask/models/fill.js
CHANGED
|
@@ -7,6 +7,10 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
7
7
|
});
|
|
8
8
|
exports.default = void 0;
|
|
9
9
|
|
|
10
|
+
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
|
11
|
+
|
|
12
|
+
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
13
|
+
|
|
10
14
|
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
11
15
|
|
|
12
16
|
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
@@ -55,37 +59,61 @@ var MaskModel = function (_BaseModel) {
|
|
|
55
59
|
}
|
|
56
60
|
}, {
|
|
57
61
|
key: "initModels",
|
|
58
|
-
value: function initModels() {
|
|
59
|
-
|
|
62
|
+
value: function initModels(callbackModel) {
|
|
63
|
+
this.buildModels(callbackModel);
|
|
60
64
|
}
|
|
61
65
|
}, {
|
|
62
66
|
key: "buildModels",
|
|
63
|
-
value: function
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
67
|
+
value: function () {
|
|
68
|
+
var _buildModels = (0, _asyncToGenerator2.default)(_regenerator.default.mark(function _callee(callbackModel) {
|
|
69
|
+
return _regenerator.default.wrap(function _callee$(_context) {
|
|
70
|
+
while (1) {
|
|
71
|
+
switch (_context.prev = _context.next) {
|
|
72
|
+
case 0:
|
|
73
|
+
this.layer.buildLayerModel({
|
|
74
|
+
moduleName: 'mask',
|
|
75
|
+
vertexShader: mask_vert,
|
|
76
|
+
fragmentShader: mask_frag,
|
|
77
|
+
triangulation: _triangulation.polygonTriangulation,
|
|
78
|
+
depth: {
|
|
79
|
+
enable: false
|
|
80
|
+
},
|
|
81
|
+
blend: this.getBlend(),
|
|
82
|
+
stencil: {
|
|
83
|
+
enable: true,
|
|
84
|
+
mask: 0xff,
|
|
85
|
+
func: {
|
|
86
|
+
cmp: _l7Core.gl.ALWAYS,
|
|
87
|
+
ref: 1,
|
|
88
|
+
mask: 0xff
|
|
89
|
+
},
|
|
90
|
+
opFront: {
|
|
91
|
+
fail: _l7Core.gl.REPLACE,
|
|
92
|
+
zfail: _l7Core.gl.REPLACE,
|
|
93
|
+
zpass: _l7Core.gl.REPLACE
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
}).then(function (model) {
|
|
97
|
+
callbackModel([model]);
|
|
98
|
+
}).catch(function (err) {
|
|
99
|
+
console.warn(err);
|
|
100
|
+
callbackModel([]);
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
case 1:
|
|
104
|
+
case "end":
|
|
105
|
+
return _context.stop();
|
|
106
|
+
}
|
|
85
107
|
}
|
|
86
|
-
}
|
|
87
|
-
})
|
|
88
|
-
|
|
108
|
+
}, _callee, this);
|
|
109
|
+
}));
|
|
110
|
+
|
|
111
|
+
function buildModels(_x) {
|
|
112
|
+
return _buildModels.apply(this, arguments);
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
return buildModels;
|
|
116
|
+
}()
|
|
89
117
|
}, {
|
|
90
118
|
key: "clearModels",
|
|
91
119
|
value: function clearModels() {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/mask/models/fill.ts"],"names":["MaskModel","layer","getLayerConfig","opacity","u_opacity","buildModels","buildLayerModel","moduleName","vertexShader","mask_vert","fragmentShader","mask_frag","triangulation","polygonTriangulation","
|
|
1
|
+
{"version":3,"sources":["../../../src/mask/models/fill.ts"],"names":["MaskModel","layer","getLayerConfig","opacity","u_opacity","callbackModel","buildModels","buildLayerModel","moduleName","vertexShader","mask_vert","fragmentShader","mask_frag","triangulation","polygonTriangulation","depth","enable","blend","getBlend","stencil","mask","func","cmp","gl","ALWAYS","ref","opFront","fail","REPLACE","zfail","zpass","then","model","catch","err","console","warn","dataTexture","destroy","layerService","clear","BaseModel"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AAEA;;AAEA;;;;;;;;;IAIqBA,S;;;;;;;;;;;;WACnB,wBAAsB;AACpB,iBAEI,KAAKC,KAAL,CAAWC,cAAX,EAFJ;AAAA,8BACEC,OADF;AAAA,UACEA,OADF,6BACY,CADZ;;AAGA,aAAO;AACLC,QAAAA,SAAS,EAAE,wBAASD,OAAT,IAAoBA,OAApB,GAA8B;AADpC,OAAP;AAGD;;;WAED,oBAAkBE,aAAlB,EAA6D;AAC3D,WAAKC,WAAL,CAAiBD,aAAjB;AACD;;;;mFAED,iBAAyBA,aAAzB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ash';\nimport BaseModel from '../../core/BaseModel';\nimport { IMaskLayerStyleOptions } from '../../core/interface';\nimport { polygonTriangulation } from '../../core/triangulation';\nimport mask_frag from '../shaders/mask_frag.glsl';\nimport mask_vert from '../shaders/mask_vert.glsl';\n\nexport default class MaskModel extends BaseModel {\n public getUninforms() {\n const {\n opacity = 0,\n } = this.layer.getLayerConfig() as IMaskLayerStyleOptions;\n return {\n u_opacity: isNumber(opacity) ? opacity : 0.0,\n };\n }\n\n public initModels(callbackModel: (models: IModel[]) => void) {\n this.buildModels(callbackModel);\n }\n\n public async buildModels(callbackModel: (models: IModel[]) => void) {\n this.layer\n .buildLayerModel({\n moduleName: 'mask',\n vertexShader: mask_vert,\n fragmentShader: mask_frag,\n triangulation: polygonTriangulation,\n depth: { enable: false },\n blend: this.getBlend(),\n stencil: {\n enable: true,\n mask: 0xff,\n func: {\n cmp: gl.ALWAYS,\n ref: 1,\n mask: 0xff,\n },\n opFront: {\n fail: gl.REPLACE,\n zfail: gl.REPLACE,\n zpass: gl.REPLACE,\n },\n },\n })\n .then((model) => {\n callbackModel([model]);\n })\n .catch((err) => {\n console.warn(err);\n callbackModel([]);\n });\n }\n\n public clearModels() {\n this.dataTexture?.destroy();\n this.layerService.clear();\n }\n\n protected registerBuiltinAttributes() {\n return '';\n }\n}\n"],"file":"fill.js"}
|
|
@@ -52,28 +52,49 @@ var DataMappingPlugin = (_dec = (0, _inversify.injectable)(), _dec2 = (0, _inver
|
|
|
52
52
|
|
|
53
53
|
var styleAttributeService = _ref.styleAttributeService;
|
|
54
54
|
layer.hooks.init.tap('DataMappingPlugin', function () {
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
55
|
+
var source = layer.getSource();
|
|
56
|
+
|
|
57
|
+
if (source.inited) {
|
|
58
|
+
_this.generateMaping(layer, {
|
|
59
|
+
styleAttributeService: styleAttributeService
|
|
60
|
+
});
|
|
61
|
+
} else {
|
|
62
|
+
source.once('sourceUpdate', function () {
|
|
63
|
+
_this.generateMaping(layer, {
|
|
64
|
+
styleAttributeService: styleAttributeService
|
|
65
|
+
});
|
|
66
|
+
});
|
|
67
|
+
}
|
|
58
68
|
});
|
|
59
69
|
layer.hooks.beforeRenderData.tap('DataMappingPlugin', function () {
|
|
60
70
|
layer.dataState.dataMappingNeedUpdate = false;
|
|
71
|
+
var source = layer.getSource();
|
|
61
72
|
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
73
|
+
if (source.inited) {
|
|
74
|
+
_this.generateMaping(layer, {
|
|
75
|
+
styleAttributeService: styleAttributeService
|
|
76
|
+
});
|
|
77
|
+
} else {
|
|
78
|
+
source.once('sourceUpdate', function () {
|
|
79
|
+
_this.generateMaping(layer, {
|
|
80
|
+
styleAttributeService: styleAttributeService
|
|
81
|
+
});
|
|
82
|
+
});
|
|
83
|
+
}
|
|
65
84
|
|
|
66
85
|
return true;
|
|
67
86
|
});
|
|
68
87
|
layer.hooks.beforeRender.tap('DataMappingPlugin', function () {
|
|
69
|
-
|
|
88
|
+
var source = layer.getSource();
|
|
89
|
+
|
|
90
|
+
if (layer.layerModelNeedUpdate || !source || !source.inited) {
|
|
70
91
|
return;
|
|
71
92
|
}
|
|
72
93
|
|
|
73
94
|
var bottomColor = layer.getBottomColor();
|
|
74
95
|
var attributes = styleAttributeService.getLayerStyleAttributes() || [];
|
|
75
96
|
var filter = styleAttributeService.getLayerStyleAttribute('filter');
|
|
76
|
-
var dataArray =
|
|
97
|
+
var dataArray = source.data.dataArray;
|
|
77
98
|
var attributesToRemapping = attributes.filter(function (attribute) {
|
|
78
99
|
return attribute.needRemapping;
|
|
79
100
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/plugins/DataMappingPlugin.ts"],"names":["DataMappingPlugin","TYPES","IGlobalConfigService","IMapService","IFontService","layer","styleAttributeService","hooks","init","tap","generateMaping","beforeRenderData","dataState","dataMappingNeedUpdate","beforeRender","layerModelNeedUpdate","bottomColor","getBottomColor","attributes","getLayerStyleAttributes","filter","getLayerStyleAttribute","dataArray","getSource","data","attributesToRemapping","attribute","needRemapping","filterData","scale","record","applyAttributeMapping","length","setEncodedData","mapping","undefined","getEncodedData","emit","p1","p2","dir","normalizeDir","arrowPoint","predata","minimumColor","getLayerConfig","arrow","enable","mappedData","map","i","preRecord","encodeRecord","id","_id","coordinates","forEach","values","name","c","Array","isArray","shape","fontService","getIconFontKey","coords","getArrowPoints","splice","adjustData2Amap2Coordinates","adjustData2SimpleCoordinates","mapService","version","Version","layerCenter","getLayerCenter","d","originCoordinates","lngLatToCoordByLayer","lngLatToCoordsByLayer","source","center","SIMPLE","simpleCoordinate","unProjectCoordinates","simpleMapCoord","unproject","coord","c1","co","push","scalers","params","field","hasOwnProperty","type","mappingResult"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAAA;;AAcA;;AACA;;AACA;;AAEA;;;;;;;;IAIqBA,iB,WADpB,4B,UAEE,uBAAOC,cAAMC,oBAAb,C,UAGA,uBAAOD,cAAME,WAAb,C,UAGA,uBAAOF,cAAMG,YAAb,C;;;;;;;;;;WAGD,eACEC,KADF,QAKE;AAAA;;AAAA,UAFEC,qBAEF,QAFEA,qBAEF;AACAD,MAAAA,KAAK,CAACE,KAAN,CAAYC,IAAZ,CAAiBC,GAAjB,CAAqB,mBAArB,EAA0C,YAAM;AAE9C,QAAA,KAAI,CAACC,cAAL,CAAoBL,KAApB,EAA2B;AAAEC,UAAAA,qBAAqB,EAArBA;AAAF,SAA3B;AACD,OAHD;AAKAD,MAAAA,KAAK,CAACE,KAAN,CAAYI,gBAAZ,CAA6BF,GAA7B,CAAiC,mBAAjC,EAAsD,YAAM;AAC1DJ,QAAAA,KAAK,CAACO,SAAN,CAAgBC,qBAAhB,GAAwC,KAAxC;;AACA,QAAA,KAAI,CAACH,cAAL,CAAoBL,KAApB,EAA2B;AAAEC,UAAAA,qBAAqB,EAArBA;AAAF,SAA3B;;AACA,eAAO,IAAP;AACD,OAJD;AAOAD,MAAAA,KAAK,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AAAA;;AACA,UAAI,CAAClB,SAAS,CAACG,KAAf,EAAsB;AACpB,eAAO,EAAP;AACD;;AACD,UAAM6D,OAAO,GAAG,CAAAhE,SAAS,SAAT,IAAAA,SAAS,WAAT,gCAAAA,SAAS,CAAEG,KAAX,sEAAkB6D,OAAlB,KAA6B,EAA7C;AACA,UAAMC,MAAiB,GAAG,EAA1B;AAEAD,MAAAA,OAAO,CAAClC,OAAR,CAAgB,iBAAe;AAAA;;AAAA,YAAZoC,KAAY,SAAZA,KAAY;;AAC7B,YACE9D,MAAM,CAAC+D,cAAP,CAAsBD,KAAtB,KACA,sBAAAlE,SAAS,CAACG,KAAV,wEAAiBiE,IAAjB,MAA0B,UAF5B,EAGE;AAEAH,UAAAA,MAAM,CAACF,IAAP,CAAY3D,MAAM,CAAC8D,KAAD,CAAlB;AACD;AACF,OARD;AAYA,UAAMG,aAAa,GAAGrE,SAAS,CAACQ,OAAV,GAAoBR,SAAS,CAACQ,OAAV,CAAkByD,MAAlB,CAApB,GAAgD,EAAtE;;AACA,UAAIjE,SAAS,CAACgC,IAAV,KAAmB,OAAnB,IAA8B,CAAC,sBAAQqC,aAAa,CAAC,CAAD,CAArB,CAAnC,EAA8D;AAC5D,eAAO,CAACnD,YAAD,CAAP;AACD;;AACD,aAAOmD,aAAP;AAED","sourcesContent":["import {\n IEncodeFeature,\n IFontService,\n IGlobalConfigService,\n ILayer,\n ILayerPlugin,\n ILngLat,\n IMapService,\n IParseDataItem,\n IStyleAttribute,\n IStyleAttributeService,\n Position,\n TYPES,\n} from '@antv/l7-core';\nimport { Version } from '@antv/l7-maps';\nimport { isColor, normalize, rgb2arr, unProjectFlat } from '@antv/l7-utils';\nimport { inject, injectable } from 'inversify';\nimport { cloneDeep } from 'lodash';\nimport 'reflect-metadata';\nimport { ILineLayerStyleOptions } from '../core/interface';\n\n@injectable()\nexport default class DataMappingPlugin implements ILayerPlugin {\n @inject(TYPES.IGlobalConfigService)\n private readonly configService: IGlobalConfigService;\n\n @inject(TYPES.IMapService)\n private readonly mapService: IMapService;\n\n @inject(TYPES.IFontService)\n private readonly fontService: IFontService;\n\n public apply(\n layer: ILayer,\n {\n styleAttributeService,\n }: { styleAttributeService: IStyleAttributeService },\n ) {\n layer.hooks.init.tap('DataMappingPlugin', () => {\n // 初始化重新生成 map\n this.generateMaping(layer, { styleAttributeService });\n });\n\n layer.hooks.beforeRenderData.tap('DataMappingPlugin', () => {\n layer.dataState.dataMappingNeedUpdate = false;\n this.generateMaping(layer, { styleAttributeService });\n return true;\n });\n\n // remapping before render\n layer.hooks.beforeRender.tap('DataMappingPlugin', () => {\n if (layer.layerModelNeedUpdate) {\n return;\n }\n const bottomColor = layer.getBottomColor();\n const attributes = styleAttributeService.getLayerStyleAttributes() || [];\n const filter = styleAttributeService.getLayerStyleAttribute('filter');\n const { dataArray } = layer.getSource().data;\n\n const attributesToRemapping = attributes.filter(\n (attribute) => attribute.needRemapping, // 如果filter变化\n );\n let filterData = dataArray;\n\n // 数据过滤完 再执行数据映射\n if (filter?.needRemapping && filter?.scale) {\n filterData = dataArray.filter((record: IParseDataItem) => {\n return this.applyAttributeMapping(filter, record, bottomColor)[0];\n });\n }\n\n if (attributesToRemapping.length) {\n // 过滤数据\n if (filter?.needRemapping) {\n layer.setEncodedData(\n this.mapping(layer, attributes, filterData, undefined, bottomColor),\n );\n filter.needRemapping = false;\n } else {\n layer.setEncodedData(\n this.mapping(\n layer,\n attributesToRemapping,\n filterData,\n layer.getEncodedData(),\n bottomColor,\n ),\n );\n }\n // 处理文本更新\n layer.emit('remapping', null);\n }\n });\n }\n private generateMaping(\n layer: ILayer,\n {\n styleAttributeService,\n }: { styleAttributeService: IStyleAttributeService },\n ) {\n const bottomColor = layer.getBottomColor();\n const attributes = styleAttributeService.getLayerStyleAttributes() || [];\n const filter = styleAttributeService.getLayerStyleAttribute('filter');\n const { dataArray } = layer.getSource().data;\n let filterData = dataArray;\n // 数据过滤完 再执行数据映射\n if (filter?.scale) {\n filterData = dataArray.filter((record: IParseDataItem) => {\n return this.applyAttributeMapping(filter, record, bottomColor)[0];\n });\n }\n layer.setEncodedData(\n this.mapping(layer, attributes, filterData, undefined, bottomColor),\n );\n // 对外暴露事件\n layer.emit('dataUpdate', null);\n }\n\n private getArrowPoints(p1: Position, p2: Position) {\n const dir = [p2[0] - p1[0], p2[1] - p1[1]];\n const normalizeDir = normalize(dir);\n const arrowPoint = [\n p1[0] + normalizeDir[0] * 0.0001,\n p1[1] + normalizeDir[1] * 0.0001,\n ];\n return arrowPoint;\n }\n\n private mapping(\n layer: ILayer,\n attributes: IStyleAttribute[],\n data: IParseDataItem[],\n predata?: IEncodeFeature[],\n minimumColor?: string,\n ): IEncodeFeature[] {\n const {\n arrow = {\n enable: false,\n },\n } = layer.getLayerConfig() as ILineLayerStyleOptions;\n const mappedData = data.map((record: IParseDataItem, i) => {\n const preRecord = predata ? predata[i] : {};\n const encodeRecord: IEncodeFeature = {\n id: record._id,\n coordinates: record.coordinates,\n ...preRecord,\n };\n attributes\n .filter((attribute) => attribute.scale !== undefined)\n .forEach((attribute: IStyleAttribute) => {\n // console.log('record', record)\n let values = this.applyAttributeMapping(\n attribute,\n record,\n minimumColor,\n );\n // console.log('values', values)\n attribute.needRemapping = false;\n\n // TODO: 支持每个属性配置 postprocess\n if (attribute.name === 'color') {\n // console.log('attribute', attribute)\n values = values.map((c: unknown) => {\n return rgb2arr(c as string);\n });\n }\n // @ts-ignore\n encodeRecord[attribute.name] =\n Array.isArray(values) && values.length === 1 ? values[0] : values;\n\n // 增加对 layer/text/iconfont unicode 映射的解析\n if (attribute.name === 'shape') {\n encodeRecord.shape = this.fontService.getIconFontKey(\n encodeRecord[attribute.name] as string,\n );\n }\n });\n\n if (\n arrow.enable &&\n (encodeRecord.shape === 'line' || encodeRecord.shape === 'halfLine')\n ) {\n // 只有在线图层且支持配置箭头的时候进行插入顶点的处理\n const coords = encodeRecord.coordinates as Position[];\n const arrowPoint = this.getArrowPoints(coords[0], coords[1]);\n encodeRecord.coordinates.splice(1, 0, arrowPoint, arrowPoint);\n }\n return encodeRecord;\n }) as IEncodeFeature[];\n // console.log('mappedData', mappedData)\n\n // 调整数据兼容 Amap2.0\n this.adjustData2Amap2Coordinates(mappedData, layer);\n\n // 调整数据兼容 SimpleCoordinates\n this.adjustData2SimpleCoordinates(mappedData);\n\n return mappedData;\n }\n\n private adjustData2Amap2Coordinates(\n mappedData: IEncodeFeature[],\n layer: ILayer,\n ) {\n // 根据地图的类型判断是否需要对点位数据进行处理, 若是高德2.0则需要对坐标进行相对偏移\n if (\n mappedData.length > 0 &&\n this.mapService.version === Version['GAODE2.x']\n ) {\n const layerCenter = this.getLayerCenter(layer);\n if (typeof mappedData[0].coordinates[0] === 'number') {\n // 单个的点数据\n // @ts-ignore\n mappedData\n // TODO: 避免经纬度被重复计算导致坐标位置偏移\n .filter((d) => !d.originCoordinates)\n .map((d) => {\n d.version = Version['GAODE2.x'];\n // @ts-ignore\n d.originCoordinates = cloneDeep(d.coordinates); // 为了兼容高德1.x 需要保存一份原始的经纬度坐标数据(许多上层逻辑依赖经纬度数据)\n // @ts-ignore\n // d.coordinates = this.mapService.lngLatToCoord(d.coordinates);\n d.coordinates = this.mapService.lngLatToCoordByLayer(\n d.coordinates,\n layerCenter,\n );\n });\n } else {\n // 连续的线、面数据\n // @ts-ignore\n mappedData\n // TODO: 避免经纬度被重复计算导致坐标位置偏移\n .filter((d) => !d.originCoordinates)\n .map((d) => {\n d.version = Version['GAODE2.x'];\n // @ts-ignore\n d.originCoordinates = cloneDeep(d.coordinates); // 为了兼容高德1.x 需要保存一份原始的经纬度坐标数据(许多上层逻辑依赖经纬度数据)\n // @ts-ignore\n // d.coordinates = this.mapService.lngLatToCoords(d.coordinates);\n d.coordinates = this.mapService.lngLatToCoordsByLayer(\n d.coordinates,\n layerCenter,\n );\n });\n }\n }\n }\n\n private getLayerCenter(layer: ILayer) {\n const source = layer.getSource();\n return source.center;\n }\n\n private adjustData2SimpleCoordinates(mappedData: IEncodeFeature[]) {\n if (mappedData.length > 0 && this.mapService.version === Version.SIMPLE) {\n mappedData.map((d) => {\n if (!d.simpleCoordinate) {\n d.coordinates = this.unProjectCoordinates(d.coordinates);\n d.simpleCoordinate = true;\n }\n });\n }\n }\n\n private unProjectCoordinates(coordinates: any) {\n if (typeof coordinates[0] === 'number') {\n return this.mapService.simpleMapCoord.unproject(\n coordinates as [number, number],\n );\n }\n\n if (coordinates[0] && coordinates[0][0] instanceof Array) {\n // @ts-ignore\n const coords = [];\n coordinates.map((coord: any) => {\n // @ts-ignore\n const c1 = [];\n coord.map((co: any) => {\n c1.push(\n this.mapService.simpleMapCoord.unproject(co as [number, number]),\n );\n });\n // @ts-ignore\n coords.push(c1);\n });\n // @ts-ignore\n return coords;\n } else {\n // @ts-ignore\n const coords = [];\n // @ts-ignore\n coordinates.map((coord) => {\n coords.push(\n this.mapService.simpleMapCoord.unproject(coord as [number, number]),\n );\n });\n // @ts-ignore\n return coords;\n }\n }\n\n private applyAttributeMapping(\n attribute: IStyleAttribute,\n record: { [key: string]: unknown },\n minimumColor?: string,\n ) {\n if (!attribute.scale) {\n return [];\n }\n const scalers = attribute?.scale?.scalers || [];\n const params: unknown[] = [];\n\n scalers.forEach(({ field }) => {\n if (\n record.hasOwnProperty(field) ||\n attribute.scale?.type === 'variable'\n ) {\n // TODO:多字段,常量\n params.push(record[field]);\n }\n });\n // console.log('params', params)\n // console.log('attribute', attribute)\n\n const mappingResult = attribute.mapping ? attribute.mapping(params) : [];\n if (attribute.name === 'color' && !isColor(mappingResult[0])) {\n return [minimumColor];\n }\n return mappingResult;\n // return attribute.mapping ? attribute.mapping(params) : [];\n }\n}\n"],"file":"DataMappingPlugin.js"}
|
|
1
|
+
{"version":3,"sources":["../../src/plugins/DataMappingPlugin.ts"],"names":["DataMappingPlugin","TYPES","IGlobalConfigService","IMapService","IFontService","layer","styleAttributeService","hooks","init","tap","source","getSource","inited","generateMaping","once","beforeRenderData","dataState","dataMappingNeedUpdate","beforeRender","layerModelNeedUpdate","bottomColor","getBottomColor","attributes","getLayerStyleAttributes","filter","getLayerStyleAttribute","dataArray","data","attributesToRemapping","attribute","needRemapping","filterData","scale","record","applyAttributeMapping","length","setEncodedData","mapping","undefined","getEncodedData","emit","p1","p2","dir","normalizeDir","arrowPoint","predata","minimumColor","getLayerConfig","arrow","enable","mappedData","map","i","preRecord","encodeRecord","id","_id","coordinates","forEach","values","name","c","Array","isArray","shape","fontService","getIconFontKey","coords","getArrowPoints","splice","adjustData2Amap2Coordinates","adjustData2SimpleCoordinates","mapService","version","Version","layerCenter","getLayerCenter","d","originCoordinates","lngLatToCoordByLayer","lngLatToCoordsByLayer","center","SIMPLE","simpleCoordinate","unProjectCoordinates","simpleMapCoord","unproject","coord","c1","co","push","scalers","params","field","hasOwnProperty","type","mappingResult"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAAA;;AAcA;;AACA;;AACA;;AAEA;;;;;;;;IAIqBA,iB,WADpB,4B,UAEE,uBAAOC,cAAMC,oBAAb,C,UAGA,uBAAOD,cAAME,WAAb,C,UAGA,uBAAOF,cAAMG,YAAb,C;;;;;;;;;;WAGD,eACEC,KADF,QAKE;AAAA;;AAAA,UAFEC,qBAEF,QAFEA,qBAEF;AACAD,MAAAA,KAAK,CAACE,KAAN,CAAYC,IAAZ,CAAiBC,GAAjB,CAAqB,mBAArB,EAA0C,YAAM;AAE9C,YAAMC,MAAM,GAAGL,KAAK,CAACM,SAAN,EAAf;;AACA,YAAID,MAAM,CAACE,MAAX,EAAmB;AACjB,UAAA,KAAI,CAACC,cAAL,CAAoBR,KAApB,EAA2B;AAAEC,YAAAA,qBAAqB,EAArBA;AAAF,WAA3B;AACD,SAFD,MAEO;AACLI,UAAAA,MAAM,CAACI,IAAP,CAAY,cAAZ,EAA4B,YAAM;AAChC,YAAA,KAAI,CAACD,cAAL,CAAoBR,KAApB,EAA2B;AAAEC,cAAAA,qBAAqB,EAArBA;AAAF,aAA3B;AACD,WAFD;AAGD;AAEF,OA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GpE,SAAS,CAACQ,OAAV,GAAoBR,SAAS,CAACQ,OAAV,CAAkBwD,MAAlB,CAApB,GAAgD,EAAtE;;AACA,UAAIhE,SAAS,CAACgC,IAAV,KAAmB,OAAnB,IAA8B,CAAC,sBAAQoC,aAAa,CAAC,CAAD,CAArB,CAAnC,EAA8D;AAC5D,eAAO,CAAClD,YAAD,CAAP;AACD;;AACD,aAAOkD,aAAP;AAED","sourcesContent":["import {\n IEncodeFeature,\n IFontService,\n IGlobalConfigService,\n ILayer,\n ILayerPlugin,\n ILngLat,\n IMapService,\n IParseDataItem,\n IStyleAttribute,\n IStyleAttributeService,\n Position,\n TYPES,\n} from '@antv/l7-core';\nimport { Version } from '@antv/l7-maps';\nimport { isColor, normalize, rgb2arr, unProjectFlat } from '@antv/l7-utils';\nimport { inject, injectable } from 'inversify';\nimport { cloneDeep } from 'lodash';\nimport 'reflect-metadata';\nimport { ILineLayerStyleOptions } from '../core/interface';\n\n@injectable()\nexport default class DataMappingPlugin implements ILayerPlugin {\n @inject(TYPES.IGlobalConfigService)\n private readonly configService: IGlobalConfigService;\n\n @inject(TYPES.IMapService)\n private readonly mapService: IMapService;\n\n @inject(TYPES.IFontService)\n private readonly fontService: IFontService;\n\n public apply(\n layer: ILayer,\n {\n styleAttributeService,\n }: { styleAttributeService: IStyleAttributeService },\n ) {\n layer.hooks.init.tap('DataMappingPlugin', () => {\n // 初始化重新生成 map\n const source = layer.getSource();\n if (source.inited) {\n this.generateMaping(layer, { styleAttributeService });\n } else {\n source.once('sourceUpdate', () => {\n this.generateMaping(layer, { styleAttributeService });\n });\n }\n // this.generateMaping(layer, { styleAttributeService });\n });\n\n layer.hooks.beforeRenderData.tap('DataMappingPlugin', () => {\n layer.dataState.dataMappingNeedUpdate = false;\n const source = layer.getSource();\n if (source.inited) {\n this.generateMaping(layer, { styleAttributeService });\n } else {\n source.once('sourceUpdate', () => {\n this.generateMaping(layer, { styleAttributeService });\n });\n }\n\n // this.generateMaping(layer, { styleAttributeService });\n\n return true;\n });\n\n // remapping before render\n layer.hooks.beforeRender.tap('DataMappingPlugin', () => {\n const source = layer.getSource();\n if (layer.layerModelNeedUpdate || !source || !source.inited) {\n return;\n }\n const bottomColor = layer.getBottomColor();\n const attributes = styleAttributeService.getLayerStyleAttributes() || [];\n const filter = styleAttributeService.getLayerStyleAttribute('filter');\n const { dataArray } = source.data;\n\n const attributesToRemapping = attributes.filter(\n (attribute) => attribute.needRemapping, // 如果filter变化\n );\n let filterData = dataArray;\n\n // 数据过滤完 再执行数据映射\n if (filter?.needRemapping && filter?.scale) {\n filterData = dataArray.filter((record: IParseDataItem) => {\n return this.applyAttributeMapping(filter, record, bottomColor)[0];\n });\n }\n\n if (attributesToRemapping.length) {\n // 过滤数据\n if (filter?.needRemapping) {\n layer.setEncodedData(\n this.mapping(layer, attributes, filterData, undefined, bottomColor),\n );\n filter.needRemapping = false;\n } else {\n layer.setEncodedData(\n this.mapping(\n layer,\n attributesToRemapping,\n filterData,\n layer.getEncodedData(),\n bottomColor,\n ),\n );\n }\n // 处理文本更新\n layer.emit('remapping', null);\n }\n });\n }\n private generateMaping(\n layer: ILayer,\n {\n styleAttributeService,\n }: { styleAttributeService: IStyleAttributeService },\n ) {\n const bottomColor = layer.getBottomColor();\n const attributes = styleAttributeService.getLayerStyleAttributes() || [];\n const filter = styleAttributeService.getLayerStyleAttribute('filter');\n const { dataArray } = layer.getSource().data;\n let filterData = dataArray;\n // 数据过滤完 再执行数据映射\n if (filter?.scale) {\n filterData = dataArray.filter((record: IParseDataItem) => {\n return this.applyAttributeMapping(filter, record, bottomColor)[0];\n });\n }\n layer.setEncodedData(\n this.mapping(layer, attributes, filterData, undefined, bottomColor),\n );\n // 对外暴露事件\n layer.emit('dataUpdate', null);\n }\n\n private getArrowPoints(p1: Position, p2: Position) {\n const dir = [p2[0] - p1[0], p2[1] - p1[1]];\n const normalizeDir = normalize(dir);\n const arrowPoint = [\n p1[0] + normalizeDir[0] * 0.0001,\n p1[1] + normalizeDir[1] * 0.0001,\n ];\n return arrowPoint;\n }\n\n private mapping(\n layer: ILayer,\n attributes: IStyleAttribute[],\n data: IParseDataItem[],\n predata?: IEncodeFeature[],\n minimumColor?: string,\n ): IEncodeFeature[] {\n const {\n arrow = {\n enable: false,\n },\n } = layer.getLayerConfig() as ILineLayerStyleOptions;\n const mappedData = data.map((record: IParseDataItem, i) => {\n const preRecord = predata ? predata[i] : {};\n const encodeRecord: IEncodeFeature = {\n id: record._id,\n coordinates: record.coordinates,\n ...preRecord,\n };\n attributes\n .filter((attribute) => attribute.scale !== undefined)\n .forEach((attribute: IStyleAttribute) => {\n // console.log('record', record)\n let values = this.applyAttributeMapping(\n attribute,\n record,\n minimumColor,\n );\n // console.log('values', values)\n attribute.needRemapping = false;\n\n // TODO: 支持每个属性配置 postprocess\n if (attribute.name === 'color') {\n // console.log('attribute', attribute)\n values = values.map((c: unknown) => {\n return rgb2arr(c as string);\n });\n }\n // @ts-ignore\n encodeRecord[attribute.name] =\n Array.isArray(values) && values.length === 1 ? values[0] : values;\n\n // 增加对 layer/text/iconfont unicode 映射的解析\n if (attribute.name === 'shape') {\n encodeRecord.shape = this.fontService.getIconFontKey(\n encodeRecord[attribute.name] as string,\n );\n }\n });\n\n if (\n arrow.enable &&\n (encodeRecord.shape === 'line' || encodeRecord.shape === 'halfLine')\n ) {\n // 只有在线图层且支持配置箭头的时候进行插入顶点的处理\n const coords = encodeRecord.coordinates as Position[];\n const arrowPoint = this.getArrowPoints(coords[0], coords[1]);\n encodeRecord.coordinates.splice(1, 0, arrowPoint, arrowPoint);\n }\n return encodeRecord;\n }) as IEncodeFeature[];\n // console.log('mappedData', mappedData)\n\n // 调整数据兼容 Amap2.0\n this.adjustData2Amap2Coordinates(mappedData, layer);\n\n // 调整数据兼容 SimpleCoordinates\n this.adjustData2SimpleCoordinates(mappedData);\n\n return mappedData;\n }\n\n private adjustData2Amap2Coordinates(\n mappedData: IEncodeFeature[],\n layer: ILayer,\n ) {\n // 根据地图的类型判断是否需要对点位数据进行处理, 若是高德2.0则需要对坐标进行相对偏移\n if (\n mappedData.length > 0 &&\n this.mapService.version === Version['GAODE2.x']\n ) {\n const layerCenter = this.getLayerCenter(layer);\n if (typeof mappedData[0].coordinates[0] === 'number') {\n // 单个的点数据\n // @ts-ignore\n mappedData\n // TODO: 避免经纬度被重复计算导致坐标位置偏移\n .filter((d) => !d.originCoordinates)\n .map((d) => {\n d.version = Version['GAODE2.x'];\n // @ts-ignore\n d.originCoordinates = cloneDeep(d.coordinates); // 为了兼容高德1.x 需要保存一份原始的经纬度坐标数据(许多上层逻辑依赖经纬度数据)\n // @ts-ignore\n // d.coordinates = this.mapService.lngLatToCoord(d.coordinates);\n d.coordinates = this.mapService.lngLatToCoordByLayer(\n d.coordinates,\n layerCenter,\n );\n });\n } else {\n // 连续的线、面数据\n // @ts-ignore\n mappedData\n // TODO: 避免经纬度被重复计算导致坐标位置偏移\n .filter((d) => !d.originCoordinates)\n .map((d) => {\n d.version = Version['GAODE2.x'];\n // @ts-ignore\n d.originCoordinates = cloneDeep(d.coordinates); // 为了兼容高德1.x 需要保存一份原始的经纬度坐标数据(许多上层逻辑依赖经纬度数据)\n // @ts-ignore\n // d.coordinates = this.mapService.lngLatToCoords(d.coordinates);\n d.coordinates = this.mapService.lngLatToCoordsByLayer(\n d.coordinates,\n layerCenter,\n );\n });\n }\n }\n }\n\n private getLayerCenter(layer: ILayer) {\n const source = layer.getSource();\n return source.center;\n }\n\n private adjustData2SimpleCoordinates(mappedData: IEncodeFeature[]) {\n if (mappedData.length > 0 && this.mapService.version === Version.SIMPLE) {\n mappedData.map((d) => {\n if (!d.simpleCoordinate) {\n d.coordinates = this.unProjectCoordinates(d.coordinates);\n d.simpleCoordinate = true;\n }\n });\n }\n }\n\n private unProjectCoordinates(coordinates: any) {\n if (typeof coordinates[0] === 'number') {\n return this.mapService.simpleMapCoord.unproject(\n coordinates as [number, number],\n );\n }\n\n if (coordinates[0] && coordinates[0][0] instanceof Array) {\n // @ts-ignore\n const coords = [];\n coordinates.map((coord: any) => {\n // @ts-ignore\n const c1 = [];\n coord.map((co: any) => {\n c1.push(\n this.mapService.simpleMapCoord.unproject(co as [number, number]),\n );\n });\n // @ts-ignore\n coords.push(c1);\n });\n // @ts-ignore\n return coords;\n } else {\n // @ts-ignore\n const coords = [];\n // @ts-ignore\n coordinates.map((coord) => {\n coords.push(\n this.mapService.simpleMapCoord.unproject(coord as [number, number]),\n );\n });\n // @ts-ignore\n return coords;\n }\n }\n\n private applyAttributeMapping(\n attribute: IStyleAttribute,\n record: { [key: string]: unknown },\n minimumColor?: string,\n ) {\n if (!attribute.scale) {\n return [];\n }\n const scalers = attribute?.scale?.scalers || [];\n const params: unknown[] = [];\n\n scalers.forEach(({ field }) => {\n if (\n record.hasOwnProperty(field) ||\n attribute.scale?.type === 'variable'\n ) {\n // TODO:多字段,常量\n params.push(record[field]);\n }\n });\n // console.log('params', params)\n // console.log('attribute', attribute)\n\n const mappingResult = attribute.mapping ? attribute.mapping(params) : [];\n if (attribute.name === 'color' && !isColor(mappingResult[0])) {\n return [minimumColor];\n }\n return mappingResult;\n // return attribute.mapping ? attribute.mapping(params) : [];\n }\n}\n"],"file":"DataMappingPlugin.js"}
|
|
@@ -45,17 +45,26 @@ var DataSourcePlugin = (_dec = (0, _inversify.injectable)(), _dec(_class = funct
|
|
|
45
45
|
var source = layer.getSource();
|
|
46
46
|
|
|
47
47
|
if (!source) {
|
|
48
|
-
var
|
|
48
|
+
var defaultSourceConfig = _l7Source.DEFAULT_SOURCE[layer.type] || {
|
|
49
49
|
data: _l7Source.DEFAULT_DATA,
|
|
50
50
|
options: _l7Source.DEFAULT_PARSER
|
|
51
|
-
}
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
var _ref = layer.sourceOption || defaultSourceConfig,
|
|
52
54
|
data = _ref.data,
|
|
53
55
|
options = _ref.options;
|
|
54
56
|
|
|
55
|
-
|
|
57
|
+
source = new _l7Source.default(data, options);
|
|
58
|
+
layer.setSource(source);
|
|
56
59
|
}
|
|
57
60
|
|
|
58
|
-
|
|
61
|
+
if (source.inited) {
|
|
62
|
+
_this.updateClusterData(layer);
|
|
63
|
+
} else {
|
|
64
|
+
source.once('sourceUpdate', function () {
|
|
65
|
+
_this.updateClusterData(layer);
|
|
66
|
+
});
|
|
67
|
+
}
|
|
59
68
|
});
|
|
60
69
|
layer.hooks.beforeRenderData.tap('DataSourcePlugin', function () {
|
|
61
70
|
var neeUpdateCluster = _this.updateClusterData(layer);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/plugins/DataSourcePlugin.ts"],"names":["DataSourcePlugin","layer","mapService","getContainer","get","TYPES","IMapService","hooks","init","tap","source","getSource","
|
|
1
|
+
{"version":3,"sources":["../../src/plugins/DataSourcePlugin.ts"],"names":["DataSourcePlugin","layer","mapService","getContainer","get","TYPES","IMapService","hooks","init","tap","source","getSource","defaultSourceConfig","DEFAULT_SOURCE","type","data","DEFAULT_DATA","options","DEFAULT_PARSER","sourceOption","Source","setSource","inited","updateClusterData","once","beforeRenderData","neeUpdateCluster","dataSourceNeedUpdate","dataState","cluster","clusterOptions","zoom","newZoom","getZoom","Math","floor","abs","clusterZoom"],"mappings":";;;;;;;;;;;;;;;;;AAAA;;AAOA;;AAKA;;AACA;;;;;;;;IAGqBA,gB,WADpB,4B;;;;;;;;WAGC,eAAaC,KAAb,EAA4B;AAAA;;AAC1B,WAAKC,UAAL,GAAkBD,KAAK,CAACE,YAAN,GAAqBC,GAArB,CAAsCC,cAAMC,WAA5C,CAAlB;AACAL,MAAAA,KAAK,CAACM,KAAN,CAAYC,IAAZ,CAAiBC,GAAjB,CAAqB,kBAArB,EAAyC,YAAM;AAC7C,YAAIC,MAAM,GAAGT,KAAK,CAACU,SAAN,EAAb;;AACA,YAAI,CAACD,MAAL,EAAa;AAEX,cAAME,mBAAmB,GAAGC,yBAC1BZ,KAAK,CAACa,IADoB,KAEvB;AACHC,YAAAA,IAAI,EAAEC,sBADH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;;AACA,UAAIE,OAAO,IAAIF,oBAAf,EAAqC;AAEnCjB,QAAAA,MAAM,CAACa,iBAAP,CAAyBW,IAAI,CAACC,KAAL,CAAWH,OAAX,CAAzB;AACD;;AAED,UAAIH,OAAO,IAAIK,IAAI,CAACE,GAAL,CAASnC,KAAK,CAACoC,WAAN,GAAoBL,OAA7B,KAAyC,CAAxD,EAA2D;AACzD,YAAID,IAAI,KAAKG,IAAI,CAACC,KAAL,CAAWH,OAAX,CAAb,EAAkC;AAChCtB,UAAAA,MAAM,CAACa,iBAAP,CAAyBW,IAAI,CAACC,KAAL,CAAWH,OAAX,CAAzB;AACD;;AACD/B,QAAAA,KAAK,CAACoC,WAAN,GAAoBL,OAApB;AACA,eAAO,IAAP;AACD;;AACD,aAAO,KAAP;AACD","sourcesContent":["import {\n ILayer,\n ILayerPlugin,\n ILngLat,\n IMapService,\n TYPES,\n} from '@antv/l7-core';\nimport Source, {\n DEFAULT_DATA,\n DEFAULT_PARSER,\n DEFAULT_SOURCE,\n} from '@antv/l7-source';\nimport { injectable } from 'inversify';\nimport 'reflect-metadata';\n\n@injectable()\nexport default class DataSourcePlugin implements ILayerPlugin {\n protected mapService: IMapService;\n public apply(layer: ILayer) {\n this.mapService = layer.getContainer().get<IMapService>(TYPES.IMapService);\n layer.hooks.init.tap('DataSourcePlugin', () => {\n let source = layer.getSource();\n if (!source) {\n // TODO: 允许用户不使用 layer 的 source 方法,在这里传入一个默认的替换的默认数据\n const defaultSourceConfig = DEFAULT_SOURCE[\n layer.type as 'PointLayer' | 'LineLayer'\n ] || {\n data: DEFAULT_DATA,\n options: DEFAULT_PARSER,\n };\n const { data, options } = layer.sourceOption || defaultSourceConfig;\n source = new Source(data, options);\n layer.setSource(source);\n }\n if (source.inited) {\n this.updateClusterData(layer);\n } else {\n source.once('sourceUpdate', () => {\n this.updateClusterData(layer);\n // TODO: layer.hooks.init.call();\n });\n }\n // this.updateClusterData(layer);\n });\n\n // 检测数据是否需要更新\n layer.hooks.beforeRenderData.tap('DataSourcePlugin', () => {\n const neeUpdateCluster = this.updateClusterData(layer);\n const dataSourceNeedUpdate = layer.dataState.dataSourceNeedUpdate;\n layer.dataState.dataSourceNeedUpdate = false;\n return neeUpdateCluster || dataSourceNeedUpdate;\n });\n }\n\n private updateClusterData(layer: ILayer): boolean {\n const source = layer.getSource();\n const cluster = source.cluster;\n const { zoom = 0 } = source.clusterOptions;\n const newZoom = this.mapService.getZoom() - 1;\n const dataSourceNeedUpdate = layer.dataState.dataSourceNeedUpdate;\n if (cluster && dataSourceNeedUpdate) {\n // 数据发生更新\n source.updateClusterData(Math.floor(newZoom));\n }\n // 如果 dataSource 有更新,跳过 zoom 的判断,直接更新一次\n if (cluster && Math.abs(layer.clusterZoom - newZoom) >= 1) {\n if (zoom !== Math.floor(newZoom)) {\n source.updateClusterData(Math.floor(newZoom));\n }\n layer.clusterZoom = newZoom;\n return true;\n }\n return false;\n }\n}\n"],"file":"DataSourcePlugin.js"}
|
|
@@ -23,18 +23,46 @@ var LayerModelPlugin = (_dec = (0, _inversify.injectable)(), _dec(_class = funct
|
|
|
23
23
|
}
|
|
24
24
|
|
|
25
25
|
(0, _createClass2.default)(LayerModelPlugin, [{
|
|
26
|
+
key: "initLayerModel",
|
|
27
|
+
value: function initLayerModel(layer) {
|
|
28
|
+
layer.prepareBuildModel();
|
|
29
|
+
layer.buildModels();
|
|
30
|
+
layer.emit('modelLoaded', null);
|
|
31
|
+
layer.styleNeedUpdate = false;
|
|
32
|
+
}
|
|
33
|
+
}, {
|
|
34
|
+
key: "prepareLayerModel",
|
|
35
|
+
value: function prepareLayerModel(layer) {
|
|
36
|
+
layer.prepareBuildModel();
|
|
37
|
+
layer.clearModels();
|
|
38
|
+
layer.buildModels();
|
|
39
|
+
layer.emit('modelLoaded', null);
|
|
40
|
+
layer.layerModelNeedUpdate = false;
|
|
41
|
+
}
|
|
42
|
+
}, {
|
|
26
43
|
key: "apply",
|
|
27
44
|
value: function apply(layer) {
|
|
45
|
+
var _this = this;
|
|
46
|
+
|
|
28
47
|
layer.hooks.init.tap('LayerModelPlugin', function () {
|
|
29
|
-
layer.
|
|
30
|
-
layer.
|
|
31
|
-
|
|
48
|
+
layer.inited = true;
|
|
49
|
+
var source = layer.getSource();
|
|
50
|
+
|
|
51
|
+
if (source.inited) {
|
|
52
|
+
_this.initLayerModel(layer);
|
|
53
|
+
}
|
|
32
54
|
});
|
|
33
55
|
layer.hooks.beforeRenderData.tap('DataSourcePlugin', function () {
|
|
34
|
-
layer.
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
56
|
+
var source = layer.getSource();
|
|
57
|
+
|
|
58
|
+
if (source.inited) {
|
|
59
|
+
_this.prepareLayerModel(layer);
|
|
60
|
+
} else {
|
|
61
|
+
source.once('sourceUpdate', function () {
|
|
62
|
+
_this.prepareLayerModel(layer);
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
|
|
38
66
|
return false;
|
|
39
67
|
});
|
|
40
68
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/plugins/LayerModelPlugin.ts"],"names":["LayerModelPlugin","layer","hooks","init","tap","
|
|
1
|
+
{"version":3,"sources":["../../src/plugins/LayerModelPlugin.ts"],"names":["LayerModelPlugin","layer","prepareBuildModel","buildModels","emit","styleNeedUpdate","clearModels","layerModelNeedUpdate","hooks","init","tap","inited","source","getSource","initLayerModel","beforeRenderData","prepareLayerModel","once"],"mappings":";;;;;;;;;;;;;AACA;;AACA;;;;IAKqBA,gB,WADpB,4B;;;;;;;WAEC,wBAAsBC,KAAtB,EAAqC;AAEnCA,MAAAA,KAAK,CAACC,iBAAN;AAEAD,MAAAA,KAAK,CAACE,WAAN;AAEAF,MAAAA,KAAK,CAACG,IAAN,CAAW,aAAX,EAA0B,IAA1B;AACAH,MAAAA,KAAK,CAACI,eAAN,GAAwB,KAAxB;AACD;;;WAED,2BAAyBJ,KAAzB,EAAwC;AAEtCA,MAAAA,KAAK,CAACC,iBAAN;AACAD,MAAAA,KAAK,CAACK,WAAN;AAEAL,MAAAA,KAAK,CAACE,WAAN;AAEAF,MAAAA,KAAK,CAACG,IAAN,CAAW,aAAX,EAA0B,IAA1B;AACAH,MAAAA,KAAK,CAACM,oBAAN,GAA6B,KAA7B;AACD;;;WAED,eAAaN,KAAb,EAA4B;AAAA;;AAC1BA,MAAAA,KAAK,CAACO,KAAN,CAAYC,IAAZ,CAAiBC,GAAjB,CAAqB,kBAArB,EAAyC,YAAM;AAC7CT,QAAAA,KAAK,CAACU,MAAN,GAAe,IAAf;AACA,YAAMC,MAAM,GAAGX,KAAK,CAACY,SAAN,EAAf;;AACA,YAAID,MAAM,CAACD,MAAX,EAAmB;AACjB,UAAA,KAAI,CAACG,cAAL,CAAoBb,KAApB;AACD;AACF,OAND;AAQAA,MAAAA,KAAK,CAACO,KAAN,CAAYO,gBAAZ,CAA6BL,GAA7B,CAAiC,kBAAjC,EAAqD,YAAM;AACzD,YAAME,MAAM,GAAGX,KAAK,CAACY,SAAN,EAAf;;AACA,YAAID,MAAM,CAACD,MAAX,EAAmB;AACjB,UAAA,KAAI,CAACK,iBAAL,CAAuBf,KAAvB;AACD,SAFD,MAEO;AACLW,UAAAA,MAAM,CAACK,IAAP,CAAY,cAAZ,EAA4B,YAAM;AAChC,YAAA,KAAI,CAACD,iBAAL,CAAuBf,KAAvB;AACD,WAFD;AAGD;;AACD,eAAO,KAAP;AACD,OAVD;AAWD","sourcesContent":["import { ILayer, ILayerPlugin, IMapService, TYPES } from '@antv/l7-core';\nimport { injectable } from 'inversify';\nimport 'reflect-metadata';\n/**\n * Layer Model 初始化,更新,销毁\n */\n@injectable()\nexport default class LayerModelPlugin implements ILayerPlugin {\n public initLayerModel(layer: ILayer) {\n // 更新Model 配置项\n layer.prepareBuildModel();\n // 初始化 Model\n layer.buildModels();\n // emit layer model loaded\n layer.emit('modelLoaded', null);\n layer.styleNeedUpdate = false;\n }\n\n public prepareLayerModel(layer: ILayer) {\n // 更新Model 配置项\n layer.prepareBuildModel();\n layer.clearModels();\n // 初始化 Model\n layer.buildModels();\n // emit layer model loaded\n layer.emit('modelLoaded', null);\n layer.layerModelNeedUpdate = false;\n }\n\n public apply(layer: ILayer) {\n layer.hooks.init.tap('LayerModelPlugin', () => {\n layer.inited = true;\n const source = layer.getSource();\n if (source.inited) {\n this.initLayerModel(layer);\n }\n });\n\n layer.hooks.beforeRenderData.tap('DataSourcePlugin', () => {\n const source = layer.getSource();\n if (source.inited) {\n this.prepareLayerModel(layer);\n } else {\n source.once('sourceUpdate', () => {\n this.prepareLayerModel(layer);\n });\n }\n return false;\n });\n }\n}\n"],"file":"LayerModelPlugin.js"}
|