From 7ce8b3f8ce0dc384ad65de7b0d82d43e62ab5f5a Mon Sep 17 00:00:00 2001 From: deyihu Date: Tue, 21 May 2024 11:07:00 +0800 Subject: [PATCH 01/10] TileLayer support only load tiles in mask --- package.json | 4 +- src/core/util/bbox.ts | 16 ++++ src/layer/Layer.ts | 14 +++- src/layer/tile/TileLayer.ts | 113 +++++++++++++++++++++++++-- src/map/Map.ts | 1 + src/renderer/layer/CanvasRenderer.ts | 6 +- 6 files changed, 146 insertions(+), 8 deletions(-) diff --git a/package.json b/package.json index 3f3b06d52..17786564e 100644 --- a/package.json +++ b/package.json @@ -49,7 +49,9 @@ "dependencies": { "@maptalks/feature-filter": "^1.3.0", "@maptalks/function-type": "^1.3.1", + "@maptalks/geojson-bbox": "^1.0.5", "frustum-intersects": "^0.1.0", + "lineclip": "^1.1.5", "rbush": "^2.0.2", "simplify-js": "^1.2.1" }, @@ -63,7 +65,6 @@ "@rollup/plugin-typescript": "^11.1.6", "@types/node": "^20.11.30", "@types/offscreencanvas": "^2019.7.3", - "rollup-plugin-dts": "^6.1.0", "eslint": "^8.57.0", "eslint-plugin-mocha": "^10.4.1", "expect-maptalks": "^0.4.1", @@ -80,6 +81,7 @@ "karma-sinon": "^1.0.5", "mocha": "^10.3.0", "rollup": "^4.13.0", + "rollup-plugin-dts": "^6.1.0", "sinon": "^3.2.1", "tslib": "^2.6.2", "typedoc": "^0.25.13", diff --git a/src/core/util/bbox.ts b/src/core/util/bbox.ts index 598d75d8f..9f2dd4665 100644 --- a/src/core/util/bbox.ts +++ b/src/core/util/bbox.ts @@ -87,3 +87,19 @@ export function bufferBBOX(bbox: BBOX, bufferSize = 0) { bbox[2] += bufferSize; bbox[3] += bufferSize; } + +export function bboxIntersect(bbox1: BBOX, bbox2: BBOX) { + if (bbox1[2] < bbox2[0]) { + return false; + } + if (bbox1[1] > bbox2[3]) { + return false; + } + if (bbox1[0] > bbox2[2]) { + return false; + } + if (bbox1[3] < bbox2[1]) { + return false; + } + return true; +} \ No newline at end of file diff --git a/src/layer/Layer.ts b/src/layer/Layer.ts index 8102bfe1c..e4993047e 100644 --- a/src/layer/Layer.ts +++ b/src/layer/Layer.ts @@ -31,6 +31,7 @@ import { CommonProjectionType } from '../geo/projection'; * @property options.forceRenderOnZooming=false - force to render layer when map is zooming * @property options.forceRenderOnRotating=false - force to render layer when map is Rotating * @property options.collisionScope=layer - layer's collision scope: layer or map + * @property options.maskClip=true - clip layer by mask(Polygon/MultiPolygon) * @memberOf Layer * @instance */ @@ -52,7 +53,8 @@ const options: LayerOptionsType = { 'collisionScope': 'layer', 'hitDetect': (function () { return !Browser.mobile; - })() + })(), + 'maskClip': true }; /** @@ -79,6 +81,7 @@ class Layer extends JSONAble(Eventable(Renderable(Class))) { _drawTime: number map: Map _mask: Polygon | MultiPolygon | Marker; + _maskGeoJSON: Record; _loaded: boolean _collisionIndex: CollisionIndex _optionsHook?(conf?: any): void @@ -550,6 +553,13 @@ class Layer extends JSONAble(Eventable(Renderable(Class))) { }); } this._mask = mask; + if (mask && mask.toGeoJSON) { + try { + this._maskGeoJSON = mask.toGeoJSON(); + } catch (error) { + console.error(error); + } + } this.options.mask = mask.toJSON(); if (!this.getMap() || this.getMap().isZooming()) { return this; @@ -570,6 +580,7 @@ class Layer extends JSONAble(Eventable(Renderable(Class))) { */ removeMask(): this { delete this._mask; + delete this._maskGeoJSON; delete this.options.mask; if (!this.getMap() || this.getMap().isZooming()) { return this; @@ -863,6 +874,7 @@ export type LayerOptionsType = { drawImmediate?: boolean, geometryEvents?: boolean, geometryEventTolerance?: number, + maskClip?: boolean; } export type LayerJSONType = { diff --git a/src/layer/tile/TileLayer.ts b/src/layer/tile/TileLayer.ts index fde2e8b63..49c3eeef2 100644 --- a/src/layer/tile/TileLayer.ts +++ b/src/layer/tile/TileLayer.ts @@ -27,6 +27,9 @@ import { formatResourceUrl } from '../../core/ResourceProxy'; import { Coordinate, Extent } from '../../geo'; import { type TileLayerCanvasRenderer } from '../../renderer'; import { type Map } from '../../map'; +import GeoJSONBBOX from '@maptalks/geojson-bbox'; +import { bboxIntersect } from '../../core/util/bbox'; +import lineclip from 'lineclip'; const DEFAULT_MAXERROR = 1; const TEMP_POINT = new Point(0, 0); @@ -96,6 +99,7 @@ class TileHashset { * @property [options.awareOfTerrain=true] - if the tile layer is aware of terrain. * @property [options.bufferPixel=0.5] - tile buffer size,the unit is pixel * @property [options.depthMask=true] - mask to decide whether to write depth buffer + * @property [options.onlyLoadTilesInMask=false] - only load tiles in mask * @memberOf TileLayer * @instance */ @@ -160,7 +164,8 @@ const options: TileLayerOptionsType = { 'bufferPixel': 0.5, 'mipmapTexture': true, 'depthMask': true, - 'currentTilesFirst': true + 'currentTilesFirst': true, + 'onlyLoadTilesInMask': false }; const URL_PATTERN = /\{ *([\w_]+) *\}/g; @@ -205,6 +210,7 @@ class TileLayer extends Layer { _tileConfig: TileConfig; _polygonOffset: number; _renderer: TileLayerCanvasRenderer; + options: TileLayerOptionsType; /** * @@ -264,13 +270,37 @@ class TileLayer extends Layer { getTiles(z: number, parentLayer: Layer) { this._coordCache = {}; + let result; if (this._isPyramidMode()) { - return this._getPyramidTiles(z, parentLayer); + result = this._getPyramidTiles(z, parentLayer); } else { - return this._getCascadeTiles(z, parentLayer); + result = this._getCascadeTiles(z, parentLayer); } + if (!this.options.onlyLoadTilesInMask) { + return result; + } + const tileGrids: Array = result.tileGrids || []; + let count = 0; + //filter tiles by mask + tileGrids.forEach(tileGrid => { + const tiles = tileGrid.tiles || []; + tileGrid.tiles = tiles.filter(tile => { + return this._tileInMask(tile); + }); + count += tileGrid.tiles.length; + const parentIds = tileGrid.tiles.map(tile => { + return tile.parent; + }); + tileGrid.parents = tileGrid.parents.filter(parent => { + return parentIds.indexOf(parent.id) > -1; + }); + }); + result.count = count; + return result; } + + _isPyramidMode() { const sr = this.getSpatialReference(); return !this._disablePyramid && !this._hasOwnSR && this.options['pyramidMode'] && sr && sr.isPyramid(); @@ -1284,7 +1314,7 @@ class TileLayer extends Layer { if (isNumber(offset)) { offset = [offset, offset]; } - return offset || [0, 0]; + return (offset as [number, number]) || [0, 0]; } getTileId(x: number, y: number, zoom: number, id: string): string { @@ -1454,6 +1484,78 @@ class TileLayer extends Layer { getRenderer() { return super.getRenderer() as TileLayerCanvasRenderer; } + + _getTileBBox(tile: TileNodeType): [number, number, number, number] | null { + const map = this.getMap(); + if (!map) { + return; + } + const z = tile.z; + const x = tile.x; + const y = tile.y; + const res = tile.res || map._getResolution(z); + const tileConfig = this._getTileConfig(); + if (!tileConfig) { + return; + } + const prjExtent = tileConfig.getTilePrjExtent(x, y, res); + if (!prjExtent) { + return; + } + const { xmin, ymin, xmax, ymax } = prjExtent; + const pmin = new Point(xmin, ymin), + pmax = new Point(xmax, ymax); + const projection = map.getProjection(); + const min = projection.unproject(pmin), + max = projection.unproject(pmax); + return [min.x, min.y, max.x, max.y]; + + } + + _tileInMask(tile: TileNodeType): boolean { + const mask = this.getMask(); + if (!mask) { + return true; + } + const type = mask.type; + if (!type || type.indexOf('Polygon') === -1) { + return true; + } + if (!this._maskGeoJSON) { + return true; + } + //cal geojson bbox + if (!this._maskGeoJSON.bbox) { + this._maskGeoJSON.bbox = GeoJSONBBOX(this._maskGeoJSON); + } + const tileBBOX = this._getTileBBox(tile); + if (!tileBBOX) { + return true; + } + const maskBBOX = this._maskGeoJSON.bbox; + if (!bboxIntersect(maskBBOX, tileBBOX)) { + return false; + } else { + const geometry = this._maskGeoJSON.geometry; + if (!geometry) { + return true; + } + let { type, coordinates } = geometry; + if (type === 'Polygon') { + coordinates = [coordinates]; + } + for (let i = 0, len = coordinates.length; i < len; i++) { + const rings = coordinates[i]; + const outRing = rings[0]; + const result = lineclip.polygon(outRing, tileBBOX); + if (result.length > 0) { + return true; + } + } + return false; + } + + } } TileLayer.registerJSONType('TileLayer'); @@ -1537,7 +1639,7 @@ export type TileLayerOptionsType = LayerOptionsType & { urlTemplate: string | ((...args) => string); subdomains?: string[]; spatialReference?: SpatialReferenceType; - tileSize?: number[]; + tileSize?: number | [number, number]; offset?: number[] | ((...args) => number[]); tileSystem?: [number, number, number, number]; maxAvailableZoom?: number; @@ -1571,4 +1673,5 @@ export type TileLayerOptionsType = LayerOptionsType & { tileStackDepth?: number; mipmapTexture?: boolean; currentTilesFirst?: boolean; + onlyLoadTilesInMask?: boolean; }; diff --git a/src/map/Map.ts b/src/map/Map.ts index 678c127d3..31e0e9c29 100644 --- a/src/map/Map.ts +++ b/src/map/Map.ts @@ -157,6 +157,7 @@ const options: MapOptionsType = { 'switchDragButton': false, 'mousemoveThrottleTime': MOUSEMOVE_THROTTLE_TIME, 'maxFPS': 0, + 'cameraInfiniteFar': false, 'debug': false }; diff --git a/src/renderer/layer/CanvasRenderer.ts b/src/renderer/layer/CanvasRenderer.ts index a91f9a383..419156a0a 100644 --- a/src/renderer/layer/CanvasRenderer.ts +++ b/src/renderer/layer/CanvasRenderer.ts @@ -571,7 +571,8 @@ class CanvasRenderer extends Class { return null; } const maskExtent2D = this._maskExtent = mask._getMaskPainter().get2DExtent(); - if (!maskExtent2D.intersects(this._extent2D)) { + //fix vt _extent2D is null + if (maskExtent2D && this._extent2D && !maskExtent2D.intersects(this._extent2D)) { this.layer.fire('renderstart', { 'context': this.context, 'gl': this.gl @@ -599,6 +600,9 @@ class CanvasRenderer extends Class { if (!mask) { return false; } + if (!this.layer.options.maskClip) { + return false; + } const old = this.middleWest; const map = this.getMap(); //when clipping, layer's middleWest needs to be reset for mask's containerPoint conversion From 513133d097a3915b91289302cc6406fa735bdc58 Mon Sep 17 00:00:00 2001 From: deyihu Date: Tue, 21 May 2024 17:32:06 +0800 Subject: [PATCH 02/10] fix lineclip --- src/layer/tile/TileLayer.ts | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/layer/tile/TileLayer.ts b/src/layer/tile/TileLayer.ts index 49c3eeef2..6243886d1 100644 --- a/src/layer/tile/TileLayer.ts +++ b/src/layer/tile/TileLayer.ts @@ -1549,6 +1549,17 @@ class TileLayer extends Layer { const outRing = rings[0]; const result = lineclip.polygon(outRing, tileBBOX); if (result.length > 0) { + let minx = Infinity, maxx = -Infinity, miny = Infinity, maxy = -Infinity; + for (let j = 0, len1 = result.length; j < len1; j++) { + const [x, y] = result[j]; + minx = Math.min(x, minx); + miny = Math.min(y, miny); + maxx = Math.max(x, maxx); + maxy = Math.max(y, maxy); + } + if (minx === maxx || miny === maxy) { + return false; + } return true; } } From 11b4ac52a50d44e90bde6189b3a4de9766e15acf Mon Sep 17 00:00:00 2001 From: deyihu Date: Tue, 21 May 2024 17:44:29 +0800 Subject: [PATCH 03/10] fixing --- src/layer/tile/TileLayer.ts | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/layer/tile/TileLayer.ts b/src/layer/tile/TileLayer.ts index 6243886d1..68839f2c9 100644 --- a/src/layer/tile/TileLayer.ts +++ b/src/layer/tile/TileLayer.ts @@ -1557,10 +1557,9 @@ class TileLayer extends Layer { maxx = Math.max(x, maxx); maxy = Math.max(y, maxy); } - if (minx === maxx || miny === maxy) { - return false; + if (minx !== maxx && miny !== maxy) { + return true; } - return true; } } return false; From 78faf6cfa5dab3d9f9492b098f37301050381b44 Mon Sep 17 00:00:00 2001 From: deyihu Date: Wed, 22 May 2024 09:29:39 +0800 Subject: [PATCH 04/10] updates --- src/core/util/bbox.ts | 47 +++++++++++++++++++++++++++++++ src/layer/tile/TileLayer.ts | 56 +++++++++---------------------------- 2 files changed, 60 insertions(+), 43 deletions(-) diff --git a/src/core/util/bbox.ts b/src/core/util/bbox.ts index 9f2dd4665..39912341c 100644 --- a/src/core/util/bbox.ts +++ b/src/core/util/bbox.ts @@ -1,4 +1,6 @@ import Coordinate from '../../geo/Coordinate'; +import GeoJSONBBOX from '@maptalks/geojson-bbox'; +import lineclip from 'lineclip'; const minx = Infinity, miny = Infinity, maxx = -Infinity, maxy = -Infinity; @@ -102,4 +104,49 @@ export function bboxIntersect(bbox1: BBOX, bbox2: BBOX) { return false; } return true; +} + +/** + * bbox Intersect Mask + * apply on TileLayer,VectorTileLayer,Geo3DTileLayer Layers + * @param bbox + * @param maskGeoJSON(Polygon/MultiPolygon GeoJSON) + * @returns + */ +export function bboxInMask(bbox: BBOX, maskGeoJSON: Record): boolean { + //cal geojson bbox + maskGeoJSON.bbox = maskGeoJSON.bbox || GeoJSONBBOX(maskGeoJSON); + const maskBBOX = maskGeoJSON.bbox; + if (!bboxIntersect(maskBBOX, bbox)) { + return false; + } else { + const geometry = maskGeoJSON.geometry; + if (!geometry) { + console.error('maskGeoJSON is error,not find geometry.', maskGeoJSON); + return false; + } + let { type, coordinates } = geometry; + if (type === 'Polygon') { + coordinates = [coordinates]; + } + for (let i = 0, len = coordinates.length; i < len; i++) { + const rings = coordinates[i]; + const outRing = rings[0]; + const result = lineclip.polygon(outRing, bbox); + if (result.length > 0) { + let minx = Infinity, maxx = -Infinity, miny = Infinity, maxy = -Infinity; + for (let j = 0, len1 = result.length; j < len1; j++) { + const [x, y] = result[j]; + minx = Math.min(x, minx); + miny = Math.min(y, miny); + maxx = Math.max(x, maxx); + maxy = Math.max(y, maxy); + } + if (minx !== maxx && miny !== maxy) { + return true; + } + } + } + return false; + } } \ No newline at end of file diff --git a/src/layer/tile/TileLayer.ts b/src/layer/tile/TileLayer.ts index 68839f2c9..2b3177a65 100644 --- a/src/layer/tile/TileLayer.ts +++ b/src/layer/tile/TileLayer.ts @@ -27,9 +27,7 @@ import { formatResourceUrl } from '../../core/ResourceProxy'; import { Coordinate, Extent } from '../../geo'; import { type TileLayerCanvasRenderer } from '../../renderer'; import { type Map } from '../../map'; -import GeoJSONBBOX from '@maptalks/geojson-bbox'; -import { bboxIntersect } from '../../core/util/bbox'; -import lineclip from 'lineclip'; +import { BBOX, bboxInMask } from '../../core/util/bbox'; const DEFAULT_MAXERROR = 1; const TEMP_POINT = new Point(0, 0); @@ -1485,7 +1483,7 @@ class TileLayer extends Layer { return super.getRenderer() as TileLayerCanvasRenderer; } - _getTileBBox(tile: TileNodeType): [number, number, number, number] | null { + _getTileBBox(tile: TileNodeType): BBOX | null { const map = this.getMap(); if (!map) { return; @@ -1517,54 +1515,26 @@ class TileLayer extends Layer { if (!mask) { return true; } - const type = mask.type; - if (!type || type.indexOf('Polygon') === -1) { + const maskType = mask.type; + if (!maskType || maskType.indexOf('Polygon') === -1) { return true; } - if (!this._maskGeoJSON) { + const maskGeoJSON = this._maskGeoJSON; + if (!maskGeoJSON || !maskGeoJSON.geometry) { return true; } - //cal geojson bbox - if (!this._maskGeoJSON.bbox) { - this._maskGeoJSON.bbox = GeoJSONBBOX(this._maskGeoJSON); + const { coordinates, type } = maskGeoJSON.geometry; + if (!coordinates || !type) { + return true; + } + if (type.indexOf('Polygon') === -1) { + return true; } const tileBBOX = this._getTileBBox(tile); if (!tileBBOX) { return true; } - const maskBBOX = this._maskGeoJSON.bbox; - if (!bboxIntersect(maskBBOX, tileBBOX)) { - return false; - } else { - const geometry = this._maskGeoJSON.geometry; - if (!geometry) { - return true; - } - let { type, coordinates } = geometry; - if (type === 'Polygon') { - coordinates = [coordinates]; - } - for (let i = 0, len = coordinates.length; i < len; i++) { - const rings = coordinates[i]; - const outRing = rings[0]; - const result = lineclip.polygon(outRing, tileBBOX); - if (result.length > 0) { - let minx = Infinity, maxx = -Infinity, miny = Infinity, maxy = -Infinity; - for (let j = 0, len1 = result.length; j < len1; j++) { - const [x, y] = result[j]; - minx = Math.min(x, minx); - miny = Math.min(y, miny); - maxx = Math.max(x, maxx); - maxy = Math.max(y, maxy); - } - if (minx !== maxx && miny !== maxy) { - return true; - } - } - } - return false; - } - + return bboxInMask(tileBBOX, this._maskGeoJSON); } } From 7fc579a3077e4e2680ec3335b20e7e00afeffb5e Mon Sep 17 00:00:00 2001 From: deyihu Date: Wed, 22 May 2024 09:33:55 +0800 Subject: [PATCH 05/10] updates --- src/layer/Layer.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/layer/Layer.ts b/src/layer/Layer.ts index e4993047e..72609a031 100644 --- a/src/layer/Layer.ts +++ b/src/layer/Layer.ts @@ -557,6 +557,7 @@ class Layer extends JSONAble(Eventable(Renderable(Class))) { try { this._maskGeoJSON = mask.toGeoJSON(); } catch (error) { + delete this._maskGeoJSON; console.error(error); } } From 21a9005c16ec4aacf50f61b2b7f3c606d20158f5 Mon Sep 17 00:00:00 2001 From: hu de yi Date: Fri, 14 Jun 2024 09:15:08 +0800 Subject: [PATCH 06/10] updates --- src/layer/tile/TileLayer.ts | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-) diff --git a/src/layer/tile/TileLayer.ts b/src/layer/tile/TileLayer.ts index 2b3177a65..8e1661daf 100644 --- a/src/layer/tile/TileLayer.ts +++ b/src/layer/tile/TileLayer.ts @@ -1488,24 +1488,18 @@ class TileLayer extends Layer { if (!map) { return; } - const z = tile.z; - const x = tile.x; - const y = tile.y; - const res = tile.res || map._getResolution(z); - const tileConfig = this._getTileConfig(); - if (!tileConfig) { - return; - } - const prjExtent = tileConfig.getTilePrjExtent(x, y, res); - if (!prjExtent) { + + const extent2d = tile.extent2d; + if (!extent2d) { return; } - const { xmin, ymin, xmax, ymax } = prjExtent; + const res = tile.res; + + const { xmin, ymin, xmax, ymax } = extent2d; const pmin = new Point(xmin, ymin), pmax = new Point(xmax, ymax); - const projection = map.getProjection(); - const min = projection.unproject(pmin), - max = projection.unproject(pmax); + const min = map.pointAtResToCoordinate(pmin, res, TEMP_POINT0), + max = map.pointAtResToCoordinate(pmax, res, TEMP_POINT1); return [min.x, min.y, max.x, max.y]; } From db5fdd94fd9e5819406a0730157419bdc40065c2 Mon Sep 17 00:00:00 2001 From: hu de yi Date: Fri, 14 Jun 2024 09:28:34 +0800 Subject: [PATCH 07/10] delete geojson-bbox npm package --- package.json | 1 - src/core/util/bbox.ts | 8 +++++--- src/layer/tile/TileLayer.ts | 7 +++++++ 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/package.json b/package.json index 17786564e..89e1e5b76 100644 --- a/package.json +++ b/package.json @@ -49,7 +49,6 @@ "dependencies": { "@maptalks/feature-filter": "^1.3.0", "@maptalks/function-type": "^1.3.1", - "@maptalks/geojson-bbox": "^1.0.5", "frustum-intersects": "^0.1.0", "lineclip": "^1.1.5", "rbush": "^2.0.2", diff --git a/src/core/util/bbox.ts b/src/core/util/bbox.ts index 39912341c..6c29b458a 100644 --- a/src/core/util/bbox.ts +++ b/src/core/util/bbox.ts @@ -1,5 +1,4 @@ import Coordinate from '../../geo/Coordinate'; -import GeoJSONBBOX from '@maptalks/geojson-bbox'; import lineclip from 'lineclip'; const minx = Infinity, miny = Infinity, maxx = -Infinity, maxy = -Infinity; @@ -114,9 +113,12 @@ export function bboxIntersect(bbox1: BBOX, bbox2: BBOX) { * @returns */ export function bboxInMask(bbox: BBOX, maskGeoJSON: Record): boolean { - //cal geojson bbox - maskGeoJSON.bbox = maskGeoJSON.bbox || GeoJSONBBOX(maskGeoJSON); + //geojson bbox const maskBBOX = maskGeoJSON.bbox; + if (!maskBBOX) { + console.error('maskGeoJSON bbox is null:', maskGeoJSON); + return false; + } if (!bboxIntersect(maskBBOX, bbox)) { return false; } else { diff --git a/src/layer/tile/TileLayer.ts b/src/layer/tile/TileLayer.ts index 8e1661daf..89dd8e27f 100644 --- a/src/layer/tile/TileLayer.ts +++ b/src/layer/tile/TileLayer.ts @@ -1524,6 +1524,13 @@ class TileLayer extends Layer { if (type.indexOf('Polygon') === -1) { return true; } + if (!maskGeoJSON.bbox) { + const extent = mask.getExtent(); + if (!extent) { + return true; + } + maskGeoJSON.bbox = [extent.xmin, extent.ymin, extent.xmax, extent.ymax]; + } const tileBBOX = this._getTileBBox(tile); if (!tileBBOX) { return true; From 94bb9e92e010deb0b873fe262f3124509fb10ade Mon Sep 17 00:00:00 2001 From: deyihu Date: Sun, 16 Jun 2024 09:07:21 +0800 Subject: [PATCH 08/10] fix lint --- src/core/util/bbox.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/core/util/bbox.ts b/src/core/util/bbox.ts index 6c29b458a..267fa3907 100644 --- a/src/core/util/bbox.ts +++ b/src/core/util/bbox.ts @@ -127,7 +127,8 @@ export function bboxInMask(bbox: BBOX, maskGeoJSON: Record): boolea console.error('maskGeoJSON is error,not find geometry.', maskGeoJSON); return false; } - let { type, coordinates } = geometry; + let { coordinates } = geometry; + const type = geometry.type; if (type === 'Polygon') { coordinates = [coordinates]; } From 21e6136e446bf3a6b4a4b5e7735fde749ad565c3 Mon Sep 17 00:00:00 2001 From: deyihu Date: Sun, 16 Jun 2024 09:22:38 +0800 Subject: [PATCH 09/10] fix lint --- src/layer/tile/TileLayer.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/layer/tile/TileLayer.ts b/src/layer/tile/TileLayer.ts index 09065bb53..3483baec2 100644 --- a/src/layer/tile/TileLayer.ts +++ b/src/layer/tile/TileLayer.ts @@ -1385,8 +1385,8 @@ class TileLayer extends Layer { } return this._tileConfig || this._defaultTileConfig; } - - _bindMap() { + // eslint-disable-next-line @typescript-eslint/no-unused-vars + _bindMap(args?: any) { this._onSpatialReferenceChange(); // eslint-disable-next-line prefer-rest-params return super._bindMap.apply(this, arguments); From 7b58108c48e192373140397bcc5610296369c110 Mon Sep 17 00:00:00 2001 From: deyihu Date: Wed, 19 Jun 2024 21:40:13 +0800 Subject: [PATCH 10/10] delete onlyLoadTilesInMask --- src/layer/tile/TileLayer.ts | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/layer/tile/TileLayer.ts b/src/layer/tile/TileLayer.ts index 3483baec2..f69efe27a 100644 --- a/src/layer/tile/TileLayer.ts +++ b/src/layer/tile/TileLayer.ts @@ -95,8 +95,7 @@ class TileHashset { * @property [options.fetchOptions=object] - fetch params,such as fetchOptions: { 'headers': { 'accept': '' } }, about accept value more info https://developer.mozilla.org/en-US/docs/Web/HTTP/Content_negotiation/List_of_default_Accept_values * @property [options.awareOfTerrain=true] - if the tile layer is aware of terrain. * @property [options.bufferPixel=0.5] - tile buffer size,the unit is pixel - * @property [options.depthMask=true] - mask to decide whether to write depth buffer - * @property [options.onlyLoadTilesInMask=false] - only load tiles in mask + * @property [options.depthMask=true] - mask to decide whether to write depth buffe * @memberOf TileLayer * @instance */ @@ -162,7 +161,6 @@ const options: TileLayerOptionsType = { 'mipmapTexture': true, 'depthMask': true, 'currentTilesFirst': true, - 'onlyLoadTilesInMask': false, 'forceRenderOnMoving': true }; @@ -274,7 +272,7 @@ class TileLayer extends Layer { } else { result = this._getCascadeTiles(z, parentLayer); } - if (!this.options.onlyLoadTilesInMask) { + if (!this._maskGeoJSON) { return result; } const tileGrids: Array = result.tileGrids || []; @@ -1646,5 +1644,4 @@ export type TileLayerOptionsType = LayerOptionsType & { tileStackDepth?: number; mipmapTexture?: boolean; currentTilesFirst?: boolean; - onlyLoadTilesInMask?: boolean; };