Merge "Issue #1600 Created a utility class for adjust angles." into development
Former-commit-id:3929ef49cd
[formerly3929ef49cd
[formerly 52672b8ce9f9f28f707f7f6c1cd7ff61845ab752]] Former-commit-id:1854e71f8a
Former-commit-id:0fc8bcc119
This commit is contained in:
commit
ce4d65e163
5 changed files with 112 additions and 30 deletions
|
@ -65,6 +65,7 @@ import com.raytheon.viz.ui.input.EditableManager;
|
|||
* that it can be stored in the
|
||||
* StormTrackState.
|
||||
* 02-12-2013 1600 jsanchez Changed the visibility of the method adjustAngle
|
||||
* 03-05-2013 1600 jsanchez Returned the visibility of the method adjustAngle to protected.
|
||||
* </pre>
|
||||
*
|
||||
* @author mschenke
|
||||
|
@ -264,12 +265,12 @@ public abstract class AbstractStormTrackResource extends
|
|||
}
|
||||
|
||||
/**
|
||||
* Adjusts the angle from -360/360 to be between -180/180
|
||||
* Adjusts the angle to be within the range -180 to +180 degrees.
|
||||
*
|
||||
* @param angle
|
||||
* @return
|
||||
*/
|
||||
public static double adjustAngle(double angle) {
|
||||
protected double adjustAngle(double angle) {
|
||||
double newVal = angle % 360;
|
||||
if (newVal > 180) {
|
||||
newVal -= 360;
|
||||
|
|
|
@ -27,10 +27,10 @@ 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;
|
||||
import com.raytheon.viz.warngen.util.AdjustAngle;
|
||||
import com.vividsolutions.jts.geom.Coordinate;
|
||||
import com.vividsolutions.jts.geom.Geometry;
|
||||
import com.vividsolutions.jts.geom.Point;
|
||||
|
@ -49,6 +49,7 @@ import com.vividsolutions.jts.geom.Point;
|
|||
* 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.
|
||||
* Mar 5, 2013 1600 jsanchez Used AdjustAngle instead of AbstractStormTrackResource to handle angle adjusting.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -338,10 +339,9 @@ abstract public class AbstractDbSourceDataAdaptor {
|
|||
gc.setStartingGeographicPoint(cp.getPoint().x, cp.getPoint().y);
|
||||
gc.setDestinationGeographicPoint(closestCoord.x, closestCoord.y);
|
||||
cp.setAzimuth(gc.getAzimuth());
|
||||
cp.setOppositeAzimuth(AbstractStormTrackResource.adjustAngle(cp
|
||||
.getAzimuth() + 180));
|
||||
cp.setOppositeAzimuth(AdjustAngle.to360Degrees(cp.getAzimuth() + 180));
|
||||
cp.setRoundedAzimuth(GeoUtil.roundAzimuth(cp.getAzimuth()));
|
||||
cp.setOppositeRoundedAzimuth(AbstractStormTrackResource.adjustAngle(cp
|
||||
cp.setOppositeRoundedAzimuth(AdjustAngle.to360Degrees(cp
|
||||
.getRoundedAzimuth() + 180));
|
||||
cp.setArea(area);
|
||||
cp.setParentArea(parentArea);
|
||||
|
|
|
@ -66,7 +66,6 @@ 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;
|
||||
|
@ -75,6 +74,7 @@ import com.raytheon.viz.warngen.WarngenException;
|
|||
import com.raytheon.viz.warngen.config.AbstractDbSourceDataAdaptor;
|
||||
import com.raytheon.viz.warngen.config.DataAdaptorFactory;
|
||||
import com.raytheon.viz.warngen.util.Abbreviation;
|
||||
import com.raytheon.viz.warngen.util.AdjustAngle;
|
||||
import com.raytheon.viz.warnings.DateUtil;
|
||||
import com.vividsolutions.jts.geom.Coordinate;
|
||||
import com.vividsolutions.jts.geom.Geometry;
|
||||
|
@ -104,6 +104,7 @@ import com.vividsolutions.jts.geom.Point;
|
|||
* 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.
|
||||
* Mar 5, 2013 1600 jsanchez Used AdjustAngle instead of AbstractStormTrackResource to handle angle adjusting.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -847,11 +848,10 @@ public class Wx {
|
|||
.getCoordinate());
|
||||
gc.setDestinationGeographicPoint(cen.x, cen.y);
|
||||
cp2.azimuth = gc.getAzimuth();
|
||||
cp2.oppositeAzimuth = AbstractStormTrackResource
|
||||
.adjustAngle(cp2.azimuth + 180);
|
||||
cp2.oppositeAzimuth = AdjustAngle.to360Degrees(cp2.azimuth + 180);
|
||||
cp2.roundedAzimuth = GeoUtil.roundAzimuth(cp2.azimuth);
|
||||
cp2.oppositeRoundedAzimuth = AbstractStormTrackResource
|
||||
.adjustAngle(cp2.roundedAzimuth + 180);
|
||||
cp2.oppositeRoundedAzimuth = AdjustAngle
|
||||
.to360Degrees(cp2.roundedAzimuth + 180);
|
||||
|
||||
return cp2;
|
||||
}
|
||||
|
|
|
@ -88,7 +88,6 @@ 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;
|
||||
|
@ -105,6 +104,7 @@ import com.raytheon.viz.warngen.gui.WarngenLayer;
|
|||
import com.raytheon.viz.warngen.gui.WarngenUIState;
|
||||
import com.raytheon.viz.warngen.text.WarningTextHandler;
|
||||
import com.raytheon.viz.warngen.text.WarningTextHandlerFactory;
|
||||
import com.raytheon.viz.warngen.util.AdjustAngle;
|
||||
import com.raytheon.viz.warngen.util.CurrentWarnings;
|
||||
import com.raytheon.viz.warngen.util.FipsUtil;
|
||||
import com.raytheon.viz.warngen.util.FollowUpUtil;
|
||||
|
@ -185,27 +185,29 @@ public class TemplateRunner {
|
|||
}
|
||||
|
||||
/**
|
||||
* Read cwa and timezone info from officeCityTimezone.txt, and put them
|
||||
* into map officeCityTimezone.
|
||||
* Read cwa and timezone info from officeCityTimezone.txt, and put them into
|
||||
* map officeCityTimezone.
|
||||
*/
|
||||
public static Map<String,String> createOfficeTimezoneMap() {
|
||||
Map<String,String> officeCityTimezone = new HashMap<String,String>();
|
||||
public static Map<String, String> createOfficeTimezoneMap() {
|
||||
Map<String, String> officeCityTimezone = new HashMap<String, String>();
|
||||
IPathManager pathMgr = PathManagerFactory.getPathManager();
|
||||
LocalizationContext lc = pathMgr.getContext(
|
||||
LocalizationType.COMMON_STATIC, LocalizationLevel.BASE);
|
||||
String octz = "officeCityTimezone.txt";
|
||||
String fileToRetrieve = IPathManager.SEPARATOR + WarningConstants.WARNGEN_DIR
|
||||
+ IPathManager.SEPARATOR + octz;
|
||||
String fileToRetrieve = IPathManager.SEPARATOR
|
||||
+ WarningConstants.WARNGEN_DIR + IPathManager.SEPARATOR + octz;
|
||||
File timezoneFile = pathMgr.getFile(lc, fileToRetrieve);
|
||||
String line;
|
||||
String[] splitLine;
|
||||
BufferedReader timezoneReader;
|
||||
try {
|
||||
timezoneReader = new BufferedReader(new InputStreamReader(new FileInputStream(
|
||||
timezoneFile)));
|
||||
for (line = timezoneReader.readLine(); line != null; line = timezoneReader.readLine()) {
|
||||
timezoneReader = new BufferedReader(new InputStreamReader(
|
||||
new FileInputStream(timezoneFile)));
|
||||
for (line = timezoneReader.readLine(); line != null; line = timezoneReader
|
||||
.readLine()) {
|
||||
splitLine = line.trim().split("\\\\");
|
||||
officeCityTimezone.put(splitLine[0].trim(),splitLine[1].trim());
|
||||
officeCityTimezone
|
||||
.put(splitLine[0].trim(), splitLine[1].trim());
|
||||
}
|
||||
} catch (Exception e) {
|
||||
statusHandler.handle(Priority.SIGNIFICANT,
|
||||
|
@ -213,7 +215,7 @@ public class TemplateRunner {
|
|||
}
|
||||
return officeCityTimezone;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Executes a warngen template given the polygon from the Warngen Layer and
|
||||
* the Storm tracking information from StormTrackDisplay
|
||||
|
@ -413,13 +415,15 @@ public class TemplateRunner {
|
|||
Map<String, String> officeCityTimezone = createOfficeTimezoneMap();
|
||||
String cityTimezone = null;
|
||||
if (officeCityTimezone != null)
|
||||
cityTimezone = officeCityTimezone.get(warngenLayer.getLocalizedSite());
|
||||
cityTimezone = officeCityTimezone.get(warngenLayer
|
||||
.getLocalizedSite());
|
||||
Iterator<String> iterator = timeZones.iterator();
|
||||
if (timeZones.size() > 1 && cityTimezone != null) {
|
||||
String timezone;
|
||||
while (iterator.hasNext()) {
|
||||
timezone = iterator.next();
|
||||
if (timezone.equals(cityTimezone) && context.get("localtimezone") == null) {
|
||||
if (timezone.equals(cityTimezone)
|
||||
&& context.get("localtimezone") == null) {
|
||||
context.put("localtimezone", timezone);
|
||||
} else if (context.get("secondtimezone") == null) {
|
||||
context.put("secondtimezone", timezone);
|
||||
|
@ -576,8 +580,8 @@ public class TemplateRunner {
|
|||
// StormTrackData motion direction is between -180/180,
|
||||
// whereas a WarningRecord motion direction is between
|
||||
// -360/360
|
||||
double motionDirection = AbstractStormTrackResource
|
||||
.adjustAngle(oldWarn.getMotdir() - 180);
|
||||
double motionDirection = AdjustAngle.to180Degrees(oldWarn
|
||||
.getMotdir() - 180);
|
||||
StormTrackData std = ToolsDataManager.getInstance()
|
||||
.getStormTrackData();
|
||||
std.setDate(simulatedTime);
|
||||
|
@ -1350,8 +1354,10 @@ public class TemplateRunner {
|
|||
|
||||
private static String NOT_IN_CWA = new String("NOT_IN_CWA");
|
||||
|
||||
/** Determines if the given UGC is in the CWA and if it is, returns
|
||||
* the portion of the CWA.
|
||||
/**
|
||||
* Determines if the given UGC is in the CWA and if it is, returns the
|
||||
* portion of the CWA.
|
||||
*
|
||||
* @param stateAbbrev
|
||||
* @param ugc
|
||||
* @param asc
|
||||
|
@ -1367,7 +1373,8 @@ public class TemplateRunner {
|
|||
return (String) g.attributes.get(asc.getFeAreaField());
|
||||
}
|
||||
|
||||
// TODO: Is this the correct way to determine if the county is in the CWA?
|
||||
// TODO: Is this the correct way to determine if the county is in the
|
||||
// CWA?
|
||||
return NOT_IN_CWA;
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,74 @@
|
|||
/**
|
||||
* This software was developed and / or modified by Raytheon Company,
|
||||
* pursuant to Contract DG133W-05-CQ-1067 with the US Government.
|
||||
*
|
||||
* U.S. EXPORT CONTROLLED TECHNICAL DATA
|
||||
* This software product contains export-restricted data whose
|
||||
* export/transfer/disclosure is restricted by U.S. law. Dissemination
|
||||
* to non-U.S. persons whether in the United States or abroad requires
|
||||
* an export license or other authorization.
|
||||
*
|
||||
* Contractor Name: Raytheon Company
|
||||
* Contractor Address: 6825 Pine Street, Suite 340
|
||||
* Mail Stop B8
|
||||
* Omaha, NE 68106
|
||||
* 402.291.0100
|
||||
*
|
||||
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for
|
||||
* further licensing information.
|
||||
**/
|
||||
package com.raytheon.viz.warngen.util;
|
||||
|
||||
/**
|
||||
* Utility methods to adjust an angle.
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Mar 5, 2013 1600 jsanchez Initial creation
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @author jsanchez
|
||||
* @version 1.0
|
||||
*/
|
||||
|
||||
public class AdjustAngle {
|
||||
|
||||
/**
|
||||
* Adjusts the angle to be within the range -180 to +180 degrees.
|
||||
*
|
||||
* @param angle
|
||||
* @return
|
||||
*/
|
||||
public static double to180Degrees(double angle) {
|
||||
double newVal = angle % 360;
|
||||
if (newVal > 180) {
|
||||
newVal -= 360;
|
||||
} else if (newVal < -180) {
|
||||
newVal += 360;
|
||||
}
|
||||
|
||||
return newVal;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adjusts the angle to be within the range 0 to 360 degrees.
|
||||
*
|
||||
* @param angle
|
||||
* @return
|
||||
*/
|
||||
public static double to360Degrees(double angle) {
|
||||
double newVal = angle % 360;
|
||||
if (newVal < 0) {
|
||||
newVal += 360;
|
||||
} else if (newVal > 360) {
|
||||
newVal -= 360;
|
||||
}
|
||||
|
||||
return newVal;
|
||||
}
|
||||
}
|
Loading…
Add table
Reference in a new issue