Skip to content
Snippets Groups Projects
Commit 2f4517c3 authored by François Agneray's avatar François Agneray
Browse files

WIP => plot

parent cfb15e78
No related branches found
No related tags found
2 merge requests!72Develop,!34New features
...@@ -40,6 +40,17 @@ export class ConeSearchPlotComponent implements OnInit { ...@@ -40,6 +40,17 @@ export class ConeSearchPlotComponent implements OnInit {
this.coneSearchPlot(); this.coneSearchPlot();
} }
getHrefBackgroundImage() {
//const scale = this.width / (this.rad * 2);
const scale = this.coneSearch.radius / this.width; // arcsec/pix
return `https://skyserver.sdss.org/dr16/SkyServerWS/ImgCutout/getjpeg?TaskName=Skyserver.Chart.Image
&ra=${this.coneSearch.ra}
&dec=${this.coneSearch.dec}
&scale=${scale}
&width=${this.width}
&height=${this.height}`;
}
coneSearchPlot(): void { coneSearchPlot(): void {
// Init SVG // Init SVG
const svg = d3.select('#plot').append('svg') const svg = d3.select('#plot').append('svg')
...@@ -49,11 +60,16 @@ export class ConeSearchPlotComponent implements OnInit { ...@@ -49,11 +60,16 @@ export class ConeSearchPlotComponent implements OnInit {
.append('g') .append('g')
.attr('transform', 'translate(' + this.margin.left + ',' + this.margin.top + ')'); .attr('transform', 'translate(' + this.margin.left + ',' + this.margin.top + ')');
// Set Domain // Set Domain RA->DEG, DEC->DEG, RADIUS->ARCSEC
this.x = d3.scaleLinear().range([this.width, 0]); const coneSearchDomain = this.getConeSearchDomain();
this.y = d3.scaleLinear().range([this.height, 0]); this.x = d3.scaleLinear().range([this.width, 0]).domain([coneSearchDomain.raMin, coneSearchDomain.raMax]);
this.x.domain([this.coneSearch.ra - (this.coneSearch.radius / 3600) / Math.cos(this.coneSearch.dec * this.degTorad), this.coneSearch.ra + (this.coneSearch.radius / 3600) / Math.cos(this.coneSearch.dec * this.degTorad)]); this.y = d3.scaleLinear().range([this.height, 0]).domain([coneSearchDomain.decMin, coneSearchDomain.decMax]);
this.y.domain([this.coneSearch.dec - (this.coneSearch.radius / 3600), this.coneSearch.dec + (this.coneSearch.radius / 3600)]);
// Background image
svg.append('image')
.attr('xlink:href', this.getHrefBackgroundImage())
.attr('width', this.width)
.attr('height', this.height);
// Add X axe // Add X axe
svg.append("g") svg.append("g")
...@@ -85,4 +101,17 @@ export class ConeSearchPlotComponent implements OnInit { ...@@ -85,4 +101,17 @@ export class ConeSearchPlotComponent implements OnInit {
}) })
.on('mouseout', () => { d3.select('.tooltip').remove(); }); .on('mouseout', () => { d3.select('.tooltip').remove(); });
} }
private getConeSearchDomain() {
const radiusInDegrees = this.coneSearch.radius / 3600;
const decMin = this.coneSearch.dec - radiusInDegrees;
const decMax = this.coneSearch.dec + radiusInDegrees;
const raCorrectedRadius = radiusInDegrees / Math.cos(this.degTorad * (Math.abs(this.coneSearch.dec) + radiusInDegrees));
const raMin = this.coneSearch.ra - raCorrectedRadius;
const raMax = this.coneSearch.ra + raCorrectedRadius;
return { raMin, raMax, decMin, decMax };
}
} }
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment