should fix #330, refac keyword heuristic from the HiPS standard

This commit is contained in:
Matthieu Baumann
2026-05-28 15:00:47 +02:00
parent 87632e3cbe
commit a247704f41
12 changed files with 5258 additions and 5221 deletions
+1 -1
View File
@@ -9,7 +9,7 @@
let aladin; let aladin;
A.init.then(() => { A.init.then(() => {
aladin = A.aladin('#aladin-lite-div', { fov:0.15, target: 'Arp 240', showContextMenu: true, showReticle: false, fullScreen: true }); aladin = A.aladin('#aladin-lite-div', { fov:0.15, target: 'Arp 240', showContextMenu: true, showReticle: false, fullScreen: true });
aladin.setBaseImageLayer(aladin.newImageSurvey('P/SDSS9/g', {colormap: "eosb", stretch: "linear"})); aladin.setBaseImageLayer(aladin.newImageSurvey('P/SDSS9/g', {url: 'https://alasky.cds.unistra.fr/SDSS/DR9/band-g/', maxOrder: 10, cooFrame: 'icrs', imgFormat: 'png', colormap: "eosb", stretch: "linear"}));
var simbad = A.catalog({name: 'Simbad', sourceSize: 16, color: '#4050F0'}); var simbad = A.catalog({name: 'Simbad', sourceSize: 16, color: '#4050F0'});
aladin.addCatalog(simbad); aladin.addCatalog(simbad);
+3 -3
View File
@@ -7,10 +7,10 @@
<script type="module"> <script type="module">
import A from '../src/js/A.js'; import A from '../src/js/A.js';
A.init.then(() => { A.init.then(() => {
let aladin = A.aladin('#aladin-lite-div', {survey: ["lksldf", 'ljkjsdf', "https://alasky.cds.unistra.fr/HIPS3D/LGLBSHI16"], target: "23 28 32.46 -00 10 38.9", fov: 4, projection: "AIT"}); let aladin = A.aladin('#aladin-lite-div', {survey: ["lksldf", 'ljkjsdf'], target: "23 28 32.46 -00 10 38.9", fov: 4, projection: "AIT"});
//let hsc = aladin.newImageSurvey("P/HSC/DR2/deep/g", {colormap:"Purples", imgFormat: "fits"}); let hsc = aladin.newImageSurvey("P/HSC/DR2/deep/g", {colormap:"Purples", imgFormat: "fits"});
//aladin.setBaseImageLayer(hsc); aladin.setBaseImageLayer(hsc);
}); });
</script> </script>
-1
View File
@@ -14,7 +14,6 @@
{ {
name: "spitzer-ssc2005-24a1", name: "spitzer-ssc2005-24a1",
successCallback: (ra, dec, fov, image) => { successCallback: (ra, dec, fov, image) => {
console.log(ra, dec)
aladin.gotoRaDec(ra, dec); aladin.gotoRaDec(ra, dec);
aladin.setFoV(fov * 5) aladin.setFoV(fov * 5)
} }
+36
View File
@@ -0,0 +1,36 @@
<!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';
let aladin;
A.init.then(() => {
aladin = A.aladin("#aladin-lite-div", {
fov: 2,
survey:
"https://images.rubinobservatory.org/hips/SVImages_v2/color_ugri",
backgroundColor: "rgb(0,0,0)",
cooFrame: "ICRSd",
});
aladin.setFoVRange(0.002, 10);
aladin.gotoRaDec(186.5, 6.95);
const secondSurvey = {
imgFormat: "webp",
cooFrame: "ICRSd",
maxOrder: 11,
url: "https://images.rubinobservatory.org/hips/asteroids/color_ugri",
};
const hips = A.HiPS(secondSurvey.url, { ...secondSurvey, opacity: 1 });
aladin.setOverlayImageLayer(hips);
});
</script>
</body>
</html>
+1 -1
View File
@@ -21,7 +21,7 @@
console.log("Rotation just changed to ", rotation); console.log("Rotation just changed to ", rotation);
}) })
aladin.on("positionChanged", ({ra, dec}) => { aladin.on("positionChanged", ({ra, dec}) => {
console.log('call to aladin', aladin.pix2world(300, 300, "galactic")) console.log('call to aladin', aladin.pix2world(300, 300, 'gal'))
console.log('positionChanged in icrs', ra, dec) console.log('positionChanged in icrs', ra, dec)
}) })
+2 -2
View File
@@ -31,8 +31,8 @@ use wasm_bindgen::prelude::*;
#[wasm_bindgen] #[wasm_bindgen]
#[derive(Clone, Copy, PartialEq, Eq, Debug, Deserialize, Hash)] #[derive(Clone, Copy, PartialEq, Eq, Debug, Deserialize, Hash)]
pub enum CooSystem { pub enum CooSystem {
ICRS = 0, ICRS,
GAL = 1, GAL,
} }
pub const NUM_COOSYSTEM: usize = 2; pub const NUM_COOSYSTEM: usize = 2;
+5162 -5162
View File
File diff suppressed because it is too large Load Diff
+4 -15
View File
@@ -1958,7 +1958,7 @@ export let Aladin = (function () {
return this.createImageSurvey( return this.createImageSurvey(
id, id,
options && options.name, options && options.name,
id, options && options.url || id,
options && options.cooFrame, options && options.cooFrame,
options && options.maxOrder, options && options.maxOrder,
options options
@@ -2211,7 +2211,7 @@ export let Aladin = (function () {
* view in the counter clockwise order (or towards the east) * view in the counter clockwise order (or towards the east)
*/ */
Aladin.prototype.setRotation = function (rotation) { Aladin.prototype.setRotation = function (rotation) {
if (!rotation) { if (Utils.isNumber(rotation)) {
console.warn("Rotation angle is not valid:", rotation) console.warn("Rotation angle is not valid:", rotation)
return; return;
} }
@@ -2808,13 +2808,8 @@ export let Aladin = (function () {
if (typeof frame === "string") { if (typeof frame === "string") {
frame = CooFrameEnum.fromString(frame, CooFrameEnum.ICRS); frame = CooFrameEnum.fromString(frame, CooFrameEnum.ICRS);
} }
// Map to the numeric wasm-bindgen CooSystem discriminant
frame = (frame.system === CooFrameEnum.SYSTEMS.GAL)
? Aladin.wasmLibs.core.CooSystem.GAL
: Aladin.wasmLibs.core.CooSystem.ICRS;
} }
let [lon, lat] = this.view.wasm.pix2world(x, y, frame); let [lon, lat] = this.view.wasm.pix2world(x, y, CooFrameEnum.toWasm(frame));
return [lon < 0 ? lon + 360.0 : lon, lat]; return [lon < 0 ? lon + 360.0 : lon, lat];
}; };
@@ -2836,16 +2831,10 @@ export let Aladin = (function () {
if (typeof frame === "string") { if (typeof frame === "string") {
frame = CooFrameEnum.fromString(frame, CooFrameEnum.ICRS); frame = CooFrameEnum.fromString(frame, CooFrameEnum.ICRS);
} }
// Map to the numeric wasm-bindgen CooSystem discriminant
frame = (frame.system === CooFrameEnum.SYSTEMS.GAL)
? Aladin.wasmLibs.core.CooSystem.GAL
: Aladin.wasmLibs.core.CooSystem.ICRS;
} }
// frame === undefined/null → passed as-is, WASM treats as None (default system) // frame === undefined/null → passed as-is, WASM treats as None (default system)
return this.view.wasm.world2pix(lon, lat, CooFrameEnum.toWasm(frame));
return this.view.wasm.world2pix(lon, lat, frame);
}; };
/** /**
+16
View File
@@ -29,6 +29,8 @@
* *
*****************************************************************************/ *****************************************************************************/
import { Aladin } from "./Aladin";
export let CooFrameEnum = (function() { export let CooFrameEnum = (function() {
// Corresponds to the Rust CooSystem enum possibilities. // Corresponds to the Rust CooSystem enum possibilities.
@@ -59,6 +61,20 @@ export let CooFrameEnum = (function() {
else { else {
return defaultValue ? defaultValue : null; return defaultValue ? defaultValue : null;
} }
},
toWasm: function(cooFrame) {
let frame = null;
let system = cooFrame?.system;
if (system === CooFrameEnum.SYSTEMS.ICRS) {
frame = Aladin.wasmLibs.core.CooSystem.ICRS;
} else if (system === CooFrameEnum.SYSTEMS.GAL) {
frame = Aladin.wasmLibs.core.CooSystem.GAL;
}
return frame;
} }
}; };
+33 -34
View File
@@ -42,11 +42,10 @@ PropertyParser.tileSize = function (properties) {
let tileSize = let tileSize =
(properties && (properties &&
properties.hips_tile_width && properties.hips_tile_width &&
+properties.hips_tile_width) || +properties.hips_tile_width)
512;
// Check if the tile width size is a power of 2 // Check if the tile width size is a power of 2
if (tileSize & (tileSize - 1 !== 0)) { if (tileSize && ((tileSize & (tileSize - 1)) !== 0)) {
tileSize = 512; tileSize = 512;
} }
@@ -175,11 +174,11 @@ PropertyParser.isPlanetaryBody = function (properties) {
* @property {Function} [successCallback] - A callback executed when the HiPS has been loaded * @property {Function} [successCallback] - A callback executed when the HiPS has been loaded
* @property {Function} [errorCallback] - A callback executed when the HiPS could not be loaded * @property {Function} [errorCallback] - A callback executed when the HiPS could not be loaded
* @property {string} [imgFormat] - Formats accepted 'webp', 'png', 'jpeg' or 'fits'. Will raise an error if the HiPS does not contain tiles in this format * @property {string} [imgFormat] - Formats accepted 'webp', 'png', 'jpeg' or 'fits'. Will raise an error if the HiPS does not contain tiles in this format
* @property {CooFrame} [cooFrame] - Coordinate frame of the survey tiles. If not given, the one from the parsed properties file will be retrieved. * @property {string} [cooFrame] - Coordinate frame of the survey tiles. If not given, the one from the parsed properties file will be retrieved. Possible values: 'ICRS', 'ICRSd', 'galactic', 'equatorial', 'j2000'
* @property {number} [maxOrder] - The maximum HEALPix order of the HiPS, i.e the HEALPix order of the most refined tile images of the HiPS. * @property {number} [maxOrder] - The maximum HEALPix order of the HiPS, i.e the HEALPix order of the most refined tile images of the HiPS.
* @property {number} [numBitsPerPixel] - Useful if you want to display the FITS tiles of a HiPS. It specifies the number of bits per pixel. Possible values are: * @property {number} [bitpix] - Useful if you want to display the FITS tiles of a HiPS. It specifies the number of bits per pixel. Possible values are:
* -64: double, -32: float, 8: unsigned byte, 16: short, 32: integer 32 bits, 64: integer 64 bits * -64: double, -32: float, 8: unsigned byte, 16: short, 32: integer 32 bits, 64: integer 64 bits
* @property {number} [tileSize] - The width of the HEALPix tile images. Mostly 512 pixels but can be 256, 128, 64, 32 * @property {number} [tileSize=512] - The width of the HEALPix tile images. Mostly 512 pixels but can be 256, 128, 64, 32
* @property {number} [minOrder] - If not given, retrieved from the properties of the survey. * @property {number} [minOrder] - If not given, retrieved from the properties of the survey.
* @property {boolean} [longitudeReversed] - Deprecated The longitudeReversed property is now deprecated since version 3.6.1. This property has been removed since version 3.7.0 and replaced with {@link Aladin#reverseLongitude} set directly on the {@link Aladin} view object and not at the HiPS level. * @property {boolean} [longitudeReversed] - Deprecated The longitudeReversed property is now deprecated since version 3.6.1. This property has been removed since version 3.7.0 and replaced with {@link Aladin#reverseLongitude} set directly on the {@link Aladin} view object and not at the HiPS level.
* @property {number} [opacity=1.0] - Opacity of the survey or image (value between 0 and 1). * @property {number} [opacity=1.0] - Opacity of the survey or image (value between 0 and 1).
@@ -281,7 +280,7 @@ export let HiPS = (function () {
*/ */
function HiPS(id, location, options) { function HiPS(id, location, options) {
this.added = false; this.added = false;
// Unique identifier for a survey // Required ID, synonym of the CreatorDid of a HiPS
this.id = id; this.id = id;
this.name = (options && options.name) || id; this.name = (options && options.name) || id;
@@ -329,20 +328,23 @@ export let HiPS = (function () {
this.url = location; this.url = location;
// Max order Required
this.maxOrder = options && options.maxOrder; this.maxOrder = options && options.maxOrder;
this.minOrder = (options && options.minOrder) || 0; this.minOrder = (options && options.minOrder) || 0;
// Frame Required
this.cooFrame = options && CooFrameEnum.fromString(options.cooFrame, null)?.system; this.cooFrame = options && CooFrameEnum.fromString(options.cooFrame, null)?.system;
this.tileSize = options && options.tileSize; this.tileSize = options && options.tileSize || 512;
this.skyFraction = options && options.skyFraction; this.skyFraction = options && options.skyFraction;
// Image format Required
this.imgFormat = options && options.imgFormat; this.imgFormat = options && options.imgFormat;
this.formats = options && options.formats; this.formats = (options && options.formats) || (this.imgFormat && [this.imgFormat]);
this.defaultFitsMinCut = options && options.defaultFitsMinCut; this.defaultFitsMinCut = options && options.defaultFitsMinCut;
this.defaultFitsMaxCut = options && options.defaultFitsMaxCut; this.defaultFitsMaxCut = options && options.defaultFitsMaxCut;
this.numBitsPerPixel = options && options.numBitsPerPixel; this.bitpix = options && options.bitpix;
this.creatorDid = options && options.creatorDid; this.creatorDid = (options && options.creatorDid) || this.id || this.url;
this.errorCallback = options && options.errorCallback; this.errorCallback = options && options.errorCallback;
this.successCallback = options && options.successCallback; this.successCallback = options && options.successCallback;
this.dataproductType = options && options.dataproductType; this.dataproductType = options && options.dataproductType || 'image';
this.tileDepth = options && options.tileDepth; this.tileDepth = options && options.tileDepth;
this.orderFreq = options && options.orderFreq; this.orderFreq = options && options.orderFreq;
this.emMin = options && options.emMin; this.emMin = options && options.emMin;
@@ -410,34 +412,33 @@ export let HiPS = (function () {
resolve(self); resolve(self);
}); });
} else { } else {
let isIncompleteOptions = true; let mustRequestProperties = true;
let isID = Utils.isUrl(this.url) === undefined; let isUrl = Utils.isUrl(this.url) !== undefined;
if (this.imgFormat === "fits") { if (this.imgFormat === "fits") {
// a fits is given // a fits is given
isIncompleteOptions = !( mustRequestProperties = !(
this.maxOrder && this.maxOrder &&
(!isID && this.url) && isUrl &&
this.imgFormat && this.imgFormat &&
this.tileSize &&
this.cooFrame && this.cooFrame &&
this.numBitsPerPixel // TODO: this should not be mandatory, one just parse FITS files
this.bitpix
); );
} else { } else {
isIncompleteOptions = !( mustRequestProperties = !(
this.maxOrder && this.maxOrder &&
(!isID && this.url) && isUrl &&
this.imgFormat && this.imgFormat &&
this.tileSize &&
this.cooFrame this.cooFrame
); );
} }
this.query = new Promise(async (resolve, reject) => { this.query = new Promise(async (resolve, reject) => {
if (isIncompleteOptions) { if (mustRequestProperties) {
// ID typed url // ID typed url
if (self.startUrl && isID) { if (self.startUrl && !isUrl) {
// First download the properties from the start url // First download the properties from the start url
await HiPSProperties.fetchFromUrl(self.startUrl, self.requestMode, self.requestCredentials) await HiPSProperties.fetchFromUrl(self.startUrl, self.requestMode, self.requestCredentials)
.then((p) => { .then((p) => {
@@ -465,7 +466,7 @@ export let HiPS = (function () {
}, },
1000 1000
); );
} else if (!self.startUrl && isID) { } else if (!self.startUrl && !isUrl) {
// the url stores a "CDS ID" we take it prioritaly // the url stores a "CDS ID" we take it prioritaly
// if the url is null, take the id, this is for some tests // if the url is null, take the id, this is for some tests
// to pass because some users might just give null as url param and a "CDS ID" as id param // to pass because some users might just give null as url param and a "CDS ID" as id param
@@ -495,12 +496,12 @@ export let HiPS = (function () {
.catch((e) => reject("HiPS " + self.id + " error: HiPS not found at url " + self.url + "\nReason: " + e.stack)) .catch((e) => reject("HiPS " + self.id + " error: HiPS not found at url " + self.url + "\nReason: " + e.stack))
} }
} else { } else {
self._parseProperties({ /*self._parseProperties({
hips_order: self.maxOrder, hips_order: self.maxOrder,
hips_service_url: self.url, hips_service_url: self.url,
hips_tile_width: self.tileSize, hips_tile_width: self.tileSize,
hips_frame: self.cooFrame hips_frame: self.cooFrame
}) })*/
} }
if (self.updateHiPSCache) { if (self.updateHiPSCache) {
@@ -581,7 +582,7 @@ export let HiPS = (function () {
// Tile formats // Tile formats
self.formats = self.formats =
PropertyParser.formats(properties) || self.formats || ["jpeg"]; PropertyParser.formats(properties) || self.formats;
// Min order // Min order
const minOrder = PropertyParser.minOrder(properties) const minOrder = PropertyParser.minOrder(properties)
@@ -594,7 +595,7 @@ export let HiPS = (function () {
PropertyParser.cooFrame(properties); PropertyParser.cooFrame(properties);
// Parse the cooframe from the properties but if it fails, take the one given by the user // Parse the cooframe from the properties but if it fails, take the one given by the user
// If the user gave nothing, then take ICRS as the default one // If the user gave nothing, then take ICRS as the default one
self.cooFrame = CooFrameEnum.fromString(cooFrame, self.cooFrame || CooFrameEnum.ICRS).system; self.cooFrame = CooFrameEnum.fromString(cooFrame, null)?.system || self.cooFrame || CooFrameEnum.ICRS.system;
// sky fraction // sky fraction
self.skyFraction = PropertyParser.skyFraction(properties); self.skyFraction = PropertyParser.skyFraction(properties);
@@ -616,8 +617,8 @@ export let HiPS = (function () {
self.defaultFitsMaxCut = cutoutFromProperties[1] || 1.0; self.defaultFitsMaxCut = cutoutFromProperties[1] || 1.0;
// Bitpix // Bitpix
self.numBitsPerPixel = self.bitpix =
PropertyParser.bitpix(properties) || self.numBitsPerPixel; PropertyParser.bitpix(properties) || self.bitpix;
// HiPS body // HiPS body
if (properties.hips_body) { if (properties.hips_body) {
@@ -632,8 +633,6 @@ export let HiPS = (function () {
self.name = self.name || self.id || self.url; self.name = self.name || self.id || self.url;
self.name = self.name.replace(/ +/g, ' '); self.name = self.name.replace(/ +/g, ' ');
self.creatorDid = self.creatorDid || self.id || self.url;
// check the imgFormat with respect to the formats accepted image format // check the imgFormat with respect to the formats accepted image format
const chooseTileFormat = (formats) => { const chooseTileFormat = (formats) => {
if (formats.indexOf("webp") >= 0) { if (formats.indexOf("webp") >= 0) {
@@ -1254,7 +1253,7 @@ export let HiPS = (function () {
cooFrame: self.cooFrame, cooFrame: self.cooFrame,
tileSize: self.tileSize, tileSize: self.tileSize,
formats: self.formats, formats: self.formats,
numBitsPerPixel: self.numBitsPerPixel, bitpix: self.bitpix,
skyFraction: self.skyFraction, skyFraction: self.skyFraction,
minOrder: self.minOrder, minOrder: self.minOrder,
initialFov: self.initialFov, initialFov: self.initialFov,
@@ -1325,7 +1324,7 @@ export let HiPS = (function () {
cooFrame: self.cooFrame, cooFrame: self.cooFrame,
tileSize: self.tileSize, tileSize: self.tileSize,
formats: self.formats, formats: self.formats,
bitpix: self.numBitsPerPixel, bitpix: self.bitpix,
skyFraction: self.skyFraction, skyFraction: self.skyFraction,
minOrder: self.minOrder, minOrder: self.minOrder,
initialFov: self.initialFov, initialFov: self.initialFov,
-1
View File
@@ -559,7 +559,6 @@ export let Image = (function () {
let self = this; let self = this;
let img = document.createElement('img'); let img = document.createElement('img');
console.log(this.url)
let checkImgFormat = Utils.fetchWithProxy({url: this.url, dataType: 'arrayBuffer'}) let checkImgFormat = Utils.fetchWithProxy({url: this.url, dataType: 'arrayBuffer'})
.then(arrayBuffer => { .then(arrayBuffer => {
const view = new DataView(arrayBuffer); const view = new DataView(arrayBuffer);
-1
View File
@@ -439,7 +439,6 @@ Utils.fetchWithProxy = function(params) {
console.info("Trying querying the proxy:" + JSONP_PROXY) console.info("Trying querying the proxy:" + JSONP_PROXY)
// Try as CORS // Try as CORS
const url = JSONP_PROXY + '?url=' + params.url; const url = JSONP_PROXY + '?url=' + params.url;
console.log(url)
return Utils.fetch({ return Utils.fetch({
...params, ...params,
url, url,