From 6d463f0c744d89a683dfedbc091e982e9dbb9d4d Mon Sep 17 00:00:00 2001 From: Jonathan Sanchez Date: Tue, 12 Feb 2013 17:20:55 -0600 Subject: [PATCH] Issue #1600 Correctly set the StormTrackData motion direction for a CAN and EXP. Former-commit-id: e82da0ee983f1a9889e25b088e2eadebb8c08fff --- .../AbstractStormTrackResource.java | 4 ++-- .../config/AbstractDbSourceDataAdaptor.java | 7 +++++-- .../viz/warngen/gis/ClosestPoint.java | 21 +------------------ .../src/com/raytheon/viz/warngen/gis/Wx.java | 7 +++++-- .../viz/warngen/gui/WarngenLayer.java | 18 +++++++++------- .../viz/warngen/template/TemplateRunner.java | 15 +++++++------ 6 files changed, 32 insertions(+), 40 deletions(-) diff --git a/cave/com.raytheon.viz.awipstools/src/com/raytheon/viz/awipstools/common/stormtrack/AbstractStormTrackResource.java b/cave/com.raytheon.viz.awipstools/src/com/raytheon/viz/awipstools/common/stormtrack/AbstractStormTrackResource.java index cee7e9acbc..361c626a22 100644 --- a/cave/com.raytheon.viz.awipstools/src/com/raytheon/viz/awipstools/common/stormtrack/AbstractStormTrackResource.java +++ b/cave/com.raytheon.viz.awipstools/src/com/raytheon/viz/awipstools/common/stormtrack/AbstractStormTrackResource.java @@ -64,7 +64,7 @@ import com.raytheon.viz.ui.input.EditableManager; * retrieve the requested line style so * that it can be stored in the * StormTrackState. - * + * 02-12-2013 1600 jsanchez Changed the visibility of the method adjustAngle * * * @author mschenke @@ -269,7 +269,7 @@ public abstract class AbstractStormTrackResource extends * @param angle * @return */ - protected double adjustAngle(double angle) { + public static double adjustAngle(double angle) { double newVal = angle % 360; if (newVal > 180) { newVal -= 360; diff --git a/cave/com.raytheon.viz.warngen/src/com/raytheon/viz/warngen/config/AbstractDbSourceDataAdaptor.java b/cave/com.raytheon.viz.warngen/src/com/raytheon/viz/warngen/config/AbstractDbSourceDataAdaptor.java index a49d0425ed..956c135f18 100644 --- a/cave/com.raytheon.viz.warngen/src/com/raytheon/viz/warngen/config/AbstractDbSourceDataAdaptor.java +++ b/cave/com.raytheon.viz.warngen/src/com/raytheon/viz/warngen/config/AbstractDbSourceDataAdaptor.java @@ -27,6 +27,7 @@ import com.raytheon.uf.common.geospatial.SpatialQueryFactory; import com.raytheon.uf.common.geospatial.SpatialQueryResult; import com.raytheon.uf.viz.core.exception.VizException; import com.raytheon.uf.viz.core.maps.rsc.DbMapQueryFactory; +import com.raytheon.viz.awipstools.common.stormtrack.AbstractStormTrackResource; import com.raytheon.viz.core.map.GeoUtil; import com.raytheon.viz.warngen.gis.ClosestPoint; import com.raytheon.viz.warngen.gis.ClosestPointComparator; @@ -47,6 +48,7 @@ import com.vividsolutions.jts.geom.Point; * pre-history * Sep 25, 2012 #15425 Qinglu Lin Added getGid(). * Oct 17, 2012 jsanchez Added pathcast algorithm. + * Feb 12, 2013 1600 jsanchez Used adjustAngle method from AbstractStormTrackResource. * * * @@ -336,9 +338,10 @@ abstract public class AbstractDbSourceDataAdaptor { gc.setStartingGeographicPoint(cp.getPoint().x, cp.getPoint().y); gc.setDestinationGeographicPoint(closestCoord.x, closestCoord.y); cp.setAzimuth(gc.getAzimuth()); - cp.setOppositeAzimuth(ClosestPoint.adjustAngle(cp.getAzimuth() + 180)); + cp.setOppositeAzimuth(AbstractStormTrackResource.adjustAngle(cp + .getAzimuth() + 180)); cp.setRoundedAzimuth(GeoUtil.roundAzimuth(cp.getAzimuth())); - cp.setOppositeRoundedAzimuth(ClosestPoint.adjustAngle(cp + cp.setOppositeRoundedAzimuth(AbstractStormTrackResource.adjustAngle(cp .getRoundedAzimuth() + 180)); cp.setArea(area); cp.setParentArea(parentArea); diff --git a/cave/com.raytheon.viz.warngen/src/com/raytheon/viz/warngen/gis/ClosestPoint.java b/cave/com.raytheon.viz.warngen/src/com/raytheon/viz/warngen/gis/ClosestPoint.java index e1fd5398ee..e3fcb8ab00 100644 --- a/cave/com.raytheon.viz.warngen/src/com/raytheon/viz/warngen/gis/ClosestPoint.java +++ b/cave/com.raytheon.viz.warngen/src/com/raytheon/viz/warngen/gis/ClosestPoint.java @@ -39,6 +39,7 @@ import com.vividsolutions.jts.geom.Coordinate; * a copy constructor. * Sep 25, 2012 #15425 Qinglu Lin Updated two ClosestPoint() and added getGid(). * Oct 17, 2012 jsanchez Added setter methods. + * Feb 12, 2013 1600 jsanchez Removed adjustAngle method. * * * @@ -247,26 +248,6 @@ public class ClosestPoint implements Comparable { this.gid = gid; } - /** - * Adjusts the angle from -360/360 to be between -180/180 - * - * @param angle - * @return - */ - public static double adjustAngle(double angle) { - double newVal = angle % 360; - if (newVal > 180) { - newVal -= 360; - } else if (newVal < -180) { - newVal += 360; - } - - if (newVal < 0) { - newVal += 360; - } - return newVal; - } - /* * (non-Javadoc) * diff --git a/cave/com.raytheon.viz.warngen/src/com/raytheon/viz/warngen/gis/Wx.java b/cave/com.raytheon.viz.warngen/src/com/raytheon/viz/warngen/gis/Wx.java index dfb2717431..02d30f0517 100644 --- a/cave/com.raytheon.viz.warngen/src/com/raytheon/viz/warngen/gis/Wx.java +++ b/cave/com.raytheon.viz.warngen/src/com/raytheon/viz/warngen/gis/Wx.java @@ -66,6 +66,7 @@ import com.raytheon.uf.common.status.IUFStatusHandler; import com.raytheon.uf.common.status.UFStatus; import com.raytheon.uf.common.status.UFStatus.Priority; import com.raytheon.uf.viz.core.exception.VizException; +import com.raytheon.viz.awipstools.common.stormtrack.AbstractStormTrackResource; import com.raytheon.viz.awipstools.common.stormtrack.StormTrackDisplay; import com.raytheon.viz.awipstools.common.stormtrack.StormTrackState; import com.raytheon.viz.core.map.GeoUtil; @@ -102,6 +103,7 @@ import com.vividsolutions.jts.geom.Point; * which are at different locations in pathcast. * Oct 17, 2012 jsanchez Moved the path cast data collecting to a separate class. * Jan 31, 2013 1557 jsanchez Used allowDuplicates flag to collect points with duplicate names. + * Feb 12, 2013 1600 jsanchez Used adjustAngle method from AbstractStormTrackResource. * * * @@ -845,9 +847,10 @@ public class Wx { .getCoordinate()); gc.setDestinationGeographicPoint(cen.x, cen.y); cp2.azimuth = gc.getAzimuth(); - cp2.oppositeAzimuth = ClosestPoint.adjustAngle(cp2.azimuth + 180); + cp2.oppositeAzimuth = AbstractStormTrackResource + .adjustAngle(cp2.azimuth + 180); cp2.roundedAzimuth = GeoUtil.roundAzimuth(cp2.azimuth); - cp2.oppositeRoundedAzimuth = ClosestPoint + cp2.oppositeRoundedAzimuth = AbstractStormTrackResource .adjustAngle(cp2.roundedAzimuth + 180); return cp2; diff --git a/cave/com.raytheon.viz.warngen/src/com/raytheon/viz/warngen/gui/WarngenLayer.java b/cave/com.raytheon.viz.warngen/src/com/raytheon/viz/warngen/gui/WarngenLayer.java index 9364ac4969..6d23b153ab 100644 --- a/cave/com.raytheon.viz.warngen/src/com/raytheon/viz/warngen/gui/WarngenLayer.java +++ b/cave/com.raytheon.viz.warngen/src/com/raytheon/viz/warngen/gui/WarngenLayer.java @@ -189,11 +189,11 @@ public class WarngenLayer extends AbstractStormTrackResource { private class CustomMaps extends Job { - private Set customMaps = new HashSet(); + private final Set customMaps = new HashSet(); private Set mapsToLoad; - private MapManager manager; + private final MapManager manager; public CustomMaps() { super("Loading WarnGen Maps"); @@ -243,7 +243,7 @@ public class WarngenLayer extends AbstractStormTrackResource { private class AreaHatcher extends Job { - private PolygonUtil polygonUtil; + private final PolygonUtil polygonUtil; private Polygon hatchedArea; @@ -365,7 +365,7 @@ public class WarngenLayer extends AbstractStormTrackResource { private boolean boxEditable = true; - private CustomMaps customMaps; + private final CustomMaps customMaps; private AreaHatcher areaHatcher; @@ -387,7 +387,7 @@ public class WarngenLayer extends AbstractStormTrackResource { private WarningAction warningAction = WarningAction.NEW; - private Set removedGids = new HashSet(); + private final Set removedGids = new HashSet(); static { for (int i = 0; i < 128; i++) { @@ -1369,6 +1369,7 @@ public class WarngenLayer extends AbstractStormTrackResource { state.setWarningArea(null); state.geometryChanged = true; dialog.getDisplay().asyncExec(new Runnable() { + @Override public void run() { dialog.setInstructions(); } @@ -1392,8 +1393,7 @@ public class WarngenLayer extends AbstractStormTrackResource { // snap back to last valid user selected area state.setWarningPolygon((Polygon) state .getMarkedWarningPolygon().clone()); - newHatchedArea = latLonToLocal((Geometry) state - .getMarkedWarningArea()); + newHatchedArea = latLonToLocal(state.getMarkedWarningArea()); state.resetMarked(); } else if (warningPolygon != null) { // want intersection of warningPolygon and oldWarningArea @@ -1459,6 +1459,7 @@ public class WarngenLayer extends AbstractStormTrackResource { issueRefresh(); VizApp.runAsync(new Runnable() { + @Override public void run() { if (dialog != null) { dialog.setInstructions(); @@ -1750,7 +1751,7 @@ public class WarngenLayer extends AbstractStormTrackResource { hatched = (Polygon) areas[0]; hatchedArea = areas[1]; } - + if (hatched != null) { state.setWarningPolygon(hatched); updateWarnedAreaState(hatchedArea, true); @@ -2504,6 +2505,7 @@ public class WarngenLayer extends AbstractStormTrackResource { } final WarngenDialog dlg = dialog; dialog.getDisplay().asyncExec(new Runnable() { + @Override public void run() { if (dlg.isDisposed() == false && dlg.getShell().isVisible() != editable) { diff --git a/cave/com.raytheon.viz.warngen/src/com/raytheon/viz/warngen/template/TemplateRunner.java b/cave/com.raytheon.viz.warngen/src/com/raytheon/viz/warngen/template/TemplateRunner.java index cbba200dfa..bb407c9b8b 100644 --- a/cave/com.raytheon.viz.warngen/src/com/raytheon/viz/warngen/template/TemplateRunner.java +++ b/cave/com.raytheon.viz.warngen/src/com/raytheon/viz/warngen/template/TemplateRunner.java @@ -78,6 +78,7 @@ import com.raytheon.uf.viz.core.localization.LocalizationManager; import com.raytheon.uf.viz.core.requests.ThriftClient; import com.raytheon.viz.awipstools.ToolsDataManager; import com.raytheon.viz.awipstools.common.StormTrackData; +import com.raytheon.viz.awipstools.common.stormtrack.AbstractStormTrackResource; import com.raytheon.viz.awipstools.common.stormtrack.StormTrackState; import com.raytheon.viz.awipstools.common.stormtrack.StormTrackState.DisplayType; import com.raytheon.viz.core.mode.CAVEMode; @@ -135,6 +136,7 @@ import com.vividsolutions.jts.io.WKTReader; * Dec 17, 2012 15571 Qinglu Lin For hydro products, resolved issue caused by calling wkt.read(loc) * while loc is null. * Jan 8, 2013 15664 Qinglu Lin Appended selectedAction to handler.handle()'s argument list. + * Feb 12, 2013 1600 jsanchez Correctly set the StormTrackData's motion direction for a CAN and EXP. * * * @@ -509,17 +511,18 @@ public class TemplateRunner { coords[i] = new Point2D.Double(locs[i].x, locs[i].y); } context.put("eventLocation", coords); - double motionDirection = oldWarn.getMotdir(); - while (motionDirection >= 360) { - motionDirection -= 360; - } - context.put("movementDirection", motionDirection); + context.put("movementDirection", oldWarn.getMotdir()); context.put("movementInKnots", oldWarn.getMotspd()); + // StormTrackData motion direction is between -180/180, + // whereas a WarningRecord motion direction is between + // -360/360 + double motionDirection = AbstractStormTrackResource + .adjustAngle(oldWarn.getMotdir() - 180); StormTrackData std = ToolsDataManager.getInstance() .getStormTrackData(); std.setDate(simulatedTime); - std.setMotionDirection(oldWarn.getMotdir()); + std.setMotionDirection(motionDirection); std.setMotionSpeed(oldWarn.getMotspd()); t0 = System.currentTimeMillis(); ToolsDataManager.getInstance().setStormTrackData(std);