Merge "Omaha #3238 Implement Interrogatable in SatResource." into omaha_14.4.1

Former-commit-id: 83cd4ad4af6ac2f90a280fa1367ef88949870dc0
This commit is contained in:
Nate Jensen 2014-06-23 17:45:11 -05:00 committed by Gerrit Code Review
commit 2d98fb83fc
4 changed files with 190 additions and 36 deletions

View file

@ -1,7 +0,0 @@
#Thu Mar 26 11:03:00 CDT 2009
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
org.eclipse.jdt.core.compiler.compliance=1.6
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.source=1.6

View file

@ -2,35 +2,32 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: Satellite Visualization Plug-in
Bundle-SymbolicName: com.raytheon.viz.satellite;singleton:=true
Bundle-Version: 1.13.0.qualifier
Bundle-Version: 1.14.0.qualifier
Bundle-RequiredExecutionEnvironment: JavaSE-1.7
Bundle-ActivationPolicy: lazy
Bundle-Vendor: Raytheon
Eclipse-RegisterBuddy: com.raytheon.viz.core, com.raytheon.uf.viz.core, com.raytheon.viz.ui
Eclipse-BuddyPolicy: ext, global
Require-Bundle: org.eclipse.ui,
org.eclipse.core.runtime,
com.raytheon.uf.viz.core,
Require-Bundle: org.eclipse.core.runtime;bundle-version="3.8",
com.raytheon.uf.viz.core;bundle-version="1.14",
com.raytheon.uf.common.dataplugin,
com.raytheon.uf.common.dataplugin.satellite,
com.raytheon.uf.common.datastorage,
com.raytheon.uf.common.serialization.comm,
com.raytheon.uf.common.geospatial,
com.raytheon.uf.common.dataplugin.satellite;bundle-version="1.14",
com.raytheon.uf.common.datastorage;bundle-version="1.14",
com.raytheon.uf.common.geospatial;bundle-version="1.14",
com.raytheon.uf.common.colormap,
com.raytheon.uf.common.pointdata,
com.raytheon.uf.common.message,
com.raytheon.uf.viz.productbrowser,
com.raytheon.uf.common.pointdata;bundle-version="1.13",
com.raytheon.uf.viz.productbrowser;bundle-version="1.14",
com.raytheon.uf.common.derivparam;bundle-version="1.14.0",
com.raytheon.uf.viz.ui.menus,
com.raytheon.uf.common.style,
com.raytheon.viz.ui,
com.raytheon.viz.core,
javax.measure,
com.raytheon.viz.ui;bundle-version="1.14",
com.raytheon.uf.common.inventory;bundle-version="1.14.0",
com.raytheon.uf.viz.datacube;bundle-version="1.14.0",
com.raytheon.uf.common.dataplugin.level,
com.raytheon.uf.common.dataplugin.level;bundle-version="1.14",
com.raytheon.uf.common.comm,
com.raytheon.uf.common.numeric,
com.raytheon.viz.alerts
Bundle-ActivationPolicy: lazy
com.raytheon.uf.common.numeric;bundle-version="1.14",
com.raytheon.viz.alerts,
com.raytheon.uf.viz.core.rsc;bundle-version="1.14",
javax.measure
Import-Package: com.raytheon.viz.core.rsc,
com.raytheon.viz.core.rsc.hdf5
Export-Package: com.raytheon.viz.satellite,
com.raytheon.viz.satellite.rsc
Bundle-RequiredExecutionEnvironment: JavaSE-1.6

View file

