mirror of
https://github.com/cds-astro/aladin-lite.git
synced 2026-01-05 09:40:02 -08:00
fix some bugs: still votables error to fix
This commit is contained in:
@@ -17,11 +17,11 @@ A.init.then(() => {
|
||||
hscGreenSurvey.setColormap("green", { stretch: "asinh" });
|
||||
hscGreenSurvey.setCuts(-0.2186, 5.30322);
|
||||
|
||||
const HSCRedSurvey = aladin.createImageSurvey('HSC-r', "HSC red", "CDS/P/HSC/DR2/deep/r", null, null, {imgFormat: 'fits', colormap: "red", minCut: 0.34228, maxCut: 2.75785, additive: true, stretch: "asinh"});
|
||||
const HSCBlueSurvey = aladin.createImageSurvey('HSC-b', "HSC blue", "CDS/P/HSC/DR2/deep/z", null, null, {imgFormat: 'fits', colormap: "blue", minCut: -0.01218, maxCut: 2.27397, additive: true, stretch: "asinh"});
|
||||
const HSCRedSurvey = aladin.createImageSurvey('CDS/P/HSC/DR2/deep/r', "HSC red", undefined, null, null, {imgFormat: 'fits', colormap: "red", minCut: 0.34228, maxCut: 2.75785, additive: true, stretch: "asinh"});
|
||||
const HSCBlueSurvey = aladin.createImageSurvey('CDS/P/HSC/DR2/deep/z', "HSC blue", undefined, null, null, {imgFormat: 'fits', colormap: "blue", minCut: -0.01218, maxCut: 2.27397, additive: true, stretch: "asinh"});
|
||||
|
||||
aladin.setOverlayImageLayer('HSC-r', 'hsc red layer');
|
||||
aladin.setOverlayImageLayer('HSC-b', 'hsc blue layer');
|
||||
aladin.setOverlayImageLayer('CDS/P/HSC/DR2/deep/r', 'hsc red layer');
|
||||
aladin.setOverlayImageLayer('CDS/P/HSC/DR2/deep/z', 'hsc blue layer');
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
<script type="text/javascript">
|
||||
let aladin;
|
||||
A.init.then(() => {
|
||||
aladin = A.aladin('#aladin-lite-div', {target: 'LMC', fov: 55});
|
||||
aladin = A.aladin('#aladin-lite-div', {target: 'LMC', fov: 55, showContextMenu: true});
|
||||
var hips = A.catalogHiPS('https://axel.u-strasbg.fr/HiPSCatService/Simbad', {onClick: 'showTable', name: 'Simbad'});
|
||||
aladin.addCatalog(hips);
|
||||
});
|
||||
|
||||
@@ -15,8 +15,8 @@
|
||||
aladin = A.aladin('#aladin-lite-div', {cooFrame: "icrs", fullScreen: true});
|
||||
|
||||
aladin.displayFITS(
|
||||
'http://data.astropy.org/tutorials/FITS-images/HorseHead.fits', // url of the fits file
|
||||
//'fits/HorseHead.fits',
|
||||
//'https://fits.gsfc.nasa.gov/samples/FOCx38i0101t_c0f.fits', // url of the fits file
|
||||
'fits/HorseHead.fits',
|
||||
//'fits/neowise.fits',
|
||||
//'fits/irac.fits',
|
||||
//'fits/FOCx38i0101t_c0f.fits',
|
||||
|
||||
@@ -13,12 +13,12 @@
|
||||
A.init.then(() => {
|
||||
aladin = A.aladin('#aladin-lite-div', {target: '14 18 16.868 +56 44 29.37', fov: 5, showContextMenu: true});
|
||||
|
||||
//const c1 = A.catalogFromURL('./ObsCore_003.xml', {onClick: 'showTable'});
|
||||
const c1 = A.catalogFromURL('./ObsCore_003.xml', {onClick: 'showTable'});
|
||||
//const catalog = A.catalogFromURL('https://vo.astron.nl/tap/sync?REQUEST=doQuery&LANG=ADQL&MAXREC=20000000&QUERY=SELECT+TOP+9999+*+FROM+ivoa.obscore+WHERE+CONTAINS%28POINT%28%27ICRS%27%2C+s_ra%2C+s_dec%29%2C+CIRCLE%28%27ICRS%27%2C+214.92068%2C+56.81529%2C+3.03%29%29+%3D+1+', {onClick: 'showTable'});
|
||||
const c2 = A.catalogFromURL('http://archive.eso.org/tap_obs/sync?REQUEST=doQuery&LANG=ADQL&MAXREC=20000000&QUERY=SELECT+TOP+9999+*+FROM+ivoa.ObsCore+WHERE+CONTAINS%28POINT%28%27ICRS%27%2C+s_ra%2C+s_dec%29%2C+CIRCLE%28%27ICRS%27%2C+83.82184%2C+-5.38635%2C+0.14798%29%29+%3D+1+AND+obs_collection+%3D+%27MUSE%27+', {onClick: 'showTable'});
|
||||
//const c2 = A.catalogFromURL('http://archive.eso.org/tap_obs/sync?REQUEST=doQuery&LANG=ADQL&MAXREC=20000000&QUERY=SELECT+TOP+9999+*+FROM+ivoa.ObsCore+WHERE+CONTAINS%28POINT%28%27ICRS%27%2C+s_ra%2C+s_dec%29%2C+CIRCLE%28%27ICRS%27%2C+83.82184%2C+-5.38635%2C+0.14798%29%29+%3D+1+AND+obs_collection+%3D+%27MUSE%27+', {onClick: 'showTable'});
|
||||
|
||||
//aladin.addCatalog(catalog);
|
||||
aladin.addCatalog(c2);
|
||||
aladin.addCatalog(c1);
|
||||
|
||||
});
|
||||
</script>
|
||||
|
||||
@@ -894,11 +894,11 @@ impl App {
|
||||
use crate::renderable::image::Image;
|
||||
use futures::TryStreamExt;
|
||||
use futures::future::Either;
|
||||
use web_sys::{Request, RequestInit};
|
||||
use web_sys::{Request, RequestInit, RequestMode};
|
||||
|
||||
let mut opts = RequestInit::new();
|
||||
opts.method("GET");
|
||||
//opts.mode(RequestMode::Cors);
|
||||
opts.mode(RequestMode::Cors);
|
||||
|
||||
let window = window().unwrap();
|
||||
let request = Request::new_with_str_and_init(&url, &opts)?;
|
||||
|
||||
@@ -1193,11 +1193,11 @@ export let Aladin = (function () {
|
||||
const url = idOrUrl;
|
||||
const id = url;
|
||||
// Url
|
||||
imageLayer = this.createImageSurvey(id, name, url, null, null);
|
||||
imageLayer = this.createImageSurvey(idOrUrl, name, idOrUrl, null, null);
|
||||
} else {
|
||||
const id = idOrUrl;
|
||||
// ID
|
||||
imageLayer = this.createImageSurvey(id, name, undefined, null, null);
|
||||
imageLayer = this.createImageSurvey(idOrUrl, name, idOrUrl, null, null);
|
||||
}
|
||||
// 2. User gives a non resolved promise
|
||||
} else {
|
||||
@@ -1727,7 +1727,17 @@ Aladin.prototype.getEmbedCode = function () {
|
||||
/*
|
||||
* Creates remotely a HiPS from a FITS image URL and displays it
|
||||
*/
|
||||
Aladin.prototype.displayFITS = function (url, options, successCallback, errorCallback, layer = "base") {
|
||||
Aladin.prototype.displayFITS = function (
|
||||
url,
|
||||
options,
|
||||
successCallback,
|
||||
errorCallback,
|
||||
layer = "base"
|
||||
) {
|
||||
successCallback = successCallback || ((ra, dec, fov, _) => {
|
||||
this.gotoRaDec(ra, dec);
|
||||
this.setFoV(fov);
|
||||
});
|
||||
const imageFits = this.createImageFITS(url, url, options, successCallback, errorCallback);
|
||||
return this.setOverlayImageLayer(imageFits, layer);
|
||||
};
|
||||
@@ -1786,7 +1796,7 @@ Aladin.prototype.displayJPG = Aladin.prototype.displayPNG = function (url, optio
|
||||
var label = options.label || "FITS image";
|
||||
var meta = response.data.meta;
|
||||
|
||||
const survey = self.createImageSurvey(response.data.url, label);
|
||||
const survey = self.createImageSurvey(response.data.url, label, response.data.url);
|
||||
self.setOverlayImageLayer(survey, "overlay");
|
||||
|
||||
var transparency = (options && options.transparency) || 1.0;
|
||||
|
||||
@@ -35,6 +35,7 @@ import { Utils } from "./Utils.js";
|
||||
import { AladinUtils } from "./AladinUtils.js";
|
||||
import { Coo } from "./libs/astro/coo.js";
|
||||
import { VOTable } from "./vo/VOTable.js";
|
||||
import { ALEvent } from "./events/ALEvent.js";
|
||||
|
||||
import $ from 'jquery';
|
||||
|
||||
@@ -385,9 +386,14 @@ export let Catalog = (function() {
|
||||
this.dec.push(sourcesToAdd[k].dec);
|
||||
}
|
||||
|
||||
this.view.wasm.setCatalog(this);
|
||||
ALEvent.AL_USE_WASM.dispatchedTo(document.body, {
|
||||
callback: (wasm) => {
|
||||
wasm.setCatalog(this);
|
||||
this.reportChange();
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
this.reportChange();
|
||||
};
|
||||
|
||||
Catalog.prototype.addFootprints = function(footprintsToAdd) {
|
||||
@@ -409,7 +415,7 @@ export let Catalog = (function() {
|
||||
};
|
||||
|
||||
Catalog.prototype.isObsCore = function() {
|
||||
return this.fields.subtype === "ObsCore";
|
||||
return this.fields && this.fields.subtype === "ObsCore";
|
||||
};
|
||||
|
||||
// API
|
||||
|
||||
@@ -33,84 +33,100 @@ import { MocServer } from "./MocServer.js";
|
||||
|
||||
export let HiPSProperties = {};
|
||||
|
||||
HiPSProperties.fetch = async function(urlOrId) {
|
||||
HiPSProperties.fetchFromID = async function(ID) {
|
||||
// Use the MOCServer to retrieve the properties
|
||||
const params = {
|
||||
get: "record",
|
||||
fmt: "json",
|
||||
ID: "*" + ID + "*",
|
||||
};
|
||||
|
||||
let metadata = await Utils.loadFromMirrors(MocServer.MIRRORS_HTTPS, {
|
||||
data: params,
|
||||
}).then(response => response.json());
|
||||
|
||||
// We get the property here
|
||||
// 1. Ensure there is exactly one survey matching
|
||||
if (!metadata || metadata.length == 0) {
|
||||
throw 'No surveys matching have been found for the id: ' + ID;
|
||||
} else {
|
||||
let result;
|
||||
|
||||
if (metadata.length > 1) {
|
||||
let matching = metadata.find((m) => m.ID === ID);
|
||||
if (matching) {
|
||||
result = matching;
|
||||
} else {
|
||||
result = metadata[0];
|
||||
console.warn("Multiple surveys are matching, please choose one. The chosen one is: " + result);
|
||||
}
|
||||
} else {
|
||||
// Exactly one matching
|
||||
result = metadata[0];
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
HiPSProperties.fetchFromUrl = async function(urlOrId) {
|
||||
try {
|
||||
urlOrId = new URL(urlOrId);
|
||||
} catch (e) {}
|
||||
|
||||
let result = {};
|
||||
if (!(urlOrId instanceof URL)) {
|
||||
// Use the MOCServer to retrieve the
|
||||
// properties
|
||||
const ID = urlOrId;
|
||||
const params = {
|
||||
get: "record",
|
||||
fmt: "json",
|
||||
ID: "*" + ID + "*",
|
||||
};
|
||||
|
||||
let metadata = await Utils.loadFromMirrors(MocServer.MIRRORS_HTTPS, {
|
||||
data: params,
|
||||
}).then(response => response.json());
|
||||
|
||||
// We get the property here
|
||||
// 1. Ensure there is exactly one survey matching
|
||||
if (!metadata || metadata.length == 0) {
|
||||
throw 'No surveys matching have been found for the id: ' + ID;
|
||||
} else {
|
||||
if (metadata.length > 1) {
|
||||
let matching = metadata.find((m) => m.ID === ID);
|
||||
if (matching) {
|
||||
result = matching;
|
||||
} else {
|
||||
result = metadata[0];
|
||||
console.warn("Multiple surveys are matching, please choose one. The chosen one is: " + result);
|
||||
}
|
||||
} else {
|
||||
// Exactly one matching
|
||||
result = metadata[0];
|
||||
}
|
||||
} catch (e) {
|
||||
// Relative path
|
||||
try {
|
||||
urlOrId = Utils.getAbsoluteURL(urlOrId)
|
||||
urlOrId = new URL(urlOrId);
|
||||
} catch(e) {
|
||||
throw e;
|
||||
}
|
||||
} else {
|
||||
// Fetch the properties of the survey
|
||||
const HiPSServiceUrl = urlOrId.toString();
|
||||
|
||||
let url = HiPSServiceUrl;
|
||||
// Use the url for retrieving the HiPS properties
|
||||
// remove final slash
|
||||
if (url.slice(-1) === '/') {
|
||||
url = url.substr(0, url.length - 1);
|
||||
}
|
||||
url = url + '/properties';
|
||||
|
||||
// make URL absolute
|
||||
url = Utils.getAbsoluteURL(url);
|
||||
// fix for HTTPS support --> will work for all HiPS served by CDS
|
||||
url = Utils.fixURLForHTTPS(url)
|
||||
|
||||
let init = {};
|
||||
if (Utils.requestCORSIfNotSameOrigin(url)) {
|
||||
init = { mode: 'cors' };
|
||||
}
|
||||
|
||||
result = await fetch(url, init)
|
||||
.then((response) => response.text())
|
||||
.then((response) => {
|
||||
// We get the property here
|
||||
let metadata = HiPSDefinition.parseHiPSProperties(response);
|
||||
|
||||
// 1. Ensure there is exactly one survey matching
|
||||
if (metadata) {
|
||||
// Set the service url if not found
|
||||
metadata.hips_service_url = HiPSServiceUrl;
|
||||
} else {
|
||||
throw 'No surveys matching at this url: ' + rootURL;
|
||||
}
|
||||
|
||||
return metadata;
|
||||
});
|
||||
}
|
||||
|
||||
// Fetch the properties of the survey
|
||||
const HiPSServiceUrl = urlOrId.toString();
|
||||
|
||||
let url = HiPSServiceUrl;
|
||||
// Use the url for retrieving the HiPS properties
|
||||
// remove final slash
|
||||
if (url.slice(-1) === '/') {
|
||||
url = url.substr(0, url.length - 1);
|
||||
}
|
||||
url = url + '/properties';
|
||||
|
||||
// make URL absolute
|
||||
url = Utils.getAbsoluteURL(url);
|
||||
// fix for HTTPS support --> will work for all HiPS served by CDS
|
||||
url = Utils.fixURLForHTTPS(url)
|
||||
|
||||
let init = {};
|
||||
if (Utils.requestCORSIfNotSameOrigin(url)) {
|
||||
init = { mode: 'cors' };
|
||||
}
|
||||
|
||||
let result = await fetch(url, init)
|
||||
.then((response) => {
|
||||
if (response.status == 404) {
|
||||
return Promise.reject("Url points to nothing")
|
||||
} else {
|
||||
return response.text();
|
||||
}
|
||||
})
|
||||
.then((response) => {
|
||||
|
||||
// We get the property here
|
||||
let metadata = HiPSDefinition.parseHiPSProperties(response);
|
||||
|
||||
// 1. Ensure there is exactly one survey matching
|
||||
if (metadata) {
|
||||
// Set the service url if not found
|
||||
metadata.hips_service_url = HiPSServiceUrl;
|
||||
} else {
|
||||
throw 'No surveys matching at this url: ' + rootURL;
|
||||
}
|
||||
|
||||
return metadata;
|
||||
})
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
@@ -206,6 +206,6 @@ ImageLayer.LAYERS = [
|
||||
},
|
||||
];
|
||||
|
||||
ImageLayer.getAvailableSurveys = function () {
|
||||
ImageLayer.getAvailableLayers = function () {
|
||||
return ImageLayer.LAYERS;
|
||||
};
|
||||
|
||||
@@ -153,7 +153,14 @@ export let ImageSurvey = (function () {
|
||||
let maxOrder, frame, tileSize, formats, minCutout, maxCutout, bitpix, skyFraction, minOrder, initialFov, initialRa, initialDec, hipsBody, isPlanetaryBody, dataproductSubtype;
|
||||
|
||||
try {
|
||||
const properties = await HiPSProperties.fetch(url || id);
|
||||
let properties;
|
||||
try {
|
||||
properties = await HiPSProperties.fetchFromUrl(url)
|
||||
.catch(async (e) => {
|
||||
// url not valid
|
||||
return await HiPSProperties.fetchFromID(id);
|
||||
})
|
||||
} catch(e) {}
|
||||
|
||||
// Give a better name if we have the HiPS metadata
|
||||
self.name = self.name || properties.obs_title;
|
||||
|
||||
@@ -108,7 +108,7 @@ export let Source = (function() {
|
||||
};
|
||||
|
||||
let options = {};
|
||||
if (this.catalog.isObsCore()) {
|
||||
if (this.catalog.isObsCore && this.catalog.isObsCore()) {
|
||||
// If the source is obscore, save the table state inside the measurement table
|
||||
// This is used to go back from a possible datalink table to the obscore one
|
||||
options["save"] = true;
|
||||
|
||||
@@ -594,7 +594,7 @@ export let View = (function () {
|
||||
'fieldsClickedActions': catalog.fieldsClickedActions,
|
||||
};
|
||||
|
||||
if (catalog.isObsCore()) {
|
||||
if (catalog.isObsCore && catalog.isObsCore()) {
|
||||
// If the source is obscore, save the table state inside the measurement table
|
||||
// This is used to go back from a possible datalink table to the obscore one
|
||||
options["save"] = true;
|
||||
@@ -1675,12 +1675,11 @@ export let View = (function () {
|
||||
|
||||
// check if there are no more surveys
|
||||
const noMoreLayersToWaitFor = this.promises.length === 0;
|
||||
|
||||
if (noMoreLayersToWaitFor && this.empty) {
|
||||
if (noMoreLayersToWaitFor && this.empty || layer === "base") {
|
||||
// no promises to launch!
|
||||
const idxServiceUrl = Math.round(Math.random());
|
||||
const dssUrl = Aladin.DEFAULT_OPTIONS.surveyUrl[idxServiceUrl]
|
||||
|
||||
console.log(idxServiceUrl)
|
||||
this.aladin.setBaseImageLayer(dssUrl);
|
||||
}
|
||||
};
|
||||
@@ -1819,7 +1818,6 @@ export let View = (function () {
|
||||
}
|
||||
|
||||
// Set the grid label format
|
||||
console.log("lavel", this.cooFrame.label)
|
||||
if (this.cooFrame.label == "J2000d") {
|
||||
this.setGridConfig({fmt: "HMS"});
|
||||
}
|
||||
|
||||
@@ -56,8 +56,6 @@ export let VOTable = (function() {
|
||||
let tables = resource.get("tables")
|
||||
if (tables) {
|
||||
tables.forEach((table) => {
|
||||
console.log(table.get("elems"))
|
||||
|
||||
let fields = table.get("elems")
|
||||
.filter((elem) => {
|
||||
const elemType = elem["elem_type"] || elem.get("elem_type")
|
||||
|
||||
Reference in New Issue
Block a user