Skip to content

Commit 1ca4933

Browse files
committed
catalog upload does a better job at guessing ra and dec columns.
1 parent 3cadbe8 commit 1ca4933

File tree

2 files changed

+29
-18
lines changed

2 files changed

+29
-18
lines changed

src/firefly/java/edu/caltech/ipac/firefly/server/query/UserCatalogQuery.java

Lines changed: 27 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
import java.io.File;
1616
import java.io.IOException;
1717
import java.util.List;
18+
import java.util.regex.Pattern;
1819

1920
/**
2021
* @author tatianag
@@ -34,6 +35,9 @@ public class UserCatalogQuery extends DynQueryProcessor {
3435
"starid" // PCRS
3536
};
3637

38+
private static Pattern raP = Pattern.compile("(^|[-_ ])ra($|[^\\p{Alpha}])");
39+
private static Pattern decP = Pattern.compile("(^|[-_ ])dec($|[^\\p{Alpha}])");
40+
3741

3842

3943
protected File loadDynDataFile(TableServerRequest req) throws IOException, DataAccessException {
@@ -56,22 +60,11 @@ public void prepareTableMeta(TableMeta meta, List<DataType> columns, ServerReque
5660

5761

5862
public static void addCatalogMeta(TableMeta meta, List<DataType> columns, ServerRequest request) {
59-
TableMeta.LonLatColumns llc;
60-
61-
String lonCol = null, latCol = null;
62-
for (DataType col : columns) {
63-
if (col.getKeyName().equalsIgnoreCase(RA)) lonCol = col.getKeyName();
64-
if (col.getKeyName().equalsIgnoreCase(DEC)) latCol = col.getKeyName();
6563

6664

67-
if (!StringUtils.isEmpty(lonCol) && !StringUtils.isEmpty(latCol)) {
68-
llc = new TableMeta.LonLatColumns(lonCol, latCol, CoordinateSys.EQ_J2000);
69-
meta.setLonLatColumnAttr(MetaConst.CATALOG_COORD_COLS, llc);
70-
break;
71-
}
72-
}
73-
boolean catalogDataFound= (lonCol!=null && latCol!=null);
74-
if (catalogDataFound) {
65+
TableMeta.LonLatColumns llc = findLonLatCols(columns, (TableServerRequest) request);
66+
if (llc != null) {
67+
meta.setLonLatColumnAttr(MetaConst.CATALOG_COORD_COLS, llc);
7568
meta.setAttribute(MetaConst.CATALOG_OVERLAY_TYPE, "USER");
7669
meta.setAttribute(MetaConst.DATA_PRIMARY, "False");
7770
}
@@ -80,6 +73,26 @@ public static void addCatalogMeta(TableMeta meta, List<DataType> columns, Server
8073
if (name != null) meta.setAttribute(MetaConst.CATALOG_TARGET_COL_NAME, name);
8174
}
8275

76+
private static TableMeta.LonLatColumns findLonLatCols(List<DataType> columns, TableServerRequest request) {
77+
String lonCol = null, latCol = null;
78+
TableMeta.LonLatColumns llc = TableMeta.LonLatColumns.parse(request.getMeta(MetaConst.CATALOG_COORD_COLS));
79+
if (llc == null) {
80+
// guess best ra/dec columns
81+
for (DataType col : columns) {
82+
String cname = col.getKeyName();
83+
if (cname.equalsIgnoreCase(RA)) lonCol = cname;
84+
if (cname.equalsIgnoreCase(DEC)) latCol = cname;
85+
86+
if (lonCol == null && raP.matcher(cname).find()) lonCol = cname;
87+
if (latCol == null && decP.matcher(cname).find()) latCol = cname;
88+
}
89+
if (lonCol != null && latCol != null) {
90+
llc = new TableMeta.LonLatColumns(lonCol, latCol, CoordinateSys.EQ_J2000);
91+
}
92+
}
93+
return llc;
94+
}
95+
8396
private static String findTargetName(List<DataType> columns) {
8497
String cname;
8598
String finalName = null;

src/firefly/js/visualize/ui/CatalogSelectViewPanel.jsx

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -123,15 +123,14 @@ function doCatalog(request) {
123123
var tReq = {};
124124
if (request.spatial === SpatialMethod.get('Multi-Object').value) {
125125
var filename = request.fileUpload;
126-
// export function makeIrsaCatalogRequest(title, project, catalog, use='catalog_overlay', params={}, options={}, tbl_id=uniqueTblId()) {
126+
var radius = conesize;
127127
tReq = makeIrsaCatalogRequest(title, request.project, request.cattable, {
128128
filename,
129129
radius,
130130
SearchMethod: request.spatial,
131131
RequestedDataSet: request.catalog
132132
});
133133
} else {
134-
const id = 'GatorQuery';
135134
title += ` (${request.spatial}`;
136135
if (request.spatial === SpatialMethod.Box.value || request.spatial === SpatialMethod.Cone.value || request.spatial === SpatialMethod.Elliptical.value) {
137136
title += ':' + conesize + '\'\'';
@@ -242,8 +241,7 @@ function doVoSearch(request) {
242241

243242
function doLoadTable(request) {
244243
var tReq = makeTblRequest('userCatalogFromFile', 'Table Upload', {
245-
filePath: request.fileUpload,
246-
use: 'catalog_overlay'
244+
filePath: request.fileUpload
247245
});
248246
dispatchTableSearch(tReq);
249247
}

0 commit comments

Comments
 (0)