Issue #2132 - Fix drawing lat/long box for madis point data
Change-Id: Ie041c31726f6e51467b9d2730d662c431b42ac96 Former-commit-id:9d3c4ce704
[formerly7b3d79edc9
] [formerlyf685e73bd2
] [formerly9d3c4ce704
[formerly7b3d79edc9
] [formerlyf685e73bd2
] [formerly14bd577f6c
[formerlyf685e73bd2
[formerly 380b50d8a3d2a3f80e5a69dd1980e8e863985c2a]]]] Former-commit-id:14bd577f6c
Former-commit-id:c180323417
[formerlydefc6a3080
] [formerly f7a3f48b1fa32bf56ed18d0e266ac2ee25be2f81 [formerly65faaadc7c
]] Former-commit-id: 36915698d722a49fcbd05f616829abbe23289698 [formerlya8a4393c82
] Former-commit-id:0e36cab21f
This commit is contained in:
parent
7af1216ef7
commit
d1d92c033a
3 changed files with 105 additions and 71 deletions
|
@ -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.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -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;
|
||||
|
||||
|
|
|
@ -44,18 +44,19 @@ import com.vividsolutions.jts.geom.Coordinate;
|
|||
|
||||
/**
|
||||
* Resource for drawing a bounding box on the Spatial Subset Map Dialog.
|
||||
*
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
*
|
||||
* @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
|
||||
|
|
|
@ -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.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue