From f16fab0d68969da6764b9fe3580b90e65133e84b Mon Sep 17 00:00:00 2001 From: Ben Steffensmeier Date: Fri, 18 Apr 2014 15:58:43 -0500 Subject: [PATCH] Issue #2947 Improve support for Satellite combined products. Former-commit-id: 4abdb898f49963a8fa1208e6ff84d1d8469bf10d [formerly 87adc0e3c5fbc3bc7eb4ea4ae408db0182464243] [formerly 043d9c8b8de82edfa02826a812bd40c2a5f7ad87] [formerly c3cd47315879ec6514222810cb3cbeb0fe979dd3 [formerly 043d9c8b8de82edfa02826a812bd40c2a5f7ad87 [formerly 891422a7d324514d5ee82d3d195e923c27fc58ef]]] Former-commit-id: c3cd47315879ec6514222810cb3cbeb0fe979dd3 Former-commit-id: c84842cbdc7ae780b96dc50e92fdeb467f64bad1 [formerly b05e2a22b8c99dfa01c312b048908e3c681b9876] Former-commit-id: 8b80c6d8fadc2bae9daad56132f7685c4763672e --- .../uf/viz/truecolor/rsc/ChannelInfo.java | 24 ++++++++------ .../truecolor/rsc/TrueColorResourceGroup.java | 18 ++++++++--- .../ext/mosaic/GLMosaicImageExtension.java | 3 +- .../satellite/rsc/SatBestResResourceData.java | 25 +++++++++------ .../satellite/rsc/SatBlendedResourceData.java | 32 +++++++++++++------ .../viz/satellite/rsc/SatResource.java | 11 ++++--- 6 files changed, 73 insertions(+), 40 deletions(-) diff --git a/cave/com.raytheon.uf.viz.truecolor/src/com/raytheon/uf/viz/truecolor/rsc/ChannelInfo.java b/cave/com.raytheon.uf.viz.truecolor/src/com/raytheon/uf/viz/truecolor/rsc/ChannelInfo.java index fe297e7e0d..373da39d85 100644 --- a/cave/com.raytheon.uf.viz.truecolor/src/com/raytheon/uf/viz/truecolor/rsc/ChannelInfo.java +++ b/cave/com.raytheon.uf.viz.truecolor/src/com/raytheon/uf/viz/truecolor/rsc/ChannelInfo.java @@ -37,9 +37,11 @@ import com.raytheon.uf.viz.truecolor.extension.ITrueColorImagingExtension.Channe * * SOFTWARE HISTORY * - * Date Ticket# Engineer Description - * ------------ ---------- ----------- -------------------------- - * Aug 20, 2012 mschenke Initial creation + * Date Ticket# Engineer Description + * ------------- -------- ----------- -------------------------- + * Aug 20, 2012 mschenke Initial creation + * Apr 18, 2014 2947 bsteffen Support unitless data. + * * * * @@ -117,20 +119,22 @@ public class ChannelInfo { * the unit to set */ public void setUnit(Unit unit) { - this.unit = unit; + if (unit == null) { + this.unit = Unit.ONE; + } else { + this.unit = unit; + } } @XmlElement(name = "unit") public void setUnitString(String unit) { if (unit != null) { - this.unit = UnitFormat.getUCUMInstance().parseObject(unit, - new ParsePosition(0)); + setUnit(UnitFormat.getUCUMInstance().parseObject(unit, + new ParsePosition(0))); } else { - this.unit = null; - } - if (this.unit == null) { - this.unit = Unit.ONE; + setUnit(null); } + } public String getUnitString() { diff --git a/cave/com.raytheon.uf.viz.truecolor/src/com/raytheon/uf/viz/truecolor/rsc/TrueColorResourceGroup.java b/cave/com.raytheon.uf.viz.truecolor/src/com/raytheon/uf/viz/truecolor/rsc/TrueColorResourceGroup.java index b2d41c3caa..be4dbb84eb 100644 --- a/cave/com.raytheon.uf.viz.truecolor/src/com/raytheon/uf/viz/truecolor/rsc/TrueColorResourceGroup.java +++ b/cave/com.raytheon.uf.viz.truecolor/src/com/raytheon/uf/viz/truecolor/rsc/TrueColorResourceGroup.java @@ -24,6 +24,8 @@ import java.util.HashMap; import java.util.IdentityHashMap; import java.util.Map; +import javax.measure.converter.UnitConverter; + import org.eclipse.swt.graphics.Rectangle; import org.opengis.referencing.crs.CoordinateReferenceSystem; @@ -63,9 +65,10 @@ import com.vividsolutions.jts.geom.Coordinate; * * SOFTWARE HISTORY * - * Date Ticket# Engineer Description - * ------------ ---------- ----------- -------------------------- - * Aug 6, 2012 mschenke Initial creation + * Date Ticket# Engineer Description + * ------------- -------- ----------- -------------------------- + * Aug 06, 2012 mschenke Initial creation + * Apr 18, 2014 2947 bsteffen Support unitless data. * * * @@ -422,11 +425,16 @@ public class TrueColorResourceGroup extends } else if (object instanceof ColorMapCapability) { ColorMapParameters params = ((ColorMapCapability) object) .getColorMapParameters(); + UnitConverter toDisplay = params + .getColorMapToDisplayConverter(); + if (toDisplay == null) { + toDisplay = UnitConverter.IDENTITY; + } ChannelInfo ci = channelInfoMap.get(params); if (ci != null) { - ci.setRangeMin(params.getDataToDisplayConverter().convert( + ci.setRangeMin(toDisplay.convert( params.getColorMapMin())); - ci.setRangeMax(params.getDataToDisplayConverter().convert( + ci.setRangeMax(toDisplay.convert( params.getColorMapMax())); ci.setUnit(params.getDisplayUnit()); } diff --git a/cave/com.raytheon.viz.core.gl/src/com/raytheon/viz/core/gl/internal/ext/mosaic/GLMosaicImageExtension.java b/cave/com.raytheon.viz.core.gl/src/com/raytheon/viz/core/gl/internal/ext/mosaic/GLMosaicImageExtension.java index c6ce3e9258..9590bd5a5d 100644 --- a/cave/com.raytheon.viz.core.gl/src/com/raytheon/viz/core/gl/internal/ext/mosaic/GLMosaicImageExtension.java +++ b/cave/com.raytheon.viz.core.gl/src/com/raytheon/viz/core/gl/internal/ext/mosaic/GLMosaicImageExtension.java @@ -58,6 +58,7 @@ import com.raytheon.viz.core.gl.images.GLOffscreenColormappedImage; * Nov 20, 2013 2492 bsteffen Mosaic in image units. * Apr 08, 2014 2950 bsteffen Always use float for maximum precision * offscreen so interpolation works. + * Apr 18, 2014 2947 bsteffen Fix mosaicing of datamapped images. * * * @@ -144,7 +145,7 @@ public abstract class GLMosaicImageExtension extends GLColormappedImageExtension.setupDataMapping(gl, (AbstractGLColormappedImage) image, - writeToImage.getDataUnit(), 2, 3); + writeToImage.getDataUnit(), GL.GL_TEXTURE2, GL.GL_TEXTURE3); return image; } // Fall through here, no actual rendering will occur diff --git a/cave/com.raytheon.viz.satellite/src/com/raytheon/viz/satellite/rsc/SatBestResResourceData.java b/cave/com.raytheon.viz.satellite/src/com/raytheon/viz/satellite/rsc/SatBestResResourceData.java index 15ee46a043..98b6a37f3c 100644 --- a/cave/com.raytheon.viz.satellite/src/com/raytheon/viz/satellite/rsc/SatBestResResourceData.java +++ b/cave/com.raytheon.viz.satellite/src/com/raytheon/viz/satellite/rsc/SatBestResResourceData.java @@ -69,6 +69,7 @@ import com.vividsolutions.jts.geom.Polygon; * Nov 06, 2012 15157 D. Friedman Allow configured inclusion percentage * Oct 10, 2013 2104 mschenke Fixed broken percentage calculation * Mar 11, 2014 2896 bsteffen Limit the number of divisions. + * Apr 18, 2014 2947 bsteffen limit divisions more for pretiled data. * * * @@ -298,7 +299,7 @@ public class SatBestResResourceData extends AbstractRequestableResourceData { } private double getInclusionPercentage(IDescriptor descriptor, - ResourcePair rp, Polygon extent) throws VizException { + ResourcePair rp, Polygon extent) { Double totalPercentage = Double.NaN; GeneralGridGeometry targetGeometry = descriptor.getGridGeometry(); try { @@ -313,10 +314,14 @@ public class SatBestResResourceData extends AbstractRequestableResourceData { request.setDistinct(true); DbQueryResponse response = (DbQueryResponse) ThriftClient .sendRequest(request); + IGridGeometryProvider[] coverages = response.getFieldObjects( + "coverage", IGridGeometryProvider.class); + int maxDivisions = 1024; + if (coverages.length > 0) { + maxDivisions = Math.max(16, maxDivisions / coverages.length); + } Geometry area = null; - for (Map result : response.getResults()) { - IGridGeometryProvider provider = (IGridGeometryProvider) result - .get("coverage"); + for (IGridGeometryProvider provider : coverages) { GridGeometry2D gridGeometry = provider.getGridGeometry(); double envWidth = gridGeometry.getEnvelope().getSpan(0); @@ -326,14 +331,14 @@ public class SatBestResResourceData extends AbstractRequestableResourceData { int xDiv = (int) (envWidth / 100); int yDiv = (int) (envHeight / 100); - if (xDiv * yDiv > 1024 * 1024) { - /* Don't wasste too much time/memory, preserve aspect ratio. */ + if ((long) xDiv * (long) yDiv > maxDivisions * maxDivisions) { + /* Don't waste too much time/memory, preserve aspect ratio. */ if (xDiv > yDiv) { - yDiv = 1024 * yDiv / xDiv; - xDiv = 1024; + yDiv = maxDivisions * yDiv / xDiv; + xDiv = maxDivisions; } else { - xDiv = 1024 * xDiv / yDiv; - yDiv = 1024; + xDiv = maxDivisions * xDiv / yDiv; + yDiv = maxDivisions; } } Geometry intersection = EnvelopeIntersection diff --git a/cave/com.raytheon.viz.satellite/src/com/raytheon/viz/satellite/rsc/SatBlendedResourceData.java b/cave/com.raytheon.viz.satellite/src/com/raytheon/viz/satellite/rsc/SatBlendedResourceData.java index 4485d0bb6c..e811b02621 100644 --- a/cave/com.raytheon.viz.satellite/src/com/raytheon/viz/satellite/rsc/SatBlendedResourceData.java +++ b/cave/com.raytheon.viz.satellite/src/com/raytheon/viz/satellite/rsc/SatBlendedResourceData.java @@ -58,18 +58,26 @@ import com.raytheon.uf.viz.core.rsc.ResourceList; import com.raytheon.uf.viz.datacube.DataCubeContainer; /** - * TODO Add Description + * Resource which displays multiple Satellite resources simultaneously. It is + * designed for displaying multiple, potentially overlapping regions such as + * the GOES East/West CONUS displays. This resource takes advantage of the + * mosaicing capability to render all teh satellite products into a single + * composite so that alpha changes are consistent for overlapping areas. * *
  * 
  * SOFTWARE HISTORY
