Result<(), JsValue> {
+ crate::log(&format!("new hips config {:?}", hips_def));
+
+ let fmt = hips_def.format;
+ let format : Result<_, JsValue> = if fmt.contains("fits") {
+ // Check the bitpix to determine the internal format of the tiles
+ match hips_def.bitpix {
+ 8 => Ok(FormatImageType::FITS(FITS::new(WebGl2RenderingContext::R8UI as i32))),
+ 16 => Ok(FormatImageType::FITS(FITS::new(WebGl2RenderingContext::R16I as i32))),
+ 32 => Ok(FormatImageType::FITS(FITS::new(WebGl2RenderingContext::R32I as i32))),
+ -32 => Ok(FormatImageType::FITS(FITS::new(WebGl2RenderingContext::R32F as i32))),
+ _ => {
+ // The bitpix is not good, so we check for jpeg or png tiles
+ if fmt.contains("png") {
+ Ok(FormatImageType::PNG)
+ } else if fmt.contains("jpeg") || fmt.contains("jpg") {
+ Ok(FormatImageType::JPG)
+ } else {
+ Err(format!("Fits tiles exists but the BITPIX is not correct in the property file").into())
+ }
+ }
+ }
+ } else if fmt.contains("png") {
+ Ok(FormatImageType::PNG)
+ } else if fmt.contains("jpeg") || fmt.contains("jpg") {
+ Ok(FormatImageType::JPG)
+ } else {
+ Err(format!("No format recognized").into())
+ };
+ self.format = format?;
+
let max_depth_tile = hips_def.maxOrder;
let tile_size = hips_def.tileSize;
+ self.tile_config = TileConfig::new(tile_size, &self.format, 0.0);
+
let texture_size = std::cmp::min(512, tile_size << max_depth_tile);
let num_tile_per_side_texture = texture_size / tile_size;
@@ -207,6 +239,9 @@ impl HiPSConfig {
self.root_url = hips_def.url;
self.min_cutout = hips_def.minCutout;
self.max_cutout = hips_def.maxCutout;
+ crate::log(&format!("new hips config3 {:?}", self));
+
+ Ok(())
}
#[inline]
diff --git a/src/render/src/buffer/image.rs b/src/render/src/buffer/image.rs
index b977d751..af811062 100644
--- a/src/render/src/buffer/image.rs
+++ b/src/render/src/buffer/image.rs
@@ -493,7 +493,7 @@ impl ReceiveImage for CompressedImageRequest {
let width = self.image.width() as i32;
let height = self.image.height() as i32;
- let size =Vector2::new(width, height);
+ let size = Vector2::new(width, height);
TileHTMLImage {
size,
image: self.image.clone()
diff --git a/src/render/src/lib.rs b/src/render/src/lib.rs
index 261a86c6..b0a4aa43 100644
--- a/src/render/src/lib.rs
+++ b/src/render/src/lib.rs
@@ -311,8 +311,8 @@ impl App {
self.sphere.set_projection::(&self.viewport, &self.shaders);
}
- fn set_image_survey(&mut self, hips_definition: HiPSDefinition) {
- self.sphere.set_image_survey::(hips_definition, &mut self.viewport, &mut self.task_executor);
+ fn set_image_survey(&mut self, hips_definition: HiPSDefinition) -> Result<(), JsValue> {
+ self.sphere.set_image_survey::(hips_definition, &mut self.viewport, &mut self.task_executor)
}
fn add_catalog(&mut self, name: String, table: JsValue) {
@@ -555,14 +555,14 @@ impl ProjectionType {
};
}
- pub fn set_image_survey(&mut self, app: &mut App, hips_definition: HiPSDefinition) {
+ pub fn set_image_survey(&mut self, app: &mut App, hips_definition: HiPSDefinition) -> Result<(), JsValue> {
match self {
ProjectionType::Aitoff => app.set_image_survey::(hips_definition),
ProjectionType::MollWeide => app.set_image_survey::(hips_definition),
ProjectionType::Ortho => app.set_image_survey::(hips_definition),
ProjectionType::Arc => app.set_image_survey::(hips_definition),
ProjectionType::Mercator => app.set_image_survey::(hips_definition),
- };
+ }
}
pub fn resize(&mut self, app: &mut App, width: f32, height: f32, enable_grid: bool) {
@@ -756,8 +756,8 @@ impl WebClient {
let gl = WebGl2Context::new();
let events = EventManager::new();
let shaders = ShaderManager::new(&gl, shaders).unwrap();
-
let app = App::new(&gl, &events, shaders, resources)?;
+
//let appconfig = AppConfig::Ortho(app);
let dt = DeltaTime::zero();
let enable_inertia = false;
@@ -895,12 +895,12 @@ impl WebClient {
/// Change HiPS
#[wasm_bindgen(js_name = setImageSurvey)]
pub fn set_image_survey(&mut self,
- hips_definition: &JsValue,
+ hips_definition: JsValue,
) -> Result<(), JsValue> {
let hips_definition: HiPSDefinition = hips_definition.into_serde().unwrap();
crate::log(&format!("hips_def222: {:?}", hips_definition));
- self.projection.set_image_survey(&mut self.app, hips_definition);
+ self.projection.set_image_survey(&mut self.app, hips_definition)?;
Ok(())
}
diff --git a/src/render/src/renderable/hips_sphere.rs b/src/render/src/renderable/hips_sphere.rs
index 639cdf33..db54811a 100644
--- a/src/render/src/renderable/hips_sphere.rs
+++ b/src/render/src/renderable/hips_sphere.rs
@@ -237,6 +237,8 @@ use crate::{
use crate::TransferFunction;
use crate::shaders::Colormap;
use crate::HiPSDefinition;
+use wasm_bindgen::JsValue;
+
impl HiPSSphere {
pub fn new(gl: &WebGl2Context, viewport: &ViewPort, config: HiPSConfig, shaders: &ShaderManager) -> Self {
let buffer = BufferTextures::new(gl, &config, viewport);
@@ -259,14 +261,15 @@ impl HiPSSphere {
gl,
}
}
-
- pub fn set_image_survey(&mut self, hips_definition: HiPSDefinition, viewport: &mut ViewPort, task_executor: &mut AladinTaskExecutor) {
- self.config.set_HiPS_definition(hips_definition);
+ pub fn set_image_survey(&mut self, hips_definition: HiPSDefinition, viewport: &mut ViewPort, task_executor: &mut AladinTaskExecutor) -> Result<(), JsValue> {
+ self.config.set_HiPS_definition(hips_definition)?;
// Tell the viewport the config has changed
viewport.set_image_survey::(&self.config);
// Clear the buffer
self.buffer.reset(&self.gl, &self.config, viewport, task_executor);
+
+ Ok(())
}
pub fn ask_for_tiles(&mut self, cells: &HashMap) {