Merge "Issue #1358 fix forced basins and ffmp loading rfc ffg on startup." into development

Former-commit-id: b214d90785 [formerly 54aae6718e] [formerly d1921c3844] [formerly 9e4c3f558b [formerly d1921c3844 [formerly 3006a86880455b6ff08c8200f51ed019699b2b3d]]]
Former-commit-id: 9e4c3f558b
Former-commit-id: eb3c0ea771b9f6c705fd13762a98cec136a5e611 [formerly b0ef0284e1]
Former-commit-id: 569e19e755
This commit is contained in:
Richard Peter 2012-11-28 17:01:55 -06:00 committed by Gerrit Code Review
commit 2020246a03
3 changed files with 58 additions and 40 deletions

View file

@ -100,7 +100,7 @@ public class FFMPGuidanceBasin extends FFMPBasin implements ISerializableObject
return Float.NaN;
}
}
/**
* purge out old entries
*
@ -178,14 +178,14 @@ public class FFMPGuidanceBasin extends FFMPBasin implements ISerializableObject
return val;
}
/**
* Gets a Value for a FFG source
*
* @param date
* @return
*/
public Float getValue(String sourceName,
public Float getValue(String sourceName,
FFMPGuidanceInterpolation interpolation, long expiration) {
Float dvalue = Float.NaN;
@ -209,23 +209,23 @@ public class FFMPGuidanceBasin extends FFMPBasin implements ISerializableObject
*/
public Float getValue(String sourceName, Date date,
FFMPGuidanceInterpolation interpolation, long expiration) {
Float dvalue = Float.NaN;
Float value = Float.NaN;
Date closestDate = getClosest(sourceName, date, expiration);
if (closestDate != null) {
value = getValue(closestDate, sourceName);
}
if (!value.isNaN()) {
FFFGDataMgr dman = FFFGDataMgr.getInstance();
if (dman.isExpired() == false) {
dvalue = dman.adjustValue(dvalue, sourceName, this.pfaf,
dvalue = dman.adjustValue(value, sourceName, this.pfaf,
this.countyFips);
} else {
dvalue = value;
dvalue = value;
}
}
@ -244,30 +244,30 @@ public class FFMPGuidanceBasin extends FFMPBasin implements ISerializableObject
Date rdate = null;
if (guidValues != null && guidValues.size() > 0) {
Date markerDate = guidValues.firstKey();
for (Date checkDate : guidValues.keySet()) {
if (guidValues.get(checkDate).containsKey(sourceName)) {
float val = guidValues.get(checkDate).get(sourceName);
if (val != FFMPUtils.MISSING) {
long time1 = markerDate.getTime();
long time2 = checkDate.getTime();
if ((time1 - time2) < expiration) {
rdate = checkDate;
}
break;
}
}
}
Date markerDate = guidValues.firstKey();
for (Date checkDate : guidValues.keySet()) {
if (guidValues.get(checkDate).containsKey(sourceName)) {
float val = guidValues.get(checkDate).get(sourceName);
if (val != FFMPUtils.MISSING) {
long time1 = markerDate.getTime();
long time2 = checkDate.getTime();
if ((time1 - time2) < expiration) {
rdate = checkDate;
}
break;
}
}
}
}
return rdate;
}
/**
* Get Closest Key
*
@ -284,14 +284,14 @@ public class FFMPGuidanceBasin extends FFMPBasin implements ISerializableObject
if (guidValues.containsKey(date)) {
if (guidValues.get(date).containsKey(sourceName)) {
float val = guidValues.get(date).get(sourceName);
if (val != FFMPUtils.MISSING) {
rdate = date;
}
}
}
}
if (rdate == null) {

View file

@ -475,11 +475,12 @@ public class FFMPUtils {
* @return
*/
public static FFMPCounty getCounty(Long pfaf, String mode) {
String ftxt = (pfaf>=10000 ? ""+pfaf : "0"+pfaf);// DR 15164
String ftxt = (pfaf >= 10000 ? "" + pfaf : "0" + pfaf);// DR 15164
String sql = "SELECT county.countyname, county.state FROM "
+ " mapdata.county WHERE county.fips = '" + ftxt/*pfaf*/ + "'";// DR 15164
+ " mapdata.county WHERE county.fips = '" + ftxt/* pfaf */+ "'";// DR
// 15164
ISpatialQuery sq = null;
FFMPCounty county = new FFMPCounty();
@ -627,10 +628,23 @@ public class FFMPUtils {
*/
@SuppressWarnings("unchecked")
public static ArrayList<?> getCountyInfo(Long fips, String mode) {
String ftxt = (fips>=10000 ? ""+fips : "0"+fips);// DR 15108: add a leading 0 to 4-digit FIPS.
String ftxt = (fips >= 10000 ? "" + fips : "0" + fips);// DR 15108: add
// a leading 0 to
// 4-digit FIPS.
String sql1 = "SELECT county.gid from " + FFMPUtils.COUNTY_TABLE
+ " WHERE county.fips = '" + ftxt/*fips*/ + "'";// DR 15108: use the 5-digit FIPS string.
System.out.println("___FFMPUtils.getCountyInfo(): county FIPS: "+ftxt);//Not a debug statement but for Template generation.
+ " WHERE county.fips = '" + ftxt/* fips */+ "'";// DR 15108:
// use the
// 5-digit FIPS
// string.
System.out
.println("___FFMPUtils.getCountyInfo(): county FIPS: " + ftxt);// Not
// a
// debug
// statement
// but
// for
// Template
// generation.
ISpatialQuery sq1 = null;
ArrayList<Long> gids = new ArrayList<Long>();
@ -914,13 +928,16 @@ public class FFMPUtils {
* @param id
* @return
*/
public static String getFFGDataURI(String parameter, String plugin) {
public static String getFFGDataURI(String rfc, String parameter,
String plugin) {
DbQueryRequest request = new DbQueryRequest();
request.setEntityClass(GridRecord.class.getName());
request.addRequestField("dataURI");
request.addConstraint(GridConstants.PARAMETER_ABBREVIATION,
new RequestConstraint(parameter));
request.addConstraint(GridConstants.DATASET_ID, new RequestConstraint(
"FFG-" + rfc.substring(1)));
request.setOrderByField("dataTime.refTime", OrderMode.DESC);
try {
DbQueryResponse response = (DbQueryResponse) RequestRouter

View file

@ -1065,7 +1065,8 @@ public class FFMPGenerator extends CompositeProductGenerator implements
String plugin = getSourceConfig().getSource(source)
.getPlugin();
uris.add(FFMPUtils.getFFGDataURI(source, plugin));
uris.add(FFMPUtils.getFFGDataURI(rfc, source,
plugin));
}
}
}