Issue #1553 minor fixes to radar grid access.

Former-commit-id: 0d5997a70653c9a327501a868b5a243d40fb66fb
This commit is contained in:
Ben Steffensmeier 2013-02-08 11:45:14 -06:00
parent f204191837
commit 701c135510
3 changed files with 48 additions and 13 deletions

View file

@ -19,7 +19,6 @@
**/ **/
package com.raytheon.uf.common.dataplugin.npp.viirs.projection; package com.raytheon.uf.common.dataplugin.npp.viirs.projection;
import org.geotools.referencing.crs.DefaultProjectedCRS;
import org.geotools.referencing.operation.DefaultMathTransformFactory; import org.geotools.referencing.operation.DefaultMathTransformFactory;
import org.opengis.parameter.ParameterValueGroup; import org.opengis.parameter.ParameterValueGroup;
import org.opengis.referencing.FactoryException; import org.opengis.referencing.FactoryException;
@ -50,7 +49,8 @@ public class VIIRSMapProjectionFactory {
/** Using single factory is faster due to internal caching */ /** Using single factory is faster due to internal caching */
private static DefaultMathTransformFactory dmtFactory = new DefaultMathTransformFactory(); private static DefaultMathTransformFactory dmtFactory = new DefaultMathTransformFactory();
public static ProjectedCRS construct(VIIRSSpatialCoverage record) public static synchronized ProjectedCRS construct(
VIIRSSpatialCoverage record)
throws FactoryException { throws FactoryException {
try { try {
ParameterValueGroup group = dmtFactory 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.ByteDataRecord;
import com.raytheon.uf.common.datastorage.records.IDataRecord; 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.DataSource;
import com.raytheon.uf.common.geospatial.interpolation.data.DataWrapper1D;
import com.raytheon.uf.common.localization.PathManagerFactory; import com.raytheon.uf.common.localization.PathManagerFactory;
import com.vividsolutions.jts.geom.Coordinate; import com.vividsolutions.jts.geom.Coordinate;
@ -145,8 +146,11 @@ public class RadarGridFactory extends AbstractGridDataPluginFactory implements
PluginDataObject pdo, GridGeometry2D gridGeometry, PluginDataObject pdo, GridGeometry2D gridGeometry,
IDataRecord dataRecord) { IDataRecord dataRecord) {
RadarRecord radarRecord = asRadarRecord(pdo); RadarRecord radarRecord = asRadarRecord(pdo);
DataSource source = DataWrapperUtil.constructArrayWrapper(dataRecord, DataWrapper1D wrapper = DataWrapperUtil.constructArrayWrapper(
dataRecord,
false); false);
wrapper.setFillValue(0);
DataSource source = wrapper;
if (radarRecord.getFormat().equals(RADIAL_FORMAT)) { if (radarRecord.getFormat().equals(RADIAL_FORMAT)) {
// The raw data is in bin,radial format but the grid geometries we // The raw data is in bin,radial format but the grid geometries we
// use are radial,bin so need to do some swapping. // 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; import com.vividsolutions.jts.geom.Coordinate;
/** /**
* TODO Add Description * Convenient location for building CRS and GridGeometries for radar radial
* data.
* *
* <pre> * <pre>
* *
@ -54,8 +55,8 @@ public class RadarProjectionFactory {
private static DefaultMathTransformFactory dmtFactory = new DefaultMathTransformFactory(); private static DefaultMathTransformFactory dmtFactory = new DefaultMathTransformFactory();
public static ProjectedCRS constructAzRan(Coordinate centerLatLon) public static synchronized ProjectedCRS constructAzRan(
throws FactoryException { Coordinate centerLatLon) throws FactoryException {
ParameterValueGroup group = dmtFactory ParameterValueGroup group = dmtFactory
.getDefaultParameters("Azimuth_Range"); .getDefaultParameters("Azimuth_Range");
group.parameter(AbstractProvider.SEMI_MAJOR.getName().getCode()) group.parameter(AbstractProvider.SEMI_MAJOR.getName().getCode())
@ -69,9 +70,9 @@ public class RadarProjectionFactory {
return MapUtil.constructProjection("Azimuth Range", group); return MapUtil.constructProjection("Azimuth Range", group);
} }
public static ProjectedCRS constructRadialBin(Coordinate centerLatLon, public static synchronized ProjectedCRS constructRadialBin(
float[] angleData, double binWidth, double tiltAngle) Coordinate centerLatLon, float[] angleData, double binWidth,
throws FactoryException { double tiltAngle) throws FactoryException {
ParameterValueGroup group = dmtFactory ParameterValueGroup group = dmtFactory
.getDefaultParameters("Radial_Bin"); .getDefaultParameters("Radial_Bin");
group.parameter(AbstractProvider.SEMI_MAJOR.getName().getCode()) group.parameter(AbstractProvider.SEMI_MAJOR.getName().getCode())
@ -94,13 +95,41 @@ public class RadarProjectionFactory {
return MapUtil.constructProjection("Radial Bin", group); 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, public static GridGeometry2D constructGridGeometry(Coordinate centerLatLon,
float[] angleData, double binWidth, double tiltAngle, int numBins, float[] angleData, double binWidth, double tiltAngle, int numBins,
boolean swapXY) throws FactoryException { boolean binRadial) throws FactoryException {
CoordinateReferenceSystem crs = constructRadialBin(centerLatLon, CoordinateReferenceSystem crs = constructRadialBin(centerLatLon,
angleData, binWidth, tiltAngle); angleData, binWidth, tiltAngle);
GridEnvelope2D gridRange = null; GridEnvelope2D gridRange = null;
if (swapXY) { if (binRadial) {
gridRange = new GridEnvelope2D(0, 0, numBins, angleData.length); gridRange = new GridEnvelope2D(0, 0, numBins, angleData.length);
} else { } else {
gridRange = new GridEnvelope2D(0, 0, angleData.length, numBins); gridRange = new GridEnvelope2D(0, 0, angleData.length, numBins);
@ -109,8 +138,10 @@ public class RadarProjectionFactory {
numBins); numBins);
GridToEnvelopeMapper mapper = new GridToEnvelopeMapper(gridRange, GridToEnvelopeMapper mapper = new GridToEnvelopeMapper(gridRange,
envelope); envelope);
mapper.setSwapXY(swapXY); mapper.setSwapXY(binRadial);
mapper.setReverseAxis(new boolean[] { false, false }); if (binRadial) {
mapper.setReverseAxis(new boolean[] { false, false });
}
return new GridGeometry2D(gridRange, mapper.createTransform(), crs); return new GridGeometry2D(gridRange, mapper.createTransform(), crs);
} }