Commit 7840ccb3 authored by Moreau Nicolas's avatar Moreau Nicolas
Browse files

continue fixing markers refresh in 2d

parent 21920031
......@@ -673,13 +673,14 @@ class MarkersFactory extends ShapesFactory {
let self = this;
var p = new Promise((resolve, reject)=>{
const { RA, DEC } = this.validateRow(row);
const iRaiDec = this.projection.raDecToiRaiDec(RA.decdegree, DEC.decdegree);
//const iRaiDec = this.projection.raDecToiRaiDec(degToRad(RA.decdegree), degToRad(DEC.decdegree));
const iRaiDec = this.projection.raDecToiRaiDec(5.274091711490477, 0.7119264195952342);
console.log("### changed" );
console.log(iRaiDec);
if (RA && DEC) {
if (inRange(iRaiDec.iRA, 0, iRAMax) && inRange(iRaiDec.iDEC, 0, iDECMax)) {
var q = self.getPixelValuePromise(iRaiDec.iRA, iRaiDec.iDEC, self.viewer.getRelFITSFilePath());
if (inRange(iRaiDec.iRa, 0, iRAMax) && inRange(iRaiDec.iDec, 0, iDECMax)) {
var q = self.getPixelValuePromise(iRaiDec.iRa, iRaiDec.iDec, self.viewer.getRelFITSFilePath());
q.then(
result => {
resolve(result)
......
......@@ -128,30 +128,11 @@ class Projection {
* @returns {Object} Object containing iRa, iDec coordinates
*/
raDecToiRaiDec(ra, dec) {
console.log("### raDecToiRaiDec");
const iRaiDec = this.absToRel([ra], [dec]);
console.log(iRaiDec);
const i_xp=Math.round((FITS_HEADER.crpix1+iRaiDec['x'])/(FITS_HEADER.cdelt1*180/Math.PI)-1);
const i_yp=Math.round((FITS_HEADER.crpix2+iRaiDec['y'])/(FITS_HEADER.cdelt2*180/Math.PI)-1);
console.log("## ixp");
console.log("## sum");
console.log(FITS_HEADER.crpix1+iRaiDec['x']);
console.log(FITS_HEADER.crpix1);
console.log(iRaiDec['x']);
console.log("## product");
console.log(FITS_HEADER.cdelt1*180/Math.PI);
console.log((FITS_HEADER.crpix1+iRaiDec['x'])/(FITS_HEADER.cdelt1*180/Math.PI)-1);
console.log(i_xp);
console.log("## iyp");
console.log("## sum");
console.log(FITS_HEADER.crpix2+iRaiDec['y']);
console.log(FITS_HEADER.crpix2);
console.log(iRaiDec['y']);
console.log("## product");
console.log(FITS_HEADER.cdelt2*180/Math.PI);
console.log((FITS_HEADER.crpix2+iRaiDec['x'])/(FITS_HEADER.cdelt2*180/Math.PI)-1);
console.log(i_yp);
const x = iRaiDec['x'];
const y = iRaiDec['y'];
const i_xp=Math.round(FITS_HEADER.crpix1+x/(FITS_HEADER.cdelt1)-1);
const i_yp=Math.round(FITS_HEADER.crpix2+y/(FITS_HEADER.cdelt2)-1);
// pixels to coordinates in radians
return { 'iRa': i_xp, 'iDec': i_yp };
......@@ -445,8 +426,10 @@ class GnomonicProjection extends Projection {
const n = a.length;
let x = new Array(n)
let y = new Array(n);
console.log("a0 : " + this._a0 + "d0 : "+ this._d0 + "angle : " + this._angle);
if (Math.abs(this._sind0) >= Projection.precision) {
console.log("CASE A");
for (let i = 0; i < n; i++) {
const sindec = Math.sin(d[i]);
const cosdec = Math.cos(d[i]);
......@@ -455,16 +438,23 @@ class GnomonicProjection extends Projection {
const product = sindec * this._cosd0 - cosdec * this._sind0 * cosa;
const r = Math.acos((sindec - this._cosd0 * product) / this._sind0);
if (r > Projection.precision) {
console.log("CASE A1");
const p = Math.atan2(cosdec * sina, product) + this._angle;
console.log("p :" + p);
const expr = Math.tan(r);
console.log("expr :" + expr);
x[i] = expr * Math.sin(p);
y[i] = expr * Math.cos(p);
console.log("xi :" + x[i]);
console.log("yi :" + y[i]);
} else {
console.log("CASE A2");
x[i] = 0.0;
y[i] = 0.0;
}
}
} else {
console.log("CASE B");
for (let i = 0; i < n; i++) {
const sina = Math.sin(a[i] - this._a0);
const cosa = Math.cos(a[i] - this._a0);
......@@ -472,18 +462,20 @@ class GnomonicProjection extends Projection {
const sindec = Math.sin(d[i]);
const r = Math.acos(cosdec * cosa);
if (r >= Projection.precision) {
console.log("CASE B1");
const p = Math.atan2(cosdec * sina, sindec) + this._angle;
const expr = Math.tan(r);
x[i] = expr * Math.sin(p);
y[i] = expr * Math.cos(p);
} else {
console.log("CASE B2");
x[i] = 0.0;
y[i] = 0.0;
}
}
}
//Projection.exit();
return { 'x': x, 'y': y };
return { 'x': x*180./Math.PI, 'y': y*180./Math.PI };
}
}
......
......@@ -59,7 +59,7 @@ import { SPEED_OF_LIGHT, VELOCITY_SHIFT_TYPE, REDSHIFT_SHIFT_TYPE } from "./cons
format(olc) {
//CoordinatesFormatter.enter(this.format.name);
var result;
const radec = this.projection.iRaiDecToHMSDMS(olc[0], olc[1]);
const radec = this.getRaDec(Math.round(olc[0]), Math.round(olc[1]));
var ctx = this.canvas.getContext('2d');
var pixelAtPosition = ctx.getImageData(olc[0], this.canvas.height - olc[1], 1, 1).data;
if (pixelAtPosition) {
......@@ -78,6 +78,13 @@ import { SPEED_OF_LIGHT, VELOCITY_SHIFT_TYPE, REDSHIFT_SHIFT_TYPE } from "./cons
return result;
}
/**
* Returns RA/DEC values in HMS/DMS format corresponding to given x/y value
*
* @param {float} x
* @param {float} y
* @returns {dict}
*/
getRaDec(x, y){
return this.projection.iRaiDecToHMSDMS(x, y);
}
......
......@@ -90,8 +90,6 @@ var displaySlice = function(relFITSFilePath, sliceIndex, viewer, settings, conto
$.post('png', { 'si': sliceIndex, 'relFITSFilePath': relFITSFilePath, 'ittName': ittName, 'lutName': lutName, 'vmName': vmName }).done(
function(resp) {
console.group("$.post('/png', {'si': _sliceIndex, 'relFITSFilePath': _relFITSFilePath})");
console.log("### RESP");
console.log(resp);
DOMAccessor.showLoaderAction(false);
if (resp["status"] == false) {
alert("Something went wrong during the generation of the image. The message was '" + resp["message"] + "'");
......@@ -251,9 +249,6 @@ $(document).ready(function() {
// displays value at clicked pixel on canvas
viewer.addClickEvent((event)=>{
// do request if click is in canvas ( not in left menu ) and no interaction enabled
console.log("### check conditions ");
console.log(event.originalEvent.originalTarget.tagName);
console.log(viewer.hasCurrentInteraction());
if(event.originalEvent.originalTarget.tagName === "CANVAS" && !viewer.hasCurrentInteraction()){
let request = '';
if(FITS_HEADER.naxis == 2){
......@@ -263,19 +258,18 @@ $(document).ready(function() {
}else{
alert("Incorrect number of axis : " + FITS_HEADER.naxis);
}
$.get( request,
$.get( request,
(data, status, xhr)=>{
if (status != "success") {
alert("A problem occurred with the request/server");
} else {
if (!data["status"]) {
console.log(data["message"]);
} else {
// show click marker if value exists
} else {
// show click marker if value exists
if(data.result !== null){
const x = Math.round(event.coordinate[0]);
const y = Math.round(event.coordinate[1]);
const y = Math.round(event.coordinate[1]);
const raDec = coordinatesFormatter.getRaDec(x, y);
if(x >= 0 && y >= 0){
lastClickMarker.setPositions(x, y, raDec['ra'], raDec['dec']);
......
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