Issue #1600 Correctly set the StormTrackData motion direction for a CAN

and EXP.

Former-commit-id: e82da0ee983f1a9889e25b088e2eadebb8c08fff
This commit is contained in:
Jonathan Sanchez 2013-02-12 17:20:55 -06:00
parent 4393e42be9
commit 6d463f0c74
6 changed files with 32 additions and 40 deletions

View file

@ -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
* </pre>
*
* @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;

View file

@ -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.
*
* </pre>
*
@ -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);

View file

@ -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.
*
* </pre>
*
@ -247,26 +248,6 @@ public class ClosestPoint implements Comparable<ClosestPoint> {
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)
*

View file

@ -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.
*
* </pre>
*
@ -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;

View file

@ -189,11 +189,11 @@ public class WarngenLayer extends AbstractStormTrackResource {
private class CustomMaps extends Job {
private Set<String> customMaps = new HashSet<String>();
private final Set<String> customMaps = new HashSet<String>();
private Set<String> 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<String> removedGids = new HashSet<String>();
private final Set<String> removedGids = new HashSet<String>();
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) {

View file

@ -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.
*
* </pre>
*
@ -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);