@ -24,15 +24,19 @@ import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import javax.measure.Measure;
import javax.measure.converter.UnitConverter;
import javax.measure.quantity.Temperature;
import javax.measure.unit.Unit;
import org.opengis.referencing.FactoryException;
import org.opengis.referencing.crs.CoordinateReferenceSystem;
import org.opengis.referencing.operation.TransformException;
import com.raytheon.uf.common.colormap.IColorMap;
import com.raytheon.uf.common.colormap.prefs.ColorMapParameters;
@ -43,6 +47,7 @@ import com.raytheon.uf.common.dataplugin.satellite.SatMapCoverage;
import com.raytheon.uf.common.dataplugin.satellite.SatelliteRecord;
import com.raytheon.uf.common.geospatial.IGridGeometryProvider;
import com.raytheon.uf.common.geospatial.ReferencedCoordinate;
import com.raytheon.uf.common.geospatial.data.GeographicDataSource;
import com.raytheon.uf.common.style.ParamLevelMatchCriteria;
import com.raytheon.uf.common.style.StyleException;
import com.raytheon.uf.common.style.StyleManager;
@ -67,6 +72,12 @@ import com.raytheon.uf.viz.core.rsc.LoadProperties;
import com.raytheon.uf.viz.core.rsc.capabilities.AbstractCapability;
import com.raytheon.uf.viz.core.rsc.capabilities.ColorMapCapability;
import com.raytheon.uf.viz.core.rsc.capabilities.ImagingCapability;
import com.raytheon.uf.viz.core.rsc.interrogation.ClassInterrogationKey;
import com.raytheon.uf.viz.core.rsc.interrogation.Interrogatable;
import com.raytheon.uf.viz.core.rsc.interrogation.InterrogateMap;
import com.raytheon.uf.viz.core.rsc.interrogation.InterrogationKey;
import com.raytheon.uf.viz.core.rsc.interrogation.Interrogator;
import com.raytheon.uf.viz.core.rsc.interrogation.StringInterrogationKey;
import com.raytheon.viz.satellite.SatelliteConstants;
import com.raytheon.viz.satellite.inventory.DerivedSatelliteRecord;
import com.raytheon.viz.satellite.tileset.SatDataRetriever;
@ -76,6 +87,14 @@ import com.vividsolutions.jts.geom.Coordinate;
/**
* Provides satellite raster rendering support
*
* This resource implements the {@link Interrogatable} interface and provides
* the keys for accessing the value at a point({@link Interrogator#VALUE}), the
* full {@link SatelliteRecord}({@link #SATELLITE_RECORD_INTERROGATE_KEY}), a
* {@link GeographicDataSource} for the currently displayed tileset/level(
* {@link #DATA_SOURCE_INTERROGATE_KEY}), and a special key that returns the
* same value but is only applicable to satellite data types(
* {@link #SATELLITE_DATA_INTERROGATE_ID})
*
* <pre>
*
* SOFTWARE HISTORY
@ -101,6 +120,7 @@ import com.vividsolutions.jts.geom.Coordinate;
* Apr 09, 2014 2947 bsteffen Improve flexibility of sat derived
* parameters, implement ImageProvider
* May 06, 2014 njensen Improve error message
* Jun 12, 2014 3238 bsteffen Implement Interrogatable
*
* </pre>
*
@ -109,30 +129,51 @@ import com.vividsolutions.jts.geom.Coordinate;
*/
public class SatResource extends
AbstractPluginDataObjectResource<SatResourceData, IMapDescriptor>
implements ImageProvider {
implements ImageProvider, Interrogatable {
/** String id to look for satellite-provided data values */
/**
* String id to look for satellite-provided data values
*
* @deprecated use #SATELLITE_DATA_INTERROGATE_KEY and
* {@link #interrogate(ReferencedCoordinate, DataTime, InterrogationKey...)}
*/
@Deprecated
public static final String SATELLITE_DATA_INTERROGATE_ID = "satelliteDataValue";
@SuppressWarnings("unchecked")
public static final InterrogationKey<Measure<? extends Number, ?>> SATELLITE_DATA_INTERROGATE_KEY = new StringInterrogationKey<>(
SATELLITE_DATA_INTERROGATE_ID,
(Class<Measure<? extends Number, ?>>) ((Class<?>) Measure.class));
private static final InterrogationKey<SatelliteRecord> SATELLITE_RECORD_INTERROGATE_KEY = new ClassInterrogationKey<>(
SatelliteRecord.class);
private static final InterrogationKey<GeographicDataSource> DATA_SOURCE_INTERROGATE_KEY = new ClassInterrogationKey<>(
GeographicDataSource.class);
private static class InterrogationResult {
private final SatelliteRecord record;
private final SatTileSetRenderable renderable;
private final double value;
public InterrogationResult(SatelliteRecord record, double value) {
this.record = record;
public InterrogationResult(SatTileSetRenderable renderable, double value) {
this.renderable = renderable;
this.value = value;
}
public SatelliteRecord getRecord() {
return record;
return renderable.getSatelliteRecord();
}
public double getValue() {
return value;
}
public GeographicDataSource getDataSource() {
return renderable.getCurrentLevelDataSource();
}
}
private class SatRenderable implements IRenderable {
@ -225,8 +266,7 @@ public class SatResource extends
for (SatTileSetRenderable renderable : tileMap.values()) {
double rValue = renderable.interrogate(latLon, requestUnit);
if (Double.isNaN(rValue) == false) {
result = new InterrogationResult(
renderable.getSatelliteRecord(), rValue);
result = new InterrogationResult(renderable, rValue);
}
}
}
@ -550,4 +590,54 @@ public class SatResource extends
return true;
}
@Override
public Set<InterrogationKey<?>> getInterrogationKeys() {
Set<InterrogationKey<?>> result = new HashSet<>();
result.add(Interrogator.VALUE);
result.add(SATELLITE_DATA_INTERROGATE_KEY);
result.add(SATELLITE_RECORD_INTERROGATE_KEY);
result.add(DATA_SOURCE_INTERROGATE_KEY);
return result;
}
@Override
public InterrogateMap interrogate(ReferencedCoordinate coordinate,
DataTime time, InterrogationKey<?>... keys) {
InterrogateMap result = new InterrogateMap();
SatRenderable renderable = (SatRenderable) getRenderable(time);
if (renderable == null) {
return result;
}
ColorMapParameters parameters = getCapability(ColorMapCapability.class)
.getColorMapParameters();
Unit<?> dataUnit = parameters.getColorMapUnit();
InterrogationResult renderableResult = null;
try {
renderableResult = renderable.interrogate(coordinate.asLatLon(),
dataUnit);
} catch (VizException | TransformException | FactoryException e) {
statusHandler.error("Cannot interrogate satellite data", e);
}
if (renderableResult == null) {
return result;
}
double dataValue = renderableResult.getValue();
Measure<Double, ?> value = Measure.valueOf(dataValue, dataUnit);
for (InterrogationKey<?> key : keys) {
if (Interrogator.VALUE.equals(key)) {
result.put(Interrogator.VALUE, value);
} else if (SATELLITE_DATA_INTERROGATE_KEY.equals(key)) {
result.put(SATELLITE_DATA_INTERROGATE_KEY, value);
} else if (SATELLITE_RECORD_INTERROGATE_KEY.equals(key)) {
result.put(SATELLITE_RECORD_INTERROGATE_KEY,
renderableResult.getRecord());
} else if (DATA_SOURCE_INTERROGATE_KEY.equals(key)) {
result.put(DATA_SOURCE_INTERROGATE_KEY,
renderableResult.getDataSource());
}
}
return result;
}
}

View file

@ -19,12 +19,23 @@
**/
package com.raytheon.viz.satellite.tileset;
import org.geotools.coverage.grid.GeneralGridEnvelope;
import org.geotools.coverage.grid.GridGeometry2D;
import org.opengis.coverage.grid.GridEnvelope;
import com.raytheon.uf.common.colormap.image.ColorMapData;
import com.raytheon.uf.common.dataplugin.satellite.SatelliteRecord;
import com.raytheon.uf.common.geospatial.data.GeographicDataSource;
import com.raytheon.uf.common.numeric.source.DataSource;
import com.raytheon.uf.viz.core.DrawableImage;
import com.raytheon.uf.viz.core.IGraphicsTarget;
import com.raytheon.uf.viz.core.VizApp;
import com.raytheon.uf.viz.core.drawables.IColormappedImage;
import com.raytheon.uf.viz.core.drawables.IImage;
import com.raytheon.uf.viz.core.rsc.AbstractVizResource;
import com.raytheon.uf.viz.core.tile.RecordTileSetRenderable;
import com.raytheon.uf.viz.core.tile.Tile;
import com.raytheon.uf.viz.core.tile.TileLevel;
/**
* Satellite tile set renderable, uses {@link SatDataRetriever} for {@link Tile}
@ -37,6 +48,8 @@ import com.raytheon.uf.viz.core.tile.Tile;
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Jun 19, 2013 mschenke Initial creation
* Jun 19, 2014 3238 bsteffen Add method to create a DataSource for
* a tile level.
*
* </pre>
*
@ -78,4 +91,65 @@ public class SatTileSetRenderable extends RecordTileSetRenderable {
public SatelliteRecord getSatelliteRecord() {
return (SatelliteRecord) record;
}
public GeographicDataSource getCurrentLevelDataSource() {
TileLevel level = tileSet.getTileLevel(lastPaintedLevel);
DataSource tile = new TileLevelDataSource(level);
GridEnvelope range = tileSetGeometry.getGridRange();
int levelFactor = 2 * level.getLevel();
if (levelFactor == 0) {
levelFactor = 1;
}
int startX = range.getLow(0) / levelFactor;
int startY = range.getLow(1) / levelFactor;
int width = range.getSpan(0) / levelFactor;
int height = range.getSpan(1) / levelFactor;
GridGeometry2D levelGeometry = new GridGeometry2D(
new GeneralGridEnvelope(new int[] { startX, startY },
new int[] { width, height }, false),
tileSetGeometry.getEnvelope());
return new GeographicDataSource(tile, levelGeometry);
}
private class TileLevelDataSource implements DataSource {
private final TileLevel level;
public TileLevelDataSource(TileLevel level) {
this.level = level;
}
@Override
public double getDataValue(final int x, final int y) {
Tile tile = level.getTile((double) x, (double) y);
IColormappedImage cmapImage = null;
if (tile != null) {
DrawableImage di = imageMap.get(tile);
if (di != null) {
IImage image = di.getImage();
if (image instanceof IColormappedImage) {
cmapImage = (IColormappedImage) image;
}
}
}
if (cmapImage != null) {
final IColormappedImage theImage = cmapImage;
final double[] result = new double[1];
VizApp.runSync(new Runnable() {
@Override
public void run() {
result[0] = theImage.getValue(x % tileSize, y
% tileSize);
}
});
return result[0];
}
return Double.NaN;
}
}
}