Skip to content

Commit

Permalink
add flatTree method (#164)
Browse files Browse the repository at this point in the history
* add flatTree method

* Update tile.ts
  • Loading branch information
bmschmidt authored Oct 24, 2024
1 parent ea143d7 commit b91c253
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/Deeptable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,9 @@ export class Deeptable {
resolve?: () => void;
}> = new Set();
public selection_history: DS.SelectionRecord[] = [];

// The flatTree is a representation of known tiles in the quadtree in a flat format
// indexed by tile index (`tix` -- see `tixRixQid`).
public flatTree: (Tile | undefined | null)[] = [];
public promise: Promise<void>;
public root_tile: Tile;
public manifest?: DS.TileManifest;
Expand Down
12 changes: 12 additions & 0 deletions src/tile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ export type Rectangle = {

import type { ArrowBuildable, LazyTileManifest, TileManifest } from './types';
import { isCompleteManifest } from './typing';
import { tileKey_to_tix, zxyToTix } from './tixrixqid';

Check failure on line 27 in src/tile.ts

View workflow job for this annotation

GitHub Actions / publish

'tileKey_to_tix' is declared but its value is never read.

Check failure on line 27 in src/tile.ts

View workflow job for this annotation

GitHub Actions / deploy-docs

'tileKey_to_tix' is declared but its value is never read.

export type RecordBatchCache =
| {
Expand Down Expand Up @@ -56,6 +57,7 @@ export class Tile {
protected _batch?: RecordBatch;
parent: Tile | null;
private _children: Array<Tile> = [];
private readonly _tix: number;
public _highest_known_ix?: number;
public deeptable: Deeptable;
public _transformations: Record<string, Promise<ArrowBuildable>> = {};
Expand Down Expand Up @@ -100,6 +102,13 @@ export class Tile {
manifest = key;
}
this.key = manifest.key;
const coords = this.key.split('/').map((value) => parseInt(value, 10));
while (coords.length < 3) {
coords.push(0);
}
const tix = zxyToTix(coords[0], coords[1], coords[2]);
this._tix = tix;
deeptable.flatTree[tix] = this;
// if (manifest.min_ix === undefined) {
// manifest.min_ix = parent ? parent.max_ix + 1 : 0;
// }
Expand Down Expand Up @@ -171,6 +180,9 @@ export class Tile {
return existing;
}

get tix() {
return this._tix;
}
/**
*
* @param fields A list of keys to be created if they don't exist.
Expand Down

0 comments on commit b91c253

Please sign in to comment.