Issue #3006 Fixed GetPointDataHandler to handle grids longer than 1 hour.
Fixed Wx parsing for AvnFPS Change-Id: I34286a7cc46f6116aaa4026d22fd41223cc16f73 Former-commit-id: e636563052042d2dbfab6a4e476b71004b28c165
This commit is contained in:
parent
abf64eafe8
commit
221a06e467
9 changed files with 268 additions and 165 deletions
|
@ -22,6 +22,8 @@ package com.raytheon.viz.aviation.guidance;
|
|||
import com.raytheon.uf.common.dataplugin.gfe.point.GFEPointDataContainers;
|
||||
import com.raytheon.uf.common.dataplugin.gfe.request.GetPointDataRequest;
|
||||
import com.raytheon.uf.common.dataplugin.gfe.server.message.ServerResponse;
|
||||
import com.raytheon.uf.common.status.IUFStatusHandler;
|
||||
import com.raytheon.uf.common.status.UFStatus;
|
||||
import com.raytheon.uf.viz.core.VizApp;
|
||||
import com.raytheon.uf.viz.core.exception.VizException;
|
||||
import com.raytheon.uf.viz.core.requests.ThriftClient;
|
||||
|
@ -37,6 +39,7 @@ import com.raytheon.uf.viz.core.requests.ThriftClient;
|
|||
* Jul 29, 2009 njensen Initial creation
|
||||
* Mar 11, 2013 1735 rferrel Get a list of GFE Point Data Containers
|
||||
* Sep 11, 2013 2277 mschenke Got rid of ScriptCreator references
|
||||
* Apr 23, 2014 3006 randerso Added error logging
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -45,6 +48,8 @@ import com.raytheon.uf.viz.core.requests.ThriftClient;
|
|||
*/
|
||||
|
||||
public class GuidanceUtil {
|
||||
private static final transient IUFStatusHandler statusHandler = UFStatus
|
||||
.getHandler(GuidanceUtil.class);
|
||||
|
||||
/**
|
||||
* Get a list of GFE Point Data information for the task request.
|
||||
|
@ -59,6 +64,10 @@ public class GuidanceUtil {
|
|||
task.setWorkstationID(VizApp.getWsId());
|
||||
ServerResponse<GFEPointDataContainers> sr = (ServerResponse<GFEPointDataContainers>) ThriftClient
|
||||
.sendRequest(task);
|
||||
if (!sr.isOkay()) {
|
||||
// some kind of error occurred on the server side
|
||||
statusHandler.error(sr.message());
|
||||
}
|
||||
return sr.getPayload();
|
||||
}
|
||||
|
||||
|
|
|
@ -5,6 +5,11 @@
|
|||
<projects>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
<buildCommand>
|
||||
<name>org.python.pydev.PyDevBuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.jdt.core.javabuilder</name>
|
||||
<arguments>
|
||||
|
@ -24,5 +29,6 @@
|
|||
<natures>
|
||||
<nature>org.eclipse.pde.PluginNature</nature>
|
||||
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||
<nature>org.python.pydev.pythonNature</nature>
|
||||
</natures>
|
||||
</projectDescription>
|
||||
|
|
5
cave/com.raytheon.viz.avnconfig/.pydevproject
Normal file
5
cave/com.raytheon.viz.avnconfig/.pydevproject
Normal file
|
@ -0,0 +1,5 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<?eclipse-pydev version="1.0"?><pydev_project>
|
||||
<pydev_property name="org.python.pydev.PYTHON_PROJECT_INTERPRETER">Default</pydev_property>
|
||||
<pydev_property name="org.python.pydev.PYTHON_PROJECT_VERSION">python 2.7</pydev_property>
|
||||
</pydev_project>
|
|
@ -28,8 +28,8 @@
|
|||
#
|
||||
# Date Ticket# Engineer Description
|
||||
# ------------ ---------- ----------- --------------------------
|
||||
# 08/12/09 njensen Initial Creation.
|
||||
#
|
||||
# 08/12/09 njensen Initial Creation.
|
||||
# 04/23/2-14 #3006 randerso Fix Wx parsing
|
||||
#
|
||||
#
|
||||
|
||||
|
@ -99,7 +99,7 @@ def wxVal(value, index):
|
|||
return value
|
||||
|
||||
skip = index
|
||||
count = 0
|
||||
count = 1
|
||||
for subkey in wxStats:
|
||||
if subkey.wxType() not in ['<NoWx>','T'] + _vsbyCodes:
|
||||
if count == skip:
|
||||
|
@ -120,7 +120,7 @@ def wxValInst(value, index):
|
|||
return value
|
||||
|
||||
skip = index
|
||||
count = 0
|
||||
count = 1
|
||||
for subkey in wxStats:
|
||||
if subkey.wxType() not in ['<NoWx>','T'] + _vsbyCodes:
|
||||
if count == skip:
|
||||
|
@ -141,7 +141,7 @@ def wxValCov(value, index):
|
|||
return value
|
||||
|
||||
skip = index
|
||||
count = 0
|
||||
count = 1
|
||||
for subkey in wxStats:
|
||||
if subkey.wxType() not in ['<NoWx>','T'] + _vsbyCodes:
|
||||
if count == skip:
|
||||
|
@ -149,7 +149,6 @@ def wxValCov(value, index):
|
|||
break
|
||||
else:
|
||||
count = count + 1
|
||||
|
||||
return value
|
||||
|
||||
def wxTstm(value):
|
||||
|
@ -179,7 +178,7 @@ def wxTstmInt(value):
|
|||
|
||||
for subkey in wxStats:
|
||||
if subkey.wxType() == 'T':
|
||||
value = self._translateCode.get(subkey.intensity(), 'm' )
|
||||
value = _translateCode.get(subkey.intensity(), 'm' )
|
||||
break
|
||||
|
||||
return value
|
||||
|
@ -188,10 +187,13 @@ def wxTstmInt(value):
|
|||
class FakeWxKey:
|
||||
|
||||
def __init__(self, value):
|
||||
split = value.split(',')
|
||||
split = value.split('^')
|
||||
self.subkeys = []
|
||||
for s in split:
|
||||
self.subkeys.append(FakeWxSubkey(s))
|
||||
self.subkeys.append(FakeWxSubkey(s))
|
||||
|
||||
def __str__(self):
|
||||
return "^".join([str(subkey) for subkey in self.subkeys])
|
||||
|
||||
def __getitem__(self, key):
|
||||
return self.subkeys[key]
|
||||
|
@ -207,10 +209,13 @@ class FakeWxSubkey:
|
|||
|
||||
def __init__(self, value):
|
||||
split = value.split(':')
|
||||
self.cov = value[0]
|
||||
self.type = value[1]
|
||||
self.inten = value[2]
|
||||
self.vis = value[3]
|
||||
self.cov = split[0]
|
||||
self.type = split[1]
|
||||
self.inten = split[2]
|
||||
self.vis = split[3]
|
||||
|
||||
def __str__(self):
|
||||
return ":".join([self.cov, self.type, self.inten, self.vis])
|
||||
|
||||
def wxType(self):
|
||||
return self.type
|
||||
|
|
|
@ -141,15 +141,14 @@
|
|||
# Status: TEST
|
||||
# Title: AvnFPS: Lack of customization in QC check
|
||||
#
|
||||
#**
|
||||
#*
|
||||
#*
|
||||
#* <pre>
|
||||
#* SOFTWARE HISTORY
|
||||
#* Date Ticket# Engineer Description
|
||||
#* ------------ ---------- ----------- --------------------------
|
||||
#* Initial creation.
|
||||
#* Mar 07, 2013 1735 rferrel Changes to obtain grid data for a list of sites.
|
||||
# <pre>
|
||||
# SOFTWARE HISTORY
|
||||
# Date Ticket# Engineer Description
|
||||
# ------------ ---------- ----------- --------------------------
|
||||
# Initial creation.
|
||||
# Mar 07, 2013 1735 rferrel Changes to obtain grid data for a list of sites.
|
||||
# Apr 23, 2014 3006 randerso Fix Wx parsing, handling of missing pdcs
|
||||
#
|
||||
##
|
||||
#
|
||||
import logging, os, time, ConfigParser
|
||||
|
@ -313,7 +312,7 @@ def _getData(pdc, firstTime):
|
|||
organizedData[fcstHr] = pdv
|
||||
for n in range(_NumHours):
|
||||
dd = {'time': 3600.0*n+(firstTime / 1000)}
|
||||
dd = _createRecord(dd, organizedData[n])
|
||||
dd = _createRecord(dd, organizedData[n])
|
||||
data.append(dd)
|
||||
else :
|
||||
return None
|
||||
|
@ -344,11 +343,11 @@ def _createRecord(dd, pdv):
|
|||
elif k == 'Tint':
|
||||
v = _stripmsng(GfeValues.wxTstmInt(arg))
|
||||
elif k[:4] == 'Prob':
|
||||
v = _stripmsng(GfeValues.wxValCov(arg, k[4]))
|
||||
v = _stripmsng(GfeValues.wxValCov(arg, int(k[4])))
|
||||
elif k[:4] == 'PTyp':
|
||||
v = _wxcode(GfeValues.wxVal(arg, k[4]))
|
||||
v = _wxcode(GfeValues.wxVal(arg, int(k[4])))
|
||||
elif k[:4] == 'Ints':
|
||||
v = _intcode(GfeValues.wxValInst(arg, k[4]))
|
||||
v = _intcode(GfeValues.wxValInst(arg, int(k[4])))
|
||||
else:
|
||||
v = _stripmsng(arg)
|
||||
dd[k] = v
|
||||
|
@ -545,12 +544,12 @@ def _retrieveMapData(siteIDs, timeSeconds, parameters=Parameters):
|
|||
results[siteID] = None
|
||||
return results
|
||||
|
||||
i = 0
|
||||
for siteID in siteIDs:
|
||||
pdc = pdcs.getContainer(i)
|
||||
for i, siteID in enumerate(siteIDs):
|
||||
data = None
|
||||
if i < pdcs.getSize() :
|
||||
++i
|
||||
data = _getData(pdc, timeSeconds * 1000)
|
||||
pdc = pdcs.getContainer(i)
|
||||
data = _getData(pdc, timeSeconds * 1000)
|
||||
|
||||
if data is None:
|
||||
_Logger.info('Data not available for %s', siteID)
|
||||
results[siteID] = data
|
||||
|
|
|
@ -21,22 +21,21 @@ package com.raytheon.edex.plugin.gfe.server.handler;
|
|||
|
||||
import java.awt.Point;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.TreeMap;
|
||||
|
||||
import javax.measure.unit.NonSI;
|
||||
import javax.measure.unit.SI;
|
||||
import javax.measure.unit.Unit;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.geotools.coverage.grid.GridGeometry2D;
|
||||
|
||||
import com.raytheon.edex.plugin.gfe.config.IFPServerConfigManager;
|
||||
import com.raytheon.edex.plugin.gfe.exception.GfeConfigurationException;
|
||||
import com.raytheon.edex.plugin.gfe.server.IFPServer;
|
||||
import com.raytheon.edex.plugin.gfe.server.database.GridDatabase;
|
||||
import com.raytheon.uf.common.dataplugin.gfe.db.objects.DatabaseID;
|
||||
import com.raytheon.uf.common.dataplugin.gfe.db.objects.GFERecord;
|
||||
import com.raytheon.uf.common.dataplugin.gfe.db.objects.GFERecord.GridType;
|
||||
import com.raytheon.uf.common.dataplugin.gfe.db.objects.GridLocation;
|
||||
import com.raytheon.uf.common.dataplugin.gfe.db.objects.ParmID;
|
||||
import com.raytheon.uf.common.dataplugin.gfe.point.GFEPointDataContainer;
|
||||
|
@ -44,15 +43,15 @@ import com.raytheon.uf.common.dataplugin.gfe.point.GFEPointDataContainers;
|
|||
import com.raytheon.uf.common.dataplugin.gfe.point.GFEPointDataView;
|
||||
import com.raytheon.uf.common.dataplugin.gfe.request.GetPointDataRequest;
|
||||
import com.raytheon.uf.common.dataplugin.gfe.server.message.ServerResponse;
|
||||
import com.raytheon.uf.common.dataplugin.gfe.server.request.GetGridRequest;
|
||||
import com.raytheon.uf.common.dataplugin.gfe.slice.DiscreteGridSlice;
|
||||
import com.raytheon.uf.common.dataplugin.gfe.slice.IGridSlice;
|
||||
import com.raytheon.uf.common.dataplugin.gfe.slice.ScalarGridSlice;
|
||||
import com.raytheon.uf.common.dataplugin.gfe.slice.VectorGridSlice;
|
||||
import com.raytheon.uf.common.geospatial.MapUtil;
|
||||
import com.raytheon.uf.common.geospatial.PointUtil;
|
||||
import com.raytheon.uf.common.dataplugin.gfe.slice.WeatherGridSlice;
|
||||
import com.raytheon.uf.common.pointdata.PointDataDescription.Type;
|
||||
import com.raytheon.uf.common.serialization.comm.IRequestHandler;
|
||||
import com.raytheon.uf.common.status.IUFStatusHandler;
|
||||
import com.raytheon.uf.common.status.UFStatus;
|
||||
import com.raytheon.uf.common.time.TimeRange;
|
||||
import com.raytheon.uf.common.time.util.TimeUtil;
|
||||
import com.vividsolutions.jts.geom.Coordinate;
|
||||
|
@ -70,6 +69,7 @@ import com.vividsolutions.jts.geom.Coordinate;
|
|||
* in a single grid request.
|
||||
* Jun 13, 2013 #2044 randerso Refactored to use IFPServer
|
||||
* Oct 31, 2013 #2508 randerso Change to use DiscreteGridSlice.getKeys()
|
||||
* Apr 23, 2014 #3006 randerso Restructured code to work with multi-hour grids
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -79,8 +79,8 @@ import com.vividsolutions.jts.geom.Coordinate;
|
|||
|
||||
public class GetPointDataHandler extends BaseGfeRequestHandler implements
|
||||
IRequestHandler<GetPointDataRequest> {
|
||||
|
||||
protected final transient Log logger = LogFactory.getLog(getClass());
|
||||
private static final transient IUFStatusHandler statusHandler = UFStatus
|
||||
.getHandler(GetPointDataHandler.class);
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
|
@ -89,143 +89,156 @@ public class GetPointDataHandler extends BaseGfeRequestHandler implements
|
|||
* com.raytheon.uf.common.serialization.comm.IRequestHandler#handleRequest
|
||||
* (com.raytheon.uf.common.serialization.comm.IServerRequest)
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public ServerResponse<?> handleRequest(GetPointDataRequest request)
|
||||
throws Exception {
|
||||
public ServerResponse<GFEPointDataContainers> handleRequest(
|
||||
GetPointDataRequest request) throws Exception {
|
||||
ServerResponse<GFEPointDataContainers> resp = new ServerResponse<GFEPointDataContainers>();
|
||||
|
||||
IFPServer ifpServer = getIfpServer(request);
|
||||
DatabaseID dbID = new DatabaseID(request.getDatabaseID());
|
||||
GridDatabase db = ifpServer.getGridParmMgr().getDatabase(dbID);
|
||||
GridLocation loc = ifpServer.getConfig().dbDomain();
|
||||
|
||||
List<String> parameters = request.getParameters();
|
||||
|
||||
DatabaseID db = new DatabaseID(request.getDatabaseID());
|
||||
List<ParmID> parmIds = new ArrayList<ParmID>(parameters.size());
|
||||
GridLocation loc = null;
|
||||
|
||||
try {
|
||||
loc = IFPServerConfigManager.getServerConfig(db.getSiteId())
|
||||
.dbDomain();
|
||||
} catch (GfeConfigurationException e) {
|
||||
String msg = "Error getting grid location for site "
|
||||
+ db.getSiteId();
|
||||
logger.error(msg, e);
|
||||
ServerResponse<?> error = new ServerResponse<Object>();
|
||||
error.addMessage(msg);
|
||||
return error;
|
||||
}
|
||||
|
||||
GridGeometry2D geom = MapUtil.getGridGeometry(loc);
|
||||
|
||||
for (String p : parameters) {
|
||||
parmIds.add(new ParmID(p, db));
|
||||
parmIds.add(new ParmID(p, dbID));
|
||||
}
|
||||
|
||||
List<TimeRange> times = new ArrayList<TimeRange>();
|
||||
for (int i = 0; i < request.getNumberHours(); i++) {
|
||||
long iStartTime = request.getStartTime()
|
||||
+ (i * TimeUtil.MILLIS_PER_HOUR);
|
||||
long iEndTime = iStartTime + TimeUtil.MILLIS_PER_HOUR;
|
||||
TimeRange tr = new TimeRange(iStartTime, iEndTime);
|
||||
times.add(tr);
|
||||
}
|
||||
int numHours = request.getNumberHours();
|
||||
long startTime = request.getStartTime();
|
||||
TimeRange overallTr = new TimeRange(new Date(startTime), numHours
|
||||
* TimeUtil.MILLIS_PER_HOUR);
|
||||
|
||||
List<Coordinate> coordinates = request.getCoordinates();
|
||||
ServerResponse<?> resp = null;
|
||||
resp = new ServerResponse<GFEPointDataContainers>();
|
||||
|
||||
Map<Coordinate, CoordinateInfo> infoMap = new HashMap<Coordinate, CoordinateInfo>();
|
||||
|
||||
boolean getSlices = false;
|
||||
|
||||
// See if any of the coordinates need the grid slices and set up info
|
||||
// map.
|
||||
for (Coordinate coordinate : coordinates) {
|
||||
CoordinateInfo info = new CoordinateInfo();
|
||||
CoordinateInfo info = new CoordinateInfo(numHours, coordinate, loc);
|
||||
infoMap.put(coordinate, info);
|
||||
|
||||
info.container = new GFEPointDataContainer();
|
||||
Point index = PointUtil.determineIndex(coordinate, loc.getCrs(),
|
||||
geom);
|
||||
info.x = index.x;
|
||||
info.y = index.y;
|
||||
info.containsCoord = !((info.x < 0) || (info.x >= loc.getNx())
|
||||
|| (info.y < 0) || (info.y >= loc.getNy()));
|
||||
|
||||
if (!getSlices) {
|
||||
getSlices = info.containsCoord;
|
||||
if (!info.containsCoord) {
|
||||
// coordinate is outside this GFE domain
|
||||
resp.addMessage(coordinate + " is outside the "
|
||||
+ request.getSiteID()
|
||||
+ " GFE domain, no data will be returned.");
|
||||
}
|
||||
}
|
||||
|
||||
for (TimeRange tr : times) {
|
||||
List<GetGridRequest> reqList = new ArrayList<GetGridRequest>();
|
||||
for (ParmID p : parmIds) {
|
||||
GetGridRequest req = new GetGridRequest();
|
||||
req.setParmId(p);
|
||||
List<GFERecord> reqRecList = new ArrayList<GFERecord>(
|
||||
times.size());
|
||||
GFERecord rec = new GFERecord(p, tr);
|
||||
reqRecList.add(rec);
|
||||
req.setRecords(reqRecList);
|
||||
reqList.add(req);
|
||||
for (ParmID parmId : parmIds) {
|
||||
ServerResponse<List<TimeRange>> invSr = db.getGridInventory(parmId,
|
||||
overallTr);
|
||||
if (!invSr.isOkay()) {
|
||||
String msg = "Error retrieving inventory for " + parmId + "\n"
|
||||
+ invSr.message();
|
||||
statusHandler.error(msg);
|
||||
resp.addMessage(msg);
|
||||
continue;
|
||||
}
|
||||
|
||||
try {
|
||||
ServerResponse<List<IGridSlice>> sr = null;
|
||||
if (getSlices) {
|
||||
sr = getIfpServer(request).getGridParmMgr().getGridData(
|
||||
reqList);
|
||||
}
|
||||
String param = parmId.getParmName();
|
||||
|
||||
for (Coordinate coordinate : coordinates) {
|
||||
CoordinateInfo info = infoMap.get(coordinate);
|
||||
boolean containsCoord = info.containsCoord;
|
||||
GFEPointDataContainer container = info.container;
|
||||
GFEPointDataView view = new GFEPointDataView();
|
||||
int x = info.x;
|
||||
int y = info.y;
|
||||
List<TimeRange> inv = invSr.getPayload();
|
||||
ServerResponse<List<IGridSlice>> slicesSR = db.getGridData(parmId,
|
||||
inv);
|
||||
if (!slicesSR.isOkay()) {
|
||||
String msg = "Error retrieving data for " + parmId + "\n"
|
||||
+ slicesSR.message();
|
||||
statusHandler.error(msg);
|
||||
resp.addMessage(msg);
|
||||
continue;
|
||||
}
|
||||
List<IGridSlice> slices = slicesSR.getPayload();
|
||||
Iterator<IGridSlice> sliceIter = slices.iterator();
|
||||
IGridSlice slice = null;
|
||||
for (int i = 0; i < numHours; i++) {
|
||||
Date time = new Date(startTime + (i * TimeUtil.MILLIS_PER_HOUR));
|
||||
try {
|
||||
for (Coordinate coordinate : coordinates) {
|
||||
CoordinateInfo info = infoMap.get(coordinate);
|
||||
boolean containsCoord = info.containsCoord;
|
||||
GFEPointDataView view = info.getView(time);
|
||||
int x = info.x;
|
||||
int y = info.y;
|
||||
|
||||
view.setData("time", Type.LONG, SI.MILLI(SI.SECOND), tr
|
||||
.getStart().getTime());
|
||||
view.setData("lat", Type.FLOAT, null, coordinate.y);
|
||||
view.setData("lon", Type.FLOAT, null, coordinate.x);
|
||||
// initially set all requested params to missing
|
||||
view.setData(parmId.getParmName(), Type.FLOAT,
|
||||
Unit.ONE, 999.0f);
|
||||
|
||||
// initially set all requested params to missing
|
||||
for (String param : parameters) {
|
||||
view.setData(param, Type.FLOAT, Unit.ONE, 999.0f);
|
||||
}
|
||||
if (containsCoord) {
|
||||
|
||||
if (containsCoord) {
|
||||
// find the slice that contains the current time
|
||||
if ((slice == null) && sliceIter.hasNext()) {
|
||||
slice = sliceIter.next();
|
||||
}
|
||||
if ((slice != null)
|
||||
&& (time.getTime() >= slice.getValidTime()
|
||||
.getEnd().getTime())
|
||||
&& sliceIter.hasNext()) {
|
||||
slice = sliceIter.next();
|
||||
}
|
||||
if ((slice != null)
|
||||
&& slice.getValidTime().contains(time)) {
|
||||
Unit<?> unit = slice.getGridInfo()
|
||||
.getUnitObject();
|
||||
|
||||
// set the retrieved data
|
||||
for (IGridSlice slice : sr.getPayload()) {
|
||||
String param = slice.getGridInfo().getParmID()
|
||||
.getParmName();
|
||||
Unit<?> unit = slice.getGridInfo().getUnitObject();
|
||||
if (slice instanceof VectorGridSlice) {
|
||||
VectorGridSlice gs = (VectorGridSlice) slice;
|
||||
Type type = Type.FLOAT;
|
||||
view.setData(param + "Dir", type,
|
||||
NonSI.DEGREE_ANGLE, gs.getDirGrid()
|
||||
.get(x, y));
|
||||
view.setData(param + "Spd", type, unit, gs
|
||||
.getMagGrid().get(x, y));
|
||||
} else if (slice instanceof ScalarGridSlice) {
|
||||
ScalarGridSlice gs = (ScalarGridSlice) slice;
|
||||
float val = gs.getScalarGrid().get(x, y);
|
||||
Type type = Type.FLOAT;
|
||||
view.setData(param, type, unit, val);
|
||||
} else if (slice instanceof DiscreteGridSlice) {
|
||||
DiscreteGridSlice gs = (DiscreteGridSlice) slice;
|
||||
byte value = gs.getDiscreteGrid().get(x, y);
|
||||
String key = gs.getKeys()[value].toString();
|
||||
Type type = Type.STRING;
|
||||
view.setData(param, type, unit, key);
|
||||
Type type;
|
||||
GridType gridType = slice.getGridInfo()
|
||||
.getGridType();
|
||||
switch (gridType) {
|
||||
case VECTOR:
|
||||
VectorGridSlice vectorSlice = (VectorGridSlice) slice;
|
||||
type = Type.FLOAT;
|
||||
view.setData(param + "Dir", type,
|
||||
NonSI.DEGREE_ANGLE, vectorSlice
|
||||
.getDirGrid().get(x, y));
|
||||
view.setData(param + "Spd", type, unit,
|
||||
vectorSlice.getMagGrid().get(x, y));
|
||||
break;
|
||||
case SCALAR:
|
||||
ScalarGridSlice scalarSlice = (ScalarGridSlice) slice;
|
||||
float val = scalarSlice.getScalarGrid()
|
||||
.get(x, y);
|
||||
type = Type.FLOAT;
|
||||
view.setData(param, type, unit, val);
|
||||
break;
|
||||
case DISCRETE:
|
||||
DiscreteGridSlice discreteSlice = (DiscreteGridSlice) slice;
|
||||
byte discreteValue = discreteSlice
|
||||
.getDiscreteGrid().get(x, y);
|
||||
String discreteKey = discreteSlice
|
||||
.getKeys()[discreteValue]
|
||||
.toString();
|
||||
type = Type.STRING;
|
||||
view.setData(param, type, unit, discreteKey);
|
||||
break;
|
||||
case WEATHER:
|
||||
WeatherGridSlice weatherSlice = (WeatherGridSlice) slice;
|
||||
byte wxValue = weatherSlice
|
||||
.getWeatherGrid().get(x, y);
|
||||
String wxKey = weatherSlice.getKeys()[wxValue]
|
||||
.toString();
|
||||
type = Type.STRING;
|
||||
view.setData(param, type, unit, wxKey);
|
||||
break;
|
||||
|
||||
default:
|
||||
String msg = "Unknown gridType: "
|
||||
+ gridType + " for " + parmId
|
||||
+ ", data will be ignored.";
|
||||
statusHandler.error(msg);
|
||||
resp.addMessage(msg);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
container.append(view);
|
||||
} catch (Exception e) {
|
||||
resp.addMessage(e.getMessage());
|
||||
}
|
||||
} catch (Exception e) {
|
||||
resp.addMessage(e.getMessage());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
GFEPointDataContainers gfeContainers = new GFEPointDataContainers();
|
||||
|
@ -235,11 +248,17 @@ public class GetPointDataHandler extends BaseGfeRequestHandler implements
|
|||
// Keep the results list in the same order as the request's
|
||||
// coordinate list.
|
||||
for (Coordinate coordinate : coordinates) {
|
||||
containers.add(infoMap.get(coordinate).container);
|
||||
CoordinateInfo info = infoMap.get(coordinate);
|
||||
|
||||
List<GFEPointDataView> views = new ArrayList<GFEPointDataView>(
|
||||
info.viewMap.values());
|
||||
|
||||
GFEPointDataContainer container = new GFEPointDataContainer();
|
||||
container.setViews(views);
|
||||
containers.add(container);
|
||||
}
|
||||
gfeContainers.setContainers(containers);
|
||||
((ServerResponse<GFEPointDataContainers>) resp)
|
||||
.setPayload(gfeContainers);
|
||||
resp.setPayload(gfeContainers);
|
||||
return resp;
|
||||
}
|
||||
|
||||
|
@ -247,12 +266,41 @@ public class GetPointDataHandler extends BaseGfeRequestHandler implements
|
|||
* Information for a coordinate.
|
||||
*/
|
||||
private class CoordinateInfo {
|
||||
GFEPointDataContainer container;
|
||||
Map<Date, GFEPointDataView> viewMap;
|
||||
|
||||
boolean containsCoord;
|
||||
|
||||
int x;
|
||||
|
||||
int y;
|
||||
|
||||
Coordinate coordinate;
|
||||
|
||||
public CoordinateInfo(int numHours, Coordinate coordinate,
|
||||
GridLocation gloc) {
|
||||
viewMap = new TreeMap<Date, GFEPointDataView>();
|
||||
this.coordinate = coordinate;
|
||||
|
||||
Point gridCell = gloc.gridCoordinate(coordinate);
|
||||
x = gridCell.x;
|
||||
y = gridCell.y;
|
||||
|
||||
containsCoord = !((x < 0) || (x >= gloc.getNx()) || (y < 0) || (y >= gloc
|
||||
.getNy()));
|
||||
}
|
||||
|
||||
public GFEPointDataView getView(Date fcstHour) {
|
||||
GFEPointDataView view = viewMap.get(fcstHour);
|
||||
if (view == null) {
|
||||
view = new GFEPointDataView();
|
||||
view.setData("time", Type.LONG, SI.MILLI(SI.SECOND),
|
||||
fcstHour.getTime());
|
||||
view.setData("lat", Type.FLOAT, null, coordinate.y);
|
||||
view.setData("lon", Type.FLOAT, null, coordinate.x);
|
||||
viewMap.put(fcstHour, view);
|
||||
}
|
||||
|
||||
return view;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -26,19 +26,19 @@ import java.util.Set;
|
|||
|
||||
import com.raytheon.uf.common.pointdata.IPointDataContainerReader;
|
||||
import com.raytheon.uf.common.pointdata.IPointDataViewReader;
|
||||
import com.raytheon.uf.common.serialization.ISerializableObject;
|
||||
import com.raytheon.uf.common.serialization.annotations.DynamicSerialize;
|
||||
import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement;
|
||||
|
||||
/**
|
||||
* TODO Add Description
|
||||
* GFE Point Data Container
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Aug 4, 2009 njensen Initial creation
|
||||
* Aug 4, 2009 njensen Initial creation
|
||||
* Apr 23, 2014 #3006 randerso Added toString to aid in debugging
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -47,8 +47,7 @@ import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement;
|
|||
*/
|
||||
|
||||
@DynamicSerialize
|
||||
public class GFEPointDataContainer implements IPointDataContainerReader,
|
||||
ISerializableObject {
|
||||
public class GFEPointDataContainer implements IPointDataContainerReader {
|
||||
|
||||
@DynamicSerializeElement
|
||||
private List<GFEPointDataView> views = new ArrayList<GFEPointDataView>();
|
||||
|
@ -104,4 +103,14 @@ public class GFEPointDataContainer implements IPointDataContainerReader,
|
|||
this.views = views;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see java.lang.Object#toString()
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
return views.toString();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -33,7 +33,8 @@ import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement;
|
|||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Mar 6, 2013 1735 rferrel Initial creation
|
||||
* Mar 6, 2013 1735 rferrel Initial creation
|
||||
* Apr 23, 2014 #3006 randerso Added toString to aid in debugging
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -86,4 +87,15 @@ public class GFEPointDataContainers {
|
|||
public GFEPointDataContainer getContainer(int index) {
|
||||
return containers.get(index);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see java.lang.Object#toString()
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
return containers.toString();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -31,12 +31,11 @@ import javax.persistence.Transient;
|
|||
import com.raytheon.uf.common.pointdata.IPointDataContainerReader;
|
||||
import com.raytheon.uf.common.pointdata.IPointDataViewReader;
|
||||
import com.raytheon.uf.common.pointdata.PointDataDescription.Type;
|
||||
import com.raytheon.uf.common.serialization.ISerializableObject;
|
||||
import com.raytheon.uf.common.serialization.annotations.DynamicSerialize;
|
||||
import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement;
|
||||
|
||||
/**
|
||||
* TODO Add Description
|
||||
* GFE Point Data View
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
|
@ -44,6 +43,8 @@ import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement;
|
|||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Aug 4, 2009 njensen Initial creation
|
||||
* Apr 23, 2014 #3006 randerso Added toString to aid in debugging
|
||||
* Fixed conversion of Double to float
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -52,8 +53,7 @@ import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement;
|
|||
*/
|
||||
|
||||
@DynamicSerialize
|
||||
public class GFEPointDataView implements IPointDataViewReader,
|
||||
ISerializableObject {
|
||||
public class GFEPointDataView implements IPointDataViewReader {
|
||||
|
||||
@DynamicSerializeElement
|
||||
private Map<String, GFEPointDataValue> valueMap = new HashMap<String, GFEPointDataValue>();
|
||||
|
@ -99,7 +99,7 @@ public class GFEPointDataView implements IPointDataViewReader,
|
|||
Type type = pd.getType();
|
||||
Object obj = pd.getValue();
|
||||
if (type == Type.FLOAT) {
|
||||
return (Float) obj;
|
||||
return ((Number) obj).floatValue();
|
||||
} else if (type == Type.STRING) {
|
||||
return Float.valueOf((String) obj);
|
||||
} else {
|
||||
|
@ -264,4 +264,14 @@ public class GFEPointDataView implements IPointDataViewReader,
|
|||
parent = container;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see java.lang.Object#toString()
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
return valueMap.toString();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue