Skip to content

Commit 040c5ed

Browse files
committed
DM-10065: Fixes and improvements
- fixed rotate north not working in certain cases - fixed restore not unflipping and unrotating - fixed recentering problem when WCS match is on - fixed magnifier: now rotated and flipped - fixed round off error that made gaps in the image tiles of safari and firefox - fixed rotation issues with wcs match when already rotated - fixed rotation match checking false positives - png download now works - flip icon now is on and off - rotation angle/direction now consistent with ds9 and irsa standard - scrolling speed optimization using lodash throttle - added more documentation on a couple of functions - rename PlotPostionUtil to PlotTransformUtils - actions are now be ROTATE and FLIP - code clean up
1 parent 1596a70 commit 040c5ed

33 files changed

+649
-1011
lines changed
Loading
Loading

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,9 @@ public class ServerParams {
146146
public static final String GET_ALL_SAVED_REQUEST= "getAllSavedRequest";
147147
public static final String TITLE= "Title";
148148
public static final String JSON_DEEP= "jsonDeep";
149+
public static final String CLIENT_IS_NORTH= "clientIsNorth";
150+
public static final String CLIENT_ROT_ANGLE= "clientRotAngle";
151+
public static final String CLIENT_FlIP_Y= "clientFlipY";
149152
public static final String ACTION= "action";
150153

151154
public static final String VIS_PUSH_ALIVE_CHECK= "pushAliveCheck";

src/firefly/java/edu/caltech/ipac/firefly/server/ServerCommandAccess.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,6 @@ private static void initCommand() {
5151
_cmdMap.put(ServerParams.CHANGE_COLOR, new VisServerCommands.ChangeColor());
5252
_cmdMap.put(ServerParams.DELETE, new VisServerCommands.DeletePlot());
5353
_cmdMap.put(ServerParams.CROP, new VisServerCommands.Crop());
54-
_cmdMap.put(ServerParams.ROTATE_NORTH, new VisServerCommands.RotateNorth());
55-
_cmdMap.put(ServerParams.ROTATE_ANGLE, new VisServerCommands.RotateAngle());
56-
_cmdMap.put(ServerParams.FLIP_Y, new VisServerCommands.FlipImageOnY());
5754
_cmdMap.put(ServerParams.HISTOGRAM, new VisServerCommands.ColorHistogram());
5855
_cmdMap.put(ServerParams.STAT, new VisServerCommands.AreaStat());
5956
_cmdMap.put(ServerParams.HEADER, new VisServerCommands.Header());

src/firefly/java/edu/caltech/ipac/firefly/server/rpc/PlotServiceImpl.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,15 +72,15 @@ public WebPlotResult crop(PlotState stateAry[],
7272
}
7373

7474
public WebPlotResult rotateNorth(PlotState state[], boolean north, float newZoomLevel) {
75-
return VisServerOps.rotateNorth(state,north,newZoomLevel);
75+
return null;
7676
}
7777

7878
public WebPlotResult rotateToAngle(PlotState state[], boolean rotate, double angle, float newZoomLevel) {
79-
return VisServerOps.rotateToAngle(state,rotate,angle, newZoomLevel);
79+
return null;
8080
}
8181

8282
public WebPlotResult flipImageOnY(PlotState state[]) {
83-
return VisServerOps.flipImageOnY(state);
83+
return null;
8484
}
8585

8686
public WebPlotResult getAreaStatistics(PlotState state,

src/firefly/java/edu/caltech/ipac/firefly/server/rpc/VisServerCommands.java

Lines changed: 4 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -378,54 +378,15 @@ public String doCommand(Map<String, String[]> paramMap) throws IllegalArgumentEx
378378
SrvParam sp= new SrvParam(paramMap);
379379
PlotState state= sp.getState();
380380
String data = sp.getRequired(ServerParams.REGION_DATA);
381-
WebPlotResult result = VisServerOps.getImagePngWithRegion(state, data);
381+
boolean isNorth = sp.getRequiredBoolean(ServerParams.CLIENT_IS_NORTH);
382+
int rotAngle = (int)sp.getRequiredFloat(ServerParams.CLIENT_ROT_ANGLE);
383+
boolean flipY = sp.getRequiredBoolean(ServerParams.CLIENT_FlIP_Y);
384+
WebPlotResult result = VisServerOps.getImagePngWithRegion(state, data,isNorth,rotAngle,flipY);
382385
return WebPlotResultSerializer.createJson(result, sp.isJsonDeep());
383386
}
384387
}
385388

386389

387-
public static class RotateNorth extends ServCommand {
388-
389-
public String doCommand(Map<String, String[]> paramMap) throws IllegalArgumentException {
390-
391-
SrvParam sp= new SrvParam(paramMap);
392-
// PlotState state= sp.getState();
393-
PlotState stateAry[]= sp.getStateAry();
394-
boolean north= sp.getRequiredBoolean(ServerParams.NORTH);
395-
float zoomLevel= sp.getOptionalFloat(ServerParams.ZOOM, -1);
396-
WebPlotResult result = VisServerOps.rotateNorth(stateAry, north,zoomLevel);
397-
return WebPlotResultSerializer.createJson(result, sp.isJsonDeep());
398-
}
399-
}
400-
401-
public static class RotateAngle extends ServCommand {
402-
403-
public String doCommand(Map<String, String[]> paramMap) throws IllegalArgumentException {
404-
SrvParam sp= new SrvParam(paramMap);
405-
// PlotState state= sp.getState();
406-
PlotState stateAry[]= sp.getStateAry();
407-
boolean rotate= sp.getRequiredBoolean(ServerParams.ROTATE);
408-
double angle= rotate ? sp.getRequiredDouble(ServerParams.ANGLE) : 0.0;
409-
float zoomLevel= sp.getOptionalFloat(ServerParams.ZOOM, -1);
410-
WebPlotResult result = VisServerOps.rotateToAngle(stateAry, rotate, angle,zoomLevel);
411-
return WebPlotResultSerializer.createJson(result, sp.isJsonDeep());
412-
}
413-
}
414-
415-
416-
public static class FlipImageOnY extends ServCommand {
417-
418-
public String doCommand(Map<String, String[]> paramMap) throws IllegalArgumentException {
419-
SrvParam sp= new SrvParam(paramMap);
420-
PlotState stateAry[]= sp.getStateAry();
421-
// PlotState state= sp.getState();
422-
WebPlotResult result = VisServerOps.flipImageOnY(stateAry);
423-
return WebPlotResultSerializer.createJson(result, sp.isJsonDeep());
424-
}
425-
}
426-
427-
428-
429390
public static class ColorHistogram extends ServCommand {
430391

431392
public String doCommand(Map<String, String[]> paramMap) throws IllegalArgumentException {

src/firefly/java/edu/caltech/ipac/firefly/server/visualize/PlotServUtils.java

Lines changed: 72 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
import edu.caltech.ipac.firefly.server.events.FluxAction;
1010
import edu.caltech.ipac.firefly.server.events.ServerEventManager;
1111
import edu.caltech.ipac.firefly.server.util.Logger;
12-
import edu.caltech.ipac.firefly.util.WebAssert;
1312
import edu.caltech.ipac.firefly.visualize.Band;
1413
import edu.caltech.ipac.firefly.visualize.PlotImages;
1514
import edu.caltech.ipac.firefly.visualize.PlotState;
@@ -27,9 +26,7 @@
2726
import edu.caltech.ipac.visualize.draw.VectorObject;
2827
import edu.caltech.ipac.visualize.plot.ActiveFitsReadGroup;
2928
import edu.caltech.ipac.visualize.plot.Circle;
30-
import edu.caltech.ipac.visualize.plot.CoordinateSys;
3129
import edu.caltech.ipac.visualize.plot.FitsRead;
32-
import edu.caltech.ipac.visualize.plot.GeomException;
3330
import edu.caltech.ipac.visualize.plot.ImageMask;
3431
import edu.caltech.ipac.visualize.plot.ImagePlot;
3532
import edu.caltech.ipac.visualize.plot.PlotGroup;
@@ -188,78 +185,78 @@ static PlotImages defineTiles(File imagefileDir,
188185

189186

190187

191-
public static File createRotatedFile(FitsRead originalFR,
192-
String originalFileStr,
193-
String workingFileStr,
194-
PlotState.RotateType rotateType,
195-
double angle,
196-
CoordinateSys rotNorthType) throws FitsException, IOException, GeomException {
197-
198-
String fStr = originalFileStr != null ? originalFileStr : workingFileStr;
199-
File originalFile = ServerContext.convertToFile(fStr);
200-
boolean rotateNorth = (rotateType == PlotState.RotateType.NORTH);
201-
File f = rotateNorth ? createRotateNorthFile(originalFile, originalFR, rotNorthType) :
202-
createRotatedAngleFile(originalFile, originalFR, angle);
203-
return f;
204-
}
205-
206-
public static File createRotateNorthFile(File originalFile,
207-
FitsRead originalFR,
208-
CoordinateSys rotateNorthType) throws FitsException,
209-
IOException,
210-
GeomException {
211-
FitsRead northFR= null;
212-
if (rotateNorthType.equals(CoordinateSys.GALACTIC)) {
213-
northFR= FitsRead.createFitsReadNorthUpGalactic(originalFR);
214-
}
215-
else if (rotateNorthType.equals(CoordinateSys.EQ_J2000)){
216-
northFR= FitsRead.createFitsReadNorthUp(originalFR);
217-
}
218-
else {
219-
WebAssert.argTst(false, "only supports galactic and j2000");
220-
221-
}
222-
String fname= originalFile.getName();
223-
File f= File.createTempFile(FileUtil.getBase(fname) + "-rot-north",
224-
"." + FileUtil.FITS,
225-
ServerContext.getVisSessionDir());
226-
BufferedOutputStream stream = new BufferedOutputStream(new FileOutputStream(f), (int) FileUtil.MEG);
227-
if (northFR!=null) northFR.writeSimpleFitsFile(stream);
228-
FileUtil.silentClose(stream);
229-
return f;
230-
}
231-
232-
233-
public static File createRotatedAngleFile(File originalFile, FitsRead originalFR, double angle) throws FitsException,
234-
IOException,
235-
GeomException {
236-
FitsRead rotateFR= FitsRead.createFitsReadRotated(originalFR, angle, false);
237-
String fname= originalFile.getName();
238-
String angleStr= String.format("%2f", angle);
239-
File f= File.createTempFile(FileUtil.getBase(fname)+"-rot-"+angleStr,
240-
"."+FileUtil.FITS,
241-
ServerContext.getVisSessionDir());
242-
BufferedOutputStream stream = new BufferedOutputStream(new FileOutputStream(f), (int) FileUtil.MEG);
243-
if (rotateFR!=null) rotateFR.writeSimpleFitsFile(stream);
244-
FileUtil.silentClose(stream);
245-
return f;
246-
}
247-
248-
public static File createFlipYFile(File originalFile, FitsRead originalFR) throws FitsException,
249-
IOException,
250-
GeomException {
251-
FitsRead rotateFR= FitsRead.createFitsReadFlipLR(originalFR);
252-
String fname= originalFile.getName();
253-
String base= FileUtil.getBase(fname);
254-
int idx= base.indexOf("-flip");
255-
if (idx>-1) base= base.substring(0,idx);
256-
File f= File.createTempFile(base+"-flip", "."+FileUtil.FITS,
257-
ServerContext.getVisSessionDir());
258-
BufferedOutputStream stream = new BufferedOutputStream(new FileOutputStream(f), (int) FileUtil.MEG);
259-
rotateFR.writeSimpleFitsFile(stream);
260-
FileUtil.silentClose(stream);
261-
return f;
262-
}
188+
// public static File createRotatedFile(FitsRead originalFR,
189+
// String originalFileStr,
190+
// String workingFileStr,
191+
// PlotState.RotateType rotateType,
192+
// double angle,
193+
// CoordinateSys rotNorthType) throws FitsException, IOException, GeomException {
194+
//
195+
// String fStr = originalFileStr != null ? originalFileStr : workingFileStr;
196+
// File originalFile = ServerContext.convertToFile(fStr);
197+
// boolean rotateNorth = (rotateType == PlotState.RotateType.NORTH);
198+
// File f = rotateNorth ? createRotateNorthFile(originalFile, originalFR, rotNorthType) :
199+
// createRotatedAngleFile(originalFile, originalFR, angle);
200+
// return f;
201+
// }
202+
//
203+
// public static File createRotateNorthFile(File originalFile,
204+
// FitsRead originalFR,
205+
// CoordinateSys rotateNorthType) throws FitsException,
206+
// IOException,
207+
// GeomException {
208+
// FitsRead northFR= null;
209+
// if (rotateNorthType.equals(CoordinateSys.GALACTIC)) {
210+
// northFR= FitsRead.createFitsReadNorthUpGalactic(originalFR);
211+
// }
212+
// else if (rotateNorthType.equals(CoordinateSys.EQ_J2000)){
213+
// northFR= FitsRead.createFitsReadNorthUp(originalFR);
214+
// }
215+
// else {
216+
// WebAssert.argTst(false, "only supports galactic and j2000");
217+
//
218+
// }
219+
// String fname= originalFile.getName();
220+
// File f= File.createTempFile(FileUtil.getBase(fname) + "-rot-north",
221+
// "." + FileUtil.FITS,
222+
// ServerContext.getVisSessionDir());
223+
// BufferedOutputStream stream = new BufferedOutputStream(new FileOutputStream(f), (int) FileUtil.MEG);
224+
// if (northFR!=null) northFR.writeSimpleFitsFile(stream);
225+
// FileUtil.silentClose(stream);
226+
// return f;
227+
// }
228+
//
229+
//
230+
// public static File createRotatedAngleFile(File originalFile, FitsRead originalFR, double angle) throws FitsException,
231+
// IOException,
232+
// GeomException {
233+
// FitsRead rotateFR= FitsRead.createFitsReadRotated(originalFR, angle, true);
234+
// String fname= originalFile.getName();
235+
// String angleStr= String.format("%2f", angle);
236+
// File f= File.createTempFile(FileUtil.getBase(fname)+"-rot-"+angleStr,
237+
// "."+FileUtil.FITS,
238+
// ServerContext.getVisSessionDir());
239+
// BufferedOutputStream stream = new BufferedOutputStream(new FileOutputStream(f), (int) FileUtil.MEG);
240+
// if (rotateFR!=null) rotateFR.writeSimpleFitsFile(stream);
241+
// FileUtil.silentClose(stream);
242+
// return f;
243+
// }
244+
//
245+
// public static File createFlipYFile(File originalFile, FitsRead originalFR) throws FitsException,
246+
// IOException,
247+
// GeomException {
248+
// FitsRead rotateFR= FitsRead.createFitsReadFlipLR(originalFR);
249+
// String fname= originalFile.getName();
250+
// String base= FileUtil.getBase(fname);
251+
// int idx= base.indexOf("-flip");
252+
// if (idx>-1) base= base.substring(0,idx);
253+
// File f= File.createTempFile(base+"-flip", "."+FileUtil.FITS,
254+
// ServerContext.getVisSessionDir());
255+
// BufferedOutputStream stream = new BufferedOutputStream(new FileOutputStream(f), (int) FileUtil.MEG);
256+
// rotateFR.writeSimpleFitsFile(stream);
257+
// FileUtil.silentClose(stream);
258+
// return f;
259+
// }
263260

264261

265262
public static long getTileModTime(String fname) {

0 commit comments

Comments
 (0)