Skip to content

Commit

Permalink
add sesame access in A.Utils + Aladin.remove that removes either an o…
Browse files Browse the repository at this point in the history
…verlay or a layer
  • Loading branch information
bmatthieu3 committed Sep 18, 2024
1 parent 64d0136 commit 9c9ebb0
Show file tree
Hide file tree
Showing 12 changed files with 230 additions and 101 deletions.
6 changes: 4 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
# Changelogs

## [Unreleased]
## 3.5.1-beta

* [feat] Add support for name removing in `removeOverlay` method
* [test] Add support of playwright. Instructions in the readme for running the test matching snapshots [PR #176]
* [fixed] Order of overlays in the stack now matches the addMOC/addCatalog/addOverlay calls ordering
* [fix] Order of overlays in the stack now matches the addMOC/addCatalog/addOverlay calls ordering
* [doc] Expose the API of Coo class
* [fix] Insert aladin css inside the aladin lite so that it should be compliant with the use of shadow DOMs [cds-astro/ipyaladin#113], [marimo-team/marimo#2106]
* [feat] Add possibility of giving a local JS FileList to load a locally-stored HiPS without starting an HTTP server [cds-astro/aladin-lite#103]
* [fix] removeOverlayByName

## 3.5.0-beta

Expand Down
15 changes: 11 additions & 4 deletions examples/al-vertices.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,17 @@

A.init.then(() => {
let vertices = A.Utils.HEALPix.vertices(Math.pow(2, 3), BigInt(276))
//let lonlat = A.Utils.HEALPix.pix2ang(8, 0n)
//let ipix = A.Utils.HEALPix.ang2pix(8, 0.1, 0.4)
//console.log("vertices", vertices, lonlat, ipix)
console.log(vertices)
let lonlat = A.Utils.HEALPix.pix2ang(8, 0n)
let ipix = A.Utils.HEALPix.ang2pix(8, 0.1, 0.4)
console.log("vertices", vertices, lonlat, ipix)

A.Utils.Sesame.resolveAstronomicalName("M101", (o) => {
console.log("object found", o)
},
(err) => {
console.error("errr", err)
}
)
})

</script>
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"homepage": "https://aladin.u-strasbg.fr/",
"name": "aladin-lite",
"type": "module",
"version": "3.5.1-alpha",
"version": "3.5.1-beta",
"description": "An astronomical HiPS visualizer in the browser",
"author": "Thomas Boch and Matthieu Baumann",
"license": "GPL-3",
Expand Down
2 changes: 1 addition & 1 deletion src/core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1033,7 +1033,7 @@ impl WebClient {
Ok(())
}

#[wasm_bindgen(js_name = addFITSMoc)]
#[wasm_bindgen(js_name = addFITSMOC)]
pub fn add_fits_moc(&mut self, params: &al_api::moc::MOC, data: &[u8]) -> Result<(), JsValue> {
//let bytes = js_sys::Uint8Array::new(array_buffer).to_vec();
let moc = match fits::from_fits_ivoa_custom(Cursor::new(&data[..]), false)
Expand Down
44 changes: 25 additions & 19 deletions src/js/A.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,23 +106,18 @@ A.aladin = function (divSelector, options) {
return new Aladin(divElement, options);
};

/**
* @function
* @name A.imageHiPS
* @memberof A
* @deprecated
* Old method name, use {@link A.HiPS} instead.
*/
A.imageHiPS = A.HiPS;

/**
* Creates a HiPS image object
*
* @function
* @name A.HiPS
* @memberof A
* @param {string} id - Can be either an `url` that refers to a HiPS.
* Or it can be a "CDS ID" pointing towards a HiPS. One can found the list of IDs {@link https://aladin.cds.unistra.fr/hips/list| here}.
* @param {string|FileList|Object} id - Can be: <br/>
* - an http url <br/>
* - a relative path to your HiPS <br/>
* - a special ID pointing towards a HiPS. One can found the list of IDs {@link https://aladin.cds.unistra.fr/hips/list| here} <br/>
* - a dict storing a local HiPS files. This object contains a tile file: hips[order][ipix] = File and refers to the properties file like so: hips["properties"] = File. <br/>
* A javascript FileList pointing to the opened webkit directory is also accepted.
* @param {HiPSOptions} [options] - Options describing the survey
* @returns {HiPS} - A HiPS image object
*/
Expand All @@ -138,6 +133,15 @@ A.HiPS = function (id, options) {
);
}

/**
* @function
* @name A.imageHiPS
* @memberof A
* @deprecated
* Old method name, use {@link A.HiPS} instead.
*/
A.imageHiPS = A.HiPS;

/**
* Creates a celestial source object with the given coordinates.
*
Expand Down Expand Up @@ -449,17 +453,19 @@ A.MOCFromURL = function (url, options, successCallback, errorCallback) {
* @returns {MOC} Returns a new MOC object
*
* @example
* var json = {"3":[517],
* "4":[2065,2066,2067,2112,2344,2346,2432],
* "5":[8221,8257,8258,8259,8293,8304,8305,8307,8308,8452,8456,9346,9352,9354,9736],
* "6":[32861,32862,32863,32881,32882,32883,32892,32893,33025,33026,33027,33157,33168,33169,33171,
* var json = {
* "3": [517],
* "4": [2065,2066,2067,2112,2344,2346,2432],
* "5": [8221,8257,8258,8259,8293,8304,8305,8307,8308,8452,8456,9346,9352,9354,9736],
* "6": [32861,32862,32863,32881,32882,32883,32892,32893,33025,33026,33027,33157,33168,33169,33171,
* 33181,33224,33225,33227,33236,33240,33812,33816,33828,33832,37377,37378,37379,37382,37388,
* 37390,37412,37414,37420,37422,37562,38928,38930,38936,38948,38952],
* "7":[131423,131439,131443,131523,131556,131557,131580,131581,132099,132612,132613,132624,132625,132627,132637,
* "7": [131423,131439,131443,131523,131556,131557,131580,131581,132099,132612,132613,132624,132625,132627,132637,
* 132680,132681,132683,132709,132720,132721,132904,132905,132948,132952,132964,132968,133008,133009,133012,135252,135256,135268,135316,135320,135332,135336,148143,148152,148154,149507,149520
* ,149522,149523,149652,149654,149660,149662,149684,149686,149692,149694,149695,150120,150122,150208,150210,150216,150218,150240,150242,150243,155748,155752,155796,155800,155812,155816]};
* ,149522,149523,149652,149654,149660,149662,149684,149686,149692,149694,149695,150120,150122,150208,150210,150216,150218,150240,150242,150243,155748,155752,155796,155800,155812,155816]
* };
* var moc = A.MOCFromJSON(json, {opacity: 0.25, color: 'magenta', lineWidth: 3});
* aladin.addMOC(moc);
* aladin.addMOC(moc);
*/
A.MOCFromJSON = function (jsonMOC, options, successCallback, errorCallback) {
var moc = new MOC(options);
Expand Down Expand Up @@ -986,7 +992,7 @@ A.box = function(options) {
}

/**
* Returns utils object
* Returns Utils object.
*
* This contains utilitary methods such as HEALPix basic or projection methods.
*
Expand Down
33 changes: 21 additions & 12 deletions src/js/Aladin.js
Original file line number Diff line number Diff line change
Expand Up @@ -1462,7 +1462,7 @@ export let Aladin = (function () {
* @memberof Aladin
*/
Aladin.prototype.removeOverlays = function () {
this.view.removeLayers();
this.view.removeOverlays();
};

/**
Expand Down Expand Up @@ -1497,10 +1497,6 @@ export let Aladin = (function () {
Aladin.prototype.removeLayer = Aladin.prototype.removeOverlay;

/**
* @deprecated
* Creates and return an image survey (HiPS) object
* Please use {@link A.hiPS} instead for creating a new survey image
*
* @memberof Aladin
* @param {string} id - Mandatory unique identifier for the survey.
* @param {string} [name] - A convinient name for the survey, optional
Expand Down Expand Up @@ -1533,10 +1529,6 @@ export let Aladin = (function () {
};

/**
* @deprecated
* Creates and return an image survey (HiPS) object.
* Please use {@link A.hiPS} instead for creating a new survey image
*
* @function createImageSurvey
* @memberof Aladin
* @static
Expand Down Expand Up @@ -1655,7 +1647,6 @@ export let Aladin = (function () {
* Please use {@link A.hiPS} instead for creating a new survey image
*
* @memberof Aladin
* @static
* @param {string} id - Can be:
* <ul>
* <li>1. An url that refers to a HiPS.</li>
Expand Down Expand Up @@ -1750,11 +1741,29 @@ export let Aladin = (function () {
return this.backgroundColor;
};

/**
* Remove an image layer/overlay from the instance
*
* @memberof Aladin
* @param {string|Overlay} item - the overlay object or image layer name to remove
*/
Aladin.prototype.remove = function (item) {
const layers = this.getStackLayers()
let idxToDelete = layers.findIndex(l => l === item);
if (idxToDelete >= 0) {
this.view.removeImageLayer(item);
return;
}

// must be an overlay
this.view.removeOverlay(item)
};

/**
* Remove a specific layer
*
* @memberof Aladin
* @param {string} layer - The name of the layer to remove
* @param {string} layer - The name of the layer to remove or the HiPS/Image object
*/
Aladin.prototype.removeImageLayer = function (layer) {
this.view.removeImageLayer(layer);
Expand Down Expand Up @@ -1795,7 +1804,7 @@ export let Aladin = (function () {
* <li>1. An url that refers to a HiPS.</li>
* <li>2. Or it can be a CDS ID that refers to a HiPS. One can found the list of IDs {@link https://aladin.cds.unistra.fr/hips/list| here}</li>
* <li>3. A {@link HiPS} HiPS object created from {@link A.HiPS}</li>
* <li>4. A {@link Image} FITS/jped/png image</li>
* <li>4. A {@link Image} FITS/jpeg/png image</li>
* </ul>
* @param {string} [layer="overlay"] - A layer name. By default 'overlay' is chosen and it is destined to be plot
* on top the 'base' layer. If the layer is already present in the view, it will be replaced by the new HiPS/FITS image given here.
Expand Down
23 changes: 23 additions & 0 deletions src/js/AladinUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
*
*****************************************************************************/
import { Aladin } from "./Aladin";
import { Sesame } from "./Sesame";

/**
* @namespace AladinUtils
Expand Down Expand Up @@ -145,6 +146,28 @@ export let AladinUtils = {
}
},

/**
* @namespace Sesame
* @memberof AladinUtils
* @description Namespace for Sesame related service.
*/
Sesame: {
/**
* find RA, DEC for any target (object name or position) <br/>
* if successful, callback is called with an object {ra: ra-value, dec: dec-value} <br/>
* if not successful, errorCallback is called
*
* @function
* @memberof AladinUtils.Sesame
* @name resolveAstronomicalName
*
* @param {string} target - object name or position
* @param {Function} callback - if successful, callback is called with an object {ra: <ra-value>, dec: <dec-value>}
* @param {Function} errorCallback - if not successful, errorCallback is called
*/
resolveAstronomicalName: Sesame.getTargetRADec
},

/**
* @deprecated
*
Expand Down
Loading

0 comments on commit 9c9ebb0

Please sign in to comment.