Merge "Issue #2122 Committing Geostationary projection for GOES-R fixed grid as well as cleanup to SatResource code." into development

Former-commit-id: d679aae13498d67d79a1134275f1016699583e1f
This commit is contained in:
Nate Jensen 2013-07-03 09:37:05 -05:00 committed by Gerrit Code Review
commit 679bf314e0
12 changed files with 444 additions and 137 deletions

View file

@ -22,7 +22,9 @@ package com.raytheon.uf.viz.core;
import com.raytheon.uf.viz.core.rsc.hdf5.ImageTile;
/**
* Interface for notification when a mesh calculation has completed
* Interface for notification when a mesh calculation has completed.
*
* Deprecated: Meshes do not need to be explicitly calculated
*
* <pre>
*
@ -36,7 +38,7 @@ import com.raytheon.uf.viz.core.rsc.hdf5.ImageTile;
* @author mschenke
* @version 1.0
*/
@Deprecated
public interface IMeshCallback {
/**

View file

@ -218,7 +218,7 @@ public class RecordTileSetRenderable extends TileSetRenderable {
DrawableImage image = images.get(i);
addTileImage(tile, image);
}
target.setNeedsRefresh(true);
issueRefresh(target);
}
public DrawableImage createTileImage(IGraphicsTarget target, Tile tile,
@ -230,7 +230,7 @@ public class RecordTileSetRenderable extends TileSetRenderable {
.constructMesh(tile.tileGeometry,
tileSet.getTargetGeometry());
return new DrawableImage(image, new PixelCoverage(mesh),
RasterMode.ASYNCHRONOUS);
RasterMode.SYNCHRONOUS);
}
}
@ -353,6 +353,13 @@ public class RecordTileSetRenderable extends TileSetRenderable {
tile.getRectangle()).getColorMapData();
}
/**
* @param target
*/
protected void issueRefresh(IGraphicsTarget target) {
target.setNeedsRefresh(true);
}
@Override
public int hashCode() {
final int prime = 31;

View file

@ -1556,55 +1556,55 @@
<key
contextId="com.raytheon.uf.viz.d2d.ui"
commandId="com.raytheon.viz.ui.showHistoryList"
schemeId="com.raytheon.viz.ui.awips.scheme"
schemeId="com.raytheon.viz.ui.cave.scheme"
sequence="M1+H">
</key>
<key
contextId="com.raytheon.uf.viz.d2d.ui"
commandId="com.raytheon.uf.viz.d2d.ui.actions.changeLegendMode"
schemeId="com.raytheon.viz.ui.awips.scheme"
schemeId="com.raytheon.viz.ui.cave.scheme"
sequence="NUMPAD_ENTER">
</key>
<key
contextId="com.raytheon.uf.viz.d2d.ui"
commandId="com.raytheon.uf.viz.d2d.ui.actions.showPrintDialog"
schemeId="com.raytheon.viz.ui.awips.scheme"
schemeId="com.raytheon.viz.ui.cave.scheme"
sequence="M1+P">
</key>
<key
contextId="com.raytheon.uf.viz.d2d.ui"
commandId="com.raytheon.viz.ui.newAWIPSProcedure"
schemeId="com.raytheon.viz.ui.awips.scheme"
schemeId="com.raytheon.viz.ui.cave.scheme"
sequence="M1+N">
</key>
<key
contextId="com.raytheon.uf.viz.d2d.ui"
commandId="com.raytheon.viz.ui.openAWIPSProcedure"
schemeId="com.raytheon.viz.ui.awips.scheme"
schemeId="com.raytheon.viz.ui.cave.scheme"
sequence="M1+O">
</key>
<key
contextId="com.raytheon.uf.viz.d2d.ui"
commandId="com.raytheon.viz.ui.deleteAWIPSProcedure"
schemeId="com.raytheon.viz.ui.awips.scheme"
schemeId="com.raytheon.viz.ui.cave.scheme"
sequence="M1+D">
</key>
<key
contextId="com.raytheon.uf.viz.d2d.ui"
commandId="com.raytheon.viz.ui.copyOutAWIPSProcedure"
schemeId="com.raytheon.viz.ui.awips.scheme"
schemeId="com.raytheon.viz.ui.cave.scheme"
sequence="M1+B">
</key>
<key
contextId="com.raytheon.uf.viz.d2d.ui"
commandId="com.raytheon.viz.ui.clear"
schemeId="com.raytheon.viz.ui.awips.scheme"
schemeId="com.raytheon.viz.ui.cave.scheme"
sequence="M1+C">
</key>
<key
commandId="com.raytheon.viz.ui.tools.looping.frameTool"
contextId="com.raytheon.viz.ui.loopContext"
schemeId="com.raytheon.viz.ui.awips.scheme"
schemeId="com.raytheon.viz.ui.cave.scheme"
sequence="ARROW_LEFT">
<parameter
id="mode"
@ -1618,7 +1618,7 @@
<key
commandId="com.raytheon.viz.ui.tools.looping.frameTool"
contextId="com.raytheon.viz.ui.loopContext"
schemeId="com.raytheon.viz.ui.awips.scheme"
schemeId="com.raytheon.viz.ui.cave.scheme"
sequence="ARROW_RIGHT">
<parameter
id="mode"
@ -1632,7 +1632,7 @@
<key
commandId="com.raytheon.viz.ui.tools.looping.frameTool"
contextId="com.raytheon.viz.ui.loopContext"
schemeId="com.raytheon.viz.ui.awips.scheme"
schemeId="com.raytheon.viz.ui.cave.scheme"
sequence="M1+ARROW_LEFT">
<parameter
id="mode"
@ -1646,7 +1646,7 @@
<key
commandId="com.raytheon.viz.ui.tools.looping.frameTool"
contextId="com.raytheon.viz.ui.loopContext"
schemeId="com.raytheon.viz.ui.awips.scheme"
schemeId="com.raytheon.viz.ui.cave.scheme"
sequence="M1+ARROW_RIGHT">
<parameter
id="mode"
@ -1660,7 +1660,7 @@
<key
commandId="com.raytheon.viz.ui.tools.looping.frameTool"
contextId="com.raytheon.viz.ui.loopContext"
schemeId="com.raytheon.viz.ui.awips.scheme"
schemeId="com.raytheon.viz.ui.cave.scheme"
sequence="ARROW_DOWN">
<parameter
id="mode"
@ -1674,7 +1674,7 @@
<key
commandId="com.raytheon.viz.ui.tools.looping.frameTool"
contextId="com.raytheon.viz.ui.loopContext"
schemeId="com.raytheon.viz.ui.awips.scheme"
schemeId="com.raytheon.viz.ui.cave.scheme"
sequence="ARROW_UP">
<parameter
id="mode"
@ -1688,7 +1688,7 @@
<key
commandId="com.raytheon.viz.ui.tools.looping.frameTool"
contextId="com.raytheon.viz.ui.loopContext"
schemeId="com.raytheon.viz.ui.awips.scheme"
schemeId="com.raytheon.viz.ui.cave.scheme"
sequence="M1+ARROW_DOWN">
<parameter
id="mode"
@ -1702,7 +1702,7 @@
<key
commandId="com.raytheon.viz.ui.tools.looping.frameTool"
contextId="com.raytheon.viz.ui.loopContext"
schemeId="com.raytheon.viz.ui.awips.scheme"
schemeId="com.raytheon.viz.ui.cave.scheme"
sequence="M1+ARROW_UP">
<parameter
id="mode"
@ -1716,7 +1716,7 @@
<key
commandId="com.raytheon.viz.ui.tools.looping.frameTool"
contextId="com.raytheon.viz.ui.loopContext"
schemeId="com.raytheon.viz.ui.awips.scheme"
schemeId="com.raytheon.viz.ui.cave.scheme"
sequence="SHIFT+ARROW_LEFT">
<parameter
id="mode"
@ -1730,7 +1730,7 @@
<key
commandId="com.raytheon.viz.ui.tools.looping.frameTool"
contextId="com.raytheon.viz.ui.loopContext"
schemeId="com.raytheon.viz.ui.awips.scheme"
schemeId="com.raytheon.viz.ui.cave.scheme"
sequence="SHIFT+ARROW_RIGHT">
<parameter
id="mode"
@ -1744,43 +1744,43 @@
<key
commandId="com.raytheon.viz.ui.tools.looping.fasterLoop"
contextId="com.raytheon.viz.ui.loopContext"
schemeId="com.raytheon.viz.ui.awips.scheme"
schemeId="com.raytheon.viz.ui.cave.scheme"
sequence="PAGE_UP"/>
<key
commandId="com.raytheon.viz.ui.tools.looping.slowerLoop"
contextId="com.raytheon.viz.ui.loopContext"
schemeId="com.raytheon.viz.ui.awips.scheme"
schemeId="com.raytheon.viz.ui.cave.scheme"
sequence="PAGE_DOWN"/>
<key
contextId="com.raytheon.uf.viz.d2d.ui"
commandId="com.raytheon.uf.viz.d2d.ui.actions.timeOptionsAction"
schemeId="com.raytheon.viz.ui.awips.scheme"
schemeId="com.raytheon.viz.ui.cave.scheme"
sequence="M1+T">
</key>
<key
commandId="com.raytheon.uf.viz.d2d.ui.map.actions.fourPanelLayout"
contextId="com.raytheon.uf.viz.d2d.ui"
schemeId="com.raytheon.viz.ui.awips.scheme"
schemeId="com.raytheon.viz.ui.cave.scheme"
sequence="END">
</key>
<key
commandId="com.raytheon.uf.viz.d2d.ui.map.actions.rotatePanels"
contextId="com.raytheon.uf.viz.d2d.ui"
schemeId="com.raytheon.viz.ui.awips.scheme"
schemeId="com.raytheon.viz.ui.cave.scheme"
sequence="DELETE">
<parameter id="direction" value="1"></parameter>
</key>
<key
commandId="com.raytheon.uf.viz.d2d.ui.map.actions.rotatePanels"
contextId="com.raytheon.uf.viz.d2d.ui"
schemeId="com.raytheon.viz.ui.awips.scheme"
schemeId="com.raytheon.viz.ui.cave.scheme"
sequence="BACKSPACE">
<parameter id="direction" value="-1"></parameter>
</key>
<key
commandId="com.raytheon.uf.viz.d2d.ui.map.actions.rotatePanels"
contextId="com.raytheon.uf.viz.d2d.ui"
schemeId="com.raytheon.viz.ui.awips.scheme"
schemeId="com.raytheon.viz.ui.cave.scheme"
sequence="1">
<parameter id="direction" value="1"></parameter>
<parameter id="startIndex" value="3"></parameter>
@ -1789,7 +1789,7 @@
<key
commandId="com.raytheon.uf.viz.d2d.ui.map.actions.rotatePanels"
contextId="com.raytheon.uf.viz.d2d.ui"
schemeId="com.raytheon.viz.ui.awips.scheme"
schemeId="com.raytheon.viz.ui.cave.scheme"
sequence="5">
<parameter id="direction" value="1"></parameter>
<parameter id="startIndex" value="3"></parameter>
@ -1798,7 +1798,7 @@
<key
commandId="com.raytheon.uf.viz.d2d.ui.map.actions.rotatePanels"
contextId="com.raytheon.uf.viz.d2d.ui"
schemeId="com.raytheon.viz.ui.awips.scheme"
schemeId="com.raytheon.viz.ui.cave.scheme"
sequence="2">
<parameter id="direction" value="1"></parameter>
<parameter id="startIndex" value="0"></parameter>
@ -1807,7 +1807,7 @@
<key
commandId="com.raytheon.uf.viz.d2d.ui.map.actions.rotatePanels"
contextId="com.raytheon.uf.viz.d2d.ui"
schemeId="com.raytheon.viz.ui.awips.scheme"
schemeId="com.raytheon.viz.ui.cave.scheme"
sequence="6">
<parameter id="direction" value="1"></parameter>
<parameter id="startIndex" value="0"></parameter>
@ -1816,7 +1816,7 @@
<key
commandId="com.raytheon.uf.viz.d2d.ui.map.actions.rotatePanels"
contextId="com.raytheon.uf.viz.d2d.ui"
schemeId="com.raytheon.viz.ui.awips.scheme"
schemeId="com.raytheon.viz.ui.cave.scheme"
sequence="3">
<parameter id="direction" value="1"></parameter>
<parameter id="startIndex" value="1"></parameter>
@ -1825,7 +1825,7 @@
<key
commandId="com.raytheon.uf.viz.d2d.ui.map.actions.rotatePanels"
contextId="com.raytheon.uf.viz.d2d.ui"
schemeId="com.raytheon.viz.ui.awips.scheme"
schemeId="com.raytheon.viz.ui.cave.scheme"
sequence="7">
<parameter id="direction" value="1"></parameter>
<parameter id="startIndex" value="1"></parameter>
@ -1834,7 +1834,7 @@
<key
commandId="com.raytheon.uf.viz.d2d.ui.map.actions.rotatePanels"
contextId="com.raytheon.uf.viz.d2d.ui"
schemeId="com.raytheon.viz.ui.awips.scheme"
schemeId="com.raytheon.viz.ui.cave.scheme"
sequence="4">
<parameter id="direction" value="1"></parameter>
<parameter id="startIndex" value="2"></parameter>
@ -1843,7 +1843,7 @@
<key
commandId="com.raytheon.uf.viz.d2d.ui.map.actions.rotatePanels"
contextId="com.raytheon.uf.viz.d2d.ui"
schemeId="com.raytheon.viz.ui.awips.scheme"
schemeId="com.raytheon.viz.ui.cave.scheme"
sequence="8">
<parameter id="direction" value="1"></parameter>
<parameter id="startIndex" value="2"></parameter>
@ -1852,37 +1852,37 @@
<key
contextId="com.raytheon.uf.viz.d2d.ui"
commandId="com.raytheon.uf.viz.d2d.ui.actions.dataScaleAction"
schemeId="com.raytheon.viz.ui.awips.scheme"
schemeId="com.raytheon.viz.ui.cave.scheme"
sequence="M1+S">
</key>
<key
contextId="com.raytheon.uf.viz.d2d.ui"
commandId="com.raytheon.uf.viz.d2d.ui.actions.imageCombination"
schemeId="com.raytheon.viz.ui.awips.scheme"
schemeId="com.raytheon.viz.ui.cave.scheme"
sequence="INSERT">
</key>
<key
contextId="com.raytheon.uf.viz.d2d.ui"
commandId="com.raytheon.uf.viz.d2d.ui.actions.locateCursorAction"
schemeId="com.raytheon.viz.ui.awips.scheme"
schemeId="com.raytheon.viz.ui.cave.scheme"
sequence="F12">
</key>
<key
contextId="com.raytheon.uf.viz.d2d.ui"
commandId="com.raytheon.viz.ui.tools.looping.loopProperties"
schemeId="com.raytheon.viz.ui.awips.scheme"
schemeId="com.raytheon.viz.ui.cave.scheme"
sequence="M1+L">
</key>
<key
contextId="com.raytheon.uf.viz.d2d.ui"
commandId="com.raytheon.viz.ui.imageProperties"
schemeId="com.raytheon.viz.ui.awips.scheme"
schemeId="com.raytheon.viz.ui.cave.scheme"
sequence="M1+I">
</key>
<key
commandId="com.raytheon.uf.viz.d2d.ui.actions.increaseBlendAmount"
contextId="com.raytheon.uf.viz.d2d.ui"
schemeId="com.raytheon.viz.ui.awips.scheme"
schemeId="com.raytheon.viz.ui.cave.scheme"
sequence="NUMPAD_ADD"/>
<key
commandId="com.raytheon.uf.viz.d2d.ui.actions.decreaseBlendAmount"

View file

@ -62,7 +62,7 @@ import com.raytheon.viz.core.style.image.ImagePreferences;
* Jul 25, 2007 chammack Initial Creation.
* Mar 26, 2009 2086 jsanchez Added a entityList to the match criteria.
* Feb 15, 2013 1638 mschenke Moved GRID_FILL_VALUE from edex.common Util into GridUtil
*
* Jun 24, 2013 2122 mschenke Added method for constructing {@link ColorMapParameters} from {@link StyleRule}
* </pre>
*
* @author chammack
@ -95,6 +95,12 @@ public class ColorMapParameterFactory {
StyleRule sr = StyleManager.getInstance().getStyleRule(
StyleManager.StyleType.IMAGERY, match);
return build(sr, data, level, parameterUnits);
}
public static ColorMapParameters build(StyleRule sr, Object data,
SingleLevel level, Unit<?> parameterUnits) {
ColorMapParameters params = new ColorMapParameters();
ImagePreferences preferences = null;

View file

@ -19,8 +19,6 @@
**/
package com.raytheon.viz.satellite.rsc;
import java.text.ParseException;
import java.text.ParsePosition;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
@ -31,19 +29,17 @@ import java.util.Map;
import javax.measure.converter.UnitConverter;
import javax.measure.unit.Unit;
import javax.measure.unit.UnitFormat;
import org.opengis.referencing.crs.CoordinateReferenceSystem;
import com.raytheon.uf.common.colormap.IColorMap;
import com.raytheon.uf.common.colormap.prefs.ColorMapParameters;
import com.raytheon.uf.common.colormap.prefs.ColorMapParameters.PersistedParameters;
import com.raytheon.uf.common.colormap.prefs.DataMappingPreferences;
import com.raytheon.uf.common.dataplugin.PluginDataObject;
import com.raytheon.uf.common.dataplugin.satellite.SatelliteRecord;
import com.raytheon.uf.common.dataplugin.satellite.units.SatelliteUnits;
import com.raytheon.uf.common.dataplugin.satellite.units.counts.DerivedWVPixel;
import com.raytheon.uf.common.dataplugin.satellite.units.generic.GenericPixel;
import com.raytheon.uf.common.dataplugin.satellite.units.goes.PolarPrecipWaterPixel;
import com.raytheon.uf.common.dataplugin.satellite.units.water.BlendedTPWPixel;
import com.raytheon.uf.common.geospatial.ISpatialObject;
import com.raytheon.uf.common.geospatial.ReferencedCoordinate;
@ -72,6 +68,7 @@ import com.raytheon.viz.core.drawables.ColorMapParameterFactory;
import com.raytheon.viz.core.style.image.ImagePreferences;
import com.raytheon.viz.core.style.image.SamplePreferences;
import com.raytheon.viz.satellite.SatelliteConstants;
import com.raytheon.viz.satellite.tileset.SatDataRetriever;
import com.raytheon.viz.satellite.tileset.SatTileSetRenderable;
import com.vividsolutions.jts.geom.Coordinate;
@ -265,10 +262,24 @@ public class SatResource extends
private void initializeFirstFrame(SatelliteRecord record)
throws VizException {
SingleLevel level = new SingleLevel(Level.LevelType.SURFACE);
SatelliteUnits.register();
Unit<?> unit = null;
ColorMapParameters colorMapParameters = null;
IColorMap colorMap = null;
String cmName = null;
PersistedParameters persisted = null;
if (hasCapability(ColorMapCapability.class)) {
colorMapParameters = getCapability(ColorMapCapability.class)
.getColorMapParameters();
if (colorMapParameters != null) {
persisted = colorMapParameters.getPersisted();
colorMap = colorMapParameters.getColorMap();
cmName = colorMapParameters.getColorMapName();
}
}
SingleLevel level = new SingleLevel(Level.LevelType.SURFACE);
Unit<?> unit = SatDataRetriever.getRecordUnit(record);
String physicalElement = null;
DerivedParameterRequest request = (DerivedParameterRequest) record
.getMessageData();
@ -277,50 +288,12 @@ public class SatResource extends
} else {
physicalElement = request.getParameterAbbreviation();
}
if (record.getUnits() != null && request == null) {
try {
unit = UnitFormat.getUCUMInstance().parseSingleUnit(
record.getUnits(), new ParsePosition(0));
} catch (ParseException e) {
throw new VizException("Unable parse units ", e);
}
} else if (request != null) {
if (physicalElement.equals("satDivWVIR")) {
unit = new DerivedWVPixel();
} else {
unit = new GenericPixel();
}
}
String creatingEntity = null;
if (physicalElement.equals(SatelliteConstants.PRECIP)) {
creatingEntity = record.getCreatingEntity();
if (creatingEntity.equals(SatelliteConstants.DMSP)
|| creatingEntity.equals(SatelliteConstants.POES)) {
unit = new PolarPrecipWaterPixel();
} else if (creatingEntity.equals(SatelliteConstants.MISC)) {
unit = new BlendedTPWPixel();
}
}
ColorMapParameters colorMapParameters = null;
IColorMap colorMap = null;
String cmName = null;
if (hasCapability(ColorMapCapability.class)) {
colorMapParameters = getCapability(ColorMapCapability.class)
.getColorMapParameters();
if (colorMapParameters != null) {
colorMap = colorMapParameters.getColorMap();
cmName = colorMapParameters.getColorMapName();
}
}
// Grab the sampleRange from the preferences
ParamLevelMatchCriteria match = new ParamLevelMatchCriteria();
match.setParameterName(Arrays.asList(physicalElement));
match.setLevels(Arrays.asList((Level) level));
match.setCreatingEntityNames(Arrays.asList(creatingEntity));
match.setCreatingEntityNames(Arrays.asList(record.getCreatingEntity()));
StyleRule sr = StyleManager.getInstance().getStyleRule(
StyleManager.StyleType.IMAGERY, match);
if (sr != null && sr.getPreferences() instanceof ImagePreferences) {
@ -333,8 +306,32 @@ public class SatResource extends
}
}
colorMapParameters = ColorMapParameterFactory.build((Object) null,
physicalElement, unit, level, creatingEntity);
colorMapParameters = ColorMapParameterFactory.build(sr, null, level,
unit);
// If null, set from style rules
if (cmName == null) {
cmName = colorMapParameters.getColorMapName();
}
if (colorMap == null) {
colorMap = colorMapParameters.getColorMap();
}
// Load colormap into parameters
if (colorMap == null) {
if (cmName == null) {
cmName = "Sat/VIS/ZA (Vis Default)";
}
colorMap = ColorMapLoader.loadColorMap(cmName);
}
if (colorMap != null) {
colorMapParameters.setColorMap(colorMap);
}
if (persisted != null) {
colorMapParameters.applyPersistedParameters(persisted);
}
// TODO: Figure out data/color map min/max values better
if (unit == null) {
colorMapParameters.setColorMapMin(0.0f);
@ -355,17 +352,6 @@ public class SatResource extends
colorMapParameters.setDataMax(255.0f);
}
if (colorMap == null) {
if (cmName == null) {
cmName = "Sat/VIS/ZA (Vis Default)";
}
colorMap = ColorMapLoader.loadColorMap(cmName);
}
if (colorMap != null) {
colorMapParameters.setColorMap(colorMap);
}
getCapability(ColorMapCapability.class).setColorMapParameters(
colorMapParameters);

View file

@ -23,11 +23,19 @@ import java.awt.Rectangle;
import java.nio.Buffer;
import java.nio.ByteBuffer;
import java.nio.ShortBuffer;
import java.text.ParseException;
import java.text.ParsePosition;
import javax.measure.unit.Unit;
import javax.measure.unit.UnitFormat;
import com.raytheon.uf.common.colormap.image.ColorMapData;
import com.raytheon.uf.common.colormap.image.ColorMapData.ColorMapDataType;
import com.raytheon.uf.common.dataplugin.PluginDataObject;
import com.raytheon.uf.common.dataplugin.satellite.SatelliteRecord;
import com.raytheon.uf.common.dataplugin.satellite.units.counts.DerivedWVPixel;
import com.raytheon.uf.common.dataplugin.satellite.units.generic.GenericPixel;
import com.raytheon.uf.common.dataplugin.satellite.units.goes.PolarPrecipWaterPixel;
import com.raytheon.uf.common.dataplugin.satellite.units.water.BlendedTPWPixel;
import com.raytheon.uf.common.datastorage.DataStoreFactory;
import com.raytheon.uf.common.datastorage.Request;
import com.raytheon.uf.common.datastorage.records.ByteDataRecord;
@ -39,6 +47,8 @@ import com.raytheon.uf.common.status.UFStatus.Priority;
import com.raytheon.uf.viz.core.data.IColorMapDataRetrievalCallback;
import com.raytheon.uf.viz.core.datastructure.DataCubeContainer;
import com.raytheon.uf.viz.core.datastructure.VizDataCubeException;
import com.raytheon.uf.viz.derivparam.library.DerivedParameterRequest;
import com.raytheon.viz.satellite.SatelliteConstants;
/**
* {@link IColorMapDataRetrievalCallback} for satellite imagery data. Supports
@ -63,19 +73,16 @@ public class SatDataRetriever implements IColorMapDataRetrievalCallback {
protected Rectangle datasetBounds;
protected PluginDataObject pdo;
protected SatelliteRecord record;
protected String dataset;
protected boolean signed = false;
public SatDataRetriever(PluginDataObject pdo, int level,
Rectangle dataSetBounds, boolean signed) {
this.pdo = pdo;
public SatDataRetriever(SatelliteRecord record, int level,
Rectangle dataSetBounds) {
this.record = record;
this.datasetBounds = dataSetBounds;
dataset = DataStoreFactory.createDataSetName(null,
SatelliteRecord.SAT_DATASET_NAME, level);
this.signed = signed;
}
/*
@ -87,14 +94,15 @@ public class SatDataRetriever implements IColorMapDataRetrievalCallback {
public ColorMapData getColorMapData() {
// TODO: Read scale/offset out of attributes?
Buffer data = null;
boolean signed = false;
Request req = Request.buildSlab(new int[] { this.datasetBounds.x,
this.datasetBounds.y }, new int[] {
this.datasetBounds.x + this.datasetBounds.width,
this.datasetBounds.y + this.datasetBounds.height });
IDataRecord[] dataRecord = null;
try {
dataRecord = DataCubeContainer
.getDataRecord(pdo, req, this.dataset);
dataRecord = DataCubeContainer.getDataRecord(record, req,
this.dataset);
if (dataRecord != null && dataRecord.length == 1) {
IDataRecord record = dataRecord[0];
if (record instanceof ByteDataRecord) {
@ -102,6 +110,8 @@ public class SatDataRetriever implements IColorMapDataRetrievalCallback {
} else if (record instanceof ShortDataRecord) {
data = ShortBuffer.wrap((short[]) record.getDataObject());
}
Unit<?> recordUnit = getRecordUnit(this.record);
signed = recordUnit instanceof GenericPixel;
}
} catch (VizDataCubeException e) {
statusHandler.handle(Priority.SIGNIFICANT,
@ -127,6 +137,50 @@ public class SatDataRetriever implements IColorMapDataRetrievalCallback {
datasetBounds.height }, dataType);
}
/**
* @param record2
* @return
*/
public static Unit<?> getRecordUnit(SatelliteRecord record) {
Unit<?> recordUnit = null;
String physicalElement = record.getPhysicalElement();
DerivedParameterRequest request = (DerivedParameterRequest) record
.getMessageData();
if (request != null) {
physicalElement = request.getParameterAbbreviation();
}
if (record.getUnits() != null && record.getUnits().isEmpty() == false && request == null) {
try {
recordUnit = UnitFormat.getUCUMInstance().parseProductUnit(
record.getUnits(), new ParsePosition(0));
} catch (ParseException e) {
statusHandler
.handle(Priority.PROBLEM,
"Unable to parse satellite units: "
+ record.getUnits(), e);
}
} else if (request != null) {
if (physicalElement.equals("satDivWVIR")) {
recordUnit = new DerivedWVPixel();
} else {
recordUnit = new GenericPixel();
}
}
if (physicalElement.equals(SatelliteConstants.PRECIP)) {
String creatingEntity = record.getCreatingEntity();
if (creatingEntity.equals(SatelliteConstants.DMSP)
|| creatingEntity.equals(SatelliteConstants.POES)) {
recordUnit = new PolarPrecipWaterPixel();
} else if (creatingEntity.equals(SatelliteConstants.MISC)) {
recordUnit = new BlendedTPWPixel();
}
}
return recordUnit;
}
/*
* (non-Javadoc)
*
@ -139,8 +193,7 @@ public class SatDataRetriever implements IColorMapDataRetrievalCallback {
result = prime * result + ((dataset == null) ? 0 : dataset.hashCode());
result = prime * result
+ ((datasetBounds == null) ? 0 : datasetBounds.hashCode());
result = prime * result + ((pdo == null) ? 0 : pdo.hashCode());
result = prime * result + (signed ? 1231 : 1237);
result = prime * result + ((record == null) ? 0 : record.hashCode());
return result;
}
@ -168,12 +221,10 @@ public class SatDataRetriever implements IColorMapDataRetrievalCallback {
return false;
} else if (!datasetBounds.equals(other.datasetBounds))
return false;
if (pdo == null) {
if (other.pdo != null)
if (record == null) {
if (other.record != null)
return false;
} else if (!pdo.equals(other.pdo))
return false;
if (signed != other.signed)
} else if (!record.equals(other.record))
return false;
return true;
}

View file

@ -21,9 +21,8 @@ package com.raytheon.viz.satellite.tileset;
import com.raytheon.uf.common.colormap.image.ColorMapData;
import com.raytheon.uf.common.dataplugin.satellite.SatelliteRecord;
import com.raytheon.uf.common.dataplugin.satellite.units.generic.GenericPixel;
import com.raytheon.uf.viz.core.IGraphicsTarget;
import com.raytheon.uf.viz.core.rsc.AbstractVizResource;
import com.raytheon.uf.viz.core.rsc.capabilities.ColorMapCapability;
import com.raytheon.uf.viz.core.tile.RecordTileSetRenderable;
import com.raytheon.uf.viz.core.tile.Tile;
@ -47,9 +46,7 @@ import com.raytheon.uf.viz.core.tile.Tile;
public class SatTileSetRenderable extends RecordTileSetRenderable {
private final boolean signed;
private final AbstractVizResource<?,?> resource;
private final AbstractVizResource<?, ?> resource;
/**
* Create satellite tile set renderable
@ -58,22 +55,26 @@ public class SatTileSetRenderable extends RecordTileSetRenderable {
* @param record
* @param signed
*/
public SatTileSetRenderable(AbstractVizResource<?,?> resource, SatelliteRecord record) {
public SatTileSetRenderable(AbstractVizResource<?, ?> resource,
SatelliteRecord record) {
// Total levels = Number of interpolation levels + base level
super(resource, record, record.getSpatialObject(), record
.getInterpolationLevels() + 1);
this.resource = resource;
// TODO: Better way of determining this (taken from SatFileBasedTileSet)
this.signed = resource.getCapability(ColorMapCapability.class)
.getColorMapParameters().getDataUnit() instanceof GenericPixel;
}
@Override
protected ColorMapData retrieveRecordData(Tile tile) {
ColorMapData data = new SatDataRetriever(record, tile.tileLevel,
tile.getRectangle(), signed).getColorMapData();
return new SatDataRetriever((SatelliteRecord) record, tile.tileLevel,
tile.getRectangle()).getColorMapData();
}
@Override
protected void issueRefresh(IGraphicsTarget target) {
super.issueRefresh(target);
resource.issueRefresh();
return data;
}
public SatelliteRecord getSatelliteRecord() {

View file

@ -85,6 +85,7 @@ public class SatelliteUnits {
public static final Unit<Dimensionless> GENERIC_PIXEL = new GenericPixel();
public static void register() {
UnitFormat.getUCUMInstance().alias(SI.KELVIN, "kelvin");
UnitFormat.getUCUMInstance().alias(SI.CELSIUS, "C");
UnitFormat.getUCUMInstance().label(SatelliteUnits.IR_PIXEL, "IRPixel");
UnitFormat.getUCUMInstance().label(SatelliteUnits.PRECIP_PIXEL,

View file

@ -5,8 +5,7 @@ Bundle-SymbolicName: com.raytheon.uf.common.geospatial
Bundle-Version: 1.12.1174.qualifier
Bundle-Vendor: RAYTHEON
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Eclipse-BuddyPolicy: ext, registered, global
Eclipse-RegisterBuddy: com.raytheon.viz.core
Eclipse-RegisterBuddy: com.raytheon.uf.common.serialization, org.geotools
Require-Bundle: org.geotools;bundle-version="2.5.2";visibility:=reexport,
org.apache.commons.collections;bundle-version="3.2.0",
org.apache.commons.lang;bundle-version="2.3.0",
@ -20,6 +19,7 @@ Require-Bundle: org.geotools;bundle-version="2.5.2";visibility:=reexport,
Export-Package: com.raytheon.uf.common.geospatial,
com.raytheon.uf.common.geospatial.interpolation,
com.raytheon.uf.common.geospatial.interpolation.data,
com.raytheon.uf.common.geospatial.projection,
com.raytheon.uf.common.geospatial.request,
com.raytheon.uf.common.geospatial.spi,
com.raytheon.uf.common.geospatial.util

View file

@ -0,0 +1 @@
com.raytheon.uf.common.geospatial.projection.Geostationary$Provider

View file

@ -0,0 +1,251 @@
/**
* This software was developed and / or modified by Raytheon Company,
* pursuant to Contract DG133W-05-CQ-1067 with the US Government.
*
* U.S. EXPORT CONTROLLED TECHNICAL DATA
* This software product contains export-restricted data whose
* export/transfer/disclosure is restricted by U.S. law. Dissemination
* to non-U.S. persons whether in the United States or abroad requires
* an export license or other authorization.
*
* Contractor Name: Raytheon Company
* Contractor Address: 6825 Pine Street, Suite 340
* Mail Stop B8
* Omaha, NE 68106
* 402.291.0100
*
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for
* further licenMath.sing information.
**/
package com.raytheon.uf.common.geospatial.projection;
import java.awt.geom.Point2D;
import javax.measure.unit.SI;
import javax.measure.unit.Unit;
import org.geotools.parameter.DefaultParameterDescriptor;
import org.geotools.parameter.DefaultParameterDescriptorGroup;
import org.geotools.referencing.operation.MathTransformProvider;
import org.geotools.referencing.operation.projection.MapProjection;
import org.geotools.referencing.operation.projection.ProjectionException;
import org.opengis.parameter.InvalidParameterNameException;
import org.opengis.parameter.InvalidParameterValueException;
import org.opengis.parameter.ParameterDescriptor;
import org.opengis.parameter.ParameterDescriptorGroup;
import org.opengis.parameter.ParameterNotFoundException;
import org.opengis.parameter.ParameterValueGroup;
import org.opengis.referencing.FactoryException;
import org.opengis.referencing.operation.MathTransform;
/**
* Geostationary map projection. Earth as viewed from space.
*
* TODO Add support latitude of origin != 0.0
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Jun 27, 2013 mschenke Initial creation
*
* </pre>
*
* @author mschenke
* @version 1.0
*/
public class Geostationary extends MapProjection {
private static final long serialVersionUID = 4747155239658791357L;
public static final String PROJECTION_NAME = "Geostationary";
public static final String PERSPECTIVE_HEIGHT = "perspective_height";
public static final String SWEEP_AXIS = "sweep_axis";
static final double DEFAULT_PERSPECTIVE_HEIGHT = 35800000.0;
private double perspectiveHeight = DEFAULT_PERSPECTIVE_HEIGHT;
private boolean swapAxis = false;
private double radius_g, radius_g_1, radius_p, radius_p2, radius_p_inv2, C;
/**
* @param values
* @throws ParameterNotFoundException
*/
protected Geostationary(ParameterValueGroup values)
throws ParameterNotFoundException {
super(values);
this.perspectiveHeight = Provider.getValue(Provider.PERSPECTIVE_HEIGHT,
values);
double sweepValue = Provider.getValue(Provider.SWEEP_AXIS, values);
this.swapAxis = sweepValue == 1.0;
double h = perspectiveHeight;
double a = semiMajor;
double b = semiMinor;
double es = 1.0 - (b * b) / (a * a);
double one_es = 1.0 - es;
double rone_es = 1.0 / one_es;
radius_g_1 = h / a;
radius_g = 1 + radius_g_1;
radius_p2 = one_es;
radius_p_inv2 = rone_es;
radius_p = Math.sqrt(radius_p2);
C = radius_g * radius_g - 1.0;
}
/*
* (non-Javadoc)
*
* @see org.geotools.referencing.operation.projection.MapProjection#
* getParameterDescriptors()
*/
@Override
public ParameterDescriptorGroup getParameterDescriptors() {
return Provider.PARAMETERS;
}
/*
* (non-Javadoc)
*
* @see org.geotools.referencing.operation.projection.MapProjection#
* inverseTransformNormalized(double, double, java.awt.geom.Point2D)
*/
@Override
protected Point2D inverseTransformNormalized(double x, double y,
Point2D ptDst) throws ProjectionException {
double lam, phi;
double Vx, Vy, Vz, a, b, det, k;
/* Setting three components of vector from satellite to position. */
Vx = -1.0;
if (swapAxis) {
Vz = Math.tan(y / radius_g_1);
Vy = Math.tan(x / radius_g_1) * Math.hypot(1.0, Vz);
} else {
Vy = Math.tan(x / radius_g_1);
Vz = Math.tan(y / radius_g_1) * Math.hypot(1.0, Vy);
}
/* Calculation of terms in cubic equation and determinant. */
a = Vz / radius_p;
a = Vy * Vy + a * a + Vx * Vx;
b = 2 * radius_g * Vx;
if ((det = (b * b) - 4 * a * C) < 0.) {
lam = phi = Double.NaN;
} else {
/*
* Calculation of three components of vector from satellite to
* position.
*/
k = (-b - Math.sqrt(det)) / (2. * a);
Vx = radius_g + k * Vx;
Vy *= k;
Vz *= k;
/* Calculation of longitude and latitude. */
lam = Math.atan2(Vy, Vx);
phi = Math.atan(Vz * Math.cos(lam) / Vx);
phi = Math.atan(radius_p_inv2 * Math.tan(phi));
}
if (ptDst == null) {
ptDst = new Point2D.Double();
}
ptDst.setLocation(lam, phi);
return ptDst;
}
/*
* (non-Javadoc)
*
* @see org.geotools.referencing.operation.projection.MapProjection#
* transformNormalized(double, double, java.awt.geom.Point2D)
*/
@Override
protected Point2D transformNormalized(double lam, double phi, Point2D ptDst)
throws ProjectionException {
double x, y;
double r, Vx, Vy, Vz, tmp;
/* Calculation of geocentric latitude. */
phi = Math.atan(radius_p2 * Math.tan(phi));
/*
* Calculation of the three components of the vector from satellite to*
* position on earth surface (lon,lat).
*/
r = (radius_p) / Math.hypot(radius_p * Math.cos(phi), Math.sin(phi));
Vx = r * Math.cos(lam) * Math.cos(phi);
Vy = r * Math.sin(lam) * Math.cos(phi);
Vz = r * Math.sin(phi);
/* Check visibility. */
if (((radius_g - Vx) * Vx - Vy * Vy - Vz * Vz * radius_p_inv2) < 0.) {
x = y = Double.NaN;
} else {
/* Calculation based on view angles from satellite. */
tmp = radius_g - Vx;
if (swapAxis) {
x = radius_g_1 * Math.atan(Vy / Math.hypot(Vz, tmp));
y = radius_g_1 * Math.atan(Vz / tmp);
} else {
x = radius_g_1 * Math.atan(Vy / tmp);
y = radius_g_1 * Math.atan(Vz / Math.hypot(Vy, tmp));
}
}
if (ptDst == null) {
ptDst = new Point2D.Double();
}
ptDst.setLocation(x, y);
return ptDst;
}
public static class Provider extends AbstractProvider {
private static final long serialVersionUID = 3868187206568280453L;
static final ParameterDescriptor<Double> PERSPECTIVE_HEIGHT = DefaultParameterDescriptor
.create(Geostationary.PERSPECTIVE_HEIGHT,
DEFAULT_PERSPECTIVE_HEIGHT, 0, Double.MAX_VALUE,
SI.METER);
static final ParameterDescriptor<Double> SWEEP_AXIS = DefaultParameterDescriptor
.create(Geostationary.SWEEP_AXIS, 0.0, 0.0, 1.0, Unit.ONE);
static final ParameterDescriptorGroup PARAMETERS = new DefaultParameterDescriptorGroup(
PROJECTION_NAME, new ParameterDescriptor[] {
SEMI_MAJOR, SEMI_MINOR, CENTRAL_MERIDIAN,
LATITUDE_OF_ORIGIN, FALSE_EASTING, FALSE_NORTHING,
PERSPECTIVE_HEIGHT, SWEEP_AXIS });
public Provider() {
super(PARAMETERS);
}
/*
* (non-Javadoc)
*
* @see org.geotools.referencing.operation.MathTransformProvider#
* createMathTransform (org.opengis.parameter.ParameterValueGroup)
*/
@Override
protected MathTransform createMathTransform(ParameterValueGroup values)
throws InvalidParameterNameException,
ParameterNotFoundException, InvalidParameterValueException,
FactoryException {
return new Geostationary(values);
}
static <T> T getValue(ParameterDescriptor<T> descriptor,
ParameterValueGroup group) {
return MathTransformProvider.value(descriptor, group);
}
}
}

View file

@ -187,8 +187,8 @@ public class EnvelopeIntersection {
if (coords[0].equals(coords[coords.length - 1])) {
border = gf.createPolygon(gf.createLinearRing(coords), null);
border = correctedPolygon = JTS.transform(corrector.correct(JTS
.transform(border,
targetCRSToLatLon)), latLonToTargetCRS);
.transform(border, targetCRSToLatLon)),
latLonToTargetCRS);
}
}
if ((border == null || border.isEmpty() || border.isValid() == false)
@ -504,7 +504,8 @@ public class EnvelopeIntersection {
for (LineString ls : lineStrings) {
envelopes.add(ls.getEnvelope());
}
gf.createGeometryCollection(envelopes.toArray(new Geometry[0]));
border = gf.createGeometryCollection(envelopes
.toArray(new Geometry[0]));
}
}