Merge tag 'OB_16.2.1-23' into asm_16.2.1

16.2.1-23


Former-commit-id: 58689e4265e780a75c5e4c8e584afa27ea30e3f1
This commit is contained in:
Shawn.Hooper 2016-04-14 14:15:39 -04:00
commit e7d7a5df40
5 changed files with 126 additions and 86 deletions

View file

@ -19,6 +19,7 @@
# Last Modified: 10/30/15 by Joe Maloney, added -q flags to scp/ssh at end. # Last Modified: 10/30/15 by Joe Maloney, added -q flags to scp/ssh at end.
# Last Modified: 11/25/15 by Tom LeFebvre, added switch to run tool from a cron or interactively. # Last Modified: 11/25/15 by Tom LeFebvre, added switch to run tool from a cron or interactively.
# Last Modified: 11/29/15 by P. Santos, completed adding code to enable running Run_NWPS interactively or from a cron. # Last Modified: 11/29/15 by P. Santos, completed adding code to enable running Run_NWPS interactively or from a cron.
# Last modified: 03/18/16 by Joe Maloney, a minor tweak to runManualNWPS_OutsideAWIPS call.
# ---------------------------------------------------------------------------- # ----------------------------------------------------------------------------
# The MenuItems list defines the GFE menu item(s) under which the # The MenuItems list defines the GFE menu item(s) under which the
@ -113,15 +114,15 @@ class Procedure (SmartScript.SmartScript):
("Waterlevels:", "ESTOFS", "radio", ["ESTOFS","PSURGE", "No"]), ("Waterlevels:", "ESTOFS", "radio", ["ESTOFS","PSURGE", "No"]),
("If PSURGE\n% Exceedance Hgt:", "10", "radio", ["10", "20", "30", "40", "50"]), ("If PSURGE\n% Exceedance Hgt:", "10", "radio", ["10", "20", "30", "40", "50"]),
] ]
varDict = {} varDict = {}
processVarList = ProcessVariableList.ProcessVariableList("Run_NWPS", variableList, varDict, None) processVarList = ProcessVariableList.ProcessVariableList("Run_NWPS", variableList, varDict, None)
status = processVarList.status() status = processVarList.status()
if status != "OK": if status != "OK":
return return
fcst_length = processVarList.varDict()["How Long Do You Want To Run NWPS:"] fcst_length = processVarList.varDict()["How Long Do You Want To Run NWPS:"]
fcstlength = str(fcst_length) fcstlength = str(fcst_length)
wind="ForecastWindGrids" wind="ForecastWindGrids"
modelstarttime = processVarList.varDict()["Model Start Time:"] modelstarttime = processVarList.varDict()["Model Start Time:"]
wheretorun = processVarList.varDict()["Local, NCEP, or Both:"] wheretorun = processVarList.varDict()["Local, NCEP, or Both:"]
@ -137,7 +138,7 @@ class Procedure (SmartScript.SmartScript):
excd = processVarList.varDict()["If PSURGE\n% Exceedance Hgt:"] excd = processVarList.varDict()["If PSURGE\n% Exceedance Hgt:"]
cron = False cron = False
# end interactive GUI portion # end interactive GUI portion
else: else:
# This part of if else statement assumes procedure is being run from command # This part of if else statement assumes procedure is being run from command
@ -161,14 +162,14 @@ class Procedure (SmartScript.SmartScript):
gstream = varDict['gstream'] gstream = varDict['gstream']
tstep = varDict['tstep'] tstep = varDict['tstep']
hotstart = varDict['hotstart'] hotstart = varDict['hotstart']
waterlevels = varDict['waterlevels'] waterlevels = varDict['waterlevels']
excd = varDict['excd'] excd = varDict['excd']
modelTR = self.getModelTimeRange("Fcst", "Wind") modelTR = self.getModelTimeRange("Fcst", "Wind")
startHour = modelTR[1] startHour = modelTR[1]
endHour = modelTR[2] endHour = modelTR[2]
timeRange = modelTR[0] timeRange = modelTR[0]
if (modelstarttime == buttonList[0]): if (modelstarttime == buttonList[0]):
starttime=timeList[0] starttime=timeList[0]
elif (modelstarttime == buttonList[1]): elif (modelstarttime == buttonList[1]):
@ -185,21 +186,21 @@ class Procedure (SmartScript.SmartScript):
starttime=timeList[6] starttime=timeList[6]
else: else:
starttime=startHour # Model start Hour if all others empty starttime=startHour # Model start Hour if all others empty
if (startHour > starttime): if (startHour > starttime):
starttime = startHour starttime = startHour
timeRange1 = TimeRange.TimeRange(AbsTime.AbsTime(starttime - 7*24*3600), AbsTime.AbsTime(starttime + 8*24*3600)) timeRange1 = TimeRange.TimeRange(AbsTime.AbsTime(starttime - 7*24*3600), AbsTime.AbsTime(starttime + 8*24*3600))
timeRange2 = TimeRange.TimeRange(AbsTime.AbsTime(starttime), AbsTime.AbsTime(starttime + 8*24*3600)) timeRange2 = TimeRange.TimeRange(AbsTime.AbsTime(starttime), AbsTime.AbsTime(starttime + 8*24*3600))
self.deleteCmd(['NWPSwind'], timeRange1) self.deleteCmd(['NWPSwind'], timeRange1)
databaseID = self.findDatabase("Fcst") databaseID = self.findDatabase("Fcst")
self.copyToCmd([('Wind', 'NWPSwind')], databaseID, timeRange2) self.copyToCmd([('Wind', 'NWPSwind')], databaseID, timeRange2)
self.fragmentCmd(['NWPSwind'], timeRange2) self.fragmentCmd(['NWPSwind'], timeRange2)
self.saveElements(["NWPSwind"]) self.saveElements(["NWPSwind"])
inp_args = fcstlength + ":" + wna + ":" + nest + ":" + gstream + ":" + wind + ":" + web + ":" + plot + ":" + tstep + ":" + hotstart + ":" + waterlevels + ":" + model + ":" + excd + ":" + wheretorun inp_args = fcstlength + ":" + wna + ":" + nest + ":" + gstream + ":" + wind + ":" + web + ":" + plot + ":" + tstep + ":" + hotstart + ":" + waterlevels + ":" + model + ":" + excd + ":" + wheretorun
try: try:
os.stat('/tmp/nwps/'+GFEDomainname) os.stat('/tmp/nwps/'+GFEDomainname)
except: except:
@ -216,5 +217,5 @@ class Procedure (SmartScript.SmartScript):
if cron: if cron:
os.system('ssh -q px2f /awips2/GFESuite/nwps/bin/runManualNWPS_OutsideAWIPS.sh '+GFEDomainname) os.system('ssh -q px2f /awips2/GFESuite/nwps/bin/runManualNWPS_OutsideAWIPS.sh '+GFEDomainname)
else: else:
os.system('xterm -e ssh -q px2f /awips2/GFESuite/nwps/bin/runManualNWPS_OutsideAWIPS.sh '+GFEDomainname) os.system('nohup xterm -iconic -e ssh -q px2f /awips2/GFESuite/nwps/bin/runManualNWPS_OutsideAWIPS.sh '+GFEDomainname+' &')
shutil.rmtree('/tmp/nwps/'+GFEDomainname) shutil.rmtree('/tmp/nwps/'+GFEDomainname)

