Merge "Issue #2672 Fix radar dataaccess from pure python." into development
Former-commit-id:dd821703b6
[formerly82fde2011c
] [formerly698a4f827d
] [formerlydd821703b6
[formerly82fde2011c
] [formerly698a4f827d
] [formerly713ec598c3
[formerly698a4f827d
[formerly 6c8fba6afd4b5e28b425b6058e40130a1dd0b518]]]] Former-commit-id:713ec598c3
Former-commit-id:ce2568b36b
[formerly05edfb90d5
] [formerly c65265d8b3848ad6c99e526ec9bdee82f0097eb3 [formerly79cbb8d79a
]] Former-commit-id: 48aa64701649e8ab565c825ab2b63fe15c4aff21 [formerly93458ab911
] Former-commit-id:51e9dec1c0
This commit is contained in:
commit
ee6a119baf
2 changed files with 69 additions and 8 deletions
|
@ -19,8 +19,12 @@
|
||||||
**/
|
**/
|
||||||
package com.raytheon.uf.common.dataaccess.response;
|
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.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.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.DynamicSerialize;
|
||||||
import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement;
|
import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement;
|
||||||
|
|
||||||
|
@ -31,9 +35,10 @@ import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement;
|
||||||
*
|
*
|
||||||
* SOFTWARE HISTORY
|
* SOFTWARE HISTORY
|
||||||
*
|
*
|
||||||
* Date Ticket# Engineer Description
|
* Date Ticket# Engineer Description
|
||||||
* ------------ ---------- ----------- --------------------------
|
* ------------- -------- ----------- --------------------------
|
||||||
* Jun 4, 2013 dgilling Initial creation
|
* Jun 04, 2013 dgilling Initial creation
|
||||||
|
* Feb 04, 2014 2672 bsteffen Better handling of odd units.
|
||||||
*
|
*
|
||||||
* </pre>
|
* </pre>
|
||||||
*
|
*
|
||||||
|
@ -61,12 +66,36 @@ public class GridResponseData extends AbstractResponseData {
|
||||||
super(data);
|
super(data);
|
||||||
|
|
||||||
parameter = data.getParameter();
|
parameter = data.getParameter();
|
||||||
if (data.getUnit() != null) {
|
|
||||||
unit = data.getUnit().toString();
|
Unit<?> dataUnit = data.getUnit();
|
||||||
}
|
|
||||||
FloatArrayWrapper dataGrid = new FloatArrayWrapper(
|
FloatArrayWrapper dataGrid = new FloatArrayWrapper(
|
||||||
data.getGridGeometry());
|
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();
|
gridData = dataGrid.getArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -139,7 +139,7 @@ public class RadarGridFactory extends AbstractGridDataPluginFactory implements
|
||||||
defaultGridData.setUnit(radarRecord.getDataUnit());
|
defaultGridData.setUnit(radarRecord.getDataUnit());
|
||||||
defaultGridData.setLevel(getTiltLevel(radarRecord
|
defaultGridData.setLevel(getTiltLevel(radarRecord
|
||||||
.getPrimaryElevationAngle()));
|
.getPrimaryElevationAngle()));
|
||||||
defaultGridData.setLocationName(radarRecord.getIcao());
|
defaultGridData.setLocationName(generateLocationName(radarRecord));
|
||||||
|
|
||||||
Map<String, Object> attributes = new HashMap<String, Object>();
|
Map<String, Object> attributes = new HashMap<String, Object>();
|
||||||
attributes.put(ICAO, radarRecord.getIcao());
|
attributes.put(ICAO, radarRecord.getIcao());
|
||||||
|
@ -150,6 +150,38 @@ public class RadarGridFactory extends AbstractGridDataPluginFactory implements
|
||||||
return defaultGridData;
|
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) {
|
protected RadarRecord asRadarRecord(PluginDataObject pdo) {
|
||||||
if (pdo instanceof RadarRecord == false) {
|
if (pdo instanceof RadarRecord == false) {
|
||||||
throw new DataRetrievalException(this.getClass().getSimpleName()
|
throw new DataRetrievalException(this.getClass().getSimpleName()
|
||||||
|
|
Loading…
Add table
Reference in a new issue