diff --git a/GribSpatialCache.java b/GribSpatialCache.java new file mode 100644 index 0000000000..feac8b8fa9 --- /dev/null +++ b/GribSpatialCache.java @@ -0,0 +1,750 @@ +/** + * 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.edex.plugin.grib.spatial; + +import java.io.File; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Iterator; +import java.util.LinkedList; +import java.util.List; +import java.util.Map; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.opengis.metadata.spatial.PixelOrientation; + +import com.raytheon.edex.plugin.grib.dao.GribModelDao; +import com.raytheon.edex.plugin.grib.dao.GridCoverageDao; +import com.raytheon.edex.plugin.grib.dao.IGridCoverageDao; +import com.raytheon.edex.site.SiteUtil; +import com.raytheon.uf.common.awipstools.GetWfoCenterPoint; +import com.raytheon.uf.common.dataplugin.grib.exception.GribException; +import com.raytheon.uf.common.dataplugin.grib.spatial.projections.GridCoverage; +import com.raytheon.uf.common.dataplugin.grib.subgrid.SubGrid; +import com.raytheon.uf.common.dataplugin.grib.subgrid.SubGridDef; +import com.raytheon.uf.common.dataplugin.grib.util.GribModelLookup; +import com.raytheon.uf.common.dataplugin.grib.util.GridModel; +import com.raytheon.uf.common.geospatial.MapUtil; +import com.raytheon.uf.common.localization.IPathManager; +import com.raytheon.uf.common.localization.LocalizationContext; +import com.raytheon.uf.common.localization.LocalizationContext.LocalizationLevel; +import com.raytheon.uf.common.localization.LocalizationContext.LocalizationType; +import com.raytheon.uf.common.localization.LocalizationFile; +import com.raytheon.uf.common.localization.PathManagerFactory; +import com.raytheon.uf.common.serialization.SerializationException; +import com.raytheon.uf.common.serialization.SerializationUtil; +import com.raytheon.uf.edex.awipstools.GetWfoCenterHandler; +import com.raytheon.uf.edex.core.EDEXUtil; +import com.raytheon.uf.edex.database.DataAccessLayerException; +import com.raytheon.uf.edex.database.cluster.ClusterLockUtils; +import com.raytheon.uf.edex.database.cluster.ClusterLockUtils.LockState; +import com.raytheon.uf.edex.database.cluster.ClusterTask; +import com.raytheon.uf.edex.database.dao.CoreDao; +import com.raytheon.uf.edex.database.dao.DaoConfig; +import com.vividsolutions.jts.geom.Coordinate; + +/** + * Cache used for holding GridCoverage objects. Since creating geometries and + * CRS objects are expensive operations, this cache is used to store + * GridCoverages as they are produced. + * + *
+ * + * SOFTWARE HISTORY + * + * Date Ticket# Engineer Description + * ------------ ---------- ----------- -------------------------- + * 4/7/09 1994 bphillip Initial Creation + * + *+ * + * @author bphillip + * @version 1 + */ +public class GribSpatialCache { + + /** The logger */ + protected transient Log logger = LogFactory.getLog(getClass()); + + /** The singleton instance */ + private static GribSpatialCache instance = new GribSpatialCache(); + + /** + * Map containing the GridCoverages
+ * + * SOFTWARE HISTORY + * + * Date Ticket# Engineer Description + * ------------ ---------- ----------- -------------------------- + * May 1, 2012 #470 bphillip Initial creation + * + *+ * + * @author bphillip + * @version 1.0 + */ +public class PurgeDao extends CoreDao { + + /** + * Constructs a new purge data access object + */ + public PurgeDao() { + super(DaoConfig.forClass(PurgeJobStatus.class)); + } + + /** + * Gets the number of purge jobs currently running on the cluster. A job is + * considered running if the 'running' flag is set to true and the job has + * been started since validStartTime and has not met or exceeded the failed + * count. + * + * @param validStartTime + * @param failedCount + * @return The number of purge jobs currently running on the cluster + */ + public int getRunningClusterJobs(final Date validStartTime, + final int failedCount) { + final String query = "from " + + daoClass.getName() + + " obj where obj.running = true and obj.startTime > :startTime and obj.failedCount <= :failedCount"; + return (Integer) txTemplate.execute(new TransactionCallback() { + @Override + public Object doInTransaction(TransactionStatus status) { + Query hibQuery = getSession(false).createQuery(query); + hibQuery.setTimestamp("startTime", validStartTime); + hibQuery.setInteger("failedCount", failedCount); + List> queryResult = hibQuery.list(); + if (queryResult == null) { + return 0; + } else { + return queryResult.size(); + } + } + }); + } + + /** + * Returns the jobs that have met or exceed the failed count. + * + * @param failedCount + * @return + */ + @SuppressWarnings("unchecked") + public List
+ * + * SOFTWARE HISTORY + * + * Date Ticket# Engineer Description + * ------------ ---------- ----------- -------------------------- + * Apr 19, 2012 #470 bphillip Initial creation + * + *+ * + * @author bphillip + * @version 1.0 + */ +public class PurgeJob extends Thread { + + /** The type of purge */ + public enum PURGE_JOB_TYPE { + PURGE_ALL, PURGE_EXPIRED + } + + private long startTime; + + /** The cluster task name to use for purge jobs */ + public static final String TASK_NAME = "Purge Plugin Data"; + + /** The plugin associated with this purge job */ + private String pluginName; + + /** The type of purge job being executed */ + private PURGE_JOB_TYPE purgeType; + + /** Last time job has printed a timed out message */ + private long lastTimeOutMessage = 0; + + /** + * Creates a new Purge job for the specified plugin. + * + * @param pluginName + * The plugin to be purged + * @param purgeType + * The type of purge to be executed + */ + public PurgeJob(String pluginName, PURGE_JOB_TYPE purgeType) { + // Give the thread a name + this.setName("Purge-" + pluginName.toUpperCase() + "-Thread"); + this.pluginName = pluginName; + this.purgeType = purgeType; + } + + public void run() { + + // Flag used to track if this job has failed + boolean failed = false; + startTime = System.currentTimeMillis(); + PurgeLogger.logInfo("Purging expired data...", pluginName); + PluginDao dao = null; + + try { + dao = PluginFactory.getInstance().getPluginDao(pluginName); + if (dao.getDaoClass() != null) { + dao.purgeExpiredData(); + PurgeLogger.logInfo("Data successfully Purged!", pluginName); + } else { + Method m = dao.getClass().getMethod("purgeExpiredData", + new Class[] {}); + if (m != null) { + if (m.getDeclaringClass().equals(PluginDao.class)) { + PurgeLogger + .logWarn( + "Unable to purge data. This plugin does not specify a record class and does not implement a custom purger.", + pluginName); + } else { + if (this.purgeType.equals(PURGE_JOB_TYPE.PURGE_EXPIRED)) { + dao.purgeExpiredData(); + } else { + dao.purgeAllData(); + } + PurgeLogger.logInfo("Data successfully Purged!", + pluginName); + } + } + } + } catch (Exception e) { + failed = true; + // keep getting next exceptions with sql exceptions to ensure + // we can see the underlying error + PurgeLogger + .logError("Error purging expired data!\n", pluginName, e); + Throwable t = e.getCause(); + while (t != null) { + if (t instanceof SQLException) { + SQLException se = ((SQLException) t).getNextException(); + PurgeLogger.logError("Next exception:", pluginName, se); + } + t = t.getCause(); + } + } finally { + ClusterTask purgeLock = PurgeManager.getInstance().getPurgeLock(); + try { + /* + * Update the status accordingly if the purge failed or + * succeeded + */ + PurgeDao purgeDao = new PurgeDao(); + PurgeJobStatus status = purgeDao + .getJobForPlugin(this.pluginName); + if (status == null) { + PurgeLogger.logError( + "Purge job completed but no status object found!", + this.pluginName); + } else { + if (failed) { + status.incrementFailedCount(); + if (status.getFailedCount() >= PurgeManager + .getInstance().getFatalFailureCount()) { + PurgeLogger + .logFatal( + "Purger for this plugin has reached or exceeded consecutive failure limit of " + + PurgeManager + .getInstance() + .getFatalFailureCount() + + ". Data will no longer being purged for this plugin.", + pluginName); + } else { + PurgeLogger.logError("Purge job has failed " + + status.getFailedCount() + + " consecutive times.", this.pluginName); + // Back the start time off by half an hour to try to + // purgin soon, don't want to start immediately so + // it doesn't ping pong between servers in a time + // out scenario + Date startTime = status.getStartTime(); + startTime.setTime(startTime.getTime() - (1800000)); + } + } else { + status.setFailedCount(0); + } + + /* + * This purger thread has exceeded the time out duration but + * finally finished. Output a message and update the status + */ + int deadPurgeJobAge = PurgeManager.getInstance() + .getDeadPurgeJobAge(); + Calendar purgeTimeOutLimit = Calendar.getInstance(); + purgeTimeOutLimit.setTimeZone(TimeZone.getTimeZone("GMT")); + purgeTimeOutLimit.add(Calendar.MINUTE, -deadPurgeJobAge); + if (startTime < purgeTimeOutLimit.getTimeInMillis()) { + PurgeLogger + .logInfo( + "Purge job has recovered from timed out state!!", + pluginName); + } + status.setRunning(false); + purgeDao.update(status); + /* + * Log execution times + */ + long executionTime = getAge(); + long execTimeInMinutes = executionTime / 60000; + if (execTimeInMinutes > 0) { + PurgeLogger.logInfo("Purge run time: " + executionTime + + " ms (" + execTimeInMinutes + " minutes)", + this.pluginName); + } else { + PurgeLogger.logInfo("Purge run time: " + executionTime + + " ms", this.pluginName); + } + } + } catch (Throwable e) { + PurgeLogger + .logError( + "An unexpected error occurred upon completion of the purge job", + this.pluginName, e); + } finally { + ClusterLockUtils.unlock(purgeLock, false); + } + } + } + + public void printTimedOutMessage(int deadPurgeJobAge) { + // only print message every 5 minutes + if (System.currentTimeMillis() - lastTimeOutMessage > 300000) { + PurgeLogger.logFatal( + "Purger running time has exceeded timeout duration of " + + deadPurgeJobAge + + " minutes. Current running time: " + + (getAge() / 60000) + " minutes", pluginName); + printStackTrace(); + } + } + + /** + * Prints the stack trace for this job thread. + */ + public void printStackTrace() { + StringBuffer buffer = new StringBuffer(); + buffer.append("Stack trace for Purge Job Thread:\n"); + buffer.append(getStackTrace(this)); + // If this thread is blocked, output the stack traces for the other + // blocked threads to assist in determining the source of the + // deadlocked + // threads + if (this.getState().equals(State.BLOCKED)) { + buffer.append("\tDUMPING OTHER BLOCKED THREADS\n"); + buffer.append(getBlockedStackTraces()); + + } + PurgeLogger.logError(buffer.toString(), this.pluginName); + + } + + /** + * Gets the stack traces for all other threads in the BLOCKED state in the + * JVM + * + * @return The stack traces for all other threads in the BLOCKED state in + * the JVM + */ + private String getBlockedStackTraces() { + StringBuffer buffer = new StringBuffer(); + Map
+ * The purge manager is designed to adhere to the following rules: + *
+ * · The cluster may have no more than 6 purge jobs running simultaneously by
+ * default. This property is configurable in the project.properties file
+ * · Any given server may have no more than 2 purge jobs running simultaneously
+ * by default. This property is configurable in the project.properties file
+ * · A purge job for a plugin is considered 'hung' if it has been running for
+ * more than 20 minutes by default. This property is configurable in the
+ * project.properties file
+ * · If a purge job that was previously determined to be hung actually finishes
+ * it's execution, the cluster lock is updated appropriately and the purge job
+ * is able to resume normal operation. This is in place so if a hung purge
+ * process goes unnoticed for a period of time, the server will still try to
+ * recover autonomously if it can.
+ * · If a purge job is determined to be hung, the stack trace for the thread
+ * executing the job is output to the log. Furthermore, if the job is in the
+ * BLOCKED state, the stack traces for all other BLOCKED threads is output to
+ * the purge log as part of a rudimentary deadlock detection strategy to be used
+ * by personnel attempting to remedy the situation.
+ * · By default, a fatal condition occurs if a given plugin's purge job fails 3
+ * consecutive times.
+ * · If a purge job hangs on one server in the cluster, it will try and run on
+ * another cluster member at the next purge interval.
+ * · If the purge manager attempts to purge a plugin that has been running for
+ * longer than the 20 minute threshold, it is considered a failure, and the
+ * failure count is updated.
+ *
+ * + * + *
+ * + * SOFTWARE HISTORY + * + * Date Ticket# Engineer Description + * ------------ ---------- ----------- -------------------------- + * Apr 18, 2012 #470 bphillip Initial creation + * + *+ * + * @author bphillip + * @version 1.0 + */ +public class PurgeManager { + + /** Purge Manager task name */ + private static final String PURGE_TASK_NAME = "Purge Manager"; + + /** Purge Manager task details */ + private static final String PURGE_TASK_DETAILS = "Purge Manager Job"; + + /** Purge Manager task override timeout. Currently 2 minutes */ + private static final long PURGE_MANAGER_TIMEOUT = 120000; + + /** + * The cluster limit property to be set via Spring with the value defined in + * project.properties + */ + private int clusterLimit = 6; + + /** + * The server limit property to be set via Spring with the value defined in + * project.properties + */ + private int serverLimit = 2; + + /** + * The time in minutes at which a purge job is considered 'dead' or 'hung' + * set via Spring with the value defined in project.properties + */ + private int deadPurgeJobAge = 20; + + /** + * The frequency, in minutes, that a plugin may be purged set via Spring + * with the value defined in project.properties + */ + private int purgeFrequency = 60; + + /** + * How many times a purger is allowed to fail before it is considered fatal. + * Set via Spring with the value defined in project.properties + */ + private int fatalFailureCount = 3; + + /** + * The master switch defined in project.properties that enables and disables + * data purging + */ + private boolean purgeEnabled = true; + + /** Map of purge jobs */ + private Map
+ * SOFTWARE HISTORY + * + * Date Ticket# Engineer Description + * ------------ ---------- ----------- -------------------------- + * 2009 dfriedma Initial version + * 2012-04-30 DR 14908 D. Friedman Require radar name for valid RPS + * file names. + *+ * + */ public class Awips1RpsListUtil { // is 'maint' an opMode?? public static class Selector { @@ -187,7 +201,7 @@ public class Awips1RpsListUtil { } protected static final Pattern selectorPattern = Pattern - .compile("^(?:(.+)\\.)?(.+)\\.VCP(\\d+)(?:\\.(.*))?$"); + .compile("^(.+)\\.(.+)\\.VCP(\\d+)(?:\\.(.*))?$"); protected static final Pattern maintPattern = Pattern .compile("^([^\\.]+)\\.maint(?:\\.(.*))?$"); @@ -197,9 +211,7 @@ public class Awips1RpsListUtil { if (m.matches()) { Selector sel = new Selector(); - if (m.group(1) != null) { - sel.radar = m.group(1).toLowerCase(); - } + sel.radar = m.group(1).toLowerCase(); String opModeString = m.group(2).toLowerCase(); if (opModeString.equals("clear-air")) diff --git a/RadarServer/com.raytheon.rcm.server/src/com/raytheon/rcm/config/awips1/Awips1ConfigProvider.java b/RadarServer/com.raytheon.rcm.server/src/com/raytheon/rcm/config/awips1/Awips1ConfigProvider.java index 5a4003cc80..a77b4cef82 100755 --- a/RadarServer/com.raytheon.rcm.server/src/com/raytheon/rcm/config/awips1/Awips1ConfigProvider.java +++ b/RadarServer/com.raytheon.rcm.server/src/com/raytheon/rcm/config/awips1/Awips1ConfigProvider.java @@ -48,6 +48,15 @@ import com.raytheon.rcm.server.Log; * com.raytheon.rcm.config.awips1.FXA_LOCAL_SITE property. * * Note: Does not recognize the FILE_SERVER_DEFAULT_PATHS environment variable. + * + *
+ * SOFTWARE HISTORY + * + * Date Ticket# Engineer Description + * ------------ ---------- ----------- -------------------------- + * 2009 dfriedma Initial version + * 2012-04-30 DR 14904 D. Friedman Add backup links to dial ORPGs. + **/ public class Awips1ConfigProvider implements ConfigurationProvider { @@ -410,10 +419,8 @@ public class Awips1ConfigProvider implements ConfigurationProvider { String radarName = ls.next().toLowerCase(); int nexradId = ls.nextInt(); - RadarConfig rc = radars.get(radarName.toLowerCase()); //config.getConfigForRadar(radarName); - // so only getting entries for current purpose .. does not - // allow easy switching - if (rc == null || rc.isDedicated() != dedicated) + RadarConfig rc = radars.get(radarName.toLowerCase()); + if (rc == null) continue; if (nexradId != rc.getNexradID()) { // warn... @@ -428,8 +435,6 @@ public class Awips1ConfigProvider implements ConfigurationProvider { lr.setLinkIndex(ls.nextInt()); lr.setTcmPassword(ls.next()); lr.setDedicated(dedicated); - // TODO: do something with max rps size? - // lr.setBackup(backup); if (dedicated) { lr.setMaxRpsListSize(ls.nextInt()); diff --git a/TextDao.java b/TextDao.java new file mode 100644 index 0000000000..069873d95d --- /dev/null +++ b/TextDao.java @@ -0,0 +1,72 @@ +/** + * 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.edex.plugin.text.dao; + +import java.util.Calendar; + +import com.raytheon.edex.db.dao.DefaultPluginDao; +import com.raytheon.edex.textdb.dbapi.impl.TextDB; +import com.raytheon.uf.common.dataplugin.PluginException; +import com.raytheon.uf.edex.database.purge.PurgeLogger; + +/** + * DAO for text products + * + *
+ * + * SOFTWARE HISTORY + * + * Date Ticket# Engineer Description + * ------------ ---------- ----------- -------------------------- + * Jul 10, 2009 2191 rjpeter Update retention time handling. + * Aug 18, 2009 2191 rjpeter Changed to version purging. + *+ * + * @author + * @version 1 + */ +public class TextDao extends DefaultPluginDao { + + public TextDao(String pluginName) throws PluginException { + super(pluginName); + } + + @Override + public void purgeAllData() { + logger.warn("purgeAllPluginData not implemented for text. No data will be purged."); + } + + protected void loadScripts() throws PluginException { + // no op + } + + public void purgeExpiredData() throws PluginException { + int deletedRecords = 0; + + // only do full purge every few hours since incremental purge runs every + // minute + if (Calendar.getInstance().get(Calendar.HOUR_OF_DAY) % 3 == 0) { + TextDB.purgeStdTextProducts(); + } + + PurgeLogger.logInfo("Purged " + deletedRecords + " items total.", + "text"); + } +} diff --git a/after.txt b/after.txt new file mode 100644 index 0000000000..1f9927016d --- /dev/null +++ b/after.txt @@ -0,0 +1,13 @@ +-rw-r--r-- 1 dmsys dmtool 94518 May 17 14:24 cave/com.raytheon.uf.viz.monitor.ffmp/src/com/raytheon/uf/viz/monitor/ffmp/FFMPMonitor.java +-rw-r--r-- 1 dmsys dmtool 7156 May 17 14:24 cave/com.raytheon.uf.viz.monitor.ffmp/src/com/raytheon/uf/viz/monitor/ffmp/ui/dialogs/FFMPTableCellData.java +-rw-r--r-- 1 dmsys dmtool 71285 May 17 14:24 cave/com.raytheon.uf.viz.monitor.ffmp/src/com/raytheon/uf/viz/monitor/ffmp/ui/dialogs/FfmpBasinTableDlg.java +-rw-r--r-- 1 dmsys dmtool 9851 May 17 14:24 cave/com.raytheon.uf.viz.monitor.ffmp/src/com/raytheon/uf/viz/monitor/ffmp/ui/rsc/FFMPColorUtils.java +-rw-r--r-- 1 dmsys dmtool 40157 May 17 14:24 cave/com.raytheon.uf.viz.monitor.ffmp/src/com/raytheon/uf/viz/monitor/ffmp/ui/rsc/FFMPDataGenerator.java +-rw-r--r-- 1 dmsys dmtool 18611 May 17 14:24 cave/com.raytheon.uf.viz.monitor.ffmp/src/com/raytheon/uf/viz/monitor/ffmp/ui/rsc/FFMPDataLoader.java +-rw-r--r-- 1 dmsys dmtool 147202 May 17 14:24 cave/com.raytheon.uf.viz.monitor.ffmp/src/com/raytheon/uf/viz/monitor/ffmp/ui/rsc/FFMPResource.java +-rw-r--r-- 1 dmsys dmtool 14664 May 17 14:24 edexOsgi/com.raytheon.uf.common.dataplugin.ffmp/src/com/raytheon/uf/common/dataplugin/ffmp/FFMPDataContainer.java +-rw-r--r-- 1 dmsys dmtool 26923 May 17 14:24 edexOsgi/com.raytheon.uf.common.dataplugin.ffmp/src/com/raytheon/uf/common/dataplugin/ffmp/FFMPRecord.java +-rw-r--r-- 1 dmsys dmtool 61981 May 17 14:24 edexOsgi/com.raytheon.uf.common.monitor/src/com/raytheon/uf/common/monitor/scan/ScanUtils.java +-rw-r--r-- 1 dmsys dmtool 17730 May 17 14:24 edexOsgi/com.raytheon.uf.edex.plugin.ffmp/src/com/raytheon/uf/edex/plugin/ffmp/FFMPURIFilter.java +-rw-r--r-- 1 dmsys dmtool 65982 May 17 14:24 edexOsgi/com.raytheon.uf.edex.plugin.ffmp/src/com/raytheon/uf/edex/plugin/ffmp/common/FFMPProcessor.java +-rw-r--r-- 1 dmsys dmtool 36163 May 17 14:24 edexOsgi/com.raytheon.uf.edex.plugin.ffmp/src/com/raytheon/uf/edex/plugin/ffmp/common/FFTI.java diff --git a/after_purge.out b/after_purge.out new file mode 100644 index 0000000000..1256a29121 --- /dev/null +++ b/after_purge.out @@ -0,0 +1,5 @@ +-rw-r--r-- 1 dmsys dmtool 24661 May 24 17:52 edexOsgi/com.raytheon.edex.plugin.grib/src/com/raytheon/edex/plugin/grib/spatial/GribSpatialCache.java +-rw-r--r-- 1 dmsys dmtool 2197 May 24 17:52 edexOsgi/com.raytheon.edex.plugin.text/src/com/raytheon/edex/plugin/text/dao/TextDao.java +-rw-r--r-- 1 dmsys dmtool 9250 May 24 17:53 edexOsgi/com.raytheon.uf.edex.purgesrv/src/com/raytheon/uf/edex/purgesrv/PurgeDao.java +-rw-r--r-- 1 dmsys dmtool 9574 May 24 17:53 edexOsgi/com.raytheon.uf.edex.purgesrv/src/com/raytheon/uf/edex/purgesrv/PurgeJob.java +-rw-r--r-- 1 dmsys dmtool 15681 May 24 17:53 edexOsgi/com.raytheon.uf.edex.purgesrv/src/com/raytheon/uf/edex/purgesrv/PurgeManager.java diff --git a/before.txt b/before.txt new file mode 100644 index 0000000000..31b3c9450e --- /dev/null +++ b/before.txt @@ -0,0 +1,13 @@ +-rw-r--r-- 1 dmsys dmtool 95993 May 10 11:41 cave/com.raytheon.uf.viz.monitor.ffmp/src/com/raytheon/uf/viz/monitor/ffmp/FFMPMonitor.java +-r--r--r-- 1 dmsys dmtool 7016 Nov 10 2011 cave/com.raytheon.uf.viz.monitor.ffmp/src/com/raytheon/uf/viz/monitor/ffmp/ui/dialogs/FFMPTableCellData.java +-rw-r--r-- 1 dmsys dmtool 71722 May 10 11:41 cave/com.raytheon.uf.viz.monitor.ffmp/src/com/raytheon/uf/viz/monitor/ffmp/ui/dialogs/FfmpBasinTableDlg.java +-r--r--r-- 1 dmsys dmtool 10752 Dec 7 15:05 cave/com.raytheon.uf.viz.monitor.ffmp/src/com/raytheon/uf/viz/monitor/ffmp/ui/rsc/FFMPColorUtils.java +-rw-r--r-- 1 dmsys dmtool 40273 May 10 11:41 cave/com.raytheon.uf.viz.monitor.ffmp/src/com/raytheon/uf/viz/monitor/ffmp/ui/rsc/FFMPDataGenerator.java +-r--r--r-- 1 dmsys dmtool 19531 Jan 31 07:54 cave/com.raytheon.uf.viz.monitor.ffmp/src/com/raytheon/uf/viz/monitor/ffmp/ui/rsc/FFMPDataLoader.java +-rw-r--r-- 1 dmsys dmtool 147364 May 10 11:41 cave/com.raytheon.uf.viz.monitor.ffmp/src/com/raytheon/uf/viz/monitor/ffmp/ui/rsc/FFMPResource.java +-rw-r--r-- 1 dmsys dmtool 15108 May 10 11:41 edexOsgi/com.raytheon.uf.common.dataplugin.ffmp/src/com/raytheon/uf/common/dataplugin/ffmp/FFMPDataContainer.java +-r--r--r-- 1 dmsys dmtool 27099 Apr 16 08:06 edexOsgi/com.raytheon.uf.common.dataplugin.ffmp/src/com/raytheon/uf/common/dataplugin/ffmp/FFMPRecord.java +-r--r--r-- 1 dmsys dmtool 61329 Feb 24 14:37 edexOsgi/com.raytheon.uf.common.monitor/src/com/raytheon/uf/common/monitor/scan/ScanUtils.java +-r--r--r-- 1 dmsys dmtool 21327 Apr 18 12:03 edexOsgi/com.raytheon.uf.edex.plugin.ffmp/src/com/raytheon/uf/edex/plugin/ffmp/FFMPURIFilter.java +-rw-r--r-- 1 dmsys dmtool 65837 May 7 10:47 edexOsgi/com.raytheon.uf.edex.plugin.ffmp/src/com/raytheon/uf/edex/plugin/ffmp/common/FFMPProcessor.java +-rw-r--r-- 1 dmsys dmtool 36591 May 10 11:41 edexOsgi/com.raytheon.uf.edex.plugin.ffmp/src/com/raytheon/uf/edex/plugin/ffmp/common/FFTI.java diff --git a/before_purge.out b/before_purge.out new file mode 100644 index 0000000000..8563dd00e2 --- /dev/null +++ b/before_purge.out @@ -0,0 +1,5 @@ +-rw-r--r-- 1 dmsys dmtool 23911 May 10 11:41 edexOsgi/com.raytheon.edex.plugin.grib/src/com/raytheon/edex/plugin/grib/spatial/GribSpatialCache.java +-r--r--r-- 1 dmsys dmtool 2000 Jun 15 2011 edexOsgi/com.raytheon.edex.plugin.text/src/com/raytheon/edex/plugin/text/dao/TextDao.java +-rw-r--r-- 1 dmsys dmtool 9022 May 10 11:41 edexOsgi/com.raytheon.uf.edex.purgesrv/src/com/raytheon/uf/edex/purgesrv/PurgeDao.java +-rw-r--r-- 1 dmsys dmtool 9090 May 10 11:41 edexOsgi/com.raytheon.uf.edex.purgesrv/src/com/raytheon/uf/edex/purgesrv/PurgeJob.java +-rw-r--r-- 1 dmsys dmtool 15020 May 10 11:41 edexOsgi/com.raytheon.uf.edex.purgesrv/src/com/raytheon/uf/edex/purgesrv/PurgeManager.java diff --git a/cave/build/cave/memorySettings.xml b/cave/build/cave/memorySettings.xml index 3f1b79fe5e..711e74b738 100644 --- a/cave/build/cave/memorySettings.xml +++ b/cave/build/cave/memorySettings.xml @@ -30,7 +30,7 @@
time
+ flux
+ * SOFTWARE HISTORY * Date Ticket# Engineer Description * ------------ ---------- ----------- -------------------------- * 29 June, 2009 2521 dhladky Initial creation * 11 Apr. 2012 DR 14522 gzhang Fixing invalid thread error. - * 16 Apr. 2012 DR 14511 gzhang Handling NullPointer in getGraphData() ** @author dhladky * @version 1.0 @@ -207,7 +207,7 @@ public class FFMPResource extends private IShadedShape streamShadedShape = null; /** always the same vertexes, one for each CWA **/ - private FFMPShapeContainer shadedShapes = new FFMPShapeContainer(); + private FFMPShapeContainer shadedShapes = new FFMPShapeContainer(); /** Basin shaded shape **/ protected ConcurrentHashMap
+ * SOFTWARE HISTORY + * Date Ticket# Engineer Description + * ------------ ---------- ----------- -------------------------- + * 22 April, 2012 2521 dhladky Initial creation + *+ * + * @author dhladky + * @version 1.0 + */ + + +public class FFMPTime { + + public double time = 0.0; + public boolean split = false; + + public FFMPTime(double time, boolean split) { + this.time = time; + this.split = split; + } + + public double getTime() { + return time; + } + + public boolean isSplit() { + return split; + } + +} + diff --git a/cave/com.raytheon.uf.viz.monitor.fog/src/com/raytheon/uf/viz/monitor/fog/FogMonitor.java b/cave/com.raytheon.uf.viz.monitor.fog/src/com/raytheon/uf/viz/monitor/fog/FogMonitor.java index 99b14c299a..c9f8cc9aa3 100644 --- a/cave/com.raytheon.uf.viz.monitor.fog/src/com/raytheon/uf/viz/monitor/fog/FogMonitor.java +++ b/cave/com.raytheon.uf.viz.monitor.fog/src/com/raytheon/uf/viz/monitor/fog/FogMonitor.java @@ -77,6 +77,8 @@ import com.vividsolutions.jts.geom.Geometry; * 3/2/2009 2047 grichard Added stationName array. * 10/7/2009 **** dhladky reworked * 11/30/2009 3424 Zhidong/Slav/Wen Adds stationTableData to keep station info. + * May 15, 2012 14510 zhao Modified processing at startup + * * * * @author dhladky @@ -157,7 +159,8 @@ public class FogMonitor extends ObsMonitor implements IFogResourceListener { monitor.createDataStructures(); monitor.getAdjAreas(); monitor.processProductAtStartup("fog"); - } + monitor.fireMonitorEvent(monitor); + } return monitor; } @@ -585,4 +588,12 @@ public class FogMonitor extends ObsMonitor implements IFogResourceListener { this.geoAdjAreas = geoAdjAreas; } + @Override + protected void processAtStartup(ObReport report) { + obData.addReport(report); + String zone = findZone(report.getPlatformId()); + getTableData().getArea(zone).addReport(report.getObservationTime(), + report); + } + } diff --git a/cave/com.raytheon.uf.viz.monitor.safeseas/src/com/raytheon/uf/viz/monitor/safeseas/SafeSeasMonitor.java b/cave/com.raytheon.uf.viz.monitor.safeseas/src/com/raytheon/uf/viz/monitor/safeseas/SafeSeasMonitor.java index 98313c4435..d50b2eab0a 100644 --- a/cave/com.raytheon.uf.viz.monitor.safeseas/src/com/raytheon/uf/viz/monitor/safeseas/SafeSeasMonitor.java +++ b/cave/com.raytheon.uf.viz.monitor.safeseas/src/com/raytheon/uf/viz/monitor/safeseas/SafeSeasMonitor.java @@ -77,6 +77,7 @@ import com.vividsolutions.jts.geom.Geometry; * 11/30/2009 3424 Zhidong/Slav/wkwock Use real station data. * Dec 30, 2009 3424 zhao use ObMultiHrsReports for obs data archive over time * July 20,2010 4891 skorolev Added resource listener + * May 15, 2012 14510 zhao Modified processing at startup * * * @@ -157,6 +158,7 @@ public class SafeSeasMonitor extends ObsMonitor implements ISSResourceListener { monitor.createDataStructures(); monitor.getAdjAreas(); monitor.processProductAtStartup("ss"); + monitor.fireMonitorEvent(monitor); } return monitor; } @@ -529,4 +531,9 @@ public class SafeSeasMonitor extends ObsMonitor implements ISSResourceListener { } + @Override + protected void processAtStartup(ObReport report) { + obData.addReport(report); + } + } diff --git a/cave/com.raytheon.uf.viz.monitor.snow/src/com/raytheon/uf/viz/monitor/snow/SnowMonitor.java b/cave/com.raytheon.uf.viz.monitor.snow/src/com/raytheon/uf/viz/monitor/snow/SnowMonitor.java index 45c18bc4d5..450ec979de 100644 --- a/cave/com.raytheon.uf.viz.monitor.snow/src/com/raytheon/uf/viz/monitor/snow/SnowMonitor.java +++ b/cave/com.raytheon.uf.viz.monitor.snow/src/com/raytheon/uf/viz/monitor/snow/SnowMonitor.java @@ -66,6 +66,7 @@ import com.raytheon.viz.alerts.observers.ProductAlertObserver; * Dec 18, 2009 3424 zhao use ObMultiHrsReports for obs data archive over time * Dec 22, 2009 3424 zhao revised processProductAtStartup method to retrieve all data * July 20,2010 4891 skorolev Added resource listener + * May 15, 2012 14510 zhao Modified processing at startup * * * @@ -131,12 +132,13 @@ public class SnowMonitor extends ObsMonitor { obData = new ObMultiHrsReports(CommonConfig.AppName.SNOW); obData.setThresholdMgr(SnowThresholdMgr.getInstance()); // Pre-populate dialog with an observation (METAR) for KOMA - processProductAtStartup("snow"); - } + } public static synchronized SnowMonitor getInstance() { if (monitor == null) { monitor = new SnowMonitor(); + monitor.processProductAtStartup("snow"); + monitor.fireMonitorEvent(monitor); } return monitor; } @@ -382,4 +384,9 @@ public class SnowMonitor extends ObsMonitor { public void setZoneDialog(SnowZoneTableDlg zoneDialog) { this.zoneDialog = zoneDialog; } + + @Override + protected void processAtStartup(ObReport report) { + obData.addReport(report); + } } diff --git a/cave/com.raytheon.uf.viz.monitor/src/com/raytheon/uf/viz/monitor/GenerateFSSObReport.java b/cave/com.raytheon.uf.viz.monitor/src/com/raytheon/uf/viz/monitor/GenerateFSSObReport.java index 61a51ff097..186cdafd5d 100644 --- a/cave/com.raytheon.uf.viz.monitor/src/com/raytheon/uf/viz/monitor/GenerateFSSObReport.java +++ b/cave/com.raytheon.uf.viz.monitor/src/com/raytheon/uf/viz/monitor/GenerateFSSObReport.java @@ -10,7 +10,12 @@ import com.raytheon.uf.common.monitor.data.ObConst.ReportType; import com.raytheon.uf.viz.monitor.data.ObReport; /** - * @author skorolev + * @author skorolev (initial creation) + * + * Change history: + * Date Ticket # Engineer Description + * --------------------------------------------------- + * May 15, 2012 14510 zhao Modified generateObReport() * */ public class GenerateFSSObReport { @@ -28,8 +33,13 @@ public class GenerateFSSObReport { // Generate the observation report. ObReport obReport = new ObReport(); FSSObsRecord metar = (FSSObsRecord) report; - obReport.setObservationTime(metar.getTimeObs().getTime()); - obReport.setRefHour(metar.getRefHour().getTime()); + try { + obReport.setObservationTime(metar.getTimeObs().getTime()); + obReport.setRefHour(metar.getRefHour().getTime()); + } catch (Exception e) { + System.out.println("Warning: missing obsTime or refHour at getTimeObs() when processing obs data; " + e + "; trying to set obsTime and refHour from dataURI"); + obReport.setTimesFromFssobDataURI(report.getDataURI()); + } obReport.setPlatformId(metar.getPlatformId()); obReport.setStationary(true); obReport.setLatitude((float) metar.getLatitude()); diff --git a/cave/com.raytheon.uf.viz.monitor/src/com/raytheon/uf/viz/monitor/ObsMonitor.java b/cave/com.raytheon.uf.viz.monitor/src/com/raytheon/uf/viz/monitor/ObsMonitor.java index 14a57f9295..ab54e7aa90 100644 --- a/cave/com.raytheon.uf.viz.monitor/src/com/raytheon/uf/viz/monitor/ObsMonitor.java +++ b/cave/com.raytheon.uf.viz.monitor/src/com/raytheon/uf/viz/monitor/ObsMonitor.java @@ -29,9 +29,6 @@ import org.eclipse.swt.widgets.Display; import com.raytheon.uf.common.dataplugin.PluginDataObject; import com.raytheon.uf.common.dataplugin.fssobs.FSSObsRecord; import com.raytheon.uf.common.dataquery.requests.RequestConstraint; -import com.raytheon.uf.common.status.IUFStatusHandler; -import com.raytheon.uf.common.status.UFStatus; -import com.raytheon.uf.common.status.UFStatus.Priority; import com.raytheon.uf.common.time.DataTime; import com.raytheon.uf.viz.core.alerts.AlertMessage; import com.raytheon.uf.viz.core.catalog.LayerProperty; @@ -54,6 +51,7 @@ import com.raytheon.uf.viz.monitor.events.IMonitorThresholdEvent; * Date Ticket# Engineer Description * ------------ ---------- ----------- -------------------------- * Feb 25, 2010 4759 dhladky Initial creation. + * Mar 15, 2012 14510 zhao modified processProductAtStartup() * * * @@ -63,8 +61,6 @@ import com.raytheon.uf.viz.monitor.events.IMonitorThresholdEvent; */ public abstract class ObsMonitor extends Monitor { - private static final IUFStatusHandler statusHandler = UFStatus.getHandler( - ObsMonitor.class, "ObsMonitor"); @Override protected abstract boolean filterNotifyMessage(NotificationMessage alertMessage); @@ -90,6 +86,8 @@ public abstract class ObsMonitor extends Monitor { */ protected abstract void process(ObReport result) throws Exception; + + protected abstract void processAtStartup(ObReport report); @Override protected abstract void processNotifyMessage(NotificationMessage filtered); @@ -246,30 +244,19 @@ public abstract class ObsMonitor extends Monitor { final Object[] resp = Connector.getInstance().connect(script, null, 60000); - System.out.println("ObsMonitor: Retriving data for monitor: " - + monitorUse); + System.out.println("ObsMonitor: Retriving data for monitor: " + monitorUse); if ((resp != null) && (resp.length > 0)) { - Display.getDefault().syncExec(new Runnable() { - public void run() { + //Display.getDefault().syncExec(new Runnable() { + //public void run() { for (int j = 0; j < resp.length; j++) { PluginDataObject objectToSend = (PluginDataObject) resp[j]; - // ObReport obReport = new ObReport(); - // obReport.init(); - ObReport result = GenerateFSSObReport - .generateObReport(objectToSend); - try { - process(result); - } catch (Exception e) { - // TODO Auto-generated catch block. Please - // revise as appropriate. - statusHandler.handle(Priority.PROBLEM, - e.getLocalizedMessage(), e); - } + ObReport result = GenerateFSSObReport.generateObReport(objectToSend); + processAtStartup(result); } - } + //} - }); + //}); } else if (resp == null) { System.out diff --git a/cave/com.raytheon.uf.viz.monitor/src/com/raytheon/uf/viz/monitor/data/AreaContainer.java b/cave/com.raytheon.uf.viz.monitor/src/com/raytheon/uf/viz/monitor/data/AreaContainer.java index 39952c777d..f34434621b 100644 --- a/cave/com.raytheon.uf.viz.monitor/src/com/raytheon/uf/viz/monitor/data/AreaContainer.java +++ b/cave/com.raytheon.uf.viz.monitor/src/com/raytheon/uf/viz/monitor/data/AreaContainer.java @@ -113,7 +113,6 @@ public class AreaContainer { if (report == null) { report = new ObReport(); - report.init(); } return report; diff --git a/cave/com.raytheon.uf.viz.monitor/src/com/raytheon/uf/viz/monitor/data/ObReport.java b/cave/com.raytheon.uf.viz.monitor/src/com/raytheon/uf/viz/monitor/data/ObReport.java index 02279c4a85..25f637af10 100644 --- a/cave/com.raytheon.uf.viz.monitor/src/com/raytheon/uf/viz/monitor/data/ObReport.java +++ b/cave/com.raytheon.uf.viz.monitor/src/com/raytheon/uf/viz/monitor/data/ObReport.java @@ -19,6 +19,7 @@ **/ package com.raytheon.uf.viz.monitor.data; +import java.text.SimpleDateFormat; import java.util.Calendar; import java.util.Date; import java.util.TimeZone; @@ -41,6 +42,7 @@ import com.raytheon.uf.common.time.SimulatedTime; * Feb 12, 2009 1999 grichard Initial creation. * Dec 9, 2009 3424 zhao Added member waveHeight and method get(varName) * Jan 22, 2010 3888 zhao Removed member waveHeight, which is the same as highResWaveHeight + * May 15, 2012 14510 zhao added setTimesFromFssobsDataURI() * * * @@ -175,11 +177,11 @@ public class ObReport { // Public constructor public ObReport() { - + init(); } // Initializer of report - public void init() { + private void init() { Date now = SimulatedTime.getSystemTime().getTime(); Calendar deltaTime = Calendar.getInstance(TimeZone.getTimeZone("UTC")); @@ -694,5 +696,22 @@ public class ObReport { public void setSeaLevelPress(float seaLevelPress) { this.seaLevelPress = seaLevelPress; } - +/** + * When obs time is missing; set obs time and ref time from fssobs dataURI + * Format of fssobs dataURI: + * /fssobs/2012-05-14_16:35:00.0/METAR/OAX/KSDA/40.75/-95.41999816894531/ss + */ + public void setTimesFromFssobDataURI(String dataURI) { + String str = dataURI.substring(8, 24); + SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd'_'hh:mm"); + try { + Date obsTime = df.parse(str); + Date refTime = TableUtil.getNominalTime(obsTime); + this.observationTime = obsTime; + this.refHour = refTime; + } catch (java.text.ParseException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } } diff --git a/cave/com.raytheon.uf.viz.monitor/src/com/raytheon/uf/viz/monitor/data/ObStnHourReports.java b/cave/com.raytheon.uf.viz.monitor/src/com/raytheon/uf/viz/monitor/data/ObStnHourReports.java index 2287568ad3..e2a057dc3a 100644 --- a/cave/com.raytheon.uf.viz.monitor/src/com/raytheon/uf/viz/monitor/data/ObStnHourReports.java +++ b/cave/com.raytheon.uf.viz.monitor/src/com/raytheon/uf/viz/monitor/data/ObStnHourReports.java @@ -87,7 +87,6 @@ public class ObStnHourReports { ObReport report = null; if ( stnReports.isEmpty() ) { // empty report for empty/default row in station table report = new ObReport(); - report.init(); } else { report = stnReports.get(stnReports.lastKey()); } diff --git a/cave/com.raytheon.uf.viz.monitor/src/com/raytheon/uf/viz/monitor/data/ObZoneHourReports.java b/cave/com.raytheon.uf.viz.monitor/src/com/raytheon/uf/viz/monitor/data/ObZoneHourReports.java index 877ca33c92..0bd541647a 100644 --- a/cave/com.raytheon.uf.viz.monitor/src/com/raytheon/uf/viz/monitor/data/ObZoneHourReports.java +++ b/cave/com.raytheon.uf.viz.monitor/src/com/raytheon/uf/viz/monitor/data/ObZoneHourReports.java @@ -91,7 +91,6 @@ public class ObZoneHourReports { private void InitWorstValues() { worstValues = new ObReport(); - worstValues.init(); worstValues.setZoneId(zone); // the ObReport's init() sets "zone id" to "" !!! } diff --git a/cave/com.raytheon.uf.viz.ncep.displays.feature/feature.xml b/cave/com.raytheon.uf.viz.ncep.displays.feature/feature.xml index a80cc9b566..32717cd93c 100644 --- a/cave/com.raytheon.uf.viz.ncep.displays.feature/feature.xml +++ b/cave/com.raytheon.uf.viz.ncep.displays.feature/feature.xml @@ -312,4 +312,25 @@ version="0.0.0" unpack="false"/> +
- * - * SOFTWARE HISTORY - * - * Date Ticket# Engineer Description - * ------------ ---------- ----------- -------------------------- - * Dec 6, 2011 mschenke Initial creation - * - *- * - * @author mschenke - * @version 1.0 - */ - -public class VIIRSProductBrowserDefinition extends - AbstractRequestableProductBrowserDataDefinition
- * - * SOFTWARE HISTORY - * - * Date Ticket# Engineer Description - * ------------ ---------- ----------- -------------------------- - * Nov 30, 2011 mschenke Initial creation - * - *- * - * @author mschenke - * @version 1.0 - */ - -public class VIIRSDataCallback implements IColorMapDataRetrievalCallback { - - private VIIRSDataRecord dataRecord; - - private Rectangle validDataBounds; - - public VIIRSDataCallback(VIIRSDataRecord dataRecord, - Rectangle validDataBounds) { - this.dataRecord = dataRecord; - this.validDataBounds = validDataBounds; - } - - /* - * (non-Javadoc) - * - * @see - * com.raytheon.uf.viz.core.data.IColorMapDataRetrievalCallback#getColorMapData - * () - */ - @Override - public ColorMapData getColorMapData() throws VizException { - try { - int[] sizes = new int[] { validDataBounds.width, - validDataBounds.height }; - IDataStore dataStore = DataStoreFactory.getDataStore(HDF5Util - .findHDF5Location(dataRecord)); - IDataRecord rawData = dataStore.retrieve(dataRecord.getDataURI(), - VIIRSDataRecord.getDataSet(0), - Request.buildSlab(new int[] { 0, 0 }, sizes)); - - Buffer shortData = ShortBuffer.wrap(((ShortDataRecord) rawData) - .getShortData()); - return new ColorMapData(shortData, sizes, - ColorMapDataType.UNSIGNED_SHORT); - } catch (Throwable t) { - throw new VizException(t); - } - } - - /* - * (non-Javadoc) - * - * @see java.lang.Object#hashCode() - */ - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result - + ((dataRecord == null) ? 0 : dataRecord.hashCode()); - result = prime * result - + ((validDataBounds == null) ? 0 : validDataBounds.hashCode()); - return result; - } - - /* - * (non-Javadoc) - * - * @see java.lang.Object#equals(java.lang.Object) - */ - @Override - public boolean equals(Object obj) { - if (this == obj) - return true; - if (obj == null) - return false; - if (getClass() != obj.getClass()) - return false; - VIIRSDataCallback other = (VIIRSDataCallback) obj; - if (dataRecord == null) { - if (other.dataRecord != null) - return false; - } else if (!dataRecord.equals(other.dataRecord)) - return false; - if (validDataBounds == null) { - if (other.validDataBounds != null) - return false; - } else if (!validDataBounds.equals(other.validDataBounds)) - return false; - return true; - } - -} diff --git a/cave/com.raytheon.uf.viz.npp.viirs/src/com/raytheon/uf/viz/npp/viirs/rsc/VIIRSDataMathTransform.java b/cave/com.raytheon.uf.viz.npp.viirs/src/com/raytheon/uf/viz/npp/viirs/rsc/VIIRSDataMathTransform.java deleted file mode 100644 index b26db0540c..0000000000 --- a/cave/com.raytheon.uf.viz.npp.viirs/src/com/raytheon/uf/viz/npp/viirs/rsc/VIIRSDataMathTransform.java +++ /dev/null @@ -1,300 +0,0 @@ -/** - * 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.uf.viz.npp.viirs.rsc; - -import org.opengis.geometry.DirectPosition; -import org.opengis.geometry.MismatchedDimensionException; -import org.opengis.referencing.operation.MathTransform; -import org.opengis.referencing.operation.Matrix; -import org.opengis.referencing.operation.NoninvertibleTransformException; -import org.opengis.referencing.operation.TransformException; - -import com.vividsolutions.jts.geom.Coordinate; -import com.vividsolutions.jts.geom.LineSegment; - -/** - * TODO Add Description - * - *
- * - * SOFTWARE HISTORY - * - * Date Ticket# Engineer Description - * ------------ ---------- ----------- -------------------------- - * Nov 30, 2011 mschenke Initial creation - * - *- * - * @author mschenke - * @version 1.0 - */ - -public class VIIRSDataMathTransform implements MathTransform { - - private float[] latitudes; - - private float[] longitudes; - - private int width, height; - - public VIIRSDataMathTransform(float[][] projectionData, int width, - int height) { - this.longitudes = projectionData[0]; - this.latitudes = projectionData[1]; - this.height = height; - this.width = width; - } - - /* - * (non-Javadoc) - * - * @see - * org.opengis.referencing.operation.MathTransform#derivative(org.opengis - * .geometry.DirectPosition) - */ - @Override - public Matrix derivative(DirectPosition arg0) - throws MismatchedDimensionException, TransformException { - return null; - } - - /* - * (non-Javadoc) - * - * @see - * org.opengis.referencing.operation.MathTransform#getSourceDimensions() - */ - @Override - public int getSourceDimensions() { - return 0; - } - - /* - * (non-Javadoc) - * - * @see - * org.opengis.referencing.operation.MathTransform#getTargetDimensions() - */ - @Override - public int getTargetDimensions() { - return 0; - } - - /* - * (non-Javadoc) - * - * @see org.opengis.referencing.operation.MathTransform#inverse() - */ - @Override - public MathTransform inverse() throws NoninvertibleTransformException { - return null; - } - - /* - * (non-Javadoc) - * - * @see org.opengis.referencing.operation.MathTransform#isIdentity() - */ - @Override - public boolean isIdentity() { - return false; - } - - /* - * (non-Javadoc) - * - * @see org.opengis.referencing.operation.MathTransform#toWKT() - */ - @Override - public String toWKT() throws UnsupportedOperationException { - System.out.println("toWKT?"); - return null; - } - - /* - * (non-Javadoc) - * - * @see - * org.opengis.referencing.operation.MathTransform#transform(org.opengis - * .geometry.DirectPosition, org.opengis.geometry.DirectPosition) - */ - @Override - public DirectPosition transform(DirectPosition arg0, DirectPosition arg1) - throws MismatchedDimensionException, TransformException { - System.out.println("transform a bunch of DirectPositions?"); - return null; - } - - /* - * (non-Javadoc) - * - * @see org.opengis.referencing.operation.MathTransform#transform(double[], - * int, double[], int, int) - */ - @Override - public void transform(double[] in, int inOffset, double[] out, - int outOffset, int numPoints) throws TransformException { - for (int i = 0; i < numPoints; ++i) { - int xIdx = (i * 2); - int yIdx = (i * 2) + 1; - - double xLoc = in[xIdx] - 0.5; - // TODO: Why is data flipped along "y" axis? - double yLoc = height - in[yIdx] - 0.5; - out[xIdx] = getInterpolatedValue(xLoc, yLoc, 0); - out[yIdx] = getInterpolatedValue(xLoc, yLoc, 1); - } - } - - /* - * (non-Javadoc) - * - * @see org.opengis.referencing.operation.MathTransform#transform(float[], - * int, float[], int, int) - */ - @Override - public void transform(float[] arg0, int arg1, float[] arg2, int arg3, - int arg4) throws TransformException { - } - - /* - * (non-Javadoc) - * - * @see org.opengis.referencing.operation.MathTransform#transform(float[], - * int, double[], int, int) - */ - @Override - public void transform(float[] arg0, int arg1, double[] arg2, int arg3, - int arg4) throws TransformException { - } - - /* - * (non-Javadoc) - * - * @see org.opengis.referencing.operation.MathTransform#transform(double[], - * int, float[], int, int) - */ - @Override - public void transform(double[] arg0, int arg1, float[] arg2, int arg3, - int arg4) throws TransformException { - } - - protected float getInterpolatedValue(double xd, double yd, int dim) { - float value = 0.0f; - float missing = 1.0f; - - float x = (float) xd; - float y = (float) yd; - - int xi = (int) x; - int yi = (int) y; - // Upper left corner - float xWeight = 1 - x + xi; - float yWeight = 1 - y + yi; - float weight = xWeight * yWeight; - float val = getRawDataValue(xi, yi, dim); - if (Float.isNaN(val)) { - missing -= weight; - } else { - value += weight * val; - } - // upper right corner - xi = xi + 1; - xWeight = 1 - xi + x; - yWeight = 1 - y + yi; - weight = xWeight * yWeight; - val = getRawDataValue(xi, yi, dim); - if (Float.isNaN(val)) { - missing -= weight; - } else { - value += weight * val; - } - // lower right corner - yi = yi + 1; - xWeight = 1 - xi + x; - yWeight = 1 - yi + y; - weight = xWeight * yWeight; - val = getRawDataValue(xi, yi, dim); - if (Float.isNaN(val)) { - missing -= weight; - } else { - value += weight * val; - } - // lower left corner - xi = xi - 1; - xWeight = 1 - x + xi; - yWeight = 1 - yi + y; - weight = xWeight * yWeight; - val = getRawDataValue(xi, yi, dim); - if (Float.isNaN(val)) { - missing -= weight; - } else { - value += weight * val; - } - - return value / missing; - } - - /** - * @param xi - * @param yi - * @param dim - * @return - */ - private float getRawDataValue(int xi, int yi, int dim) { - Coordinate c = null; - if (xi >= 0 && xi < width && yi >= 0 && yi < height) { - c = index(xi, yi); - } else { - int xInc = 0; - int closestX = xi; - if (closestX < 0) { - closestX = 0; - xInc = 1; - } else if (closestX >= width) { - closestX = width - 1; - xInc = -1; - } - - int yInc = 0; - int closestY = yi; - if (closestY < 0) { - closestY = 0; - yInc = 1; - } else if (closestY >= height) { - closestY = height - 1; - yInc = -1; - } - - Coordinate a = index(closestX, closestY); - Coordinate b = index(closestX + xInc, closestY + yInc); - LineSegment ls = new LineSegment(a, b); - int xDiff = closestX - xi; - int yDiff = closestY - yi; - c = ls.pointAlong(-Math.sqrt(xDiff * xDiff + yDiff * yDiff)); - } - return (float) (dim == 0 ? c.x : c.y); - } - - private Coordinate index(int xi, int yi) { - return new Coordinate(longitudes[yi * width + xi], latitudes[yi * width - + xi]); - } -} \ No newline at end of file diff --git a/cave/com.raytheon.uf.viz.npp.viirs/src/com/raytheon/uf/viz/npp/viirs/rsc/VIIRSResource.java b/cave/com.raytheon.uf.viz.npp.viirs/src/com/raytheon/uf/viz/npp/viirs/rsc/VIIRSResource.java deleted file mode 100644 index 745f942f11..0000000000 --- a/cave/com.raytheon.uf.viz.npp.viirs/src/com/raytheon/uf/viz/npp/viirs/rsc/VIIRSResource.java +++ /dev/null @@ -1,445 +0,0 @@ -/** - * 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.uf.viz.npp.viirs.rsc; - -import java.awt.Point; -import java.awt.Rectangle; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import javax.measure.unit.Unit; - -import com.raytheon.uf.common.dataplugin.annotations.DataURI; -import com.raytheon.uf.common.dataplugin.npp.viirs.VIIRSDataRecord; -import com.raytheon.uf.common.dataplugin.npp.viirs.VIIRSSpatialRecord; -import com.raytheon.uf.common.datastorage.DataStoreFactory; -import com.raytheon.uf.common.datastorage.IDataStore; -import com.raytheon.uf.common.datastorage.Request; -import com.raytheon.uf.common.datastorage.records.FloatDataRecord; -import com.raytheon.uf.common.datastorage.records.IDataRecord; -import com.raytheon.uf.common.status.IUFStatusHandler; -import com.raytheon.uf.common.status.UFStatus; -import com.raytheon.uf.common.status.UFStatus.Priority; -import com.raytheon.uf.common.time.BinOffset; -import com.raytheon.uf.common.time.DataTime; -import com.raytheon.uf.viz.core.DrawableImage; -import com.raytheon.uf.viz.core.HDF5Util; -import com.raytheon.uf.viz.core.IGraphicsTarget; -import com.raytheon.uf.viz.core.IGraphicsTarget.RasterMode; -import com.raytheon.uf.viz.core.drawables.ColorMapLoader; -import com.raytheon.uf.viz.core.drawables.ColorMapParameters; -import com.raytheon.uf.viz.core.drawables.IImage; -import com.raytheon.uf.viz.core.drawables.PaintProperties; -import com.raytheon.uf.viz.core.drawables.ext.colormap.IColormappedImageExtension; -import com.raytheon.uf.viz.core.exception.VizException; -import com.raytheon.uf.viz.core.map.IMapDescriptor; -import com.raytheon.uf.viz.core.rsc.AbstractVizResource; -import com.raytheon.uf.viz.core.rsc.IResourceDataChanged; -import com.raytheon.uf.viz.core.rsc.LoadProperties; -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.hdf5.ImageTile; - -/** - * NPP VIIRS resource. Responsible for drawing a single color band - * - *
- * - * SOFTWARE HISTORY - * - * Date Ticket# Engineer Description - * ------------ ---------- ----------- -------------------------- - * Nov 30, 2011 mschenke Initial creation - * - *- * - * @author mschenke - * @version 1.0 - */ - -public class VIIRSResource extends - AbstractVizResource