Commit 1410ef26 authored by François Agneray's avatar François Agneray
Browse files

Plot background with dataset images => done

parent ca9c1a21
Pipeline #5552 passed with stages
in 17 minutes and 57 seconds
......@@ -7,6 +7,8 @@
* file that was distributed with this source code.
*/
import { Image } from './image.model';
/**
* Interface for dataset.
*
......@@ -24,12 +26,16 @@ export interface Dataset {
id_dataset_family: number;
public: boolean;
config: {
images: Image[],
cone_search: {
enabled: boolean;
opened: boolean;
column_ra: number;
column_dec: number;
plot_enabled: boolean;
sdss_enabled: boolean;
sdss_display: number;
background: {id: number, enabled: boolean, display: number}[];
},
download: {
enabled: boolean;
......
export interface Image {
id: number;
name: string;
size: number;
ra_min: number;
ra_max: number;
dec_min: number;
dec_max: number;
stretch: string;
pmin: number;
pmax: number;
}
......@@ -6,4 +6,5 @@ export * from './survey.model';
export * from './attributes-by-dataset.model';
export * from './attribute.model';
export * from './option.model';
export * from './renderer-config.model';
\ No newline at end of file
export * from './renderer-config.model';
export * from './image.model';
......@@ -8,13 +8,28 @@
<span *ngIf="!ag.isOpen"><span class="fas fa-chevron-down"></span></span>
</span>
</button>
<app-cone-search-plot
[dataset]="getData()"
[ra]="coneSearch.ra"
[dec]="coneSearch.dec"
[rad]="coneSearch.radius"
[width]="500"
[height]="500">
</app-cone-search-plot>
<div class="row">
<div class="col-sm-12 col-md-6">
<app-cone-search-plot
[dataset]="getDataset()"
[data]="getData()"
[backgroundList]="backgroundList"
[selectedBackground]="selectedBackground"
[ra]="coneSearch.ra"
[dec]="coneSearch.dec"
[rad]="coneSearch.radius"
[width]="500"
[height]="500">
</app-cone-search-plot>
</div>
<div class="col-sm-12 col-md-6">
<div *ngIf="backgroundList.length > 0" class="form-group">
<label for="plot_background">Change background</label>
<ng-select [(ngModel)]="selectedBackground">
<ng-option *ngFor="let background of backgroundList" [value]="background.id">{{ background.name }}</ng-option>
</ng-select>
</div>
</div>
</div>
</accordion-group>
</accordion>
\ No newline at end of file
......@@ -7,7 +7,7 @@
* file that was distributed with this source code.
*/
import { ChangeDetectionStrategy, Component, Input } from '@angular/core';
import { ChangeDetectionStrategy, Component, Input, OnChanges, SimpleChanges } from '@angular/core';
import { ConeSearch } from 'src/app/shared/cone-search/store/model';
import { Attribute, Dataset } from '../../../metamodel/model';
......@@ -17,7 +17,7 @@ import { Attribute, Dataset } from '../../../metamodel/model';
templateUrl: 'cone-search-plot-tab.component.html',
changeDetection: ChangeDetectionStrategy.OnPush
})
export class ConeSearchPlotTabComponent {
export class ConeSearchPlotTabComponent implements OnChanges {
@Input() datasetName: string;
@Input() datasetList: Dataset[];
@Input() datasetAttributeList: Attribute[];
......@@ -27,6 +27,17 @@ export class ConeSearchPlotTabComponent {
@Input() isConeSearchAdded: boolean;
@Input() coneSearch: ConeSearch;
backgroundList = [];
selectedBackground = null;
ngOnChanges(changes: SimpleChanges) {
if (changes.datasetList) {
if (changes.datasetList.firstChange) {
this.setBackgroundList();
}
}
}
/**
* Checks if datatable accordion should be open.
*
......@@ -62,4 +73,29 @@ export class ConeSearchPlotTabComponent {
getDataset(): Dataset {
return this.datasetList.find(dataset => dataset.name === this.datasetName);
}
setBackgroundList() {
let background = [];
const dataset = this.getDataset();
if (dataset.config.cone_search.sdss_enabled) {
background.push({id: 0, name: "SDSS DR16", display: dataset.config.cone_search.sdss_display})
}
dataset.config.cone_search.background.forEach(b => {
if (b.enabled) {
const image = dataset.config.images.find(i => i.id === b.id);
background.push({
id: b.id,
display: b.display,
...image
});
}
})
if (background.length > 0) {
background.sort((a, b) => a.display - b.display);
this.backgroundList = background;
this.selectedBackground = background[0].id;
}
}
}
import { Component, OnChanges, ViewEncapsulation, Input, SimpleChanges } from '@angular/core';
import * as d3 from 'd3';
import { Dataset } from 'src/app/metamodel/model';
import { environment } from '../../../../environments/environment';
/**
* @class
* @classdesc Cone Search Plot component.
......@@ -15,7 +19,10 @@ import * as d3 from 'd3';
encapsulation: ViewEncapsulation.None
})
export class ConeSearchPlotComponent implements OnChanges {
@Input() dataset: {x: number, y: number}[];
@Input() dataset: Dataset;
@Input() data: {x: number, y: number}[];
@Input() backgroundList: {id: number, name: string, display: number, stretch: string, pmin: number, pmax: number}[];
@Input() selectedBackground: number;
@Input() ra: number;
@Input() dec: number;
@Input() rad: number;
......@@ -30,29 +37,34 @@ export class ConeSearchPlotComponent implements OnChanges {
y: d3.ScaleLinear<number, number>;
ngOnChanges(changes: SimpleChanges) {
if (changes.dataset) {
if (changes.dataset.previousValue != changes.dataset.currentValue) {
if (changes.data) {
if (changes.data.previousValue != changes.data.currentValue) {
this.conesearch_plot();
}
}
}
getHrefBackgroundImage() {
const scale = this.width / (this.rad * 2);
return `http://skyserver.sdss.org/dr16/SkyServerWS/ImgCutout/getjpeg?TaskName=Skyserver.Chart.Image
&ra=${this.ra}
&dec=${this.dec}
&scale=${scale}
&width=${this.width}
&height=${this.height}
&opt=&query=`;
const background = this.backgroundList.find(b => b.id === this.selectedBackground);
if (background.name === 'SDSS DR16') {
const scale = this.width / (this.rad * 2);
return `http://skyserver.sdss.org/dr16/SkyServerWS/ImgCutout/getjpeg?TaskName=Skyserver.Chart.Image
&ra=${this.ra}
&dec=${this.dec}
&scale=${scale}
&width=${this.width}
&height=${this.height}`;
} else {
return `${environment.servicesUrl}/fits-cut-to-png/${this.dataset.name}?filename=${background.name}`
+ `&ra=${this.ra}&dec=${this.dec}&radius=${this.rad}&stretch=${background.stretch}&pmin=${background.pmin}&pmax=${background.pmax}&axes=false`;
}
}
/**
* Creates the graph.
*/
conesearch_plot(): void {
if (!this.dataset || this.dataset.length === 0) {
if (!this.data || this.data.length === 0) {
return;
}
......@@ -73,10 +85,12 @@ export class ConeSearchPlotComponent implements OnChanges {
this.y.domain([this.dec - (this.rad / 3600), this.dec + (this.rad / 3600)]);
// Add fitscut png as backgroung
svg.append('image')
.attr('xlink:href', this.getHrefBackgroundImage())
.attr('width', this.width)
.attr('height', this.height);
if (this.backgroundList.length > 0) {
svg.append('image')
.attr('xlink:href', this.getHrefBackgroundImage())
.attr('width', this.width)
.attr('height', this.height);
}
// Add X axe
svg.append("g")
......@@ -89,7 +103,7 @@ export class ConeSearchPlotComponent implements OnChanges {
// Add Dataset
svg.selectAll("circle")
.data(this.dataset)
.data(this.data)
.enter()
.append("rect")
.attr('class','star')
......
......@@ -62,7 +62,11 @@ export class ConeSearchComponent {
* @param {ConeSearch} coneSearch - The cone search coordinates.
*/
updateConeSearch(coneSearch: ConeSearch): void {
this.store.dispatch(new coneSearchActions.AddConeSearchAction(coneSearch));
this.store.dispatch(new coneSearchActions.AddConeSearchAction({
ra: +coneSearch.ra,
dec: +coneSearch.dec,
radius: +coneSearch.radius
}));
}
/**
......
......@@ -37,7 +37,7 @@ describe('[Search][Result][Renderer] Component: ImageComponent', () => {
width: null
};
expect(component.getValue()).toEqual(
environment.servicesUrl + '/fits-to-png/anis_observation?filename=20141002/M_81-S001-R001-C001-SDSS_g.fits'
environment.servicesUrl + '/fits-to-png/anis_observation?filename=20141002/M_81-S001-R001-C001-SDSS_g.fits&stretch=linear&pmin=0.25&pmax=99.75&axes=true'
);
});
});
......@@ -58,7 +58,8 @@ export class ImageComponent {
*/
getValue(): string {
if (this.config.type === 'fits') {
return this.SERVICES_PATH + '/fits-to-png/' + this.datasetName + '?filename=' + this.value;
return `${this.SERVICES_PATH}/fits-to-png/${this.datasetName}?filename=${this.value}`
+ `&stretch=linear&pmin=0.25&pmax=99.75&axes=true`;
} else {
return this.value as string;
}
......
......@@ -13,12 +13,16 @@ export const DATASET_LIST: Dataset[] = [
id_dataset_family: 1,
public: true,
config: {
images: [],
cone_search: {
enabled: true,
opened: true,
column_ra: 2,
column_dec: 3,
plot_enabled: false
plot_enabled: false,
sdss_enabled: false,
sdss_display: 10,
background: []
},
download: {
enabled: true,
......@@ -59,12 +63,16 @@ export const DATASET_LIST: Dataset[] = [
id_dataset_family: 2,
public: false,
config: {
images: [],
cone_search: {
enabled: false,
opened: false,
column_ra: 2,
column_dec: 3,
plot_enabled: false
plot_enabled: false,
sdss_enabled: false,
sdss_display: 10,
background: []
},
download: {
enabled: true,
......@@ -105,12 +113,16 @@ export const DATASET_LIST: Dataset[] = [
id_dataset_family: 2,
public: false,
config: {
images: [],
cone_search: {
enabled: false,
opened: false,
column_ra: 2,
column_dec: 3,
plot_enabled: false
plot_enabled: false,
sdss_enabled: false,
sdss_display: 10,
background: []
},
download: {
enabled: true,
......
......@@ -12,12 +12,16 @@ export const DATASET: Dataset = {
id_dataset_family: 1,
public: true,
config: {
images: [],
cone_search: {
enabled: true,
opened: true,
column_ra: 2,
column_dec: 3,
plot_enabled: false
plot_enabled: false,
sdss_enabled: false,
sdss_display: 10,
background: []
},
download: {
enabled: true,
......
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