Issue #2672 Fix radar dataaccess from pure python.
Former-commit-id:add98f22b1
[formerly3e0cba04c0
] [formerlye19b4518ef
[formerly 8beef8db2ffe599c9167dbd61aed8243d3a0af0e]] Former-commit-id:e19b4518ef
Former-commit-id:399e3d3f07
This commit is contained in:
parent
08bffb26ca
commit
2be385e6b8
2 changed files with 69 additions and 8 deletions
|
@ -19,8 +19,12 @@
|
|||
**/
|
||||
package com.raytheon.uf.common.dataaccess.response;
|
||||
|
||||
import javax.measure.unit.Unit;
|
||||
|
||||
import com.raytheon.uf.common.dataaccess.grid.IGridData;
|
||||
import com.raytheon.uf.common.geospatial.interpolation.data.DataDestination;
|
||||
import com.raytheon.uf.common.geospatial.interpolation.data.FloatArrayWrapper;
|
||||
import com.raytheon.uf.common.geospatial.interpolation.data.UnitConvertingDataDestination;
|
||||
import com.raytheon.uf.common.serialization.annotations.DynamicSerialize;
|
||||
import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement;
|
||||
|
||||
|
@ -31,9 +35,10 @@ import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement;
|
|||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Jun 4, 2013 dgilling Initial creation
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------- -------- ----------- --------------------------
|
||||
* Jun 04, 2013 dgilling Initial creation
|
||||
* Feb 04, 2014 2672 bsteffen Better handling of odd units.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -61,12 +66,36 @@ public class GridResponseData extends AbstractResponseData {
|
|||
super(data);
|
||||
|
||||
parameter = data.getParameter();
|
||||
if (data.getUnit() != null) {
|
||||
unit = data.getUnit().toString();
|
||||
}
|
||||
|
||||
Unit<?> dataUnit = data.getUnit();
|
||||
FloatArrayWrapper dataGrid = new FloatArrayWrapper(
|
||||
data.getGridGeometry());
|
||||
dataGrid = data.populateData(dataGrid);
|
||||
DataDestination dataDest = dataGrid;
|
||||
if (data.getUnit() != null) {
|
||||
try {
|
||||
this.unit = dataUnit.toString();
|
||||
} catch (IllegalArgumentException e1) {
|
||||
/*
|
||||
* Not all units are representable as strings, convert to the
|
||||
* standard unit so that the units can be preserved in string
|
||||
* form.
|
||||
*/
|
||||
Unit<?> stdUnit = dataUnit.getStandardUnit();
|
||||
try {
|
||||
this.unit = stdUnit.toString();
|
||||
dataDest = new UnitConvertingDataDestination(
|
||||
dataUnit.toStandardUnit(), dataDest);
|
||||
} catch (IllegalArgumentException e2) {
|
||||
/*
|
||||
* The standard unit is also unstringable so treat the data
|
||||
* as unitless.
|
||||
*/
|
||||
this.unit = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
data.populateData(dataDest);
|
||||
gridData = dataGrid.getArray();
|
||||
}
|
||||
|
||||
|
|
|
@ -139,7 +139,7 @@ public class RadarGridFactory extends AbstractGridDataPluginFactory implements
|
|||
defaultGridData.setUnit(radarRecord.getDataUnit());
|
||||
defaultGridData.setLevel(getTiltLevel(radarRecord
|
||||
.getPrimaryElevationAngle()));
|
||||
defaultGridData.setLocationName(radarRecord.getIcao());
|
||||
defaultGridData.setLocationName(generateLocationName(radarRecord));
|
||||
|
||||
Map<String, Object> attributes = new HashMap<String, Object>();
|
||||
attributes.put(ICAO, radarRecord.getIcao());
|
||||
|
@ -150,6 +150,38 @@ public class RadarGridFactory extends AbstractGridDataPluginFactory implements
|
|||
return defaultGridData;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a unique name describing the location of the radar data. The name
|
||||
* always includes icao, elevation angle, num bins and num radials. For
|
||||
* radial data it also includes the first and last angle of the radial data.
|
||||
* Theoretically two radial geometries could have the same name but
|
||||
* internally different angleData but this is very unlikely and the points
|
||||
* would be very nearly identical.
|
||||
*
|
||||
*
|
||||
* @param radarRecord
|
||||
* a record.
|
||||
* @return A unique location name
|
||||
*/
|
||||
protected String generateLocationName(RadarRecord radarRecord){
|
||||
StringBuilder locationName = new StringBuilder(32);
|
||||
locationName.append(radarRecord.getIcao());
|
||||
locationName.append("_");
|
||||
locationName.append(radarRecord.getTrueElevationAngle());
|
||||
locationName.append("_");
|
||||
locationName.append(radarRecord.getNumBins());
|
||||
locationName.append("_");
|
||||
locationName.append(radarRecord.getNumRadials());
|
||||
float[] angleData = radarRecord.getAngleData();
|
||||
if (angleData != null) {
|
||||
locationName.append("_");
|
||||
locationName.append(angleData[0]);
|
||||
locationName.append("_");
|
||||
locationName.append(angleData[angleData.length - 1]);
|
||||
}
|
||||
return locationName.toString();
|
||||
}
|
||||
|
||||
protected RadarRecord asRadarRecord(PluginDataObject pdo) {
|
||||
if (pdo instanceof RadarRecord == false) {
|
||||
throw new DataRetrievalException(this.getClass().getSimpleName()
|
||||
|
|
Loading…
Add table
Reference in a new issue