| 29 | } |
| 30 | // |
| 31 | export default class Source extends EventEmitter implements ISource { |
| 32 | public type: string = 'source'; |
| 33 | public isTile: boolean = false; |
| 34 | public inited: boolean = false; |
| 35 | public data: IParserData; |
| 36 | public center: [number, number]; |
| 37 | // 数据范围 |
| 38 | public extent: BBox; |
| 39 | // 生命周期钩子 |
| 40 | public hooks = { |
| 41 | init: new SyncHook(), |
| 42 | }; |
| 43 | public getSourceCfg() { |
| 44 | return this.cfg; |
| 45 | } |
| 46 | public parser: IParserCfg | ITileParserCFG = { type: 'geojson' }; |
| 47 | public transforms: ITransform[] = []; |
| 48 | public cluster: boolean = false; |
| 49 | public clusterOptions: Partial<IClusterOptions> = { |
| 50 | enable: false, |
| 51 | radius: 40, |
| 52 | maxZoom: 20, |
| 53 | zoom: -99, |
| 54 | method: 'count', |
| 55 | }; |
| 56 | |
| 57 | // 瓦片数据管理器 |
| 58 | public tileset: TilesetManager | undefined; |
| 59 | // 是否有效范围 |
| 60 | private invalidExtent: boolean = false; |
| 61 | |
| 62 | private dataArrayChanged: boolean = false; |
| 63 | |
| 64 | // 原始数据 |
| 65 | protected originData: any; |
| 66 | protected rawData: any; |
| 67 | private cfg: Partial<ISourceCFG> = { |
| 68 | autoRender: true, |
| 69 | }; |
| 70 | |
| 71 | private clusterIndex: Supercluster; |
| 72 | |
| 73 | constructor(data: any | ISource, cfg?: ISourceCFG) { |
| 74 | super(); |
| 75 | // this.rawData = cloneDeep(data); |
| 76 | this.originData = data; |
| 77 | this.initCfg(cfg); |
| 78 | |
| 79 | this.init().then(() => { |
| 80 | this.inited = true; |
| 81 | this.emit('update', { |
| 82 | type: 'inited', |
| 83 | }); |
| 84 | }); |
| 85 | } |
| 86 | |
| 87 | public getClusters(zoom: number): any { |
| 88 | return this.clusterIndex.getClusters(this.caculClusterExtent(2), zoom); |
nothing calls this directly
no outgoing calls
no test coverage detected