mapcomplete/Logic/FeatureSource/TiledFeatureSource/TileHierarchy.ts
2022-07-13 17:56:33 +02:00

25 lines
No EOL
641 B
TypeScript

import FeatureSource, {Tiled} from "../FeatureSource";
import {BBox} from "../../BBox";
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: T[] = []
hierarchy.loadedTiles.forEach((tile) => {
if (tile.bbox.overlapsWith(bbox)) {
result.push(tile)
}
})
return result;
}
}