mirror of
https://github.com/cds-astro/aladin-lite.git
synced 2025-12-12 15:49:18 -08:00
only authorize giving shape's positions in icrs frame
This commit is contained in:
@@ -11,11 +11,11 @@
|
||||
|
||||
let aladin;
|
||||
A.init.then(() => {
|
||||
aladin = A.aladin('#aladin-lite-div', {target: 'Gamma Cas', fov: 10});
|
||||
aladin = A.aladin('#aladin-lite-div', {target: 'Gamma Cas', fov: 10, cooFrame: 'icrs'});
|
||||
|
||||
var overlay = A.graphicOverlay({color: '#ee2345', lineWidth: 2});
|
||||
var overlay = A.graphicOverlay({lineWidth: 2});
|
||||
aladin.addOverlay(overlay);
|
||||
overlay.add(A.polyline([ [2.29452158, 59.14978110], [10.12683778, 56.53733116], [14.1772154, 60.7167403], [21.45396446, 60.23528403], [28.59885697, 63.67010079] ]));
|
||||
overlay.add(A.polyline([ [2.29452158, 59.14978110], [10.12683778, 56.53733116], [14.1772154, 60.7167403], [21.45396446, 60.23528403], [28.59885697, 63.67010079] ], {color: 'green'}));
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
|
||||
@@ -637,7 +637,7 @@ impl WebClient {
|
||||
use crate::math::lonlat::LonLat;
|
||||
let xyz =
|
||||
LonLatT::new(lon.to_radians().to_angle(), lat.to_radians().to_angle()).vector();
|
||||
let lonlat = coosys::apply_coo_system(frame, self.app.get_coo_system(), &xyz).lonlat();
|
||||
let lonlat = coosys::apply_coo_system(frame, CooSystem::ICRS, &xyz).lonlat();
|
||||
lon = lonlat.lon().to_degrees();
|
||||
lat = lonlat.lat().to_degrees();
|
||||
}
|
||||
@@ -715,7 +715,7 @@ impl WebClient {
|
||||
///
|
||||
/// * `pos_x` - The x screen coordinate in pixels
|
||||
/// * `pos_y` - The y screen coordinate in pixels
|
||||
/// * `frame` - If not given, use the current view frame
|
||||
/// * `frame` - If not given, the coo given will be in the current view frame
|
||||
#[wasm_bindgen(js_name = pix2world)]
|
||||
pub fn pixel_to_world(
|
||||
&self,
|
||||
|
||||
@@ -30,10 +30,11 @@
|
||||
|
||||
import { MOC } from "./MOC.js";
|
||||
import { Overlay } from "./Overlay.js";
|
||||
import { Circle } from "./Circle.js";
|
||||
import { Ellipse } from "./Ellipse.js";
|
||||
import { Polyline } from "./Polyline.js";
|
||||
import { Line } from "./Line.js";
|
||||
import { Circle } from "./shapes/Circle.js";
|
||||
import { Ellipse } from "./shapes/Ellipse.js";
|
||||
import { Polyline } from "./shapes/Polyline.js";
|
||||
import { Line } from "./shapes/Line.js";
|
||||
|
||||
import { Catalog } from "./Catalog.js";
|
||||
import { ProgressiveCat } from "./ProgressiveCat.js";
|
||||
import { Source } from "./Source.js";
|
||||
|
||||
@@ -2295,32 +2295,35 @@ aladin.on("positionChanged", ({ra, dec}) => {
|
||||
}
|
||||
}
|
||||
|
||||
let radec = this.view.wasm.pix2world(x, y, frame);
|
||||
let lonlat = this.view.wasm.pix2world(x, y, frame);
|
||||
|
||||
let [ra, dec] = radec;
|
||||
let [lon, lat] = lonlat;
|
||||
|
||||
if (ra < 0) {
|
||||
return [ra + 360.0, dec];
|
||||
if (lon < 0) {
|
||||
return [lon + 360.0, lat];
|
||||
}
|
||||
|
||||
return [ra, dec];
|
||||
return [lon, lat];
|
||||
};
|
||||
|
||||
/**
|
||||
* Transform world coordinates to pixel coordinates in the view.
|
||||
*
|
||||
* @memberof Aladin
|
||||
* @param {number} ra - The Right Ascension (RA) coordinate in degrees.
|
||||
* @param {number} dec - The Declination (Dec) coordinate in degrees.
|
||||
* @param {CooFrame} [frame] - If not specified, the frame considered is the current view frame
|
||||
* @param {number} lon - Londitude coordinate in degrees.
|
||||
* @param {number} lat - Latitude coordinate in degrees.
|
||||
* @param {CooFrame} [frame] - If not specified, the frame used is ICRS
|
||||
|
||||
* @returns {number[]} - An array representing the [x, y] coordinates in pixel coordinates in the view.
|
||||
*
|
||||
* @throws {Error} Throws an error if an issue occurs during the transformation.
|
||||
*/
|
||||
Aladin.prototype.world2pix = function (ra, dec, frame) {
|
||||
Aladin.prototype.world2pix = function (lon, lat, frame) {
|
||||
if (frame) {
|
||||
frame = CooFrameEnum.fromString(frame, CooFrameEnum.J2000);
|
||||
if (frame instanceof string) {
|
||||
frame = CooFrameEnum.fromString(frame, CooFrameEnum.J2000);
|
||||
}
|
||||
|
||||
if (frame.label == CooFrameEnum.SYSTEMS.GAL) {
|
||||
frame = Aladin.wasmLibs.core.CooSystem.GAL;
|
||||
}
|
||||
@@ -2329,7 +2332,7 @@ aladin.on("positionChanged", ({ra, dec}) => {
|
||||
}
|
||||
}
|
||||
|
||||
return this.view.wasm.world2pix(ra, dec, frame);
|
||||
return this.view.wasm.world2pix(lon, lat, frame);
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
@@ -33,10 +33,10 @@ import { Coo } from "./libs/astro/coo.js";
|
||||
import { VOTable } from "./vo/VOTable.js";
|
||||
import { ObsCore } from "./vo/ObsCore.js";
|
||||
import A from "./A.js";
|
||||
import { Polyline } from "./Polyline.js";
|
||||
import { Line } from "./Line.js";
|
||||
import { Ellipse } from "./Ellipse.js";
|
||||
import { Circle } from "./Circle.js";
|
||||
import { Polyline } from "./shapes/Polyline.js";
|
||||
import { Line } from "./shapes/Line.js";
|
||||
import { Ellipse } from "./shapes/Ellipse.js";
|
||||
import { Circle } from "./shapes/Circle.js";
|
||||
import { Footprint } from "./Footprint.js";
|
||||
|
||||
/**
|
||||
|
||||
@@ -32,6 +32,7 @@
|
||||
|
||||
import { Utils } from './Utils';
|
||||
import A from "./A.js";
|
||||
import { Color } from './Color';
|
||||
|
||||
|
||||
export let Overlay = (function() {
|
||||
|
||||
@@ -36,9 +36,9 @@ import { ProjectionEnum } from "./ProjectionEnum.js";
|
||||
import { Utils } from "./Utils";
|
||||
import { GenericPointer } from "./GenericPointer.js";
|
||||
import { Stats } from "./libs/Stats.js";
|
||||
import { Circle } from "./Circle.js";
|
||||
import { Ellipse } from "./Ellipse.js";
|
||||
import { Polyline } from "./Polyline.js";
|
||||
import { Circle } from "./shapes/Circle.js";
|
||||
import { Ellipse } from "./shapes/Ellipse.js";
|
||||
import { Polyline } from "./shapes/Polyline.js";
|
||||
import { CooFrameEnum } from "./CooFrameEnum.js";
|
||||
import { requestAnimFrame } from "./libs/RequestAnimationFrame.js";
|
||||
import { WebGLCtx } from "./WebGL.js";
|
||||
|
||||
@@ -28,8 +28,8 @@
|
||||
*
|
||||
*****************************************************************************/
|
||||
|
||||
import { Utils } from "./Utils";
|
||||
import { Overlay } from "./Overlay.js";
|
||||
import { Utils } from "./../Utils";
|
||||
import { Overlay } from "./../Overlay.js";
|
||||
|
||||
/**
|
||||
* Represents an circle shape
|
||||
@@ -43,13 +43,13 @@ export let Circle = (function() {
|
||||
*
|
||||
* @constructor
|
||||
* @memberof Circle
|
||||
* @param {number[]} center - right-ascension/declination 2-tuple of the circle's center in degrees
|
||||
* @param {number[]} centerRaDec - right-ascension/declination 2-tuple of the circle's center in degrees
|
||||
* @param {number} radius - radius in degrees
|
||||
* @param {ShapeOptions} options - Configuration options for the circle
|
||||
*
|
||||
* @returns {Circle} - The circle shape object
|
||||
*/
|
||||
let Circle = function(center, radius, options) {
|
||||
let Circle = function(centerRaDec, radius, options) {
|
||||
options = options || {};
|
||||
|
||||
this.color = options['color'] || undefined;
|
||||
@@ -61,7 +61,7 @@ export let Circle = (function() {
|
||||
// TODO : all graphic overlays should have an id
|
||||
this.id = 'circle-' + Utils.uuidv4();
|
||||
|
||||
this.setCenter(center);
|
||||
this.setCenter(centerRaDec);
|
||||
this.setRadius(radius);
|
||||
this.overlay = null;
|
||||
|
||||
@@ -28,9 +28,8 @@
|
||||
*
|
||||
*****************************************************************************/
|
||||
|
||||
import { Utils } from "./Utils";
|
||||
import { Overlay } from "./Overlay.js";
|
||||
import { requestAnimFrame } from "./libs/RequestAnimationFrame";
|
||||
import { Utils } from "./../Utils";
|
||||
import { Overlay } from "./../Overlay.js";
|
||||
|
||||
/**
|
||||
* @typedef {Object} ShapeOptions
|
||||
@@ -44,7 +43,6 @@ import { requestAnimFrame } from "./libs/RequestAnimationFrame";
|
||||
* @property {number} [options.opacity=1] - The opacity, between 0 (totally transparent) and 1 (totally opaque)
|
||||
* @property {string} [options.selectionColor='#00ff00'] - A selection color
|
||||
* @property {string} [options.hoverColor] - A hovered color
|
||||
* @property {CooFrame} [options.frame] - Frame in which the coordinates are given. If none, the frame used is icrs/j2000.
|
||||
*/
|
||||
|
||||
/**
|
||||
@@ -59,7 +57,7 @@ export let Ellipse = (function() {
|
||||
*
|
||||
* @constructor
|
||||
* @memberof Ellipse
|
||||
* @param {number[]} center - right-ascension/declination 2-tuple of the ellipse's center in degrees
|
||||
* @param {number[]} centerRaDec - right-ascension/declination 2-tuple of the ellipse's center in degrees
|
||||
* @param {number} a - semi-major axis length in degrees
|
||||
* @param {number} b - semi-minor axis length in degrees
|
||||
* @param {number} theta - angle of the ellipse in degrees
|
||||
@@ -67,7 +65,7 @@ export let Ellipse = (function() {
|
||||
*
|
||||
* @returns {Ellipse} - The ellipse shape object
|
||||
*/
|
||||
let Ellipse = function(center, a, b, theta, options) {
|
||||
let Ellipse = function(centerRaDec, a, b, theta, options) {
|
||||
options = options || {};
|
||||
|
||||
this.color = options['color'] || undefined;
|
||||
@@ -80,7 +78,7 @@ export let Ellipse = (function() {
|
||||
// TODO : all graphic overlays should have an id
|
||||
this.id = 'ellipse-' + Utils.uuidv4();
|
||||
|
||||
this.setCenter(center);
|
||||
this.setCenter(centerRaDec);
|
||||
this.setAxisLength(a, b);
|
||||
this.setRotation(theta);
|
||||
this.overlay = null;
|
||||
@@ -198,7 +196,7 @@ export let Ellipse = (function() {
|
||||
this.overlay.reportChange();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Ellipse.prototype.setCenter = function(centerRaDec) {
|
||||
this.centerRaDec = centerRaDec;
|
||||
if (this.overlay) {
|
||||
@@ -280,34 +278,7 @@ export let Ellipse = (function() {
|
||||
|
||||
// 5. Get the correct ellipse angle
|
||||
let theta = -this.rotation + westToNorthAngle;
|
||||
//let ct = Math.cos(theta);
|
||||
//let st = Math.sin(theta);
|
||||
|
||||
/*let circlePtXyViewRa = view.aladin.world2pix(view.viewCenter.lon + 1.0, view.viewCenter.lat);
|
||||
let circlePtXyViewDec = view.aladin.world2pix(view.viewCenter.lon, view.viewCenter.lat + 1.0);
|
||||
|
||||
if (!circlePtXyViewRa || !circlePtXyViewDec) {
|
||||
// the circle border goes out of the projection
|
||||
// we do not draw it
|
||||
return;
|
||||
}
|
||||
|
||||
var dxRa = circlePtXyViewRa[0] - centerXyview[0];
|
||||
var dyRa = circlePtXyViewRa[1] - centerXyview[1];
|
||||
var dRa = Math.sqrt(dxRa*dxRa + dyRa*dyRa);
|
||||
|
||||
var dxDec = circlePtXyViewDec[0] - centerXyview[0];
|
||||
var dyDec = circlePtXyViewDec[1] - centerXyview[1];
|
||||
var dDec = Math.sqrt(dxDec*dxDec + dyDec*dyDec);*/
|
||||
|
||||
//var radiusInPixX = Math.abs(this.a * ct * dRa) + Math.abs(this.a * st * dDec);
|
||||
//var radiusInPixY = Math.abs(this.b * st * dRa) + Math.abs(this.b * ct * dDec);
|
||||
|
||||
// Ellipse crossing the projection
|
||||
/*if ((dxRa*dyDec - dxDec*dyRa) <= 0.0) {
|
||||
// We do not draw it
|
||||
return;
|
||||
}*/
|
||||
noStroke = noStroke===true || false;
|
||||
|
||||
// TODO : check each 4 point until show
|
||||
@@ -30,8 +30,8 @@
|
||||
*
|
||||
*****************************************************************************/
|
||||
import { Polyline } from "./Polyline.js";
|
||||
import { Utils } from './Utils';
|
||||
import { Overlay } from "./Overlay.js";
|
||||
import { Utils } from '../Utils';
|
||||
import { Overlay } from "../Overlay.js";
|
||||
import { Ellipse } from "./Ellipse.js";
|
||||
|
||||
/**
|
||||
@@ -77,7 +77,6 @@ export let Line = (function() {
|
||||
this.dec1 = dec1;
|
||||
this.ra2 = ra2;
|
||||
this.dec2 = dec2;
|
||||
this.frame = options.frame || "icrs";
|
||||
};
|
||||
|
||||
Line.prototype = {
|
||||
@@ -33,10 +33,9 @@
|
||||
*
|
||||
*****************************************************************************/
|
||||
|
||||
import { Utils } from './Utils';
|
||||
import { Overlay } from "./Overlay.js";
|
||||
import { ProjectionEnum } from "./ProjectionEnum.js";
|
||||
|
||||
import { Utils } from '../Utils';
|
||||
import { Overlay } from "../Overlay.js";
|
||||
import { ProjectionEnum } from "../ProjectionEnum.js";
|
||||
|
||||
/**
|
||||
* Represents a polyline shape
|
||||
@@ -97,13 +96,13 @@ export let Polyline = (function() {
|
||||
*
|
||||
* @constructor
|
||||
* @memberof Polyline
|
||||
* @param {Array.<number[]>} radecArray - right-ascension/declination 2-tuple array describing the polyline's vertices in degrees
|
||||
* @param {Array.<number[]>} raDecArray - right-ascension/declination 2-tuple array describing the polyline's vertices in degrees
|
||||
* @param {ShapeOptions} options - Configuration options for the polyline. Additional properties:
|
||||
* @param {boolean} [options.closed=false] - Close the polyline, default to false.
|
||||
*
|
||||
* @returns {Polyline} - The polyline shape object
|
||||
*/
|
||||
let Polyline = function(radecArray, options) {
|
||||
let Polyline = function(raDecArray, options) {
|
||||
options = options || {};
|
||||
this.color = options['color'] || undefined;
|
||||
this.fill = options['fill'] || false;
|
||||
@@ -118,7 +117,7 @@ export let Polyline = (function() {
|
||||
// All graphics overlay have an id
|
||||
this.id = 'polyline-' + Utils.uuidv4();
|
||||
|
||||
this.radecArray = radecArray;
|
||||
this.raDecArray = raDecArray;
|
||||
this.overlay = null;
|
||||
|
||||
this.isShowing = true;
|
||||
@@ -246,7 +245,7 @@ export let Polyline = (function() {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (! this.radecArray || this.radecArray.length<2) {
|
||||
if (! this.raDecArray || this.raDecArray.length<2) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -279,7 +278,7 @@ export let Polyline = (function() {
|
||||
// 1. project the vertices into the screen
|
||||
// and computes a BBox
|
||||
let xyView = [];
|
||||
let len = this.radecArray.length;
|
||||
let len = this.raDecArray.length;
|
||||
|
||||
let xmin = Number.POSITIVE_INFINITY
|
||||
let xmax = Number.NEGATIVE_INFINITY
|
||||
@@ -287,7 +286,7 @@ export let Polyline = (function() {
|
||||
let ymax = Number.NEGATIVE_INFINITY;
|
||||
|
||||
for (var k=0; k<len; k++) {
|
||||
var xyview = view.aladin.world2pix(this.radecArray[k][0], this.radecArray[k][1]);
|
||||
var xyview = view.aladin.world2pix(this.raDecArray[k][0], this.raDecArray[k][1]);
|
||||
if (!xyview) {
|
||||
return false;
|
||||
}
|
||||
@@ -459,8 +458,8 @@ export let Polyline = (function() {
|
||||
ctx.lineWidth = this.lineWidth;
|
||||
|
||||
let pointXY = [];
|
||||
for (var j = 0; j < this.radecArray.length; j++) {
|
||||
var xy = view.aladin.world2pix(this.radecArray[j][0], this.radecArray[j][1]);
|
||||
for (var j = 0; j < this.raDecArray.length; j++) {
|
||||
var xy = view.aladin.world2pix(this.raDecArray[j][0], this.raDecArray[j][1]);
|
||||
if (!xy) {
|
||||
return false;
|
||||
}
|
||||
Reference in New Issue
Block a user