| 
									
										
										
										
											2021-09-21 02:10:42 +02:00
										 |  |  | import FeatureSource, {Tiled} from "../FeatureSource"; | 
					
						
							| 
									
										
										
										
											2021-09-28 17:30:48 +02:00
										 |  |  | import {BBox} from "../../BBox"; | 
					
						
							| 
									
										
										
										
											2021-09-21 02:10:42 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | export default interface TileHierarchy<T extends FeatureSource & Tiled> { | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     /** | 
					
						
							|  |  |  |      * A mapping from 'tile_index' to the actual tile featrues | 
					
						
							|  |  |  |      */ | 
					
						
							|  |  |  |     loadedTiles: Map<number, T> | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | export class TileHierarchyTools { | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     public static getTiles<T extends FeatureSource & Tiled>(hierarchy: TileHierarchy<T>, bbox: BBox): T[] { | 
					
						
							|  |  |  |         const result = [] | 
					
						
							|  |  |  |         hierarchy.loadedTiles.forEach((tile) => { | 
					
						
							|  |  |  |             if (tile.bbox.overlapsWith(bbox)) { | 
					
						
							|  |  |  |                 result.push(tile) | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  |         }) | 
					
						
							|  |  |  |         return result; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | } |