From 2e0b64277cd5e5a104401ba6e05c86a6e59590e4 Mon Sep 17 00:00:00 2001 From: Mike Duff Date: Thu, 20 Sep 2012 10:17:47 -0500 Subject: [PATCH] Issue #1162 - Fix the NCEP/Hydro RFC FFG Mosaic displays. Fixed the grid resource and created FFGVizGroupResource. Change-Id: I4e90fb77c9a27da049e6c06d091076961e7f304c Former-commit-id: ec28f8f28ff333b3fa5e3db8d70377c37632c8f7 [formerly 643eaea29d97d27d1607b3f447c4ef59b9a8a385] [formerly 9fe028c4383d0f664843e5ccf0dd8f557081e267 [formerly d99d895daeaa049c6b4e683b7fbd37186f5ef1dc]] Former-commit-id: 9fe028c4383d0f664843e5ccf0dd8f557081e267 Former-commit-id: ff2bb36d393675a33957553d546264fce17b2427 --- .../grid/record/RequestableDataRecord.java | 18 +- .../viz/grid/rsc/FFGVizGroupResource.java | 203 ++++++++++++++++++ .../viz/grid/rsc/FfgGridNameGenerator.java | 34 +-- .../viz/grid/rsc/FfgVizGroupResourceData.java | 20 +- .../raytheon/viz/grid/rsc/GridResource.java | 110 ++++++++-- 5 files changed, 337 insertions(+), 48 deletions(-) create mode 100644 cave/com.raytheon.viz.grid/src/com/raytheon/viz/grid/rsc/FFGVizGroupResource.java diff --git a/cave/com.raytheon.viz.grid/src/com/raytheon/viz/grid/record/RequestableDataRecord.java b/cave/com.raytheon.viz.grid/src/com/raytheon/viz/grid/record/RequestableDataRecord.java index 8e54101886..497bc7e3f0 100644 --- a/cave/com.raytheon.viz.grid/src/com/raytheon/viz/grid/record/RequestableDataRecord.java +++ b/cave/com.raytheon.viz.grid/src/com/raytheon/viz/grid/record/RequestableDataRecord.java @@ -1,19 +1,19 @@ /** * 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 licensing information. **/ @@ -42,16 +42,17 @@ import com.raytheon.viz.grid.util.TiltRequest; /** * The RequestableDataRecord Class - * + * *
- * 
+ *
  * SOFTWARE HISTORY
  * Date         Ticket#    Engineer    Description
  * ------------ ---------- ----------- --------------------------
  * Mar 18, 2010            bsteffen     Initial creation
  * 
+ *
  * 
