Merge "Issue #1553 minor fixes to radar grid access." into development

Former-commit-id: f0be76e8ee [formerly f113911f360b69d9a831b1fe7aed8ba29806316d]
Former-commit-id: 8a141029ff
This commit is contained in:
Nate Jensen 2013-02-11 09:53:51 -06:00 committed by Gerrit Code Review
commit f938432a6f
3 changed files with 48 additions and 13 deletions

View file

@ -19,7 +19,6 @@
**/
package com.raytheon.uf.common.dataplugin.npp.viirs.projection;
import org.geotools.referencing.crs.DefaultProjectedCRS;
import org.geotools.referencing.operation.DefaultMathTransformFactory;
import org.opengis.parameter.ParameterValueGroup;
import org.opengis.referencing.FactoryException;
@ -50,7 +49,8 @@ public class VIIRSMapProjectionFactory {
/** Using single factory is faster due to internal caching */
private static DefaultMathTransformFactory dmtFactory = new DefaultMathTransformFactory();
public static ProjectedCRS construct(VIIRSSpatialCoverage record)
public static synchronized ProjectedCRS construct(
VIIRSSpatialCoverage record)
throws FactoryException {
try {
ParameterValueGroup group = dmtFactory

View file

@ -57,6 +57,7 @@ import com.raytheon.uf.common.datastorage.Request;
import com.raytheon.uf.common.datastorage.records.ByteDataRecord;
import com.raytheon.uf.common.datastorage.records.IDataRecord;
import com.raytheon.uf.common.geospatial.interpolation.data.DataSource;
import com.raytheon.uf.common.geospatial.interpolation.data.DataWrapper1D;
import com.raytheon.uf.common.localization.PathManagerFactory;
import com.vividsolutions.jts.geom.Coordinate;
@ -145,8 +146,11 @@ public class RadarGridFactory extends AbstractGridDataPluginFactory implements
PluginDataObject pdo, GridGeometry2D gridGeometry,
IDataRecord dataRecord) {
RadarRecord radarRecord = asRadarRecord(pdo);
DataSource source = DataWrapperUtil.constructArrayWrapper(dataRecord,
DataWrapper1D wrapper = DataWrapperUtil.constructArrayWrapper(
dataRecord,
false);
wrapper.setFillValue(0);
DataSource source = wrapper;
if (radarRecord.getFormat().equals(RADIAL_FORMAT)) {
// The raw data is in bin,radial format but the grid geometries we
// use are radial,bin so need to do some swapping.

View file

@ -34,7 +34,8 @@ import com.raytheon.uf.common.geospatial.MapUtil;
import com.vividsolutions.jts.geom.Coordinate;
/**
* TODO Add Description
* Convenient location for building CRS and GridGeometries for radar radial
* data.
*
* <pre>
*
@ -54,8 +55,8 @@ public class RadarProjectionFactory {
private static DefaultMathTransformFactory dmtFactory = new DefaultMathTransformFactory();
public static ProjectedCRS constructAzRan(Coordinate centerLatLon)
throws FactoryException {
public static synchronized ProjectedCRS constructAzRan(
Coordinate centerLatLon) throws FactoryException {
ParameterValueGroup group = dmtFactory
.getDefaultParameters("Azimuth_Range");
group.parameter(AbstractProvider.SEMI_MAJOR.getName().getCode())
@ -69,9 +70,9 @@ public class RadarProjectionFactory {
return MapUtil.constructProjection("Azimuth Range", group);
}
public static ProjectedCRS constructRadialBin(Coordinate centerLatLon,
float[] angleData, double binWidth, double tiltAngle)
throws FactoryException {
public static synchronized ProjectedCRS constructRadialBin(
Coordinate centerLatLon, float[] angleData, double binWidth,
double tiltAngle) throws FactoryException {
ParameterValueGroup group = dmtFactory
.getDefaultParameters("Radial_Bin");
group.parameter(AbstractProvider.SEMI_MAJOR.getName().getCode())
@ -94,13 +95,41 @@ public class RadarProjectionFactory {
return MapUtil.constructProjection("Radial Bin", group);
}
/**
* Construct a grid geometry with a radial bin projection.
*
* @param centerLatLon
* - the location at the center of the projection.
* @param angleData
* - The angles of the various radials
* @param binWidth
* - the width of bins in meters.
* @param tiltAngle
* - the elevation angle of radar tilt, 0 if there is no tilt.
* @param numBins
* - the number of bins for the geometry
* @param binRadial
* - If true then the geometry will be constructed for data in
* bin,radial(bin-major) format as opposed to
* radial,bin(radial-major). This can be good becauase radar data
* is currently stored in bin,radial alignment in hdf5. Use this
* option with caution because not all code using GridGeometries
* will correctly use the result, for example the switch is lost
* in serialization. When this is set to false then the resulting
* GridGeometry should work with any code using GridGeometries
* but the raw data will need to be realigned to radial,bin
* format.
*
* @return
* @throws FactoryException
*/
public static GridGeometry2D constructGridGeometry(Coordinate centerLatLon,
float[] angleData, double binWidth, double tiltAngle, int numBins,
boolean swapXY) throws FactoryException {
boolean binRadial) throws FactoryException {
CoordinateReferenceSystem crs = constructRadialBin(centerLatLon,
angleData, binWidth, tiltAngle);
GridEnvelope2D gridRange = null;
if (swapXY) {
if (binRadial) {
gridRange = new GridEnvelope2D(0, 0, numBins, angleData.length);
} else {
gridRange = new GridEnvelope2D(0, 0, angleData.length, numBins);
@ -109,8 +138,10 @@ public class RadarProjectionFactory {
numBins);
GridToEnvelopeMapper mapper = new GridToEnvelopeMapper(gridRange,
envelope);
mapper.setSwapXY(swapXY);
mapper.setReverseAxis(new boolean[] { false, false });
mapper.setSwapXY(binRadial);
if (binRadial) {
mapper.setReverseAxis(new boolean[] { false, false });
}
return new GridGeometry2D(gridRange, mapper.createTransform(), crs);
}