Skip to content

Commit 2c3ab59

Browse files
committed
response to review comments
1 parent e98f036 commit 2c3ab59

File tree

3 files changed

+16
-14
lines changed

3 files changed

+16
-14
lines changed

src/firefly/js/metaConvert/LsstSdssRequestList.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import {ZoomType} from '../visualize/ZoomType.js';
88
import {WebPlotRequest, TitleOptions} from '../visualize/WebPlotRequest.js';
99
import {ServerRequest} from '../data/ServerRequest.js';
1010
import {ServerParams} from '../data/ServerParams.js';
11+
import {toMaxFixed} from '../util/MathUtil.js';
1112

1213
/**
1314
* This method returns a WebRequest object
@@ -17,6 +18,9 @@ import {ServerParams} from '../data/ServerParams.js';
1718
* @returns {WebPlotRequest} a web plot request
1819
*/
1920
const bandMap= {u:0, g:1,r:2,i:3, z:4};
21+
22+
const DECDIGIT = 4;
23+
2024
function makeWebRequest(sr, plotId, title) {
2125
const r = WebPlotRequest.makeProcessorRequest(sr, 'lsst-sdss');
2226
const rangeValues= RangeValues.makeRV({which:SIGMA, lowerValue:-2, upperValue:10, algorithm:STRETCH_LINEAR});
@@ -56,7 +60,8 @@ function makeCcdReqBuilder(table, rowIdx) {
5660
return (plotId, id, filterName) => {
5761
sr.setParam('filterName', `${filterName}`);
5862
const scienceCCCdId = id.toString();
59-
const title =scienceCCCdId.substr(0, 4) + bandMap[filterName].toString() + scienceCCCdId.substr(5, 10)+'-'+filterName+(subsize ? ` size: ${subsize}(deg)` : '');
63+
const title =scienceCCCdId.substr(0, 4) + bandMap[filterName].toString() + scienceCCCdId.substr(5, 10)+
64+
'-'+filterName+(subsize ? ` size: ${toMaxFixed(subsize,DECDIGIT)}(deg)` : '');
6065
return makeWebRequest(sr, plotId, title);
6166
};
6267
}
@@ -87,7 +92,7 @@ function makeCoadReqBuilder(table, rowIdx) {
8792
return (plotId, id, filterName) => {
8893
sr.setParam('filterName', `${filterName}`);
8994
const deepCoaddId = id + bandMap[filterName];
90-
const title = deepCoaddId+'-'+filterName+(subsize ? ` size: ${subsize}(deg)` : '');
95+
const title = deepCoaddId+'-'+filterName+(subsize ? ` size: ${toMaxFixed(subsize,DECDIGIT)}(deg)` : '');
9196
return makeWebRequest(sr, plotId, title);
9297
};
9398
}

src/firefly/js/ui/SizeInputField.jsx

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import {convertAngle} from '../visualize/VisUtil.js';
66
import {InputFieldView} from './InputFieldView.jsx';
77
import {ListBoxInputFieldView} from './ListBoxInputField.jsx';
88
import Validate from '../util/Validate.js';
9+
import {toMaxFixed} from '../util/MathUtil.js';
910
import validator from 'validator';
1011

1112
const invalidSizeMsg = 'size is not set properly or size is out of range';
@@ -16,20 +17,13 @@ function getUnit(unit) {
1617
return unitSign[unit];
1718
}
1819

19-
/*
20-
* remove trailing zero from toFixed result
21-
*/
22-
function toMaxFixed(floatNum, digits) {
23-
return parseFloat(floatNum.toFixed(digits));
24-
}
25-
2620
// input: string format,
2721
// output: size in degree (string foramt, no decimal digit limit), '': invalid input
2822
export const sizeToDeg = (sizestr, unit) => {
2923
if (sizestr && !validator.isFloat(sizestr)) {
3024
return sizestr;
3125
}
32-
return (sizestr) ? toMaxFixed(convertAngle(((unit) ? unit : 'deg'), 'deg', sizestr), DECDIGIT).toString() : '';
26+
return (sizestr) ? convertAngle(((unit) ? unit : 'deg'), 'deg', sizestr).toString() : '';
3327
};
3428

3529
// input: size in degree string format

src/firefly/js/util/MathUtil.js

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,10 @@
1-
/**
2-
* @author tatianag
3-
*/
41
/*
52
Get the format string for a number, given an interval between the adjacent numbers
63
and the number of significant digits you'd like to preserve in this interval
74
*/
85
export const getFormatString = function(range, numSigDigits) {
96

10-
if (range==0) { return '0'; }
7+
if (range===0) { return '0'; }
118

129
var format; // string format
1310

@@ -32,3 +29,9 @@ export const getFormatString = function(range, numSigDigits) {
3229
return format;
3330
};
3431

32+
/*
33+
* remove trailing zero from toFixed result
34+
*/
35+
export function toMaxFixed(floatNum, digits) {
36+
return parseFloat(Number(floatNum).toFixed(digits));
37+
}

0 commit comments

Comments
 (0)