View file

@ -93,6 +93,7 @@ import com.vividsolutions.jts.io.WKBReader;
* 07/15/13 2184 dhladky Remove all HUC's for storage except ALL * 07/15/13 2184 dhladky Remove all HUC's for storage except ALL
* Nov 18, 2014 3831 dhladky StatusHandler logging. Proper list sizing. Geometry chunk sizing. * Nov 18, 2014 3831 dhladky StatusHandler logging. Proper list sizing. Geometry chunk sizing.
* Aug 08, 2015 4722 dhladky Improved Grid support. * Aug 08, 2015 4722 dhladky Improved Grid support.
* Apr 07, 2016 5491 tjensen Fix NullPointerException from getRawGeometries
* </pre> * </pre>
* *
* @author dhladky * @author dhladky
@ -163,7 +164,7 @@ public class FFMPTemplates {
.getHandler(FFMPTemplates.class); .getHandler(FFMPTemplates.class);
private final IPathManager pathManager; private final IPathManager pathManager;
/** /**
* Single constructor * Single constructor
* *
@ -362,11 +363,12 @@ public class FFMPTemplates {
*/ */
private LinkedHashMap<String, FFMPVirtualGageBasinMetaData> readVGBFile( private LinkedHashMap<String, FFMPVirtualGageBasinMetaData> readVGBFile(
String name, String cwa, String dataKey) { String name, String cwa, String dataKey) {
HashMap<String, FFMPVirtualGageBasinMetaData> protoMap = readVGBDomainMap( HashMap<String, FFMPVirtualGageBasinMetaData> protoMap = readVGBDomainMap(
dataKey, cwa); dataKey, cwa);
String[] list = readVGBDomainList(dataKey, cwa); String[] list = readVGBDomainList(dataKey, cwa);
LinkedHashMap<String, FFMPVirtualGageBasinMetaData> map = new LinkedHashMap<String, FFMPVirtualGageBasinMetaData>(list.length, 1.0f); LinkedHashMap<String, FFMPVirtualGageBasinMetaData> map = new LinkedHashMap<>(
list.length, 1.0f);
// construct ordered map // construct ordered map
for (String lid : list) { for (String lid : list) {
@ -416,13 +418,17 @@ public class FFMPTemplates {
list = null; list = null;
} catch (SerializationException se) { } catch (SerializationException se) {
statusHandler.error("Serialization Exception: Write VGB: cwa: "+cwa+" dataKey: "+dataKey, se); statusHandler.error("Serialization Exception: Write VGB: cwa: "
+ cwa + " dataKey: " + dataKey, se);
} catch (FileNotFoundException fnfe) { } catch (FileNotFoundException fnfe) {
statusHandler.error("File Not found Exception: Write VGB: cwa: "+cwa+" dataKey: "+dataKey, fnfe); statusHandler.error("File Not found Exception: Write VGB: cwa: "
+ cwa + " dataKey: " + dataKey, fnfe);
} catch (IOException ioe) { } catch (IOException ioe) {
statusHandler.error("IO Exception: Write VGB: cwa: "+cwa+" dataKey: "+dataKey, ioe); statusHandler.error("IO Exception: Write VGB: cwa: " + cwa
+ " dataKey: " + dataKey, ioe);
} catch (LocalizationOpFailedException e) { } catch (LocalizationOpFailedException e) {
statusHandler.error("Localization Exception: Write VGB: cwa: "+cwa+" dataKey: "+dataKey, e); statusHandler.error("Localization Exception: Write VGB: cwa: "
+ cwa + " dataKey: " + dataKey, e);
} }
} }
@ -489,13 +495,19 @@ public class FFMPTemplates {
list = null; list = null;
} catch (SerializationException se) { } catch (SerializationException se) {
statusHandler.error("Serialization Exception: Write Template: cwa: "+cwa+" dataKey:"+dataKey+" huc: "+huc, se); statusHandler.error(
"Serialization Exception: Write Template: cwa: " + cwa
+ " dataKey:" + dataKey + " huc: " + huc, se);
} catch (FileNotFoundException fnfe) { } catch (FileNotFoundException fnfe) {
statusHandler.error("File Not found Exception: Write Template: cwa: "+cwa+" dataKey:"+dataKey+" huc: "+huc, fnfe); statusHandler.error(
"File Not found Exception: Write Template: cwa: " + cwa
+ " dataKey:" + dataKey + " huc: " + huc, fnfe);
} catch (IOException ioe) { } catch (IOException ioe) {
statusHandler.error("IO Exception: Write Template: cwa: "+cwa+" dataKey:"+dataKey+" huc: "+huc, ioe); statusHandler.error("IO Exception: Write Template: cwa: " + cwa
+ " dataKey:" + dataKey + " huc: " + huc, ioe);
} catch (LocalizationOpFailedException e) { } catch (LocalizationOpFailedException e) {
statusHandler.error("Localization Exception: Write Template: cwa: "+cwa+" dataKey:"+dataKey+" huc: "+huc, e); statusHandler.error("Localization Exception: Write Template: cwa: "
+ cwa + " dataKey:" + dataKey + " huc: " + huc, e);
} }
} }
@ -846,7 +858,8 @@ public class FFMPTemplates {
} }
} }
} catch (Exception e) { } catch (Exception e) {
statusHandler.error("Find Basin by lon lat failed: dataKey: "+dataKey+ " coor:"+coor.toString(), e); statusHandler.error("Find Basin by lon lat failed: dataKey: "
+ dataKey + " coor:" + coor.toString(), e);
} }
return null; return null;
@ -1010,7 +1023,8 @@ public class FFMPTemplates {
} }
} catch (Exception e) { } catch (Exception e) {
statusHandler.error("Failed to lookup County: dataKey: "+dataKey, e); statusHandler.error("Failed to lookup County: dataKey: " + dataKey,
e);
} }
FFMPCounties counties = new FFMPCounties(countyList); FFMPCounties counties = new FFMPCounties(countyList);
@ -1085,16 +1099,16 @@ public class FFMPTemplates {
Rectangle rect = null; Rectangle rect = null;
rect = HRAPCoordinates.getHRAPCoordinates(); rect = HRAPCoordinates.getHRAPCoordinates();
rect.setBounds(rect.x * primeSource.getHrapGridFactor(), rect.y rect.setBounds(rect.x * primeSource.getHrapGridFactor(), rect.y
* primeSource.getHrapGridFactor(), rect.width * primeSource.getHrapGridFactor(),
* primeSource.getHrapGridFactor(), rect.height rect.width * primeSource.getHrapGridFactor(), rect.height
* primeSource.getHrapGridFactor()); * primeSource.getHrapGridFactor());
HRAPSubGrid hrapgrid = new HRAPSubGrid(rect, HRAPSubGrid hrapgrid = new HRAPSubGrid(rect,
primeSource.getHrapGridFactor()); primeSource.getHrapGridFactor());
Geometry geo = hrapgrid.getGeometry(); Geometry geo = hrapgrid.getGeometry();
siteExtents = FFMPUtils.getGeometryText(geo); siteExtents = FFMPUtils.getGeometryText(geo);
} else if (primeSource.getDataType().equals( } else if (primeSource.getDataType().equals(
FFMPSourceConfigurationManager.DATA_TYPE.RADAR.getDataType())) { FFMPSourceConfigurationManager.DATA_TYPE.RADAR.getDataType())) {
@ -1108,7 +1122,8 @@ public class FFMPTemplates {
} else if (primeSource.getDataType().equals( } else if (primeSource.getDataType().equals(
FFMPSourceConfigurationManager.DATA_TYPE.GRID.getDataType())) { FFMPSourceConfigurationManager.DATA_TYPE.GRID.getDataType())) {
// extract the Grid Coverage for use in site extents creation // extract the Grid Coverage for use in site extents creation
GridCoverage coverage = FFMPUtils.getGridCoverageRecord(primeSource.getDataPath()); GridCoverage coverage = FFMPUtils.getGridCoverageRecord(primeSource
.getDataPath());
siteExtents = FFMPUtils.getGeometryText(coverage.getGeometry()); siteExtents = FFMPUtils.getGeometryText(coverage.getGeometry());
} else if (primeSource.getDataType().equals( } else if (primeSource.getDataType().equals(
FFMPSourceConfigurationManager.DATA_TYPE.PDO.getDataType())) { FFMPSourceConfigurationManager.DATA_TYPE.PDO.getDataType())) {
@ -1170,7 +1185,9 @@ public class FFMPTemplates {
getMaxExtent(), getSiteExtents(dataKey), getMaxExtent(), getSiteExtents(dataKey),
mode.getMode())); mode.getMode()));
} catch (Exception e) { } catch (Exception e) {
statusHandler.handle(Priority.PROBLEM, "Unable to create FFMP Template for this dataKey: "+dataKey, e); statusHandler.handle(Priority.PROBLEM,
"Unable to create FFMP Template for this dataKey: "
+ dataKey, e);
} }
} else if (huc.equals(FFMPRecord.COUNTY)) { } else if (huc.equals(FFMPRecord.COUNTY)) {
list = getCountyFips(cwa, dataKey); list = getCountyFips(cwa, dataKey);
@ -1243,7 +1260,8 @@ public class FFMPTemplates {
primary = true; primary = true;
} }
if (rawGeometries == null) { if (rawGeometries == null
|| rawGeometries.isEmpty()) {
rawGeometries = getRawGeometries(dataKey, cwa); rawGeometries = getRawGeometries(dataKey, cwa);
} }
@ -1745,19 +1763,19 @@ public class FFMPTemplates {
SoftReference<Map<Long, Geometry>> rawGeomRef = cwaRawGeometries SoftReference<Map<Long, Geometry>> rawGeomRef = cwaRawGeometries
.get(compositeKey); .get(compositeKey);
Map<Long, Geometry> pfafGeometries = null; Map<Long, Geometry> pfafGeometries = null;
if (rawGeomRef != null) { if (rawGeomRef != null) {
pfafGeometries = rawGeomRef.get(); pfafGeometries = rawGeomRef.get();
} }
if (results != null && results.length > 0) { if (results != null && results.length > 0) {
if (pfafGeometries == null) { if (pfafGeometries == null) {
pfafGeometries = new HashMap<Long, Geometry>(results.length, 1.0f); pfafGeometries = new HashMap<>(results.length, 1.0f);
cwaRawGeometries.put(compositeKey, cwaRawGeometries.put(compositeKey,
new SoftReference<Map<Long, Geometry>>(pfafGeometries)); new SoftReference<Map<Long, Geometry>>(pfafGeometries));
} }
for (int i = 0; i < results.length; i++) { for (int i = 0; i < results.length; i++) {
Object[] row = (Object[]) results[i]; Object[] row = (Object[]) results[i];
basin = FFMPUtils.getMetaDataBasin(row, mode.getMode()); basin = FFMPUtils.getMetaDataBasin(row, mode.getMode());
@ -1772,12 +1790,14 @@ public class FFMPTemplates {
if ((row.length >= (upstreamDepth + 9)) if ((row.length >= (upstreamDepth + 9))
&& (row[upstreamDepth + 9] != null)) { && (row[upstreamDepth + 9] != null)) {
try { try {
pfafGeometries.put(basin.getPfaf(), reader pfafGeometries.put(basin.getPfaf(),
.read((byte[]) row[upstreamDepth + 9]) reader.read((byte[]) row[upstreamDepth + 9])
.buffer(0)); .buffer(0));
} catch (Exception e) { } catch (Exception e) {
statusHandler.error("Failure to add rawGeometry in loadBasins: "+siteKey, e); statusHandler.error(
"Failure to add rawGeometry in loadBasins: "
+ siteKey, e);
} }
} }
} }
@ -1995,9 +2015,11 @@ public class FFMPTemplates {
list = SerializationUtil.transformFromThrift(long[].class, list = SerializationUtil.transformFromThrift(long[].class,
FileUtil.file2bytes(f.getFile(), true)); FileUtil.file2bytes(f.getFile(), true));
} catch (SerializationException se) { } catch (SerializationException se) {
statusHandler.error("Serialization Exception: Read Domain: cwa: "+cwa+" dataKey: "+dataKey+" huc: "+huc, se); statusHandler.error("Serialization Exception: Read Domain: cwa: "
+ cwa + " dataKey: " + dataKey + " huc: " + huc, se);
} catch (IOException e) { } catch (IOException e) {
statusHandler.error("IO Exception: Read Domain: cwa: "+cwa+" dataKey: "+dataKey+" huc: "+huc, e); statusHandler.error("IO Exception: Read Domain: cwa: " + cwa
+ " dataKey: " + dataKey + " huc: " + huc, e);
} }
return list; return list;
@ -2032,9 +2054,11 @@ public class FFMPTemplates {
FileUtil.file2bytes(f.getFile(), true)); FileUtil.file2bytes(f.getFile(), true));
} }
} catch (SerializationException se) { } catch (SerializationException se) {
statusHandler.error("Serialization Exception: Domain Map: "+dataKey+" cwa:"+cwa+" huc: "+huc, se); statusHandler.error("Serialization Exception: Domain Map: "
+ dataKey + " cwa:" + cwa + " huc: " + huc, se);
} catch (IOException e) { } catch (IOException e) {
statusHandler.error("IO Exception: Domain Map: "+dataKey+" cwa:"+cwa+" huc: "+huc, e); statusHandler.error("IO Exception: Domain Map: " + dataKey
+ " cwa:" + cwa + " huc: " + huc, e);
} }
return map; return map;
@ -2063,9 +2087,11 @@ public class FFMPTemplates {
.transformFromThrift(HashMap.class, .transformFromThrift(HashMap.class,
FileUtil.file2bytes(f.getFile(), true)); FileUtil.file2bytes(f.getFile(), true));
} catch (SerializationException se) { } catch (SerializationException se) {
statusHandler.error("Serialization Exception: Virtual Basins: "+dataKey+" cwa: "+cwa, se); statusHandler.error("Serialization Exception: Virtual Basins: "
+ dataKey + " cwa: " + cwa, se);
} catch (IOException e) { } catch (IOException e) {
statusHandler.error("IO Exception: Virtual Basins: "+dataKey+" cwa: "+cwa, e); statusHandler.error("IO Exception: Virtual Basins: " + dataKey
+ " cwa: " + cwa, e);
} }
return map; return map;
@ -2091,9 +2117,12 @@ public class FFMPTemplates {
list = SerializationUtil.transformFromThrift(String[].class, list = SerializationUtil.transformFromThrift(String[].class,
FileUtil.file2bytes(f.getFile(), true)); FileUtil.file2bytes(f.getFile(), true));
} catch (SerializationException se) { } catch (SerializationException se) {
statusHandler.error("Serialization Exception: : Read Virtual Domain: cwa: "+cwa+" dataKey: "+dataKey, se); statusHandler.error(
"Serialization Exception: : Read Virtual Domain: cwa: "
+ cwa + " dataKey: " + dataKey, se);
} catch (IOException e) { } catch (IOException e) {
statusHandler.error("IO Exception: : Read Virtual Domain: cwa: "+cwa+" dataKey: "+dataKey, e); statusHandler.error("IO Exception: : Read Virtual Domain: cwa: "
+ cwa + " dataKey: " + dataKey, e);
} }
return list; return list;
@ -2151,14 +2180,15 @@ public class FFMPTemplates {
if (rawGeomRef != null) { if (rawGeomRef != null) {
pfafGeometries = rawGeomRef.get(); pfafGeometries = rawGeomRef.get();
} }
if (pfafGeometries == null) { if (pfafGeometries == null || pfafGeometries.isEmpty()) {
// TODO: add sync locking per cwa // TODO: add sync locking per cwa
long t0 = System.currentTimeMillis(); long t0 = System.currentTimeMillis();
pfafGeometries = FFMPUtils.getRawGeometries(getMap(siteKey, cwa, pfafGeometries = FFMPUtils.getRawGeometries(getMap(siteKey, cwa,
FFMPRecord.ALL).keySet()); FFMPRecord.ALL).keySet());
long t1 = System.currentTimeMillis(); long t1 = System.currentTimeMillis();
System.out.println("Retrieval of raw geometries for site " statusHandler.handle(Priority.INFO,
+ siteKey + " cwa " + cwa + " took " + (t1 - t0) + " ms."); "Retrieval of raw geometries for site " + siteKey + " cwa "
+ cwa + " took " + (t1 - t0) + " ms.");
cwaRawGeometries.put(compositeKey, cwaRawGeometries.put(compositeKey,
new SoftReference<Map<Long, Geometry>>(pfafGeometries)); new SoftReference<Map<Long, Geometry>>(pfafGeometries));
} }
@ -2362,10 +2392,14 @@ public class FFMPTemplates {
if (res >= 0.004) { if (res >= 0.004) {
try { try {
list = FFMPUtils.getUniqueCountyFips(cwa, getMaxExtent(), list = FFMPUtils
getSiteExtents(dataKey), mode.getMode(), resolution); .getUniqueCountyFips(cwa, getMaxExtent(),
getSiteExtents(dataKey), mode.getMode(),
resolution);
} catch (Exception e) { } catch (Exception e) {
statusHandler.handle(Priority.PROBLEM, "Unable to create FFMP Template for this dataKey: "+dataKey, e); statusHandler.handle(Priority.PROBLEM,
"Unable to create FFMP Template for this dataKey: "
+ dataKey, e);
} }
if (list.size() > 0) { if (list.size() > 0) {

View file

@ -100,6 +100,7 @@ import com.vividsolutions.jts.io.WKTWriter;
* Aug 08, 2015 4722 dhladky Added Grid coverage and parsing methods. * Aug 08, 2015 4722 dhladky Added Grid coverage and parsing methods.
* Sep 17, 2015 4756 dhladky Multiple guidance source bugs. * Sep 17, 2015 4756 dhladky Multiple guidance source bugs.
* Feb 12, 2016 5370 dhladky Camel case for insertTime. * Feb 12, 2016 5370 dhladky Camel case for insertTime.
* Apr 07, 2016 5491 tjensen Fix NullPointerException from getRawGeometries
* </pre> * </pre>
* *
* @author dhladky * @author dhladky
@ -124,7 +125,7 @@ public class FFMPUtils {
public static float MISSING = -99999.0f; public static float MISSING = -99999.0f;
private static NumberFormat formatter = new DecimalFormat("#.##"); private static NumberFormat formatter = new DecimalFormat("#.##");
private static final IUFStatusHandler statusHandler = UFStatus private static final IUFStatusHandler statusHandler = UFStatus
.getHandler(FFMPUtils.class); .getHandler(FFMPUtils.class);
@ -371,8 +372,8 @@ public class FFMPUtils {
* @param extents * @param extents
* @return * @return
*/ */
public static Object[] getBasins(String cwa, double buffer, public static Object[] getBasins(String cwa, double buffer, String extents,
String extents, String mode) { String mode) {
String lowestSimplificationLevel = ScanUtils String lowestSimplificationLevel = ScanUtils
.getHighResolutionLevel("ffmp_basins"); .getHighResolutionLevel("ffmp_basins");
String highestSimplificationLevel = ScanUtils String highestSimplificationLevel = ScanUtils
@ -424,7 +425,8 @@ public class FFMPUtils {
* @return * @return
*/ */
public static Map<Long, Geometry> getRawGeometries(Collection<Long> pfafs) { public static Map<Long, Geometry> getRawGeometries(Collection<Long> pfafs) {
HashMap<Long, Geometry> rval = null; // Initialize rval to an empty Map to use as the default return value.
HashMap<Long, Geometry> rval = new HashMap<>();
if (pfafs.size() > 0) { if (pfafs.size() > 0) {
StringBuilder builder = new StringBuilder(); StringBuilder builder = new StringBuilder();
builder.append("SELECT pfaf_id, AsBinary(" builder.append("SELECT pfaf_id, AsBinary("
@ -448,7 +450,7 @@ public class FFMPUtils {
try { try {
sq = SpatialQueryFactory.create(); sq = SpatialQueryFactory.create();
results = sq.dbRequest(builder.toString(), MAPS_DB); results = sq.dbRequest(builder.toString(), MAPS_DB);
rval = new HashMap<Long, Geometry>(results.length, 1.0f); rval = new HashMap<>(results.length, 1.0f);
} catch (SpatialException e) { } catch (SpatialException e) {
statusHandler.error("Error querying Raw Geometries: +sql: " statusHandler.error("Error querying Raw Geometries: +sql: "
+ builder.toString(), e); + builder.toString(), e);
@ -971,19 +973,19 @@ public class FFMPUtils {
* @param id * @param id
* @return * @return
*/ */
public static String getFFGDataURI(GUIDANCE_TYPE type, String datasetid, String parameter, public static String getFFGDataURI(GUIDANCE_TYPE type, String datasetid,
String plugin) { String parameter, String plugin) {
DbQueryRequest request = new DbQueryRequest(); DbQueryRequest request = new DbQueryRequest();
request.setEntityClass(GridRecord.class.getName()); request.setEntityClass(GridRecord.class.getName());
request.addConstraint(GridConstants.PARAMETER_ABBREVIATION, request.addConstraint(GridConstants.PARAMETER_ABBREVIATION,
new RequestConstraint(parameter)); new RequestConstraint(parameter));
if (type == GUIDANCE_TYPE.RFC) { if (type == GUIDANCE_TYPE.RFC) {
request.addConstraint(GridConstants.DATASET_ID, new RequestConstraint( request.addConstraint(GridConstants.DATASET_ID,
"FFG-" + datasetid.substring(1))); new RequestConstraint("FFG-" + datasetid.substring(1)));
} else { } else {
request.addConstraint(GridConstants.DATASET_ID, new RequestConstraint( request.addConstraint(GridConstants.DATASET_ID,
datasetid)); new RequestConstraint(datasetid));
} }
request.setOrderByField("dataTime.refTime", OrderMode.DESC); request.setOrderByField("dataTime.refTime", OrderMode.DESC);
@ -994,8 +996,8 @@ public class FFMPUtils {
if (grids != null && grids.length > 0) { if (grids != null && grids.length > 0) {
return grids[0].getDataURI(); return grids[0].getDataURI();
} else { } else {
statusHandler.warn( statusHandler.warn("No data available for this FFG Request: "
"No data available for this FFG Request: " + request.toString()); + request.toString());
} }
} catch (Exception e) { } catch (Exception e) {
statusHandler.error( statusHandler.error(
@ -1432,7 +1434,7 @@ public class FFMPUtils {
return unmappedResults.toArray(new Object[0]); return unmappedResults.toArray(new Object[0]);
} }
/** /**
* For Grid FFMP types used as primary sources, request the coverage record * For Grid FFMP types used as primary sources, request the coverage record
* for use in domain creation. * for use in domain creation.
@ -1471,8 +1473,9 @@ public class FFMPUtils {
coverage = record.getLocation(); coverage = record.getLocation();
} }
} else { } else {
statusHandler.error("Query for Grid Coverage returned no results: DataSetID = " statusHandler
+ datasetID); .error("Query for Grid Coverage returned no results: DataSetID = "
+ datasetID);
} }
return coverage; return coverage;

View file

@ -30,7 +30,6 @@ import com.raytheon.uf.common.dataplugin.PluginException;
import com.raytheon.uf.common.dataplugin.grid.GridRecord; import com.raytheon.uf.common.dataplugin.grid.GridRecord;
import com.raytheon.uf.common.datastorage.records.FloatDataRecord; import com.raytheon.uf.common.datastorage.records.FloatDataRecord;
import com.raytheon.uf.common.monitor.config.FFMPSourceConfigurationManager; import com.raytheon.uf.common.monitor.config.FFMPSourceConfigurationManager;
import com.raytheon.uf.common.monitor.config.FFMPSourceConfigurationManager.SOURCE_TYPE;
import com.raytheon.uf.common.monitor.config.FFMPTemplateConfigurationManager; import com.raytheon.uf.common.monitor.config.FFMPTemplateConfigurationManager;
import com.raytheon.uf.common.monitor.config.FFTIDataManager; import com.raytheon.uf.common.monitor.config.FFTIDataManager;
import com.raytheon.uf.common.monitor.processing.IMonitorProcessing; import com.raytheon.uf.common.monitor.processing.IMonitorProcessing;
@ -63,6 +62,7 @@ import com.vividsolutions.jts.geom.GeometryFactory;
* Sep.09, 2015 4756 dhladky Further simplified configuration. * Sep.09, 2015 4756 dhladky Further simplified configuration.
* Mar 04, 2016 5429 dhladky Special case for RFCFFG multi-RFC mosaics. * Mar 04, 2016 5429 dhladky Special case for RFCFFG multi-RFC mosaics.
* Mar 29, 2016 5491 tjensen Special case for QPFSCAN * Mar 29, 2016 5491 tjensen Special case for QPFSCAN
* Apr 02, 2016 5491 tjensen Fixed special case for QPFSCAN to be strict
* </pre> * </pre>
* *
* @author dhladky * @author dhladky
@ -482,7 +482,7 @@ public class FFMPConfig {
* RFC mosaic piece. Use existing sourceKey that designates that * RFC mosaic piece. Use existing sourceKey that designates that
* mosaic piece. * mosaic piece.
*/ */
} else if (source.getSourceType().equals(SOURCE_TYPE.QPF.name())) { } else if (source.getSourceName().equals("QPFSCAN")) {
/* /*
* The special case of QPFSCAN. Use existing sourceKey that * The special case of QPFSCAN. Use existing sourceKey that
* designates that mosaic piece. * designates that mosaic piece.

View file

@ -109,6 +109,7 @@ import com.vividsolutions.jts.geom.Polygon;
* Aug 26, 2015 4777 dhladky Fixed bug in DPR accumulations. * Aug 26, 2015 4777 dhladky Fixed bug in DPR accumulations.
* Sep 28, 2015 4756 dhladky Multiple Guidance upgrades. * Sep 28, 2015 4756 dhladky Multiple Guidance upgrades.
* Feb 04, 2016 5311 dhladky Bug in creation of source bins fixed. * Feb 04, 2016 5311 dhladky Bug in creation of source bins fixed.
* Apr 07, 2016 5491 tjensen Fix NullPointerException from getRawGeometries
* </pre> * </pre>
* *
* @author dhladky * @author dhladky
@ -377,7 +378,8 @@ public class FFMPProcessor {
} else { } else {
if (checkLockStatus()) { if (checkLockStatus()) {
lock(); lock();
if (cwaGeometries == null) { if (cwaGeometries == null
|| cwaGeometries.isEmpty()) {
cwaGeometries = template cwaGeometries = template
.getRawGeometries(dataKey, .getRawGeometries(dataKey,
domain.getCwa()); domain.getCwa());
@ -902,7 +904,7 @@ public class FFMPProcessor {
} }
} else { } else {
if (cwaGeometries == null) { if (cwaGeometries == null || cwaGeometries.isEmpty()) {
cwaGeometries = template.getRawGeometries(dataKey, cwa); cwaGeometries = template.getRawGeometries(dataKey, cwa);
} }
@ -1007,7 +1009,7 @@ public class FFMPProcessor {
} }
} else { } else {
if (cwaGeometries == null) { if (cwaGeometries == null || cwaGeometries.isEmpty()) {
cwaGeometries = template.getRawGeometries(dataKey, cwa); cwaGeometries = template.getRawGeometries(dataKey, cwa);
} }
@ -1222,7 +1224,7 @@ public class FFMPProcessor {
} }
} else { } else {
if (cwaGeometries == null) { if (cwaGeometries == null || cwaGeometries.isEmpty()) {
cwaGeometries = template.getRawGeometries(siteKey, cwa); cwaGeometries = template.getRawGeometries(siteKey, cwa);
} }