fix multiple little things to make the examples on https://aladin.cds.unistra.fr/AladinLite/doc/API/examples/ pass

This commit is contained in:
Matthieu Baumann
2024-03-26 18:36:37 +01:00
parent 2062d6bfeb
commit cf26bd840c
10 changed files with 112 additions and 24 deletions

View File

@@ -22,10 +22,8 @@
samp: true,
});
A.catalogFromSimbad('09 55 52.4 +69 40 47', 0.1, {onClick: 'showTable', limit: 1000}, (cat) => {
aladin.addCatalog(cat)
});
aladin.addCatalog(A.catalogFromNED('09 55 52.4 +69 40 47', 0.1, {onClick: 'showPopup', shape: 'plus'}));
aladin.addCatalog(A.catalogFromSimbad('M 82', 0.1, {onClick: 'showTable'}));
aladin.addCatalog(A.catalogFromNED('09 55 52.4 +69 40 47', 0.1, {onClick: 'showPopup', shape: 'plus'}));
});
</script>

View File

@@ -0,0 +1,45 @@
<!doctype html>
<html>
<head>
</head>
<body>
<script src="https://code.jquery.com/jquery-1.10.1.min.js"></script>
<div id="aladin-lite-div" style="width: 1024px; height: 768px"></div>
Show sources with proper motion greater than:
<input id='slider' style='vertical-align:middle;width:60vw;' step='1' min='0' max='10' type='range' value='0'>
<span id='pmVal' >0 mas/yr</span><br><br><div id='aladin-lite-div' style='width: 500px;height: 500px;'></div>
<script type="module">
import A from '../src/js/A.js';
let aladin;
A.init.then(() => {
var colorThreshold = 0;
var slider = document.getElementById('slider');
slider.oninput = function() {
colorThreshold = this.value;
$('#colorVal').html(colorThreshold);
cat.reportChange();
}
var myFilterFunction = function(source) {
const magB = parseFloat(source.data['B']);
const magV = parseFloat(source.data['V']);
if (isNaN(magB) || isNaN(magV) ) {
return false;
}
const color = magB - magV;
return color>colorThreshold;
}
aladin = A.aladin('#aladin-lite-div', {target: 'M 81', fov: 0.5, survey: 'CDS/P/SDSS9/color'});
var cat = A.catalogFromSimbad('M 81', 0.25, {onClick: 'showTable', verbosity: 3, filter: myFilterFunction});
aladin.addCatalog(cat);
});
</script>
</body>
</html>

View File

@@ -3,7 +3,7 @@ name = "aladin-lite"
description = "Aladin Lite v3 introduces a new graphical engine written in Rust with the use of WebGL"
license = "BSD-3-Clause"
repository = "https://github.com/cds-astro/aladin-lite"
version = "3.3.0"
version = "3.3.1"
authors = [ "baumannmatthieu0@gmail.com", "matthieu.baumann@astro.unistra.fr",]
edition = "2018"

View File

