Skip to content

Commit f2aba67

Browse files
committed
DM-5792: Support artifacts on all images that have them (wise and 2mass)
- Image FileRetrievers can now artifacts to RelatedData - WISE and 2MASS supported - Artifact drawing layer uses lazy loading - added layer title matching for visibility, color, and symbol changing - firefly: IbeQueryArtifact replaces ife: FinderChartQueryArtifact - Also added support for getting adding RelatedData artifacts IbeFileRetrieve
1 parent 8fb6553 commit f2aba67

32 files changed

+980
-409
lines changed

src/firefly/java/edu/caltech/ipac/firefly/data/FileInfo.java

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,9 +93,18 @@ public static FileInfo blankFilePlaceholder() {
9393
public int getResponseCode() { return StringUtils.getInt(attributes.get(RESPONSE_CODE), 200); }
9494
public String getResponseCodeMsg() { return attributes.get(RESPONSE_CODE_MSG); }
9595

96+
97+
public void addRelatedDataList(List<RelatedData> rDataList) {
98+
if (rDataList==null) return;
99+
for(RelatedData rd : rDataList) addRelatedData(rd);
100+
}
101+
102+
96103
public void addRelatedData(RelatedData rData) {
97-
if (relatedData==null) relatedData= new ArrayList<>();
98-
relatedData.add(rData);
104+
if (rData!=null) {
105+
if (relatedData==null) relatedData= new ArrayList<>();
106+
relatedData.add(rData);
107+
}
99108
}
100109

101110
public List<RelatedData> getRelatedData() { return relatedData; }

src/firefly/java/edu/caltech/ipac/firefly/data/RelatedData.java

Lines changed: 59 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,10 @@
22
* License information at https://github.com/Caltech-IPAC/firefly/blob/master/License.txt
33
*/
44

5-
/*
6-
* License information at https://github.com/Caltech-IPAC/firefly/blob/master/License.txt
7-
*/
8-
95
package edu.caltech.ipac.firefly.data;
106

11-
127
import edu.caltech.ipac.firefly.visualize.RequestType;
138
import edu.caltech.ipac.firefly.visualize.WebPlotRequest;
14-
159
import java.io.Serializable;
1610
import java.util.HashMap;
1711
import java.util.Map;
@@ -26,66 +20,100 @@ public class RelatedData implements Serializable {
2620

2721
private String dataType= ""; // image or table
2822
private String desc;
23+
/** related dataKey should be a unique string for a fits file */
24+
private String dataKey;
2925
private Map<String,String> searchParams= new HashMap<>();
3026
private Map<String,String> availableMask= new HashMap<>();
3127

3228

3329
private RelatedData() {}
3430

35-
public static RelatedData makeMaskRelatedData(String fileName, Map<String,String> availableMask, int extensionNumber) {
36-
RelatedData d= new RelatedData();
37-
d.dataType= IMAGE_MASK;
38-
d.availableMask= availableMask;
39-
40-
d.desc= "Mask";
41-
d.searchParams.put(WebPlotRequest.FILE, fileName);
42-
d.searchParams.put(WebPlotRequest.PLOT_AS_MASK, "true");
43-
d.searchParams.put(WebPlotRequest.TYPE, RequestType.FILE+"");
44-
d.searchParams.put(WebPlotRequest.MULTI_IMAGE_IDX, extensionNumber+"");
45-
46-
return d;
31+
/**
32+
* Factory method to create mask related data
33+
* @param fileName - fits file name on the server
34+
* @param availableMask - a map with the key to be the bits number (as a string) and the value to be a description
35+
* @param extensionNumber - extension number of the fits file
36+
* @param dataKey - should be a unique string for a fits file
37+
* @return RelatedData
38+
*/
39+
public static RelatedData makeMaskRelatedData(String fileName, Map<String,String> availableMask, int extensionNumber, String dataKey) {
40+
Map<String,String> searchParams= new HashMap<>();
41+
searchParams.put(WebPlotRequest.FILE, fileName);
42+
searchParams.put(WebPlotRequest.PLOT_AS_MASK, "true");
43+
searchParams.put(WebPlotRequest.TYPE, RequestType.FILE+"");
44+
searchParams.put(WebPlotRequest.MULTI_IMAGE_IDX, extensionNumber+"");
45+
return makeMaskRelatedData(searchParams, availableMask, dataKey);
4746
}
4847

49-
50-
public static RelatedData makeMaskRelatedData(Map<String,String> searchParams, Map<String,String> availableMask) {
48+
/**
49+
* Factory method to create mask related data
50+
* @param searchParams- parameters used to make a WebPlotRequest search
51+
* @param availableMask - a map with the key to be the bits number (as a string) and the value to be a description
52+
* @param dataKey - should be a unique string for a fits file
53+
* @return RelatedData
54+
*/
55+
public static RelatedData makeMaskRelatedData(Map<String,String> searchParams, Map<String,String> availableMask, String dataKey) {
5156
RelatedData d= new RelatedData();
5257
d.dataType= IMAGE_MASK;
5358
d.availableMask= availableMask;
5459

5560
d.desc= "Mask";
61+
d.dataKey = dataKey;
5662
d.searchParams= searchParams;
5763
return d;
5864
}
5965

60-
public static RelatedData makeImageOverlayRelatedData(String fileName, String desc, int extensionNumber) {
61-
RelatedData d= new RelatedData();
62-
d.dataType= IMAGE_OVERLAY;
63-
d.desc= desc;
64-
65-
d.searchParams.put(WebPlotRequest.FILE, fileName);
66-
d.searchParams.put(WebPlotRequest.TYPE, RequestType.FILE+"");
67-
d.searchParams.put(WebPlotRequest.MULTI_IMAGE_IDX, extensionNumber+"");
68-
return d;
66+
/**
67+
* Factory method to create image overlay related data
68+
* @param fileName - name of the fits file
69+
* @param dataKey - should be a unique string for a fits file
70+
* @param desc - description of the data
71+
* @param extensionNumber - extenions number in the fits file
72+
* @return RelatedData
73+
*/
74+
public static RelatedData makeImageOverlayRelatedData(String fileName, String dataKey, String desc, int extensionNumber) {
75+
Map<String,String> searchParams= new HashMap<>();
76+
searchParams.put(WebPlotRequest.FILE, fileName);
77+
searchParams.put(WebPlotRequest.TYPE, RequestType.FILE+"");
78+
searchParams.put(WebPlotRequest.MULTI_IMAGE_IDX, extensionNumber+"");
79+
return makeImageOverlayRelatedData(searchParams,dataKey,desc);
6980
}
7081

71-
public static RelatedData makeImageOverlayRelatedData(Map<String,String> searchParams, String desc) {
82+
/**
83+
* Factory method to create image overlay related data
84+
* @param searchParams - parameters used to make a WebPlotRequest search
85+
* @param dataKey - should be a unique string for a fits file
86+
* @param desc - description of the data
87+
* @return RelatedData
88+
*/
89+
public static RelatedData makeImageOverlayRelatedData(Map<String,String> searchParams, String dataKey, String desc) {
7290
RelatedData d= new RelatedData();
7391
d.dataType= IMAGE_OVERLAY;
7492
d.desc= desc;
93+
d.dataKey = dataKey;
7594
d.searchParams= searchParams;
7695
return d;
7796
}
7897

79-
public static RelatedData makeTabularRelatedData(Map<String,String> searchParams, String desc) {
98+
/**
99+
* Factory method to create tabular related data
100+
* @param searchParams - parameters us to make a table file type server request
101+
* @param dataKey - should be a unique string for a fits file
102+
* @param desc - description of the data
103+
* @return RelatedData
104+
*/
105+
public static RelatedData makeTabularRelatedData(Map<String,String> searchParams, String dataKey, String desc) {
80106
RelatedData d= new RelatedData();
81107
d.dataType= TABLE;
82108
d.searchParams= searchParams;
109+
d.dataKey = dataKey;
83110
d.desc= desc;
84111
return d;
85112
}
86113

87114

88115
public String getDataType() { return dataType;}
116+
public String getDataKey() { return dataKey;}
89117
public Map<String,String> getAvailableMask() { return availableMask;}
90118
public String getDesc() { return desc;}
91119
public Map<String,String> getSearchParams() { return searchParams;}

src/firefly/java/edu/caltech/ipac/firefly/server/persistence/IbeFileRetrieve.java

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,18 +11,23 @@
1111
import edu.caltech.ipac.astro.ibe.IBE;
1212
import edu.caltech.ipac.astro.ibe.IbeDataParam;
1313
import edu.caltech.ipac.astro.ibe.IbeDataSource;
14+
import edu.caltech.ipac.firefly.data.FileInfo;
15+
import edu.caltech.ipac.firefly.data.RelatedData;
1416
import edu.caltech.ipac.firefly.data.ServerRequest;
1517
import edu.caltech.ipac.firefly.server.ServerContext;
16-
import edu.caltech.ipac.firefly.data.FileInfo;
1718
import edu.caltech.ipac.firefly.server.query.BaseFileInfoProcessor;
1819
import edu.caltech.ipac.firefly.server.query.DataAccessException;
1920
import edu.caltech.ipac.firefly.server.query.ParamDoc;
2021
import edu.caltech.ipac.firefly.server.query.SearchProcessorImpl;
22+
import edu.caltech.ipac.firefly.server.query.ibe.IbeQueryArtifact;
23+
import edu.caltech.ipac.visualize.plot.WorldPt;
2124

2225
import java.io.File;
2326
import java.io.IOException;
27+
import java.util.List;
2428
import java.util.Map;
2529

30+
2631
@SearchProcessorImpl(id = "ibe_file_retrieve", params =
2732
{@ParamDoc(name = "mission", desc = "mission"),
2833
})
@@ -48,13 +53,37 @@ protected FileInfo loadData(ServerRequest request) throws IOException, DataAcces
4853
} else {
4954
Map<String, String> cookies = ServerContext.getRequestOwner().getIdentityCookies();
5055
ofile.setCookies(cookies);
56+
ofile.addRelatedDataList( findRelatedDataList(request));
5157
return ofile;
5258
}
5359
} catch (Exception e) {
5460
throw new DataAccessException(e.getMessage(), e);
5561
}
5662
}
5763

64+
private List<RelatedData> findRelatedDataList(ServerRequest r) {
65+
String mission = r.getParam(MISSION);
66+
WorldPt wp= getWorldPtFromCenterParam(r.getParam("center"));
67+
String subsize= r.getParam("subsize");
68+
if (wp==null || mission==null || subsize==null) return null;
69+
70+
switch (mission.toLowerCase()) {
71+
case "wise":
72+
return IbeQueryArtifact.getWiseRelatedData(wp, subsize,r.getParam("band"));
73+
case "2mass":
74+
return IbeQueryArtifact.get2MassRelatedData(wp, subsize);
75+
default:
76+
return null;
77+
}
78+
}
79+
80+
private static WorldPt getWorldPtFromCenterParam(String cen) {
81+
if (cen==null) return null;
82+
String parts[]= cen.split(",");
83+
if (parts.length!=2) return null;
84+
return WorldPt.parse(parts[0]+';' + parts[1]+";J2000");
85+
}
86+
5887
protected File makeOutputFile(IbeDataParam params) throws IOException {
5988
String fname = params.getFileName();
6089
if (fname.contains(".tbl")) {

0 commit comments

Comments
 (0)