@@ -138,15 +138,57 @@ export class Deeptable {
138
138
// Must come after manifest is set.
139
139
this . base_url = baseUrl ;
140
140
this . root_tile = new Tile ( defaultManifest , null , this ) ;
141
- const preProcessRootTile = this . root_tile . preprocessRootTileInfo ( ) ;
142
-
143
141
// At instantiation, the deeptable isn't ready; only once this
144
142
// async stuff is done can the deeptable be used.
145
143
// TODO: Add an async static method as the preferred initialization method.
146
- this . promise = preProcessRootTile . then ( async ( ) => {
144
+ this . promise = this . _makePromise ( defaultManifest ) ;
145
+ }
146
+
147
+ /**
148
+ * Loads a quadtree created by version 2.0 or great of the quadfeather package (including manifests).
149
+ *
150
+ * @param tileProxy A tileProxy to use for fetching tiles. Can be used to wrap authentication.
151
+ * @param baseUrl The base URL of the quadfeather data.
152
+ *
153
+ */
154
+ static async fromQuadfeather ( {
155
+ tileProxy,
156
+ baseUrl,
157
+ plot = null ,
158
+ } : {
159
+ tileProxy ?: DS . TileProxy ;
160
+ baseUrl : string ;
161
+ plot ?: Scatterplot | null ;
162
+ } ) {
163
+ let manifest : DS . TileManifest ;
164
+ if ( tileProxy !== undefined ) {
165
+ throw new Error ( 'Not yet supported' ) ;
166
+ } else {
167
+ manifest = await loadTileManifest ( baseUrl + '/manifest.feather' ) ;
168
+ }
169
+
170
+ const dt = new Deeptable ( {
171
+ tileProxy,
172
+ tileManifest : manifest ,
173
+ baseUrl,
174
+ rootKey : '0/0/0' ,
175
+ plot,
176
+ } ) ;
177
+ await dt . promise ;
178
+ return dt ;
179
+ }
180
+
181
+ /**
182
+ * Internal function to ensure
183
+ */
184
+ protected _makePromise (
185
+ tileManifest : Partial < DS . TileManifest > & { key : string } ,
186
+ ) : Promise < void > {
187
+ return this . root_tile . preprocessRootTileInfo ( ) . then ( async ( ) => {
147
188
const batch = await this . root_tile . get_arrow ( null ) ;
148
189
const schema = batch . schema ;
149
- if ( ! tileManifest ) {
190
+ // TODO: Cleaner check that it's a lazy manifest
191
+ if ( ! tileManifest . max_ix ) {
150
192
this . root_tile . manifest =
151
193
await this . root_tile . deriveManifestInfoFromTileMetadata ( ) ;
152
194
}
@@ -1188,7 +1230,7 @@ export type TileManifest = {
1188
1230
extent : Rectangle ;
1189
1231
} ;
1190
1232
1191
- export async function tileManifest ( url : string ) {
1233
+ export async function loadTileManifest ( url : string ) : Promise < TileManifest > {
1192
1234
const data = await fetch ( url ) . then ( ( d ) => d . arrayBuffer ( ) ) ;
1193
1235
const tb = tableFromIPC ( data ) ;
1194
1236
const rows : RowFormatManifest [ ] = [ ...tb ] . map (
0 commit comments