@@ -41,7 +41,7 @@ import type {
4141 Triangulation ,
4242} from '@antv/l7-core' ;
4343import { BlendType , IDebugLog , ILayerStage , globalConfigService } from '@antv/l7-core' ;
44- import { lodashUtil , processRelativeCoordinates } from '@antv/l7-utils' ;
44+ import { lodashUtil } from '@antv/l7-utils' ;
4545import { EventEmitter } from 'eventemitter3' ;
4646import { createPlugins } from '../plugins' ;
4747import type Source from '../source' ;
@@ -50,6 +50,7 @@ import { createMultiPassRenderer, normalizePasses } from '../utils/multiPassRend
5050import LayerMaskManager from './LayerMaskManager' ;
5151import LayerPickingManager from './LayerPickingManager' ;
5252import LayerPickService from './LayerPickService' ;
53+ import LayerRelativeCoords from './LayerRelativeCoords' ;
5354import LayerVisibilityZoom from './LayerVisibilityZoom' ;
5455import TextureService from './TextureService' ;
5556const { isEqual, isFunction, isNumber, isObject, isPlainObject, isUndefined } = lodashUtil ;
@@ -217,9 +218,11 @@ export default class BaseLayer<ChildLayerStyleOptions = {}>
217218 protected animateOptions : IAnimateOption = { enable : false } ;
218219
219220 // 相对坐标系支持
220- protected relativeOrigin : [ number , number ] = [ 0 , 0 ] ;
221- protected originalExtent : [ number , number , number , number ] = [ 0 , 0 , 0 , 0 ] ;
222- protected absoluteDataArray : IParseDataItem [ ] = [ ] ; // 保存绝对坐标数据用于交互
221+ /**
222+ * 相对坐标状态与转换 delegate(阶段 1.4)。原 protected 字段搬入;
223+ * 外部经 ILayer getter 访问,`processRelativeCoordinates` 经 protected 薄转发。
224+ */
225+ protected relativeCoordsManager : LayerRelativeCoords = new LayerRelativeCoords ( this ) ;
223226
224227 /**
225228 * 图层容器
@@ -1249,46 +1252,28 @@ export default class BaseLayer<ChildLayerStyleOptions = {}>
12491252 * 处理相对坐标转换
12501253 */
12511254 protected processRelativeCoordinates ( ) {
1252- const layerConfig = this . getLayerConfig ( ) ;
1253- const enableRelativeCoordinates = layerConfig ?. enableRelativeCoordinates ;
1254-
1255- if ( ! enableRelativeCoordinates || ! this . layerSource || ! this . layerSource . data ) {
1256- return ;
1257- }
1258-
1259- // 保存原始绝对坐标数据用于交互
1260- this . absoluteDataArray = [ ...this . layerSource . data . dataArray ] ;
1261-
1262- // 处理相对坐标转换
1263- const result = processRelativeCoordinates ( this . layerSource . data . dataArray , {
1264- enableRelativeCoordinates : true ,
1265- } ) ;
1266-
1267- // 更新source数据为相对坐标
1268- this . layerSource . data . dataArray = result . dataArray ;
1269- this . relativeOrigin = result . relativeOrigin ;
1270- this . originalExtent = result . originalExtent ;
1255+ this . relativeCoordsManager . processRelativeCoordinates ( ) ;
12711256 }
12721257
12731258 /**
12741259 * 获取绝对坐标数据(用于交互计算)
12751260 */
12761261 public getAbsoluteData ( ) {
1277- return this . absoluteDataArray ;
1262+ return this . relativeCoordsManager . getAbsoluteData ( ) ;
12781263 }
12791264
12801265 /**
12811266 * 获取相对坐标原点
12821267 */
12831268 public getRelativeOrigin ( ) {
1284- return this . relativeOrigin ;
1269+ return this . relativeCoordsManager . getRelativeOrigin ( ) ;
12851270 }
12861271
12871272 /**
12881273 * 获取原始数据范围
12891274 */
12901275 public getOriginalExtent ( ) {
1291- return this . originalExtent ;
1276+ return this . relativeCoordsManager . getOriginalExtent ( ) ;
12921277 }
12931278
12941279 protected sourceEvent = ( ) => {
0 commit comments