private void TryGetAllDataInView(Imageset imageset, bool limit, CatalogSpreadSheetLayer catalogSpreadSheetLayer, Action <InViewReturnMessage> onComplete, int i) { int maxX = GetTilesXForLevel(imageset, imageset.BaseLevel); int maxY = GetTilesYForLevel(imageset, imageset.BaseLevel); bool anyTileStillDownloading = false; for (int x = 0; x < maxX; x++) { for (int y = 0; y < maxY; y++) { Tile tile = TileCache.GetTile(imageset.BaseLevel, x, y, imageset, null); if (tile != null) { bool tileAndChildrenReady = ((HealpixTile)tile).GetDataInView(this, limit, catalogSpreadSheetLayer); anyTileStillDownloading = anyTileStillDownloading || !tileAndChildrenReady; } else { anyTileStillDownloading = true; } } } if (anyTileStillDownloading) { int count = catalogSpreadSheetLayer.Table.Rows.Count; if ((count > 10000 || i > 100 * 60 * 5) && limit) // ~5 minutes { Script.Literal("console.log('Too Many results - Aborting')"); Script.Literal("console.log(count)"); InViewReturnMessage returnMessage = new InViewReturnMessage(); returnMessage.aborted = true; returnMessage.table = catalogSpreadSheetLayer.GetTableDataInView(); onComplete.Invoke(returnMessage); catalogSpreadSheetLayer.CleanUp(); } else { Script.SetTimeout(delegate() { TryGetAllDataInView(imageset, limit, catalogSpreadSheetLayer, onComplete, i); }, 10); if (i % 200 == 0) { Script.Literal("console.log('Waiting for more tiles to load')"); Script.Literal("console.log(count)"); } i++; } } else { int count = catalogSpreadSheetLayer.Table.Rows.Count; Script.Literal("console.log('Done!')"); Script.Literal("console.log(count)"); InViewReturnMessage returnMessage = new InViewReturnMessage(); returnMessage.aborted = false; returnMessage.table = catalogSpreadSheetLayer.GetTableDataInView(); onComplete.Invoke(returnMessage); catalogSpreadSheetLayer.CleanUp(); } }
public bool GetDataInView(RenderContext renderContext, bool limit, CatalogSpreadSheetLayer catalogSpreadSheetLayer) { if (!ReadyToRender) { if (!errored) { RequestImage(); if (limit) { return(false); } } else if (Level >= 3) //Level 0-2 sometimes deleted in favor of allsky.jpg/tsv { return(true); } } bool allChildrenReady = true; bool anyChildInFrustum = false; int childIndex = 0; for (int y1 = 0; y1 < 2; y1++) { for (int x1 = 0; x1 < 2; x1++) { if (Level < dataset.Levels) { if (children[childIndex] == null) { children[childIndex] = TileCache.GetTile(Level + 1, x1, y1, dataset, this); } if (children[childIndex].IsTileInFrustum(renderContext.Frustum)) { anyChildInFrustum = true; allChildrenReady = allChildrenReady && ((HealpixTile)children[childIndex]).GetDataInView(renderContext, limit, catalogSpreadSheetLayer); } } childIndex++; } } if (anyChildInFrustum) { catalogSpreadSheetLayer.AddTileRows(Key, catalogRows); } return(allChildrenReady && !Downloading); }
public void GetCatalogHipsDataInView(Imageset imageset, bool limit, Action <InViewReturnMessage> onComplete) { CatalogSpreadSheetLayer layer = new CatalogSpreadSheetLayer(); Action onHeaderInfoLoad = delegate() { layer.UseHeadersFromVoTable(imageset.HipsProperties.CatalogColumnInfo); TryGetAllDataInView(imageset, limit, layer, onComplete, 0); }; if (imageset.HipsProperties == null) { imageset.HipsProperties = new HipsProperties(imageset); imageset.HipsProperties.SetDownloadCompleteListener(onHeaderInfoLoad); } else if (imageset.HipsProperties != null && imageset.HipsProperties.DownloadComplete) { onHeaderInfoLoad.Invoke(); } else { imageset.HipsProperties.SetDownloadCompleteListener(onHeaderInfoLoad); } }