Skip to content

Commit

Permalink
wip: image format inference, avm parser based on https://www.strudel.…
Browse files Browse the repository at this point in the history
…org.uk/avm/js/, wcs creation from avm tags
  • Loading branch information
bmatthieu3 committed Jul 23, 2024
1 parent 0cf53a6 commit 1661ec6
Show file tree
Hide file tree
Showing 9 changed files with 468 additions and 90 deletions.
2 changes: 1 addition & 1 deletion examples/al-hips-local.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
A.init.then(() => {
aladin = A.aladin('#aladin-lite-div', {target: "05 40 59.12 -02 27 04.1", fov: 2});

let survey = aladin.createImageSurvey('DSS2 local', "local hips", "hips/CDS_P_DSS2_color");
let survey = aladin.createImageSurvey('DSS2 local', "local hips", "./hips/CDS_P_DSS2_color");
aladin.setBaseImageLayer(survey);
});
</script>
Expand Down
28 changes: 28 additions & 0 deletions examples/al-image-with-AVM-tags.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<!doctype html>
<html>
<head>
</head>
<body>
<div id="aladin-lite-div" style="width: 1024px; height: 768px"></div>
<script type="module">
import A from '../src/js/A.js';
A.init.then(() => {
let aladin = A.aladin('#aladin-lite-div', {fov: 30, survey: "CDS/P/PanSTARRS/DR1/color-z-zg-g", target: "280 +0", projection: "AIT", showShareControl:true, showSettingsControl: true, showContextMenu:true});

aladin.setOverlayImageLayer(A.image(
//"https://www.virtualastronomy.org/images/sig05-013.jpg",
"https://www.astropix.org/archive/eso/eso0755a/eso_eso0755a_1280.jpg",
{
name: "sig05-017",
successCallback: (ra, dec, fov, image) => {
console.log(ra, dec)
aladin.gotoRaDec(ra, dec);
aladin.setFoV(fov * 5)
}
},
));
});

</script>
</body>
</html>
1 change: 0 additions & 1 deletion examples/al-image-with-WCS.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
"https://nova.astrometry.net/image/25038473?filename=M61.jpg",
{
name: "M61",
imgFormat: 'jpeg',
wcs: {
NAXIS: 0, // Minimal header
CTYPE1: 'RA---TAN', // TAN (gnomic) projection
Expand Down
5 changes: 3 additions & 2 deletions src/core/src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1115,7 +1115,6 @@ impl App {

pub(crate) fn add_image_fits(
&mut self,
id: String,
stream: web_sys::ReadableStream,
meta: ImageMetadata,
layer: String,
Expand Down Expand Up @@ -1245,8 +1244,9 @@ impl App {
} else {
let fits = ImageLayer {
images,
id: layer.clone(),

layer,
id,
meta,
};

Expand Down Expand Up @@ -1301,6 +1301,7 @@ impl App {
) -> Result<(), JsValue> {
let old_meta = self.layers.get_layer_cfg(&layer)?;
// Set the new meta
// keep the old meta data
let new_img_fmt = meta.img_format;
self.layers
.set_layer_cfg(layer.clone(), meta, &mut self.camera, &self.projection)?;
Expand Down
8 changes: 3 additions & 5 deletions src/core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -382,21 +382,19 @@ impl WebClient {
#[wasm_bindgen(js_name = addImageFITS)]
pub fn add_image_fits(
&mut self,
id: String,
stream: web_sys::ReadableStream,
cfg: JsValue,
layer: String,
) -> Result<js_sys::Promise, JsValue> {
let cfg: ImageMetadata = serde_wasm_bindgen::from_value(cfg)?;
//let wcs: Option<WCSParams> = serde_wasm_bindgen::from_value(wcs)?;

self.app.add_image_fits(id, stream, cfg, layer)
self.app.add_image_fits(stream, cfg, layer)
}

#[wasm_bindgen(js_name = addImageWithWCS)]
pub fn add_image_with_wcs(
&mut self,
data: web_sys::ReadableStream,
stream: web_sys::ReadableStream,
wcs: JsValue,
cfg: JsValue,
layer: String,
Expand All @@ -406,7 +404,7 @@ impl WebClient {
let wcs_params: WCSParams = serde_wasm_bindgen::from_value(wcs)?;
let wcs = WCS::new(&wcs_params).map_err(|e| JsValue::from_str(&format!("{:?}", e)))?;

self.app.add_image_from_blob_and_wcs(layer, data, wcs, cfg)
self.app.add_image_from_blob_and_wcs(layer, stream, wcs, cfg)
}

#[wasm_bindgen(js_name = removeLayer)]
Expand Down
2 changes: 1 addition & 1 deletion src/glsl/webgl2/image/sampler.frag
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@ uniform float opacity;
#include ../hips/color.glsl;

void main() {
out_frag_color = texture(tex, frag_uv);
out_frag_color = texture(tex, vec2(frag_uv.x, 1.0 - frag_uv.y));
out_frag_color.a = out_frag_color.a * opacity;
}
Loading

0 comments on commit 1661ec6

Please sign in to comment.