- * Date         Ticket#    Engineer    Description
- * ------------ ---------- ----------- --------------------------
- * Feb 19, 2009            jsanchez     Initial creation
- * Mar 10, 2009        800 jsanchez     Returned a single display name at a time.
- * Mar 20, 2009            jsanchez     Constructed resource with highest frequency first.
- * Apr 29, 2009       2295 jsanchez     Removed the size parameter in getFrequencyIndex().
- * Jun 17, 2009       2493 jsanchez     Displayed both times in CONUS scale.
+ * Date          Ticket#  Engineer    Description
+ * ------------- -------- ----------- --------------------------
+ * Feb 19, 2009           jsanchez    Initial creation
+ * Mar 10, 2009  800      jsanchez    Returned a single display name at a time.
+ * Mar 20, 2009           jsanchez    Constructed resource with highest
+ *                                    frequency first.
+ * Apr 29, 2009  2295     jsanchez    Removed the size parameter in
+ *                                    getFrequencyIndex().
+ * Jun 17, 2009  2493     jsanchez    Displayed both times in CONUS scale.
+ * Apr 18, 2014  2947     bsteffen    Allow resources being blended to omit
+ *                                    load properties.
  * 
  * 
* @@ -147,8 +155,12 @@ public class SatBlendedResourceData extends AbstractRequestableResourceData if (rp.getResource() != null) { rp.setResourceData(rp.getResource().getResourceData()); } - rp.getLoadProperties().overrideCapabilities( - loadProperties.getCapabilities()); + LoadProperties props = rp.getLoadProperties(); + if (props == null) { + props = new LoadProperties(); + rp.setLoadProperties(props); + } + props.overrideCapabilities(loadProperties.getCapabilities()); boolean success = true; try { success = rp.instantiateResource(descriptor, false); diff --git a/cave/com.raytheon.viz.satellite/src/com/raytheon/viz/satellite/rsc/SatResource.java b/cave/com.raytheon.viz.satellite/src/com/raytheon/viz/satellite/rsc/SatResource.java index c4eec82abf..55204a29b3 100644 --- a/cave/com.raytheon.viz.satellite/src/com/raytheon/viz/satellite/rsc/SatResource.java +++ b/cave/com.raytheon.viz.satellite/src/com/raytheon/viz/satellite/rsc/SatResource.java @@ -41,7 +41,6 @@ import com.raytheon.uf.common.colormap.prefs.DataMappingPreferences; import com.raytheon.uf.common.dataplugin.PluginDataObject; import com.raytheon.uf.common.dataplugin.satellite.SatMapCoverage; import com.raytheon.uf.common.dataplugin.satellite.SatelliteRecord; -import com.raytheon.uf.common.dataplugin.satellite.units.SatelliteUnits; import com.raytheon.uf.common.geospatial.IGridGeometryProvider; import com.raytheon.uf.common.geospatial.ReferencedCoordinate; import com.raytheon.uf.common.style.ParamLevelMatchCriteria; @@ -60,12 +59,14 @@ import com.raytheon.uf.viz.core.IGraphicsTarget; import com.raytheon.uf.viz.core.drawables.ColorMapLoader; import com.raytheon.uf.viz.core.drawables.IRenderable; import com.raytheon.uf.viz.core.drawables.PaintProperties; +import com.raytheon.uf.viz.core.drawables.ext.IImagingExtension.ImageProvider; import com.raytheon.uf.viz.core.exception.VizException; import com.raytheon.uf.viz.core.map.IMapDescriptor; import com.raytheon.uf.viz.core.rsc.AbstractPluginDataObjectResource; 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.viz.satellite.SatelliteConstants; import com.raytheon.viz.satellite.inventory.DerivedSatelliteRecord; import com.raytheon.viz.satellite.tileset.SatDataRetriever; @@ -98,7 +99,7 @@ import com.vividsolutions.jts.geom.Coordinate; * Nov 20, 2013 2492 bsteffen Always get min/max values from style * rules. * Apr 09, 2014 2947 bsteffen Improve flexibility of sat derived - * parameters. + * parameters, implement ImageProvider * * * @@ -106,7 +107,8 @@ import com.vividsolutions.jts.geom.Coordinate; * @version 1 */ public class SatResource extends - AbstractPluginDataObjectResource { + AbstractPluginDataObjectResource + implements ImageProvider { /** String id to look for satellite-provided data values */ public static final String SATELLITE_DATA_INTERROGATE_ID = "satelliteDataValue"; @@ -268,7 +270,7 @@ public class SatResource extends private void initializeFirstFrame(SatelliteRecord record) throws VizException { - SatelliteUnits.register(); + getCapability(ImagingCapability.class).setProvider(this); ColorMapParameters colorMapParameters = null; IColorMap colorMap = null; String cmName = null; @@ -463,6 +465,7 @@ public class SatResource extends record.getCreatingEntity()); } + @Override public List getImages(IGraphicsTarget target, PaintProperties paintProps) throws VizException { SatRenderable renderable = (SatRenderable) getOrCreateRenderable(paintProps