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

some modificatio x

parent 7840ccb3
......@@ -54,7 +54,7 @@ class AxesFactory extends ShapesFactory {
console.trace();
console.log(axes);
let lineString = new ol.geom.MultiLineString(axes.parallels.concat(axes.meridians));
let f = new ol.Feature({ geometry: lineString.simplify(1) });
f.setStyle(this.axisStyle);
......@@ -84,11 +84,9 @@ class AxesFactory extends ShapesFactory {
* @param {array} ra/dec coordinates
*/
addExtremityPoint(coords, label) {
let point = new ol.geom.Point(coords);
let f2 = new ol.Feature({ geometry: point });
f2.setStyle(new ol.style.Style({
stroke: new ol.style.Stroke({
color: 'green',
......@@ -116,21 +114,24 @@ class AxesFactory extends ShapesFactory {
* @returns {array} an array of x, y arrays with all coordinates of the meridians
*/
getMeridians(limits) {
// Plot the meridians,
// Plot the meridians,
console.log("### getMeridians");
console.log(limits);
const x = FITS_HEADER.naxis1 * Math.abs(FITS_HEADER.cdelt1);
const stepx = x / this.numeridians;
const y = FITS_HEADER.naxis2 * Math.abs(FITS_HEADER.cdelt2);
const stepy = y / this.numeridians;
let ras = [];
let decs = [];
const radDegInterval = radToDeg(limits["RA_max"]) - radToDeg(limits["RA_min"]);
const decDegInterval = radToDeg(limits["DEC_max"]) - radToDeg(limits["DEC_min"]);
const coeff = 0.5;
for(let i = radToDeg(limits["RA_min"]) - coeff*radDegInterval; i <= radToDeg(limits["RA_max"])+ coeff*radDegInterval; i = i+stepx){
ras.push(i);
}
......@@ -140,21 +141,22 @@ class AxesFactory extends ShapesFactory {
}
let coordinates_list = [];
console.log(ras);
for(let i = 0; i < ras.length; i=i+2){
let coordinates = [];
for(let j = 0; j < decs.length; j=j+2){
let xy = this.projection.absToRel([ras[i]*(Math.PI/180)], [decs[j]*(Math.PI/180)]);
const i_xp = Math.round(FITS_HEADER.crpix1 + (xy['x'][0]) / (this.cdelt1) - 1);
const i_yp = Math.round(FITS_HEADER.crpix2 + (xy['y'][0]) / (this.cdelt2) - 1);
const i_xp = Math.round(FITS_HEADER.crpix1 + ((xy['x']) / (this.cdelt1)) - 1);
const i_yp = Math.round(FITS_HEADER.crpix2 + ((xy['y']) / (this.cdelt2)) - 1)
if (this.viewer.isInExtent(i_xp, i_yp)) {
coordinates.push([i_xp, i_yp]);
}
}
if (coordinates.length > 1)
coordinates_list.push(coordinates);
}
console.log(coordinates_list);
return coordinates_list;
}
......@@ -192,8 +194,8 @@ class AxesFactory extends ShapesFactory {
let coordinates = [];
for(let j = 0; j < ras.length; j=j+2){
let xy = this.projection.absToRel([ras[j]*(Math.PI/180)], [decs[i]*(Math.PI/180)]);
const i_xp = Math.round(FITS_HEADER.crpix1 + (xy['x'][0]) / (this.cdelt1) - 1);
const i_yp = Math.round(FITS_HEADER.crpix2 + (xy['y'][0]) / (this.cdelt2) - 1);
const i_xp = Math.round(FITS_HEADER.crpix1 + (xy['x']) / (this.cdelt1) - 1);
const i_yp = Math.round(FITS_HEADER.crpix2 + (xy['y']) / (this.cdelt2) - 1);
if (this.viewer.isInExtent(i_xp, i_yp)) {
coordinates.push([i_xp, i_yp]);
}
......@@ -204,7 +206,6 @@ class AxesFactory extends ShapesFactory {
}
return coordinates_list;
}
/**
......
......@@ -344,6 +344,8 @@ class MarkersFactory extends ShapesFactory {
{ title: 'label', type: 'text', width: '100px', name: 'label', readOnly: false },
{ title: 'RA', type: 'text', width: '150px', name: 'RA', readOnly: true },
{ title: 'DEC', type: 'text', width: '150px', name: 'DEC', readOnly: true },
{ title: 'iRA', type: 'text', width: '150px', name: 'iRA', readOnly: true },
{ title: 'iDEC', type: 'text', width: '150px', name: 'iDEC', readOnly: true },
{ title: this.pixelValueColumnName, type: 'numeric', width: '150px', name: this.pixelValueColumnName, readOnly: true }
];
this.fieldNames = this.columns.map((o) => { return o.title });
......@@ -534,8 +536,10 @@ class MarkersFactory extends ShapesFactory {
*/
getDataAsJSON() {
MarkersFactory.enter(this.getDataAsJSON.name);
console.log("function getDataAsJSon");
let json_result = [];
let data = this.jexcel.getData();
console.log(data);
for (let i = 0; i < data.length; i++) {
let result = this.a2O(data[i]);
json_result.push(result);
......@@ -673,8 +677,10 @@ class MarkersFactory extends ShapesFactory {
let self = this;
var p = new Promise((resolve, reject)=>{
const { RA, DEC } = this.validateRow(row);
//const iRaiDec = this.projection.raDecToiRaiDec(degToRad(RA.decdegree), degToRad(DEC.decdegree));
const iRaiDec = this.projection.raDecToiRaiDec(5.274091711490477, 0.7119264195952342);
console.log(RA);
console.log(DEC);
const iRaiDec = this.projection.raDecToiRaiDec(RA.decdegree, DEC.decdegree);
//const iRaiDec = this.projection.raDecToiRaiDec(5.274091711490477, 0.7119264195952342);
console.log("### changed" );
console.log(iRaiDec);
......@@ -763,11 +769,11 @@ class MarkersFactory extends ShapesFactory {
var RAinDD = self.checkRA(row.RA).decdegree;
var DECinDD = self.checkDEC(row.DEC).decdegree;
if (RAinDD && DECinDD) {
let [iRA, iDEC] = self.projection.absToRel(degToRad(RAinDD), degToRad(DECinDD));
let iRaiDec = self.projection.absToRel(degToRad(RAinDD), degToRad(DECinDD));
/* var x = Math.round(this.raDDtoPixelConverter.convert(RAinDD));
var y = Math.round(this.decDDtoPixelConverter.convert(DECinDD)); */
var label = row.label;
var f = new ol.Feature({ geometry: new ol.geom.Point([iRA, iDEC]) });
var f = new ol.Feature({ geometry: new ol.geom.Point([iRaiDec['x'], iRaiDec['y']]) });
f.set("label", label);
f.setStyle(this.style_f(f));
self.numOfMarkers += 1;
......@@ -835,6 +841,7 @@ class MarkersFactory extends ShapesFactory {
var label = `m_${this.numOfMarkers}`;
event.feature.set('label', label);
// get ra/dec coorinates with projection
console.log("maker at coordinates : " + coordinates[0] + " " + coordinates[1]);
const radec = this.projection.iRaiDecToHMSDMS(coordinates[0], coordinates[1]);
event.feature.set('RA', radec['ra']);
......@@ -855,8 +862,11 @@ class MarkersFactory extends ShapesFactory {
this.indexToMarker[this.markerIndex] = event.feature;
let d = {
'id': this.markerIndex, 'RA': radec['ra'],
'id': this.markerIndex,
'RA': radec['ra'],
'DEC': radec['dec'],
'iRA' : Math.floor(coordinates[0]),
'iDEC' : Math.floor(coordinates[1]),
'label': label
};
d[this.pixelValueColumnName] = flux["value"];
......@@ -971,12 +981,14 @@ class MarkersFactory extends ShapesFactory {
RA.minute = result[2];
RA.second = result[3];
RA.decdegree = RA.hour * 15 + RA.minute / 4 + RA.second / 240;
RA.rad = degToRad(RA.decdegree);
result = RA;
} else {
pat = /(\d{1,3})\.(\d+)/;
result = this.matchAndEvaluate(value, pat);
if (result) {
RA.decdegree = parseFloat(value);
RA.rad = degToRad(RA.decdegree);
RA.hour = Math.floor(RA.decdegree / 15);
RA.minute = Math.floor((RA.decdegree / 15 - RA.hour) * 60);
RA.second = (RA.decdegree / 15 - RA.hour - RA.minute / 60) * 3600;
......@@ -1028,6 +1040,7 @@ class MarkersFactory extends ShapesFactory {
DEC.minute = result[2];
DEC.second = result[3];
DEC.decdegree = (DEC.degree + DEC.minute / 60. + DEC.second / 3600.) * (DEC.negative ? -1 : 1);
DEC.rad = degToRad(DEC.decdegree);
result = DEC;
} else {
if (value.charCodeAt(0) == 8722 || value.charCodeAt(0) == 45) { value = "-" + value.slice(1); }
......@@ -1035,6 +1048,7 @@ class MarkersFactory extends ShapesFactory {
var result1 = this.matchAndEvaluate(value, pat1);
if (result1) {
DEC.decdegree = result1[1];
DEC.rad = degToRad(DEC.decdegree);
if (value[0] == "-") {
DEC.decdegree = -DEC.decdegree;
}
......
......@@ -426,10 +426,7 @@ 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]);
......@@ -438,23 +435,17 @@ 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);
......@@ -462,20 +453,18 @@ 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*180./Math.PI, 'y': y*180./Math.PI };
return { 'x': x, 'y': y };
}
}
......
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