Merge branch 'master_14.2.1' (14.2.1-24) into omaha_14.2.1

Former-commit-id: 462609aa3f [formerly c2efe26c11] [formerly 462609aa3f [formerly c2efe26c11] [formerly 70b95c7636 [formerly 2627e4d38b3dcee82dcf7a6032d692170d50d9ad]]]
Former-commit-id: 70b95c7636
Former-commit-id: 29ecfa91cb [formerly 667dff3919]
Former-commit-id: 292bb044a8
This commit is contained in:
Steve Harris 2014-05-13 15:23:57 -05:00
commit 80d1cec3ec
38 changed files with 3714 additions and 3416 deletions

View file

@ -76,6 +76,7 @@ import com.raytheon.uf.viz.d2d.core.D2DLoadProperties;
* Feb 10, 2009 chammack Initial creation
* Jul 03, 2013 2159 bsteffen Synchronize TimeCache access.
* Aug 9, 2013 DR 16448 D. Friedman Validate time match basis in redoTimeMatching
* May 5, 2014 DR 17201 D. Friedman Make same-radar time matching work more like A1.
*
* </pre>
*
@ -133,7 +134,7 @@ public class D2DTimeMatcher extends AbstractTimeMatcher {
protected transient AbstractVizResource<?, ?> timeMatchBasis;
private IDisposeListener timeMatchBasisDisposeListener = new IDisposeListener() {
private final IDisposeListener timeMatchBasisDisposeListener = new IDisposeListener() {
@Override
public void disposed(AbstractVizResource<?, ?> resource) {
@ -168,7 +169,7 @@ public class D2DTimeMatcher extends AbstractTimeMatcher {
private AbstractTimeMatchingConfigurationFactory configFactory;
private Map<AbstractVizResource<?, ?>, TimeCache> timeCacheMap = new IdentityHashMap<AbstractVizResource<?, ?>, D2DTimeMatcher.TimeCache>();
private final Map<AbstractVizResource<?, ?>, TimeCache> timeCacheMap = new IdentityHashMap<AbstractVizResource<?, ?>, D2DTimeMatcher.TimeCache>();
/**
* Default Constructor.
@ -184,6 +185,7 @@ public class D2DTimeMatcher extends AbstractTimeMatcher {
}
}
@Override
public void redoTimeMatching(AbstractVizResource<?, ?> resource) {
TimeCache cache = null;
synchronized (timeCacheMap) {
@ -230,8 +232,9 @@ public class D2DTimeMatcher extends AbstractTimeMatcher {
@Override
public void redoTimeMatching(IDescriptor descriptor) throws VizException {
synchronized (this) {
if (timeMatchBasis != null && timeMatchBasis.getDescriptor() == descriptor &&
! validateTimeMatchBasis(descriptor)) {
if ((timeMatchBasis != null)
&& (timeMatchBasis.getDescriptor() == descriptor)
&& !validateTimeMatchBasis(descriptor)) {
changeTimeMatchBasis(null);
}
if (timeMatchBasis != null) {
@ -265,7 +268,7 @@ public class D2DTimeMatcher extends AbstractTimeMatcher {
AbstractVizResource<?, ?> rsc = pairIterator.next()
.getResource();
recursiveOverlay(descriptor, new FramesInfo(timeSteps, -1,
resourceTimeMap), rsc);
resourceTimeMap), rsc, resourceTimeMap);
}
// Update the descriptor to the new times.
@ -287,7 +290,7 @@ public class D2DTimeMatcher extends AbstractTimeMatcher {
int oldIndex, DataTime[] frames, int startFrame) {
int frameToUse = startFrame;
IRenderableDisplay display = descriptor.getRenderableDisplay();
if (display != null && display.getContainer() != null) {
if ((display != null) && (display.getContainer() != null)) {
IDisplayPaneContainer container = display.getContainer();
if (container.getLoopProperties().isLooping()) {
return frameToUse;
@ -295,7 +298,7 @@ public class D2DTimeMatcher extends AbstractTimeMatcher {
}
switch (descriptor.getFrameCoordinator().getAnimationMode()) {
case Latest: {
if (oldIndex == oldTimes.length - 1) {
if (oldIndex == (oldTimes.length - 1)) {
frameToUse = frames.length - 1;
}
break;
@ -337,22 +340,23 @@ public class D2DTimeMatcher extends AbstractTimeMatcher {
*/
private int determineNewIndex(IDescriptor descriptor, FramesInfo currInfo,
DataTime[] timeSteps) {
if (timeSteps == null || timeSteps.length == 0) {
if ((timeSteps == null) || (timeSteps.length == 0)) {
return -1;
}
// If possible just copy from the time match basis
if (timeMatchBasis.getDescriptor() != null
&& timeMatchBasis.getDescriptor() != descriptor) {
if ((timeMatchBasis.getDescriptor() != null)
&& (timeMatchBasis.getDescriptor() != descriptor)) {
int idx = timeMatchBasis.getDescriptor().getFramesInfo()
.getFrameIndex();
if (idx >= 0 && idx < timeSteps.length) {
if ((idx >= 0) && (idx < timeSteps.length)) {
return idx;
}
}
// Next try to get the closest time to
DataTime[] origSteps = currInfo.getFrameTimes();
int curIndex = currInfo.getFrameIndex();
if (origSteps != null && curIndex >= 0 && curIndex < origSteps.length) {
if ((origSteps != null) && (curIndex >= 0)
&& (curIndex < origSteps.length)) {
DataTime startTime = origSteps[curIndex];
int dateIndex = Arrays.binarySearch(timeSteps, startTime);
if (dateIndex < 0) {
@ -362,7 +366,7 @@ public class D2DTimeMatcher extends AbstractTimeMatcher {
} else {
dateIndex = indexToUpdateTo(descriptor, origSteps, curIndex,
timeSteps, dateIndex);
if (dateIndex >= 0 && dateIndex < timeSteps.length - 1) {
if ((dateIndex >= 0) && (dateIndex < (timeSteps.length - 1))) {
return dateIndex;
}
}
@ -379,20 +383,24 @@ public class D2DTimeMatcher extends AbstractTimeMatcher {
* the descriptor that is being updated
* @param rsc
* the resource being updated.
* @param resourceTimeMap
* map of all previously time matched resources.
* @param frameTimesSoure
* map of all previously time matched resources that may be used
* to determine the frame times
* @throws VizException
*/
private void recursiveOverlay(IDescriptor descriptor,
FramesInfo framesInfo, AbstractVizResource<?, ?> rsc)
FramesInfo framesInfo, AbstractVizResource<?, ?> rsc,
Map<AbstractVizResource<?, ?>, DataTime[]> frameTimesSoure)
throws VizException {
if (rsc == null) {
return;
}
if (rsc instanceof IResourceGroup) {
Map<AbstractVizResource<?, ?>, DataTime[]> completed = new HashMap<AbstractVizResource<?, ?>, DataTime[]>(
frameTimesSoure);
for (ResourcePair rp : ((IResourceGroup) rsc).getResourceList()) {
AbstractVizResource<?, ?> rsc1 = rp.getResource();
recursiveOverlay(descriptor, framesInfo, rsc1);
recursiveOverlay(descriptor, framesInfo, rsc1, completed);
}
}
@ -401,18 +409,24 @@ public class D2DTimeMatcher extends AbstractTimeMatcher {
.getLoadProperties());
TimeCache timeCache = getTimeCache(rsc);
synchronized (timeCache) {
DataTime[] timeSteps = getFrameTimes(descriptor, framesInfo);
DataTime[] timeSteps = getFrameTimes(descriptor, framesInfo,
frameTimesSoure);
if (Arrays.equals(timeSteps, timeCache.getLastBaseTimes())) {
framesInfo.getTimeMap().put(rsc,
timeCache.getLastFrameTimes());
} else {
config = config.clone();
if (config.getDataTimes() == null
|| config.getDataTimes().length < 1) {
if ((config.getDataTimes() == null)
|| (config.getDataTimes().length < 1)) {
config.setDataTimes(getLatestTimes(rsc));
}
populateConfiguration(config);
DataTime[] overlayDates = TimeMatcher.makeOverlayList(
TimeMatcher tm = new TimeMatcher();
if (rsc instanceof ID2DTimeMatchingExtension) {
((ID2DTimeMatchingExtension) rsc).modifyTimeMatching(
this, rsc, tm);
}
DataTime[] overlayDates = tm.makeOverlayList(
config.getDataTimes(), config.getClock(),
timeSteps, config.getLoadMode(),
config.getForecast(), config.getDelta(),
@ -429,15 +443,16 @@ public class D2DTimeMatcher extends AbstractTimeMatcher {
* is the timeMatchBasisTimes, for four panel it is a bit more complex.
*
* @param descriptor
* @param rsc
* @param resourceTimeMap
* @param frameInfo
* @param frameTimesSoure
* @return
*/
private DataTime[] getFrameTimes(IDescriptor descriptor,
FramesInfo frameInfo) {
FramesInfo frameInfo,
Map<AbstractVizResource<?, ?>, DataTime[]> frameTimesSource) {
DataTime[] descTimes = frameInfo.getFrameTimes();
if (timeMatchBasis != null
&& timeMatchBasis.getDescriptor() == descriptor) {
if ((timeMatchBasis != null)
&& (timeMatchBasis.getDescriptor() == descriptor)) {
return descTimes;
}
@ -448,17 +463,17 @@ public class D2DTimeMatcher extends AbstractTimeMatcher {
DataTime[] times = new DataTime[frameInfo.getFrameCount()];
for (ResourcePair rp : descriptor.getResourceList()) {
DataTime[] rscTimes = frameInfo.getTimeMap().get(rp.getResource());
if (rscTimes == null || rscTimes.length != times.length) {
DataTime[] rscTimes = frameTimesSource.get(rp.getResource());
if ((rscTimes == null) || (rscTimes.length != times.length)) {
if (rp.getResource() instanceof IResourceGroup) {
// Descend into resource groups.
for (ResourcePair rp1 : ((IResourceGroup) rp.getResource())
.getResourceList()) {
rscTimes = frameInfo.getTimeMap()
.get(rp1.getResource());
if (rscTimes != null && rscTimes.length == times.length) {
rscTimes = frameTimesSource.get(rp1.getResource());
if ((rscTimes != null)
&& (rscTimes.length == times.length)) {
for (int i = 0; i < times.length; i++) {
if (times[i] == null && rscTimes[i] != null) {
if ((times[i] == null) && (rscTimes[i] != null)) {
times[i] = rscTimes[i];
}
}
@ -468,13 +483,13 @@ public class D2DTimeMatcher extends AbstractTimeMatcher {
continue;
}
for (int i = 0; i < times.length; i++) {
if (times[i] == null && rscTimes[i] != null) {
if ((times[i] == null) && (rscTimes[i] != null)) {
times[i] = rscTimes[i];
}
}
}
for (int i = 0; i < times.length; i++) {
if (times[i] == null && descTimes[i] != null) {
if ((times[i] == null) && (descTimes[i] != null)) {
times[i] = descTimes[i];
}
}
@ -498,8 +513,8 @@ public class D2DTimeMatcher extends AbstractTimeMatcher {
DataTime[] times = null;
synchronized (timeCache) {
times = timeCache.getLastFrameTimes();
if (times == null || timeCache.getLastBaseTimes() != null
|| timeCache.getLastFrameCount() != numberOfFrames) {
if ((times == null) || (timeCache.getLastBaseTimes() != null)
|| (timeCache.getLastFrameCount() != numberOfFrames)) {
times = makeEmptyLoadList(numberOfFrames, timeMatchBasis);
timeCache.setTimes(null, times, numberOfFrames);
}
@ -556,17 +571,18 @@ public class D2DTimeMatcher extends AbstractTimeMatcher {
*/
private DataTime[] makeEmptyLoadList(int numberOfFrames,
AbstractVizResource<?, ?> rsc) throws VizException {
if (timeMatchBasis != null && rsc != timeMatchBasis) {
if ((timeMatchBasis != null) && (rsc != timeMatchBasis)) {
throw new IllegalArgumentException(
"Cannot make Empty Load List for a resource which is not the Time Match Basis.");
}
TimeMatchingConfiguration config = getConfiguration(
rsc.getLoadProperties()).clone();
if (config.getDataTimes() == null || config.getDataTimes().length < 1) {
if ((config.getDataTimes() == null)
|| (config.getDataTimes().length < 1)) {
config.setDataTimes(getLatestTimes(rsc));
if (config.getDataTimes() == null
|| config.getDataTimes().length < 1) {
if ((config.getDataTimes() == null)
|| (config.getDataTimes().length < 1)) {
return null;
}
}
@ -574,7 +590,7 @@ public class D2DTimeMatcher extends AbstractTimeMatcher {
DataTime[] timeSteps = TimeMatcher.makeEmptyLoadList(
config.getDataTimes(), config.getClock(), numberOfFrames,
config.getLoadMode(), config.getForecast(), config.getDelta());
if (timeSteps == null || timeSteps.length == 0) {
if ((timeSteps == null) || (timeSteps.length == 0)) {
return null;
}
changeTimeMatchBasis(rsc);
@ -656,8 +672,8 @@ public class D2DTimeMatcher extends AbstractTimeMatcher {
Arrays.sort(config.getDataTimes());
if (config.getClock() == null) {
if (SimulatedTime.getSystemTime().isRealTime()
&& config.getDataTimes() != null
&& config.getDataTimes().length != 0) {
&& (config.getDataTimes() != null)
&& (config.getDataTimes().length != 0)) {
config.setClock(config.getDataTimes()[config.getDataTimes().length - 1]
.getValidTime().getTime());
} else {
@ -834,12 +850,12 @@ public class D2DTimeMatcher extends AbstractTimeMatcher {
if (timeMatchBasis == null) {
config = configFactory.getConfiguration(loadProps, this,
availableTimes, descriptor);
if (config == null || config.isCancel()) {
if ((config == null) || config.isCancel()) {
return dataTimesToLoad;
}
config = config.clone();
if (config.getDataTimes() == null
|| config.getDataTimes().length < 1) {
if ((config.getDataTimes() == null)
|| (config.getDataTimes().length < 1)) {
config.setDataTimes(availableTimes);
}
populateConfiguration(config);
@ -850,26 +866,27 @@ public class D2DTimeMatcher extends AbstractTimeMatcher {
} else {
config = configFactory.getOverlayConfiguration(loadProps, this,
availableTimes, descriptor);
if (config == null || config.isCancel()) {
if ((config == null) || config.isCancel()) {
return dataTimesToLoad;
}
config = config.clone();
if (config.getDataTimes() == null
|| config.getDataTimes().length < 1) {
if ((config.getDataTimes() == null)
|| (config.getDataTimes().length < 1)) {
config.setDataTimes(availableTimes);
}
populateConfiguration(config);
DataTime[] existingDataTimes = getFrameTimes(descriptor,
descriptor.getFramesInfo());
descriptor.getFramesInfo(), descriptor.getFramesInfo()
.getTimeMap());
dataTimesToLoad = TimeMatcher.makeOverlayList(
config.getDataTimes(), config.getClock(),
existingDataTimes, config.getLoadMode(),
TimeMatcher tm = new TimeMatcher();
dataTimesToLoad = tm.makeOverlayList(config.getDataTimes(),
config.getClock(), existingDataTimes, config.getLoadMode(),
config.getForecast(), config.getDelta(),
config.getTolerance());
if (timeMatchBasis.getDescriptor() != null
&& timeMatchBasis.getDescriptor() != descriptor) {
if ((timeMatchBasis.getDescriptor() != null)
&& (timeMatchBasis.getDescriptor() != descriptor)) {
// Still use my times, but the index from the time match basis
FramesInfo myFi = descriptor.getFramesInfo();
FramesInfo tmFi = timeMatchBasis.getDescriptor()
@ -1052,11 +1069,12 @@ public class D2DTimeMatcher extends AbstractTimeMatcher {
resetMultiload();
}
@Override
public void resetMultiload() {
configFactory.resetMultiload();
}
private boolean validateTimeMatchBasis(IDescriptor descriptor ) {
private boolean validateTimeMatchBasis(IDescriptor descriptor) {
/*
* If a resource is shared by multiple panels (this can be the case with
* tools, at least), then it is necessary to search all of them as
@ -1064,14 +1082,14 @@ public class D2DTimeMatcher extends AbstractTimeMatcher {
* this condition to occur?
*/
IRenderableDisplay display = descriptor.getRenderableDisplay();
IDisplayPaneContainer container = display != null ?
display.getContainer() : null;
IDisplayPaneContainer container = display != null ? display
.getContainer() : null;
if (container != null) {
for (IDisplayPane pane : container.getDisplayPanes()) {
IRenderableDisplay paneDisplay = pane.getRenderableDisplay();
IDescriptor paneDescriptor = paneDisplay != null ?
paneDisplay.getDescriptor() : null;
if (paneDescriptor != null
IDescriptor paneDescriptor = paneDisplay != null ? paneDisplay
.getDescriptor() : null;
if ((paneDescriptor != null)
&& validateTimeMatchBasis(paneDescriptor
.getResourceList())) {
return true;
@ -1091,10 +1109,10 @@ public class D2DTimeMatcher extends AbstractTimeMatcher {
} else if (rp.getProperties().isMapLayer()
|| rp.getProperties().isSystemResource()) {
continue;
} else if (rsc != null
&& rsc.getResourceData() instanceof IResourceGroup) {
if (validateTimeMatchBasis(((IResourceGroup) rsc.getResourceData())
.getResourceList())) {
} else if ((rsc != null)
&& (rsc.getResourceData() instanceof IResourceGroup)) {
if (validateTimeMatchBasis(((IResourceGroup) rsc
.getResourceData()).getResourceList())) {
return true;
}
}

View file

@ -0,0 +1,20 @@
package com.raytheon.uf.viz.d2d.core.time;
import com.raytheon.uf.viz.core.rsc.AbstractVizResource;
/**
* Allows a resource to modify time matching behavior
*
* <pre>
*
* SOFTWARE HISTORY
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* 2014-05-05 DR 17201 D. Friedman Initial revision.
*
* </pre>
*
*/
public interface ID2DTimeMatchingExtension {
public void modifyTimeMatching(D2DTimeMatcher d2dTimeMatcher, AbstractVizResource<?, ?> rsc, TimeMatcher timeMatcher);
}

View file

@ -51,6 +51,7 @@ import com.raytheon.uf.common.time.DataTimeComparator;
* Jun 19, 2007 chammack Initial Creation.
* May 31, 2013 15908 dhuffman Removed a null from a method call to
* cease a null pointer exception.
* May 5, 2014 DR 17201 D. Friedman Make same-radar time matching work more like A1.
* Aug 08, 2013 2245 bsteffen Make all DataTime comparisons consistent.
*
* </pre>
@ -97,15 +98,15 @@ public class TimeMatcher {
// 6 hours in seconds
private static final long SIX_HOURS_S = ONE_HOUR_S * 6;
private static boolean radarOnRadarYes = false;
public static final float DEFAULT_TOLERANCE_FACTOR = 0.6f;
private static long autoIntervals[] = { 300, 900, 1800, 3600, 10800, 21600,
43200, 86400 };
// Disable instantiation
private TimeMatcher() {
private boolean radarOnRadarYes = false;
// Package access
TimeMatcher() {
}
@ -223,7 +224,7 @@ public class TimeMatcher {
// of time separating the individual items. Considers separation in both
// initial time and forecast time space. Separation cannot be zero.
// ---------------------------------------------------------------------------
static IntrinsicReturnVal intrinsicPeriod(DataTime[] times,
IntrinsicReturnVal intrinsicPeriod(DataTime[] times,
boolean haveForecasts) {
int i0, i, j, m, nn, n0;
long dt, dt2, d, df;
@ -364,7 +365,7 @@ public class TimeMatcher {
// call to validTimeSort and determines the minimum length of valid
// time separating the individual items. Separation cannot be zero.
// ---------------------------------------------------------------------------
static IntrinsicReturnVal intrinsicPeriod(List<DataTime> times,
IntrinsicReturnVal intrinsicPeriod(List<DataTime> times,
List<Integer> majorIndex, boolean haveForecasts) {
int i, j, k, nn, n0;
long dt, dt2, d;
@ -540,7 +541,7 @@ public class TimeMatcher {
// tolerance being half the intrinsic period the existing frames or the
// data being overlaid, whichever is greater.
// ---------------------------------------------------------------------------
public static DataTime[] doValTimOverlay(DataTime[] depictTimeArr,
public DataTime[] doValTimOverlay(DataTime[] depictTimeArr,
DataTime[] frameTimes, long deltaTime, LoadMode mode, Date latest,
float tolerance) {
@ -656,10 +657,31 @@ public class TimeMatcher {
if (fspatial) {
frameFcsts = dataFcsts;
dtf = dt;
} else if (dtf > dt) {
dt = dtf;
}
// A1 TimeMatchFunctions.C ~ line 952
if (dt > ONE_MINUTE_MS && dt <= ELEVEN_MINUTES_MS
&& dtf > ONE_MINUTE_MS && dtf <= ELEVEN_MINUTES_MS
&& radarOnRadarYes) {
if (dtf<dt) {
dt = dtf;
}
} else if (dtf>dt) {
dt = dtf;
}
/* A1 TimeMatchingFunctions.C ~ line 960
* For 88D radar, dt is usually 300 seconds or larger
* For TDWR radar, dt is usually 180 seconds or less
* To allow 3 minutes overlay for TDWR products, dt is set to 300 seconds
*/
if (radarOnRadarYes && dt < FIVE_MINUTES_MS) {
dt = FIVE_MINUTES_MS;
}
if (tolerance > 99) {
dt = 0x7FFFFFl * 1000l;
} else {
@ -697,7 +719,7 @@ public class TimeMatcher {
vf = (frameTimes)[f].getMatchValid() + deltaTime;
v1 = vf - dt; // first usable valid time
v2 = vf + dt; // last usable valid time
if (!dataFcsts && !frameFcsts && vf > latest.getTime()) {
if (!radarOnRadarYes && !dataFcsts && !frameFcsts && vf > latest.getTime()) {
// if we are dealing with live data(without forecast times) then
// we want to allow extra time on the latest frame. For example
// LAPS data arrives hourly, and radar arrives every 6 minutes,
@ -1411,7 +1433,7 @@ public class TimeMatcher {
// Optional argument "forecast" controls how modes PROG_LOOP,
// FORCED, FCST_TIME_MATCH and DPROG_DT work.
// ---------------------------------------------------------------------------
public static DataTime[] makeOverlayList(DataTime[] depictTimes,
public DataTime[] makeOverlayList(DataTime[] depictTimes,
Date clock, DataTime[] frameTimes, LoadMode mode, long forecast,
long deltaTime, float tolerance) {
// The levelvalue check has been added to allow resources on a single
@ -1554,7 +1576,7 @@ public class TimeMatcher {
default:
break;
}
radarOnRadarYes = false;
// radarOnRadarYes = false; // A2 uses setRadarOnRadar().
// If we stripped the levelvalue, restore it.
if (levelvalue != null) {
for (DataTime time : loadTimes) {
@ -1594,7 +1616,7 @@ public class TimeMatcher {
Arrays.sort(times);
}
long minInterval = intrinsicPeriod(times, haveForecasts).intrinsicPeriod;
long minInterval = (new TimeMatcher()).intrinsicPeriod(times, haveForecasts).intrinsicPeriod;
// the intrinsic period interval is in milliseconds
minInterval /= 1000;
@ -1667,4 +1689,11 @@ public class TimeMatcher {
return intervals;
}
public boolean isRadarOnRadar() {
return radarOnRadarYes;
}
public void setRadarOnRadar(boolean radarOnRadar) {
this.radarOnRadarYes = radarOnRadar;
}
}

View file

@ -45,7 +45,7 @@ import com.raytheon.viz.pointdata.rsc.AdaptivePlotResourceData.PlotObject;
import com.vividsolutions.jts.geom.Coordinate;
/**
* TODO Add Description
* Adaptive plot resource. Used for displaying spotters readout, etc.
*
* <pre>
*
@ -53,7 +53,8 @@ import com.vividsolutions.jts.geom.Coordinate;
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Aug 3, 2011 mschenke Initial creation
* Aug 03, 2011 mschenke Initial creation
* Apr 30, 2014 3092 njensen Sped up paintInternal()
*
* </pre>
*
@ -128,11 +129,12 @@ public class AdaptivePlotResource extends
float mag = getCapability(MagnificationCapability.class)
.getMagnification().floatValue();
PointStyle style = getCapability(PointCapability.class).getPointStyle();
List<double[]> points = new ArrayList<double[]>(plots.size());
for (PlotObject object : plots) {
double[] pixel = descriptor.worldToPixel(new double[] {
object.longitude, object.latitude });
target.drawPoint(pixel[0], pixel[1], 0.0, color, style, mag);
points.add(descriptor.worldToPixel(new double[] { object.longitude,
object.latitude }));
}
target.drawPoints(points, color, style, mag);
}
@Override

View file

@ -37,6 +37,7 @@ import com.raytheon.uf.common.dataplugin.IDecoderGettable.Amount;
import com.raytheon.uf.common.dataplugin.PluginDataObject;
import com.raytheon.uf.common.dataplugin.radar.RadarRecord;
import com.raytheon.uf.common.dataplugin.radar.util.RadarInfoDict;
import com.raytheon.uf.common.dataquery.requests.RequestConstraint;
import com.raytheon.uf.common.geospatial.ReferencedCoordinate;
import com.raytheon.uf.common.localization.PathManagerFactory;
import com.raytheon.uf.common.status.IUFStatusHandler;
@ -49,6 +50,7 @@ import com.raytheon.uf.viz.core.drawables.IDescriptor;
import com.raytheon.uf.viz.core.drawables.IDescriptor.FramesInfo;
import com.raytheon.uf.viz.core.drawables.PaintProperties;
import com.raytheon.uf.viz.core.exception.VizException;
import com.raytheon.uf.viz.core.rsc.AbstractResourceData;
import com.raytheon.uf.viz.core.rsc.AbstractVizResource;
import com.raytheon.uf.viz.core.rsc.IResourceDataChanged;
import com.raytheon.uf.viz.core.rsc.LoadProperties;
@ -58,6 +60,9 @@ import com.raytheon.uf.viz.core.rsc.capabilities.ColorMapCapability;
import com.raytheon.uf.viz.core.rsc.capabilities.ColorableCapability;
import com.raytheon.uf.viz.d2d.core.map.IDataScaleResource;
import com.raytheon.uf.viz.d2d.core.sampling.ID2DSamplingResource;
import com.raytheon.uf.viz.d2d.core.time.D2DTimeMatcher;
import com.raytheon.uf.viz.d2d.core.time.ID2DTimeMatchingExtension;
import com.raytheon.uf.viz.d2d.core.time.TimeMatcher;
import com.raytheon.viz.awipstools.capabilityInterfaces.IRangeableResource;
import com.raytheon.viz.radar.DefaultVizRadarRecord;
import com.raytheon.viz.radar.VizRadarRecord;
@ -79,6 +84,7 @@ import com.vividsolutions.jts.geom.Coordinate;
* Aug 03, 2010 mnash Initial creation
* MAR 05, 2013 15313 kshresth Added sampling for DMD
* Apr 11, 2013 DR 16030 D. Friedman Fix NPE.
* May 5, 2014 DR 17201 D. Friedman Enable same-radar time matching.
*
* </pre>
*
@ -89,7 +95,8 @@ import com.vividsolutions.jts.geom.Coordinate;
public class AbstractRadarResource<D extends IDescriptor> extends
AbstractVizResource<RadarResourceData, D> implements
IResourceDataChanged, IRangeableResource, IDataScaleResource,
IRadarTextGeneratingResource, ICacheObjectCallback<RadarRecord> {
IRadarTextGeneratingResource, ICacheObjectCallback<RadarRecord>,
ID2DTimeMatchingExtension {
private static final transient IUFStatusHandler statusHandler = UFStatus
.getHandler(AbstractRadarResource.class);
@ -590,4 +597,22 @@ public class AbstractRadarResource<D extends IDescriptor> extends
public void objectArrived(RadarRecord object) {
issueRefresh();
}
@Override
public void modifyTimeMatching(D2DTimeMatcher d2dTimeMatcher,
AbstractVizResource<?, ?> rsc, TimeMatcher timeMatcher) {
/* Intended to be equivalent to A1 radar-specific part of
* TimeMatchingFunctions.C:setRadarOnRadar.
*/
AbstractVizResource<?, ?> tmb = d2dTimeMatcher.getTimeMatchBasis();
if (tmb instanceof AbstractRadarResource) {
AbstractRadarResource<?> tmbRadarRsc = (AbstractRadarResource<?>) tmb;
AbstractResourceData tmbResData = tmbRadarRsc.getResourceData();
RequestConstraint icaoRC = getResourceData().getMetadataMap().get("icao");
if (icaoRC != null && tmbResData instanceof RadarResourceData &&
icaoRC.equals(((RadarResourceData) tmbResData).getMetadataMap().get("icao"))) {
timeMatcher.setRadarOnRadar(true);
}
}
}
}

View file

@ -30,7 +30,7 @@ import java.util.regex.Pattern;
import javax.xml.bind.JAXB;
import com.raytheon.uf.common.dataplugin.warning.util.FileUtil;
import com.raytheon.uf.common.dataplugin.warning.util.WarnFileUtil;
import com.raytheon.uf.common.localization.IPathManager;
import com.raytheon.uf.common.localization.PathManagerFactory;
import com.raytheon.uf.common.status.IUFStatusHandler;
@ -48,6 +48,7 @@ import com.raytheon.uf.common.status.UFStatus.Priority;
* ------------ ---------- ----------- --------------------------
* Sep 6, 2011 10764 rferrel Use QualityControlCfg.xml for
* configuable information.
* Apr 29, 2013 3033 jsanchez Updated method to retrieve files in localization.
*
* </pre>
*
@ -77,7 +78,7 @@ public class QualityControl {
try {
QualityControl.loadQualityControlCfg();
String file = FileUtil.open("countyTypes.txt", "base");
String file = WarnFileUtil.convertFileContentsToString("countyTypes.txt", null, null);
countyTypes = new HashMap<String, String>();
for (String line : file.split("\n")) {
String[] parts = line.split("\\\\");

View file

@ -34,8 +34,8 @@ import com.raytheon.uf.common.dataplugin.warning.config.GeospatialConfiguration;
import com.raytheon.uf.common.dataplugin.warning.config.WarngenConfiguration;
import com.raytheon.uf.common.dataplugin.warning.gis.GeospatialData;
import com.raytheon.uf.common.dataplugin.warning.util.CountyUserData;
import com.raytheon.uf.common.dataplugin.warning.util.FileUtil;
import com.raytheon.uf.common.dataplugin.warning.util.GeometryUtil;
import com.raytheon.uf.common.dataplugin.warning.util.WarnFileUtil;
import com.raytheon.uf.common.dataquery.requests.RequestConstraint;
import com.raytheon.uf.common.geospatial.ISpatialQuery.SearchMode;
import com.raytheon.uf.common.geospatial.SpatialException;
@ -74,6 +74,7 @@ import com.vividsolutions.jts.geom.prep.PreparedGeometry;
* Apr 29, 2013 1955 jsanchez Ignored comparing the geometry's user data when finding intersected areas.
* May 2, 2013 1963 jsanchez Updated method to determine partOfArea.
* Aug 19, 2013 2177 jsanchez Used portionsUtil to calculate area portion descriptions.
* Apr 29, 2014 3033 jsanchez Updated method to retrieve files in localization.
* </pre>
*
* @author chammack
@ -165,9 +166,10 @@ public class Area {
if (areaConfig.getAreaNotationTranslationFile() != null) {
try {
abbreviation = new Abbreviation(FileUtil.getFile(
abbreviation = new Abbreviation(WarnFileUtil
.findFileInLocalizationIncludingBackupSite(
areaConfig.getAreaNotationTranslationFile(),
localizedSite));
localizedSite, null).getFile());
} catch (FileNotFoundException e) {
statusHandler.handle(Priority.ERROR, "Unable to find "
+ areaConfig.getAreaNotationTranslationFile() + "", e);

View file

@ -56,7 +56,7 @@ import com.raytheon.uf.common.dataplugin.warning.config.PointSourceConfiguration
import com.raytheon.uf.common.dataplugin.warning.config.WarngenConfiguration;
import com.raytheon.uf.common.dataplugin.warning.gis.GeospatialData;
import com.raytheon.uf.common.dataplugin.warning.gis.GeospatialFactory;
import com.raytheon.uf.common.dataplugin.warning.util.FileUtil;
import com.raytheon.uf.common.dataplugin.warning.util.WarnFileUtil;
import com.raytheon.uf.common.dataquery.requests.RequestConstraint;
import com.raytheon.uf.common.geospatial.DestinationGeodeticCalculator;
import com.raytheon.uf.common.geospatial.ISpatialQuery.SearchMode;
@ -114,7 +114,7 @@ import com.vividsolutions.jts.geom.Point;
* points that are in the past.
* Jun 24, 2013 DR 16317 D. Friedman Handle "motionless" track.
* Jun 25, 2013 16224 Qinglu Lin Resolved the issue with "Date start" for pathcast in CON.
*
* Apr 29, 2014 3033 jsanchez Updated method to retrieve files in localization.
* </pre>
*
* @author chammack
@ -262,8 +262,8 @@ public class Wx {
String trxFileStr = pathcastConfiguration
.getAreaNotationTranslationFile();
if (trxFileStr != null) {
File trxFile = FileUtil.getFile(areaNotationAbbrevField,
localizedSite);
File trxFile = WarnFileUtil.findFileInLocalizationIncludingBackupSite(
areaNotationAbbrevField, localizedSite, null).getFile();
if (!trxFile.exists()) {
throw new WarngenException(
"Translation file does not exist: " + trxFileStr);
@ -279,8 +279,8 @@ public class Wx {
if (stormTrackState.isNonstationary()) {
List<Coordinate> coordinates = new ArrayList<Coordinate>();
Date stormTime = new Date();
Date start = DateUtil.roundDate(new Date(stormTime.getTime() + delta),
pathcastConfiguration.getInterval());
Date start = DateUtil.roundDate(new Date(stormTime.getTime()
+ delta), pathcastConfiguration.getInterval());
DestinationGeodeticCalculator gc = new DestinationGeodeticCalculator();
while (start.getTime() <= wwaStopTime) {
PathCast cast = new PathCast();
@ -449,16 +449,20 @@ public class Wx {
points = new ArrayList<ClosestPoint>(0);
}
if (flag) {
pointsToBeRemoved = findPointsToBeRemoved(centroid, points, stormTrackState.angle);
pointsToBeRemoved = findPointsToBeRemoved(centroid, points,
stormTrackState.angle);
flag = false;
}
if (pointsToBeRemoved != null) {
for (int i=0; i<pointsToBeRemoved.size(); i++) {
for (int j=0; j<points.size(); j++) {
// double comparison below can be replaced by gid comparison when bug in getGid() is fixed.
if (pointsToBeRemoved.get(i).getPoint().x == points.get(j).getPoint().x &&
pointsToBeRemoved.get(i).getPoint().y == points.get(j).getPoint().y) {
for (int i = 0; i < pointsToBeRemoved.size(); i++) {
for (int j = 0; j < points.size(); j++) {
// double comparison below can be replaced by gid
// comparison when bug in getGid() is fixed.
if (pointsToBeRemoved.get(i).getPoint().x == points
.get(j).getPoint().x
&& pointsToBeRemoved.get(i).getPoint().y == points
.get(j).getPoint().y) {
points.remove(j);
break;
}
@ -482,7 +486,8 @@ public class Wx {
for (PathCast pc2 : tmp) {
if (pc2 != pc) {
List<ClosestPoint> points2 = pcPoints.get(pc2);
ClosestPoint found = find(cp, points2, Integer.MAX_VALUE);
ClosestPoint found = find(cp, points2,
Integer.MAX_VALUE);
if (found != null) {
// We found a point within maxCount in this
// list.
@ -958,7 +963,8 @@ public class Wx {
return new Date(this.wwaStartTime);
}
private List<ClosestPoint> findPointsToBeRemoved(Point centroid, List<ClosestPoint> points, double stormtrackAngle) {
private List<ClosestPoint> findPointsToBeRemoved(Point centroid,
List<ClosestPoint> points, double stormtrackAngle) {
// convert storm track angle to geometry angle in range of (0,360)
double convertedAngle = 90.0 - stormtrackAngle;
if (convertedAngle < 0.0)
@ -968,7 +974,8 @@ public class Wx {
List<ClosestPoint> removedPoints = new ArrayList<ClosestPoint>();
while (iter.hasNext()) {
ClosestPoint cp = iter.next();
double d = Math.abs(convertedAngle - computeAngle(centroid, cp.point));
double d = Math.abs(convertedAngle
- computeAngle(centroid, cp.point));
if (d > 180.0)
d = 360.0 - d;
if (d > 90.0)
@ -978,7 +985,8 @@ public class Wx {
}
private double computeAngle(Point p, Coordinate c) {
double angle = Math.atan2(c.y - p.getY(), c.x - p.getX()) * 180 / Math.PI;
double angle = Math.atan2(c.y - p.getY(), c.x - p.getX()) * 180
/ Math.PI;
if (angle < 0)
angle += 360;
return angle;

View file

@ -76,6 +76,7 @@ import com.raytheon.uf.common.time.util.TimeUtil;
import com.raytheon.uf.viz.core.IDisplayPaneContainer;
import com.raytheon.uf.viz.core.VizApp;
import com.raytheon.uf.viz.core.exception.VizException;
import com.raytheon.uf.viz.core.localization.LocalizationManager;
import com.raytheon.uf.viz.core.maps.MapManager;
import com.raytheon.viz.awipstools.common.stormtrack.StormTrackState.DisplayType;
import com.raytheon.viz.awipstools.common.stormtrack.StormTrackState.Mode;
@ -152,6 +153,7 @@ import com.vividsolutions.jts.geom.Polygon;
* Sep 24, 2013 #2401 lvenable Fixed font memory leak.
* Oct 01, 2013 DR16612 m.gamazaychikov Fixed inconsistencies with track locking and updateListSelected method
* Oct 29, 2013 DR 16734 D. Friedman If redraw-from-hatched-area fails, don't allow the polygon the be used.
* Apr 28, 2014 3033 jsanchez Re-initialized the Velocity Engine when switching back up sites.
* </pre>
*
* @author chammack
@ -168,15 +170,24 @@ public class WarngenDialog extends CaveSWTDialog implements
private static final int FONT_HEIGHT = 9;
static {
// Ensure TemplateRunner gets initialized for use
new Job("Template Runner Initialization") {
private class TemplateRunnerInitJob extends Job {
private String site;
public TemplateRunnerInitJob() {
super("Template Runner Initialization");
this.site = LocalizationManager.getInstance().getCurrentSite();
}
public TemplateRunnerInitJob(String site) {
super("Template Runner Initialization");
this.site = site;
}
@Override
protected IStatus run(IProgressMonitor monitor) {
TemplateRunner.initialize();
TemplateRunner.initialize(site);
return Status.OK_STATUS;
}
}.schedule();
}
private static String UPDATELISTTEXT = "UPDATE LIST ";
@ -300,6 +311,7 @@ public class WarngenDialog extends CaveSWTDialog implements
bulletListManager = new BulletListManager();
warngenLayer = layer;
CurrentWarnings.addListener(this);
new TemplateRunnerInitJob().schedule();
}
@Override
@ -1073,7 +1085,7 @@ public class WarngenDialog extends CaveSWTDialog implements
if ((followupData != null)
&& (WarningAction.valueOf(followupData.getAct()) == WarningAction.NEW)) {
if (! redrawFromWarned())
if (!redrawFromWarned())
return;
}
@ -1300,8 +1312,14 @@ public class WarngenDialog extends CaveSWTDialog implements
private void backupSiteSelected() {
if ((backupSiteCbo.getSelectionIndex() >= 0)
&& (backupSiteCbo.getItemCount() > 0)) {
warngenLayer.setBackupSite(backupSiteCbo.getItems()[backupSiteCbo
.getSelectionIndex()]);
int index = backupSiteCbo.getSelectionIndex();
String backupSite = backupSiteCbo.getItem(index);
warngenLayer.setBackupSite(backupSite);
if (backupSite.equalsIgnoreCase("none")) {
new TemplateRunnerInitJob().schedule();
} else {
new TemplateRunnerInitJob(backupSite).schedule();
}
// Refresh template
changeTemplate(warngenLayer.getTemplateName());
resetPressed();
@ -1658,7 +1676,7 @@ public class WarngenDialog extends CaveSWTDialog implements
for (int i = 0; i < updateListCbo.getItemCount(); i++) {
FollowupData fd = (FollowupData) updateListCbo
.getData(updateListCbo.getItem(i));
if ( fd != null ) {
if (fd != null) {
if (fd.equals(warngenLayer.state.followupData)) {
updateListCbo.select(i);
updateListCbo.setText(updateListCbo.getItem(i));
@ -2478,8 +2496,10 @@ public class WarngenDialog extends CaveSWTDialog implements
public void realizeEditableState() {
boolean layerEditable = warngenLayer.isEditable();
// TODO: Note there is no 'is track editing allowed' state yet.
warngenLayer.getStormTrackState().editable = layerEditable && trackEditable && !trackLocked;
warngenLayer.setBoxEditable(layerEditable && boxEditable && !polygonLocked);
warngenLayer.getStormTrackState().editable = layerEditable
&& trackEditable && !trackLocked;
warngenLayer.setBoxEditable(layerEditable && boxEditable
&& !polygonLocked);
warngenLayer.issueRefresh();
}

View file

@ -119,7 +119,6 @@ import com.raytheon.viz.warngen.util.FipsUtil;
import com.vividsolutions.jts.geom.Coordinate;
import com.vividsolutions.jts.geom.Envelope;
import com.vividsolutions.jts.geom.Geometry;
import com.vividsolutions.jts.geom.GeometryCollection;
import com.vividsolutions.jts.geom.GeometryFactory;
import com.vividsolutions.jts.geom.LineSegment;
import com.vividsolutions.jts.geom.LinearRing;
@ -196,6 +195,7 @@ import com.vividsolutions.jts.io.WKTReader;
* 10/29/2013 DR 16734 D. Friedman If redraw-from-hatched-area fails, don't allow the pollygon the be used.
* 01/09/2014 DR 16974 D. Friedman Improve followup redraw-from-hatched-area polygons.
* 04/15/2014 DR 17247 D. Friedman Rework error handling in AreaHatcher.
* 04/28,2014 3033 jsanchez Properly handled back up configuration (*.xml) files. Set backupSite to null when backup site is not selected.
* </pre>
*
* @author mschenke
@ -484,7 +484,8 @@ public class WarngenLayer extends AbstractStormTrackResource {
}
int inner_counter = 0;
System.out.println("");
while (!outputHatchedArea.isValid() && inner_counter < 5) {
while (!outputHatchedArea.isValid()
&& inner_counter < 5) {
System.out
.println(" Calling alterVertexes #"
+ inner_counter);
@ -501,7 +502,8 @@ public class WarngenLayer extends AbstractStormTrackResource {
}
for (Coordinate c : outputHatchedArea.getCoordinates()) {
if (Double.isNaN(c.x) || Double.isNaN(c.y)) {
throw new IllegalStateException("Invalid coordinate " + c);
throw new IllegalStateException(
"Invalid coordinate " + c);
}
}
outputHatchedWarningArea = createWarnedArea(
@ -512,13 +514,14 @@ public class WarngenLayer extends AbstractStormTrackResource {
this.hatchedWarningArea = outputHatchedWarningArea;
} catch (Exception e) {
this.hatchException = e;
/* This is DEBUG so as to not distract the user when the
* result may not even be used. If there is an an attempt
* to use the result, the error is reported with a higher
/*
* This is DEBUG so as to not distract the user when the
* result may not even be used. If there is an an attempt to
* use the result, the error is reported with a higher
* priority in getHatchedAreas().
*/
statusHandler.handle(Priority.DEBUG,
String.format("Error redrawing polygon: %s\n Input: %s\n",
statusHandler.handle(Priority.DEBUG, String.format(
"Error redrawing polygon: %s\n Input: %s\n",
e.getLocalizedMessage(), inputWarningPolygon), e);
}
}
@ -557,10 +560,10 @@ public class WarngenLayer extends AbstractStormTrackResource {
if (hatchException instanceof VizException) {
message = hatchException.getLocalizedMessage();
} else {
message = "Could not redraw box from warned area: " +
hatchException.getLocalizedMessage();
message = "Could not redraw box from warned area: "
+ hatchException.getLocalizedMessage();
}
statusHandler.handle(Priority.PROBLEM, message, hatchException );
statusHandler.handle(Priority.PROBLEM, message, hatchException);
return new Geometry[] { null, null };
}
}
@ -1045,7 +1048,8 @@ public class WarngenLayer extends AbstractStormTrackResource {
WarngenConfiguration config = null;
try {
config = WarngenConfiguration.loadConfig(templateName,
getLocalizedSite());
LocalizationManager.getInstance().getCurrentSite(),
backupSite);
} catch (Exception e) {
statusHandler.handle(Priority.PROBLEM,
"Error occurred loading template " + templateName, e);
@ -1287,7 +1291,7 @@ public class WarngenLayer extends AbstractStormTrackResource {
public void setBackupSite(String site) {
if (site.equalsIgnoreCase("none")) {
backupSite = "";
backupSite = null;
} else {
backupSite = site;
}
@ -1295,7 +1299,7 @@ public class WarngenLayer extends AbstractStormTrackResource {
public String getLocalizedSite() {
String site = "";
if (backupSite == null || "".equals(backupSite)) {
if (backupSite == null) {
site = LocalizationManager.getInstance().getCurrentSite();
} else {
site = backupSite;
@ -1405,9 +1409,15 @@ public class WarngenLayer extends AbstractStormTrackResource {
GeospatialDataList gdl = searchCountyGeospatialDataAccessor();
if (gdl == null) {
// Cause county geospatial data to be loaded
// TODO: Should not be referencing tornadoWarning.
/*
* TODO This code needs to be refactored because 'tornadoWarning'
* should not be hard coded. What if the file tornadoWarning does
* not exist in the base? The 'tornadoWarning' was originally not
* the filename. What happens in the future if the base file gets
* changed again? A ticket should be opened for this to be resolved.
*/
WarngenConfiguration torConfig = WarngenConfiguration.loadConfig(
"tornadoWarning", getLocalizedSite());
"tornadoWarning", getLocalizedSite(), null);
loadGeodataForConfiguration(torConfig);
gdl = searchCountyGeospatialDataAccessor();
}
@ -1642,7 +1652,8 @@ public class WarngenLayer extends AbstractStormTrackResource {
Geometry newHatchedArea = null;
Geometry newUnfilteredArea = null;
boolean useFilteredArea = false;
boolean useFallback = getConfiguration().getHatchedAreaSource().isInclusionFallback();
boolean useFallback = getConfiguration().getHatchedAreaSource()
.isInclusionFallback();
/*
* The resultant warning area is constructed in one of two ways:
@ -1737,7 +1748,8 @@ public class WarngenLayer extends AbstractStormTrackResource {
} else {
boolean passed = filterArea(f, intersection, true);
useFilteredArea = useFilteredArea || passed;
include = (passed || filterAreaSecondChance(f, intersection, true))
include = (passed || filterAreaSecondChance(f,
intersection, true))
&& (oldWarningPolygon == null
|| prepGeom.intersects(oldWarningPolygon) || isOldAreaOutsidePolygon(f));
newUnfilteredArea = union(newUnfilteredArea, intersection);
@ -1755,8 +1767,8 @@ public class WarngenLayer extends AbstractStormTrackResource {
}
}
newHatchedArea = useFilteredArea && newHatchedArea != null ? newHatchedArea :
useFallback ? newUnfilteredArea : null;
newHatchedArea = useFilteredArea && newHatchedArea != null ? newHatchedArea
: useFallback ? newUnfilteredArea : null;
return newHatchedArea != null ? newHatchedArea : new GeometryFactory()
.createGeometryCollection(new Geometry[0]);
}
@ -1796,13 +1808,16 @@ public class WarngenLayer extends AbstractStormTrackResource {
if (oldWarningArea != null) {
int areaPercent = -1;
try {
areaPercent = Double.valueOf(
((oldWarningPolygon.intersection(warningPolygon)
.getArea() / oldWarningArea.getArea()) * 100))
.intValue();
areaPercent = Double
.valueOf(
((oldWarningPolygon.intersection(
warningPolygon).getArea() / oldWarningArea
.getArea()) * 100)).intValue();
} catch (Exception e) {
statusHandler.handle(Priority.VERBOSE,
"Error determining amount of overlap with original polygon", e);
statusHandler
.handle(Priority.VERBOSE,
"Error determining amount of overlap with original polygon",
e);
areaPercent = 100;
}
if (oldWarningPolygon.intersects(warningPolygon) == false
@ -2327,7 +2342,8 @@ public class WarngenLayer extends AbstractStormTrackResource {
* If redraw failed, do not allow this polygon to be used to
* generate a warning.
*
* Note that this duplicates code from updateWarnedAreaState.
* Note that this duplicates code from
* updateWarnedAreaState.
*/
state.strings.clear();
state.setWarningArea(null);
@ -2874,9 +2890,8 @@ public class WarngenLayer extends AbstractStormTrackResource {
if (oldWarningArea != null) {
// for a CON, prevents extra areas to be added
Set<String> fipsIds = getAllFipsInArea(oldWarningArea);
if (fipsIds.contains(featureFips) == false ||
! (oldWarningPolygon.contains(point) == true
|| isOldAreaOutsidePolygon(f))) {
if (fipsIds.contains(featureFips) == false
|| !(oldWarningPolygon.contains(point) == true || isOldAreaOutsidePolygon(f))) {
break;
}
}
@ -2888,7 +2903,8 @@ public class WarngenLayer extends AbstractStormTrackResource {
for (GeospatialData gd : dataWithFips) {
Geometry g = gd.geometry;
if (oldWarningArea != null) {
g = GeometryUtil.intersection(oldWarningArea, g);
g = GeometryUtil
.intersection(oldWarningArea, g);
}
fipsParts.add(g);
}
@ -2897,12 +2913,11 @@ public class WarngenLayer extends AbstractStormTrackResource {
.toArray(new Geometry[fipsParts.size()]));
if (warningPolygon.contains(point)) {
// If inside warning polygon, intersect
geom = GeometryUtil.intersection(
warningPolygon, geom);
geom = GeometryUtil.intersection(warningPolygon,
geom);
}
newWarningArea = GeometryUtil.union(
removeCounty(warningArea, featureFips),
geom);
removeCounty(warningArea, featureFips), geom);
}
state.setWarningArea(filterWarningArea(newWarningArea));
setUniqueFip();
@ -2924,25 +2939,29 @@ public class WarngenLayer extends AbstractStormTrackResource {
return null;
/*
* Note: Currently does not determine if warningArea is valid (i.e., in
* contained in CWA, old warning area, etc.) or has overlapping geometries.
* contained in CWA, old warning area, etc.) or has overlapping
* geometries.
*/
Geometry newHatchedArea = null;
Geometry newUnfilteredArea = null;
boolean useFilteredArea = false;
boolean useFallback = getConfiguration().getHatchedAreaSource().isInclusionFallback();
boolean useFallback = getConfiguration().getHatchedAreaSource()
.isInclusionFallback();
for (GeospatialData f : geoData.features) {
String gid = GeometryUtil.getPrefix(f.geometry.getUserData());
Geometry warningAreaForFeature = getWarningAreaForGids(Arrays.asList(gid), warningArea);
Geometry warningAreaForFeature = getWarningAreaForGids(
Arrays.asList(gid), warningArea);
boolean passed = filterArea(f, warningAreaForFeature, false);
useFilteredArea = useFilteredArea || passed;
if (passed || filterAreaSecondChance(f, warningAreaForFeature, false))
if (passed
|| filterAreaSecondChance(f, warningAreaForFeature, false))
newHatchedArea = union(newHatchedArea, warningAreaForFeature);
newUnfilteredArea = union(newUnfilteredArea, warningAreaForFeature);
}
newHatchedArea = useFilteredArea && newHatchedArea != null ? newHatchedArea :
useFallback ? newUnfilteredArea : null;
newHatchedArea = useFilteredArea && newHatchedArea != null ? newHatchedArea
: useFallback ? newUnfilteredArea : null;
return newHatchedArea != null ? newHatchedArea : new GeometryFactory()
.createGeometryCollection(new Geometry[0]);
@ -3252,6 +3271,7 @@ public class WarngenLayer extends AbstractStormTrackResource {
/**
* Like buildArea, but does not take inclusion filters into account. Also
* returns a Geometry in lat/lon space.
*
* @param inputArea
* @return
*/
@ -3268,7 +3288,8 @@ public class WarngenLayer extends AbstractStormTrackResource {
Geometry intersection = null;
try {
// Get intersection between county and hatched boundary
intersection = GeometryUtil.intersection(localHatchedArea, prepGeom);
intersection = GeometryUtil.intersection(localHatchedArea,
prepGeom);
if (oldWarningArea != null) {
intersection = GeometryUtil.intersection(intersection,
oldWarningArea);
@ -3280,7 +3301,8 @@ public class WarngenLayer extends AbstractStormTrackResource {
newHatchedArea = union(newHatchedArea, intersection);
}
Geometry result = newHatchedArea != null ? newHatchedArea : new GeometryFactory()
Geometry result = newHatchedArea != null ? newHatchedArea
: new GeometryFactory()
.createGeometryCollection(new Geometry[0]);
return localToLatLon(result);
}

View file

@ -29,7 +29,7 @@ import org.apache.velocity.exception.ResourceNotFoundException;
import org.apache.velocity.runtime.resource.Resource;
import org.apache.velocity.runtime.resource.loader.FileResourceLoader;
import com.raytheon.uf.common.dataplugin.warning.util.FileUtil;
import com.raytheon.uf.common.dataplugin.warning.util.WarnFileUtil;
import com.raytheon.uf.common.localization.FileUpdatedMessage;
import com.raytheon.uf.common.localization.ILocalizationFileObserver;
import com.raytheon.uf.common.localization.LocalizationFile;
@ -37,7 +37,7 @@ import com.raytheon.uf.common.localization.LocalizationUtil;
import com.raytheon.uf.common.localization.exception.LocalizationException;
/**
* TODO Add Description
* Loads the appropriate files in the localization for the Velocity Engine.
*
* <pre>
*
@ -47,7 +47,7 @@ import com.raytheon.uf.common.localization.exception.LocalizationException;
* ------------ ---------- ----------- --------------------------
* Aug 18, 2011 mschenke Initial creation
* 06/01/2012 DR 14555 D. Friedman Support new version of Velocity.
*
* Apr 28, 2014 3033 jsanchez Retrieved the site and back up from the extended properties.
* </pre>
*
* @author mschenke
@ -57,7 +57,9 @@ import com.raytheon.uf.common.localization.exception.LocalizationException;
public class LocalizationResourceLoader extends FileResourceLoader implements
ILocalizationFileObserver {
public static final String SITE_KEY = "SITE";
public static final String PROPERTY_BACKUP = "file.resource.loader.backup";
public static final String PROPERTY_SITE = "file.resource.loader.site";
private String site;
@ -94,7 +96,8 @@ public class LocalizationResourceLoader extends FileResourceLoader implements
throw new RuntimeException("Unable to locate file: " + name
+ ", resource loader has not been initialized");
}
String site = configuration.getString(SITE_KEY);
String site = configuration.getString("site");
String backup = configuration.getString("backup");
if (site == null || site.equals(this.site) == false) {
// We changed sites since last time, clear out cache
for (LocalizationFile file : fileMap.values()) {
@ -108,7 +111,7 @@ public class LocalizationResourceLoader extends FileResourceLoader implements
try {
LocalizationFile file = fileMap.get(name);
if (file == null || file.exists() == false) {
file = FileUtil.getLocalizationFile(name, site);
file = WarnFileUtil.findFileInLocalizationIncludingBackupSite(name, site, backup);
file.addFileUpdatedObserver(this);
fileMap.put(name, file);
}

View file

@ -156,6 +156,7 @@ import com.vividsolutions.jts.io.WKTReader;
* May 30, 2013 DR 16237 D. Friedman Fix watch query.
* Jun 18, 2013 2118 njensen Only calculate pathcast if it's actually used
* Aug 19, 2013 2177 jsanchez Passed PortionsUtil to Area class.
* Apr 28, 2014 3033 jsanchez Set the site and backup site in Velocity Engine's properties
* </pre>
*
* @author njensen
@ -887,7 +888,7 @@ public class TemplateRunner {
long tz0 = System.currentTimeMillis();
String script = createScript(warngenLayer.getTemplateName() + ".vm",
context, warngenLayer.getLocalizedSite());
context);
System.out.println("velocity time: "
+ (System.currentTimeMillis() - tz0));
@ -902,36 +903,38 @@ public class TemplateRunner {
private static VelocityEngine ENGINE;
public static void initialize() {
public static void initialize(String issuingSite) {
synchronized (TemplateRunner.class) {
if (ENGINE == null) {
ENGINE = new VelocityEngine();
Properties p = new Properties();
p.setProperty("file.resource.loader.class",
LocalizationResourceLoader.class.getName());
p.setProperty("runtime.log",
FileUtil.join(FileUtil.join(
LocalizationManager.getUserDir(), "logs"),
p.setProperty("runtime.log", FileUtil.join(
FileUtil.join(LocalizationManager.getUserDir(), "logs"),
"velocity.log"));
p.setProperty("velocimacro.permissions.allowInline", "true");
p.setProperty(
"velocimacro.permissions.allow.inline.to.replace.global",
"true");
String site = LocalizationManager.getInstance().getCurrentSite();
p.setProperty(LocalizationResourceLoader.PROPERTY_SITE, site);
if (issuingSite.equalsIgnoreCase(site) == false) {
p.setProperty(LocalizationResourceLoader.PROPERTY_BACKUP,
issuingSite);
}
ENGINE.init(p);
}
}
}
private static String createScript(String vmFile, VelocityContext context,
String site) throws VizException {
private static String createScript(String vmFile, VelocityContext context)
throws VizException {
synchronized (TemplateRunner.class) {
if (ENGINE == null) {
initialize();
}
StringWriter sw = new StringWriter();
try {
// Update site for ENGINE
ENGINE.setProperty(LocalizationResourceLoader.SITE_KEY, site);
context.put("scriptLibrary", "VM_global_library.vm");
Template template = ENGINE.getTemplate(vmFile,
Velocity.ENCODING_DEFAULT);

View file

@ -30,7 +30,7 @@ import java.util.regex.Pattern;
import org.apache.commons.lang.StringUtils;
import com.raytheon.uf.common.dataplugin.warning.WarningRecord.WarningAction;
import com.raytheon.uf.common.dataplugin.warning.util.FileUtil;
import com.raytheon.uf.common.dataplugin.warning.util.WarnFileUtil;
import com.raytheon.uf.common.status.IUFStatusHandler;
import com.raytheon.uf.common.status.UFStatus;
import com.raytheon.uf.common.status.UFStatus.Priority;
@ -54,6 +54,7 @@ import com.raytheon.viz.warngen.gis.AffectedAreas;
* bulletIndices(), header(), firstBullet(), secondBullet(), getImmediateCausesPtrn();
* updated body(), header(), and secondBullet();
* Mar 13, 2013 DR 15892 D. Friedman Fix bullet parsing.
* Apr 29, 2014 3033 jsanchez Moved patterns into ICommonPatterns
*
* </pre>
*
@ -142,8 +143,9 @@ abstract public class AbstractLockingBehavior implements ICommonPatterns {
private Integer[] bulletIndices() {
List<Integer> bulletIndices = new ArrayList<Integer>();
/* Assumes first line cannot be a bullet and that the '*' is
* at the start of a line.
/*
* Assumes first line cannot be a bullet and that the '*' is at the
* start of a line.
*/
int index = text.indexOf("\n* ");
while (index >= 0) {
@ -160,9 +162,7 @@ abstract public class AbstractLockingBehavior implements ICommonPatterns {
private void header() {
// LOCK_END should not be found at the beginning since the previous line
// should be blank.
String h = "^((THE NATIONAL WEATHER SERVICE IN .{1,} HAS (ISSUED A|EXTENDED THE))"
+ newline + ")$";
Pattern header = Pattern.compile(h, Pattern.MULTILINE);
find(header.matcher(text));
}
@ -255,13 +255,6 @@ abstract public class AbstractLockingBehavior implements ICommonPatterns {
* Locks the second bullet.
*/
private void secondBullet() {
// LOCK_END should not be found at the beginning since the previous line
// should be blank.
String secondBullet =
"\\* UNTIL \\d{3,4} (AM|PM) \\w{3,4}( \\w{6,9}){0,1}(\\/\\d{3,4} (AM|PM) \\w{3,4}( \\w{6,9}){0,1}\\/){0,1}"
+ newline;
Pattern secondBulletPtrn = Pattern.compile(secondBullet,
Pattern.MULTILINE);
find(secondBulletPtrn.matcher(text));
}
@ -273,7 +266,7 @@ abstract public class AbstractLockingBehavior implements ICommonPatterns {
StringBuffer pattern = new StringBuffer();
try {
String immediateCause = FileUtil.open(filename, "base");
String immediateCause = WarnFileUtil.convertFileContentsToString(filename, null, null);
pattern.append("(.*)(A DAM BREAK");
for (String ic : immediateCause.split("\n")) {
String[] parts = ic.split("\\\\");
@ -319,7 +312,7 @@ abstract public class AbstractLockingBehavior implements ICommonPatterns {
* Locks the UGC line or FIPS line.
*/
private void ugc() {
Pattern ugcPtrn = Pattern.compile(ugc + newline, Pattern.MULTILINE);
Pattern ugcPtrn = Pattern.compile(ugc + NEWLINE, Pattern.MULTILINE);
find(ugcPtrn.matcher(text));
}
@ -327,13 +320,6 @@ abstract public class AbstractLockingBehavior implements ICommonPatterns {
* Locks the HTEC line.
*/
private void htec() {
// LOCK_END can be added at the start of the line if a previous line has
// been locked.
String htec = "^(("
+ LOCK_END
+ "){0,1}/[A-Za-z0-9]{5}.[0-3NU].\\w{2}.\\d{6}T\\d{4}Z.\\d{6}T\\d{4}Z.\\d{6}T\\d{4}Z.\\w{2}/"
+ newline + ")";
Pattern htecPtrn = Pattern.compile(htec, Pattern.MULTILINE);
find(htecPtrn.matcher(text));
}
@ -341,13 +327,6 @@ abstract public class AbstractLockingBehavior implements ICommonPatterns {
* Locks the VTEC line.
*/
private void vtec() {
// LOCK_END can be added at the start of the line if a previous line has
// been locked.
String vtec = "^(("
+ LOCK_END
+ "){0,1}/[OTEX]\\.([A-Z]{3})\\.[A-Za-z0-9]{4}\\.[A-Z]{2}\\.[WAYSFON]\\.\\d{4}\\.\\d{6}T\\d{4}Z-\\d{6}T\\d{4}Z/"
+ newline + ")";
Pattern vtecPtrn = Pattern.compile(vtec, Pattern.MULTILINE);
find(vtecPtrn.matcher(text));
}
@ -355,7 +334,7 @@ abstract public class AbstractLockingBehavior implements ICommonPatterns {
* Locks the list of area names.
*/
private void areaNames() {
Pattern listOfAreaNamePtrn = Pattern.compile(listOfAreaName + newline,
Pattern listOfAreaNamePtrn = Pattern.compile(listOfAreaName + NEWLINE,
Pattern.MULTILINE);
find(listOfAreaNamePtrn.matcher(text));
}
@ -420,13 +399,6 @@ abstract public class AbstractLockingBehavior implements ICommonPatterns {
* Locks the TIME...MOT...LINE (Can be multiple lines).
*/
private void tml() {
// LOCK_END can be added at the start of the line if a previous line has
// been locked.
String tml = "^(("
+ LOCK_END
+ "){0,1}(TIME\\.\\.\\.MOT\\.\\.\\.LOC \\d{3,4}Z \\d{3}DEG \\d{1,3}KT(( \\d{3,4} \\d{3,5}){1,})(\\s*\\d{3,5} )*)\\s*"
+ newline + ")";
Pattern tmlPtrn = Pattern.compile(tml, Pattern.MULTILINE);
find(tmlPtrn.matcher(text));
}
@ -434,11 +406,7 @@ abstract public class AbstractLockingBehavior implements ICommonPatterns {
* Locks the coordinates of the polygon.
*/
private void latLon() {
// LOCK_END should not be found at the beginning of the LAT...LON since
// the previous line should be blank.
String latLon = "^((LAT\\.\\.\\.LON( \\d{3,4} \\d{3,5})+)" + newline
+ ")(((\\s{5}( \\d{3,4} \\d{3,5})+)" + newline + ")+)?";
Pattern latLonPtrn = Pattern.compile(latLon, Pattern.MULTILINE);
find(latLonPtrn.matcher(text));
}
@ -446,15 +414,6 @@ abstract public class AbstractLockingBehavior implements ICommonPatterns {
* Locks the Call To Action header and the segment tags.
*/
private void callToActions() {
// LOCK_END should not be found at the beginning since the previous line
// should be blank.
String precautionaryPtrn = "^(PRECAUTIONARY/PREPAREDNESS ACTIONS\\.\\.\\."
+ newline + ")";
String ctaEndPtrn = "^(&&" + newline + ")";
String segmentPtrn = "^(\\$\\$" + newline + ")";
Pattern cta = Pattern.compile("(" + precautionaryPtrn + ")" + "|("
+ ctaEndPtrn + ")" + "|(" + segmentPtrn + ")",
Pattern.MULTILINE);
find(cta.matcher(text));
}
@ -462,13 +421,6 @@ abstract public class AbstractLockingBehavior implements ICommonPatterns {
* Locks the test messages.
*/
private void testMessages() {
String test1 = "THIS IS A TEST MESSAGE\\. DO NOT TAKE ACTION BASED ON THIS MESSAGE\\."
+ newline;
String test2 = "THIS IS A TEST MESSAGE\\.";
String test3 = "\\.\\.\\.THIS MESSAGE IS FOR TEST PURPOSES ONLY\\.\\.\\."
+ newline;
Pattern testPtrn = Pattern.compile("(" + test1 + ")|" + "(" + test2
+ ")|" + "(" + test3 + ")");
find(testPtrn.matcher(text));
}

View file

@ -34,6 +34,7 @@ import java.util.regex.Pattern;
* Oct 18, 2012 15332 jsanchez Replaced listOfAreaNamesPtrn with String pattern.
* Mar 13, 2013 DR 15892 D. Friedman Allow some punctuation in area names.
* Apr 18, 2013 DR 16055 D. Friedman Allow more than one contiguous space in areas.
* Apr 29, 2014 3033 jsanchez Added more patterns.
*
* </pre>
*
@ -48,7 +49,7 @@ public interface ICommonPatterns {
/** End tag for locking */
public static final String LOCK_END = "</L>";
public static final String newline = "\\n";
public static final String NEWLINE = "\\n";
// LOCK_END should not be found at the beginning since the previous line
// should be blank.
@ -56,13 +57,14 @@ public interface ICommonPatterns {
// LOCK_END can be added at the start of the line if a previous line has
// been locked.
public static final String listOfAreaName = "^((" + LOCK_END
public static final String listOfAreaName = "^(("
+ LOCK_END
+ "){0,1}((([\\?\\(\\)\\w\\.,/'-]+\\s{1,})+\\w{2}-)*(([\\?\\(\\)\\w\\.,/'-]+\\s{1,})+\\w{2}-)))";
// LOCK_END should not be found at the beginning of a first bullet since the
// previous line should be blank.
public static final String firstBullet = "^(\\* (.*) (WARNING|ADVISORY)( FOR(.*)|\\.\\.\\.)"
+ newline + ")";
+ NEWLINE + ")";
// LOCK_END can be added at the start of the line if a previous line has
// been locked.
@ -71,5 +73,61 @@ public interface ICommonPatterns {
"^(("
+ LOCK_END
+ "){0,1}\\d{3,4} (AM|PM) (\\w{3,4}) \\w{3} (\\w{3})\\s+(\\d{1,2}) (\\d{4})"
+ newline + ")", Pattern.MULTILINE);
+ NEWLINE + ")", Pattern.MULTILINE);
public static final Pattern header = Pattern.compile(
"^((THE NATIONAL WEATHER SERVICE IN .{1,} HAS (ISSUED A|EXTENDED THE))"
+ NEWLINE + ")$", Pattern.MULTILINE);
/*
* LOCK_END should not be found at the beginning since the previous line
*/
public static final Pattern secondBulletPtrn = Pattern
.compile(
"\\* UNTIL \\d{3,4} (AM|PM) \\w{3,4}( \\w{6,9}){0,1}(\\/\\d{3,4} (AM|PM) \\w{3,4}( \\w{6,9}){0,1}\\/){0,1}"
+ NEWLINE, Pattern.MULTILINE);
public static final Pattern htecPtrn = Pattern
.compile(
"^(("
+ LOCK_END
+ "){0,1}/[A-Za-z0-9]{5}.[0-3NU].\\w{2}.\\d{6}T\\d{4}Z.\\d{6}T\\d{4}Z.\\d{6}T\\d{4}Z.\\w{2}/"
+ NEWLINE + ")", Pattern.MULTILINE);
public static final Pattern vtecPtrn = Pattern
.compile(
"^(("
+ LOCK_END
+ "){0,1}/[OTEX]\\.([A-Z]{3})\\.[A-Za-z0-9]{4}\\.[A-Z]{2}\\.[WAYSFON]\\.\\d{4}\\.\\d{6}T\\d{4}Z-\\d{6}T\\d{4}Z/"
+ NEWLINE + ")", Pattern.MULTILINE);
public static final Pattern tmlPtrn = Pattern
.compile(
"^(("
+ LOCK_END
+ "){0,1}(TIME\\.\\.\\.MOT\\.\\.\\.LOC \\d{3,4}Z \\d{3}DEG \\d{1,3}KT(( \\d{3,4} \\d{3,5}){1,})(\\s*\\d{3,5} )*)\\s*"
+ NEWLINE + ")", Pattern.MULTILINE);
public static Pattern testPtrn = Pattern
.compile("("
+ "THIS IS A TEST MESSAGE\\. DO NOT TAKE ACTION BASED ON THIS MESSAGE\\."
+ NEWLINE
+ ")|"
+ "("
+ "THIS IS A TEST MESSAGE\\."
+ ")|"
+ "("
+ "\\.\\.\\.THIS MESSAGE IS FOR TEST PURPOSES ONLY\\.\\.\\."
+ NEWLINE + ")");
public static final Pattern cta = Pattern.compile("("
+ "^(PRECAUTIONARY/PREPAREDNESS ACTIONS\\.\\.\\." + NEWLINE + ")"
+ ")" + "|(" + "^(&&" + NEWLINE + ")" + ")" + "|(" + "^(\\$\\$"
+ NEWLINE + ")" + ")", Pattern.MULTILINE);
public static final Pattern latLonPtrn = Pattern.compile(
"^((LAT\\.\\.\\.LON( \\d{3,4} \\d{3,5})+)" + NEWLINE
+ ")(((\\s{5}( \\d{3,4} \\d{3,5})+)" + NEWLINE + ")+)?",
Pattern.MULTILINE);
}

View file

@ -41,6 +41,7 @@ import com.raytheon.viz.core.mode.CAVEMode;
* ------------ ---------- ----------- --------------------------
* May 3, 2011 jsanchez Initial creation
* Oct 25, 2013 2249 rferrel getAvailableTimes always returns a non-empty list.
* Apr 28, 2014 DR 17310 D. Friedman Handle null VTEC fields.
*
* </pre>
*
@ -79,8 +80,8 @@ public class WWAResourceData extends AbstractRequestableResourceData {
for (int i = 0; i < objects.length; i++) {
records.add((AbstractWarningRecord) objects[i]);
}
watchResource = ((AbstractWarningRecord) objects[0]).getSig()
.equals("A");
watchResource = "A".equals(((AbstractWarningRecord) objects[0])
.getSig());
} else if (loadProperties.isLoadWithoutData()) {
// I must be trying to load without data, Ill try.
RequestConstraint phenSig = metadataMap.get("phensig");
@ -172,8 +173,10 @@ public class WWAResourceData extends AbstractRequestableResourceData {
TreeSet<DataTime> startTimes = new TreeSet<DataTime>();
for (AbstractWarningRecord warnRec : warnings) {
boolean valid = true;
WarningAction action = WarningAction.valueOf(warnRec.getAct());
if (action == WarningAction.CAN || action == WarningAction.EXP) {
WarningAction action = warnRec.getAct() != null ?
WarningAction.valueOf(warnRec.getAct()) : null;
if ((action == WarningAction.CAN || action == WarningAction.EXP) &&
warnRec.getEtn() != null && warnRec.getPhensig() != null) {
valid = false;
for (AbstractWarningRecord w : warnings) {
if (warnRec.equals(w)) {
@ -182,8 +185,8 @@ public class WWAResourceData extends AbstractRequestableResourceData {
TimeRange tr = new TimeRange(w.getStartTime(),
w.getEndTime());
if (tr.contains(warnRec.getStartTime().getTime())
&& w.getEtn().equals(warnRec.getEtn()) == false
&& w.getPhensig().equals(warnRec.getPhensig()) == false) {
&& warnRec.getEtn().equals(w.getEtn()) == false
&& warnRec.getPhensig().equals(w.getPhensig()) == false) {
valid = true;
}
}

View file

@ -18,11 +18,13 @@ Require-Bundle: com.raytheon.edex.common,
com.raytheon.uf.common.localization,
javax.persistence,
org.apache.commons.cli;bundle-version="1.0.0",
com.raytheon.uf.common.dataplugin.shef;bundle-version="1.12.1174"
com.raytheon.uf.common.dataplugin.shef;bundle-version="1.12.1174",
com.raytheon.uf.common.status;bundle-version="1.12.1174"
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Import-Package: com.raytheon.edex.plugin.obs,
com.raytheon.edex.plugin.obs.metar,
com.raytheon.edex.plugin.obs.metar.util,
com.raytheon.edex.plugin.shef.database,
com.raytheon.edex.textdb.dbapi.impl,
com.raytheon.uf.common.dataplugin.obs.metar,
com.raytheon.uf.common.dataplugin.obs.metar.util,

View file

@ -21,17 +21,15 @@ package com.raytheon.edex.plugin.shef;
import java.util.Date;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import com.raytheon.edex.esb.Headers;
import com.raytheon.edex.exception.DecoderException;
import com.raytheon.edex.plugin.shef.ShefSeparator.ShefDecoderInput;
import com.raytheon.edex.plugin.shef.data.ShefRecord;
import com.raytheon.edex.plugin.shef.database.PostShef;
import com.raytheon.edex.plugin.shef.database.PurgeText;
import com.raytheon.uf.common.dataplugin.PluginDataObject;
import com.raytheon.uf.common.ohd.AppsDefaults;
import com.raytheon.uf.common.status.IUFStatusHandler;
import com.raytheon.uf.common.status.UFStatus;
import com.raytheon.uf.edex.decodertools.core.DecoderTools;
/**
@ -56,11 +54,13 @@ import com.raytheon.uf.edex.decodertools.core.DecoderTools;
* 01/15/2009 1892 J. Sanchez Update parse method, set obsTimeFlag to false when done.
* 12/--/2009 jkorman Major refactor - split into ShefDecoder/SHEFParser
* 03/07/2013 15071 W. Kwock Skip empty data files.
* 04/28/2014 3088 mpduff Use UFStatus logging, various cleanup.
* </pre>
*/
public class ShefDecoder {
private final Log logger = LogFactory.getLog(getClass());
private static final IUFStatusHandler logger = UFStatus
.getHandler(ShefDecoder.class);
// SHEF never returns real data to edex, so create an empty data array
// here.
@ -68,8 +68,6 @@ public class ShefDecoder {
/**
* Constructor
*
* @throws DecoderException
*/
public ShefDecoder() {
this("shef");
@ -78,41 +76,39 @@ public class ShefDecoder {
/**
* Constructor
*
* @throws DecoderException
* @param name
*/
public ShefDecoder(String name) {
}
/**
* Decode.
*
* @param data
* Data to decode
* @param headers
* @return
* The headers for the data
* @return PluginDataObject[] of decoded data
*/
public PluginDataObject[] decode(byte[] data, Headers headers) {
boolean archiveMode = AppsDefaults.getInstance().getBoolean("ALLOW_ARCHIVE_DATA",false);
boolean archiveMode = AppsDefaults.getInstance().getBoolean(
"ALLOW_ARCHIVE_DATA", false);
String traceId = null;
if (data == null || data.length == 0){
if (data == null || data.length == 0) {
return null;
}
if (headers != null) {
traceId = (String) headers.get(DecoderTools.INGEST_FILE_NAME);
}
if (traceId != null) {
logger.info("Separating " + traceId);
}
ShefSeparator separator = null;
try {
separator = ShefSeparator.separate(data, headers);
} catch(Exception e) {
logger.error("Could not separate " + traceId);
if(logger.isDebugEnabled()) {
logger.error(e);
}
} catch (Exception e) {
logger.error("Could not separate " + traceId, e);
separator = null;
}
if (separator != null) {
@ -120,21 +116,20 @@ public class ShefDecoder {
long startTime = System.currentTimeMillis();
Date postDate = null;
if(archiveMode) {
postDate = getPostTime(separator.getWmoHeader().getHeaderDate().getTimeInMillis());
if (archiveMode) {
postDate = getPostTime(separator.getWmoHeader().getHeaderDate()
.getTimeInMillis());
} else {
postDate = getPostTime(startTime);
}
PostShef postShef = new PostShef(postDate);
if(separator.hasNext()) {
if (separator.hasNext()) {
PurgeText pText = new PurgeText(postDate);
pText.storeTextProduct(separator);
}
if(postShef != null) {
doDecode(separator, traceId, postShef);
}
logger.info(traceId + "- Decode complete in "
+ (System.currentTimeMillis() - startTime)
+ " milliSeconds");
@ -163,13 +158,8 @@ public class ShefDecoder {
try {
separator = ShefSeparator.separate(data, headers);
} catch(Exception e) {
if(logger.isDebugEnabled()) {
} catch (Exception e) {
logger.error("Could not separate " + traceId, e);
} else {
logger.error("Could not separate " + traceId);
}
logger.error("Could not separate ",e);
separator = null;
}
@ -181,35 +171,26 @@ public class ShefDecoder {
try {
postShef = new PostShef(postDate);
} catch (Exception e) {
if(logger.isDebugEnabled()) {
logger.error("Could not create PostShef", e);
} else {
logger.error("Could not create PostShef" + e.toString());
}
}
if(postShef != null) {
if (postShef != null) {
try {
doDecode(separator, traceId, postShef);
logger.info(traceId + "- Decode complete in "
+ (System.currentTimeMillis() - startTime)
+ " milliSeconds");
} catch (Exception e) {
if(logger.isDebugEnabled()) {
logger.error("ShefDecoder.decode failed", e);
} else {
logger.error("ShefDecoder.decode failed " + e.toString());
}
}
}
}
return records;
}
private void doDecode(ShefSeparator separator, String traceId, PostShef postShef) {
private void doDecode(ShefSeparator separator, String traceId,
PostShef postShef) {
long startTime = System.currentTimeMillis();
try {
AppsDefaults appDefaults = AppsDefaults.getInstance();
boolean logSHEFOut = appDefaults.getBoolean("shef_out", false);
@ -218,7 +199,6 @@ public class ShefDecoder {
while (separator.hasNext()) {
ShefDecoderInput sdi = separator.next();
try {
SHEFParser parser = new SHEFParser(sdi);
ShefRecord shefRecord = parser.decode();
if (shefRecord != null) {
@ -226,8 +206,6 @@ public class ShefDecoder {
try {
if (logSHEFOut) {
logger.info(traceId + " > " + shefRecord);
} else if (logger.isDebugEnabled()) {
logger.debug(traceId + " > " + shefRecord);
}
postShef.post(shefRecord);
} catch (Throwable tt) {
@ -241,16 +219,15 @@ public class ShefDecoder {
logger.info(traceId + "- No records in file.");
}
} catch (Exception ee) {
logger
.error(traceId + "- Could not parse SHEF report.",
ee);
if (logger.isDebugEnabled()) {
logger.debug(traceId + " " + sdi.record);
}
logger.error(traceId + "- Could not parse SHEF report.", ee);
}
} // while()
if(dataProcessed) {
postShef.logStats(traceId, System.currentTimeMillis() - startTime);
if (dataProcessed) {
postShef.logStats(traceId, System.currentTimeMillis()
- startTime);
}
} finally {
postShef.close();
}
}
@ -264,11 +241,10 @@ public class ShefDecoder {
return new Date(startTime - (startTime % 1000));
}
/*
*
*/
public static final void main(String [] args) {
public static final void main(String[] args) {
long t = System.currentTimeMillis();
Date postDateA = new Date(t);

View file

@ -34,13 +34,12 @@ import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import com.raytheon.edex.esb.Headers;
import com.raytheon.edex.plugin.AbstractRecordSeparator;
import com.raytheon.edex.plugin.shef.util.SHEFErrors;
import com.raytheon.uf.common.dataplugin.shef.util.SHEFErrorCodes;
import com.raytheon.uf.common.status.IUFStatusHandler;
import com.raytheon.uf.common.status.UFStatus;
import com.raytheon.uf.edex.decodertools.core.DecoderTools;
import com.raytheon.uf.edex.decodertools.time.TimeTools;
import com.raytheon.uf.edex.wmo.message.WMOHeader;
@ -59,7 +58,7 @@ import com.raytheon.uf.edex.wmo.message.WMOHeader;
* 11/29/2012 lbousaidi fixed the decoding issue when the shef starts
* with :
* 6/27/2013 16225 wkwock Fixed trail with slash and space issue.
*
* 04/29/2014 3088 mpduff Use UFStatus logging
* </pre>
*
* @author bphillip
@ -85,7 +84,8 @@ public class ShefSeparator extends AbstractRecordSeparator {
public String traceId;
}
private static final Log log = LogFactory.getLog(ShefSeparator.class);
private static final IUFStatusHandler log = UFStatus
.getHandler(ShefSeparator.class);
private static final SHEFErrors ERR_LOGGER = SHEFErrors
.registerLogger(ShefSeparator.class);
@ -199,11 +199,7 @@ public class ShefSeparator extends AbstractRecordSeparator {
}
separator.setData(data, headers);
} catch (Exception e) {
if(log.isDebugEnabled()) {
log.error(separator.traceId + "- Error separating data.", e);
} else {
log.error(separator.traceId + "- Error separating data " + e.toString());
}
}
return separator;
}
@ -598,15 +594,7 @@ public class ShefSeparator extends AbstractRecordSeparator {
records.add(buffer.toString());
}
} catch (Exception e) {
if (log.isDebugEnabled()) {
ERR_LOGGER.error(getClass(), "Data error ", e);
} else {
ERR_LOGGER.error(getClass(), "Data error ");
}
}
if (log.isDebugEnabled()) {
ERR_LOGGER.debug(getClass(), "Message has " + records.size()
+ " records.");
}
}

View file

@ -19,20 +19,19 @@
**/
package com.raytheon.edex.plugin.shef.data;
import java.text.ParseException;
import java.util.Date;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import com.raytheon.edex.plugin.shef.util.SHEFDate;
import com.raytheon.edex.plugin.shef.util.ShefParm;
import com.raytheon.uf.common.dataplugin.shef.util.ParameterCode;
import com.raytheon.uf.common.dataplugin.shef.util.SHEFTimezone;
import com.raytheon.uf.common.dataplugin.shef.util.ParameterCode.Duration;
import com.raytheon.uf.common.dataplugin.shef.util.ParameterCode.Extremum;
import com.raytheon.uf.common.dataplugin.shef.util.ParameterCode.PhysicalElement;
import com.raytheon.uf.common.dataplugin.shef.util.ParameterCode.Probability;
import com.raytheon.uf.common.dataplugin.shef.util.ParameterCode.TypeSource;
import com.raytheon.edex.plugin.shef.util.SHEFDate;
import com.raytheon.edex.plugin.shef.util.ShefParm;
import com.raytheon.uf.common.dataplugin.shef.util.SHEFTimezone;
import com.raytheon.uf.common.dataplugin.shef.util.ShefConstants;
import com.raytheon.uf.common.serialization.ISerializableObject;
@ -47,6 +46,7 @@ import com.raytheon.uf.common.serialization.ISerializableObject;
* ------------ ---------- ----------- --------------------------
* 03/19/08 387 M. Duff Initial creation.
* 10/16/2008 1548 jelkins Integrated ParameterCode Types
* 04/29/2014 3088 mpduff cleanup.
*
* </pre>
*/
@ -59,6 +59,7 @@ public class ShefData implements ISerializableObject {
private String qualifier = "Z";
private String locationId = null;
// Only used for B records.
private String dataSource = null;
@ -76,7 +77,8 @@ public class ShefData implements ISerializableObject {
private TypeSource typeSource = TypeSource.READING_NONSPECIFIC;
private String dataTypeCode = TypeSource.READING_NONSPECIFIC.getCode().substring(0,1);
private String dataTypeCode = TypeSource.READING_NONSPECIFIC.getCode()
.substring(0, 1);
private String dataSourceCode = TypeSource.READING_NONSPECIFIC.getSource();
@ -90,16 +92,12 @@ public class ShefData implements ISerializableObject {
private String observationTime = null;
private Date observationTimeObj = null;
private SHEFDate obsTime = null;
private String unitsCode = null;
private String creationDate = null;
private Date creationDateObj = null;
private SHEFDate createTime = null;
private int timeSeriesId = ShefConstants.SHEF_NOT_SERIES;
@ -123,24 +121,25 @@ public class ShefData implements ISerializableObject {
}
/**
* @param stringValue the stringValue to set
* @param stringValue
* the stringValue to set
*/
public void setStringValue(String stringValue) {
this.stringValue = stringValue;
try {
boolean neg = false;
int negPos = stringValue.indexOf('-');
if(negPos >= 0) {
stringValue = stringValue.substring(negPos+1);
if (negPos >= 0) {
stringValue = stringValue.substring(negPos + 1);
neg = true;
}
value = Double.parseDouble(stringValue);
if(neg && Math.signum(value) != 0) {
if (neg && Math.signum(value) != 0) {
value *= -1.0;
}
} catch(NumberFormatException nfe) {
} catch (NumberFormatException nfe) {
value = null;
} catch(NullPointerException npe) {
} catch (NullPointerException npe) {
value = null;
}
}
@ -153,7 +152,8 @@ public class ShefData implements ISerializableObject {
}
/**
* @param value the value to set
* @param value
* the value to set
*/
public void setValue(Double value) {
this.value = value;
@ -167,7 +167,8 @@ public class ShefData implements ISerializableObject {
}
/**
* @param qualifier the qualifier to set
* @param qual
* the qualifier to set
*/
public void setQualifier(String qual) {
qualifier = (qual == null) ? "Z" : qual;
@ -181,7 +182,8 @@ public class ShefData implements ISerializableObject {
}
/**
* @param locationId the locationId to set
* @param locationId
* the locationId to set
*/
public void setLocationId(String locationId) {
this.locationId = locationId;
@ -195,7 +197,8 @@ public class ShefData implements ISerializableObject {
}
/**
* @param dataSource the dataSource to set
* @param dataSource
* the dataSource to set
*/
public void setDataSource(String dataSource) {
this.dataSource = dataSource;
@ -209,7 +212,8 @@ public class ShefData implements ISerializableObject {
}
/**
* @param timeSeriesId the timeSeriesId to set
* @param timeSeriesId
* the timeSeriesId to set
*/
public void setTimeSeriesId(int timeSeriesId) {
this.timeSeriesId = timeSeriesId;
@ -227,42 +231,45 @@ public class ShefData implements ISerializableObject {
/**
* Set the parameter code string
*
* @param parameterCode
* @param peCode
* the parameterCode to set
* @param variableDuration
*/
public void setParameterCodeString(String peCode, String variableDuration) {
if((peCode != null)&&(peCode.length() >= 2)) {
if ((peCode != null) && (peCode.length() >= 2)) {
parameterCodeString = peCode;
PhysicalElement pe = PhysicalElement.getEnum(peCode.substring(0,2));
if(!PhysicalElement.UNKNOWN.equals(pe)) {
PhysicalElement pe = PhysicalElement
.getEnum(peCode.substring(0, 2));
if (!PhysicalElement.UNKNOWN.equals(pe)) {
// Set up default values for PEDTSEP
String paramProbability = Probability.NULL.getCode();
String paramExtremum = Extremum.NULL.getCode();
String paramType = TypeSource.READING_NONSPECIFIC.getCode().substring(0,1);
String paramType = TypeSource.READING_NONSPECIFIC.getCode()
.substring(0, 1);
String paramSource = TypeSource.READING_NONSPECIFIC.getSource();
String paramDuration = "Z";
switch(peCode.length()) {
case 7 : {
paramProbability = peCode.substring(6,7);
switch (peCode.length()) {
case 7: {
paramProbability = peCode.substring(6, 7);
}
case 6 : {
paramExtremum = peCode.substring(5,6);
case 6: {
paramExtremum = peCode.substring(5, 6);
}
case 5 : {
paramSource = peCode.substring(4,5);
case 5: {
paramSource = peCode.substring(4, 5);
}
case 4 : {
paramType = peCode.substring(3,4);
if("Z".equals(paramType)) {
case 4: {
paramType = peCode.substring(3, 4);
if ("Z".equals(paramType)) {
paramType = "R";
}
}
case 3 : {
paramDuration = peCode.substring(2,3);
case 3: {
paramDuration = peCode.substring(2, 3);
}
case 2 : {
case 2: {
setProbability(Probability.getEnum(paramProbability));
setExtremum(Extremum.getEnum(paramExtremum));
@ -271,7 +278,7 @@ public class ShefData implements ISerializableObject {
String key = paramType + paramSource;
Integer n = ShefParm.getTypeSourceCode(key);
if((n != null) && (n == 1)) {
if ((n != null) && (n == 1)) {
TypeSource ts = TypeSource.getEnum(key);
dataTypeCode = paramType;
dataSourceCode = paramSource;
@ -282,7 +289,7 @@ public class ShefData implements ISerializableObject {
}
Duration duration = Duration.INSTANTENOUS;
if("Z".equals(paramDuration)) {
if ("Z".equals(paramDuration)) {
// Use the default duration code for this PE
duration = ParameterCode.Duration.getDefault(pe);
} else if ("V".equals(paramDuration)) {
@ -298,7 +305,7 @@ public class ShefData implements ISerializableObject {
setPhysicalElement(pe);
break;
}
default : {
default: {
// This is an error condition!
}
}
@ -318,11 +325,11 @@ public class ShefData implements ISerializableObject {
/**
* Set the retained comment
*
* @param retainedComment
* @param comment
* the retainedComment to set
*/
public void setRetainedComment(String comment) {
if((comment != null)&&(comment.length() == 0)) {
if ((comment != null) && (comment.length() == 0)) {
comment = null;
}
retainedComment = comment;
@ -359,7 +366,7 @@ public class ShefData implements ISerializableObject {
/**
* Set the physical element
*
* @param physicalElement
* @param element
* the physicalElement to set
*/
public void setPhysicalElement(PhysicalElement element) {
@ -393,7 +400,8 @@ public class ShefData implements ISerializableObject {
}
/**
* @param durationValue the durationValue to set
* @param duration
* the durationValue to set
*/
public void setDurationValue(Short duration) {
durationValue = duration;
@ -443,17 +451,7 @@ public class ShefData implements ISerializableObject {
* @return the observationTime
*/
public String getObservationTime() {
String retVal = null;
if (observationTime != null) {
retVal = observationTime;
} else {
// if (shefRecord.getTimeZoneCode().equalsIgnoreCase(ShefConstants.Z)) {
// retVal = "120000";
// } else {
// retVal = "240000";
// }
}
return retVal;
return observationTime;
}
/**
@ -461,10 +459,8 @@ public class ShefData implements ISerializableObject {
*
* @param anObservationTime
* the observationTime to set
* @throws ParseException
*/
public void setObservationTime(String anObservationTime)
{
public void setObservationTime(String anObservationTime) {
observationTime = anObservationTime;
}
@ -501,9 +497,8 @@ public class ShefData implements ISerializableObject {
*
* @param creationDate
* the creationDate to set
* @throws ParseException
*/
public void setCreationDate(String creationDate) throws ParseException {
public void setCreationDate(String creationDate) {
this.creationDate = creationDate;
}
@ -514,7 +509,7 @@ public class ShefData implements ISerializableObject {
*/
public Date getCreationDateObj() {
Date retDate = null;
if(createTime != null) {
if (createTime != null) {
retDate = createTime.toCalendar().getTime();
}
return retDate;
@ -523,15 +518,14 @@ public class ShefData implements ISerializableObject {
/**
* Set the creation date Date obj
*
* @param creationDateObj
* @param creationDate
* the creationDateObj to set
*/
public void setCreationDateObj(Date creationDate) {
SHEFDate d = new SHEFDate(creationDate,SHEFTimezone.GMT_TIMEZONE);
if(d != null) {
SHEFDate d = new SHEFDate(creationDate, SHEFTimezone.GMT_TIMEZONE);
if (d != null) {
createTime = d;
}
creationDateObj = creationDate;
}
/**
@ -542,10 +536,11 @@ public class ShefData implements ISerializableObject {
}
/**
* @param createTime the createTime to set
* @param createTime
* the createTime to set
*/
public void setCreateTime(SHEFDate createTime) {
if(createTime != null) {
if (createTime != null) {
this.createTime = new SHEFDate(createTime);
}
}
@ -576,7 +571,7 @@ public class ShefData implements ISerializableObject {
*/
public Date getObservationTimeObj() {
Date retDate = null;
if(obsTime != null) {
if (obsTime != null) {
retDate = obsTime.toCalendar().getTime();
}
return retDate;
@ -585,19 +580,18 @@ public class ShefData implements ISerializableObject {
/**
* Set the observation time Date object
*
* @param observationTimeObj
* @param observationTime
* the observationTimeObj to set
*/
public void setObservationTimeObj(Date observationTime) {
SHEFDate d = new SHEFDate(observationTime,SHEFTimezone.GMT_TIMEZONE);
if(d != null) {
SHEFDate d = new SHEFDate(observationTime, SHEFTimezone.GMT_TIMEZONE);
if (d != null) {
obsTime = d;
}
observationTimeObj = observationTime;
}
public void setObsTime(SHEFDate date) {
if(date != null) {
if (date != null) {
obsTime = new SHEFDate(date);
}
}
@ -629,7 +623,8 @@ public class ShefData implements ISerializableObject {
}
/**
* @param revisedRecord the revisedRecord to set
* @param revisedRecord
* the revisedRecord to set
*/
public void setRevisedRecord(boolean revisedRecord) {
this.revisedRecord = revisedRecord;
@ -643,8 +638,8 @@ public class ShefData implements ISerializableObject {
*/
public int fixupDuration(Short durationValue) {
int errorCode = 0;
if(duration != null) {
if(Duration.VARIABLE_PERIOD.equals(duration)) {
if (duration != null) {
if (Duration.VARIABLE_PERIOD.equals(duration)) {
if (durationValue != null) {
setDurationValue(durationValue);
} else {
@ -659,61 +654,53 @@ public class ShefData implements ISerializableObject {
return errorCode;
}
/**
* Processes all internal data so that it is ready for PostSHEF.
*
* <pre>
* 1. All dates converted to UTC.
* 2. All data values converted to their English equivalent.
* 3. Ensure that all "defaults" are set correctly for output.
* </pre>
*/
public void toPostData() {
if("S".equals(unitsCode)) {
if(physicalElement != null) {
if ("S".equals(unitsCode)) {
if (physicalElement != null) {
String key = physicalElement.getCode();
Double cf = ShefParm.getPhysicalElementConversionFactor(key);
Double n = doConversion(physicalElement,unitsCode,value);
if(n == null) {
if(cf != null) {
Double n = doConversion(physicalElement, unitsCode, value);
if (n == null) {
if (cf != null) {
value *= cf;
}
} else {
value = n;
}
stringValue = String.format("%f",value);
stringValue = String.format("%f", value);
unitsCode = "E";
}
}
if(createTime != null) {
if (createTime != null) {
createTime.toZuluDate();
}
if(obsTime != null) {
if (obsTime != null) {
obsTime.toZuluDate();
}
switch(getPhysicalElement()) {
case PRECIPITATION_ACCUMULATOR :
case PRECIPITATION_INCREMENT :
case PRECIPITATION_INCREMENT_DAILY : {
if(getValue() >= 0) {
switch (getPhysicalElement()) {
case PRECIPITATION_ACCUMULATOR:
case PRECIPITATION_INCREMENT:
case PRECIPITATION_INCREMENT_DAILY: {
if (getValue() >= 0) {
String val = getStringValue();
// Is there a decimal point in the value?
if(val.indexOf('.') < 0) {
if (val.indexOf('.') < 0) {
double value = getValue() / 100.0;
setStringValue(String.format("%.3f",value));
setStringValue(String.format("%.3f", value));
}
}
break;
}
}
// if(Duration.DEFAULT.equals(getDuration())) {
// // Check default durations
// Duration defaultDuration = Duration.getDefault(getPhysicalElement());
// if(defaultDuration == null) {
// defaultDuration = Duration.INSTANTENOUS;
// }
// setDuration(defaultDuration);
// setDurationValue((short) getDuration().getValue());
// setDurationCodeVariable(getDuration().getCode());
// }
}
/**
@ -723,26 +710,26 @@ public class ShefData implements ISerializableObject {
* @param multiplier
* @param adder
*/
public void adjustValue(double divisor, double base, double multiplier, double adder) {
public void adjustValue(double divisor, double base, double multiplier,
double adder) {
double adjustedValue = Double.parseDouble(stringValue);
adjustedValue = (adjustedValue / divisor + base)
* multiplier + adder;
adjustedValue = (adjustedValue / divisor + base) * multiplier + adder;
value = adjustedValue;
stringValue = String.valueOf(adjustedValue);
}
public StringBuilder toString(StringBuilder receiver) {
if(receiver == null) {
if (receiver == null) {
receiver = new StringBuilder();
}
receiver.append(String.format("%-8s",locationId));
if(obsTime != null) {
receiver.append(String.format("%-8s", locationId));
if (obsTime != null) {
receiver.append(obsTime.toOutString());
} else {
receiver.append(" 0 0 0 0 0 0");
}
receiver.append(" ");
if(createTime != null) {
if (createTime != null) {
receiver.append(createTime.toOutString());
} else {
receiver.append(" 0 0 0 0 0 0");
@ -752,7 +739,7 @@ public class ShefData implements ISerializableObject {
receiver.append(physicalElement.getCode());
receiver.append(" ");
// Type Code
if(TypeSource.UNKNOWN.equals(typeSource)) {
if (TypeSource.UNKNOWN.equals(typeSource)) {
receiver.append(" ");
} else {
receiver.append(dataTypeCode);
@ -762,46 +749,48 @@ public class ShefData implements ISerializableObject {
// Extremnum
receiver.append(extremum.getCode());
// Data Value
if(value != null) {
if (value != null) {
receiver.append(String.format("%10.3f", value));
} else {
receiver.append(String.format("%10s",ShefConstants.SHEF_MISSING));
receiver.append(String.format("%10s", ShefConstants.SHEF_MISSING));
}
receiver.append(" ");
// Data Qualifier
receiver.append((qualifier != null) ? qualifier : " ");
if(probability != null) {
if (probability != null) {
Double p = probability.getValue();
receiver.append(String.format("%6.2f",p));
receiver.append(String.format("%6.2f", p));
} else {
receiver.append(" ");
}
if(durationValue != null) {
receiver.append(String.format("%5d",durationValue));
if (durationValue != null) {
receiver.append(String.format("%5d", durationValue));
} else {
receiver.append(String.format("%5d",0));
receiver.append(String.format("%5d", 0));
}
// Revision code
receiver.append((revisedRecord) ? " 1" : " 0");
receiver.append(" ");
// Data source
receiver.append(String.format("%-8s",(dataSource != null) ? dataSource : " "));
receiver.append(String.format("%-8s", (dataSource != null) ? dataSource
: " "));
receiver.append(" ");
// Time series indicator
receiver.append(String.format("%3d",timeSeriesId));
receiver.append(String.format("%3d", timeSeriesId));
receiver.append(" ");
// Full Parameter code
receiver.append(String.format("%-7s",parameterCodeString));
receiver.append(String.format("%-7s", parameterCodeString));
receiver.append(" ");
// Unused
receiver.append(String.format("%8s"," "));
receiver.append(String.format("%8s", " "));
receiver.append(" ");
if(retainedComment != null) {
if (retainedComment != null) {
receiver.append(retainedComment);
}
return receiver;
}
/**
* Human readable output of data stored in this object
*/
@ -813,6 +802,7 @@ public class ShefData implements ISerializableObject {
/**
* The data's PETSEP.
*
* @return
*/
public String getPeTsE() {
@ -823,7 +813,6 @@ public class ShefData implements ISerializableObject {
return sb.toString();
}
/**
*
* @param element
@ -831,28 +820,29 @@ public class ShefData implements ISerializableObject {
* @param dValue
* @return The converted value or null to indicate no conversion took place.
*/
private Double doConversion(PhysicalElement element, String unitCode, Double dValue) {
if(dValue != null) {
if(element != null) {
switch(element) {
case TEMPERATURE_AIR_DRY :
case TEMPERATURE_COOLING :
case TEMPERATURE_DEW :
case TEMPERATURE_FREEZING :
case TEMPERATURE_HEATING :
case TEMPERATURE_AIR_WET :
case TEMPERATURE_AIR_MINIMUM :
case TEMPERATURE_PAN_WATER :
case TEMPERATURE_ROAD_SURFACE :
case TEMPERATURE_WATER :
case TEMPERATURE_AIR_MAXIMUM :
case TEMPERATURE_FREEZING_SURFACE : {
if("S".equals(unitCode)) {
private Double doConversion(PhysicalElement element, String unitCode,
Double dValue) {
if (dValue != null) {
if (element != null) {
switch (element) {
case TEMPERATURE_AIR_DRY:
case TEMPERATURE_COOLING:
case TEMPERATURE_DEW:
case TEMPERATURE_FREEZING:
case TEMPERATURE_HEATING:
case TEMPERATURE_AIR_WET:
case TEMPERATURE_AIR_MINIMUM:
case TEMPERATURE_PAN_WATER:
case TEMPERATURE_ROAD_SURFACE:
case TEMPERATURE_WATER:
case TEMPERATURE_AIR_MAXIMUM:
case TEMPERATURE_FREEZING_SURFACE: {
if ("S".equals(unitCode)) {
dValue = ((value * 9.0) / 5.0) + 32;
}
break;
}
default : {
default: {
dValue = null;
}
}
@ -865,18 +855,18 @@ public class ShefData implements ISerializableObject {
*
* @param args
*/
public static final void main(String [] args) {
public static final void main(String[] args) {
// ShefData d = new ShefData();
//
// d.setParameterCodeString("AD","Z");
//
// System.out.println(d);
//
// double dv = 0.04;
//
// System.out.println(String.format("[%.3f]",dv));
//
// ShefData d = new ShefData();
//
// d.setParameterCodeString("AD","Z");
//
// System.out.println(d);
//
// double dv = 0.04;
//
// System.out.println(String.format("[%.3f]",dv));
//
double adjustedValue = 10;
double divisor = 1;
@ -890,13 +880,10 @@ public class ShefData implements ISerializableObject {
Pattern Q_CODES = Pattern.compile("Q[^BEF]");
Matcher m = Q_CODES.matcher("QI");
if(m.matches()) {
if (m.matches()) {
System.out.println("found");
}
}
}

View file

@ -0,0 +1,122 @@
/**
* 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.edex.plugin.shef.util;
/**
* SHEF adjust factor object holding the values required to adjust the shef
* value.
*
* <pre>
*
* SOFTWARE HISTORY
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Apr 28, 2014 3088 mpduff Initial creation.
*
* </pre>
*
* @author mpduff
*
*/
public class ShefAdjustFactor {
private double divisor = 1.0;
private double base = 0.0;
private double multiplier = 1.0;
private double adder = 0.0;
/**
* Constructor.
*
* @param divisor
* @param base
* @param multiplier
* @param adder
*/
public ShefAdjustFactor(double divisor, double base, double multiplier,
double adder) {
this.divisor = divisor;
this.base = base;
this.multiplier = multiplier;
this.adder = adder;
}
/**
* @return the divisor
*/
public double getDivisor() {
return divisor;
}
/**
* @param divisor
* the divisor to set
*/
public void setDivisor(double divisor) {
this.divisor = divisor;
}
/**
* @return the base
*/
public double getBase() {
return base;
}
/**
* @param base
* the base to set
*/
public void setBase(double base) {
this.base = base;
}
/**
* @return the multiplier
*/
public double getMultiplier() {
return multiplier;
}
/**
* @param multiplier
* the multiplier to set
*/
public void setMultiplier(double multiplier) {
this.multiplier = multiplier;
}
/**
* @return the adder
*/
public double getAdder() {
return adder;
}
/**
* @param adder
* the adder to set
*/
public void setAdder(double adder) {
this.adder = adder;
}
}

View file

@ -20,7 +20,7 @@
-->
<requestPatterns xmlns:ns2="group">
<regex>^[AF][BS].... (KOMA|KOAX|KLSE|KARX|KDSM|KDMX|KDVN|KMLI|KEAX|KMCI|KFSD|KGRI|KGID|KLBF|KSTL|KLSX|KMSP|KMPX|KTOP|KZMP|KPQR).*</regex>
<regex>^FGUS.. (KKRF|KMSR ).*</regex>
<regex>^FGUS.. (KKRF|KMSR|KSTR ).*</regex>
<regex>^FOUS[67]3 (KKRF|KMSR ).*</regex>
<regex>^SRUS.. KOHD.*</regex>
<regex>^SRUS[568][36].*</regex>

View file

@ -96,6 +96,7 @@ import com.vividsolutions.jts.simplify.TopologyPreservingSimplifier;
* AreaConfiguration to areaFields List.
* May 7, 2013 15690 Qinglu Lin Added convertToMultiPolygon() and updated queryGeospatialData().
* Oct 22, 2013 2361 njensen Use JAXBManager for XML
* Apr 29, 2014 3033 jsanchez Properly handled site and back up site files.
* </pre>
*
* @author rjpeter
@ -136,7 +137,7 @@ public class GeospatialDataGenerator {
WarngenConfiguration template = null;
try {
template = WarngenConfiguration.loadConfig(templateName,
site);
site, null);
} catch (Exception e) {
statusHandler
.handle(Priority.ERROR,

View file

@ -6,14 +6,14 @@
</defaultRule>
<rule>
<keyValue>FA.Y</keyValue>
<period>05-00:00:00</period>
<period>20-00:00:00</period>
</rule>
<rule>
<keyValue>FA.W</keyValue>
<period>05-00:00:00</period>
<period>20-00:00:00</period>
</rule>
<rule>
<keyValue>FF.W</keyValue>
<period>05-00:00:00</period>
<period>20-00:00:00</period>
</rule>
</purgeRuleSet>

View file

@ -37,6 +37,7 @@ import java.util.regex.Pattern;
* 10/16/2008 1548 jelkins Removed unneeded constants
* 02/02/2009 1943 jsanchez Added shef_load_maxfcst.
* 06/03/2009 2410 jsanchez Changed kk to HH.
* 04/29/2014 3088 mpduff Added MILLLIS_PER_SECOND;
*
* </pre>
*/
@ -53,6 +54,8 @@ public class ShefConstants {
public static final int MILLIS_PER_MINUTE = MILLIS_PER_SECOND * 60;
public static final int MILLIS_PER_HOUR = MILLIS_PER_SECOND * 60 * 60;
public static final long MILLIS_PER_DAY = 1000 * 60 * 60 * 24;
public static final long HALF_YEAR = 365L * 24L * 3600L * 1000L / 2L;
@ -85,7 +88,6 @@ public class ShefConstants {
public static final int UPPER_LID_LIMIT = 9;
/* Precipitation index constants */
public static final int NOT_PRECIP = 0;
@ -215,8 +217,8 @@ public class ShefConstants {
public static final String VALID_UNITS = "ES";
public static final String DATE_INC_CODES = "SNHDMEY";
public static final int [] DATE_INC_VALS = new int [] {
Calendar.SECOND, // S
public static final int[] DATE_INC_VALS = new int[] { Calendar.SECOND, // S
Calendar.MINUTE, // N
Calendar.HOUR_OF_DAY, // H
Calendar.DAY_OF_MONTH, // D
@ -226,8 +228,9 @@ public class ShefConstants {
};
public static final String DURATION_CODES = "SNHDMY";
public static final short [] DURATION_VALS = new short [] {
7000, // "S" Seconds
public static final short[] DURATION_VALS = new short[] { 7000, // "S"
// Seconds
0, // "N" Minutes
1000, // "H" Hours
2000, // "D" Days

View file

@ -1,3 +1,22 @@
/**
* 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.uf.common.dataplugin.warning.config;
import java.io.FileNotFoundException;
@ -9,11 +28,10 @@ import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import com.raytheon.uf.common.dataplugin.warning.util.FileUtil;
import com.raytheon.uf.common.dataplugin.warning.util.WarnFileUtil;
import com.raytheon.uf.common.serialization.SingleTypeJAXBManager;
/**
*
* Configuration for warngen dialog
*
* <pre>
@ -24,18 +42,20 @@ import com.raytheon.uf.common.serialization.SingleTypeJAXBManager;
* ------------ ---------- ----------- --------------------------
* --/--/---- Initial creation
* 10/22/2013 2361 njensen Use JAXBManager for XML
*
* Apr 28, 2014 3033 jsanchez Refactored file retrieval.
* </pre>
*
*
* @author jsanchez
* @version 1.0
*/
@XmlAccessorType(XmlAccessType.NONE)
@XmlRootElement(name = "configuration")
public class DialogConfiguration {
private static final SingleTypeJAXBManager<DialogConfiguration> jaxb = SingleTypeJAXBManager
.createWithoutException(DialogConfiguration.class);
private static final String CONFIG_FILE = "config.xml";
@XmlElement
private String warngenOfficeShort;
@ -66,7 +86,8 @@ public class DialogConfiguration {
public static DialogConfiguration loadDialogConfig(String localSite)
throws FileNotFoundException, IOException, JAXBException {
String xml = FileUtil.open("config.xml", localSite);
String xml = WarnFileUtil.convertFileContentsToString(CONFIG_FILE,
localSite, null);
return (DialogConfiguration) jaxb.unmarshalFromXml(xml);
}

View file

@ -40,7 +40,7 @@ import javax.xml.bind.annotation.XmlRootElement;
import com.raytheon.uf.common.dataplugin.warning.WarningRecord.WarningAction;
import com.raytheon.uf.common.dataplugin.warning.config.AreaSourceConfiguration.AreaType;
import com.raytheon.uf.common.dataplugin.warning.util.FileUtil;
import com.raytheon.uf.common.dataplugin.warning.util.WarnFileUtil;
import com.raytheon.uf.common.serialization.SingleTypeJAXBManager;
import com.raytheon.uf.common.status.IUFStatusHandler;
import com.raytheon.uf.common.status.UFStatus;
@ -60,7 +60,7 @@ import com.raytheon.uf.common.status.UFStatus.Priority;
* May 26, 2010 #4649 Qinglu Lin Made including TO.A and SV.A mandatory
* Apr 24, 2013 1943 jsanchez Marked areaConfig as Deprecated.
* Oct 22, 2013 2361 njensen Removed ISerializableObject
*
* Apr 28, 2014 3033 jsanchez Properly handled back up configuration (*.xml) files.
* </pre>
*
* @author chammack
@ -156,16 +156,20 @@ public class WarngenConfiguration {
*
* @param templateName
* - the name of the warngen template
* @param localSite
* - the site cave is localized to
* @param localSite
* - the back up site
* @return the warngen configuration
* @throws VizException
*/
public static WarngenConfiguration loadConfig(String templateName,
String localSite) throws FileNotFoundException, IOException,
JAXBException {
String localSite, String backupSite) throws FileNotFoundException,
IOException, JAXBException {
WarngenConfiguration config = new WarngenConfiguration();
// Open the template file
String xml = FileUtil.open(templateName + ".xml", localSite);
String xml = WarnFileUtil
.convertFileContentsToString(templateName + ".xml", localSite, backupSite);
// Include external files, such as damInfo.txt
Matcher m = p.matcher(xml);
@ -173,7 +177,8 @@ public class WarngenConfiguration {
try {
while (m.find()) {
includeFile = m.group(1);
String includeXml = FileUtil.open(includeFile, localSite);
String includeXml = WarnFileUtil.convertFileContentsToString(includeFile, localSite,
backupSite);
xml = xml.replace(m.group(0), includeXml);
}
} catch (Exception e) {

View file

@ -1,77 +0,0 @@
package com.raytheon.uf.common.dataplugin.warning.util;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import com.raytheon.uf.common.dataplugin.warning.WarningConstants;
import com.raytheon.uf.common.localization.IPathManager;
import com.raytheon.uf.common.localization.LocalizationContext;
import com.raytheon.uf.common.localization.LocalizationContext.LocalizationLevel;
import com.raytheon.uf.common.localization.LocalizationContext.LocalizationType;
import com.raytheon.uf.common.localization.LocalizationFile;
import com.raytheon.uf.common.localization.PathManagerFactory;
public class FileUtil {
public static LocalizationFile getLocalizationFile(String filename,
String siteID) throws FileNotFoundException {
IPathManager pm = PathManagerFactory.getPathManager();
LocalizationContext[] searchContext = pm
.getLocalSearchHierarchy(LocalizationType.COMMON_STATIC);
LocalizationFile fileToUse = null;
String fileToRetrieve = WarningConstants.WARNGEN_DIR
+ IPathManager.SEPARATOR + filename;
for (LocalizationContext ctx : searchContext) {
if ((ctx.getLocalizationLevel() == LocalizationLevel.SITE || ctx
.getLocalizationLevel() == LocalizationLevel.CONFIGURED)
&& siteID != null) {
ctx.setContextName(siteID);
}
LocalizationFile file = pm.getLocalizationFile(ctx, fileToRetrieve);
if (file != null && file.exists()) {
fileToUse = file;
break;
}
}
if (fileToUse == null) {
throw new FileNotFoundException("'" + filename
+ "' can not be found");
}
return fileToUse;
}
public static File getFile(String filename, String siteID)
throws FileNotFoundException {
return getLocalizationFile(filename, siteID).getFile();
}
public static String open(String filename, String localSite)
throws FileNotFoundException, IOException {
StringBuffer sb = new StringBuffer();
BufferedReader input = null;
File file = getFile(filename, localSite);
try {
input = new BufferedReader(new FileReader(file));
String line = null;
while ((line = input.readLine()) != null) {
sb.append(line + "\n");
}
} catch (IOException e) {
} finally {
if (input != null) {
try {
input.close();
input = null;
} catch (Exception e) {
input = null;
}
}
}
return sb.toString();
}
}

View file

@ -0,0 +1,133 @@
package com.raytheon.uf.common.dataplugin.warning.util;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import com.raytheon.uf.common.dataplugin.warning.WarningConstants;
import com.raytheon.uf.common.localization.IPathManager;
import com.raytheon.uf.common.localization.LocalizationContext;
import com.raytheon.uf.common.localization.LocalizationContext.LocalizationLevel;
import com.raytheon.uf.common.localization.LocalizationContext.LocalizationType;
import com.raytheon.uf.common.localization.LocalizationFile;
import com.raytheon.uf.common.localization.PathManagerFactory;
/**
* Utility class to retrieve the appropriate file in localization and in backup
* directories.
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Apr 28, 2014 3033 jsanchez Searches the backup site directory before the localized site directory.
* </pre>
*
* @author jsanchez
* @version 1.0
*/
public class WarnFileUtil {
/**
* Returns the appropriate file in localization. If a backupSiteID is not
* null and a corresponding file does exist in the backup site directory,
* then that file in the backup site directory will be returned. However, if
* that backup file does not exist, then regular localization handling for
* the issuingSiteID is applied. For example, if a file exists in the
* issuingSiteID directory then that the file with the returned. Otherwise,
* the base level version of the file will be returned.
*
* @param filename
* @param issuingSiteID
* (optional)
* @param backupSiteID
* (optional)
* @return
* @throws FileNotFoundException
*/
public static LocalizationFile findFileInLocalizationIncludingBackupSite(String filename,
String issuingSiteID, String backupSiteID)
throws FileNotFoundException {
IPathManager pm = PathManagerFactory.getPathManager();
String fileToRetrieve = WarningConstants.WARNGEN_DIR
+ IPathManager.SEPARATOR + filename;
if (backupSiteID != null) {
LocalizationContext backupSiteCtx = pm.getContext(
LocalizationType.COMMON_STATIC, LocalizationLevel.SITE);
backupSiteCtx.setContextName(backupSiteID);
LocalizationFile backupFile = pm.getLocalizationFile(backupSiteCtx,
fileToRetrieve);
if (backupFile != null && backupFile.exists()) {
return backupFile;
}
}
LocalizationFile fileToUse = null;
LocalizationContext[] searchContext = pm
.getLocalSearchHierarchy(LocalizationType.COMMON_STATIC);
for (LocalizationContext ctx : searchContext) {
if ((ctx.getLocalizationLevel() == LocalizationLevel.SITE || ctx
.getLocalizationLevel() == LocalizationLevel.CONFIGURED)
&& issuingSiteID != null) {
ctx.setContextName(issuingSiteID);
}
LocalizationFile file = pm.getLocalizationFile(ctx, fileToRetrieve);
if (file != null && file.exists()) {
fileToUse = file;
break;
}
}
if (fileToUse == null) {
throw new FileNotFoundException("'" + filename
+ "' can not be found");
}
return fileToUse;
}
/**
* Locates the appropriate file in the localization hierarchy including the
* backupSite directory (if provided) and converts the content of the file
* into a string.
*
* @param filename
* @param localizedSite
* @param backupSite
* @return
* @throws FileNotFoundException
* @throws IOException
*/
public static String convertFileContentsToString(String filename,
String localizedSite, String backupSite)
throws FileNotFoundException, IOException {
StringBuffer sb = new StringBuffer();
BufferedReader input = null;
File file = findFileInLocalizationIncludingBackupSite(filename, localizedSite, backupSite)
.getFile();
try {
input = new BufferedReader(new FileReader(file));
String line = null;
while ((line = input.readLine()) != null) {
sb.append(line + "\n");
}
} catch (IOException e) {
} finally {
if (input != null) {
try {
input.close();
input = null;
} catch (Exception e) {
input = null;
}
}
}
return sb.toString();
}
}

View file

@ -9,7 +9,7 @@
Name: awips2-ldm
Summary: AWIPS II LDM Distribution
Version: %{_ldm_version}
Release: 11
Release: 12
Group: AWIPSII
BuildRoot: /tmp
BuildArch: noarch

View file

@ -0,0 +1,294 @@
%global __os_install_post %(echo '%{__os_install_post}' | sed -e 's!/usr/lib[^[:space:]]*/brp-python-bytecompile[[:space:]].*$!!g')
%define _build_arch %(uname -i)
%define _python_build_loc %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
%define _lapack_version 3.4.2
#
# AWIPS II Python Spec File
#
Name: awips2-python
Summary: AWIPS II Python Distribution
Version: 2.7.1
Release: 10.el6
Group: AWIPSII
BuildRoot: %{_build_root}
BuildArch: %{_build_arch}
URL: N/A
License: N/A
Distribution: N/A
Vendor: Raytheon
Packager: Bryan Kowal
AutoReq: no
provides: awips2-python
%description
AWIPS II Python Distribution - Contains Python V2.7.1 plus modules
required for AWIPS II.
%prep
# Verify That The User Has Specified A BuildRoot.
if [ "%{_build_root}" = "" ]
then
echo "A Build Root has not been specified."
echo "Unable To Continue ... Terminating"
exit 1
fi
rm -rf %{_build_root}
mkdir -p %{_build_root}/awips2/python
if [ -d %{_python_build_loc} ]; then
rm -rf %{_python_build_loc}
fi
mkdir -p %{_python_build_loc}
%build
PYTHON_TAR="Python-2.7.1.tgz"
PYTHON_SRC_DIR="%{_baseline_workspace}/rpms/awips2.core/Installer.python/src"
cp -v ${PYTHON_SRC_DIR}/${PYTHON_TAR} %{_python_build_loc}
pushd . > /dev/null
# Untar the source.
cd %{_python_build_loc}
tar -xf ${PYTHON_TAR}
RC=$?
if [ ${RC} -ne 0 ]; then
exit 1
fi
cd Python-2.7.1
# complete the substitution for python-config
sed -e "s,@EXENAME@,/awips2/python/bin/python," < Misc/python-config.in > Misc/python-config.in.new
if [ $? -ne 0 ]; then
exit 1
fi
mv -f Misc/python-config.in.new Misc/python-config.in
if [ $? -ne 0 ]; then
exit 1
fi
export CPPFLAGS="-I/usr/local/tcl8.6.1/include -I/usr/local/tk-8.6.1/include"
export LD_LIBRARY_PATH=/usr/local/tcl-8.6.1/lib:/usr/local/tk-8.6.1/lib
./configure --prefix=/awips2/python \
--enable-shared
RC=$?
if [ ${RC} -ne 0 ]; then
exit 1
fi
make clean
RC=$?
if [ ${RC} -ne 0 ]; then
exit 1
fi
make
if [ ${RC} -ne 0 ]; then
exit 1
fi
popd > /dev/null
%install
# Copies the standard Raytheon licenses into a license directory for the
# current component.
function copyLegal()
{
# $1 == Component Build Root
COMPONENT_BUILD_DIR=${1}
mkdir -p %{_build_root}/${COMPONENT_BUILD_DIR}/licenses
cp %{_baseline_workspace}/rpms/legal/license.txt \
%{_build_root}/${COMPONENT_BUILD_DIR}/licenses
cp "%{_baseline_workspace}/rpms/legal/Master Rights File.pdf" \
%{_build_root}/${COMPONENT_BUILD_DIR}/licenses
}
pushd . > /dev/null
cd %{_python_build_loc}/Python-2.7.1
make install prefix=%{_build_root}/awips2/python
RC=$?
if [ ${RC} -ne 0 ]; then
exit 1
fi
popd > /dev/null
RC=$?
if [ ${RC} -ne 0 ]; then
exit 1
fi
# Our profile.d scripts.
mkdir -p %{_build_root}/etc/profile.d
PYTHON_PROJECT_DIR="%{_baseline_workspace}/rpms/awips2.core/Installer.python"
PYTHON_SRC_DIR="${PYTHON_PROJECT_DIR}/src"
PYTHON_SCRIPTS_DIR="${PYTHON_PROJECT_DIR}/scripts"
PYTHON_PROFILED_DIR="${PYTHON_SCRIPTS_DIR}/profile.d"
cp -v ${PYTHON_PROFILED_DIR}/* %{_build_root}/etc/profile.d
RC=$?
if [ ${RC} -ne 0 ]; then
exit 1
fi
# The external libraries (hdf5, netcdf, ...) and headers
# we include with python.
# Retrieve hdf5 from: hdf5-1.8.4-patch1-linux-?-shared.tar.gz
HDF5184_PATTERN="hdf5-1.8.4-patch1-linux*-shared.tar.gz"
pushd . > /dev/null
cd ${PYTHON_SRC_DIR}/%{_build_arch}
HDF5_TAR=`ls -1 ${HDF5184_PATTERN}`
popd > /dev/null
# Copy the hdf5 tar file to our build directory.
cp -v ${PYTHON_SRC_DIR}/%{_build_arch}/${HDF5_TAR} \
%{_python_build_loc}
if [ $? -ne 0 ]; then
exit 1
fi
pushd . > /dev/null
cd %{_python_build_loc}
tar -xvf ${HDF5_TAR}
if [ $? -ne 0 ]; then
exit 1
fi
# Determine what the hdf5 directory is.
HDF_ROOT_DIR=`/bin/tar -tf ${HDF5_TAR} | head -n 1`
rm -fv ${HDF5_TAR}
cp -v ${HDF_ROOT_DIR}lib/* \
%{_build_root}/awips2/python/lib
if [ $? -ne 0 ]; then
exit 1
fi
popd > /dev/null
PYTHON_PROJECT_DIR="%{_baseline_workspace}/rpms/awips2.core/Installer.python"
PYTHON_SRC_DIR="${PYTHON_PROJECT_DIR}/src"
PYTHON_NATIVE_DIR="${PYTHON_PROJECT_DIR}/nativeLib"
LAPACK_TAR="lapack-%{_lapack_version}.tgz"
LAPACK_PATCH="lapack.patch1"
# The Raytheon-built native (nativeLib) libraries.
cp -vP ${PYTHON_NATIVE_DIR}/%{_build_arch}/grib2.so \
${PYTHON_NATIVE_DIR}/%{_build_arch}/gridslice.so \
%{_build_root}/awips2/python/lib/python2.7
if [ $? -ne 0 ]; then
exit 1
fi
cp -vP ${PYTHON_NATIVE_DIR}/%{_build_arch}/libjasper.so \
${PYTHON_NATIVE_DIR}/%{_build_arch}/libjasper.so.1 \
${PYTHON_NATIVE_DIR}/%{_build_arch}/libjasper.so.1.0.0 \
%{_build_root}/awips2/python/lib
if [ $? -ne 0 ]; then
exit 1
fi
# An additional step for 32-bit rpms (for now).
if [ "%{_build_arch}" = "i386" ]; then
/bin/tar -xvf ${PYTHON_SRC_DIR}/i386/awips2-python.tar \
-C %{_build_root}/awips2/python
if [ $? -ne 0 ]; then
exit 1
fi
fi
# Copy the LAPACK tar file and patch to our build directory.
cp -v ${PYTHON_SRC_DIR}/${LAPACK_TAR} \
%{_python_build_loc}
RC=$?
if [ ${RC} -ne 0 ]; then
exit 1
fi
cp -v ${PYTHON_SRC_DIR}/${LAPACK_PATCH} \
%{_python_build_loc}
RC=$?
if [ ${RC} -ne 0 ]; then
exit 1
fi
pushd . > /dev/null
cd %{_python_build_loc}
tar -xvf ${LAPACK_TAR}
RC=$?
if [ ${RC} -ne 0 ]; then
exit 1
fi
rm -fv ${LAPACK_TAR}
if [ ! -d lapack-%{_lapack_version} ]; then
file lapack-%{_lapack_version}
exit 1
fi
patch -p1 -i ${LAPACK_PATCH}
RC=$?
if [ ${RC} -ne 0 ]; then
exit 1
fi
cd lapack-%{_lapack_version}
mv make.inc.example make.inc
if [ $? -ne 0 ]; then
exit 1
fi
make blaslib
RC=$?
if [ ${RC} -ne 0 ]; then
exit 1
fi
make lapacklib
RC=$?
if [ ${RC} -ne 0 ]; then
exit 1
fi
# Copy the libraries that we just built to
# the python lib directory.
if [ ! -f BLAS/SRC/libblas.so ]; then
file BLAS/SRC/libblas.so
exit 1
fi
cp -v BLAS/SRC/libblas.so \
%{_build_root}/awips2/python/lib
RC=$?
if [ ${RC} -ne 0 ]; then
exit 1
fi
if [ ! -f SRC/liblapack.so ]; then
file SRC/liblapack.so
exit 1
fi
cp -v SRC/liblapack.so \
%{_build_root}/awips2/python/lib
RC=$?
if [ ${RC} -ne 0 ]; then
exit 1
fi
popd > /dev/null
copyLegal "awips2/python"
%clean
rm -rf %{_build_root}
rm -rf %{_python_build_loc}
%files
%defattr(644,awips,fxalpha,755)
%attr(755,root,root) /etc/profile.d/awips2Python.csh
%attr(755,root,root) /etc/profile.d/awips2Python.sh
%dir /awips2/python
%dir /awips2/python/lib
/awips2/python/lib/*
%docdir /awips2/python/licenses
%dir /awips2/python/licenses
/awips2/python/licenses/*
%dir /awips2/python/share
/awips2/python/share/*
%defattr(755,awips,fxalpha,755)
%dir /awips2/python/include
/awips2/python/include/*
%dir /awips2/python/bin
/awips2/python/bin/*

View file

@ -409,7 +409,7 @@ fi
if [ "${1}" = "-viz" ]; then
buildRPM "awips2"
#buildRPM "awips2-common-base"
buildRPM "awips2-common-base"
#buildRPM "awips2-python-numpy"
#buildRPM "awips2-ant"
#buildRPM "awips2-python-dynamicserialize"
@ -454,12 +454,12 @@ if [ "${1}" = "-custom" ]; then
#fi
#buildRPM "awips2-adapt-native"
#buildRPM "awips2-hydroapps-shared"
buildRPM "awips2-common-base"
buildRPM "awips2-gfesuite-client"
buildRPM "awips2-gfesuite-server"
buildRPM "awips2-python-dynamicserialize"
#buildRPM "awips2-common-base"
#buildRPM "awips2-gfesuite-client"
#buildRPM "awips2-gfesuite-server"
#buildRPM "awips2-python-dynamicserialize"
#buildRPM "awips2-alertviz"
#buildRPM "awips2-python"
buildRPM "awips2-python"
#buildRPM "awips2-alertviz"
#buildRPM "awips2-ant"
#buildRPM "awips2-eclipse"

View file

@ -92,6 +92,8 @@
<classpathentry combineaccessrules="false" kind="src" path="/javax.jms"/>
<classpathentry combineaccessrules="false" kind="src" path="/org.apache.commons.cxf"/>
<classpathentry kind="src" path="/com.raytheon.uf.common.archive"/>
<classpathentry combineaccessrules="false" kind="src" path="/com.raytheon.edex.plugin.shef"/>
<classpathentry combineaccessrules="false" kind="src" path="/com.raytheon.uf.common.dataplugin.obs"/>
<classpathentry combineaccessrules="false" kind="src" path="/com.raytheon.uf.edex.datadelivery.bandwidth.ncf"/>
<classpathentry combineaccessrules="false" kind="src" path="/org.apache.thrift"/>
<classpathentry combineaccessrules="false" kind="src" path="/com.raytheon.uf.common.dataplugin.gfe"/>

View file

@ -68,7 +68,6 @@ public class TestMetarToShefTransformer {
assertNotNull(it);
assertFalse(it.hasNext());
assertNull(it.next());
}
/**
@ -83,9 +82,16 @@ public class TestMetarToShefTransformer {
return null;
}
/*
* (non-Javadoc)
*
* @see
* com.raytheon.uf.common.dataplugin.PluginDataObject#getPluginName
* ()
*/
@Override
public String getPluginName() {
return null;
return "testMetarToShef";
}
};