fasten a little bit the starting by disabling the download of less precised tiles and thus it will only blend the good resolued tiles with less precised ones.

This commit is contained in:
Matthieu Baumann
2024-08-11 12:37:18 +02:00
committed by Matthieu Baumann
parent c9b1fc5f7f
commit 69b2254542
6 changed files with 152 additions and 147 deletions

View File

@@ -13,10 +13,10 @@
aladin = A.aladin(
'#aladin-lite-div',
{
//survey: 'P/allWISE/color', // set initial image survey
survey: 'P/allWISE/color', // set initial image survey
projection: 'AIT', // set a projection
fov: 1.5, // initial field of view in degrees
target: '10 10', // initial target
target: 'orion', // initial target
cooFrame: 'icrs', // set galactic frame
reticleColor: '#ff89ff', // change reticle color
reticleSize: 64, // change reticle size

View File

@@ -1,6 +1,5 @@
<html>
<head>
<link rel="stylesheet" type="text/css" href="//aladin.u-strasbg.fr/AladinLite/api/v2/latest/aladin.min.css">
</head>
<body>
<h1>Trifid interactive map</h1>
@@ -10,7 +9,6 @@
<!-- our script needs jQuery -->
<script type="text/javascript" src="https://code.jquery.com/jquery-1.9.1.min.js" charset="utf-8"></script>
<!-- V2-->
<div id="aladin-lite-div-old" style="width:700px;height:400px;"></div>
@@ -19,15 +17,18 @@
<script type="text/javascript">
var aladinold = A.aladin('#aladin-lite-div-old', {survey: "P/allWISE/color", fov:1.5, target: "14 03 12.583 +54 20 55.5"});
</script>
<script type="text/javascript" src="./../dist/aladin.umd.cjs" charset="utf-8"></script>
<!-- Aladin Lite V3 JS code -->
<!-- Creation of Aladin Lite instance with initial parameters -->
<script type="module">
import A from '../src/js/A.js';
<script type="text/javascript">
//import A from '../src/js/A.js';
let aladin;
A.init.then(() => {
aladin = A.aladin('#aladin-lite-div', {survey: "https://alasky.cds.unistra.fr/AllWISE/RGB-W4-W2-W1/", fov:1.5, target: "14 03 12.583 +54 20 55.5"});
aladin = A.aladin('#aladin-lite-div', {survey: "https://alasky.cds.unistra.fr/AllWISE/RGB-W4-W2-W1/", fov:1.5, target: "14 03 12.583 +54 20 55.5", });
});
</script>
</body>

View File

@@ -262,8 +262,6 @@ impl App {
// Move the views of the different active surveys
self.tile_fetcher.clear();
// Loop over the surveys
let _raytracer = self.layers.get_raytracer();
for survey in self.layers.values_mut_hips() {
if self.camera.get_texture_depth() == 0
&& self
@@ -292,9 +290,14 @@ impl App {
&mut self.downloader,
);
if tile_cell.depth() >= min_tile_depth + 3 {
let ancestor_tile_cell = tile_cell.ancestor(3);
ancestors.insert(ancestor_tile_cell);
// check if we are starting aladin lite or not.
// If so we want to retrieve only the tiles in the view and access them
// directly i.e. without blending them with less precised tiles
if self.tile_fetcher.get_num_tile_fetched() > 0 {
if tile_cell.depth() >= min_tile_depth + 3 {
let ancestor_tile_cell = tile_cell.ancestor(3);
ancestors.insert(ancestor_tile_cell);
}
}
//let ancestor_next_tile_cell = next_tile_cell.ancestor(3);
//if !survey.contains_tile(&ancestor_tile_cell) {
@@ -598,117 +601,116 @@ impl App {
for rsc in rscs_received {
match rsc {
Resource::Tile(tile) => {
if !_has_camera_zoomed {
if let Some(survey) =
self.layers.get_mut_hips_from_cdid(&tile.get_hips_cdid())
{
let cfg = survey.get_config_mut();
//if !_has_camera_zoomed {
if let Some(survey) =
self.layers.get_mut_hips_from_cdid(&tile.get_hips_cdid())
{
let cfg = survey.get_config_mut();
if cfg.get_format() == tile.format {
let delta_depth = cfg.delta_depth();
let fov_coverage = self.camera.get_cov(cfg.get_frame());
let included_or_near_coverage = tile
.cell()
.get_texture_cell(delta_depth)
.get_tile_cells(delta_depth)
.any(|neighbor_tile_cell| {
fov_coverage.intersects_cell(&neighbor_tile_cell)
});
if cfg.get_format() == tile.format {
let delta_depth = cfg.delta_depth();
let fov_coverage = self.camera.get_cov(cfg.get_frame());
let included_or_near_coverage = tile
.cell()
.get_texture_cell(delta_depth)
.get_tile_cells(delta_depth)
.any(|neighbor_tile_cell| {
fov_coverage.intersects_cell(&neighbor_tile_cell)
});
//let is_tile_root = tile.cell().depth() == delta_depth;
//let _depth = tile.cell().depth();
// do not perform tex_sub costly GPU calls while the camera is zooming
if included_or_near_coverage {
let is_missing = tile.missing();
/*self.tile_fetcher.notify_tile(
&tile,
true,
false,
&mut self.downloader,
);*/
let Tile {
cell,
image,
time_req,
..
} = tile;
//let is_tile_root = tile.cell().depth() == delta_depth;
//let _depth = tile.cell().depth();
// do not perform tex_sub costly GPU calls while the camera is zooming
if included_or_near_coverage {
let is_missing = tile.missing();
/*self.tile_fetcher.notify_tile(
&tile,
true,
false,
&mut self.downloader,
);*/
let Tile {
cell,
image,
time_req,
..
} = tile;
let image = if is_missing {
// Otherwise we push nothing, it is probably the case where:
// - an request error occured on a valid tile
// - the tile is not present, e.g. chandra HiPS have not the 0, 1 and 2 order tiles
None
} else {
Some(image)
};
use al_core::image::ImageType;
use fitsrs::fits::Fits;
use std::io::Cursor;
if let Some(image) = image.as_ref() {
match &*image.lock().unwrap_abort() {
Some(ImageType::FitsImage {
raw_bytes: raw_bytes_buf,
}) => {
// check if the metadata has not been set
if !cfg.fits_metadata {
let num_bytes =
raw_bytes_buf.length() as usize;
let mut raw_bytes = vec![0; num_bytes];
raw_bytes_buf.copy_to(&mut raw_bytes[..]);
let image = if is_missing {
// Otherwise we push nothing, it is probably the case where:
// - an request error occured on a valid tile
// - the tile is not present, e.g. chandra HiPS have not the 0, 1 and 2 order tiles
None
} else {
Some(image)
};
use al_core::image::ImageType;
use fitsrs::fits::Fits;
use std::io::Cursor;
if let Some(image) = image.as_ref() {
match &*image.lock().unwrap_abort() {
Some(ImageType::FitsImage {
raw_bytes: raw_bytes_buf,
}) => {
// check if the metadata has not been set
if !cfg.fits_metadata {
let num_bytes = raw_bytes_buf.length() as usize;
let mut raw_bytes = vec![0; num_bytes];
raw_bytes_buf.copy_to(&mut raw_bytes[..]);
let mut bytes_reader =
Cursor::new(raw_bytes.as_slice());
let Fits { hdu } =
Fits::from_reader(&mut bytes_reader)
.map_err(|_| {
JsValue::from_str(
"Parsing fits error",
)
})?;
let mut bytes_reader =
Cursor::new(raw_bytes.as_slice());
let Fits { hdu } =
Fits::from_reader(&mut bytes_reader)
.map_err(|_| {
JsValue::from_str(
"Parsing fits error",
)
})?;
let header = hdu.get_header();
let bscale = if let Some(
fitsrs::card::Value::Float(bscale),
) = header.get(b"BSCALE ")
{
*bscale as f32
} else {
1.0
};
let bzero = if let Some(
fitsrs::card::Value::Float(bzero),
) = header.get(b"BZERO ")
{
*bzero as f32
} else {
0.0
};
let blank = if let Some(
fitsrs::card::Value::Float(blank),
) = header.get(b"BLANK ")
{
*blank as f32
} else {
std::f32::NAN
};
let header = hdu.get_header();
let bscale = if let Some(
fitsrs::card::Value::Float(bscale),
) = header.get(b"BSCALE ")
{
*bscale as f32
} else {
1.0
};
let bzero = if let Some(
fitsrs::card::Value::Float(bzero),
) = header.get(b"BZERO ")
{
*bzero as f32
} else {
0.0
};
let blank = if let Some(
fitsrs::card::Value::Float(blank),
) = header.get(b"BLANK ")
{
*blank as f32
} else {
std::f32::NAN
};
cfg.set_fits_metadata(bscale, bzero, blank);
}
cfg.set_fits_metadata(bscale, bzero, blank);
}
_ => (),
}
_ => (),
}
survey.add_tile(&cell, image, time_req)?;
self.request_redraw = true;
self.time_start_blending = Time::now();
}
survey.add_tile(&cell, image, time_req)?;
self.request_redraw = true;
self.time_start_blending = Time::now();
}
}
} else {
self.downloader.delay_rsc(Resource::Tile(tile));
}
/*} else {
self.downloader.delay_rsc(Resource::Tile(tile));
}*/
}
Resource::Allsky(allsky) => {
let hips_cdid = allsky.get_hips_cdid();
@@ -783,13 +785,14 @@ impl App {
let has_not_moved_recently =
(Time::now() - self.camera.get_time_of_last_move()) > DeltaTime(100.0);
let dt = if has_not_moved_recently {
/*let dt = if has_not_moved_recently {
None
} else {
Some(DeltaTime::from_millis(700.0))
};
self.tile_fetcher.notify(&mut self.downloader, dt);
};*/
if has_not_moved_recently {
self.tile_fetcher.notify(&mut self.downloader, None);
}
}
}
@@ -797,7 +800,7 @@ impl App {
//self.layers.update(&mut self.camera, &self.projection);
if self.request_for_new_tiles
&& Time::now() - self.last_time_request_for_new_tiles > DeltaTime::from(200.0)
//&& Time::now() - self.last_time_request_for_new_tiles > DeltaTime::from(200.0)
{
self.look_for_new_tiles()?;

View File

@@ -1,6 +1,15 @@
struct BitVector<const N: usize>([u64; N]);
impl<const N: usize> Default for BitVector<N> {
fn default() -> Self {
Self([0_u64; N])
}
}
impl<const N: usize> BitVector<N> {
pub fn new_empty() -> Self {
Self::default()
}
pub fn set(&mut self, i: usize) {
debug_assert!(i < (N << 6));
let j = i >> 6;
@@ -17,3 +26,14 @@ impl<const N: usize> BitVector<N> {
(self.0[j] >> k) & 0x1 == 1
}
}
mod tests {
use super::BitVector;
#[test]
fn test_bitvector_basic_op() {
let mut bv: BitVector<32> = BitVector::new_empty();
bv.set(64);
assert!(bv.get(64));
}
}

View File

@@ -5,7 +5,7 @@ use crate::Abort;
use std::collections::VecDeque;
const MAX_NUM_TILE_FETCHING: isize = 8;
const MAX_NUM_TILE_FETCHING: usize = 8;
const MAX_QUERY_QUEUE_LENGTH: usize = 100;
pub struct TileFetcherQueue {
@@ -13,6 +13,7 @@ pub struct TileFetcherQueue {
queries: VecDeque<query::Tile>,
base_tile_queries: Vec<query::Tile>,
tiles_fetched_time: Time,
num_tiles_fetched: usize,
}
impl TileFetcherQueue {
@@ -20,10 +21,12 @@ impl TileFetcherQueue {
let queries = VecDeque::new();
let base_tile_queries = Vec::new();
let tiles_fetched_time = Time::now();
let mut num_tiles_fetched = 0;
Self {
queries,
base_tile_queries,
tiles_fetched_time,
num_tiles_fetched,
}
}
@@ -63,6 +66,10 @@ impl TileFetcherQueue {
}
}
pub fn get_num_tile_fetched(&self) -> usize {
self.num_tiles_fetched
}
fn fetch(&mut self, downloader: &mut Downloader) {
// Fetch the base tiles with higher priority
while let Some(query) = self.base_tile_queries.pop() {
@@ -83,7 +90,8 @@ impl TileFetcherQueue {
}
}
log!(num_fetched_tile);
self.num_tiles_fetched += num_fetched_tile;
//log!(num_fetched_tile);
}
pub fn launch_starting_hips_requests(&mut self, hips: &HiPS, downloader: &mut Downloader) {

View File

@@ -294,35 +294,7 @@ export let View = (function () {
}
self.requestRedraw();
}, 1000);*/
console.log("aaaa bbbb")
const loadImage = (url) => {
return fetch(url);
}
const f = async (url) => {
let result = await loadImage(url)
.then((resp) => {
return Promise.resolve(true);
}).catch((e) => {
return Promise.resolve(false);
});
console.log("url fetched", url)
return result;
};
let p = []
for (var i = 0; i < 48; i++) {
p.push(f("https://alasky.cds.unistra.fr/DSS/DSSColor/Norder1/Dir0/Npix" + i + ".jpg"))
};
let b = Promise.all(p)
.then((a) => {
console.log("jkjkdsjf", a)
})
}, 1000);*/
};
// different available modes
@@ -1339,7 +1311,8 @@ export let View = (function () {
//if (elapsedTime >= View.FPS_INTERVAL) {
// Get ready for next frame by setting then=now, but also adjust for your
// specified fpsInterval not being a multiple of RAF's interval (16.7ms)
//if (this.dt > 10)
// console.log(this.dt)
// Drawing code
//try {
this.moving = this.wasm.update(elapsedTime);