Skip to content

Commit

Permalink
feat: rasterTile support extent (#2630)
Browse files Browse the repository at this point in the history
* feat: rasterTile support extent

* fix: eslint fixed

* chore: commit changeset

* fix: eslint fixed

---------

Co-authored-by: duxinyue.dxy <[email protected]>
  • Loading branch information
XinyueDu and duxinyue.dxy authored Nov 5, 2024
1 parent d71e8c7 commit 1d5c5fa
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 1 deletion.
6 changes: 6 additions & 0 deletions .changeset/thick-wombats-lie.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'@antv/l7-source': major
'@antv/l7-core': major
---

rasterTile support extent
1 change: 1 addition & 0 deletions packages/core/src/services/source/ISourceService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<RequestParameters>;
updateStrategy?: 'overlap' | 'replace';
// 指定 feature 编码 id
Expand Down
13 changes: 12 additions & 1 deletion packages/source/src/parser/raster-tile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<TilesetManagerOptions> = {
tileSize: 256,
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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,
};
Expand Down

0 comments on commit 1d5c5fa

Please sign in to comment.