Omaha #3170 get accum value from multiple times if they are requested in FFMP geometry factory
Change-Id: Ia7759a942ec078ec5ce72b6c0007629e263d8a4a Former-commit-id:983c2c71e0
[formerly983c2c71e0
[formerly 2f027b86244a3080a62c02cc816dcdca59e4538f]] Former-commit-id:f31bf67cca
Former-commit-id:d4609b08d9
This commit is contained in:
parent
a43a3a94c7
commit
1be462cc91
1 changed files with 46 additions and 10 deletions
|
@ -50,6 +50,7 @@ import com.raytheon.uf.common.monitor.xml.SourceXML;
|
||||||
import com.raytheon.uf.common.status.IUFStatusHandler;
|
import com.raytheon.uf.common.status.IUFStatusHandler;
|
||||||
import com.raytheon.uf.common.status.UFStatus;
|
import com.raytheon.uf.common.status.UFStatus;
|
||||||
import com.raytheon.uf.common.status.UFStatus.Priority;
|
import com.raytheon.uf.common.status.UFStatus.Priority;
|
||||||
|
import com.raytheon.uf.common.time.TimeRange;
|
||||||
import com.vividsolutions.jts.geom.Geometry;
|
import com.vividsolutions.jts.geom.Geometry;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -68,6 +69,7 @@ import com.vividsolutions.jts.geom.Geometry;
|
||||||
* Jan,14, 2014 2667 mnash Remove getGridData method
|
* Jan,14, 2014 2667 mnash Remove getGridData method
|
||||||
* May 1, 2014 3099 bkowal No longer use an empty pfaf list when the
|
* May 1, 2014 3099 bkowal No longer use an empty pfaf list when the
|
||||||
* data request locationNames list is empty.
|
* data request locationNames list is empty.
|
||||||
|
* Jun 24, 2014 3170 mnash Get the accumulated time if multiple times are requested
|
||||||
*
|
*
|
||||||
* </pre>
|
* </pre>
|
||||||
*
|
*
|
||||||
|
@ -114,10 +116,25 @@ public class FFMPGeometryFactory extends AbstractDataPluginFactory {
|
||||||
DbQueryResponse dbQueryResponse) {
|
DbQueryResponse dbQueryResponse) {
|
||||||
List<Map<String, Object>> results = dbQueryResponse.getResults();
|
List<Map<String, Object>> results = dbQueryResponse.getResults();
|
||||||
Map<Long, DefaultGeometryData> cache = new HashMap<Long, DefaultGeometryData>();
|
Map<Long, DefaultGeometryData> cache = new HashMap<Long, DefaultGeometryData>();
|
||||||
|
FFMPRecord record = null;
|
||||||
|
TimeRange range = new TimeRange();
|
||||||
for (Map<String, Object> map : results) {
|
for (Map<String, Object> map : results) {
|
||||||
for (Map.Entry<String, Object> es : map.entrySet()) {
|
for (Map.Entry<String, Object> es : map.entrySet()) {
|
||||||
FFMPRecord rec = (FFMPRecord) es.getValue();
|
FFMPRecord rec = (FFMPRecord) es.getValue();
|
||||||
|
// Adding all of the basin data to a single record so that we
|
||||||
|
// can get the accumulated values from that record
|
||||||
|
if (record == null) {
|
||||||
|
record = rec;
|
||||||
|
}
|
||||||
|
// building a time range of the earliest FFMP time (based on
|
||||||
|
// each record) to the latest FFMP time (based on each record)
|
||||||
|
if (range.getStart().after(rec.getDataTime().getRefTime())) {
|
||||||
|
range.setStart(rec.getDataTime().getRefTime());
|
||||||
|
}
|
||||||
|
if (range.getEnd().before(rec.getDataTime().getRefTime())) {
|
||||||
|
range.setEnd(rec.getDataTime().getRefTime());
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
rec.retrieveMapFromDataStore(templates);
|
rec.retrieveMapFromDataStore(templates);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
@ -126,15 +143,30 @@ public class FFMPGeometryFactory extends AbstractDataPluginFactory {
|
||||||
+ rec.toString(), e);
|
+ rec.toString(), e);
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
// loop over each pfaf id in the current record (rec) we are
|
||||||
cache = makeGeometryData(rec, request, cache);
|
// iterating.
|
||||||
} catch (Exception e) {
|
// Add that basin data to the record that we are keeping around
|
||||||
statusHandler.handle(Priority.PROBLEM,
|
// (record)
|
||||||
e.getLocalizedMessage(), e);
|
// to use to get the accumulated value.
|
||||||
|
for (Long pfaf : rec.getBasinData().getPfafIds()) {
|
||||||
|
// setValue is a misnomer here, it is actually an add
|
||||||
|
record.getBasinData()
|
||||||
|
.get(pfaf)
|
||||||
|
.setValue(rec.getDataTime().getRefTime(),
|
||||||
|
rec.getBasinData().get(pfaf).getValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// now that we have all the basin data in a single record (record), we
|
||||||
|
// can use the methods on the FFMPRecord class to get the accumulated
|
||||||
|
// value in the case of a non-guidance basin
|
||||||
|
try {
|
||||||
|
cache = makeGeometryData(record, request, cache, range);
|
||||||
|
} catch (Exception e) {
|
||||||
|
statusHandler.handle(Priority.PROBLEM,
|
||||||
|
"Unable to create the geoemtry data from the records.", e);
|
||||||
|
}
|
||||||
return cache.values().toArray(
|
return cache.values().toArray(
|
||||||
new DefaultGeometryData[cache.values().size()]);
|
new DefaultGeometryData[cache.values().size()]);
|
||||||
}
|
}
|
||||||
|
@ -189,8 +221,8 @@ public class FFMPGeometryFactory extends AbstractDataPluginFactory {
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
private Map<Long, DefaultGeometryData> makeGeometryData(FFMPRecord rec,
|
private Map<Long, DefaultGeometryData> makeGeometryData(FFMPRecord rec,
|
||||||
IDataRequest request, Map<Long, DefaultGeometryData> cache)
|
IDataRequest request, Map<Long, DefaultGeometryData> cache,
|
||||||
throws Exception {
|
TimeRange range) throws Exception {
|
||||||
String huc = (String) request.getIdentifiers().get(HUC);
|
String huc = (String) request.getIdentifiers().get(HUC);
|
||||||
String dataKey = (String) request.getIdentifiers().get(DATA_KEY);
|
String dataKey = (String) request.getIdentifiers().get(DATA_KEY);
|
||||||
String siteKey = (String) request.getIdentifiers().get(SITE_KEY);
|
String siteKey = (String) request.getIdentifiers().get(SITE_KEY);
|
||||||
|
@ -258,7 +290,11 @@ public class FFMPGeometryFactory extends AbstractDataPluginFactory {
|
||||||
value = ((FFMPGuidanceBasin) basin).getValue(
|
value = ((FFMPGuidanceBasin) basin).getValue(
|
||||||
rec.getSourceName(), 1000);
|
rec.getSourceName(), 1000);
|
||||||
} else {
|
} else {
|
||||||
value = basin.getValue(rec.getDataTime().getRefTime());
|
value = basin.getAccumValue(range.getStart(),
|
||||||
|
range.getEnd(),
|
||||||
|
sourceXml.getExpirationMinutes(rec.getSiteKey()),
|
||||||
|
false);
|
||||||
|
// value = basin.getValue(rec.getDataTime().getRefTime());
|
||||||
}
|
}
|
||||||
String parameter = rec.getSourceName();
|
String parameter = rec.getSourceName();
|
||||||
String unitStr = sourceXml.getUnit();
|
String unitStr = sourceXml.getUnit();
|
||||||
|
|
Loading…
Add table
Reference in a new issue