- * + * * @author bsteffen * @version 1.0 */ @@ -60,7 +61,7 @@ public class RequestableDataRecord extends GribRecord { private static final long serialVersionUID = 1L; - private AbstractRequestableData requester; + private final AbstractRequestableData requester; public RequestableDataRecord(AbstractRequestableData requester) throws VizException { @@ -74,6 +75,9 @@ public class RequestableDataRecord extends GribRecord { coverage); } GribModel modelInfo = new GribModel(); + if (requester instanceof GribRequestableData) { + setGridVersion(((GribRequestableData) requester).getGribSource().getGridVersion()); + } modelInfo.setModelName(requester.getSource()); modelInfo.setLocation(coverage); modelInfo.setLevel(requester.getLevel()); diff --git a/cave/com.raytheon.viz.grid/src/com/raytheon/viz/grid/rsc/FFGVizGroupResource.java b/cave/com.raytheon.viz.grid/src/com/raytheon/viz/grid/rsc/FFGVizGroupResource.java new file mode 100644 index 0000000000..e8a58a889e --- /dev/null +++ b/cave/com.raytheon.viz.grid/src/com/raytheon/viz/grid/rsc/FFGVizGroupResource.java @@ -0,0 +1,203 @@ +/** + * 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 licensing information. + **/ +package com.raytheon.viz.grid.rsc; +import java.util.ArrayList; +import java.util.Map; + +import com.raytheon.uf.common.geospatial.ReferencedCoordinate; +import com.raytheon.uf.common.time.DataTime; +import com.raytheon.uf.viz.core.IGraphicsTarget; +import com.raytheon.uf.viz.core.drawables.PaintProperties; +import com.raytheon.uf.viz.core.drawables.ResourcePair; +import com.raytheon.uf.viz.core.exception.VizException; +import com.raytheon.uf.viz.core.map.MapDescriptor; +import com.raytheon.uf.viz.core.rsc.AbstractVizResource; +import com.raytheon.uf.viz.core.rsc.IRefreshListener; +import com.raytheon.uf.viz.core.rsc.IResourceDataChanged; +import com.raytheon.uf.viz.core.rsc.LoadProperties; +import com.raytheon.uf.viz.core.rsc.ResourceList; +import com.raytheon.uf.viz.core.rsc.capabilities.AbstractCapability; +import com.raytheon.viz.core.rsc.VizGroupResourceData; + +/** + * FFG Group Resource class. + * + * Based off VizGroupResource.java + * + *
+ *
+ * SOFTWARE HISTORY
+ *
+ * Date         Ticket#    Engineer    Description
+ * ------------ ---------- ----------- --------------------------
+ * Sep 19, 2012  1162      mpduff      Initial creation.
+ *
+ * 
+ * + * @author mpduff + * @version 1.0 + */ + +public class FFGVizGroupResource extends + AbstractVizResource implements + IResourceDataChanged, IRefreshListener { + + private final String NO_DATA = "No Data"; + + /** + * Constructor. + * + * @param resourceData + * @param loadProperties + */ + protected FFGVizGroupResource(VizGroupResourceData resourceData, + LoadProperties loadProperties) { + super(resourceData, loadProperties); + dataTimes = new ArrayList(); + } + + /* + * (non-Javadoc) + * + * @see com.raytheon.uf.viz.core.rsc.AbstractVizResource#disposeInternal() + */ + @Override + protected void disposeInternal() { + for (ResourcePair rp : this.resourceData.getResourceList()) { + if (rp.getResource() != null) { + rp.getResource().dispose(); + } + } + } + + /* + * (non-Javadoc) + * + * @see + * com.raytheon.uf.viz.core.rsc.AbstractVizResource#paintInternal(com.raytheon + * .uf.viz.core.IGraphicsTarget, + * com.raytheon.uf.viz.core.drawables.PaintProperties) + */ + @Override + protected void paintInternal(IGraphicsTarget target, + PaintProperties paintProps) throws VizException { + for (ResourcePair rp : this.resourceData.getResourceList()) { + if (rp.getResource() != null) { + rp.getResource().paint(target, paintProps); + } + } + } + + /* + * (non-Javadoc) + * + * @see + * com.raytheon.uf.viz.core.rsc.AbstractVizResource#inspect(com.raytheon + * .uf.common.geospatial.ReferencedCoordinate) + */ + @Override + public String inspect(ReferencedCoordinate coord) throws VizException { + ResourceList rl = resourceData.getResourceList(); + String value = "No Data"; + for (ResourcePair pair : rl) { + if (pair.getResource() != null) { + AbstractVizResource rsc = pair.getResource(); + value = rsc.inspect(coord); + if (!value.equals(NO_DATA)) { + return value; + } + } + } + + return value; + } + + /* + * (non-Javadoc) + * + * @see + * com.raytheon.uf.viz.core.rsc.AbstractVizResource#interrogate(com.raytheon + * .uf.common.geospatial.ReferencedCoordinate) + */ + @Override + public Map interrogate(ReferencedCoordinate coord) + throws VizException { + // TODO Auto-generated method stub + return super.interrogate(coord); + } + + /* + * (non-Javadoc) + * + * @see + * com.raytheon.uf.viz.core.rsc.AbstractVizResource#initInternal(com.raytheon + * .uf.viz.core.IGraphicsTarget) + */ + @Override + protected void initInternal(IGraphicsTarget target) throws VizException { + for (AbstractVizResource resource : resourceData.getRscs()) { + if (resource != null) { + resource.init(target); + resource.registerListener(this); + } + } + + // If child resources have capabilities that this does not, steal them + for (AbstractVizResource rcs : getResourceData().getRscs()) { + for (AbstractCapability capability : rcs.getCapabilities() + .getCapabilityClassCollection()) { + this.getCapabilities().addCapability(capability); + capability.setResourceData(resourceData); + } + } + + // Spread my master capability set to all my children + for (AbstractCapability capability : getCapabilities() + .getCapabilityClassCollection()) { + for (AbstractVizResource rcs : getResourceData().getRscs()) { + rcs.getCapabilities().addCapability(capability); + } + } + } + + /* + * (non-Javadoc) + * + * @see com.raytheon.uf.viz.core.rsc.IRefreshListener#refresh() + */ + @Override + public void refresh() { + // TODO Auto-generated method stub + + } + + /* + * (non-Javadoc) + * + * @see + * com.raytheon.uf.viz.core.rsc.IResourceDataChanged#resourceChanged(com + * .raytheon.uf.viz.core.rsc.IResourceDataChanged.ChangeType, + * java.lang.Object) + */ + @Override + public void resourceChanged(ChangeType type, Object object) { + // TODO Auto-generated method stub + } +} diff --git a/cave/com.raytheon.viz.grid/src/com/raytheon/viz/grid/rsc/FfgGridNameGenerator.java b/cave/com.raytheon.viz.grid/src/com/raytheon/viz/grid/rsc/FfgGridNameGenerator.java index b871f0f615..af2fb63df1 100644 --- a/cave/com.raytheon.viz.grid/src/com/raytheon/viz/grid/rsc/FfgGridNameGenerator.java +++ b/cave/com.raytheon.viz.grid/src/com/raytheon/viz/grid/rsc/FfgGridNameGenerator.java @@ -1,61 +1,67 @@ /** * 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 licensing information. **/ package com.raytheon.viz.grid.rsc; +import javax.measure.unit.Unit; + import com.raytheon.uf.viz.core.rsc.AbstractVizResource; import com.raytheon.uf.viz.core.rsc.capabilities.ColorMapCapability; -import com.raytheon.viz.core.rsc.VizGroupResource; import com.raytheon.viz.core.rsc.VizGroupResourceData; /** * FFG Grid Name Generator. - * + * *
- * 
+ *
  * SOFTWARE HISTORY
- * 
+ *
  * Date         Ticket#    Engineer    Description
  * ------------ ---------- ----------- --------------------------
- * Jan 29, 2011            mpduff     Initial creation
- * 
+ * Jan 29, 2011            mpduff      Initial creation
+ * Sep 19, 2012  1162      mpudff      Protect against null pointer
+ *
  * 
- * + * * @author mpduff * @version 1.0 */ public class FfgGridNameGenerator extends GridNameGenerator { - + public FfgGridNameGenerator() { } /* * (non-Javadoc) - * + * * @see * com.raytheon.viz.grid.rsc.GridNameGenerator#getName(com.raytheon.uf.viz * .core.rsc.AbstractVizResource) */ @Override public String getName(AbstractVizResource absResource) { - String unit = ((VizGroupResource) absResource).getCapability(ColorMapCapability.class).getColorMapParameters().getDisplayUnit().toString(); - return ((VizGroupResourceData) absResource.getResourceData()).getName() + "(" + unit + ")"; + Unit unitObj = ((FFGVizGroupResource) absResource).getCapability(ColorMapCapability.class).getColorMapParameters().getDisplayUnit(); + if (unitObj != null) { + return ((VizGroupResourceData) absResource.getResourceData()).getName() + "(" + unitObj.toString() + ")"; + } + + return ((VizGroupResourceData) absResource.getResourceData()).getName(); } } diff --git a/cave/com.raytheon.viz.grid/src/com/raytheon/viz/grid/rsc/FfgVizGroupResourceData.java b/cave/com.raytheon.viz.grid/src/com/raytheon/viz/grid/rsc/FfgVizGroupResourceData.java index 8ef549e06b..bcecd0da91 100644 --- a/cave/com.raytheon.viz.grid/src/com/raytheon/viz/grid/rsc/FfgVizGroupResourceData.java +++ b/cave/com.raytheon.viz.grid/src/com/raytheon/viz/grid/rsc/FfgVizGroupResourceData.java @@ -1,19 +1,19 @@ /** * 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 licensing information. **/ @@ -28,16 +28,19 @@ import java.util.Iterator; import java.util.List; import java.util.Set; +import com.raytheon.uf.common.dataplugin.PluginDataObject; import com.raytheon.uf.common.time.DataTime; import com.raytheon.uf.viz.core.drawables.ResourcePair; import com.raytheon.uf.viz.core.exception.VizException; import com.raytheon.uf.viz.core.rsc.AbstractRequestableResourceData; +import com.raytheon.uf.viz.core.rsc.AbstractVizResource; +import com.raytheon.uf.viz.core.rsc.LoadProperties; import com.raytheon.viz.core.rsc.VizGroupResourceData; /** * FFG Resource Data. - * + * *
  *
  * SOFTWARE HISTORY
@@ -50,7 +53,7 @@ import com.raytheon.viz.core.rsc.VizGroupResourceData;
  * 
* * @author mpduff - * @version 1.0 + * @version 1.0 */ public class FfgVizGroupResourceData extends VizGroupResourceData { @@ -85,4 +88,11 @@ public class FfgVizGroupResourceData extends VizGroupResourceData { return availableTimes.toArray(new DataTime[availableTimes.size()]); } + + @Override + protected AbstractVizResource constructResource( + LoadProperties loadProperties, PluginDataObject[] objects) + throws VizException { + return new FFGVizGroupResource(this, loadProperties); + } } diff --git a/cave/com.raytheon.viz.grid/src/com/raytheon/viz/grid/rsc/GridResource.java b/cave/com.raytheon.viz.grid/src/com/raytheon/viz/grid/rsc/GridResource.java index 6ae4499d6a..4288fe7a07 100644 --- a/cave/com.raytheon.viz.grid/src/com/raytheon/viz/grid/rsc/GridResource.java +++ b/cave/com.raytheon.viz.grid/src/com/raytheon/viz/grid/rsc/GridResource.java @@ -1,19 +1,19 @@ /** * 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 licensing information. **/ @@ -112,6 +112,7 @@ import com.raytheon.viz.core.rsc.hdf5.AbstractTileSet; import com.raytheon.viz.core.rsc.hdf5.MemoryBasedTileSet; import com.raytheon.viz.core.style.image.ImagePreferences; import com.raytheon.viz.grid.GridLevelTranslator; +import com.raytheon.viz.grid.record.RequestableDataRecord; import com.raytheon.viz.grid.rsc.GridNameGenerator.IGridNameResource; import com.raytheon.viz.grid.rsc.GridNameGenerator.LegendParameters; import com.raytheon.viz.grid.xml.FieldDisplayTypesFactory; @@ -121,14 +122,14 @@ import com.vividsolutions.jts.io.WKTReader; /** * Grid Resource - * + * * Accepts grib data records from different time and levels. Data record array * should represent a single parameter. - * + * *
- * 
+ *
  *    SOFTWARE HISTORY
- *   
+ *
  *    Date         Ticket#     Engineer    Description
  *    ------------ ----------  ----------- --------------------------
  *    Feb 28, 2007             chammack    Initial Creation.
@@ -139,9 +140,10 @@ import com.vividsolutions.jts.io.WKTReader;
  *    06/19/2012   14988       D. Friedman Choose interpolation method based on
  *                                         ImagingCapability.isInterpolationState().
  *                                         Oversample reprojected grids.
- * 
+ *    09/20/2012    15394      mpduff      Condense the PDOs based on grid version.
+ *                                         Get DataTime from paintProps.
  * 
- * + * * @author chammack * @version 1 */ @@ -202,7 +204,7 @@ public class GridResource extends * The great protector of all things related to dataTimes, do not modify or * iterate over pdosToParse, dataTimes, or tileSet unless you sync on this * or else... - * + * */ protected Object timeLock = new Object(); @@ -540,7 +542,7 @@ public class GridResource extends } private class DataRetrievalJob extends Job { - private ConcurrentLinkedQueue tilesToRetrieve = new ConcurrentLinkedQueue(); + private final ConcurrentLinkedQueue tilesToRetrieve = new ConcurrentLinkedQueue(); public DataRetrievalJob() { super("Retrieving Gridded Data"); @@ -566,7 +568,7 @@ public class GridResource extends } } - private DataRetrievalJob dataRetriever = new DataRetrievalJob(); + private final DataRetrievalJob dataRetriever = new DataRetrievalJob(); /** * Constructor @@ -785,7 +787,7 @@ public class GridResource extends /* * (non-Javadoc) - * + * * @see com.raytheon.uf.viz.core.rsc.AbstractVizResource#disposeInternal() */ @Override @@ -807,6 +809,7 @@ public class GridResource extends this.target = target; if (pdosToParse.size() > 0) { + condensePDOs(); for (PluginDataObject pdo : pdosToParse) { createTile(pdo); } @@ -893,9 +896,71 @@ public class GridResource extends } } + /** + * Condense the PDOs to one pdo per level per DataTime based on + * the gridVersion. + */ + private void condensePDOs() { + Map>> dateMap = new HashMap>>(); + List newList = new ArrayList(); + + for (PluginDataObject pdo : pdosToParse) { + if (pdo instanceof RequestableDataRecord) { + String level = null; + if (!dateMap.containsKey(pdo.getDataTime())) { + Map> levelMap = new HashMap>(); + + RequestableDataRecord rdr = (RequestableDataRecord) pdo; + level = rdr.getModelInfo().getLevel().getLevelInfo(); + levelMap.put(level, new ArrayList()); + dateMap.put(pdo.getDataTime(), levelMap); + } + + Map> levelsMap = dateMap.get(pdo + .getDataTime()); + String lvl = ((RequestableDataRecord) pdo).getModelInfo() + .getLevelInfo(); + if (!levelsMap.containsKey(lvl)) { + levelsMap.put(lvl, new ArrayList()); + } + levelsMap.get(lvl).add(pdo); + } + } + + // loop over each date + for (DataTime time : dateMap.keySet()) { + Map> levelMap = dateMap.get(time); + + // loop over each level + for (String key : levelMap.keySet()) { + List pdos = levelMap.get(key); + + PluginDataObject maxVersionedPdo = null; + int maxVersion = -1; + + // loop over all the pdos for this level + for (PluginDataObject pdo : pdos) { + RequestableDataRecord rdr = (RequestableDataRecord) pdo; + int version = ((GribRecord) rdr).getGridVersion(); + if (version > maxVersion) { + maxVersion = version; + maxVersionedPdo = pdo; + } + } + + newList.add(maxVersionedPdo); + } + } + + if (!newList.isEmpty()) { + pdosToParse.clear(); + pdosToParse.addAll(newList); + } + } + /** * Combine the given tiles sets - * + * * @param gridMemoryBasedTileSet * @param gridMemoryBasedTileSet2 * @param dataTime @@ -1099,7 +1164,7 @@ public class GridResource extends /** * Subtracts the second parameter from the first. - * + * * @param floatDataRecord1 * @param floatDataRecord2 * @param primaryMax @@ -1157,7 +1222,7 @@ public class GridResource extends /** * Dynamically scale the color map based on the data in the given tileset - * + * * @param gridMemoryBasedTileSet */ private void updateColorMap(GridMemoryBasedTileSet gridMemoryBasedTileSet) { @@ -1202,7 +1267,7 @@ public class GridResource extends PaintProperties paintProps) throws VizException { this.target = target; - DataTime time = descriptor.getFramesInfo().getTimeForResource(this); + DataTime time = paintProps.getDataTime(); Map tileGroup = tileSet.get(time); if (tileGroup == null) { return; @@ -1441,7 +1506,7 @@ public class GridResource extends /* * (non-Javadoc) - * + * * @see * com.raytheon.viz.core.rsc.capabilities.IVertSeqResource#getVerticalLevels * () @@ -1452,7 +1517,7 @@ public class GridResource extends /* * (non-Javadoc) - * + * * @see * com.raytheon.viz.core.rsc.capabilities.IVertSeqResource#getVerticalLevelType * () @@ -1463,7 +1528,7 @@ public class GridResource extends /* * (non-Javadoc) - * + * * @see * com.raytheon.viz.core.rsc.capabilities.IVertSeqResource#setVerticalLevel * (float) @@ -1520,9 +1585,10 @@ public class GridResource extends if (object instanceof ImagingCapability) { // TODO: check if interpolation state really changed try { - if (descriptor != null) + if (descriptor != null) { project(descriptor.getGridGeometry() .getCoordinateReferenceSystem()); + } } catch (VizException e) { statusHandler.handle(Priority.PROBLEM, "Error updating grid resource imaging", e); @@ -1550,7 +1616,7 @@ public class GridResource extends /* * (non-Javadoc) - * + * * @see com.raytheon.uf.viz.core.rsc.AbstractVizResource#getName() */ @Override