Skip to content

Commit

Permalink
WIP: try to enhance starting
Browse files Browse the repository at this point in the history
  • Loading branch information
bmatthieu3 committed Aug 7, 2024
1 parent 16117f0 commit 90ad5a5
Show file tree
Hide file tree
Showing 10 changed files with 124 additions and 30 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@

## 3.5.0-beta

* [enhancement] add `options.colnames` to A.catalogFromVizieR
* [enhancement] add `options.colnames` to A.catalogFromVizieR to tell VizieR we want absolutely want to retrieve specific columns
* [feat] provide a new drawAxes option to A.ellipse. This is useful for plotting error ellipsis.

## 3.4.5-beta

Expand Down
4 changes: 2 additions & 2 deletions examples/al-error-ellipse.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,14 @@
customImg.onload = function() {
const cat = A.catalogFromVizieR('II/246/out', 'm1', 0.1, {onClick: 'showTable', hoverColor: 'purple', limit: 1000, colnames: ["errMin", "errMaj", "errPA"], shape: (s) => {
if (+s.data['Jmag'] > 15) {
return customImg;
return;
} else {
let a = +s.data['errMaj']/36;
let b = +s.data['errMin']/36;

let theta = +s.data['errPA'];

return A.ellipse(s.ra, s.dec, a, b, theta, {fillColor: 'rgba(255, 0, 255, 0.2)'})
return A.ellipse(s.ra, s.dec, a, b, theta, {fillColor: 'rgba(255, 0, 255, 0.2)', drawAxes: true})
}
}});
aladin.addCatalog(cat);
Expand Down
34 changes: 34 additions & 0 deletions examples/al-v2VSv3.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<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>

<!-- Aladin Lite container at requested dimensions -->
<div id="aladin-lite-div" style="width:700px;height:400px;"></div>

<!-- 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>

<!-- Aladin Lite V2 JS code -->
<script type="text/javascript" src="https://aladin.u-strasbg.fr/AladinLite/api/v2/latest/aladin.min.js" charset="utf-8"></script>
<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>

<!-- Aladin Lite V3 JS code -->
<!-- Creation of Aladin Lite instance with initial parameters -->
<script type="module">
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"});
});
</script>
</body>
</html>
6 changes: 5 additions & 1 deletion src/core/src/downloader/request/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,13 @@ where
} else {
resolved_cloned.set(ResolvedStatus::Failed);
}

Ok(JsValue::from_bool(true))
};

wasm_bindgen_futures::spawn_local(fut);
let _ = wasm_bindgen_futures::future_to_promise(fut);

log!("launch promises");
}

Self {
Expand Down
6 changes: 3 additions & 3 deletions src/core/src/downloader/request/tile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@ impl From<TileRequest> for RequestType {
}
}

