mirror of https://gitee.com/antv-l7/antv-l7
fix: 合并冲突
This commit is contained in:
commit
b31b804194
|
@ -75,8 +75,8 @@ export default () => {
|
|||
.then((res) => res.json())
|
||||
.then((maskData) => {
|
||||
const layer = new RasterLayer({
|
||||
mask: true,
|
||||
maskfence: maskData,
|
||||
// mask: true,
|
||||
// maskfence: maskData,
|
||||
});
|
||||
|
||||
const tileSource = new Source(
|
||||
|
|
|
@ -1,26 +1,44 @@
|
|||
import { ILayer, ILngLat, IRendererService } from '@antv/l7-core';
|
||||
import { SourceTile } from '@antv/l7-utils';
|
||||
import { ILayer, ILngLat, IRendererService, ITexture2D } from '@antv/l7-core';
|
||||
import { SourceTile, IColorRamp } from '@antv/l7-utils';
|
||||
import 'reflect-metadata';
|
||||
import Tile from '../tileFactory/Tile';
|
||||
import { createColorTexture } from '../style/utils';
|
||||
|
||||
interface TileLayerServiceOptions {
|
||||
rendererService: IRendererService;
|
||||
parent:ILayer;
|
||||
}
|
||||
|
||||
interface ITileLayerStyleOptions {
|
||||
rampColors?: IColorRamp;
|
||||
}
|
||||
|
||||
|
||||
export class TileLayerService {
|
||||
private rendererService: IRendererService;
|
||||
private parent: ILayer;
|
||||
|
||||
public colorTexture: ITexture2D; // 颜色纹理,被栅格瓦片共用
|
||||
|
||||
private _tiles: Tile[] = [];
|
||||
constructor({ rendererService, parent }: TileLayerServiceOptions) {
|
||||
this.rendererService = rendererService;
|
||||
this.parent = parent;
|
||||
// 初始化全局资源
|
||||
this.initGlobalResource();
|
||||
}
|
||||
get tiles():Tile[] {
|
||||
return this.tiles;
|
||||
}
|
||||
|
||||
// 初始化全局资源 - 所有瓦片共用的资源
|
||||
initGlobalResource() {
|
||||
const { rampColors } = this.parent.getLayerConfig() as ITileLayerStyleOptions;
|
||||
if(rampColors) {
|
||||
this.colorTexture = createColorTexture(rampColors, this.rendererService);
|
||||
}
|
||||
}
|
||||
|
||||
hasTile(tileKey: string): boolean {
|
||||
return this._tiles.some((tile) => tile.key === tileKey);
|
||||
}
|
||||
|
|
|
@ -7,6 +7,18 @@ import {
|
|||
|
||||
import { generateColorRamp, IColorRamp } from '@antv/l7-utils';
|
||||
|
||||
export function createColorTexture(config: IColorRamp, rendererService: IRendererService){
|
||||
const { createTexture2D } = rendererService;
|
||||
const imageData = generateColorRamp(config) as ImageData;
|
||||
const texture = createTexture2D({
|
||||
data: imageData.data,
|
||||
width: imageData.width,
|
||||
height: imageData.height,
|
||||
flipY: false,
|
||||
});
|
||||
return texture;
|
||||
}
|
||||
|
||||
export function updateTexture(config: IColorRamp, layers: ILayer[], rendererService: IRendererService) {
|
||||
const { createTexture2D } = rendererService;
|
||||
const imageData = generateColorRamp(config) as ImageData;
|
||||
|
|
|
@ -1,13 +1,16 @@
|
|||
import { ILayerAttributesOption } from '@antv/l7-core';
|
||||
import { getTileLayer } from './util';
|
||||
import RasterLayer from './layers/rasterDataLayer';
|
||||
import Tile from './Tile';
|
||||
export default class RasterTile extends Tile {
|
||||
public async initTileLayer(): Promise<void> {
|
||||
const attributes = this.parent.getLayerAttributeConfig();
|
||||
const layerOptions = this.parent.getLayerConfig();
|
||||
const rasterLayer = getTileLayer(this.parent.type);
|
||||
const sourceOptions = this.getSourceOption();
|
||||
const layer = new rasterLayer({...layerOptions}).source(
|
||||
const layer = new RasterLayer({
|
||||
...layerOptions,
|
||||
colorTexture: this.tileLayerService.colorTexture,
|
||||
})
|
||||
.source(
|
||||
sourceOptions.data,
|
||||
sourceOptions.options,
|
||||
);
|
||||
|
|
|
@ -6,18 +6,21 @@ import {
|
|||
} from '@antv/l7-core';
|
||||
import { SourceTile } from '@antv/l7-utils';
|
||||
import { Container } from 'inversify';
|
||||
import { TileLayerService } from '../service/TileLayerService';
|
||||
export default abstract class Tile {
|
||||
public x: number;
|
||||
public y: number;
|
||||
public z: number;
|
||||
public key: string;
|
||||
protected parent: ILayer;
|
||||
protected tileLayerService: TileLayerService;
|
||||
protected sourceTile: SourceTile;
|
||||
public visible: boolean = true;
|
||||
protected layers: ILayer[] = [];
|
||||
public isLoaded: boolean = false;
|
||||
constructor(sourceTile: SourceTile, parent: ILayer) {
|
||||
constructor(sourceTile: SourceTile, parent: ILayer, tileLayerService: TileLayerService) {
|
||||
this.parent = parent;
|
||||
this.tileLayerService = tileLayerService;
|
||||
this.sourceTile = sourceTile;
|
||||
this.x = sourceTile.x;
|
||||
this.y = sourceTile.y;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
|
||||
import { PointLayer, PolygonLayer, LineLayer, RasterLayer} from '@antv/l7-layers'
|
||||
import { PointLayer, PolygonLayer, LineLayer} from '@antv/l7-layers'
|
||||
export function getTileLayer(type:string) {
|
||||
if(type === 'PolygonLayer') {
|
||||
return PolygonLayer;
|
||||
|
@ -10,9 +10,6 @@ export function getTileLayer(type:string) {
|
|||
if(type === 'PointLayer') {
|
||||
return PointLayer
|
||||
}
|
||||
if(type === 'RasterLayer') {
|
||||
return RasterLayer;
|
||||
}
|
||||
return PointLayer
|
||||
|
||||
}
|
|
@ -148,12 +148,12 @@ export class Base {
|
|||
.map(async (tile: SourceTile) => {
|
||||
if (!this.tileLayerService.hasTile(tile.key)) {
|
||||
const tileInstance = getTileFactory(this.parent);
|
||||
const tileLayer = new tileInstance(tile, this.parent);
|
||||
const tileLayer = new tileInstance(tile, this.parent, this.tileLayerService);
|
||||
await tileLayer.initTileLayer();
|
||||
this.tileLayerService.addTile(tileLayer);
|
||||
this.layerService.reRender()
|
||||
} else {
|
||||
|
||||
|
||||
this.tileLayerService.updateTileVisible(tile);
|
||||
this.layerService.reRender()
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue