WIP: try to enhance starting

This commit is contained in:
Matthieu Baumann
2024-08-07 14:16:08 +02:00
committed by Matthieu Baumann
parent b9fb0b7e53
commit 0024032861
10 changed files with 122 additions and 28 deletions

View File

@@ -7,7 +7,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

View File

@@ -17,14 +17,14 @@ A.init.then(() => {
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);

34
examples/al-v2VSv3.html Normal file
View File

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

View File

@@ -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 {

View File

@@ -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(""));
@@ -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)
}

View File

@@ -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) {

View File

@@ -576,23 +576,15 @@ export let Catalog = (function () {
if (this._shapeIsFunction) {
for (const source of sources) {
try {
let shapes = [].concat(this.shape(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 {
// convert simple shapes to footprints
/*if (
shape instanceof Circle ||
shape instanceof Polyline ||
shape instanceof Ellipse ||
shape instanceof Vector
) {*/
shapes = new Footprint(shapes, source);
//}
if (shapes.length == 1 && (shapes[0] instanceof Image || shapes[0] instanceof HTMLCanvasElement)) {
source.setImage(shapes[0]);
} else {
shapes = new Footprint(shapes, source);
//if (shape instanceof Footprint) {
//shape.setSource(source);
let footprint = shapes;
this._shapeIsFootprintFunction = true;
@@ -600,7 +592,7 @@ export let Catalog = (function () {
// store the footprints
footprints.push(footprint);
//}
}
}
} catch (e) {
// do not create the footprint

View File

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

View File

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

View File

@@ -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) {
@@ -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();
@@ -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;