From 00005f1147842a21917d4057d5b697b465259a46 Mon Sep 17 00:00:00 2001 From: YiQianYao <42212176+2912401452@users.noreply.github.com> Date: Mon, 23 May 2022 18:31:20 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=8F=91=E5=B8=83=E6=89=93=E5=8C=85?= =?UTF-8?q?=E4=BB=A3=E7=A0=81=E8=B0=83=E6=95=B4=20(#1117)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * fix: 修复 mouseup 失效 * chore: update version 2.8.35 -> 2.8.36 * fix: fix bboxPolygon conflict * fix: fix bboxPolygon conflict * feat: add utils turf dependencies * fix: change rollup build config * feat: 替换 turf/bbox-polygon 的引入方式 * feat: add turf bboxpolygon dependencies * feat: change TileLoadParams interface export * style: lint style * feat: change TilesetManagerOptions interface export * style: lint style * feat: rename tilebboxPolygon -> bboxPolygon * feat: rename tilebboxPolygon -> bboxPolygon * fix: 解决 rollup 打包问题 Co-authored-by: yunji --- lerna.json | 15 +++++--- packages/component/package.json | 6 ++-- packages/core/package.json | 4 +-- packages/l7/package.json | 16 ++++----- packages/l7/src/version.ts | 2 +- packages/layers/package.json | 8 ++--- packages/map/package.json | 4 +-- packages/maps/package.json | 8 ++--- packages/mini/package.json | 12 +++---- packages/renderer/package.json | 4 +-- packages/scene/package.json | 14 ++++---- packages/source/package.json | 6 ++-- packages/three/package.json | 8 ++--- packages/utils/package.json | 3 +- packages/utils/src/tileset-manager/const.ts | 4 +-- packages/utils/src/tileset-manager/index.ts | 5 +-- packages/utils/src/tileset-manager/tile.ts | 33 +++++------------- .../src/tileset-manager/tileset-manager.ts | 14 ++------ packages/utils/src/tileset-manager/types.ts | 34 ++++++++++++++++++- .../src/tileset-manager/utils/lonlat-tile.ts | 8 ++--- 20 files changed, 112 insertions(+), 96 deletions(-) diff --git a/lerna.json b/lerna.json index 42bd0a191d..98eee186a6 100644 --- a/lerna.json +++ b/lerna.json @@ -1,14 +1,21 @@ { - "packages": ["packages/*"], + "packages": [ + "packages/*" + ], "command": { "publish": { - "ignoreChanges": ["*.md"], - "allowBranch": ["publish", "docs"], + "ignoreChanges": [ + "*.md" + ], + "allowBranch": [ + "publish", + "docs" + ], "message": "chore: publish", "registry": "https://registry.npmjs.org" } }, - "version": "2.8.35", + "version": "2.8.36", "npmClient": "yarn", "useWorkspaces": true, "publishConfig": { diff --git a/packages/component/package.json b/packages/component/package.json index 1b4b6e4a5c..97fed8661c 100644 --- a/packages/component/package.json +++ b/packages/component/package.json @@ -1,6 +1,6 @@ { "name": "@antv/l7-component", - "version": "2.8.35", + "version": "2.8.36", "description": "", "main": "lib/index.js", "module": "es/index.js", @@ -25,8 +25,8 @@ "author": "lzxue", "license": "ISC", "dependencies": { - "@antv/l7-core": "^2.8.35", - "@antv/l7-utils": "^2.8.35", + "@antv/l7-core": "^2.8.36", + "@antv/l7-utils": "^2.8.36", "@babel/runtime": "^7.7.7", "eventemitter3": "^4.0.0", "inversify": "^5.0.1", diff --git a/packages/core/package.json b/packages/core/package.json index 084a60a04b..6a9e113d2b 100644 --- a/packages/core/package.json +++ b/packages/core/package.json @@ -1,6 +1,6 @@ { "name": "@antv/l7-core", - "version": "2.8.35", + "version": "2.8.36", "description": "", "main": "lib/index.js", "module": "es/index.js", @@ -24,7 +24,7 @@ "license": "ISC", "dependencies": { "@antv/async-hook": "^2.1.0", - "@antv/l7-utils": "^2.8.35", + "@antv/l7-utils": "^2.8.36", "@babel/runtime": "^7.7.7", "ajv": "^6.10.2", "element-resize-event": "^3.0.3", diff --git a/packages/l7/package.json b/packages/l7/package.json index 7037da995e..2554aecfe3 100644 --- a/packages/l7/package.json +++ b/packages/l7/package.json @@ -1,6 +1,6 @@ { "name": "@antv/l7", - "version": "2.8.35", + "version": "2.8.36", "description": "A Large-scale WebGL-powered Geospatial Data Visualization", "main": "lib/index.js", "module": "es/index.js", @@ -25,13 +25,13 @@ "author": "antv", "license": "MIT", "dependencies": { - "@antv/l7-component": "^2.8.35", - "@antv/l7-core": "^2.8.35", - "@antv/l7-layers": "^2.8.35", - "@antv/l7-maps": "^2.8.35", - "@antv/l7-scene": "^2.8.35", - "@antv/l7-source": "^2.8.35", - "@antv/l7-utils": "^2.8.35", + "@antv/l7-component": "^2.8.36", + "@antv/l7-core": "^2.8.36", + "@antv/l7-layers": "^2.8.36", + "@antv/l7-maps": "^2.8.36", + "@antv/l7-scene": "^2.8.36", + "@antv/l7-source": "^2.8.36", + "@antv/l7-utils": "^2.8.36", "@babel/runtime": "^7.7.7" }, "gitHead": "684ba4eb806a798713496d3fc0b4d1e17517dc31", diff --git a/packages/l7/src/version.ts b/packages/l7/src/version.ts index 10a79f95d2..e7249fbe0d 100644 --- a/packages/l7/src/version.ts +++ b/packages/l7/src/version.ts @@ -1,2 +1,2 @@ -const version = '2.8.35'; +const version = '2.8.36'; export { version }; diff --git a/packages/layers/package.json b/packages/layers/package.json index 24af95390b..4b970b08d9 100644 --- a/packages/layers/package.json +++ b/packages/layers/package.json @@ -1,6 +1,6 @@ { "name": "@antv/l7-layers", - "version": "2.8.35", + "version": "2.8.36", "description": "L7's collection of built-in layers", "main": "lib/index.js", "module": "es/index.js", @@ -23,9 +23,9 @@ "author": "xiaoiver", "license": "ISC", "dependencies": { - "@antv/l7-core": "^2.8.35", - "@antv/l7-source": "^2.8.35", - "@antv/l7-utils": "^2.8.35", + "@antv/l7-core": "^2.8.36", + "@antv/l7-source": "^2.8.36", + "@antv/l7-utils": "^2.8.36", "@babel/runtime": "^7.7.7", "@mapbox/martini": "^0.2.0", "@turf/meta": "^6.0.2", diff --git a/packages/map/package.json b/packages/map/package.json index 62ae2e4479..daf315d51b 100644 --- a/packages/map/package.json +++ b/packages/map/package.json @@ -1,6 +1,6 @@ { "name": "@antv/l7-map", - "version": "2.8.35", + "version": "2.8.36", "description": "l7 map", "keywords": [], "author": "thinkinggis ", @@ -37,7 +37,7 @@ }, "homepage": "https://github.com/antvis/L7#readme", "dependencies": { - "@antv/l7-utils": "^2.8.35", + "@antv/l7-utils": "^2.8.36", "@babel/runtime": "^7.7.7", "@mapbox/point-geometry": "^0.1.0", "@mapbox/unitbezier": "^0.0.0", diff --git a/packages/maps/package.json b/packages/maps/package.json index ac126661dd..5da7cb20ec 100644 --- a/packages/maps/package.json +++ b/packages/maps/package.json @@ -1,6 +1,6 @@ { "name": "@antv/l7-maps", - "version": "2.8.35", + "version": "2.8.36", "description": "", "main": "lib/index.js", "module": "es/index.js", @@ -27,9 +27,9 @@ "license": "ISC", "dependencies": { "@amap/amap-jsapi-loader": "^0.0.3", - "@antv/l7-core": "^2.8.35", - "@antv/l7-map": "^2.8.35", - "@antv/l7-utils": "^2.8.35", + "@antv/l7-core": "^2.8.36", + "@antv/l7-map": "^2.8.36", + "@antv/l7-utils": "^2.8.36", "@babel/runtime": "^7.7.7", "@types/amap-js-api": "^1.4.6", "@types/mapbox-gl": "^1.11.2", diff --git a/packages/mini/package.json b/packages/mini/package.json index e29c5f79c8..76a69d6bb3 100644 --- a/packages/mini/package.json +++ b/packages/mini/package.json @@ -1,6 +1,6 @@ { "name": "@antv/l7-mini", - "version": "2.8.35", + "version": "2.8.36", "description": "A Large-scale WebGL-powered Geospatial Data Visualization", "main": "lib/index.js", "module": "es/index.js", @@ -25,11 +25,11 @@ "author": "antv", "license": "MIT", "dependencies": { - "@antv/l7-core": "^2.8.35", - "@antv/l7-layers": "^2.8.35", - "@antv/l7-maps": "^2.8.35", - "@antv/l7-scene": "^2.8.35", - "@antv/l7-utils": "^2.8.35", + "@antv/l7-core": "^2.8.36", + "@antv/l7-layers": "^2.8.36", + "@antv/l7-maps": "^2.8.36", + "@antv/l7-scene": "^2.8.36", + "@antv/l7-utils": "^2.8.36", "@babel/runtime": "^7.7.7" }, "gitHead": "684ba4eb806a798713496d3fc0b4d1e17517dc31", diff --git a/packages/renderer/package.json b/packages/renderer/package.json index 122989bd89..07a5e81d0c 100644 --- a/packages/renderer/package.json +++ b/packages/renderer/package.json @@ -1,6 +1,6 @@ { "name": "@antv/l7-renderer", - "version": "2.8.35", + "version": "2.8.36", "description": "", "main": "lib/index.js", "module": "es/index.js", @@ -26,7 +26,7 @@ "gl": "^4.4.0" }, "dependencies": { - "@antv/l7-core": "^2.8.35", + "@antv/l7-core": "^2.8.36", "@babel/runtime": "^7.7.7", "inversify": "^5.0.1", "l7regl": "^0.0.20", diff --git a/packages/scene/package.json b/packages/scene/package.json index 323ba97c69..4ecee8e428 100644 --- a/packages/scene/package.json +++ b/packages/scene/package.json @@ -1,6 +1,6 @@ { "name": "@antv/l7-scene", - "version": "2.8.35", + "version": "2.8.36", "description": "", "main": "lib/index.js", "module": "es/index.js", @@ -23,12 +23,12 @@ "author": "xiaoiver", "license": "ISC", "dependencies": { - "@antv/l7-component": "^2.8.35", - "@antv/l7-core": "^2.8.35", - "@antv/l7-layers": "^2.8.35", - "@antv/l7-maps": "^2.8.35", - "@antv/l7-renderer": "^2.8.35", - "@antv/l7-utils": "^2.8.35", + "@antv/l7-component": "^2.8.36", + "@antv/l7-core": "^2.8.36", + "@antv/l7-layers": "^2.8.36", + "@antv/l7-maps": "^2.8.36", + "@antv/l7-renderer": "^2.8.36", + "@antv/l7-utils": "^2.8.36", "@babel/runtime": "^7.7.7", "inversify": "^5.0.1", "mapbox-gl": "^1.2.1", diff --git a/packages/source/package.json b/packages/source/package.json index 988cc0727d..3fb25b083f 100644 --- a/packages/source/package.json +++ b/packages/source/package.json @@ -1,6 +1,6 @@ { "name": "@antv/l7-source", - "version": "2.8.35", + "version": "2.8.36", "description": "", "main": "lib/index.js", "module": "es/index.js", @@ -26,8 +26,8 @@ "license": "ISC", "dependencies": { "@antv/async-hook": "^2.1.0", - "@antv/l7-core": "^2.8.35", - "@antv/l7-utils": "^2.8.35", + "@antv/l7-core": "^2.8.36", + "@antv/l7-utils": "^2.8.36", "@babel/runtime": "^7.7.7", "@mapbox/geojson-rewind": "^0.4.0", "@turf/helpers": "^6.1.4", diff --git a/packages/three/package.json b/packages/three/package.json index 4687fcbaa4..99d1464252 100644 --- a/packages/three/package.json +++ b/packages/three/package.json @@ -1,6 +1,6 @@ { "name": "@antv/l7-three", - "version": "2.8.35", + "version": "2.8.36", "description": "three for L7 ", "keywords": [ "3D", @@ -44,9 +44,9 @@ }, "homepage": "https://github.com/antvis/L7#readme", "dependencies": { - "@antv/l7-core": "^2.8.35", - "@antv/l7-layers": "^2.8.35", - "@antv/l7-scene": "^2.8.35", + "@antv/l7-core": "^2.8.36", + "@antv/l7-layers": "^2.8.36", + "@antv/l7-scene": "^2.8.36", "@babel/runtime": "^7.7.7", "inversify": "^5.0.1", "reflect-metadata": "^0.1.13", diff --git a/packages/utils/package.json b/packages/utils/package.json index f365e6f296..93a9bc9975 100644 --- a/packages/utils/package.json +++ b/packages/utils/package.json @@ -1,6 +1,6 @@ { "name": "@antv/l7-utils", - "version": "2.8.35", + "version": "2.8.36", "description": "", "main": "lib/index.js", "module": "es/index.js", @@ -25,6 +25,7 @@ "dependencies": { "@babel/runtime": "^7.7.7", "@turf/helpers": "^6.1.4", + "@turf/bbox-polygon": "^6.5.0", "d3-color": "^1.4.0" }, "devDependencies": { diff --git a/packages/utils/src/tileset-manager/const.ts b/packages/utils/src/tileset-manager/const.ts index 68a17da749..279b7db826 100644 --- a/packages/utils/src/tileset-manager/const.ts +++ b/packages/utils/src/tileset-manager/const.ts @@ -1,11 +1,11 @@ -import { Bounds, UpdateTileStrategy } from './types'; +import { TileBounds, UpdateTileStrategy } from './types'; import { updateTileStateOverlap, updateTileStateReplace, } from './utils/strategies'; export const TILE_SIZE = 256; -export const DEFAULT_EXTENT: Bounds = [ +export const DEFAULT_EXTENT: TileBounds = [ -Infinity, -Infinity, Infinity, diff --git a/packages/utils/src/tileset-manager/index.ts b/packages/utils/src/tileset-manager/index.ts index 7866992826..f44a6d2d69 100644 --- a/packages/utils/src/tileset-manager/index.ts +++ b/packages/utils/src/tileset-manager/index.ts @@ -1,3 +1,4 @@ export * from './utils/tile-url'; -export { Tile, TileLoadParams } from './tile'; -export { TilesetManager, TilesetManagerOptions } from './tileset-manager'; +export * from './types'; +export { Tile } from './tile'; +export { TilesetManager } from './tileset-manager'; diff --git a/packages/utils/src/tileset-manager/tile.ts b/packages/utils/src/tileset-manager/tile.ts index d00528b1d9..51a8a34d47 100644 --- a/packages/utils/src/tileset-manager/tile.ts +++ b/packages/utils/src/tileset-manager/tile.ts @@ -1,27 +1,12 @@ -import { bboxPolygon } from '@turf/turf'; -import { Bounds } from './types'; +import bboxPolygon from '@turf/bbox-polygon'; +import { + LoadTileDataStatus, + TileBounds, + TileLoadDataOptions, + TileOptions, +} from './types'; import { getTileWarpXY, tileToBounds } from './utils/lonlat-tile'; -type TileOptions = { x: number; y: number; z: number; tileSize: number }; - -export type TileLoadParams = TileOptions & { - bounds: Bounds; - signal: AbortSignal; -}; - -type TileLoadDataOptions = { - getData: (tile: TileLoadParams) => Promise; - onLoad: (tile: Tile) => void; - onError: (error: Error, tile: Tile) => void; -}; - -enum LoadTileDataStatus { - Loading = 'Loading', - Loaded = 'Loaded', - Failure = 'Failure', - Cancelled = 'Cancelled', -} - /** * 单个瓦片 * 负责瓦片数据加载、缓存数据、缓存图层 @@ -98,7 +83,7 @@ export class Tile { const [minLng, minLat, maxLng, maxLat] = this.bounds; const center = [(maxLng - minLng) / 2, (maxLat - minLat) / 2] as const; - const polygon = bboxPolygon(this.bounds as Bounds, { + const polygon = bboxPolygon(this.bounds as TileBounds, { properties: { key: this.key, bbox: this.bounds, @@ -158,7 +143,7 @@ export class Tile { // 如果请求出错或数据为空 if (error || !tileData) { this.loadStatus = LoadTileDataStatus.Failure; - onError(error, this); + onError(error as Error, this); return; } diff --git a/packages/utils/src/tileset-manager/tileset-manager.ts b/packages/utils/src/tileset-manager/tileset-manager.ts index c16620f852..301cbc9adc 100644 --- a/packages/utils/src/tileset-manager/tileset-manager.ts +++ b/packages/utils/src/tileset-manager/tileset-manager.ts @@ -5,20 +5,10 @@ import { NOOP, UPDATE_TILE_STRATEGIES, } from './const'; -import { Tile, TileLoadParams } from './tile'; -import { Bounds, UpdateTileStrategy } from './types'; +import { Tile } from './tile'; +import { TilesetManagerOptions, UpdateTileStrategy } from './types'; import { getTileIndices } from './utils/lonlat-tile'; -export type TilesetManagerOptions = { - tileSize: number; - zoomOffset: number; - minZoom: number; - maxZoom: number; - extent: Bounds; - getTileData: (tile: TileLoadParams) => any; - updateStrategy: UpdateTileStrategy | ((tiles: Tile[]) => void); -}; - /** * 管理瓦片数据 */ diff --git a/packages/utils/src/tileset-manager/types.ts b/packages/utils/src/tileset-manager/types.ts index 671ca79a18..22b37abd82 100644 --- a/packages/utils/src/tileset-manager/types.ts +++ b/packages/utils/src/tileset-manager/types.ts @@ -1,5 +1,7 @@ +import { Tile } from './tile'; + // Bounds [minLng, minLat, maxLng, maxLat] -export type Bounds = [number, number, number, number]; +export type TileBounds = [number, number, number, number]; // 瓦片更新显示策略 export enum UpdateTileStrategy { @@ -8,3 +10,33 @@ export enum UpdateTileStrategy { // 全部替换策略 Replace = 'replace', } + +export type TileOptions = { x: number; y: number; z: number; tileSize: number }; + +export type TileLoadParams = TileOptions & { + bounds: TileBounds; + signal: AbortSignal; +}; + +export type TileLoadDataOptions = { + getData: (tile: TileLoadParams) => Promise; + onLoad: (tile: Tile) => void; + onError: (error: Error, tile: Tile) => void; +}; + +export enum LoadTileDataStatus { + Loading = 'Loading', + Loaded = 'Loaded', + Failure = 'Failure', + Cancelled = 'Cancelled', +} + +export type TilesetManagerOptions = { + tileSize: number; + zoomOffset: number; + minZoom: number; + maxZoom: number; + extent: TileBounds; + getTileData: (tile: TileLoadParams) => any; + updateStrategy: UpdateTileStrategy | ((tiles: Tile[]) => void); +}; diff --git a/packages/utils/src/tileset-manager/utils/lonlat-tile.ts b/packages/utils/src/tileset-manager/utils/lonlat-tile.ts index 1ee975bb93..d58df187a4 100644 --- a/packages/utils/src/tileset-manager/utils/lonlat-tile.ts +++ b/packages/utils/src/tileset-manager/utils/lonlat-tile.ts @@ -1,5 +1,5 @@ import { DEFAULT_EXTENT } from '../const'; -import { Bounds } from '../types'; +import { TileBounds } from '../types'; // // https://wiki.openstreetmap.org/wiki/Slippy_map_tilenames#ECMAScript_.28JavaScript.2FActionScript.2C_etc..29 export function osmLonLat2TileXY(lon: number, lat: number, zoom: number) { @@ -30,7 +30,7 @@ export function osmTileXY2LonLat(x: number, y: number, zoom: number) { export const tileToBounds = (x: number, y: number, z: number) => { const [minLng, maxLat] = osmTileXY2LonLat(x, y, z); const [maxLng, minLat] = osmTileXY2LonLat(x + 1, y + 1, z); - return [minLng, minLat, maxLng, maxLat] as Bounds; + return [minLng, minLat, maxLng, maxLat] as TileBounds; }; /** @@ -49,11 +49,11 @@ export function getTileIndices({ extent = DEFAULT_EXTENT, }: { zoom: number; - latLonBounds: Bounds; + latLonBounds: TileBounds; maxZoom: number; minZoom: number; zoomOffset: number; - extent: Bounds; + extent: TileBounds; tileSize: number; }) { let z = Math.ceil(zoom) + zoomOffset;