Skip to content

Commit de31231

Browse files
author
Cindy Wang
committed
DM-11349 Add ra, dec colunmn name info the table meta for LSSTLightCurveQuery. Solve the issue to attach the existing drawing layers to the newly created plots.
1 parent 3c9af9b commit de31231

21 files changed

+312
-98
lines changed

src/firefly/java/edu/caltech/ipac/firefly/server/query/lsst/LSSTCataLogSearch.java

Lines changed: 2 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -303,27 +303,6 @@ protected String getFilePrefix(TableServerRequest request) {
303303

304304
}
305305

306-
/**
307-
* get ra (or ra corners) column name given the database and table name
308-
* @param database database name
309-
* @param catalog table name
310-
* @return ra related column(s)
311-
*/
312-
Object getRA(String database, String catalog) {
313-
return LSSTQuery.getDatasetInfo(database, catalog, new String[]{"ra"});
314-
}
315-
316-
/**
317-
* get dec (or dec corners) columne name given the database and table name
318-
* @param database database name
319-
* @param catalog table name
320-
* @return dec related column(s)
321-
*/
322-
Object getDEC(String database, String catalog) {
323-
return LSSTQuery.getDatasetInfo(database, catalog, new String[]{"dec"});
324-
325-
}
326-
327306

328307
@Override
329308
public void prepareTableMeta(TableMeta meta, List<DataType> columns, ServerRequest request) {
@@ -333,8 +312,8 @@ public void prepareTableMeta(TableMeta meta, List<DataType> columns, ServerReque
333312
String database = request.getParam("database");
334313

335314
if (LSSTQuery.isCatalogTable(database, catTable)) {
336-
Object RA = getRA(database, catTable);
337-
Object DEC = getDEC(database, catTable);
315+
Object RA = LSSTQuery.getRA(database, catTable);
316+
Object DEC = LSSTQuery.getDEC(database, catTable);
338317

339318
TableMeta.LonLatColumns llc = new TableMeta.LonLatColumns((String) RA, (String) DEC, CoordinateSys.EQ_J2000);
340319
meta.setCenterCoordColumns(llc);

src/firefly/java/edu/caltech/ipac/firefly/server/query/lsst/LSSTLightCurveQuery.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,18 @@ String buildExistingConstraints(TableServerRequest request, String objectIdConst
100100
public void prepareTableMeta(TableMeta meta, List<DataType> columns, ServerRequest request) {
101101
super.prepareTableMeta(meta, columns, request);
102102
meta.setAttribute(MetaConst.DATASET_CONVERTER, "lsst_sdss");
103+
104+
String database = request.getParam("database");
105+
String tableName = request.getParam("table_name");
106+
107+
// add ra&dec column name info
108+
if (LSSTQuery.isCatalogTable(database, tableName)) {
109+
Object RA = LSSTQuery.getRA(database, tableName);
110+
Object DEC = LSSTQuery.getDEC(database, tableName);
111+
112+
TableMeta.LonLatColumns llc = new TableMeta.LonLatColumns((String) RA, (String) DEC);
113+
meta.setCenterCoordColumns(llc);
114+
}
103115
}
104116

105117
}

src/firefly/java/edu/caltech/ipac/firefly/server/query/lsst/LSSTMultiObjectSearch.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ private DataGroup getSearchResult(TableServerRequest request, String filename) t
7070

7171
String tableName = request.getParam("table_name");
7272
String database = request.getParam("database");
73-
return ConcurrentSearchUtil.doSearch(workers, nThread, inDg, (String)getRA(database, tableName), (String)getDEC(database, tableName));
73+
return ConcurrentSearchUtil.doSearch(workers, nThread, inDg, (String)LSSTQuery.getRA(database, tableName), (String)LSSTQuery.getDEC(database, tableName));
7474

7575
}
7676

src/firefly/java/edu/caltech/ipac/firefly/server/query/lsst/LSSTQuery.java

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -541,6 +541,28 @@ public static String getTableColumn(String database, String tableName, String co
541541
return null;
542542
}
543543

544+
/**
545+
* get ra (or ra corners) column name given the database and table name
546+
* @param database database name
547+
* @param catalog table name
548+
* @return ra related column(s)
549+
*/
550+
public static Object getRA(String database, String catalog) {
551+
return LSSTQuery.getDatasetInfo(database, catalog, new String[]{"ra"});
552+
}
553+
554+
/**
555+
* get dec (or dec corners) columne name given the database and table name
556+
* @param database database name
557+
* @param catalog table name
558+
* @return dec related column(s)
559+
*/
560+
public static Object getDEC(String database, String catalog) {
561+
return LSSTQuery.getDatasetInfo(database, catalog, new String[]{"dec"});
562+
563+
}
564+
565+
544566
static String[] getDBTableNameFromRequest(TableServerRequest request) {
545567
String tableName = request.getParam("table_name");
546568
String catTable = request.getParam(CatalogRequest.CATALOG);

src/firefly/js/drawingLayers/DistanceTool.js

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
*/
44

55
import numeral from 'numeral';
6-
import {isBoolean} from 'lodash';
6+
import {isBoolean, get} from 'lodash';
77
import DrawLayerCntlr, {DRAWING_LAYER_KEY} from '../visualize/DrawLayerCntlr.js';
88
import {getPreference} from '../core/AppDataCntlr.js';
99
import {visRoot,dispatchAttributeChange} from '../visualize/ImagePlotCntlr.js';
@@ -19,10 +19,6 @@ import ShapeDataObj from '../visualize/draw/ShapeDataObj.js';
1919
import {primePlot, getDrawLayerById} from '../visualize/PlotViewUtil.js';
2020
import {getUIComponent} from './DistanceToolUI.jsx';
2121
import {makeFactoryDef} from '../visualize/draw/DrawLayerFactory.js';
22-
import {flux} from '../Firefly.js';
23-
24-
25-
2622

2723

2824
const EDIT_DISTANCE= BrowserInfo.isTouchInput() ? 18 : 10;
@@ -103,7 +99,7 @@ function onDetach(drawLayer,action) {
10399

104100
function getCursor(plotView, screenPt) {
105101
const plot= primePlot(plotView);
106-
var cc= CsysConverter.make(plot);
102+
107103
var ptAry= getPtAry(plot);
108104
if (!ptAry) return null;
109105
var idx= findClosestPtIdx(ptAry,screenPt);
@@ -127,7 +123,9 @@ function getLayerChanges(drawLayer, action) {
127123
return end(action);
128124
break;
129125
case DrawLayerCntlr.ATTACH_LAYER_TO_PLOT:
130-
return attach();
126+
if (!get(action.payload, 'isExistingDrawLayer', false)) {
127+
return attach();
128+
}
131129
break;
132130
case DrawLayerCntlr.MODIFY_CUSTOM_FIELD:
133131
return dealWithMods(drawLayer,action);

src/firefly/js/drawingLayers/FootprintTool.js

Lines changed: 72 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,14 @@ import {ANGLE_UNIT, OutlineType, getWorldOrImage, findClosestIndex, makeFootprin
1414
lengthSizeUnit, updateFootprintDrawobjAngle,
1515
updateFootprintTranslate, updateFootprintOutline} from '../visualize/draw/MarkerFootprintObj.js';
1616
import {markerInterval, getCC, cancelTimeoutProcess, initMarkerPos,
17-
updateVertexInfo, updateMarkerText} from './MarkerTool.js';
17+
updateVertexInfo, updateMarkerText, translateForRelocate, getMovement} from './MarkerTool.js';
1818
import {getFootprintToolUIComponent} from './FootprintToolUI.jsx';
1919
import ShapeDataObj from '../visualize/draw/ShapeDataObj.js';
2020
import {clone} from '../util/WebUtil.js';
2121
import {getDS9Region} from '../rpc/PlotServicesJson.js';
2222
import {FootprintFactory} from '../visualize/draw/FootprintFactory.js';
2323
import {makeImagePt} from '../visualize/Point.js';
24-
import {get, set, isArray, has, isNil} from 'lodash';
24+
import {get, set, isArray, has, isNil, isEmpty} from 'lodash';
2525
import Enum from 'enum';
2626

2727

@@ -67,7 +67,7 @@ export function footprintCreateLayerActionCreator(rawAction) {
6767
get(visRoot(), 'activePlotId') : isArray(plotId) ? plotId[0] : plotId;
6868

6969
if (pId) {
70-
dispatchAttachLayerToPlot(drawLayerId, pId, attachPlotGroup);
70+
dispatchAttachLayerToPlot(drawLayerId, pId, attachPlotGroup, attachPlotGroup);
7171

7272
var plot = primePlot(visRoot(), pId);
7373
if (plot) {
@@ -102,6 +102,7 @@ export function footprintStartActionCreator(rawAction) {
102102
const {footprintStatus, currentPt, timeoutProcess} = get(footprintObj, 'actionInfo', {});
103103
var wpt, idx, refPt;
104104
var nextStatus = null;
105+
let move = {};
105106

106107
cancelTimeoutProcess(timeoutProcess);
107108
// marker can move to anywhere the mouse click at while in 'attached' state
@@ -112,7 +113,8 @@ export function footprintStartActionCreator(rawAction) {
112113
wpt = getWorldOrImage(currentPt, cc);
113114
nextStatus = FootprintStatus.rotate;
114115
} else {
115-
wpt = getWorldOrImage(imagePt, cc); // relocate the footprint right after the layer is attached
116+
wpt = getWorldOrImage(currentPt, cc); // relocate the footprint right after the layer is attached
117+
move = getMovement(currentPt, imagePt, cc);
116118
nextStatus = FootprintStatus.attached_relocate;
117119
}
118120
}
@@ -132,7 +134,7 @@ export function footprintStartActionCreator(rawAction) {
132134
}
133135
if (nextStatus) {
134136
showFootprintByTimer(dispatcher, DrawLayerCntlr.FOOTPRINT_START, regions, plotId,
135-
nextStatus, footprintInterval, drawLayerId, {isOutline: true, isRotate:true}, fpInfo, wpt, refPt);
137+
nextStatus, footprintInterval, drawLayerId, {isOutline: true, isRotate:true}, fpInfo, wpt, refPt, move);
136138
}
137139
};
138140
}
@@ -278,13 +280,13 @@ function getLayerChanges(drawLayer, action) {
278280
if (!drawLayerId || drawLayerId !== drawLayer.drawLayerId) return null;
279281

280282
const dd = Object.assign({}, drawLayer.drawData);
281-
var plotIdAry;
283+
const {plotIdAry=[]} = drawLayer;
282284
var retV = null;
283285

284286
switch (action.type) {
285287

286288
case DrawLayerCntlr.FOOTPRINT_CREATE:
287-
plotIdAry = getPlotViewIdListInGroup(visRoot(), plotId);
289+
//plotIdAry = getPlotViewIdListInGroup(visRoot(), plotId);
288290
plotIdAry.forEach((pId) => {
289291
const plot = primePlot(visRoot(), pId);
290292
const cc = CsysConverter.make(plot);
@@ -300,17 +302,17 @@ function getLayerChanges(drawLayer, action) {
300302
var wptObj;
301303
const {wpt} = action.payload;
302304

303-
plotIdAry = getPlotViewIdListInGroup(visRoot(), plotId);
305+
//plotIdAry = getPlotViewIdListInGroup(visRoot(), plotId);
304306
plotIdAry.forEach((pId) => {
305307
wptObj = (pId === plotId) ? wpt : get(dd, ['data', pId, 'pts', '0']);
306308
retV = createFootprintObjs(action, drawLayer, pId, wptObj, retV);
307309
});
308310
return retV;
309311

310312
case DrawLayerCntlr.MODIFY_CUSTOM_FIELD:
311-
const {fpText, fpTextLoc, angleDeg, activePlotId} = action.payload.changes;
313+
const {fpText, fpTextLoc, angleDeg} = action.payload.changes;
312314

313-
plotIdAry = getPlotViewIdListInGroup(visRoot(), activePlotId);
315+
//plotIdAry = getPlotViewIdListInGroup(visRoot(), activePlotId);
314316
if (plotIdAry) {
315317
if (!isNil(angleDeg)) {
316318
return updateFootprintAngle(angleDeg, dd[DataTypes.DATA], plotIdAry);
@@ -319,6 +321,11 @@ function getLayerChanges(drawLayer, action) {
319321
}
320322
}
321323
break;
324+
case DrawLayerCntlr.ATTACH_LAYER_TO_PLOT:
325+
if (get(action.payload, 'isExistingDrawLayer', false)) {
326+
return attachToNewPlot(drawLayer, get(action.payload, ['plotIdAry', '0']));
327+
}
328+
break;
322329
default:
323330
return null;
324331
}
@@ -437,8 +444,10 @@ function createFootprintObjs(action, dl, plotId, wpt, prevRet) {
437444

438445
if (footprintStatus === FootprintStatus.attached ||
439446
footprintStatus === FootprintStatus.attached_relocate) { // position is relocated after the layer is attached
440-
441447
footprintObj = makeFootprint(regions, wpt, isHandle, cc, text, textLoc);
448+
if (footprintStatus === FootprintStatus.attached_relocate) {
449+
footprintObj = translateForRelocate(footprintObj, move, cc);
450+
}
442451
} else if (crtFpObj) {
443452
if ((footprintStatus === FootprintStatus.rotate || footprintStatus === FootprintStatus.relocate) && move) {
444453
var {apt} = move; // move to relocate or rotate
@@ -518,4 +527,55 @@ function resetRotateSide(footprintObj) {
518527
outlineBox[rSide] = 1;
519528
}
520529
}
521-
}
530+
}
531+
532+
/**
533+
* add the footprint drawing objects into the new plot reated after the drawing layer is created
534+
* @param drawLayer
535+
* @param newPlotId new plot
536+
* @returns {*}
537+
*/
538+
function attachToNewPlot(drawLayer, newPlotId) {
539+
const data = get(drawLayer, ['drawData', 'data'], {});
540+
const existPlotId = !isEmpty(data) && Object.keys(data).find((pId) => {
541+
return !isEmpty(drawLayer.drawData.data[pId]);
542+
});
543+
544+
if (!existPlotId) return null;
545+
546+
const { text, textLoc, renderOptions, actionInfo, translation, angle, angleUnit,
547+
drawData, regions} = get(drawLayer, ['drawData', 'data', existPlotId]);
548+
const plot = primePlot(visRoot(), newPlotId);
549+
const cc = CsysConverter.make(plot);
550+
let wpt = initMarkerPos(plot, cc);
551+
let footprintObj = makeFootprint(regions, wpt,
552+
{isOutline: drawData? drawData.isOutline : false,
553+
isRotate: drawData? drawData.isRorate : false},
554+
cc, text, textLoc);
555+
556+
if (!isEmpty(translation)) {
557+
footprintObj = updateFootprintTranslate(footprintObj, cc, translation);
558+
footprintObj= updateFootprintOutline(footprintObj, cc);
559+
resetRotateSide(footprintObj);
560+
wpt = get(footprintObj, ['pts', '0']);
561+
}
562+
563+
if (angle) {
564+
footprintObj = updateFootprintDrawobjAngle(footprintObj, cc, wpt, angle, angleUnit);
565+
footprintObj.angleFromUI = false;
566+
}
567+
568+
const aInfo = Object.assign({}, actionInfo, {currentPt: wpt});
569+
set(drawLayer.drawData, [DataTypes.DATA, newPlotId], Object.assign(footprintObj, {actionInfo: aInfo,
570+
renderOptions, translation}));
571+
const dlObj = {drawData: drawLayer.drawData, helpLine: editHelpText};
572+
573+
if (aInfo.footprintStatus) {
574+
const {exclusiveDef, vertexDef} = updateVertexInfo(footprintObj, newPlotId, drawLayer, drawLayer);
575+
576+
if (exclusiveDef && vertexDef) {
577+
return clone(dlObj, {footprintStatus: aInfo.footprintStatus, vertexDef, exclusiveDef});
578+
}
579+
}
580+
return dlObj;
581+
}

0 commit comments

Comments
 (0)