Issue #189 fix several errors with grid resources when there is no valid data.
Former-commit-id:392e64f33e
[formerly392e64f33e
[formerly 98d52a1d86b5b5325c678a3aedbc4d20c009413d]] Former-commit-id:efb19ceb6f
Former-commit-id:a9c7c3297c
This commit is contained in:
parent
27d3146ec0
commit
c140338859
7 changed files with 82 additions and 66 deletions
|
@ -118,7 +118,7 @@ public class VizGroupResource extends
|
|||
if (pair.getResource() != null) {
|
||||
AbstractVizResource<?,?> rsc = pair.getResource();
|
||||
value = rsc.inspect(coord);
|
||||
if (value.equals(NO_DATA) == false) {
|
||||
if (value.equalsIgnoreCase(NO_DATA) == false) {
|
||||
return value;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -81,7 +81,7 @@ public class TiltRequestableData extends AbstractRequestableData {
|
|||
fdr = TiltUtils.getInstance().getHeightGrid(coverage,
|
||||
level.getLevelonevalue());
|
||||
}
|
||||
if (arg instanceof Request) {
|
||||
if (fdr != null && arg instanceof Request) {
|
||||
return SliceUtil.slice(fdr, (Request) arg);
|
||||
} else {
|
||||
return fdr;
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
**/
|
||||
package com.raytheon.viz.grid.rsc;
|
||||
|
||||
import com.raytheon.uf.viz.core.drawables.ColorMapParameters;
|
||||
import com.raytheon.uf.viz.core.rsc.AbstractVizResource;
|
||||
import com.raytheon.uf.viz.core.rsc.capabilities.ColorMapCapability;
|
||||
import com.raytheon.viz.core.rsc.VizGroupResource;
|
||||
|
@ -45,6 +46,7 @@ public class FfgGridNameGenerator extends GridNameGenerator {
|
|||
|
||||
public FfgGridNameGenerator() {
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
|
@ -54,8 +56,15 @@ public class FfgGridNameGenerator extends GridNameGenerator {
|
|||
*/
|
||||
@Override
|
||||
public String getName(AbstractVizResource<?, ?> absResource) {
|
||||
String unit = ((VizGroupResource) absResource).getCapability(ColorMapCapability.class).getColorMapParameters().getDisplayUnit().toString();
|
||||
return ((VizGroupResourceData) absResource.getResourceData()).getName() + "(" + unit + ")";
|
||||
String unit = "";
|
||||
ColorMapParameters params = ((VizGroupResource) absResource)
|
||||
.getCapability(ColorMapCapability.class)
|
||||
.getColorMapParameters();
|
||||
if (params != null && params.getDisplayUnit() != null) {
|
||||
unit = params.getDisplayUnit().toString();
|
||||
}
|
||||
return ((VizGroupResourceData) absResource.getResourceData()).getName()
|
||||
+ "(" + unit + ")";
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -72,6 +72,7 @@ import com.raytheon.uf.viz.core.rsc.capabilities.ImagingCapability;
|
|||
import com.raytheon.uf.viz.core.rsc.capabilities.MagnificationCapability;
|
||||
import com.raytheon.uf.viz.core.rsc.capabilities.OutlineCapability;
|
||||
import com.raytheon.uf.viz.core.style.AbstractStylePreferences;
|
||||
import com.raytheon.uf.viz.core.style.MatchCriteria;
|
||||
import com.raytheon.uf.viz.core.style.ParamLevelMatchCriteria;
|
||||
import com.raytheon.uf.viz.core.style.StyleManager;
|
||||
import com.raytheon.uf.viz.core.style.StyleManager.StyleType;
|
||||
|
@ -346,23 +347,26 @@ public abstract class AbstractGridResource<T extends AbstractResourceData>
|
|||
protected void initStylePreferences() throws VizStyleException {
|
||||
DisplayType displayType = getDisplayType();
|
||||
StyleRule styleRule = null;
|
||||
MatchCriteria criteria = getMatchCriteria();
|
||||
if (criteria != null) {
|
||||
switch (displayType) {
|
||||
case IMAGE:
|
||||
styleRule = StyleManager.getInstance().getStyleRule(
|
||||
StyleType.IMAGERY, getMatchCriteria());
|
||||
StyleType.IMAGERY, criteria);
|
||||
break;
|
||||
case CONTOUR:
|
||||
case STREAMLINE:
|
||||
styleRule = StyleManager.getInstance().getStyleRule(
|
||||
StyleType.CONTOUR, getMatchCriteria());
|
||||
StyleType.CONTOUR, criteria);
|
||||
break;
|
||||
case BARB:
|
||||
case ARROW:
|
||||
case DUALARROW:
|
||||
styleRule = StyleManager.getInstance().getStyleRule(
|
||||
StyleType.ARROW, getMatchCriteria());
|
||||
StyleType.ARROW, criteria);
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (styleRule != null) {
|
||||
stylePreferences = styleRule.getPreferences();
|
||||
if (stylePreferences instanceof ImagePreferences) {
|
||||
|
|
|
@ -124,6 +124,9 @@ public class D2DGridResource extends GridResource<GridResourceData> implements
|
|||
gridRecord, descriptor);
|
||||
if (dataRecs == null) {
|
||||
dataRecs = DataCubeContainer.getDataRecord(gridRecord);
|
||||
if (dataRecs == null) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
// For world wide lat lon grids we reproject, this is done to match A1,
|
||||
// but it also makes the wind barbs look more evenly spaced near the
|
||||
|
|
|
@ -75,7 +75,10 @@ public class GridResource<T extends AbstractResourceData> extends
|
|||
List<GeneralGridData> dataList = new ArrayList<GeneralGridData>(
|
||||
pdos.size());
|
||||
for (PluginDataObject pdo : pdos) {
|
||||
dataList.add(getData((GridRecord) pdo));
|
||||
GeneralGridData data = getData((GridRecord) pdo);
|
||||
if (data != null) {
|
||||
dataList.add(data);
|
||||
}
|
||||
}
|
||||
return dataList;
|
||||
}
|
||||
|
@ -84,6 +87,9 @@ public class GridResource<T extends AbstractResourceData> extends
|
|||
throws VizException {
|
||||
Unit<?> dataUnit = gridRecord.getParameter().getUnit();
|
||||
IDataRecord[] dataRecs = DataCubeContainer.getDataRecord(gridRecord);
|
||||
if (dataRecs == null) {
|
||||
return null;
|
||||
}
|
||||
return getData(dataRecs, gridRecord.getLocation().getGridGeometry(),
|
||||
dataUnit);
|
||||
}
|
||||
|
|
|
@ -34,7 +34,6 @@ import com.raytheon.uf.common.dataplugin.radar.RadarStation;
|
|||
import com.raytheon.uf.common.datastorage.records.FloatDataRecord;
|
||||
import com.raytheon.uf.common.geospatial.MapUtil;
|
||||
import com.raytheon.uf.common.gridcoverage.GridCoverage;
|
||||
import com.raytheon.uf.common.gridcoverage.LatLonGridCoverage;
|
||||
import com.raytheon.uf.common.status.IUFStatusHandler;
|
||||
import com.raytheon.uf.common.status.UFStatus;
|
||||
import com.raytheon.uf.common.status.UFStatus.Priority;
|
||||
|
@ -62,13 +61,13 @@ public class TiltUtils {
|
|||
|
||||
private static class CacheKey {
|
||||
|
||||
private final int coverageId;
|
||||
private final Integer coverageId;
|
||||
|
||||
private final double lat;
|
||||
|
||||
private final double lon;
|
||||
|
||||
public CacheKey(int coverageId, double lon, double lat) {
|
||||
public CacheKey(Integer coverageId, double lon, double lat) {
|
||||
this.coverageId = coverageId;
|
||||
this.lat = lat;
|
||||
this.lon = lon;
|
||||
|
@ -78,7 +77,8 @@ public class TiltUtils {
|
|||
public int hashCode() {
|
||||
final int prime = 31;
|
||||
int result = 1;
|
||||
result = prime * result + coverageId;
|
||||
result = prime * result
|
||||
+ ((coverageId == null) ? 0 : coverageId.hashCode());
|
||||
long temp;
|
||||
temp = Double.doubleToLongBits(lat);
|
||||
result = prime * result + (int) (temp ^ (temp >>> 32));
|
||||
|
@ -96,7 +96,10 @@ public class TiltUtils {
|
|||
if (getClass() != obj.getClass())
|
||||
return false;
|
||||
CacheKey other = (CacheKey) obj;
|
||||
if (coverageId != other.coverageId)
|
||||
if (coverageId == null) {
|
||||
if (other.coverageId != null)
|
||||
return false;
|
||||
} else if (!coverageId.equals(other.coverageId))
|
||||
return false;
|
||||
if (Double.doubleToLongBits(lat) != Double
|
||||
.doubleToLongBits(other.lat))
|
||||
|
@ -148,9 +151,9 @@ public class TiltUtils {
|
|||
|
||||
private FloatDataRecord getHeightGrid(RadarStation radar,
|
||||
GridCoverage coverage, double tilt) {
|
||||
if (radar != null) {
|
||||
CacheKey cacheKey = new CacheKey(coverage.getId(), radar.getLon(),
|
||||
radar.getLat());
|
||||
if (radar != null) {
|
||||
GridGeometry2D geometry = MapUtil.getGridGeometry(coverage);
|
||||
GridEnvelope2D gridRange = geometry.getGridRange2D();
|
||||
double[] radius = null;
|
||||
|
@ -160,8 +163,6 @@ public class TiltUtils {
|
|||
}
|
||||
if (radius == null) {
|
||||
try {
|
||||
|
||||
if (!(coverage instanceof LatLonGridCoverage)) {
|
||||
MathTransform gridToCrs = geometry.getGridToCRS();
|
||||
MathTransform fromLatLon = MapUtil
|
||||
.getTransformFromLatLon(coverage.getCrs());
|
||||
|
@ -169,8 +170,7 @@ public class TiltUtils {
|
|||
double[] radarLonLat = new double[] { radar.getLon(),
|
||||
radar.getLat() };
|
||||
double[] radarCrsCoord = new double[2];
|
||||
fromLatLon.transform(radarLonLat, 0, radarCrsCoord, 0,
|
||||
1);
|
||||
fromLatLon.transform(radarLonLat, 0, radarCrsCoord, 0, 1);
|
||||
int numPoints = gridRange.height * gridRange.width;
|
||||
double[] gridCoordGrid = new double[numPoints * 2];
|
||||
int offset = 0;
|
||||
|
@ -189,15 +189,7 @@ public class TiltUtils {
|
|||
- gridCoordGrid[offset++];
|
||||
double yDist = radarCrsCoord[1]
|
||||
- gridCoordGrid[offset++];
|
||||
radius[i] = Math
|
||||
.sqrt(xDist * xDist + yDist * yDist);
|
||||
}
|
||||
} else {
|
||||
// use geodetic calculator
|
||||
MathTransform gridToLatLon = geometry.getGridToCRS();
|
||||
|
||||
radius = getRadius(radar, gridRange, gridToLatLon);
|
||||
|
||||
radius[i] = Math.sqrt(xDist * xDist + yDist * yDist);
|
||||
}
|
||||
gridRadiusCache.put(cacheKey, new SoftReference<double[]>(
|
||||
radius));
|
||||
|
@ -206,12 +198,14 @@ public class TiltUtils {
|
|||
.handle(Priority.PROBLEM,
|
||||
"Error occurred generating height grid for radar tilt",
|
||||
e);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
return getHeightGrid(radar, gridRange, radius, tilt);
|
||||
}
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public FloatDataRecord getHeightGrid(GridEnvelope2D gridRange,
|
||||
MathTransform gridToLatLon, double tilt) {
|
||||
|
|
Loading…
Add table
Reference in a new issue