Merge "Omaha #3170 add data times to ffmp geometries being returned, also aggregate data as it is more useful that way" into omaha_14.4.1
Former-commit-id:3ea3cfe6c3
[formerlyd977dbfcb0
] [formerly1fd0ed2de6
] [formerly3a2558eac8
[formerly1fd0ed2de6
[formerly fbc9b64a0c0734e46ec9db10e0760aa8f2b27c24]]] Former-commit-id:3a2558eac8
Former-commit-id: e5bf64a127cdcb0adf234dadad07bb06b81d9133 [formerlybb8918e96b
] Former-commit-id:2781d227f3
This commit is contained in:
commit
3232793b13
1 changed files with 28 additions and 19 deletions
|
@ -20,6 +20,7 @@
|
|||
package com.raytheon.uf.common.dataplugin.ffmp.dataaccess;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
@ -52,6 +53,7 @@ import com.raytheon.uf.common.monitor.xml.SourceXML;
|
|||
import com.raytheon.uf.common.status.IUFStatusHandler;
|
||||
import com.raytheon.uf.common.status.UFStatus;
|
||||
import com.raytheon.uf.common.status.UFStatus.Priority;
|
||||
import com.raytheon.uf.common.time.DataTime;
|
||||
import com.raytheon.uf.common.time.TimeRange;
|
||||
import com.vividsolutions.jts.geom.Geometry;
|
||||
|
||||
|
@ -121,22 +123,26 @@ public class FFMPGeometryFactory extends AbstractDataPluginFactory {
|
|||
List<Map<String, Object>> results = dbQueryResponse.getResults();
|
||||
Map<Long, DefaultGeometryData> cache = new HashMap<Long, DefaultGeometryData>();
|
||||
FFMPRecord record = null;
|
||||
TimeRange range = new TimeRange();
|
||||
Date start = new Date(Long.MAX_VALUE);
|
||||
Date end = new Date(0);
|
||||
|
||||
for (Map<String, Object> map : results) {
|
||||
for (Map.Entry<String, Object> es : map.entrySet()) {
|
||||
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
|
||||
/*
|
||||
* 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 (start.after(rec.getDataTime().getRefTime())) {
|
||||
start = rec.getDataTime().getRefTime();
|
||||
}
|
||||
if (range.getEnd().before(rec.getDataTime().getRefTime())) {
|
||||
range.setEnd(rec.getDataTime().getRefTime());
|
||||
if (end.before(rec.getDataTime().getRefTime())) {
|
||||
end = rec.getDataTime().getRefTime();
|
||||
}
|
||||
|
||||
try {
|
||||
|
@ -147,11 +153,11 @@ public class FFMPGeometryFactory extends AbstractDataPluginFactory {
|
|||
+ rec.toString(), e);
|
||||
}
|
||||
|
||||
// loop over each pfaf id in the current record (rec) we are
|
||||
// iterating.
|
||||
// Add that basin data to the record that we are keeping around
|
||||
// (record)
|
||||
// to use to get the accumulated value.
|
||||
/*
|
||||
* loop over each pfaf id in the current record (rec) we are
|
||||
* iterating. Add that basin data to the record that we are
|
||||
* keeping around (record) 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()
|
||||
|
@ -162,11 +168,13 @@ public class FFMPGeometryFactory extends AbstractDataPluginFactory {
|
|||
|
||||
}
|
||||
}
|
||||
// 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
|
||||
/*
|
||||
* 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);
|
||||
cache = makeGeometryData(record, request, cache, start, end);
|
||||
} catch (Exception e) {
|
||||
statusHandler.handle(Priority.PROBLEM,
|
||||
"Unable to create the geoemtry data from the records.", e);
|
||||
|
@ -226,7 +234,7 @@ public class FFMPGeometryFactory extends AbstractDataPluginFactory {
|
|||
*/
|
||||
private Map<Long, DefaultGeometryData> makeGeometryData(FFMPRecord rec,
|
||||
IDataRequest request, Map<Long, DefaultGeometryData> cache,
|
||||
TimeRange range) throws Exception {
|
||||
Date start, Date end) throws Exception {
|
||||
String huc = (String) request.getIdentifiers().get(HUC);
|
||||
String dataKey = (String) request.getIdentifiers().get(DATA_KEY);
|
||||
String siteKey = (String) request.getIdentifiers().get(SITE_KEY);
|
||||
|
@ -275,6 +283,8 @@ public class FFMPGeometryFactory extends AbstractDataPluginFactory {
|
|||
data.setAttributes(attrs);
|
||||
data.setLocationName(String.valueOf(pfaf));
|
||||
data.setGeometry(geomMap.get(pfaf));
|
||||
data.setDataTime(new DataTime(start.getTime(),
|
||||
new TimeRange(start, end)));
|
||||
cache.put(pfaf, data);
|
||||
}
|
||||
|
||||
|
@ -294,8 +304,7 @@ public class FFMPGeometryFactory extends AbstractDataPluginFactory {
|
|||
value = ((FFMPGuidanceBasin) basin).getValue(
|
||||
rec.getSourceName(), 1000);
|
||||
} else {
|
||||
value = basin.getAccumValue(range.getStart(),
|
||||
range.getEnd(),
|
||||
value = basin.getAccumValue(start, end,
|
||||
sourceXml.getExpirationMinutes(rec.getSiteKey()),
|
||||
false);
|
||||
// value = basin.getValue(rec.getDataTime().getRefTime());
|
||||
|
|
Loading…
Add table
Reference in a new issue