diff --git a/cave/com.raytheon.uf.viz.datadelivery/src/com/raytheon/uf/viz/datadelivery/common/ui/AreaComp.java b/cave/com.raytheon.uf.viz.datadelivery/src/com/raytheon/uf/viz/datadelivery/common/ui/AreaComp.java index 051bf12ab9..26932e75c8 100644 --- a/cave/com.raytheon.uf.viz.datadelivery/src/com/raytheon/uf/viz/datadelivery/common/ui/AreaComp.java +++ b/cave/com.raytheon.uf.viz.datadelivery/src/com/raytheon/uf/viz/datadelivery/common/ui/AreaComp.java @@ -91,6 +91,7 @@ import com.vividsolutions.jts.geom.Coordinate; * Dec 11, 2012 1264 mpduff Fix validaiton of lat/lon text fields. * Mar 21, 2013 1638 mschenke Changed map scales not tied to d2d * Jun 14, 2013 2064 mpduff Reset controls on load. + * Jun 21, 2013 2132 mpduff Swap target and source envelopes. * * * @@ -733,8 +734,8 @@ public class AreaComp extends Composite implements ISubset { // the dialog should always use an envelope in the same crs as the // data. try { - dlgEnvelope = MapUtil.reprojectAndIntersect(dlgEnvelope, - fullEnvelope); + dlgEnvelope = MapUtil.reprojectAndIntersect(fullEnvelope, + dlgEnvelope); } catch (TransformException e) { statusHandler.handle(Priority.PROBLEM, e.getLocalizedMessage(), e); @@ -889,9 +890,9 @@ public class AreaComp extends Composite implements ISubset { Coordinate ul = EnvelopeUtils.getUpperLeftLatLon(envelope); Coordinate lr = EnvelopeUtils.getLowerRightLatLon(envelope); - upperLeftLonTxt.setText(formatter.format(lr.x)); + upperLeftLonTxt.setText(formatter.format(ul.x)); upperLeftLatTxt.setText(formatter.format(ul.y)); - lowerRightLonTxt.setText(formatter.format(ul.x)); + lowerRightLonTxt.setText(formatter.format(lr.x)); lowerRightLatTxt.setText(formatter.format(lr.y)); this.subEnvelope = envelope; diff --git a/cave/com.raytheon.uf.viz.datadelivery/src/com/raytheon/uf/viz/datadelivery/rsc/DrawBoxResource.java b/cave/com.raytheon.uf.viz.datadelivery/src/com/raytheon/uf/viz/datadelivery/rsc/DrawBoxResource.java index ccb75db299..47d5a21f5c 100644 --- a/cave/com.raytheon.uf.viz.datadelivery/src/com/raytheon/uf/viz/datadelivery/rsc/DrawBoxResource.java +++ b/cave/com.raytheon.uf.viz.datadelivery/src/com/raytheon/uf/viz/datadelivery/rsc/DrawBoxResource.java @@ -44,18 +44,19 @@ import com.vividsolutions.jts.geom.Coordinate; /** * Resource for drawing a bounding box on the Spatial Subset Map Dialog. - * + * *
- * + * * SOFTWARE HISTORY - * + * * Date Ticket# Engineer Description * ------------ ---------- ----------- -------------------------- * Jan 19, 2012 mpduff Initial creation. * Oct 31, 2012 1278 mpduff Added functionality for other datasets in NOMADS. - * + * Jun 21, 2013 2132 mpduff Convert coordinates to East/West before drawing. + * *- * + * * @author mpduff * @version 1.0 */ @@ -130,7 +131,7 @@ public class DrawBoxResource extends /* * (non-Javadoc) - * + * * @see com.raytheon.uf.viz.core.rsc.AbstractVizResource#disposeInternal() */ @Override @@ -140,7 +141,7 @@ public class DrawBoxResource extends /* * (non-Javadoc) - * + * * @see * com.raytheon.uf.viz.core.rsc.AbstractVizResource#paintInternal(com.raytheon * .uf.viz.core.IGraphicsTarget, @@ -151,6 +152,8 @@ public class DrawBoxResource extends PaintProperties paintProps) throws VizException { this.target = target; if ((c1 != null) && (c2 != null)) { + c1.x = spatialUtils.convertToEastWest(c1.x); + c2.x = spatialUtils.convertToEastWest(c2.x); double[] ul = descriptor.worldToPixel(new double[] { c1.x, c1.y }); double[] lr = descriptor.worldToPixel(new double[] { c2.x, c2.y }); PixelExtent pe = new PixelExtent(ul[0], lr[0], ul[1], lr[1]); @@ -160,7 +163,7 @@ public class DrawBoxResource extends /* * (non-Javadoc) - * + * * @see * com.raytheon.uf.viz.core.rsc.AbstractVizResource#initInternal(com.raytheon * .uf.viz.core.IGraphicsTarget) @@ -182,7 +185,7 @@ public class DrawBoxResource extends /* * (non-Javadoc) - * + * * @see com.raytheon.uf.viz.core.rsc.AbstractVizResource#getName() */ @Override @@ -204,7 +207,7 @@ public class DrawBoxResource extends /* * (non-Javadoc) - * + * * @see com.raytheon.viz.ui.input.InputAdapter#handleMouseDown(int, int, * int) */ @@ -215,9 +218,12 @@ public class DrawBoxResource extends x1 = x; y1 = y; c1 = getResourceContainer().translateClick(x, y); - c1.x = spatialUtils.convertToEasting(c1.x); - if (spatialUtils.getLongitudinalShift() > 0 && x >= x360) { - c1.x += 360; + if (c1 != null) { + c1.x = spatialUtils.convertToEasting(c1.x); + if (spatialUtils.getLongitudinalShift() > 0 + && x >= x360) { + c1.x += 360; + } } } } else if (mouseButton == 2) { @@ -228,7 +234,7 @@ public class DrawBoxResource extends /* * (non-Javadoc) - * + * * @see com.raytheon.viz.ui.input.InputAdapter#handleMouseDownMove(int, * int, int) */ @@ -238,23 +244,25 @@ public class DrawBoxResource extends drawingBox = true; if (resizingBox) { Coordinate c = getResourceContainer().translateClick(x, y); - if (boxSide == 0) { - c1.y = c.y; - } else if (boxSide == 1) { - c1.x = c.x; - c1.x = spatialUtils.convertToEasting(c1.x); - if (spatialUtils.getLongitudinalShift() > 0 - && x >= x360) { - c1.x += 360; - } - } else if (boxSide == 2) { - c2.y = c.y; - } else if (boxSide == 3) { - c2.x = c.x; - c2.x = spatialUtils.convertToEasting(c2.x); - if (spatialUtils.getLongitudinalShift() > 0 - && x >= x360) { - c2.x += 360; + if (c != null) { + if (boxSide == 0) { + c1.y = c.y; + } else if (boxSide == 1) { + c1.x = c.x; + c1.x = spatialUtils.convertToEasting(c1.x); + if (spatialUtils.getLongitudinalShift() > 0 + && x >= x360) { + c1.x += 360; + } + } else if (boxSide == 2) { + c2.y = c.y; + } else if (boxSide == 3) { + c2.x = c.x; + c2.x = spatialUtils.convertToEasting(c2.x); + if (spatialUtils.getLongitudinalShift() > 0 + && x >= x360) { + c2.x += 360; + } } } } else { @@ -267,6 +275,7 @@ public class DrawBoxResource extends } } } + fireBoxChangedEvent(); createRegions(); target.setNeedsRefresh(true); @@ -279,7 +288,7 @@ public class DrawBoxResource extends /* * (non-Javadoc) - * + * * @see com.raytheon.viz.ui.input.InputAdapter#handleMouseMove(int, int) */ @Override @@ -309,7 +318,7 @@ public class DrawBoxResource extends /* * (non-Javadoc) - * + * * @see com.raytheon.viz.ui.input.InputAdapter#handleMouseUp(int, int, * int) */ @@ -318,38 +327,42 @@ public class DrawBoxResource extends if (mouseButton == 1) { if (resizingBox) { Coordinate c = getResourceContainer().translateClick(x, y); - c.x = spatialUtils.convertToEasting(c.x); - if (spatialUtils.getLongitudinalShift() > 0 && x >= x360) { - c.x += 360; + if (c != null) { + c.x = spatialUtils.convertToEasting(c.x); + if (spatialUtils.getLongitudinalShift() > 0 + && x >= x360) { + c.x += 360; + } + if (boxSide == 0) { + c1.y = c.y; + y1 = y; + } else if (boxSide == 1) { + c1.x = c.x; + x1 = x; + } else if (boxSide == 2) { + c2.y = c.y; + y2 = y; + } else if (boxSide == 3) { + c2.x = c.x; + x2 = x; + } + createRegions(); + fireBoxChangedEvent(); + target.setNeedsRefresh(true); + drawingBox = false; } - if (boxSide == 0) { - c1.y = c.y; - y1 = y; - } else if (boxSide == 1) { - c1.x = c.x; - x1 = x; - } else if (boxSide == 2) { - c2.y = c.y; - y2 = y; - } else if (boxSide == 3) { - c2.x = c.x; - x2 = x; - } - - createRegions(); - fireBoxChangedEvent(); - target.setNeedsRefresh(true); - drawingBox = false; } else { if (drawingBox) { x2 = x; y2 = y; target.setNeedsRefresh(true); c2 = getResourceContainer().translateClick(x, y); - c2.x = spatialUtils.convertToEasting(c2.x); - if (spatialUtils.getLongitudinalShift() > 0 - && x >= x360) { - c2.x += 360; + if (c2 != null) { + c2.x = spatialUtils.convertToEasting(c2.x); + if (spatialUtils.getLongitudinalShift() > 0 + && x >= x360) { + c2.x += 360; + } } createRegions(); @@ -369,7 +382,7 @@ public class DrawBoxResource extends /** * Add a box listener. - * + * * @param listener * the listener to add */ @@ -379,7 +392,7 @@ public class DrawBoxResource extends /** * Remove the box listener. - * + * * @param listener * the listener to remove */ @@ -470,7 +483,7 @@ public class DrawBoxResource extends /** * Set the parent shell. - * + * * @param shell * the parent shell */ @@ -480,7 +493,7 @@ public class DrawBoxResource extends /** * Set the coordinates. - * + * * @param ul * upper left coordinates * @param lr diff --git a/edexOsgi/com.raytheon.uf.common.datadelivery.registry/src/com/raytheon/uf/common/datadelivery/registry/EnvelopeUtils.java b/edexOsgi/com.raytheon.uf.common.datadelivery.registry/src/com/raytheon/uf/common/datadelivery/registry/EnvelopeUtils.java index 80c8aa542d..6de17bfdd0 100644 --- a/edexOsgi/com.raytheon.uf.common.datadelivery.registry/src/com/raytheon/uf/common/datadelivery/registry/EnvelopeUtils.java +++ b/edexOsgi/com.raytheon.uf.common.datadelivery.registry/src/com/raytheon/uf/common/datadelivery/registry/EnvelopeUtils.java @@ -45,7 +45,8 @@ import com.vividsolutions.jts.geom.Coordinate; * * Date Ticket# Engineer Description * ------------ ---------- ----------- -------------------------- - * Dec 5, 2012 bsteffen Initial creation + * Dec 5, 2012 bsteffen Initial creation. + * Jun 21, 2013 2132 mpduf createSubEnvelopeFromLatLon now uses East/West direction. * * * @@ -319,10 +320,14 @@ public class EnvelopeUtils { * @return */ public static ReferencedEnvelope createSubenvelopeFromLatLon( - Envelope envelope, Coordinate latLon1, - Coordinate latLon2) { - ReferencedEnvelope result = createEnvelopeFromLatLon(envelope.getCoordinateReferenceSystem(), latLon1, latLon2); - return new ReferencedEnvelope(result.intersection(reference(envelope)), envelope.getCoordinateReferenceSystem()); + Envelope envelope, Coordinate latLon1, Coordinate latLon2) { + latLon1 = EnvelopeUtils.convertToEastWest(latLon1); + latLon2 = EnvelopeUtils.convertToEastWest(latLon2); + + ReferencedEnvelope result = createEnvelopeFromLatLon( + envelope.getCoordinateReferenceSystem(), latLon1, latLon2); + return new ReferencedEnvelope(result.intersection(reference(envelope)), + envelope.getCoordinateReferenceSystem()); } /** @@ -353,4 +358,19 @@ public class EnvelopeUtils { return new ReferencedEnvelope(envelope); } } + + /** + * Convert coordinate value to East/West. + * + * @param coord + * Coordinate to convert + * @return converted coordinate + */ + public static Coordinate convertToEastWest(Coordinate coord) { + if (coord.x > 180) { + coord.x = coord.x - 360; + } + + return coord; + } }