Issue #1048 re-commit code cleanup changes from other branch

Change-Id: I2789e2c268f802c004f1594d7d2e5636065b5740

Former-commit-id: d5b15b488d [formerly fa0043a012] [formerly bdfb01c501] [formerly d5b15b488d [formerly fa0043a012] [formerly bdfb01c501] [formerly 8f7dbdb619 [formerly bdfb01c501 [formerly da4f41b2627e52bde097ab331e1f99c169a7e494]]]]
Former-commit-id: 8f7dbdb619
Former-commit-id: 22c6fb54a9 [formerly 846158f252] [formerly a19ee7b07bdce9654fe665e1844b6a200de43606 [formerly 00abcef8a0]]
Former-commit-id: 57d7cf62736927dae4e07ee0b5fd29abf9381859 [formerly a94642d620]
Former-commit-id: 7ad8585310
This commit is contained in:
Nate Jensen 2012-09-17 15:13:25 -05:00
parent faa2bbda20
commit 5858136598

View file

@ -150,6 +150,7 @@ import com.vividsolutions.jts.geom.Point;
* 29 June, 2009 2521 dhladky Initial creation * 29 June, 2009 2521 dhladky Initial creation
* 11 Apr. 2012 DR 14522 gzhang Fixing invalid thread error. * 11 Apr. 2012 DR 14522 gzhang Fixing invalid thread error.
* 31 July 2012 14517 mpduff Fix for blanking map on update. * 31 July 2012 14517 mpduff Fix for blanking map on update.
* 14 Sep 2012 1048 njensen Code cleanup
* *
* </pre> * </pre>
* *
@ -161,6 +162,10 @@ public class FFMPResource extends
AbstractVizResource<FFMPResourceData, MapDescriptor> implements AbstractVizResource<FFMPResourceData, MapDescriptor> implements
IResourceDataChanged, IFFMPResourceListener, FFMPListener, IResourceDataChanged, IFFMPResourceListener, FFMPListener,
FFMPLoadListener { FFMPLoadListener {
// TODO move ALL constant to common plugin
private static final String ALL = "ALL";
private static final transient IUFStatusHandler statusHandler = UFStatus private static final transient IUFStatusHandler statusHandler = UFStatus
.getHandler(FFMPResource.class); .getHandler(FFMPResource.class);
@ -375,7 +380,7 @@ public class FFMPResource extends
/** ordered list of times **/ /** ordered list of times **/
private ArrayList<Date> timeOrderedKeys = new ArrayList<Date>(); private ArrayList<Date> timeOrderedKeys = new ArrayList<Date>();
private boolean toKeysInitialized = false; private boolean toKeysInitialized = false;
/** force utility **/ /** force utility **/
@ -424,22 +429,19 @@ public class FFMPResource extends
.equals(getResourceData().sourceName)) { .equals(getResourceData().sourceName)) {
// go back an extra time step // go back an extra time step
Date previousMostRecentTime = null; Date previousMostRecentTime = null;
if (getTimeOrderedKeys().size() >= 2) { List<Date> tok = getTimeOrderedKeys();
previousMostRecentTime = getTimeOrderedKeys().get( if (tok.size() >= 2) {
getTimeOrderedKeys().size() - 2); previousMostRecentTime = tok.get(tok.size() - 2);
} else if (getTimeOrderedKeys().size() >= 1) {
previousMostRecentTime = getTimeOrderedKeys().get(
getTimeOrderedKeys().size() - 1);
} else { } else {
previousMostRecentTime = getTimeOrderedKeys().get(0); previousMostRecentTime = tok.get(0);
} }
updateTimeOrderedkeys(ffmpRec.getDataTime().getRefTime()); updateTimeOrderedkeys(ffmpRec.getDataTime().getRefTime());
if (getResourceData().tableLoad) { if (getResourceData().tableLoad) {
setTableTime(); setTableTime();
} }
setRecord(ffmpRec); setRecord(ffmpRec);
statusHandler.handle(Priority.INFO, "Updating : Previous: " statusHandler.handle(Priority.INFO, "Updating : Previous: "
@ -476,17 +478,7 @@ public class FFMPResource extends
purge(ffmpRec.getDataTime().getRefTime()); purge(ffmpRec.getDataTime().getRefTime());
} }
qpeRecord = null; resetRecords();
isNewQpe = true;
isNewRate = true;
rateRecord = null;
isNewRate = true;
virtualRecord = null;
isNewVirtual = true;
guidRecord = null;
isNewGuid = true;
qpfRecord = null;
isNewQpf = true;
} }
} catch (VizException ve) { } catch (VizException ve) {
@ -503,6 +495,24 @@ public class FFMPResource extends
refresh(); refresh();
} }
/**
* Resets the records to null and sets the boolean values relating to if the
* data is new to true
*/
private void resetRecords() {
isNewQpe = true;
isNewRate = true;
isNewVirtual = true;
isNewGuid = true;
isNewQpf = true;
qpeRecord = null;
rateRecord = null;
virtualRecord = null;
guidRecord = null;
qpfRecord = null;
}
@Override @Override
public void refresh() { public void refresh() {
if (!isAutoRefresh) { if (!isAutoRefresh) {
@ -573,13 +583,14 @@ public class FFMPResource extends
Date recentTime, boolean aggregate) throws VizException { Date recentTime, boolean aggregate) throws VizException {
FFMPBasin basin = null; FFMPBasin basin = null;
String huc = null;
if (aggregate) { if (aggregate) {
basin = getRecord(bfield, recentTime).getBasinData(getHuc()) huc = getHuc();
.getBasins().get(key);
} else { } else {
basin = getRecord(bfield, recentTime).getBasinData("ALL") huc = ALL;
.getBasins().get(key);
} }
basin = getRecord(bfield, recentTime).getBasinData(huc).getBasins()
.get(key);
return basin; return basin;
} }
@ -598,7 +609,7 @@ public class FFMPResource extends
double value = Double.NaN; double value = Double.NaN;
if (centeredAggregationKey != null) { if (centeredAggregationKey != null) {
if (getHuc().equals("ALL")) { if (getHuc().equals(ALL)) {
value = getBasinValue(key, recentTime, false); value = getBasinValue(key, recentTime, false);
return getColorUtil().colorByValue(value); return getColorUtil().colorByValue(value);
} else { } else {
@ -653,12 +664,12 @@ public class FFMPResource extends
break; break;
} }
case RATE: { case RATE: {
value = getRateRecord(recentTime).getBasinData("ALL") value = getRateRecord(recentTime).getBasinData(ALL)
.getMaxValue(pfafs, recentTime); .getMaxValue(pfafs, recentTime);
break; break;
} }
case QPF: { case QPF: {
value = getQpfRecord(recentTime).getBasinData("ALL") value = getQpfRecord(recentTime).getBasinData(ALL)
.getAverageMaxValue(pfafs, recentTime, .getAverageMaxValue(pfafs, recentTime,
getQpfSourceExpiration()); getQpfSourceExpiration());
break; break;
@ -667,21 +678,17 @@ public class FFMPResource extends
long fips = monitor.getTemplates(getSiteKey()) long fips = monitor.getTemplates(getSiteKey())
.getCountyFipsByPfaf(pfafs.get(0)); .getCountyFipsByPfaf(pfafs.get(0));
value = getGuidanceRecord().getBasinData("ALL") value = getGuidanceRecord().getBasinData(ALL)
.getMaxGuidanceValue(pfafs, .getMaxGuidanceValue(pfafs,
getGuidanceInterpolation(getFFGName()), getGuidanceInterpolation(getFFGName()),
getGuidSourceExpiration(), fips); getGuidSourceExpiration(), fips);
break; break;
} }
case QPE: { case QPE: {
value = getQpeRecord().getBasinData("ALL") value = getQpeRecord().getBasinData(ALL).getAccumMaxValue(
.getAccumMaxValue( pfafs, recentTime, getTableTime(),
pfafs, getQpeSourceExpiration(),
recentTime, getResourceData().getPrimarySourceXML().isRate());
getTableTime(),
getQpeSourceExpiration(),
getResourceData().getPrimarySourceXML()
.isRate());
break; break;
} }
} }
@ -781,12 +788,12 @@ public class FFMPResource extends
boolean forced = forceUtil.isForced(); boolean forced = forceUtil.isForced();
if ((forcedPfafs.size() > 0) && forced) { if ((forcedPfafs.size() > 0) && forced) {
// Recalculate the guidance using the forced value(s) // Recalculate the guidance using the forced value(s)
value = guidRecord.getBasinData("ALL").getAverageGuidanceValue( value = guidRecord.getBasinData(ALL).getAverageGuidanceValue(
pfafList, this.getGuidanceInterpolation(getFFGName()), pfafList, this.getGuidanceInterpolation(getFFGName()),
new Float(value), forcedPfafs, new Float(value), forcedPfafs,
getGuidSourceExpiration()); getGuidSourceExpiration());
} else if (forcedPfafs.size() > 0) { } else if (forcedPfafs.size() > 0) {
value = guidRecord.getBasinData("ALL").getAverageGuidanceValue( value = guidRecord.getBasinData(ALL).getAverageGuidanceValue(
pfafList, this.getGuidanceInterpolation(getFFGName()), pfafList, this.getGuidanceInterpolation(getFFGName()),
Float.NaN, forcedPfafs, getGuidSourceExpiration()); Float.NaN, forcedPfafs, getGuidSourceExpiration());
} }
@ -850,6 +857,21 @@ public class FFMPResource extends
return prefix.toString(); return prefix.toString();
} }
/**
* Returns the ALL huc if worst case, otherwise the huc
*
* @return
*/
private String getHucIfWorstCase() {
String huc = null;
if (isWorstCase()) {
huc = ALL;
} else {
huc = getHuc();
}
return huc;
}
/** /**
* Gets the record currently used * Gets the record currently used
* *
@ -859,19 +881,11 @@ public class FFMPResource extends
if ((rateRecord == null) && isNewRate) { if ((rateRecord == null) && isNewRate) {
try { try {
String huc = getHucIfWorstCase();
if (isWorstCase()) { rateRecord = monitor.getRateRecord(getProduct(), getSiteKey(),
rateRecord = monitor.getRateRecord(getProduct(), getDataKey(), getPrimarySource(), recentTime, huc,
getSiteKey(), getDataKey(), getPrimarySource(), false);
recentTime, "ALL", false);
} else {
rateRecord = monitor.getRateRecord(getProduct(),
getSiteKey(), getDataKey(), getPrimarySource(),
recentTime, getHuc(), false);
}
isNewRate = false; isNewRate = false;
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }
@ -887,18 +901,10 @@ public class FFMPResource extends
public FFMPCacheRecord getQpeRecord() { public FFMPCacheRecord getQpeRecord() {
try { try {
if ((qpeRecord == null) && (getTableTime() != null) && isNewQpe) { if ((qpeRecord == null) && (getTableTime() != null) && isNewQpe) {
String huc = getHucIfWorstCase();
if (isWorstCase()) { qpeRecord = monitor.getQPERecord(getProduct(), getSiteKey(),
qpeRecord = monitor.getQPERecord(getProduct(), getDataKey(), getPrimarySource(), getTableTime(), huc,
getSiteKey(), getDataKey(), getPrimarySource(), false);
getTableTime(), "ALL", false);
} else {
qpeRecord = monitor.getQPERecord(getProduct(),
getSiteKey(), getDataKey(), getPrimarySource(),
getTableTime(), getHuc(), false);
}
isNewQpe = false; isNewQpe = false;
} }
} catch (Exception e) { } catch (Exception e) {
@ -930,16 +936,9 @@ public class FFMPResource extends
isStandAlone = true; isStandAlone = true;
} }
if (isWorstCase()) { String huc = getHucIfWorstCase();
guidRecord = monitor guidRecord = monitor.getGuidanceRecord(getProduct(),
.getGuidanceRecord(getProduct(), getSiteKey(), getSiteKey(), sourceName, date, huc, isStandAlone);
sourceName, date, "ALL", isStandAlone);
} else {
guidRecord = monitor.getGuidanceRecord(getProduct(),
getSiteKey(), sourceName, date, getHuc(),
isStandAlone);
}
isNewGuid = false; isNewGuid = false;
} }
@ -968,15 +967,9 @@ public class FFMPResource extends
} }
} }
qpfRecord = monitor String huc = getHucIfWorstCase();
.getQPFRecord(getProduct(), getSiteKey(), getDataKey(), qpfRecord = monitor.getQPFRecord(getProduct(), getSiteKey(),
getPrimarySource(), date, getHuc(), false); getDataKey(), getPrimarySource(), date, huc, false);
if (isWorstCase()) {
qpfRecord = monitor.getQPFRecord(getProduct(),
getSiteKey(), getDataKey(), getPrimarySource(),
date, "ALL", false);
}
isNewQpf = false; isNewQpf = false;
} }
} catch (Exception e) { } catch (Exception e) {
@ -996,7 +989,7 @@ public class FFMPResource extends
if ((virtualRecord == null) && isNewVirtual) { if ((virtualRecord == null) && isNewVirtual) {
virtualRecord = monitor.getVirtualRecord(getProduct(), virtualRecord = monitor.getVirtualRecord(getProduct(),
getSiteKey(), getDataKey(), getPrimarySource(), getSiteKey(), getDataKey(), getPrimarySource(),
getTableTime(), "ALL", false); getTableTime(), ALL, false);
isNewVirtual = false; isNewVirtual = false;
} }
@ -1191,7 +1184,8 @@ public class FFMPResource extends
FFMPDrawable drawable = null; FFMPDrawable drawable = null;
if (paintTime != null) { if (paintTime != null) {
if (loader != null && !loader.isDone && loader.loadType == LOADER_TYPE.GENERAL) { if (loader != null && !loader.isDone
&& loader.loadType == LOADER_TYPE.GENERAL) {
return; return;
} }
if (!drawables.containsKey(paintTime)) { if (!drawables.containsKey(paintTime)) {
@ -1201,7 +1195,7 @@ public class FFMPResource extends
} else { } else {
// we found it! // we found it!
drawable = drawables.get(paintTime); drawable = drawables.get(paintTime);
// System.out.println("Found the drawable"); // System.out.println("Found the drawable");
if (!paintTime.equals(drawable.getTime())) { if (!paintTime.equals(drawable.getTime())) {
drawable.setDirty(true); drawable.setDirty(true);
@ -1223,7 +1217,8 @@ public class FFMPResource extends
&& !paintTime.getRefTime().equals(getMostRecentTime())) { && !paintTime.getRefTime().equals(getMostRecentTime())) {
setMostRecentTime(paintTime.getRefTime()); setMostRecentTime(paintTime.getRefTime());
setTableTime(); setTableTime();
// if (isLinkToFrame && loader != null && loader.loadType != LOADER_TYPE.GENERAL) { // if (isLinkToFrame && loader != null && loader.loadType !=
// LOADER_TYPE.GENERAL) {
if (isLinkToFrame) { if (isLinkToFrame) {
updateDialog(); updateDialog();
} }
@ -1246,6 +1241,7 @@ public class FFMPResource extends
lastExtent = expandedExtent; lastExtent = expandedExtent;
} }
boolean isAllHuc = getHuc().equals(ALL);
for (DomainXML domain : getDomains()) { for (DomainXML domain : getDomains()) {
String cwa = domain.getCwa(); String cwa = domain.getCwa();
if (isShaded) { if (isShaded) {
@ -1295,9 +1291,8 @@ public class FFMPResource extends
} }
if ((lowestCenter == ZOOM.AGGREGATE) if ((lowestCenter == ZOOM.AGGREGATE)
|| (lowestCenter == ZOOM.BASIN) || (lowestCenter == ZOOM.BASIN) || isAllHuc
|| getHuc().equals("ALL") || this.isBasinToggle() || this.isBasinToggle() || isSmallBasins) {
|| isSmallBasins) {
if (isSmallBasins && this.isBasinToggle()) { if (isSmallBasins && this.isBasinToggle()) {
if ((smallBasinOverlayShape != null) if ((smallBasinOverlayShape != null)
@ -1334,31 +1329,29 @@ public class FFMPResource extends
if (centeredAggregationKey != null) { if (centeredAggregationKey != null) {
vgbDrawables.clear(); vgbDrawables.clear();
// create pixelCoverages for the VGB's // create pixelCoverages for the VGB's
if (lowestCenter == FFMPRecord.ZOOM.AGGREGATE) { if (isAllHuc) {
if (getHuc().equals("ALL")) { for (DomainXML domain : getDomains()) {
for (DomainXML domain : getDomains()) { for (Long pfaf : monitor
for (Long pfaf : monitor .getTemplates(getSiteKey())
.getMap(getSiteKey(), domain.getCwa(), getHuc())
.keySet()) {
ArrayList<FFMPVirtualGageBasinMetaData> fvgmdList = monitor
.getTemplates(getSiteKey()) .getTemplates(getSiteKey())
.getMap(getSiteKey(), domain.getCwa(), .getVirtualGageBasinMetaData(getSiteKey(),
getHuc()).keySet()) { domain.getCwa(), pfaf);
ArrayList<FFMPVirtualGageBasinMetaData> fvgmdList = monitor if (fvgmdList != null) {
.getTemplates(getSiteKey()) for (FFMPVirtualGageBasinMetaData fvgmd : fvgmdList) {
.getVirtualGageBasinMetaData( vgbDrawables.put(
getSiteKey(), domain.getCwa(), fvgmd.getLid(),
pfaf); getPixelCoverage(
if (fvgmdList != null) { fvgmd.getCoordinate(),
for (FFMPVirtualGageBasinMetaData fvgmd : fvgmdList) { paintProps));
vgbDrawables.put(
fvgmd.getLid(),
getPixelCoverage(
fvgmd.getCoordinate(),
paintProps));
}
} }
} }
} }
}
} else { } else {
if (lowestCenter == FFMPRecord.ZOOM.AGGREGATE) {
for (Long pfaf : monitor.getTemplates(getSiteKey()) for (Long pfaf : monitor.getTemplates(getSiteKey())
.getAllAggregatePfafs(centeredAggregationKey, .getAllAggregatePfafs(centeredAggregationKey,
getHuc())) { getHuc())) {
@ -1376,30 +1369,6 @@ public class FFMPResource extends
} }
} }
} }
}
} else {
if (getHuc().equals("ALL")) {
for (DomainXML domain : getDomains()) {
for (Long pfaf : monitor
.getTemplates(getSiteKey())
.getMap(getSiteKey(), domain.getCwa(),
getHuc()).keySet()) {
ArrayList<FFMPVirtualGageBasinMetaData> fvgmdList = monitor
.getTemplates(getSiteKey())
.getVirtualGageBasinMetaData(
getSiteKey(), domain.getCwa(),
pfaf);
if (fvgmdList != null) {
for (FFMPVirtualGageBasinMetaData fvgmd : fvgmdList) {
vgbDrawables.put(
fvgmd.getLid(),
getPixelCoverage(
fvgmd.getCoordinate(),
paintProps));
}
}
}
}
} else { } else {
for (DomainXML domain : getDomains()) { for (DomainXML domain : getDomains()) {
for (Entry<String, FFMPVirtualGageBasinMetaData> entry : monitor for (Entry<String, FFMPVirtualGageBasinMetaData> entry : monitor
@ -1604,7 +1573,7 @@ public class FFMPResource extends
try { try {
FFMPBasinMetaData metaBasin = monitor.getTemplates(getSiteKey()) FFMPBasinMetaData metaBasin = monitor.getTemplates(getSiteKey())
.findBasinByLatLon(getSiteKey(), coord.asLatLon()); .findBasinByLatLon(getSiteKey(), coord.asLatLon());
if (getHuc().equals("ALL") || centeredAggregationKey != null) { if (getHuc().equals(ALL) || centeredAggregationKey != null) {
pfaf = metaBasin.getPfaf(); pfaf = metaBasin.getPfaf();
if (isMaintainLayer) { if (isMaintainLayer) {
pfaf = monitor.getTemplates(getSiteKey()) pfaf = monitor.getTemplates(getSiteKey())
@ -1717,10 +1686,11 @@ public class FFMPResource extends
int mapWidth = getDescriptor().getMapWidth() / 1000; int mapWidth = getDescriptor().getMapWidth() / 1000;
FFMPTemplates templates = monitor.getTemplates(getSiteKey()); FFMPTemplates templates = monitor.getTemplates(getSiteKey());
String huc = getHuc(); String huc = getHuc();
boolean isAllHuc = huc.equals(ALL);
if (centeredAggregationKey == null) { if (centeredAggregationKey == null) {
centeredAggregationKey = fz.getKey(); centeredAggregationKey = fz.getKey();
if (!"ALL".equals(huc)) { if (!isAllHuc) {
center = templates.findAggregationCenter( center = templates.findAggregationCenter(
(Long) centeredAggregationKey, getSiteKey(), huc); (Long) centeredAggregationKey, getSiteKey(), huc);
@ -1732,7 +1702,7 @@ public class FFMPResource extends
getDescriptor().getRenderableDisplay().getExtent().reset(); getDescriptor().getRenderableDisplay().getExtent().reset();
float zoomLevel = 0.0f; float zoomLevel = 0.0f;
if (!getHuc().equals("ALL")) { if (!isAllHuc) {
if (lowestCenter == FFMPRecord.ZOOM.WFO) { if (lowestCenter == FFMPRecord.ZOOM.WFO) {
clearAllHuc(); clearAllHuc();
} }
@ -1749,7 +1719,7 @@ public class FFMPResource extends
} else if (!centeredAggregationKey.equals(fz.getKey())) { } else if (!centeredAggregationKey.equals(fz.getKey())) {
centeredAggregationKey = fz.getKey(); centeredAggregationKey = fz.getKey();
if (lowestCenter == FFMPRecord.ZOOM.WFO) { if (lowestCenter == FFMPRecord.ZOOM.WFO) {
if (!getHuc().equals("ALL")) { if (!isAllHuc) {
centeredAggregationKey = fz.getKey(); centeredAggregationKey = fz.getKey();
center = templates.findAggregationCenter( center = templates.findAggregationCenter(
(Long) centeredAggregationKey, getSiteKey(), (Long) centeredAggregationKey, getSiteKey(),
@ -1762,7 +1732,7 @@ public class FFMPResource extends
getDescriptor().getRenderableDisplay().getExtent().reset(); getDescriptor().getRenderableDisplay().getExtent().reset();
float zoomLevel = 0.0f; float zoomLevel = 0.0f;
if (!getHuc().equals("ALL")) { if (!isAllHuc) {
clearTables(); clearTables();
lowestCenter = FFMPRecord.ZOOM.AGGREGATE; lowestCenter = FFMPRecord.ZOOM.AGGREGATE;
zoomLevel = (float) AGGREGATE_ZOOM / mapWidth; zoomLevel = (float) AGGREGATE_ZOOM / mapWidth;
@ -1798,8 +1768,7 @@ public class FFMPResource extends
} }
// stops the annoying wait cursor every time you re-center // stops the annoying wait cursor every time you re-center
if (getHuc().equals("ALL") if (isAllHuc || (lowestCenter == FFMPRecord.ZOOM.BASIN)) {
|| (lowestCenter == FFMPRecord.ZOOM.BASIN)) {
basinTableDlg.getShell().setCursor(null); basinTableDlg.getShell().setCursor(null);
} }
} }
@ -1874,12 +1843,11 @@ public class FFMPResource extends
ArrayList<Float> guids = null; ArrayList<Float> guids = null;
if ((getQpeRecord() != null) if ((getQpeRecord() != null)
&& (getGuidanceRecord() != null)) { && (getGuidanceRecord() != null)) {
qpes = getQpeRecord().getBasinData("ALL") qpes = getQpeRecord().getBasinData(ALL).getAccumValues(
.getAccumValues(pfafs, getTableTime(), pfafs, getTableTime(), recentTime,
recentTime, getQpeSourceExpiration(), getQpeSourceExpiration(), isRate());
isRate());
guids = getGuidanceRecord().getBasinData("ALL") guids = getGuidanceRecord().getBasinData(ALL)
.getGuidanceValues(pfafs, .getGuidanceValues(pfafs,
getGuidanceInterpolation(getFFGName()), getGuidanceInterpolation(getFFGName()),
getGuidSourceExpiration()); getGuidSourceExpiration());
@ -1911,14 +1879,14 @@ public class FFMPResource extends
} else { } else {
if ((getQpeRecord() != null) && (getGuidanceRecord() != null)) { if ((getQpeRecord() != null) && (getGuidanceRecord() != null)) {
qpe = getQpeRecord() qpe = getQpeRecord()
.getBasinData("ALL") .getBasinData(ALL)
.get(key) .get(key)
.getAccumValue(getTableTime(), recentTime, .getAccumValue(getTableTime(), recentTime,
getQpeSourceExpiration(), isRate()); getQpeSourceExpiration(), isRate());
guid = getGuidanceValue( guid = getGuidanceValue(
(FFMPGuidanceBasin) getGuidanceRecord() (FFMPGuidanceBasin) getGuidanceRecord()
.getBasinData("ALL").get(key), recentTime, .getBasinData(ALL).get(key), recentTime,
getFFGName()); getFFGName());
guid = forceValue(pfafs, guid = forceValue(pfafs,
getBasin(key, getField(), recentTime, aggregate), getBasin(key, getField(), recentTime, aggregate),
@ -1952,13 +1920,12 @@ public class FFMPResource extends
ArrayList<Float> qpes = null; ArrayList<Float> qpes = null;
ArrayList<Float> guids = null; ArrayList<Float> guids = null;
if (getQpeRecord() != null) { if (getQpeRecord() != null) {
qpes = getQpeRecord().getBasinData("ALL") qpes = getQpeRecord().getBasinData(ALL).getAccumValues(
.getAccumValues(pfafs, getTableTime(), pfafs, getTableTime(), recentTime,
recentTime, getQpeSourceExpiration(), getQpeSourceExpiration(), isRate());
isRate());
} }
if (getGuidanceRecord() != null) { if (getGuidanceRecord() != null) {
guids = getGuidanceRecord().getBasinData("ALL") guids = getGuidanceRecord().getBasinData(ALL)
.getGuidanceValues(pfafs, .getGuidanceValues(pfafs,
getGuidanceInterpolation(getFFGName()), getGuidanceInterpolation(getFFGName()),
getGuidSourceExpiration()); getGuidSourceExpiration());
@ -1988,13 +1955,13 @@ public class FFMPResource extends
} else { } else {
if ((getQpeRecord() != null) && (getGuidanceRecord() != null)) { if ((getQpeRecord() != null) && (getGuidanceRecord() != null)) {
qpe = getQpeRecord() qpe = getQpeRecord()
.getBasinData("ALL") .getBasinData(ALL)
.get(key) .get(key)
.getAccumValue(getTableTime(), recentTime, .getAccumValue(getTableTime(), recentTime,
getQpeSourceExpiration(), isRate()); getQpeSourceExpiration(), isRate());
guid = getGuidanceValue( guid = getGuidanceValue(
(FFMPGuidanceBasin) getGuidanceRecord() (FFMPGuidanceBasin) getGuidanceRecord()
.getBasinData("ALL").get(key), recentTime, .getBasinData(ALL).get(key), recentTime,
getFFGName()); getFFGName());
ratio = FFMPUtils.getRatioValue(qpe, guid); ratio = FFMPUtils.getRatioValue(qpe, guid);
} }
@ -2067,7 +2034,7 @@ public class FFMPResource extends
public void clearAllHuc() { public void clearAllHuc() {
if (drawables != null) { if (drawables != null) {
for (Entry<DataTime, FFMPDrawable> entry : drawables.entrySet()) { for (Entry<DataTime, FFMPDrawable> entry : drawables.entrySet()) {
entry.getValue().removeTable("ALL"); entry.getValue().removeTable(ALL);
} }
} }
} }
@ -2219,7 +2186,7 @@ public class FFMPResource extends
for (DomainXML domain : getDomains()) { for (DomainXML domain : getDomains()) {
try { try {
Map<Long, Geometry> map = hucGeomFactory.getGeometries( Map<Long, Geometry> map = hucGeomFactory.getGeometries(
templates, getSiteKey(), domain.getCwa(), "ALL"); templates, getSiteKey(), domain.getCwa(), ALL);
if (map.containsKey(pfaf)) { if (map.containsKey(pfaf)) {
center = map.get(pfaf).getCentroid().getCoordinate(); center = map.get(pfaf).getCentroid().getCoordinate();
@ -2359,40 +2326,40 @@ public class FFMPResource extends
private float getVGBValue(Long pfaf, Date recentTime) { private float getVGBValue(Long pfaf, Date recentTime) {
float value = 0.0f; float value = 0.0f;
if (getField() == FIELDS.RATE) { if (getField() == FIELDS.RATE) {
value = getVirtualRecord().getBasinsMap().get("ALL").get(pfaf) value = getVirtualRecord().getBasinsMap().get(ALL).get(pfaf)
.getValue(recentTime); .getValue(recentTime);
} else if (getField() == FIELDS.QPE) { } else if (getField() == FIELDS.QPE) {
value = getVirtualRecord() value = getVirtualRecord()
.getBasinsMap() .getBasinsMap()
.get("ALL") .get(ALL)
.get(pfaf) .get(pfaf)
.getAccumValue(getTableTime(), getMostRecentTime(), .getAccumValue(getTableTime(), getMostRecentTime(),
getQpeSourceExpiration(), isRate()); getQpeSourceExpiration(), isRate());
} else if (getField() == FIELDS.RATIO) { } else if (getField() == FIELDS.RATIO) {
float qpe = getVirtualRecord() float qpe = getVirtualRecord()
.getBasinsMap() .getBasinsMap()
.get("ALL") .get(ALL)
.get(pfaf) .get(pfaf)
.getAccumValue(getTableTime(), getMostRecentTime(), .getAccumValue(getTableTime(), getMostRecentTime(),
getQpeSourceExpiration(), isRate()); getQpeSourceExpiration(), isRate());
float guidance = getGuidanceValue( float guidance = getGuidanceValue(
((FFMPGuidanceBasin) getGuidanceRecord().getBasinsMap() ((FFMPGuidanceBasin) getGuidanceRecord().getBasinsMap()
.get("ALL").get(pfaf)), recentTime, getFFGName()); .get(ALL).get(pfaf)), recentTime, getFFGName());
value = FFMPUtils.getRatioValue(qpe, guidance); value = FFMPUtils.getRatioValue(qpe, guidance);
} else if (getField() == FIELDS.DIFF) { } else if (getField() == FIELDS.DIFF) {
float qpe = getVirtualRecord() float qpe = getVirtualRecord()
.getBasinsMap() .getBasinsMap()
.get("ALL") .get(ALL)
.get(pfaf) .get(pfaf)
.getAccumValue(getTableTime(), getMostRecentTime(), .getAccumValue(getTableTime(), getMostRecentTime(),
getQpeSourceExpiration(), isRate()); getQpeSourceExpiration(), isRate());
float guidance = getGuidanceValue( float guidance = getGuidanceValue(
((FFMPGuidanceBasin) getGuidanceRecord().getBasinsMap() ((FFMPGuidanceBasin) getGuidanceRecord().getBasinsMap()
.get("ALL").get(pfaf)), recentTime, getFFGName()); .get(ALL).get(pfaf)), recentTime, getFFGName());
value = FFMPUtils.getDiffValue(qpe, guidance); value = FFMPUtils.getDiffValue(qpe, guidance);
} else if (getField() == FIELDS.GUIDANCE) { } else if (getField() == FIELDS.GUIDANCE) {
value = getGuidanceValue(((FFMPGuidanceBasin) getGuidanceRecord() value = getGuidanceValue(((FFMPGuidanceBasin) getGuidanceRecord()
.getBasinsMap().get("ALL").get(pfaf)), recentTime, .getBasinsMap().get(ALL).get(pfaf)), recentTime,
getFFGName()); getFFGName());
} }
return value; return value;
@ -2542,6 +2509,7 @@ public class FFMPResource extends
.getTemplates(getSiteKey()); .getTemplates(getSiteKey());
String phuc = getHuc(); String phuc = getHuc();
boolean isAllPhuc = phuc.equals(ALL);
FIELDS field = getField(); FIELDS field = getField();
if (getResourceData().tableLoad) { if (getResourceData().tableLoad) {
@ -2563,16 +2531,7 @@ public class FFMPResource extends
.isWorstCase())); .isWorstCase()));
if (globalRegen) { if (globalRegen) {
rateRecord = null; resetRecords();
isNewRate = true;
qpfRecord = null;
isNewQpf = true;
qpeRecord = null;
isNewQpe = true;
guidRecord = null;
isNewGuid = true;
virtualRecord = null;
isNewVirtual = true;
} }
for (DomainXML domain : getDomains()) { for (DomainXML domain : getDomains()) {
@ -2598,7 +2557,7 @@ public class FFMPResource extends
pfafsToProcess = cwaPfafs; pfafsToProcess = cwaPfafs;
} else { } else {
// center selected, determine center key // center selected, determine center key
if (!phuc.equals("ALL")) { if (!isAllPhuc) {
if (centeredAggregationKey instanceof String) { if (centeredAggregationKey instanceof String) {
if (lowestCenter != ZOOM.BASIN) { if (lowestCenter != ZOOM.BASIN) {
@ -2661,7 +2620,7 @@ public class FFMPResource extends
HashMap<Object, RGB> colorMap = new HashMap<Object, RGB>(); HashMap<Object, RGB> colorMap = new HashMap<Object, RGB>();
String shadedHuc = null; String shadedHuc = null;
if (!phuc.equals("ALL")) { if (!isAllPhuc) {
Map<Long, Geometry> geomMap = hucGeomFactory Map<Long, Geometry> geomMap = hucGeomFactory
.getGeometries(templates, .getGeometries(templates,
@ -2670,28 +2629,19 @@ public class FFMPResource extends
for (Long pfaf : pfafsToProcess) { for (Long pfaf : pfafsToProcess) {
if (!isMaintainLayer() && isParent() if (!isMaintainLayer() && isParent()
&& !"ALL".equals(phuc)
&& pfaf.equals(centeredAggr)) { && pfaf.equals(centeredAggr)) {
// add centered aggr to shape // add centered aggr to shape
Collection<Long> allPfafs = null; Collection<Long> allPfafs = null;
if (!"ALL".equals(phuc)) { if (isParent()) {
allPfafs = templates.getMap(
if (isParent()) { getSiteKey(), cwa, ALL)
allPfafs = templates .keySet();
.getMap(getSiteKey(),
cwa, "ALL")
.keySet();
} else {
allPfafs = (List<Long>) (templates
.getMap(getSiteKey(),
cwa, phuc)
.get(centeredAggr));
}
} else { } else {
allPfafs = new ArrayList<Long>( allPfafs = (List<Long>) (templates
1); .getMap(getSiteKey(),
allPfafs.add(centeredAggr); cwa, phuc)
.get(centeredAggr));
} }
if (allPfafs != null) { if (allPfafs != null) {
@ -2699,29 +2649,29 @@ public class FFMPResource extends
.getGeometries( .getGeometries(
templates, templates,
getSiteKey(), getSiteKey(),
cwa, "ALL"); cwa, ALL);
IColormapShadedShape shape = shadedShapes IColormapShadedShape shape = shadedShapes
.getShape(cwa, "ALL", .getShape(cwa, ALL,
req.target, req.target,
descriptor); descriptor);
shadedHuc = "ALL"; shadedHuc = ALL;
for (Long allPfaf : allPfafs) { for (Long allPfaf : allPfafs) {
generateShapes(templates, generateShapes(templates,
"ALL", allPfaf, ALL, allPfaf,
allGeomMap, req, allGeomMap, req,
shape, colorMap); shape, colorMap);
} }
} }
} else if (!isMaintainLayer() } else if (!isMaintainLayer()
&& !isParent() && !isParent()
&& !"ALL".equals(phuc) && !ALL.equals(phuc)
&& pfaf.equals(centeredAggr)) { && pfaf.equals(centeredAggr)) {
Collection<Long> allPfafs = templates Collection<Long> allPfafs = templates
.getMap(getSiteKey(), cwa, .getMap(getSiteKey(), cwa,
"ALL").keySet(); ALL).keySet();
if (allPfafs != null) { if (allPfafs != null) {
@ -2729,19 +2679,19 @@ public class FFMPResource extends
.getGeometries( .getGeometries(
templates, templates,
getSiteKey(), getSiteKey(),
cwa, "ALL"); cwa, ALL);
IColormapShadedShape shape = shadedShapes IColormapShadedShape shape = shadedShapes
.getShape(cwa, "ALL", .getShape(cwa, ALL,
req.target, req.target,
descriptor); descriptor);
shadedHuc = "ALL"; shadedHuc = ALL;
for (Long allPfaf : allPfafs) { for (Long allPfaf : allPfafs) {
generateShapes(templates, generateShapes(templates,
"ALL", allPfaf, ALL, allPfaf,
allGeomMap, req, allGeomMap, req,
shape, colorMap); shape, colorMap);
} }
@ -2768,17 +2718,16 @@ public class FFMPResource extends
Map<Long, Geometry> allGeomMap = hucGeomFactory Map<Long, Geometry> allGeomMap = hucGeomFactory
.getGeometries(templates, .getGeometries(templates,
getSiteKey(), cwa, getSiteKey(), cwa, ALL);
"ALL");
IColormapShadedShape shape = shadedShapes IColormapShadedShape shape = shadedShapes
.getShape(cwa, "ALL", .getShape(cwa, ALL, req.target,
req.target, descriptor); descriptor);
shadedHuc = "ALL"; shadedHuc = ALL;
for (Long allPfaf : pfafsToProcess) { for (Long allPfaf : pfafsToProcess) {
generateShapes(templates, "ALL", generateShapes(templates, ALL,
allPfaf, allGeomMap, req, allPfaf, allGeomMap, req,
shape, colorMap); shape, colorMap);
} }
@ -2894,7 +2843,7 @@ public class FFMPResource extends
try { try {
color = getColor(pfaf, req.time.getRefTime(), color = getColor(pfaf, req.time.getRefTime(),
!"ALL".equals(huc)); !ALL.equals(huc));
if (color != null) { if (color != null) {
if (!shape.getColorKeys().contains(pfaf)) { if (!shape.getColorKeys().contains(pfaf)) {
@ -2969,7 +2918,7 @@ public class FFMPResource extends
Map<Long, Geometry> geomMap = hucGeomFactory Map<Long, Geometry> geomMap = hucGeomFactory
.getGeometries(templates, getSiteKey(), cwa, .getGeometries(templates, getSiteKey(), cwa,
"ALL"); ALL);
for (Long pfaf : streamPfafIds) { for (Long pfaf : streamPfafIds) {
// TODO: streamPfafIds should be ordered by // TODO: streamPfafIds should be ordered by
@ -3028,7 +2977,7 @@ public class FFMPResource extends
for (DomainXML domains : templates.getDomains()) { for (DomainXML domains : templates.getDomains()) {
String cwa = domains.getCwa(); String cwa = domains.getCwa();
Map<Long, Geometry> geomMap = hucGeomFactory.getGeometries( Map<Long, Geometry> geomMap = hucGeomFactory.getGeometries(
templates, getSiteKey(), cwa, "ALL"); templates, getSiteKey(), cwa, ALL);
if (geomMap != null) { if (geomMap != null) {
for (Long pfaf : geomMap.keySet()) { for (Long pfaf : geomMap.keySet()) {
@ -3309,7 +3258,7 @@ public class FFMPResource extends
try { try {
rateBasin = monitor.getGraphRateBasin(getProduct(), getSiteKey(), rateBasin = monitor.getGraphRateBasin(getProduct(), getSiteKey(),
getDataKey(), fvgbmd == null ? getProduct().getRate() getDataKey(), fvgbmd == null ? getProduct().getRate()
: getProduct().getVirtual(), oldestRefTime, "ALL", : getProduct().getVirtual(), oldestRefTime, ALL,
dataId); dataId);
ArrayList<Double> rateTimes = new ArrayList<Double>(); ArrayList<Double> rateTimes = new ArrayList<Double>();
@ -3333,13 +3282,13 @@ public class FFMPResource extends
try { try {
qpeBasin = monitor.getGraphQPEBasin(getProduct(), getSiteKey(), qpeBasin = monitor.getGraphQPEBasin(getProduct(), getSiteKey(),
getDataKey(), fvgbmd == null ? getProduct().getQpe() getDataKey(), fvgbmd == null ? getProduct().getQpe()
: getProduct().getVirtual(), oldestRefTime, "ALL", : getProduct().getVirtual(), oldestRefTime, ALL,
dataId); dataId);
ArrayList<Double> qpeTimes = new ArrayList<Double>(); ArrayList<Double> qpeTimes = new ArrayList<Double>();
if (qpeBasin != null) { if (qpeBasin != null) {
for (Date date : qpeBasin.getValues().keySet()) { for (Date date : qpeBasin.getValues().keySet()) {
double dtime = FFMPGuiUtils.getTimeDiff(mostRecentRefTime, double dtime = FFMPGuiUtils.getTimeDiff(mostRecentRefTime,
@ -3363,7 +3312,7 @@ public class FFMPResource extends
try { try {
qpfBasin = monitor.getGraphQPFBasin(getProduct(), getSiteKey(), qpfBasin = monitor.getGraphQPFBasin(getProduct(), getSiteKey(),
getDataKey(), null, oldestRefTime, "ALL", basinPfaf); getDataKey(), null, oldestRefTime, ALL, basinPfaf);
Float qpfFloat = qpfBasin.getValue(monitor.getQpfWindow() Float qpfFloat = qpfBasin.getValue(monitor.getQpfWindow()
.getBeforeTime(), monitor.getQpfWindow().getAfterTime()); .getBeforeTime(), monitor.getQpfWindow().getAfterTime());
@ -3408,7 +3357,7 @@ public class FFMPResource extends
guidBasin = (FFMPGuidanceBasin) monitor.getGraphGuidanceBasin( guidBasin = (FFMPGuidanceBasin) monitor.getGraphGuidanceBasin(
getProduct(), getSiteKey(), getDataKey(), null, getProduct(), getSiteKey(), getDataKey(), null,
oldestRefTime, "ALL", basinPfaf); oldestRefTime, ALL, basinPfaf);
ArrayList<Double> guidTimes = new ArrayList<Double>(); ArrayList<Double> guidTimes = new ArrayList<Double>();
for (SourceXML ffgSource : getProduct().getGuidanceSourcesByType( for (SourceXML ffgSource : getProduct().getGuidanceSourcesByType(
ffgGraphType)) { ffgGraphType)) {
@ -3597,7 +3546,7 @@ public class FFMPResource extends
if (tableTime == null) { if (tableTime == null) {
tableTime = new Date(); tableTime = new Date();
} }
synchronized (tableTime) { synchronized (tableTime) {
Date recentTime = getMostRecentTime(); Date recentTime = getMostRecentTime();
long time = new Double(recentTime.getTime() - (1000 * 3600) long time = new Double(recentTime.getTime() - (1000 * 3600)
@ -3766,7 +3715,7 @@ public class FFMPResource extends
public synchronized ArrayList<Date> getTimeOrderedKeys() { public synchronized ArrayList<Date> getTimeOrderedKeys() {
if (timeOrderedKeys == null || !toKeysInitialized) { if (timeOrderedKeys == null || !toKeysInitialized) {
toKeysInitialized = true; toKeysInitialized = true;
// stand alone displays use this // stand alone displays use this
timeOrderedKeys = new ArrayList<Date>(); timeOrderedKeys = new ArrayList<Date>();
@ -4254,7 +4203,7 @@ public class FFMPResource extends
ArrayList<String> hucsToLoad = new ArrayList<String>(); ArrayList<String> hucsToLoad = new ArrayList<String>();
if (isWorstCase) { if (isWorstCase) {
hucsToLoad.add("ALL"); hucsToLoad.add(ALL);
} }
// tertiary loader only loads ALL // tertiary loader only loads ALL
@ -4263,8 +4212,8 @@ public class FFMPResource extends
hucsToLoad.add(getHuc()); hucsToLoad.add(getHuc());
} }
} else { } else {
if (!hucsToLoad.contains("ALL")) { if (!hucsToLoad.contains(ALL)) {
hucsToLoad.add("ALL"); hucsToLoad.add(ALL);
} }
} }
// destroy any old loader // destroy any old loader