Commit d15edd67 authored by Moreau Nicolas's avatar Moreau Nicolas
Browse files

Sends markers to Aladin

parent 70146cfd
......@@ -187,21 +187,20 @@ class Slice {
});
this._shapesLayerGroup.set('title', 'shapes');
this._map = this.viewer.map; //this._getMap(sliceDivId);
this._map = this.viewer.map;
// initial image resolution, for later reset
this._defaultResolution = this._map.getView().getResolution();
//this._graticule = this._getGraticule();
//this._graticule.setMap(this._map);
// constrols display of markers on open layers image
this._markerManager = new MarkerManager(this._map, true);
// list of markers declared by user
this._markers = [];
this._initControl = this._initControl.bind(this);
this.updateSlice = this.updateSlice.bind(this);
this._imageLoadFunction = this._imageLoadFunction.bind(this);
this._getMap = this._getMap.bind(this);
//this._getGraticule = this._getGraticule.bind(this);
}
/**
......@@ -219,6 +218,7 @@ class Slice {
*/
markerListClear() {
this._markerManager.clearMarkers();
this._markers = [];
}
/**
......@@ -270,6 +270,7 @@ class Slice {
let res = this._absToPix.convert(degToRad(event.detail.ra), degToRad(event.detail.dec));
try {
this._markerManager.addMarker(res[0], res[1], event.detail["object"]);
this._markers.push({"ra" : event.detail.ra, "dec" : event.detail.dec, "label" : event.detail["object"].trim()});
} catch (error) {
console.log(error);
}
......@@ -281,11 +282,13 @@ class Slice {
*/
markerListUpdate(event) {
this._markerManager.clearMarkers();
this._markers = [];
for (const marker of event.detail.markers) {
if (marker.ra !== undefined && marker.dec !== undefined && marker.label !== undefined) {
this._markers.push(marker);
try {
let iRaiDec = this._projection.raDecToiRaiDec(HMS2DecDeg(marker.ra), DMS2DecDeg(marker.dec));
this._markerManager.addMarker(iRaiDec["iRa"], iRaiDec["iDec"], marker["label"]);
this._markerManager.addMarker(iRaiDec["iRa"], iRaiDec["iDec"], marker["label"].trim());
} catch (error) {
alert(`Error with object RA : ${marker.ra}, DEC : ${marker.dec}, label : ${marker.label} : ${error} `);
throw error;
......@@ -295,7 +298,6 @@ class Slice {
throw new Erro("Coordinates are syntaxically incorrect");
}
}
}
/**
......@@ -515,7 +517,7 @@ class SingleSlice extends Slice {
let url = URL_ROOT + res.result;
window.open(url, '_blank');
});
});
});
controls.push(imgView);
controls.push(imgDownload);
......@@ -528,7 +530,9 @@ class SingleSlice extends Slice {
this._sampButton = builder.build();
if(withSAMP){
this._sampButton.setHandler(sAMPPublisher.sendPNGSlice);
this._sampButton.setHandler(()=>{
sAMPPublisher.sendPNGSlice();
sAMPPublisher.sendMarkers(this._markers)});
controls.push(this._sampButton);
}
......
......@@ -43,9 +43,7 @@ class MarkerList {
this._dataElement.value = source.trim();
this._markers.add(event.detail.object);
}
}
/**
* Adds an object listening to event from this object
* @param {Object} listener
......@@ -141,6 +139,10 @@ class MarkerManager {
this._initialized = false;
}
getMarkers(){
return this._markers;
}
/**
* Adds a new marker on map
* @param {number} pixRa RA in pixels (int)
......
......@@ -22,8 +22,9 @@ var SAMPPublisher = function(connector, dataPaths) {
console.log("SAMPPublisher ctor: entering");
let _connector = connector;
let _dataPaths = dataPaths;
let self = this;
this.sendPNGSlice = function() {
this.sendPNGSlice= function(){
console.log("var _sendPNGSlice = function(connection) {: entering");
//var pngUrl = URL_ROOT + "/" + _relSlicePNGPath;
var pngUrl = URL_ROOT + "/" + _dataPaths.relSlicePNG;
......@@ -35,6 +36,22 @@ var SAMPPublisher = function(connector, dataPaths) {
console.log("var _sendPNGSlice = function(connection) {: exiting");
}
this.sendMarkers = function(markers) {
console.log("### sendMarkers");
console.log(markers);
console.log("var _sendPNGSlice = function(connection) {: entering");
let command = "";
for (let marker of markers){
command = command + `draw tag(${marker.ra}, ${marker.dec}, "${marker.label}",30,30,circle,15);`
}
console.log("About to send this message 'load " + command + "' to the HUB");
const msg = new samp.Message("script.aladin.send", {
"script": command
});
_connector.connection.notifyAll([msg]);
console.log("var _sendPNGSlice = function(connection) {: exiting");
}
this.sendPNGSummedSlices = function() {
//_connector.runWithConnection(_sendPNGSummedSlices);
console.log("var _sendPNGSummedSlices = function(connection) {: entering");
......@@ -51,7 +68,7 @@ var SAMPPublisher = function(connector, dataPaths) {
this.sendSpectrumToAll = function(spectrumUrl, tableId) {
console.log("var _sendSpectrum = function(connection) {: entering");
//var tabUrl = URL_ROOT + _spectrumPath;
//var tabUrl = URL_ROOT + _spectrumPath;
console.log(`Sending url ${spectrumUrl}`);
var msg = new samp.Message("table.load.fits", {
"table-id": tableId,
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment