diff --git a/.changeset/thick-wombats-lie.md b/.changeset/thick-wombats-lie.md new file mode 100644 index 0000000000..7fa9523b59 --- /dev/null +++ b/.changeset/thick-wombats-lie.md @@ -0,0 +1,6 @@ +--- +'@antv/l7-source': major +'@antv/l7-core': major +--- + +rasterTile support extent diff --git a/packages/core/src/services/source/ISourceService.ts b/packages/core/src/services/source/ISourceService.ts index e432850ef4..7559490963 100644 --- a/packages/core/src/services/source/ISourceService.ts +++ b/packages/core/src/services/source/ISourceService.ts @@ -38,6 +38,7 @@ export interface ITileParserCFG { cb: (err: any, data: any) => void, ) => void; extent?: [number, number, number, number]; + coordinates?: [[number, number], [number, number], [number, number], [number, number]]; requestParameters: Partial; updateStrategy?: 'overlap' | 'replace'; // 指定 feature 编码 id diff --git a/packages/source/src/parser/raster-tile.ts b/packages/source/src/parser/raster-tile.ts index 01d83988be..259b0ab00a 100644 --- a/packages/source/src/parser/raster-tile.ts +++ b/packages/source/src/parser/raster-tile.ts @@ -4,6 +4,7 @@ import type { ITileBand, SourceTile, TileLoadParams, TilesetManagerOptions } fro import type { IParserData } from '../interface'; import { getCustomData, getCustomImageData } from '../utils/tile/getCustomData'; import { defaultFormat, getTileBuffer, getTileImage } from '../utils/tile/getRasterTile'; +import { extentToCoord } from '../utils/util'; const DEFAULT_CONFIG: Partial = { tileSize: 256, @@ -37,6 +38,9 @@ export default function rasterTile( if (isUrlError(data)) { throw new Error('tile server url is error'); } + + const { extent = [Infinity, Infinity, -Infinity, -Infinity], coordinates } = cfg; + let tileDataType: RasterTileType = cfg?.dataType || RasterTileType.IMAGE; // Tip: RasterTileType.RGB 是彩色多通道的数据纹理,同样走数据纹理的请求 if (tileDataType === RasterTileType.RGB) { @@ -69,11 +73,18 @@ export default function rasterTile( return getTileImage(data as string | string[], tileParams, tile, cfg); } }; + const tilesetOptions = { ...DEFAULT_CONFIG, ...cfg, getTileData }; + const rasterTileCoord = extentToCoord(coordinates, extent); return { data, - dataArray: [], + dataArray: [ + { + _id: 1, + coordinates: rasterTileCoord, + }, + ], tilesetOptions, isTile: true, };