async fn query_html_image(url: &str) -> Result<HtmlImageElement, JsValue> {
async fn query_html_image(url: &str) -> Result<web_sys::HtmlImageElement, JsValue> {
let image = web_sys::HtmlImageElement::new().unwrap_abort();
let image_cloned = image.clone();

let html_img_elt_promise = js_sys::Promise::new(
let promise = js_sys::Promise::new(
&mut (Box::new(move |resolve, reject| {
// Ask for CORS permissions
image_cloned.set_cross_origin(Some(""));
Expand All @@ -40,7 +40,7 @@ async fn query_html_image(url: &str) -> Result<HtmlImageElement, JsValue> {
}) as Box<dyn FnMut(js_sys::Function, js_sys::Function)>),
);

let _ = JsFuture::from(html_img_elt_promise).await?;
let _ = JsFuture::from(promise).await?;

Ok(image)
}
Expand Down
2 changes: 2 additions & 0 deletions src/core/src/tile_fetcher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,8 @@ impl TileFetcherQueue {
num_fetched_tile += 1;
}
}

log!(num_fetched_tile);
}

pub fn launch_starting_hips_requests(&mut self, hips: &HiPS, downloader: &mut Downloader) {
Expand Down
28 changes: 10 additions & 18 deletions src/js/Catalog.js
Original file line number Diff line number Diff line change
Expand Up @@ -576,31 +576,23 @@ export let Catalog = (function () {
if (this._shapeIsFunction) {
for (const source of sources) {
try {
let shapes = [].concat(this.shape(source));

if (shapes.length == 1 && (shapes[0] instanceof Image || shapes[0] instanceof HTMLCanvasElement)) {
source.setImage(shapes[0]);
} else {
// convert simple shapes to footprints
/*if (
shape instanceof Circle ||
shape instanceof Polyline ||
shape instanceof Ellipse ||
shape instanceof Vector
) {*/
shapes = new Footprint(shapes, source);
//}

//if (shape instanceof Footprint) {
//shape.setSource(source);
let shapes = this.shape(source);
if (shapes) {
shapes = [].concat(shapes);

if (shapes.length == 1 && (shapes[0] instanceof Image || shapes[0] instanceof HTMLCanvasElement)) {
source.setImage(shapes[0]);
} else {
shapes = new Footprint(shapes, source);

let footprint = shapes;
this._shapeIsFootprintFunction = true;

footprint.setCatalog(this);

// store the footprints
footprints.push(footprint);
//}
}
}
} catch (e) {
// do not create the footprint
Expand Down
2 changes: 1 addition & 1 deletion src/js/HiPSProperties.js
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ HiPSProperties.getFasterMirrorUrl = function (metadata, currUrl) {

urls.push(curUrl)
}

console.log(promises)
return Promise.all(promises)
.then((responses) => {
// filter the ones that failed to not choose them
Expand Down
27 changes: 27 additions & 0 deletions src/js/View.js
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,33 @@ 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)
})
};

// different available modes
Expand Down
42 changes: 38 additions & 4 deletions src/js/shapes/Ellipse.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,11 @@ export let Ellipse = (function() {
* @class
* @constructs Ellipse
* @param {number[]} centerRaDec - right-ascension/declination 2-tuple of the ellipse's center in degrees
* @param {number} a - half-major axis length in degrees
* @param {number} b - half-minor axis length in degrees
* @param {number} a - semi-major axis length in degrees
* @param {number} b - semi-minor axis length in degrees
* @param {number} theta - angle of the ellipse in degrees. Origin aligns the ellipsis' major axis with the north pole. Positive angle points towards the east.
* @param {ShapeOptions} options - Configuration options for the ellipse
*
* @param {ShapeOptions} [options] - Configuration options for the ellipse
* @param {boolean} [options.drawAxes] - Whether to show the semi-major and semi-minor axes in dashed
* @returns {Ellipse} - The ellipse shape object
*/
let Ellipse = function(centerRaDec, a, b, theta, options) {
Expand All @@ -55,6 +55,7 @@ export let Ellipse = (function() {
this.selectionColor = options["selectionColor"] || '#00ff00';
this.hoverColor = options["hoverColor"] || undefined;
this.opacity = options['opacity'] || 1;
this.drawAxes = options['drawAxes'] || undefined;

// TODO : all graphic overlays should have an id
this.id = 'ellipse-' + Utils.uuidv4();
Expand Down Expand Up @@ -292,7 +293,40 @@ export let Ellipse = (function() {
ctx.fillStyle = this.fillColor;
ctx.fill();
}

ctx.stroke();

if (this.drawAxes === true) {
let getVertexOnEllipse = (t) => {
let ax = px_per_deg * this.a * Math.cos(theta);
let ay = px_per_deg * this.a * Math.sin(theta);
let bx = -px_per_deg * this.b * Math.sin(theta);
let by = px_per_deg * this.b * Math.cos(theta);

let X = originScreen[0] + ax * Math.cos(t) + bx * Math.sin(t);
let Y = originScreen[1] + ay * Math.cos(t) + by * Math.sin(t);

return [X, Y]
}

let [xa, ya] = getVertexOnEllipse(Math.PI * 0.5)
let [xb, yb] = getVertexOnEllipse(3 * Math.PI * 0.5)
let [xc, yc] = getVertexOnEllipse(Math.PI)
let [xd, yd] = getVertexOnEllipse(0)
ctx.save();

ctx.lineWidth = Math.max(this.lineWidth * 0.5, 1.0);
ctx.setLineDash([this.lineWidth, this.lineWidth]);

ctx.moveTo(xa, ya);
ctx.lineTo(xb, yb);
ctx.moveTo(xc, yc);
ctx.lineTo(xd, yd);

ctx.stroke();

ctx.restore()
}
}

return true;
Expand Down

0 comments on commit 90ad5a5

Please sign in to comment.