@@ -1,8 +1,8 @@
body { overscroll-behavior: contain; }
/*body { overscroll-behavior: contain; }*/
.aladin-container {
position: relative;
height: 100%;
/*height: 100%;*/
border: 0px solid #ddd;
/* SVG inside divs add a 4px height: https://stackoverflow.com/questions/75751593/why-there-is-additional-4px-height-for-div-when-there-is-svg-inside-it */
@@ -115,6 +115,7 @@ body { overscroll-behavior: contain; }
.aladin-measurement-div.aladin-dark-theme table thead {
background-color: #000;
color: white;
}
.aladin-measurement-div table td.aladin-href-td-container a:hover {
@@ -412,6 +413,9 @@ canvas {
.aladin-measurement-div.aladin-dark-theme {
background-color: rgba(0, 0, 0, 0.5);
border: 1px solid white;
}
.aladin-measurement-div.aladin-dark-theme table {
color: white;
}
@@ -1168,6 +1172,9 @@ canvas {
max-width: calc(100% - 0.4rem);
line-height: 1rem;
}
.aladin-measurement-div.aladin-dark-theme {
color: white;
}
.aladin-share-control {
position: absolute;

View File

@@ -44,6 +44,7 @@ import { Aladin } from "./Aladin.js";
import { ActionButton } from "./gui/Widgets/ActionButton.js";
import { Box } from "./gui/Widgets/Box.js";
import { AladinUtils } from "./AladinUtils.js";
import { Sesame } from "./Sesame.js";
// Wasm top level import
import init, * as module from './../core/pkg';
@@ -502,9 +503,9 @@ A.catalogFromURL = function (url, options, successCallback, errorCallback, usePr
* @param {number} target.dec - Declination in degrees of the cone's center
* @param {number} radius - Radius of the cone in degrees
* @param {Object|CatalogOptions} [options] - Additional configuration options for SIMBAD cone search. See the {@link https://simbad.cds.unistra.fr/cone/help/#/ConeSearch/get_ SIMBAD cone search} parameters.
* @param {Object} [options.limit] - The max number of sources to return
* @param {Object} [options.orderBy] - Order the result by specific
*
* @param {number} [options.limit] - The max number of sources to return
* @param {string} [options.orderBy='nb_ref'] - Order the result by specific ref number
* @param {number} [options.verbosity=2] - Verbosity, put 3 if you want all the column
* @param {function} [successCallback] - The callback function to execute on successful catalog creation.
* @param {function} [errorCallback] - The callback function to execute on error during catalog creation.
* @returns {Catalog} A new instance of the Catalog class created from the SIMBAD cone search.
@@ -519,8 +520,8 @@ A.catalogFromSimbad = function (target, radius, options, successCallback, errorC
if (!('name' in options)) {
options['name'] = 'Simbad';
}
return new Promise((resolve, reject) => {
let cat = A.catalog(options);
new Promise((resolve, reject) => {
let coo;
if (target && (typeof target === "object")) {
if ('ra' in target && 'dec' in target) {
@@ -556,8 +557,45 @@ A.catalogFromSimbad = function (target, radius, options, successCallback, errorC
}
}).then((coo) => {
const url = URLBuilder.buildSimbadCSURL(coo.lon, coo.lat, radius, options)
return A.catalogFromURL(url, options, successCallback, errorCallback, false);
const processVOTable = function (table) {
let {sources, footprints, fields, type} = table;
cat.setFields(fields);
if (cat.type === 'ObsCore') {
// The fields corresponds to obscore ones
// Set the name of the catalog to be ObsCore:<catalog name>
cat.name = "ObsCore:" + url;
}
cat.addFootprints(footprints)
cat.addSources(sources);
if (successCallback) {
successCallback(cat);
}
if (sources.length === 0) {
console.warn(cat.name + ' has no sources!')
}
// Even if the votable is not a proper ObsCore one, try to see if specific columns are given
// e.g. access_format and access_url
//ObsCore.handleActions(catalog);
};
Catalog.parseVOTable(
url,
processVOTable,
errorCallback,
cat.maxNbSources,
false,
cat.raField, cat.decField
);
})
return cat;
};
/**

View File

@@ -2057,7 +2057,8 @@ export let Aladin = (function () {
* @param {Function} successCallback - The callback function to be executed on a successful display.
* The callback gives the ra, dec, and fov of the image;
* @param {Function} errorCallback - The callback function to be executed if an error occurs during display.
*
* @param {string} [layer="base"] - The name of the layer. If not specified, it will be replace the base layer.
*
* @example
* aladin.displayJPG(
* // the JPG to transform to HiPS
@@ -2099,6 +2100,7 @@ export let Aladin = (function () {
* @param {Function} successCallback - The callback function to be executed on a successful display.
* The callback gives the ra, dec, and fov of the image;
* @param {Function} errorCallback - The callback function to be executed if an error occurs during display.
* @param {string} [layer="overlay"] - The name of the layer. If not specified, it will add a new overlay layer on top of the base.
*
* @example
* aladin.displayJPG(
@@ -2113,7 +2115,7 @@ export let Aladin = (function () {
* })
*);
*/
Aladin.prototype.displayJPG = function (url, options, successCallback, errorCallback) {
Aladin.prototype.displayJPG = function (url, options, successCallback, errorCallback, layer = "overlay") {
options = options || {};
options.color = true;
options.label = options.label || "JPG/PNG image";
@@ -2163,7 +2165,7 @@ export let Aladin = (function () {
var meta = response.data.meta;
const survey = self.createImageSurvey(response.data.url, label, response.data.url);
self.setOverlayImageLayer(survey, "overlay");
self.setOverlayImageLayer(survey, layer);
var transparency = (options && options.transparency) || 1.0;
survey.setOpacity(transparency);

View File

@@ -209,8 +209,6 @@ export let ImageFITS = (function () {
return self;
}).catch((e) => {
window.alert(e + ". See the javascript console for more logging details.")
if (self.errorCallback) {
self.errorCallback()
}

View File

@@ -40,6 +40,10 @@ export let URLBuilder = (function() {
url += '&MAXREC=' + options.limit;
}
if (options && options.verbosity) {
url += '&VERB=' + options.verbosity;
}
const orderBy = options && options.orderBy || 'nb_ref';
url += '&ORDER_BY=' + orderBy;

View File

@@ -351,8 +351,8 @@ export let View = (function () {
this.aladinDiv.style.setProperty('line-height', 0);
Utils.cssScale = undefined;
var computedWidth = parseFloat(window.getComputedStyle(this.aladinDiv).width) || 1.0;
var computedHeight = parseFloat(window.getComputedStyle(this.aladinDiv).height) || 1.0;
var computedWidth = parseFloat(this.aladinDiv.getBoundingClientRect().width) || 1.0;
var computedHeight = parseFloat(this.aladinDiv.getBoundingClientRect().height) || 1.0;
this.width = Math.max(computedWidth, 1);
this.height = Math.max(computedHeight, 1); // this prevents many problems when div size is equal to 0

View File

@@ -85,10 +85,6 @@ export class ServiceQueryBox extends Box {
.catch((e) => {
window.alert(e)
})
.finally(() => {
// set cursor back to the normal mode
//loadingBtn.remove();
})
},
subInputs: []
});