Merge "Issue #2250 resolve some ffmp data factory issues and make some changes to failing function calls in FFMP, and handle new types of objects in JUtil" into development
Former-commit-id:783b7d151f
[formerly8d01eefc50
] [formerly6941e3300b
[formerly 811924693ef44e87aae65a33c8decd1a7f1cd321]] Former-commit-id:6941e3300b
Former-commit-id:599642edf5
This commit is contained in:
commit
4de49cde5a
3 changed files with 68 additions and 21 deletions
|
@ -84,7 +84,9 @@ import com.vividsolutions.jts.io.WKTWriter;
|
|||
* 01/02/13 DR 1569 D. Hladky constants, arraylist to list and moved common menthods here
|
||||
* 03/01/13 DR 13228 G. Zhang Add state for VGB query and related code
|
||||
* 03/18/13 1817 D. Hladky Fixed issue with BOX where only 1 HUC was showing up.
|
||||
* 08/20/13 2250 mnash Fixed incorrect return types for database queries.
|
||||
* </pre>
|
||||
*
|
||||
* @author dhladky
|
||||
* @version 1
|
||||
*/
|
||||
|
@ -199,13 +201,15 @@ public class FFMPUtils {
|
|||
double extent, String cwa, String mode) {
|
||||
|
||||
LinkedHashMap<String, FFMPVirtualGageBasinMetaData> virtualBasins = new LinkedHashMap<String, FFMPVirtualGageBasinMetaData>();
|
||||
String sql = "SELECT lid, county, name, lat, lon, state FROM location "// DR 13228 state added
|
||||
/*
|
||||
* DR 13228 state added to the below query
|
||||
*/
|
||||
String sql = "SELECT lid, county, name, lat, lon, state FROM location "
|
||||
+ "where lid in " + "(select distinct(lid) from IngestFilter "
|
||||
+ "where pe in ('PC', 'PP') " + "and ingest = 'T' "
|
||||
+ "and dur < 2000)";
|
||||
CoreDao dao = new CoreDao(DaoConfig.forDatabase(ShefConstants.IHFS));
|
||||
try {
|
||||
|
||||
Object[] results = dao.executeSQLQuery(sql.toString());
|
||||
Geometry poly = getCwaGeometry(cwa, mode);
|
||||
PreparedGeometry pg = PreparedGeometryFactory.prepare(poly);
|
||||
|
@ -250,7 +254,7 @@ public class FFMPUtils {
|
|||
|
||||
if (results.length > 0) {
|
||||
for (int i = 0; i < results.length; i++) {
|
||||
String column_name = (String) results[i];
|
||||
String column_name = (String) ((Object[]) results[i])[0];
|
||||
if (column_name.startsWith("upstream")) {
|
||||
upstreams.add("upstream" + j);
|
||||
j++;
|
||||
|
@ -311,13 +315,14 @@ public class FFMPUtils {
|
|||
maxDepth = depth;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// do an 80% analysis to find min (startDepth)
|
||||
if (pfafs.length > 0) {
|
||||
for (int myMinDepth = maxDepth; myMinDepth > 0; myMinDepth--) {
|
||||
int ilevelcount = 0;
|
||||
for (int i = 0; i < pfafs.length; i++) {
|
||||
int idepth = pfafs[i].substring(prelimstartDepth).indexOf("0");
|
||||
int idepth = pfafs[i].substring(prelimstartDepth).indexOf(
|
||||
"0");
|
||||
idepth = prelimstartDepth + idepth;
|
||||
if (idepth >= myMinDepth) {
|
||||
ilevelcount++;
|
||||
|
@ -595,7 +600,8 @@ public class FFMPUtils {
|
|||
if (results.length > 0) {
|
||||
for (int i = 0; i < results.length; i++) {
|
||||
if (results[i] != null) {
|
||||
keys.add(new Integer((String) results[i])
|
||||
keys.add(new Integer(
|
||||
(String) ((Object[]) results[i])[0])
|
||||
.longValue());
|
||||
}
|
||||
}
|
||||
|
@ -806,7 +812,8 @@ public class FFMPUtils {
|
|||
public static Geometry getCwaGeometry(String cwa, String mode) {
|
||||
// convert buffer to km, then degrees
|
||||
String sql = "Select asBinary("
|
||||
+ ScanUtils.getHighResolutionLevel("cwa") // DR 13228.getStandardResolutionLevel("cwa")
|
||||
+ ScanUtils.getHighResolutionLevel("cwa") // DR
|
||||
// 13228.getStandardResolutionLevel("cwa")
|
||||
+ ") from mapdata.cwa where cwa = '" + cwa + "'";
|
||||
|
||||
ISpatialQuery sq = null;
|
||||
|
@ -1220,11 +1227,11 @@ public class FFMPUtils {
|
|||
if ((lat != Double.NaN) && (lon != Double.NaN)) {
|
||||
basin.setCoordinate(new Coordinate(lon, lat));
|
||||
}
|
||||
|
||||
|
||||
if (dbResult[5] != null) {
|
||||
basin.setState((String) dbResult[5]);// DR 13228
|
||||
}
|
||||
|
||||
|
||||
return basin;
|
||||
}
|
||||
|
||||
|
@ -1282,8 +1289,7 @@ public class FFMPUtils {
|
|||
* @param guids
|
||||
* @return
|
||||
*/
|
||||
public static float getMaxRatioValue(List<Float> qpes,
|
||||
List<Float> guids) {
|
||||
public static float getMaxRatioValue(List<Float> qpes, List<Float> guids) {
|
||||
float ratio = Float.NaN;
|
||||
|
||||
if ((qpes.size() == guids.size()) && (qpes.size() > 0)
|
||||
|
@ -1329,8 +1335,7 @@ public class FFMPUtils {
|
|||
* @param guids
|
||||
* @return
|
||||
*/
|
||||
public static float getMaxDiffValue(List<Float> qpes,
|
||||
List<Float> guids) {
|
||||
public static float getMaxDiffValue(List<Float> qpes, List<Float> guids) {
|
||||
float diff = Float.NaN;
|
||||
if ((qpes.size() == guids.size()) && (qpes.size() > 0)
|
||||
&& (guids.size() > 0)) {
|
||||
|
@ -1348,15 +1353,17 @@ public class FFMPUtils {
|
|||
|
||||
return diff;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the file used to store aggregate records
|
||||
*
|
||||
* @param cwa
|
||||
* @param sourceSiteDataKey
|
||||
* @return
|
||||
*/
|
||||
public static File getHdf5File(String cwa, String sourceSiteDataKey) {
|
||||
return new File("ffmp" + File.separatorChar + cwa + File.separatorChar + sourceSiteDataKey + ".h5");
|
||||
return new File("ffmp" + File.separatorChar + cwa + File.separatorChar
|
||||
+ sourceSiteDataKey + ".h5");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -37,6 +37,7 @@ import com.raytheon.uf.common.dataaccess.util.DatabaseQueryUtil;
|
|||
import com.raytheon.uf.common.dataaccess.util.DatabaseQueryUtil.QUERY_MODE;
|
||||
import com.raytheon.uf.common.dataplugin.ffmp.FFMPBasin;
|
||||
import com.raytheon.uf.common.dataplugin.ffmp.FFMPBasinData;
|
||||
import com.raytheon.uf.common.dataplugin.ffmp.FFMPGuidanceBasin;
|
||||
import com.raytheon.uf.common.dataplugin.ffmp.FFMPRecord;
|
||||
import com.raytheon.uf.common.dataplugin.ffmp.FFMPTemplates;
|
||||
import com.raytheon.uf.common.dataplugin.ffmp.FFMPTemplates.MODE;
|
||||
|
@ -64,7 +65,8 @@ import com.vividsolutions.jts.geom.Geometry;
|
|||
* ------------ ---------- ----------- --------------------------
|
||||
* Jan 24, 2013 1552 mpduff Initial creation
|
||||
* Apr 16, 2013 1912 bsteffen Initial bulk hdf5 access for ffmp
|
||||
* Jul 15, 2013 2184 dhladky Remove all HUC's for storage except ALL
|
||||
* Jul 15, 2013 2184 dhladky Remove all HUC's for storage except ALL
|
||||
* Aug,20, 2013 2250 mnash Change some methods that were not working in all cases
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -204,14 +206,22 @@ public class FFMPGeometryFactory extends AbstractDataPluginFactory {
|
|||
String siteKey = (String) request.getIdentifiers().get(SITE_KEY);
|
||||
String cwa = (String) request.getIdentifiers().get(WFO);
|
||||
|
||||
if (dataKey == null) {
|
||||
dataKey = siteKey;
|
||||
}
|
||||
|
||||
FFMPBasinData basinData = rec.getBasinData();
|
||||
|
||||
Map<Long, FFMPBasin> basinDataMap = basinData.getBasins();
|
||||
|
||||
HucLevelGeometriesFactory geomFactory = HucLevelGeometriesFactory
|
||||
.getInstance();
|
||||
// BAL - Switched to use siteKey instead of dataKey.
|
||||
// Map<Long, Geometry> geomMap = geomFactory.getGeometries(templates,
|
||||
// dataKey, cwa, huc);
|
||||
Map<Long, Geometry> geomMap = geomFactory.getGeometries(templates,
|
||||
dataKey, cwa, huc);
|
||||
siteKey, cwa, huc);
|
||||
|
||||
FFMPSourceConfigurationManager srcConfigMan = FFMPSourceConfigurationManager
|
||||
.getInstance();
|
||||
SourceXML sourceXml = srcConfigMan.getSource(rec.getSourceName());
|
||||
|
@ -243,10 +253,23 @@ public class FFMPGeometryFactory extends AbstractDataPluginFactory {
|
|||
}
|
||||
|
||||
FFMPBasin basin = basinDataMap.get(pfaf);
|
||||
Float value = null;
|
||||
|
||||
if (basin == null) {
|
||||
continue;
|
||||
}
|
||||
Float value = basin.getValue(rec.getDataTime().getRefTime());
|
||||
|
||||
if (basin instanceof FFMPGuidanceBasin) {
|
||||
/*
|
||||
* Bryon L - Added test for FFMPGuidanceBasin object.
|
||||
* Couldn't use getValue(Date, Sourcename) here. Odd problem
|
||||
* with date key reference.
|
||||
*/
|
||||
value = ((FFMPGuidanceBasin) basin).getValue(
|
||||
rec.getSourceName(), 1000);
|
||||
} else {
|
||||
value = basin.getValue(rec.getDataTime().getRefTime());
|
||||
}
|
||||
String parameter = rec.getSourceName();
|
||||
String unitStr = sourceXml.getUnit();
|
||||
|
||||
|
|
|
@ -19,11 +19,15 @@
|
|||
# #
|
||||
|
||||
|
||||
from java.lang import Integer, Float, Long, Boolean, String
|
||||
from java.lang import Integer, Float, Long, Boolean, String, Object, Double
|
||||
from java.util import HashMap, LinkedHashMap, ArrayList
|
||||
from java.util import Collections
|
||||
from java.util import Date
|
||||
from collections import OrderedDict
|
||||
|
||||
import jep
|
||||
import datetime
|
||||
|
||||
#
|
||||
# Provides convenience methods for Java-Python bridging
|
||||
#
|
||||
|
@ -36,7 +40,7 @@ from collections import OrderedDict
|
|||
# 05/01/08 njensen Initial Creation.
|
||||
# 03/12/13 1759 dgilling Extend Java List types handled
|
||||
# by javaObjToPyVal().
|
||||
#
|
||||
# 08/20/13 2250 mnash Handle Dates, doubles, and arrays
|
||||
#
|
||||
#
|
||||
|
||||
|
@ -120,6 +124,10 @@ def pyValToJavaObj(val):
|
|||
for i in val:
|
||||
tempList.add(pyValToJavaObj(i))
|
||||
retObj = Collections.unmodifiableList(tempList)
|
||||
elif valtype is datetime.datetime:
|
||||
epoch = datetime.datetime.utcfromtimestamp(0)
|
||||
delta = val - epoch
|
||||
retObj = Date(long(delta.total_seconds()) * 1000)
|
||||
elif issubclass(valtype, dict):
|
||||
retObj = pyDictToJavaMap(val)
|
||||
elif issubclass(valtype, JavaWrapperClass):
|
||||
|
@ -140,6 +148,15 @@ def javaObjToPyVal(obj, customConverter=None):
|
|||
retVal = obj.longValue()
|
||||
elif objtype == "java.lang.Boolean":
|
||||
retVal = bool(obj.booleanValue())
|
||||
elif objtype == "java.lang.Double":
|
||||
retVal = obj.doubleValue()
|
||||
elif objtype == "java.util.Date":
|
||||
retVal = datetime.datetime.fromtimestamp(obj.getTime() / 1000)
|
||||
elif isinstance(obj, type(jep.jarray(0, Object))):
|
||||
retVal = []
|
||||
size = len(obj)
|
||||
for i in range(size):
|
||||
retVal.append(javaObjToPyVal(obj.get(i), customConverter))
|
||||
elif objtype in ["java.util.ArrayList", "java.util.Arrays$ArrayList"]:
|
||||
retVal = []
|
||||
size = obj.size()
|
||||
|
|
Loading…
Add table
Reference in a new issue