Skip to content

DM-6516-footprint footprint tool implementation. Integrating with the implementation of marker tool. Both are made in consistent style. #117

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Jul 20, 2016
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
* Time: 1:27 PM
*/


import edu.caltech.ipac.firefly.data.DataEntry;
import edu.caltech.ipac.firefly.data.ServerParams;
import edu.caltech.ipac.firefly.data.TableServerRequest;
import edu.caltech.ipac.firefly.data.table.TableMeta;
Expand All @@ -23,13 +23,17 @@
import edu.caltech.ipac.firefly.visualize.WebPlotRequest;
import edu.caltech.ipac.firefly.visualize.WebPlotResult;
import edu.caltech.ipac.firefly.visualize.draw.StaticDrawInfo;
import edu.caltech.ipac.util.FileUtil;
import edu.caltech.ipac.util.DataGroup;
import edu.caltech.ipac.visualize.plot.ImagePt;

import nom.tam.fits.FitsException;
import org.json.simple.JSONArray;
import org.json.simple.JSONObject;

import java.io.BufferedReader;
import java.io.IOException;
import java.net.URL;
import java.util.*;

/**
Expand Down Expand Up @@ -432,16 +436,22 @@ public String doCommand(Map<String, String[]> paramMap) throws IllegalArgumentEx
}

public static class DS9Region extends ServerCommandAccess.ServCommand {
private static final String footprintKey = "${footprintDef}";

public String doCommand(Map<String, String[]> paramMap) throws IllegalArgumentException {
SrvParam sp= new SrvParam(paramMap);
public String doCommand(Map<String, String[]> paramMap) throws IllegalArgumentException, IOException {
SrvParam sp = new SrvParam(paramMap);
String fileKey = sp.getRequired(ServerParams.FILE_KEY);
WebPlotResult result= VisServerOps.getDS9Region(fileKey);
WebPlotResult result;

if (fileKey.contains(footprintKey)) {
result = VisServerOps.getFootprintRegion(fileKey.substring(footprintKey.length()));
} else {
result = VisServerOps.getDS9Region(fileKey);
}
return WebPlotResultSerializer.createJson(result, sp.isJsonDeep());
}
}


public static class SaveDS9Region extends ServerCommandAccess.ServCommand {

public String doCommand(Map<String, String[]> paramMap) throws IllegalArgumentException {
Expand Down Expand Up @@ -473,9 +483,6 @@ public String doCommand(Map<String, String[]> paramMap) throws IllegalArgumentEx
}
}




//=============================================
//-------------- Utility Methods --------------
//=============================================
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,11 @@
import java.awt.geom.Rectangle2D;
import java.awt.image.IndexColorModel;
import java.io.BufferedOutputStream;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileOutputStream;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.IOException;
import java.io.RandomAccessFile;
import java.util.ArrayList;
Expand Down Expand Up @@ -1434,9 +1437,66 @@ public static WebPlotResult getDS9Region(String fileKey) {
retval = createError("on getDSRegion", null, e);
}
return retval;
}

private static final Map<String, String> footprintMap;
static {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you and I and @loitly should talk about where the right place to store these files are. I don't know if we want put it in 'visualize/reousrces'

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

besides the issue regrading where to put the footprint files, I also have some concern regrading if it is ok to hardcode the footprint map in the java file? or put the map data into a text file and create the map by loading the text file?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, good point. I would decouple the data content and the loading. The same way we load properties. Actually you could think a future use case of a user-defined footprint to be loaded and added to the layers as part of all the predefined footprint available.

Emmanuel Joliet
NASA/IPAC Infrared Science Archive
MS 100-22, Caltech, Pasadena, CA 91125
Office: 170
Email: [email protected]
Phone: (626) 395-1489

On Jul 18, 2016, at 12:58, Cindy Wang [email protected] wrote:

In src/firefly/java/edu/caltech/ipac/firefly/server/visualize/VisServerOps.java:

  • private static final Map<String, String> footprintMap;
  • static {
    besides the issue regrading where to put the footprint files, I also have some concern regrading if it is ok to hardcode the footprint map in the java file? or put the map data into a text file and create the map by loading the text file?


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub, or mute the thread.

footprintMap = new HashMap<String, String>();
footprintMap.put("HST", "Footprint_HST.reg");
footprintMap.put("HST_NICMOS", "Footprint_HST.reg");
footprintMap.put("HST_WFPC2", "Footprint_HST.reg");
footprintMap.put("HST_ACS/WFC", "Footprint_HST.reg");
footprintMap.put("HST_ACS/HRC", "Footprint_HST.reg");
footprintMap.put("HST_ACS/SBC", "Footprint_HST.reg");
footprintMap.put("HST_WFC3/UVIS","Footprint_HST.reg");
footprintMap.put("HST_WFC3/IR", "Footprint_HST.reg");
footprintMap.put("JWST", "Footprint_JWST.reg");
footprintMap.put("JWST_FGS", "Footprint_JWST.reg");
footprintMap.put("JWST_MIRI", "Footprint_JWST.reg");
footprintMap.put("JWST_NIRCAM", "Footprint_JWST.reg");
footprintMap.put("JWST_NIS", "Footprint_JWST.reg");
footprintMap.put("JWST_NIRSPEC","Footprint_JWST.reg");
footprintMap.put("SPITZER", "Footprint_SPITZER.reg" );
footprintMap.put("SPITZER_IRAC36", "Footprint_SPITZER.reg");
footprintMap.put("SPITZER_IRAC45", "Footprint_SPITZER.reg");
footprintMap.put("WFIRST", "Footprint_WFIRST.reg");
}

public static WebPlotResult getFootprintRegion(String fpInfo) {

List<String> rAsStrList = new ArrayList<String>();
List<String> msgList = new ArrayList<String>();
WebPlotResult retval = new WebPlotResult();

if (footprintMap.containsKey(fpInfo)) {
int idx = fpInfo.indexOf('_');

String tag = idx >= 0 ? fpInfo.substring(idx + 1) : fpInfo;
String fileName = "edu/caltech/ipac/visualize/resources/" + footprintMap.get(fpInfo);

try {
InputStream in = VisServerOps.class.getClassLoader().getResourceAsStream(fileName);
BufferedReader br = new BufferedReader(new InputStreamReader(in));
String tmpLine;

while ((tmpLine = br.readLine()) != null) {
tmpLine = tmpLine.trim();
if (!tmpLine.startsWith("#") && (tmpLine.contains("tag={" + tag)))
rAsStrList.add(tmpLine);
}
if (rAsStrList.size() == 0) {
msgList.add("no region is defined in the footprint file");
}
} catch (Exception e) {
retval = createError("on getFootprintRegion", null, e);
}
}
retval.putResult(WebPlotResult.REGION_DATA,
new DataEntry.Str(StringUtils.combineStringList(rAsStrList)));
retval.putResult(WebPlotResult.REGION_ERRORS,
new DataEntry.Str(StringUtils.combineStringList(msgList)));
return retval;
}

public static synchronized boolean addSavedRequest(String saveKey, WebPlotRequest request) {
Cache cache = UserCache.getInstance();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#NICMOS
POLYGON -0.01082769 0.01555834 -0.01297767 0.01773334 -0.01515545 0.01558057 -0.01300546 0.01340557 -0.01082769 0.01555834 # color=cyan tag={NICMOS}
POLYGON -0.01491377 0.02102499 -0.01871653 0.02476942 -0.02249152 0.02093610 -0.01868877 0.01719167 -0.01491377 0.02102499 # color=cyan tag={NICMOS}
POLYGON 0.01088058 0.00023060 0.00071672 0.01036392 -0.00944160 0.00017227 0.00072225 -0.00995826 0.01088058 0.00023060 # color=cyan tag={NICMOS}
#WFPC2
POLYGON 360.00006667 -0.00312778 360.00723056 -0.01026944 360.00009167 -0.01743333 359.99292778 -0.01028889 360.00006667 -0.00312778 # color=yellow tag={WFPC2}
POLYGON 360.00148056 -0.00349167 359.98601112 -0.01929166 359.97019723 -0.00381111 359.98566389 0.01199167 360.00148056 -0.00349167 # color=yellow tag={WFPC2}
POLYGON 359.99971945 -0.00553611 359.98399167 0.01002778 359.99953889 0.02574166 360.01526945 0.01017778 359.99971945 -0.00553611 # color=yellow tag={WFPC2}
POLYGON 359.99818056 -0.00391111 360.01389167 0.01165833 360.02947778 -0.00406666 360.01376667 -0.01963889 359.99818056 -0.00391111 # color=yellow tag={WFPC2}
#WFC
POLYGON 359.97153610 0.00394449 360.02780819 0.00184727 360.02867769 -0.02606378 359.97321946 -0.02329159 359.97153610 0.00394449 # color=magenta tag={ACS/WFC}
POLYGON 359.97016108 0.03281108 360.02699980 0.03145827 360.02782208 0.00258060 359.97155555 0.00463893 359.97016108 0.03281108 # color=magenta tag={ACS/WFC}
#HRC
POLYGON 360.00400540 -0.00392492 359.99599432 -0.00308881 359.99597208 0.00397226 360.00404983 0.00315004 360.00400540 -0.00392492 # color=#00a8ff tag={ACS/HRC}
#SBC
POLYGON 360.00477485 -0.00375547 359.99528321 -0.00286381 359.99522208 0.00569725 360.00482483 0.00476670 360.00477485 -0.00375547 # color=green tag={ACS/SBC},
#UVIS
POLYGON 0.01545556 -0.01782778 -0.01446667 0.01608611 0.00152500 0.03198333 0.03108889 -0.00191111 0.01545556 -0.01782778 # color=purple tag={WFC3/UVIS}
POLYGON -0.00058333 -0.03417222 -0.03089722 -0.00026389 -0.01472778 0.01583889 0.01521944 -0.01804722 -0.00058333 -0.03417222 # color=purple tag={WFC3/UVIS}
#IR
POLYGON 360.00175833 -0.02767222 359.97505000 -0.00110278 359.99865556 0.02345556 360.02604444 -0.00377500 360.00175833 -0.02767222 # color=green tag={WFC3/IR}
#HST
POLYGON 0.04443055 0.07030828 0.10070267 0.06821097 0.10157212 0.04029993 0.04611388 0.04307220 0.04443055 0.07030828 # color=blue tag={HST}
POLYGON 0.04305555 0.09917487 0.09989434 0.09782198 0.10071656 0.06894430 0.04444999 0.07100272 0.04305555 0.09917487 # color=blue tag={HST}
POLYGON 0.06131664 0.12724694 0.05330554 0.12808307 0.05328332 0.13514413 0.06136109 0.13432190 0.06131664 0.12724694 # color=blue tag={HST}
POLYGON 0.06194720 0.12593028 0.05245554 0.12682196 0.05239443 0.13538303 0.06199720 0.13445245 0.06194720 0.12593028 # color=blue tag={HST}
CIRCLE 0.06462497 -0.06595826 0.00069444 # color=blue tag={HST}
CIRCLE 0.06462497 -0.06595826 0.00069444 # color=blue tag={HST}
POLYGON 0.12901798 0.11616805 0.13973823 0.10302369 0.14912465 0.08889596 0.15708764 0.07391970 0.16355120 0.05823786 0.16845363 0.04200014 0.17174815 0.02536152 0.17340331 0.00848082 0.17340331 -0.00848082 0.17174815 -0.02536152 0.16845363 -0.04200014 0.16355120 -0.05823786 0.15708764 -0.07391970 0.14912465 -0.08889596 0.13973823 -0.10302369 0.12901798 -0.11616805 0.17030352 -0.15334139 0.18445419 -0.13599087 0.19684420 -0.11734230 0.20735529 -0.09757369 0.21588714 -0.07687373 0.22235832 -0.05544000 0.22670706 -0.03347709 0.22889186 -0.01119465 0.22889186 0.01119465 0.22670706 0.03347709 0.22235832 0.05544000 0.21588714 0.07687373 0.20735529 0.09757369 0.19684420 0.11734230 0.18445419 0.13599087 0.17030352 0.15334139 0.12901798 0.11616805 # color=blue tag={HST}
POLYGON 0.11616835 -0.12901772 0.10302400 -0.13973800 0.08889626 -0.14912447 0.07391997 -0.15708751 0.05823810 -0.16355111 0.04200032 -0.16845359 0.02536164 -0.17174814 0.00848086 -0.17340331 -0.00848086 -0.17340331 -0.02536164 -0.17174814 -0.04200032 -0.16845359 -0.05823810 -0.16355111 -0.07391997 -0.15708751 -0.08889626 -0.14912447 -0.10302400 -0.13973800 -0.11616835 -0.12901772 -0.15334206 -0.17030291 -0.13599157 -0.18445367 -0.11734299 -0.19684379 -0.09757433 -0.20735499 -0.07687427 -0.21588695 -0.05544042 -0.22235822 -0.03347736 -0.22670702 -0.01119474 -0.22889185 0.01119474 -0.22889185 0.03347736 -0.22670702 0.05544042 -0.22235822 0.07687427 -0.21588695 0.09757433 -0.20735499 0.11734299 -0.19684379 0.13599157 -0.18445367 0.15334206 -0.17030291 0.11616835 -0.12901772 # color=blue tag={HST}
POLYGON -0.12901798 -0.11616805 -0.13973823 -0.10302369 -0.14912465 -0.08889596 -0.15708764 -0.07391970 -0.16355120 -0.05823786 -0.16845363 -0.04200014 -0.17174815 -0.02536152 -0.17340331 -0.00848082 -0.17340331 0.00848082 -0.17174815 0.02536152 -0.16845363 0.04200014 -0.16355120 0.05823786 -0.15708764 0.07391970 -0.14912465 0.08889596 -0.13973823 0.10302369 -0.12901798 0.11616805 -0.17030352 0.15334139 -0.18445419 0.13599087 -0.19684420 0.11734230 -0.20735529 0.09757369 -0.21588714 0.07687373 -0.22235832 0.05544000 -0.22670706 0.03347709 -0.22889186 0.01119465 -0.22889186 -0.01119465 -0.22670706 -0.03347709 -0.22235832 -0.05544000 -0.21588714 -0.07687373 -0.20735529 -0.09757369 -0.19684420 -0.11734230 -0.18445419 -0.13599087 -0.17030352 -0.15334139 -0.12901798 -0.11616805 # color=blue tag={HST}
POLYGON -0.07989995 0.08093320 -0.08204995 0.08310819 -0.08422772 0.08095541 -0.08207772 0.07878042 -0.07989995 0.08093320 # color=blue tag={HST}
POLYGON -0.08398605 0.08639984 -0.08778882 0.09014426 -0.09156381 0.08631094 -0.08776104 0.08256651 -0.08398605 0.08639984 # color=blue tag={HST}
POLYGON -0.05819165 0.06560549 -0.06835552 0.07573879 -0.07851384 0.06554713 -0.06834997 0.05541661 -0.05819165 0.06560549 # color=blue tag={HST}
CIRCLE -0.05935553 -0.06245550 0.01979722 # color=blue tag={HST}
CIRCLE -0.05935553 -0.06245550 0.01979722 # color=blue tag={HST}
CIRCLE -0.05935553 -0.06245550 0.01979722 # color=blue tag={HST}
POLYGON 0.01545556 -0.01782778 -0.01446667 0.01608611 0.00152500 0.03198333 0.03108889 -0.00191111 0.01545556 -0.01782778 # color=blue tag={HST}
POLYGON -0.00058333 -0.03417222 -0.03089722 -0.00026389 -0.01472778 0.01583889 0.01521944 -0.01804722 -0.00058333 -0.03417222 # color=blue tag={HST}
POLYGON 0.00193333 -0.02526111 -0.02477500 0.00130833 -0.00116944 0.02586667 0.02621944 -0.00136389 0.00193333 -0.02526111 # color=blue tag={HST}
POLYGON 0.00193333 -0.02526111 -0.02477500 0.00130833 -0.00116944 0.02586667 0.02621944 -0.00136389 0.00193333 -0.02526111 # color=blue tag={HST}
Loading