Merge remote-tracking branch 'omaha/omaha_16.1.1.1' into master_16.1.2
Conflicts: cave/com.raytheon.viz.mpe.ui/src/com/raytheon/viz/mpe/ui/rsc/MPEFieldResource.java Change-Id: I2e27575f864da841a07ca019a12819e0fcb16ced Former-commit-id: 4b93303cd64cdae241f4dfc02fbdc3ab8a2c31f2
This commit is contained in:
commit
fad499c581
35 changed files with 1643 additions and 1086 deletions
|
@ -185,7 +185,7 @@
|
|||
isTopOfTheHour="false">
|
||||
<binOffset posOffset="1800" negOffset="1800"
|
||||
virtualOffset="0" />
|
||||
<metadataMap>
|
||||
<metadataMap>
|
||||
<mapping key="pluginName">
|
||||
<constraint constraintValue="fssobs"
|
||||
constraintType="EQUALS" />
|
||||
|
@ -194,10 +194,6 @@
|
|||
<constraint constraintValue="1006,1003"
|
||||
constraintType="IN" />
|
||||
</mapping>
|
||||
<mapping key="location.stationId">
|
||||
<constraint constraintValue="${stations}"
|
||||
constraintType="IN" />
|
||||
</mapping>
|
||||
</metadataMap>
|
||||
<alertParser xsi:type="plotAlertParser" />
|
||||
</resourceData>
|
||||
|
@ -256,15 +252,10 @@
|
|||
<constraint constraintValue="fssobs"
|
||||
constraintType="EQUALS" />
|
||||
</mapping>
|
||||
|
||||
<mapping key="reportType">
|
||||
<constraint constraintValue="1007"
|
||||
constraintType="EQUALS" />
|
||||
</mapping>
|
||||
<mapping key="location.stationId">
|
||||
<constraint constraintValue="${stations}"
|
||||
constraintType="IN" />
|
||||
</mapping>
|
||||
</metadataMap>
|
||||
<binOffset virtualOffset="0"
|
||||
posOffset="1800" negOffset="1800" />
|
||||
|
|
|
@ -197,14 +197,11 @@
|
|||
<constraint constraintValue="fssobs"
|
||||
constraintType="EQUALS" />
|
||||
</mapping>
|
||||
|
||||
<mapping key="reportType">
|
||||
<constraint constraintValue="1006,1003"
|
||||
constraintType="IN" />
|
||||
</mapping>
|
||||
<mapping key="location.stationId">
|
||||
<constraint constraintValue="${stations}"
|
||||
constraintType="IN" />
|
||||
</mapping>
|
||||
|
||||
</metadataMap>
|
||||
<alertParser xsi:type="plotAlertParser" />
|
||||
|
@ -227,7 +224,6 @@
|
|||
isRequeryNecessaryOnTimeMatch="true"
|
||||
isTopOfTheHour="false">
|
||||
<metadataMap>
|
||||
|
||||
<mapping key="pluginName">
|
||||
<constraint constraintValue="fssobs"
|
||||
constraintType="EQUALS" />
|
||||
|
@ -240,7 +236,6 @@
|
|||
<constraint constraintValue="${stations}"
|
||||
constraintType="IN" />
|
||||
</mapping>
|
||||
|
||||
</metadataMap>
|
||||
</resourceData>
|
||||
</resource>
|
||||
|
@ -272,10 +267,6 @@
|
|||
<constraint constraintValue="1007"
|
||||
constraintType="EQUALS" />
|
||||
</mapping>
|
||||
<mapping key="location.stationId">
|
||||
<constraint constraintValue="${stations}"
|
||||
constraintType="IN" />
|
||||
</mapping>
|
||||
|
||||
</metadataMap>
|
||||
<binOffset virtualOffset="0"
|
||||
|
|
|
@ -24,6 +24,7 @@ import com.raytheon.uf.viz.monitor.data.ObReport;
|
|||
* May 15, 2012 14510 zhao Modified generateObReport()
|
||||
* Jan 06, 2014 2653 skorolev Included SNOW data into ObReport.
|
||||
* Sep 20, 2015 3873 skorolev Added IsStationary and getReportType.
|
||||
* Dec 02, 2015 3873 dhladky Fixed missing parameters.
|
||||
*
|
||||
*
|
||||
* </pre>
|
||||
|
@ -48,6 +49,7 @@ public class GenerateFSSObReport {
|
|||
// Generate the observation report.
|
||||
ObReport obReport = new ObReport();
|
||||
FSSObsRecord fssData = (FSSObsRecord) report;
|
||||
|
||||
try {
|
||||
obReport.setObservationTime(fssData.getTimeObs().getTime());
|
||||
obReport.setRefHour(fssData.getRefHour().getTime());
|
||||
|
@ -59,7 +61,7 @@ public class GenerateFSSObReport {
|
|||
obReport.setTimesFromFssobDataURI(report.getDataURI());
|
||||
}
|
||||
obReport.setPlatformId(fssData.getPlatformId());
|
||||
obReport.setStationary(fssData.getIsStationary());
|
||||
obReport.setStationary(fssData.isStationary());
|
||||
obReport.setLatitude((float) fssData.getLatitude());
|
||||
obReport.setLongitude((float) fssData.getLongitude());
|
||||
// Table data:
|
||||
|
@ -117,19 +119,31 @@ public class GenerateFSSObReport {
|
|||
return obReport;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve the type of the report. ReportType Enumeration
|
||||
*/
|
||||
private static ReportType getReportType(String reportType) {
|
||||
if (reportType == null) {
|
||||
reportType = "";
|
||||
}
|
||||
switch (reportType) {
|
||||
case "1003":
|
||||
case "1004":
|
||||
case "1005":
|
||||
case "1006":
|
||||
case "1007":
|
||||
case "1003":
|
||||
return ReportType.SYNOPTIC_SHIP;
|
||||
case "1004":
|
||||
return ReportType.SYNOPTIC_CMAN;
|
||||
case "1005":
|
||||
return ReportType.SYNOPTIC_MOORED_BUOY;
|
||||
case "1006":
|
||||
return ReportType.DRIFTING_BUOY;
|
||||
case "1007":
|
||||
return ReportType.MARITIME;
|
||||
// TODO:MESONET
|
||||
default:
|
||||
case "SPECI":
|
||||
return ReportType.SPECI;
|
||||
case "METAR":
|
||||
return ReportType.METAR;
|
||||
case "MESONET":
|
||||
return ReportType.MESONET;
|
||||
default:
|
||||
return ReportType.METAR;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -64,7 +64,7 @@ public class ProcessObsJob extends Job {
|
|||
protected static final int PROGRESS_FACTOR = 1;
|
||||
|
||||
/** how many hours do FSSObs go back we wish to load here **/
|
||||
public static final int HOUR_BACK = 24;
|
||||
public static final int HOUR_BACK = 12;
|
||||
|
||||
private ObsMonitor obsMonitor;
|
||||
|
||||
|
|
|
@ -27,12 +27,15 @@ import java.util.Map;
|
|||
import java.util.Set;
|
||||
|
||||
import com.raytheon.uf.common.geospatial.SpatialException;
|
||||
import com.raytheon.uf.common.localization.exception.LocalizationException;
|
||||
import com.raytheon.uf.common.monitor.MonitorAreaUtils;
|
||||
import com.raytheon.uf.common.monitor.config.FSSObsMonitorConfigurationManager;
|
||||
import com.raytheon.uf.common.monitor.data.CommonConfig;
|
||||
import com.raytheon.uf.common.monitor.data.CommonConfig.AppName;
|
||||
import com.raytheon.uf.common.monitor.data.ObConst.ReportType;
|
||||
import com.raytheon.uf.common.monitor.xml.AreaIdXML;
|
||||
import com.raytheon.uf.common.monitor.xml.StationIdXML;
|
||||
import com.raytheon.uf.common.serialization.SerializationException;
|
||||
import com.raytheon.uf.common.status.IUFStatusHandler;
|
||||
import com.raytheon.uf.common.status.UFStatus;
|
||||
import com.raytheon.uf.common.status.UFStatus.Priority;
|
||||
|
@ -56,6 +59,9 @@ import com.vividsolutions.jts.geom.Coordinate;
|
|||
* Sep 04 2014 3220 skorolev Added updateZones method.
|
||||
* Mar 17 2015 3888 dhladky check for nulls
|
||||
* Sep 25 2015 3873 skorolev Corrected addReport for moving platforms.
|
||||
* Oct 19 2015 3841 skorolev Added try to saveConfigXml
|
||||
* Nov 12 2015 3841 dhladky Augmented Slav's fix for moving platforms.
|
||||
* Dec 02 2015 3873 dhladky Pulled 3841 changes to 16.1.1.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -70,26 +76,26 @@ public class ObHourReports {
|
|||
/**
|
||||
* the nominal time of this ObHourReports object
|
||||
*/
|
||||
private Date nominalTime;
|
||||
private final Date nominalTime;
|
||||
|
||||
/**
|
||||
* application name (SNOW, FOG, SAFESEAS)
|
||||
*/
|
||||
private CommonConfig.AppName appName;
|
||||
private final CommonConfig.AppName appName;
|
||||
|
||||
/**
|
||||
* key is zone id, value is ObZoneHourReports object
|
||||
*/
|
||||
private Map<String, ObZoneHourReports> hourReports;
|
||||
private final Map<String, ObZoneHourReports> hourReports;
|
||||
|
||||
/**
|
||||
* current threshold manager
|
||||
*/
|
||||
private AbstractThresholdMgr thresholdMgr;
|
||||
private final AbstractThresholdMgr thresholdMgr;
|
||||
|
||||
private Set<String> zones = new HashSet<String>();
|
||||
private final Set<String> zones = new HashSet<String>();
|
||||
|
||||
private FSSObsMonitorConfigurationManager configMgr;
|
||||
private final FSSObsMonitorConfigurationManager configMgr;
|
||||
|
||||
/**
|
||||
* constructor
|
||||
|
@ -161,9 +167,22 @@ public class ObHourReports {
|
|||
try {
|
||||
// use only marine zones
|
||||
if (zone.charAt(2) == 'Z') {
|
||||
|
||||
Coordinate zcoor = MonitorAreaUtils.getZoneCenter(zone);
|
||||
double shipToZone = distance(latShip, lonShip, zcoor.y,
|
||||
zcoor.x);
|
||||
double latZone;
|
||||
double lonZone;
|
||||
|
||||
if (zcoor != null) {
|
||||
latZone = zcoor.y;
|
||||
lonZone = zcoor.x;
|
||||
} else {
|
||||
// Newly added zone
|
||||
AreaIdXML zoneXML = configMgr.getAreaXml(zone);
|
||||
latZone = zoneXML.getCLat();
|
||||
lonZone = zoneXML.getCLon();
|
||||
}
|
||||
double shipToZone = distance(latShip, lonShip, latZone,
|
||||
lonZone);
|
||||
if (shipToZone <= shipDist) {
|
||||
// associate moving platform with monitoring zone.
|
||||
shipZones.add(zone);
|
||||
|
@ -181,12 +200,18 @@ public class ObHourReports {
|
|||
continue;
|
||||
}
|
||||
} catch (SpatialException e) {
|
||||
statusHandler.handle(Priority.PROBLEM, e.getLocalizedMessage(),
|
||||
e);
|
||||
statusHandler.handle(Priority.PROBLEM,
|
||||
"Could not determine distance from moving platform to zone: Platform: "
|
||||
+ report.getPlatformId() + " Zone: " + zone, e);
|
||||
}
|
||||
}
|
||||
// Update configuration file.
|
||||
configMgr.saveConfigXml();
|
||||
try {
|
||||
configMgr.saveConfigXml();
|
||||
} catch (LocalizationException e) {
|
||||
statusHandler.handle(Priority.PROBLEM, "Problem saving Localization file!", e);
|
||||
} catch (SerializationException e) {
|
||||
statusHandler.handle(Priority.PROBLEM, "Problem serializaing Localization File!", e);
|
||||
}
|
||||
return shipZones;
|
||||
}
|
||||
|
||||
|
@ -206,9 +231,12 @@ public class ObHourReports {
|
|||
*/
|
||||
public TableData getZoneTableData() {
|
||||
TableData tblData = new TableData(appName);
|
||||
for (String zone : hourReports.keySet()) {
|
||||
tblData.addTableRowData(this.getObZoneHourReports(zone)
|
||||
.getZoneTableRowData());
|
||||
// Area configuration manager controls what gets displayed
|
||||
for (String zone : configMgr.getAreaList()) {
|
||||
if (hourReports.containsKey(zone)) {
|
||||
tblData.addTableRowData(this.getObZoneHourReports(zone)
|
||||
.getZoneTableRowData());
|
||||
}
|
||||
}
|
||||
return tblData;
|
||||
}
|
||||
|
@ -221,15 +249,18 @@ public class ObHourReports {
|
|||
*/
|
||||
public TableData getFogZoneTableData(Map<String, CellType> algCellType) {
|
||||
TableData tblData = new TableData(AppName.FOG);
|
||||
for (String zone : hourReports.keySet()) {
|
||||
CellType theAlgCellType;
|
||||
if (algCellType.containsKey(zone)) {
|
||||
theAlgCellType = algCellType.get(zone);
|
||||
} else {
|
||||
theAlgCellType = CellType.NotAvailable;
|
||||
// Area configuration manager controls what gets displayed
|
||||
for (String zone : configMgr.getAreaList()) {
|
||||
if (hourReports.containsKey(zone)) {
|
||||
CellType theAlgCellType;
|
||||
if (algCellType.containsKey(zone)) {
|
||||
theAlgCellType = algCellType.get(zone);
|
||||
} else {
|
||||
theAlgCellType = CellType.NotAvailable;
|
||||
}
|
||||
tblData.addTableRowData(this.getObZoneHourReports(zone)
|
||||
.getFogZoneTableRowData(theAlgCellType));
|
||||
}
|
||||
tblData.addTableRowData(this.getObZoneHourReports(zone)
|
||||
.getFogZoneTableRowData(theAlgCellType));
|
||||
}
|
||||
return tblData;
|
||||
}
|
||||
|
@ -242,15 +273,18 @@ public class ObHourReports {
|
|||
*/
|
||||
public TableData getSSZoneTableData(Map<String, CellType> fogCellType) {
|
||||
TableData tblData = new TableData(AppName.SAFESEAS);
|
||||
for (String zone : hourReports.keySet()) {
|
||||
CellType theFogCellType;
|
||||
if (fogCellType.containsKey(zone)) {
|
||||
theFogCellType = fogCellType.get(zone);
|
||||
} else {
|
||||
theFogCellType = CellType.NotAvailable;
|
||||
// Area configuration manager controls what gets displayed
|
||||
for (String zone : configMgr.getAreaList()) {
|
||||
if (hourReports.containsKey(zone)) {
|
||||
CellType theFogCellType;
|
||||
if (fogCellType.containsKey(zone)) {
|
||||
theFogCellType = fogCellType.get(zone);
|
||||
} else {
|
||||
theFogCellType = CellType.NotAvailable;
|
||||
}
|
||||
tblData.addTableRowData(this.getObZoneHourReports(zone)
|
||||
.getSSZoneTableRowData(theFogCellType));
|
||||
}
|
||||
tblData.addTableRowData(this.getObZoneHourReports(zone)
|
||||
.getSSZoneTableRowData(theFogCellType));
|
||||
}
|
||||
return tblData;
|
||||
}
|
||||
|
@ -302,7 +336,7 @@ public class ObHourReports {
|
|||
if (!hourReports.keySet().contains(zone)) {
|
||||
hourReports.put(zone, new ObZoneHourReports(nominalTime, zone,
|
||||
appName, thresholdMgr));
|
||||
}
|
||||
}
|
||||
}
|
||||
// add and(or) remove stations
|
||||
for (String zone : updtZones) {
|
||||
|
@ -364,4 +398,4 @@ public class ObHourReports {
|
|||
private static double toRad(double value) {
|
||||
return value * Math.PI / 180;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -36,11 +36,8 @@ import com.raytheon.uf.common.monitor.config.FSSObsMonitorConfigurationManager.M
|
|||
import com.raytheon.uf.common.monitor.data.CommonConfig;
|
||||
import com.raytheon.uf.common.monitor.data.CommonConfig.AppName;
|
||||
import com.raytheon.uf.common.monitor.data.ObConst;
|
||||
import com.raytheon.uf.common.status.IUFStatusHandler;
|
||||
import com.raytheon.uf.common.status.UFStatus;
|
||||
import com.raytheon.uf.common.time.SimulatedTime;
|
||||
import com.raytheon.uf.common.time.util.TimeUtil;
|
||||
import com.raytheon.uf.viz.monitor.ProcessObsJob;
|
||||
import com.raytheon.uf.viz.monitor.config.CommonTableConfig.CellType;
|
||||
import com.raytheon.uf.viz.monitor.config.CommonTableConfig.ObsHistType;
|
||||
import com.raytheon.uf.viz.monitor.thresholds.AbstractThresholdMgr;
|
||||
|
@ -61,7 +58,9 @@ import com.raytheon.uf.viz.monitor.thresholds.AbstractThresholdMgr;
|
|||
* Oct 31, 2012 1297 skorolev Clean code.
|
||||
* Jan 29, 2013 15654 zhao add Wind Chill calculation for SNOW
|
||||
* Sep 04, 2014 3220 skorolev Updated getStationTableData method.
|
||||
* Sep 25, 2015 3873 skorolev Added multiHrsTabData. Corrected getEmptyZoneTableData().
|
||||
* Sep 25, 2015 3873 skorolev Added multiHrsTabData.
|
||||
* Nov 12, 2015 3841 dhladky Augmented Slav's update fix.
|
||||
* Dec 02 2015 3873 dhladky Pulled 3841 changes to 16.1.1.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -70,8 +69,6 @@ import com.raytheon.uf.viz.monitor.thresholds.AbstractThresholdMgr;
|
|||
*/
|
||||
|
||||
public class ObMultiHrsReports {
|
||||
private final IUFStatusHandler statusHandler = UFStatus
|
||||
.getHandler(ObMultiHrsReports.class);
|
||||
|
||||
/**
|
||||
* Thresholds manager
|
||||
|
@ -86,7 +83,7 @@ public class ObMultiHrsReports {
|
|||
/**
|
||||
* application name (snow, fog, safeseas, etc)
|
||||
*/
|
||||
private final CommonConfig.AppName appName;
|
||||
private CommonConfig.AppName appName;
|
||||
|
||||
/**
|
||||
* FSSObs records cache. Key is nominal time, value is ObHourReports object
|
||||
|
@ -98,7 +95,7 @@ public class ObMultiHrsReports {
|
|||
*/
|
||||
private ConcurrentHashMap<Date, TableData> multiHrsTabData = new ConcurrentHashMap<Date, TableData>();
|
||||
|
||||
private final int maxFrames = ObConst.MAX_FRAMES;
|
||||
private int maxFrames = ObConst.MAX_FRAMES;
|
||||
|
||||
private FSSObsMonitorConfigurationManager cfgMgr = null;
|
||||
|
||||
|
@ -130,6 +127,7 @@ public class ObMultiHrsReports {
|
|||
*/
|
||||
public void addReport(ObReport report) {
|
||||
Date nominalTime = report.getRefHour();
|
||||
|
||||
/**
|
||||
* DR #8723: if wind speed is zero, wind direction should be N/A, not 0
|
||||
*/
|
||||
|
@ -170,11 +168,15 @@ public class ObMultiHrsReports {
|
|||
// update multiHrsReports with new data
|
||||
obHourReports = multiHrsReports.get(nominalTime);
|
||||
}
|
||||
obHourReports.addReport(report);
|
||||
// update data cache
|
||||
multiHrsReports.put(nominalTime, obHourReports);
|
||||
TableData tblData = obHourReports.getZoneTableData();
|
||||
multiHrsTabData.put(nominalTime, tblData);
|
||||
|
||||
if (report != null && obHourReports != null) {
|
||||
obHourReports.addReport(report);
|
||||
// update data cache
|
||||
multiHrsReports.put(nominalTime, obHourReports);
|
||||
TableData tblData = obHourReports.getZoneTableData();
|
||||
multiHrsTabData.put(nominalTime, tblData);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -248,10 +250,8 @@ public class ObMultiHrsReports {
|
|||
* @return
|
||||
*/
|
||||
public TableData getEmptyZoneTableData() {
|
||||
long currentTime = SimulatedTime.getSystemTime().getMillis();
|
||||
Date nominalTime = new Date(currentTime
|
||||
- (ProcessObsJob.HOUR_BACK * TimeUtil.MILLIS_PER_HOUR));
|
||||
|
||||
Date nominalTime = TableUtil.getNominalTime(SimulatedTime
|
||||
.getSystemTime().getTime());
|
||||
ObHourReports hourReports = new ObHourReports(nominalTime, appName,
|
||||
thresholdMgr);
|
||||
TableData tabData = null;
|
||||
|
@ -260,6 +260,12 @@ public class ObMultiHrsReports {
|
|||
} else {
|
||||
tabData = hourReports.getZoneTableData();
|
||||
}
|
||||
// update data cache
|
||||
multiHrsReports.put(nominalTime, hourReports);
|
||||
// update cache with empty table data
|
||||
if (multiHrsTabData.replace(nominalTime, tabData) == null) {
|
||||
multiHrsTabData.put(nominalTime, tabData);
|
||||
}
|
||||
return tabData;
|
||||
}
|
||||
|
||||
|
@ -519,7 +525,7 @@ public class ObMultiHrsReports {
|
|||
* @return
|
||||
*/
|
||||
public ObHourReports getObHourReports() {
|
||||
if (multiHrsReports.isEmpty()) {
|
||||
if (multiHrsReports.isEmpty() || multiHrsTabData.isEmpty()) {
|
||||
ObHourReports obHrsReps = new ObHourReports(
|
||||
TableUtil.getNominalTime(SimulatedTime.getSystemTime()
|
||||
.getTime()), appName, thresholdMgr);
|
||||
|
@ -612,8 +618,12 @@ public class ObMultiHrsReports {
|
|||
* Updates table cache
|
||||
*/
|
||||
public void updateTableCache() {
|
||||
// clear and rebuild table data on config changes
|
||||
multiHrsTabData.clear();
|
||||
|
||||
for (Date time : multiHrsReports.keySet()) {
|
||||
getZoneTableData(time);
|
||||
TableData tblData = getZoneTableData(time);
|
||||
multiHrsTabData.put(time, tblData);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -56,6 +56,7 @@ import com.raytheon.viz.ui.dialogs.CaveSWTDialog;
|
|||
* Nov 20, 2012 1297 skorolev Changes for non-blocking dialog.
|
||||
* Apr 23, 2014 3054 skorolev Added MESONET handling.
|
||||
* Apr 28, 2014 3086 skorolev Removed local getAreaConfigMgr method.
|
||||
* Dec 02, 2015 3873 dhladky Pulled 3841 to 16.1.1.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -261,7 +262,7 @@ public class AddNewStationDlg extends CaveSWTDialog {
|
|||
return;
|
||||
}
|
||||
macDlg.addNewStationAction(stn);
|
||||
macDlg.getInstance().addStation(area, stn, type, false);
|
||||
macDlg.getInstance().addNewStation(area, stn, type, false);
|
||||
macDlg.getInstance().getStations().add(stn);
|
||||
}
|
||||
|
||||
|
|
|
@ -22,13 +22,14 @@ package com.raytheon.uf.viz.monitor.ui.dialogs;
|
|||
import org.eclipse.swt.SWT;
|
||||
import org.eclipse.swt.events.SelectionAdapter;
|
||||
import org.eclipse.swt.events.SelectionEvent;
|
||||
import org.eclipse.swt.events.VerifyEvent;
|
||||
import org.eclipse.swt.events.VerifyListener;
|
||||
import org.eclipse.swt.layout.GridData;
|
||||
import org.eclipse.swt.layout.GridLayout;
|
||||
import org.eclipse.swt.widgets.Button;
|
||||
import org.eclipse.swt.widgets.Composite;
|
||||
import org.eclipse.swt.widgets.Label;
|
||||
import org.eclipse.swt.widgets.Layout;
|
||||
import org.eclipse.swt.widgets.MessageBox;
|
||||
import org.eclipse.swt.widgets.Shell;
|
||||
import org.eclipse.swt.widgets.Text;
|
||||
|
||||
|
@ -50,6 +51,9 @@ import com.raytheon.viz.ui.dialogs.CaveSWTDialog;
|
|||
* Apr 23, 2014 3054 skorolev Deleted unnecessary parameter in addArea method.
|
||||
* Apr 28, 2014 3086 skorolev Removed local getAreaConfigMgr method.
|
||||
* Feb 10, 2015 3886 skorolev Added fixed width for dialog.
|
||||
* Aug 17, 2015 3841 skorolev Corrected handleAddNewAction method.
|
||||
* Nov 12, 2015 3841 dhladky Augmented Slav's fix for moving platforms.
|
||||
* Dec 02, 2015 3873 dhladky Pulled 3841 to 16.1.1.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -59,7 +63,7 @@ import com.raytheon.viz.ui.dialogs.CaveSWTDialog;
|
|||
public class AddNewZoneDlg extends CaveSWTDialog {
|
||||
|
||||
/** Application name. */
|
||||
private AppName appName;
|
||||
private final AppName appName;
|
||||
|
||||
/** Marine zone radio button. */
|
||||
private Button marineZoneRdo;
|
||||
|
@ -77,7 +81,25 @@ public class AddNewZoneDlg extends CaveSWTDialog {
|
|||
private Text centroidLonTF;
|
||||
|
||||
/** Monitoring Area Configuration Dialog. */
|
||||
private MonitoringAreaConfigDlg macDlg;
|
||||
private final MonitoringAreaConfigDlg macDlg;
|
||||
|
||||
/** County constant char */
|
||||
private static final char C = 'C';
|
||||
|
||||
/** Zone constant char */
|
||||
private static final char Z = 'Z';
|
||||
|
||||
/** Upper Latitude Boundary **/
|
||||
public static double upLatBound = 90.0;
|
||||
|
||||
/** Lower Latitude Boundary **/
|
||||
public static double lowLatBound = -90.0;
|
||||
|
||||
/** Upper Longitude Boundary **/
|
||||
public static double upLonBound = 180.0;
|
||||
|
||||
/** Lower Longitude Boundary **/
|
||||
public static double lowLonBound = -180.0;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
|
@ -144,13 +166,15 @@ public class AddNewZoneDlg extends CaveSWTDialog {
|
|||
/*
|
||||
* Add the radio controls.
|
||||
*/
|
||||
Composite radioComp = new Composite(topComp, SWT.NONE);
|
||||
radioComp.setLayout(new GridLayout(1, false));
|
||||
marineZoneRdo = new Button(radioComp, SWT.RADIO);
|
||||
marineZoneRdo.setText("Marine Zone");
|
||||
marineZoneRdo.setSelection(true);
|
||||
countyRdo = new Button(radioComp, SWT.RADIO);
|
||||
countyRdo.setText("County");
|
||||
if (!appName.equals(AppName.SNOW)) {
|
||||
Composite radioComp = new Composite(topComp, SWT.NONE);
|
||||
radioComp.setLayout(new GridLayout(1, false));
|
||||
marineZoneRdo = new Button(radioComp, SWT.RADIO);
|
||||
marineZoneRdo.setText("Marine Zone");
|
||||
marineZoneRdo.setSelection(true);
|
||||
countyRdo = new Button(radioComp, SWT.RADIO);
|
||||
countyRdo.setText("County");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -179,11 +203,21 @@ public class AddNewZoneDlg extends CaveSWTDialog {
|
|||
GridData gd = new GridData(SWT.FILL, SWT.CENTER, true, true);
|
||||
gd.widthHint = 200;
|
||||
Label idLbl = new Label(textComp, SWT.RIGHT);
|
||||
idLbl.setText("Id (e.g. AMZ080):");
|
||||
if (appName.equals(AppName.SNOW)) {
|
||||
idLbl.setText("Id (e.g. AMC080):");
|
||||
} else {
|
||||
idLbl.setText("Id (e.g. AMZ080):");
|
||||
}
|
||||
idLbl.setLayoutData(gd);
|
||||
|
||||
idTF = new Text(textComp, SWT.BORDER);
|
||||
idTF.setLayoutData(new GridData(120, SWT.DEFAULT));
|
||||
idTF.addVerifyListener(new VerifyListener() {
|
||||
@Override
|
||||
public void verifyText(VerifyEvent e) {
|
||||
e.text = e.text.toUpperCase();
|
||||
}
|
||||
});
|
||||
|
||||
gd = new GridData(SWT.FILL, SWT.CENTER, true, true);
|
||||
Label centroidLatLbl = new Label(textComp, SWT.RIGHT);
|
||||
|
@ -236,9 +270,12 @@ public class AddNewZoneDlg extends CaveSWTDialog {
|
|||
addBtn.addSelectionListener(new SelectionAdapter() {
|
||||
@Override
|
||||
public void widgetSelected(SelectionEvent event) {
|
||||
String areaId = idTF.getText();
|
||||
String latString = centroidLatTF.getText();
|
||||
String lonString = centroidLonTF.getText();
|
||||
handleAddNewAction(latString, lonString);
|
||||
if (macDlg.formIsValid(areaId, latString, lonString)) {
|
||||
handleAddNewAction(areaId, latString, lonString);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -261,58 +298,43 @@ public class AddNewZoneDlg extends CaveSWTDialog {
|
|||
* @param latString
|
||||
* @param lonString
|
||||
*/
|
||||
private void handleAddNewAction(String latString, String lonString) {
|
||||
String areaId = idTF.getText();
|
||||
if (areaId.equals("") || areaId.length() != 6
|
||||
|| (areaId.charAt(2) != 'C' && areaId.charAt(2) != 'Z')) {
|
||||
displayInputErrorMsg("Invalid Area ID = '" + areaId
|
||||
+ "' entered. Please enter a correctly formatted Area ID.");
|
||||
private void handleAddNewAction(String areaId, String latString,
|
||||
String lonString) throws NumberFormatException {
|
||||
|
||||
ZoneType type = ZoneType.REGULAR;
|
||||
char charAt = idTF.getText().charAt(2);
|
||||
if (!appName.equals(AppName.SNOW)) {
|
||||
if (marineZoneRdo.getSelection()) {
|
||||
type = ZoneType.MARITIME;
|
||||
}
|
||||
// correct zone type
|
||||
if (marineZoneRdo.getSelection() && charAt != Z) {
|
||||
String z = idTF.getText().substring(2).replace(charAt, Z);
|
||||
idTF.setText(idTF.getText().substring(0, 2) + z);
|
||||
}
|
||||
if (countyRdo.getSelection() && charAt != C) {
|
||||
String c = idTF.getText().substring(2).replace(charAt, C);
|
||||
idTF.setText(idTF.getText().substring(0, 2) + c);
|
||||
}
|
||||
} else if (appName.equals(AppName.SNOW) && charAt != C) {
|
||||
String c = idTF.getText().substring(2).replace(charAt, C);
|
||||
idTF.setText(idTF.getText().substring(0, 2) + c);
|
||||
}
|
||||
double lat = Double.parseDouble(latString.trim());
|
||||
double lon = Double.parseDouble(lonString.trim());
|
||||
if (lat > upLatBound || lat < lowLatBound || lon > upLonBound || lon < lowLonBound) {
|
||||
macDlg.latLonErrorMsg(latString, lonString);
|
||||
return;
|
||||
}
|
||||
areaId = idTF.getText();
|
||||
if (macDlg.isExistingZone(areaId)) {
|
||||
displayInputErrorMsg("The Area ID, "
|
||||
macDlg.displayInputErrorMsg("The Area ID, "
|
||||
+ areaId
|
||||
+ ", is already in your Monitoring Area or among your Additional Zones.");
|
||||
return;
|
||||
}
|
||||
if (latString == null || latString.isEmpty() || lonString == null
|
||||
|| lonString.isEmpty()) {
|
||||
macDlg.latLonErrorMsg(latString, lonString);
|
||||
return;
|
||||
} else {
|
||||
try {
|
||||
double lat = Double.parseDouble(latString.trim());
|
||||
double lon = Double.parseDouble(lonString.trim());
|
||||
ZoneType type = ZoneType.REGULAR;
|
||||
if (appName != AppName.SNOW) {
|
||||
if (marineZoneRdo.getSelection()) {
|
||||
type = ZoneType.MARITIME;
|
||||
}
|
||||
}
|
||||
if (lat > 90.0 || lat < -90.0 || lon > 180.0 || lon < -180.0) {
|
||||
macDlg.latLonErrorMsg(latString, lonString);
|
||||
return;
|
||||
}
|
||||
macDlg.configMgr.addArea(areaId, lat, lon, type);
|
||||
macDlg.addNewZoneAction(areaId, centroidLatTF.getText(),
|
||||
centroidLonTF.getText());
|
||||
} catch (NumberFormatException e) {
|
||||
macDlg.latLonErrorMsg(latString, lonString);
|
||||
return;
|
||||
}
|
||||
macDlg.configMgr.addNewArea(areaId, lat, lon, type);
|
||||
macDlg.addZoneToMA(areaId);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Displays Input Error Message
|
||||
*
|
||||
* @param msg
|
||||
*/
|
||||
private void displayInputErrorMsg(String msg) {
|
||||
MessageBox messageBox = new MessageBox(shell, SWT.ICON_INFORMATION
|
||||
| SWT.OK);
|
||||
messageBox.setText("Invalid input");
|
||||
messageBox.setMessage(msg);
|
||||
messageBox.open();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -19,6 +19,8 @@
|
|||
**/
|
||||
package com.raytheon.uf.viz.monitor.ui.dialogs;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import org.eclipse.swt.SWT;
|
||||
import org.eclipse.swt.events.SelectionAdapter;
|
||||
import org.eclipse.swt.events.SelectionEvent;
|
||||
|
@ -35,6 +37,7 @@ import org.eclipse.swt.widgets.Shell;
|
|||
|
||||
import com.raytheon.uf.common.monitor.config.FSSObsMonitorConfigurationManager;
|
||||
import com.raytheon.uf.common.monitor.data.CommonConfig.AppName;
|
||||
import com.raytheon.uf.common.monitor.xml.AreaIdXML;
|
||||
import com.raytheon.viz.ui.dialogs.CaveSWTDialog;
|
||||
|
||||
/**
|
||||
|
@ -50,6 +53,9 @@ import com.raytheon.viz.ui.dialogs.CaveSWTDialog;
|
|||
* Nov 20, 2012 1297 skorolev Changes for non-blocking dialog.
|
||||
* Apr 23, 2014 3054 skorolev Fixed issue with deleting a new station.
|
||||
* Apr 28, 2014 3086 skorolev Removed local getAreaConfigMgr method.
|
||||
* Aug 17, 2015 3841 skorolev Corrected deleteSelected method.
|
||||
* Nov 12, 2015 3841 dhladky Augmented Slav's work.
|
||||
* Dec 02, 2015 3873 dhladky Pulled 3841 to 16.1.1.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -64,11 +70,10 @@ public class DeleteStationDlg extends CaveSWTDialog {
|
|||
/** Control font. */
|
||||
private Font controlFont;
|
||||
|
||||
/** Area configuration manager. */
|
||||
private FSSObsMonitorConfigurationManager configMgr;
|
||||
|
||||
/** Monitoring Area Configuration Dialog */
|
||||
private MonitoringAreaConfigDlg macDlg;
|
||||
private final MonitoringAreaConfigDlg macDlg;
|
||||
|
||||
private final java.util.List<String> newAddedStns = new ArrayList<String>();
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
|
@ -77,13 +82,14 @@ public class DeleteStationDlg extends CaveSWTDialog {
|
|||
* Parent shell.
|
||||
* @param appName
|
||||
* Application name.
|
||||
* @param area
|
||||
* @param macDlg
|
||||
*/
|
||||
public DeleteStationDlg(Shell parent, AppName appName,
|
||||
MonitoringAreaConfigDlg macDlg) {
|
||||
super(parent, SWT.DIALOG_TRIM, CAVE.DO_NOT_BLOCK);
|
||||
setText(appName.toString() + ": Delete a Newly Entered Station");
|
||||
this.macDlg = macDlg;
|
||||
configMgr = macDlg.getInstance();
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -114,6 +120,11 @@ public class DeleteStationDlg extends CaveSWTDialog {
|
|||
controlFont = new Font(shell.getDisplay(), "Monospace", 10, SWT.NORMAL);
|
||||
createListControl();
|
||||
createBottomButtons();
|
||||
FSSObsMonitorConfigurationManager cfgMgr = macDlg.getInstance();
|
||||
java.util.List<AreaIdXML> areaList = cfgMgr.getConfigXml().getAreaIds();
|
||||
newAddedStns.addAll(cfgMgr.getNewlyAddedStations(areaList));
|
||||
areaList = cfgMgr.getAdjAreaConfigXml().getAreaIds();
|
||||
newAddedStns.addAll(cfgMgr.getNewlyAddedStations(areaList));
|
||||
populate();
|
||||
}
|
||||
|
||||
|
@ -175,8 +186,7 @@ public class DeleteStationDlg extends CaveSWTDialog {
|
|||
* Populate list of added stations.
|
||||
*/
|
||||
private void populate() {
|
||||
java.util.List<String> addedStations = configMgr.getAddedStations();
|
||||
stationList.setItems(addedStations.toArray(new String[addedStations
|
||||
stationList.setItems(newAddedStns.toArray(new String[newAddedStns
|
||||
.size()]));
|
||||
}
|
||||
|
||||
|
@ -184,15 +194,21 @@ public class DeleteStationDlg extends CaveSWTDialog {
|
|||
* Delete stations from the list.
|
||||
*/
|
||||
private String deleteSelected() {
|
||||
String retval = null;
|
||||
String retval = "";
|
||||
if (stationList.getItemCount() != 0) {
|
||||
if (stationList.getSelectionIndex() != -1) {
|
||||
int idx = stationList.getSelectionIndex();
|
||||
String selection = stationList.getItem(idx);
|
||||
retval = configMgr.getAddedStations().get(idx);
|
||||
configMgr.getAddedStations().remove(idx);
|
||||
stationList.remove(selection);
|
||||
FSSObsMonitorConfigurationManager cfgMgr = macDlg.getInstance();
|
||||
java.util.List<AreaIdXML> areaXmlList = cfgMgr.getConfigXml()
|
||||
.getAreaIds();
|
||||
cfgMgr.removeStation(selection.split("#")[0], areaXmlList);
|
||||
areaXmlList = cfgMgr.getAdjAreaConfigXml().getAreaIds();
|
||||
cfgMgr.removeStation(selection.split("#")[0], areaXmlList);
|
||||
newAddedStns.remove(selection);
|
||||
populate();
|
||||
macDlg.maStationsChanged = true;
|
||||
} else {
|
||||
MessageBox messageBox = new MessageBox(shell,
|
||||
SWT.ICON_INFORMATION | SWT.NONE);
|
||||
|
|
|
@ -19,9 +19,13 @@
|
|||
**/
|
||||
package com.raytheon.uf.viz.monitor.ui.dialogs;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import org.eclipse.swt.SWT;
|
||||
import org.eclipse.swt.events.SelectionAdapter;
|
||||
import org.eclipse.swt.events.SelectionEvent;
|
||||
import org.eclipse.swt.events.VerifyEvent;
|
||||
import org.eclipse.swt.events.VerifyListener;
|
||||
import org.eclipse.swt.graphics.Font;
|
||||
import org.eclipse.swt.layout.GridData;
|
||||
import org.eclipse.swt.layout.GridLayout;
|
||||
|
@ -34,9 +38,11 @@ import org.eclipse.swt.widgets.MessageBox;
|
|||
import org.eclipse.swt.widgets.Shell;
|
||||
import org.eclipse.swt.widgets.Text;
|
||||
|
||||
import com.raytheon.uf.common.monitor.config.FSSObsMonitorConfigurationManager;
|
||||
import com.raytheon.uf.common.monitor.data.CommonConfig.AppName;
|
||||
import com.raytheon.uf.common.monitor.xml.AreaIdXML;
|
||||
import com.raytheon.uf.common.monitor.xml.AreaIdXML.ZoneType;
|
||||
import com.raytheon.uf.common.monitor.xml.StationIdXML;
|
||||
import com.raytheon.viz.ui.dialogs.CaveSWTDialog;
|
||||
|
||||
/**
|
||||
|
@ -53,6 +59,9 @@ import com.raytheon.viz.ui.dialogs.CaveSWTDialog;
|
|||
* Apr 23, 2014 3054 skorolev Fixed issues with removing a new zone from list.
|
||||
* Apr 28, 2014 3086 skorolev Removed local getAreaConfigMgr method.
|
||||
* Nov 10, 2014 3741 skorolev Fixed configXML issue.
|
||||
* Aug 17, 2015 3841 skorolev Made editable a content of ID field.
|
||||
* Nov 12, 2015 3841 dhladky Augmented Slav's update fixes.
|
||||
* Dec 02, 2015 3873 dhladky Pulled 3841 to 16.1.1.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -62,7 +71,7 @@ import com.raytheon.viz.ui.dialogs.CaveSWTDialog;
|
|||
public class EditNewZoneDlg extends CaveSWTDialog {
|
||||
|
||||
/** Call back interface. */
|
||||
private MonitoringAreaConfigDlg macDlg;
|
||||
private final MonitoringAreaConfigDlg macDlg;
|
||||
|
||||
/** Zone list control. */
|
||||
private List zoneList;
|
||||
|
@ -85,17 +94,11 @@ public class EditNewZoneDlg extends CaveSWTDialog {
|
|||
/** Control font. */
|
||||
private Font controlFont;
|
||||
|
||||
/** Marine station radio button. */
|
||||
private Button marineRdo;
|
||||
|
||||
/** None Marine station radio button. */
|
||||
private Button nonMarineRdo;
|
||||
|
||||
/** Bottom label */
|
||||
private Label bottomLbl;
|
||||
|
||||
/** Deleted zone */
|
||||
private String delZone;
|
||||
private boolean delZone = false;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
|
@ -142,7 +145,7 @@ public class EditNewZoneDlg extends CaveSWTDialog {
|
|||
createListAndTextControls();
|
||||
createBottomLabel();
|
||||
createCloseButton();
|
||||
populate();
|
||||
populate("");
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -202,6 +205,12 @@ public class EditNewZoneDlg extends CaveSWTDialog {
|
|||
gd.horizontalSpan = 2;
|
||||
idTF = new Text(textButtonComp, SWT.BORDER);
|
||||
idTF.setLayoutData(gd);
|
||||
idTF.addVerifyListener(new VerifyListener() {
|
||||
@Override
|
||||
public void verifyText(VerifyEvent e) {
|
||||
e.text = e.text.toUpperCase();
|
||||
}
|
||||
});
|
||||
|
||||
gd = new GridData();
|
||||
gd.horizontalSpan = 2;
|
||||
|
@ -227,21 +236,6 @@ public class EditNewZoneDlg extends CaveSWTDialog {
|
|||
lonTF = new Text(textButtonComp, SWT.BORDER);
|
||||
lonTF.setLayoutData(gd);
|
||||
|
||||
gd = new GridData();
|
||||
gd.horizontalSpan = 2;
|
||||
gd.verticalIndent = 15;
|
||||
marineRdo = new Button(textButtonComp, SWT.RADIO);
|
||||
marineRdo.setLayoutData(gd);
|
||||
marineRdo.setSelection(false);
|
||||
marineRdo.setText("Marine Station");
|
||||
|
||||
gd = new GridData();
|
||||
gd.horizontalSpan = 2;
|
||||
nonMarineRdo = new Button(textButtonComp, SWT.RADIO);
|
||||
nonMarineRdo.setLayoutData(gd);
|
||||
nonMarineRdo.setSelection(true);
|
||||
nonMarineRdo.setText("Non-Marine Station");
|
||||
|
||||
gd = new GridData(SWT.CENTER, SWT.DEFAULT, false, true);
|
||||
gd.widthHint = 80;
|
||||
gd.verticalIndent = 5;
|
||||
|
@ -251,7 +245,17 @@ public class EditNewZoneDlg extends CaveSWTDialog {
|
|||
saveBtn.addSelectionListener(new SelectionAdapter() {
|
||||
@Override
|
||||
public void widgetSelected(SelectionEvent event) {
|
||||
saveSelected();
|
||||
if (zoneList.getItemCount() != 0) {
|
||||
String area = zoneList.getItem(zoneList.getSelectionIndex());
|
||||
String areaStr = idTF.getText();
|
||||
String latStr = latTF.getText();
|
||||
String lonStr = lonTF.getText();
|
||||
if (macDlg.formIsValid(areaStr, latStr, lonStr)) {
|
||||
saveSelected(area, areaStr, latStr, lonStr);
|
||||
}
|
||||
} else {
|
||||
bottomLbl.setText("No zones have been edited.");
|
||||
}
|
||||
}
|
||||
});
|
||||
gd = new GridData(SWT.CENTER, SWT.DEFAULT, false, true);
|
||||
|
@ -309,9 +313,25 @@ public class EditNewZoneDlg extends CaveSWTDialog {
|
|||
/**
|
||||
* Populate list of added zones.
|
||||
*/
|
||||
private void populate() {
|
||||
java.util.List<String> newList = macDlg.configMgr.getAddedZones();
|
||||
private void populate(String selected) {
|
||||
java.util.List<String> newList = new ArrayList<String>();
|
||||
java.util.List<AreaIdXML> maList = macDlg.getInstance().getConfigXml()
|
||||
.getAreaIds();
|
||||
for (AreaIdXML maZone : maList) {
|
||||
if (maZone.getCLat() != null) {
|
||||
newList.add(maZone.getAreaId());
|
||||
}
|
||||
}
|
||||
java.util.List<AreaIdXML> adtnlList = macDlg.getInstance()
|
||||
.getAdjAreaConfigXml().getAreaIds();
|
||||
for (AreaIdXML aZone : adtnlList) {
|
||||
if (aZone.getCLat() != null) {
|
||||
newList.add(aZone.getAreaId());
|
||||
}
|
||||
}
|
||||
zoneList.removeAll();
|
||||
zoneList.setItems(newList.toArray(new String[newList.size()]));
|
||||
macDlg.populateLeftLists(selected);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -319,27 +339,24 @@ public class EditNewZoneDlg extends CaveSWTDialog {
|
|||
*/
|
||||
private void handleZoneSelection() {
|
||||
String zone = zoneList.getItem(zoneList.getSelectionIndex());
|
||||
AreaIdXML areaXml = macDlg.configMgr.getAreaXml(zone);
|
||||
// DR #7343: a null areaXml causes an "Unhandled event loop exception"
|
||||
FSSObsMonitorConfigurationManager cfgMgr = macDlg.getInstance();
|
||||
AreaIdXML areaXml = cfgMgr.getAreaXml(zone);
|
||||
AreaIdXML adjAreaXml = cfgMgr.getAdjAreaXML(zone);
|
||||
if (areaXml != null) {
|
||||
idTF.setText(areaXml.getAreaId());
|
||||
idTF.setEnabled(false);
|
||||
latTF.setText(String.valueOf(areaXml.getCLat()));
|
||||
lonTF.setText(String.valueOf(areaXml.getCLon()));
|
||||
if (areaXml.getType() == ZoneType.REGULAR) {
|
||||
nonMarineRdo.setSelection(true);
|
||||
marineRdo.setSelection(false);
|
||||
} else {
|
||||
nonMarineRdo.setSelection(false);
|
||||
marineRdo.setSelection(true);
|
||||
}
|
||||
} else if (adjAreaXml != null) {
|
||||
idTF.setText(adjAreaXml.getAreaId());
|
||||
latTF.setText(String.valueOf(adjAreaXml.getCLat()));
|
||||
lonTF.setText(String.valueOf(adjAreaXml.getCLon()));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete selected zones.
|
||||
*/
|
||||
private String deleteSelected() {
|
||||
private boolean deleteSelected() {
|
||||
if (zoneList.getItemCount() != 0) {
|
||||
if (zoneList.getSelectionIndex() == -1) {
|
||||
MessageBox messageBox = new MessageBox(shell,
|
||||
|
@ -348,62 +365,99 @@ public class EditNewZoneDlg extends CaveSWTDialog {
|
|||
messageBox.setMessage("Please select zone to be deleted.");
|
||||
messageBox.open();
|
||||
zoneList.select(0);
|
||||
return null;
|
||||
return false;
|
||||
}
|
||||
String area = zoneList.getItem(zoneList.getSelectionIndex());
|
||||
AreaIdXML zoneXML = null;
|
||||
FSSObsMonitorConfigurationManager cfgMgr = macDlg.getInstance();
|
||||
if (cfgMgr.getConfigXml().containsArea(area)) {
|
||||
zoneXML = cfgMgr.getAreaXml(area);
|
||||
} else if (cfgMgr.getAdjAreaConfigXml().containsArea(area)) {
|
||||
zoneXML = cfgMgr.getAdjAreaXML(area);
|
||||
}
|
||||
zoneList.remove(zoneList.getSelectionIndex());
|
||||
macDlg.configMgr.removeArea(area);
|
||||
idTF.setText("");
|
||||
latTF.setText("");
|
||||
lonTF.setText("");
|
||||
return area;
|
||||
zoneList.select(0);
|
||||
if (zoneList.getItemCount() != 0) {
|
||||
handleZoneSelection();
|
||||
} else {
|
||||
idTF.setText("");
|
||||
latTF.setText("");
|
||||
lonTF.setText("");
|
||||
}
|
||||
if (zoneXML != null && macDlg.getMaZones().contains(area)) {
|
||||
macDlg.getMaZones().remove(area);
|
||||
cfgMgr.removeArea(zoneXML);
|
||||
}
|
||||
if (zoneXML != null && macDlg.getAdditionalZones().contains(area)) {
|
||||
macDlg.getAdditionalZones().remove(area);
|
||||
cfgMgr.removeAdjArea(zoneXML);
|
||||
}
|
||||
macDlg.populateLeftLists("");
|
||||
macDlg.maZonesChanged = true;
|
||||
return true;
|
||||
} else {
|
||||
bottomLbl.setText("No zones have been deleted.");
|
||||
}
|
||||
return null;
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Save selected zones.
|
||||
*
|
||||
* @param area
|
||||
* Original zone ID
|
||||
* @param areaStr
|
||||
* New zone ID
|
||||
* @param latStr
|
||||
* Latitude
|
||||
* @param lonStr
|
||||
* Longitude
|
||||
* @throws NumberFormatException
|
||||
*/
|
||||
private void saveSelected() {
|
||||
|
||||
if (zoneList.getItemCount() != 0) {
|
||||
String area = zoneList.getItem(zoneList.getSelectionIndex());
|
||||
String latStr = latTF.getText();
|
||||
String lontStr = lonTF.getText();
|
||||
if (latStr == null || latStr.isEmpty() || lontStr == null
|
||||
|| lontStr.isEmpty()) {
|
||||
macDlg.latLonErrorMsg(latStr, lontStr);
|
||||
return;
|
||||
} else {
|
||||
try {
|
||||
double lat = Double.parseDouble(latStr);
|
||||
double lon = Double.parseDouble(lontStr);
|
||||
if (lat > 90.0 || lat < -90.0 || lon > 180.0
|
||||
|| lon < -180.0) {
|
||||
macDlg.latLonErrorMsg(latStr, lontStr);
|
||||
return;
|
||||
}
|
||||
ZoneType type = ZoneType.REGULAR;
|
||||
if (marineRdo.getSelection()) {
|
||||
type = ZoneType.MARITIME;
|
||||
}
|
||||
// Replace previously added zone
|
||||
macDlg.configMgr.removeArea(area);
|
||||
macDlg.configMgr.removeAddedArea(area);
|
||||
macDlg.configMgr.addArea(area, lat, lon, type);
|
||||
populate();
|
||||
// Return cursor to the top of the list.
|
||||
zoneList.select(0);
|
||||
} catch (NumberFormatException e) {
|
||||
macDlg.latLonErrorMsg(latStr, lontStr);
|
||||
return;
|
||||
}
|
||||
}
|
||||
private void saveSelected(String area, String areaStr, String latStr,
|
||||
String lonStr) throws NumberFormatException {
|
||||
FSSObsMonitorConfigurationManager cfgMgr = macDlg.getInstance();
|
||||
java.util.List<StationIdXML> stationIds;
|
||||
if (macDlg.getMaZones().contains(area)) {
|
||||
stationIds = cfgMgr.getAreaXml(area).getStationIds();
|
||||
} else if (macDlg.getAdditionalZones().contains(area)) {
|
||||
stationIds = cfgMgr.getAdjAreaXML(area).getStationIds();
|
||||
} else {
|
||||
bottomLbl.setText("No zones have been edited.");
|
||||
return;
|
||||
}
|
||||
double lat = Double.parseDouble(latStr);
|
||||
double lon = Double.parseDouble(lonStr);
|
||||
if (lat > AddNewZoneDlg.upLatBound || lat < AddNewZoneDlg.lowLatBound || lon > AddNewZoneDlg.upLonBound || lon < AddNewZoneDlg.lowLonBound) {
|
||||
macDlg.latLonErrorMsg(latStr, lonStr);
|
||||
return;
|
||||
}
|
||||
ZoneType type = ZoneType.REGULAR;
|
||||
if (areaStr.charAt(2) != 'C') {
|
||||
type = (ZoneType.MARITIME);
|
||||
}
|
||||
AreaIdXML areaXML = new AreaIdXML();
|
||||
areaXML.setAreaId(areaStr);
|
||||
areaXML.setCLat(lat);
|
||||
areaXML.setCLon(lon);
|
||||
areaXML.setType(type);
|
||||
areaXML.setStationIds(stationIds);
|
||||
// Replace previously added zone
|
||||
if (cfgMgr.getAreaList().contains(area)) {
|
||||
if (macDlg.getMaZones().contains(area)) {
|
||||
int idx = macDlg.getMaZones().indexOf(area);
|
||||
macDlg.getMaZones().set(idx, areaXML.getAreaId());
|
||||
}
|
||||
cfgMgr.replaceArea(cfgMgr.getAreaXml(area), areaXML);
|
||||
} else if (macDlg.getAdditionalZones().contains(area)) {
|
||||
if (macDlg.getAdditionalZones().contains(area)) {
|
||||
int idx = macDlg.getAdditionalZones().indexOf(area);
|
||||
macDlg.getAdditionalZones().set(idx, areaXML.getAreaId());
|
||||
}
|
||||
cfgMgr.replaceAdjArea(cfgMgr.getAdjAreaXML(area), areaXML);
|
||||
}
|
||||
populate(areaStr);
|
||||
// Return cursor to the list.
|
||||
zoneList.select(zoneList.indexOf(areaStr));
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
@ -21,7 +21,9 @@ package com.raytheon.uf.viz.monitor.ui.dialogs;
|
|||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.LinkedList;
|
||||
|
||||
import org.eclipse.jface.resource.ImageDescriptor;
|
||||
import org.eclipse.swt.SWT;
|
||||
|
@ -47,7 +49,7 @@ import com.raytheon.uf.common.localization.exception.LocalizationException;
|
|||
import com.raytheon.uf.common.monitor.config.FSSObsMonitorConfigurationManager;
|
||||
import com.raytheon.uf.common.monitor.data.CommonConfig;
|
||||
import com.raytheon.uf.common.monitor.data.CommonConfig.AppName;
|
||||
import com.raytheon.uf.common.monitor.xml.AreaIdXML.ZoneType;
|
||||
import com.raytheon.uf.common.monitor.xml.AreaIdXML;
|
||||
import com.raytheon.uf.common.serialization.SerializationException;
|
||||
import com.raytheon.uf.common.status.IUFStatusHandler;
|
||||
import com.raytheon.uf.common.status.UFStatus;
|
||||
|
@ -83,6 +85,9 @@ import com.raytheon.viz.ui.dialogs.ICloseCallback;
|
|||
* Nov 12, 2014 3650 skorolev Added confirmation box for unsaved changes in the dialog.
|
||||
* Mar 08, 2015 3888 dhladky Restored threshold pop-up when adding new stations/zones.
|
||||
* Sep 18, 2015 3873 skorolev Added formIsValid method.
|
||||
* Oct 19, 2015 3841 skorolev Corrected formIsValid messages.
|
||||
* Nov 12, 2015 3841 dhladky Augmented Slav's fix for moving platforms.
|
||||
* Dec 02, 2015 3873 dhladky Pulled 3841 to 16.1.1.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -185,7 +190,7 @@ public abstract class MonitoringAreaConfigDlg extends CaveSWTDialog implements
|
|||
private Font controlFont;
|
||||
|
||||
/** Application name. **/
|
||||
private CommonConfig.AppName appName;
|
||||
private final CommonConfig.AppName appName;
|
||||
|
||||
/** The current site. **/
|
||||
protected static String currentSite = null;
|
||||
|
@ -194,13 +199,13 @@ public abstract class MonitoringAreaConfigDlg extends CaveSWTDialog implements
|
|||
private java.util.List<String> maZones = null;
|
||||
|
||||
/** monitor area zones status. */
|
||||
protected boolean maZonesRemoved = false;
|
||||
protected boolean maZonesChanged = false;
|
||||
|
||||
/** monitor area stations **/
|
||||
private java.util.List<String> maStations = null;
|
||||
|
||||
/** monitor area stations status. */
|
||||
protected boolean maStationsRemoved = false;
|
||||
protected boolean maStationsChanged = false;
|
||||
|
||||
/** monitor area additional zones **/
|
||||
private java.util.List<String> additionalZones = null;
|
||||
|
@ -234,11 +239,12 @@ public abstract class MonitoringAreaConfigDlg extends CaveSWTDialog implements
|
|||
/** Flag set when user wants to close with unsaved modifications. */
|
||||
protected boolean closeFlag = false;
|
||||
|
||||
private final static String INVALID_AREA_MSG = "Invalid Area ID = '%s' entered.\n"
|
||||
private final static String INVALID_AREA_MSG_C = "Invalid Area ID = '%s' entered.\n"
|
||||
+ "Please enter a correctly formatted Area ID:\n"
|
||||
+ "Zone ID must have six characters.\n"
|
||||
+ "A third character should be C for county and Z for marine zone.\n"
|
||||
+ "Use only capital characters.";
|
||||
+ "Zone ID must have three letters and three digits.\n"
|
||||
+ "A third character should be C for county";
|
||||
|
||||
private final static String INVALID_AREA_MSG_Z = "and Z for marine zone.\n";
|
||||
|
||||
private final static String INVALID_COORD_MSG = "Invalid Lat/Lon entered:\n"
|
||||
+ "Latitude = '%s'\n"
|
||||
|
@ -250,6 +256,13 @@ public abstract class MonitoringAreaConfigDlg extends CaveSWTDialog implements
|
|||
private final static String MODIFY_THRESHOLD_MSG = "New zones have been added, and their monitoring thresholds "
|
||||
+ "have been set to default values; would you like to modify "
|
||||
+ "their threshold values now?";
|
||||
|
||||
|
||||
/** County constant char */
|
||||
private static final char C = 'C';
|
||||
|
||||
/** Zone constant char */
|
||||
private static final char Z = 'Z';
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
|
@ -350,7 +363,7 @@ public abstract class MonitoringAreaConfigDlg extends CaveSWTDialog implements
|
|||
// initialize zone/station lists
|
||||
initZoneStationLists();
|
||||
// Populate the dialog
|
||||
populateLeftLists();
|
||||
populateLeftLists("");
|
||||
setValues();
|
||||
shell.addShellListener(new ShellAdapter() {
|
||||
@Override
|
||||
|
@ -422,7 +435,7 @@ public abstract class MonitoringAreaConfigDlg extends CaveSWTDialog implements
|
|||
getDisplay().getSystemCursor(SWT.CURSOR_WAIT));
|
||||
mode = Mode.Zone;
|
||||
changeZoneStationControls();
|
||||
populateLeftLists();
|
||||
populateLeftLists("");
|
||||
if (!getShell().isDisposed()) {
|
||||
getShell().setCursor(null);
|
||||
}
|
||||
|
@ -438,7 +451,7 @@ public abstract class MonitoringAreaConfigDlg extends CaveSWTDialog implements
|
|||
getDisplay().getSystemCursor(SWT.CURSOR_WAIT));
|
||||
mode = Mode.Station;
|
||||
changeZoneStationControls();
|
||||
populateLeftLists();
|
||||
populateLeftLists("");
|
||||
if (!getShell().isDisposed()) {
|
||||
getShell().setCursor(null);
|
||||
}
|
||||
|
@ -515,7 +528,6 @@ public abstract class MonitoringAreaConfigDlg extends CaveSWTDialog implements
|
|||
@Override
|
||||
public void widgetSelected(SelectionEvent event) {
|
||||
removeZoneStn();
|
||||
maZonesRemoved = true;
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -611,7 +623,6 @@ public abstract class MonitoringAreaConfigDlg extends CaveSWTDialog implements
|
|||
@Override
|
||||
public void widgetSelected(SelectionEvent event) {
|
||||
removeAssociated();
|
||||
maStationsRemoved = true;
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -914,7 +925,7 @@ public abstract class MonitoringAreaConfigDlg extends CaveSWTDialog implements
|
|||
public void dialogClosed(Object returnValue) {
|
||||
if ((Boolean) returnValue) {
|
||||
// Update the dialog
|
||||
populateLeftLists();
|
||||
populateLeftLists("");
|
||||
}
|
||||
addNewZoneDlg = null;
|
||||
}
|
||||
|
@ -933,7 +944,7 @@ public abstract class MonitoringAreaConfigDlg extends CaveSWTDialog implements
|
|||
public void dialogClosed(Object returnValue) {
|
||||
if ((Boolean) returnValue) {
|
||||
// Update the dialog
|
||||
populateLeftLists();
|
||||
populateLeftLists("");
|
||||
}
|
||||
addNewStnDlg = null;
|
||||
}
|
||||
|
@ -963,7 +974,9 @@ public abstract class MonitoringAreaConfigDlg extends CaveSWTDialog implements
|
|||
public void dialogClosed(Object returnValue) {
|
||||
if (returnValue instanceof String) {
|
||||
// Update the edit dialog
|
||||
populateLeftLists();
|
||||
String selectedZone = returnValue.toString();
|
||||
maZones.remove(selectedZone);
|
||||
populateLeftLists("");
|
||||
}
|
||||
editDlg = null;
|
||||
}
|
||||
|
@ -977,10 +990,9 @@ public abstract class MonitoringAreaConfigDlg extends CaveSWTDialog implements
|
|||
@Override
|
||||
public void dialogClosed(Object returnValue) {
|
||||
if (returnValue instanceof String) {
|
||||
// Update the delete dialog
|
||||
String selectedStn = returnValue.toString();
|
||||
maStations.remove(selectedStn);
|
||||
populateLeftLists();
|
||||
String station = returnValue.toString();
|
||||
maStations.remove(station);
|
||||
populateLeftLists("");
|
||||
}
|
||||
deleteStnDlg = null;
|
||||
}
|
||||
|
@ -1011,13 +1023,14 @@ public abstract class MonitoringAreaConfigDlg extends CaveSWTDialog implements
|
|||
maRegionalList.setItems(additionalZones
|
||||
.toArray(new String[additionalZones.size()]));
|
||||
}
|
||||
maRegionalList.select(0);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Populates the zone list boxes.
|
||||
*/
|
||||
private void populateLeftLists() {
|
||||
protected void populateLeftLists(String selected) {
|
||||
if (mode == Mode.Zone) {
|
||||
/** Zone Mode */
|
||||
Collections.sort(maZones);
|
||||
|
@ -1037,7 +1050,11 @@ public abstract class MonitoringAreaConfigDlg extends CaveSWTDialog implements
|
|||
}
|
||||
if (monitorAreaList.getItemCount() > 0) {
|
||||
// select top of the list
|
||||
monitorAreaList.setSelection(0);
|
||||
if (selected.equals("")) {
|
||||
monitorAreaList.setSelection(0);
|
||||
} else {
|
||||
monitorAreaList.setSelection(monitorAreaList.indexOf(selected));
|
||||
}
|
||||
handleMonitorAreaListSelection();
|
||||
}
|
||||
}
|
||||
|
@ -1071,6 +1088,8 @@ public abstract class MonitoringAreaConfigDlg extends CaveSWTDialog implements
|
|||
configMgr.setShipDistance(shipDistance.getSelection());
|
||||
configMgr.setUseAlgorithms(fogChk.getSelection());
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1116,6 +1135,7 @@ public abstract class MonitoringAreaConfigDlg extends CaveSWTDialog implements
|
|||
if (mode == Mode.Zone) {
|
||||
String zone = additionalList.getItem(additionalList
|
||||
.getSelectionIndex());
|
||||
AreaIdXML zoneXML = configMgr.getAdjAreaXML(zone);
|
||||
additionalList.remove(additionalList.getSelectionIndex());
|
||||
maZones.add(zone);
|
||||
Collections.sort(maZones);
|
||||
|
@ -1123,13 +1143,12 @@ public abstract class MonitoringAreaConfigDlg extends CaveSWTDialog implements
|
|||
.setItems(maZones.toArray(new String[maZones.size()]));
|
||||
monitorAreaList.setSelection(maZones.indexOf(zone));
|
||||
additionalZones.remove(zone);
|
||||
configMgr.addArea(zone, zone.charAt(2) == 'Z' ? ZoneType.MARITIME
|
||||
: ZoneType.REGULAR);
|
||||
configMgr.addArea(zoneXML);
|
||||
handleMonitorAreaListSelection();
|
||||
if (!configMgr.getAddedZones().contains(zone)) {
|
||||
configMgr.getAddedZones().add(zone);
|
||||
}
|
||||
configMgr.removeAdjArea(zone);
|
||||
handleMonitorAreaListSelection();
|
||||
configMgr.removeAdjArea(zoneXML);
|
||||
} else { // Station mode
|
||||
if (associatedList.getSelectionCount() == 0) {
|
||||
showMessage(shell, SWT.ERROR, "Selection Needed",
|
||||
|
@ -1149,10 +1168,12 @@ public abstract class MonitoringAreaConfigDlg extends CaveSWTDialog implements
|
|||
.getSelectionIndex());
|
||||
String stnId = stn.substring(0, stn.indexOf('#'));
|
||||
String stnType = stn.substring(stn.indexOf('#') + 1);
|
||||
configMgr.addStation(zone, stnId, stnType, configMgr
|
||||
configMgr.addNewStation(zone, stnId, stnType, configMgr
|
||||
.getAddedStations().contains(stnId));
|
||||
handleMonitorAreaListSelection();
|
||||
}
|
||||
|
||||
maZonesChanged = true;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1171,10 +1192,11 @@ public abstract class MonitoringAreaConfigDlg extends CaveSWTDialog implements
|
|||
}
|
||||
String entry = monitorAreaList.getItem(monitorAreaList
|
||||
.getSelectionIndex());
|
||||
monitorAreaList.remove(monitorAreaList.getSelectionIndex());
|
||||
associatedList.removeAll();
|
||||
|
||||
if (mode == Mode.Zone) {
|
||||
monitorAreaList.remove(monitorAreaList.getSelectionIndex());
|
||||
// entry is a zone to remove.
|
||||
AreaIdXML zoneXML = configMgr.getAreaXml(entry);
|
||||
if (!additionalZones.contains(entry)) {
|
||||
additionalZones.add(entry);
|
||||
}
|
||||
|
@ -1183,24 +1205,33 @@ public abstract class MonitoringAreaConfigDlg extends CaveSWTDialog implements
|
|||
.toArray(new String[additionalZones.size()]));
|
||||
additionalList.setSelection(additionalZones.indexOf(entry));
|
||||
maZones.remove(entry);
|
||||
configMgr.removeArea(entry);
|
||||
configMgr.removeArea(zoneXML);
|
||||
if (configMgr.getAddedZones().contains(entry)) {
|
||||
configMgr.getAddedZones().remove(entry);
|
||||
}
|
||||
|
||||
configMgr.addAdjArea(entry,
|
||||
entry.charAt(2) == 'Z' ? ZoneType.MARITIME
|
||||
: ZoneType.REGULAR);
|
||||
} else { // Station mode
|
||||
// entry is a station to remove.
|
||||
configMgr.addAdjArea(zoneXML);
|
||||
associatedList.removeAll();
|
||||
} else { // Station mode. entry is name#type of station.
|
||||
if (associatedList.getItemCount() >= 1
|
||||
&& associatedList.getSelectionIndex() < 0) {
|
||||
showMessage(shell, SWT.ERROR, "Selection Needed",
|
||||
"You must select a associated area zone to remove.");
|
||||
return;
|
||||
}
|
||||
monitorAreaList.remove(monitorAreaList.getSelectionIndex());
|
||||
String stnZone = associatedList.getSelection()[0];
|
||||
additionalStns.add(entry);
|
||||
Collections.sort(additionalStns);
|
||||
additionalList.setItems(additionalStns
|
||||
.toArray(new String[additionalStns.size()]));
|
||||
additionalList.setSelection(additionalStns.indexOf(entry));
|
||||
maStations.remove(entry);
|
||||
configMgr.removeStation(entry.substring(0, entry.indexOf('#')));
|
||||
// station removes from configuration XML files
|
||||
configMgr.removeStationFromArea(stnZone,
|
||||
entry.substring(0, entry.indexOf('#')));
|
||||
}
|
||||
|
||||
maZonesChanged = true;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1233,11 +1264,8 @@ public abstract class MonitoringAreaConfigDlg extends CaveSWTDialog implements
|
|||
}
|
||||
String entry = maRegionalList.getItem(maRegionalList
|
||||
.getSelectionIndex());
|
||||
String[] items = associatedList.getItems();
|
||||
ArrayList<String> itemList = new ArrayList<String>();
|
||||
for (String item : items) {
|
||||
itemList.add(item);
|
||||
}
|
||||
java.util.List<String> itemList = new LinkedList<String>(
|
||||
Arrays.asList(associatedList.getItems()));
|
||||
if (itemList.contains(entry)) {
|
||||
/**
|
||||
* if selected entry is already in associated list: highlight the
|
||||
|
@ -1266,26 +1294,28 @@ public abstract class MonitoringAreaConfigDlg extends CaveSWTDialog implements
|
|||
.getSelectionIndex());
|
||||
String stnId = entry.substring(0, entry.indexOf('#'));
|
||||
String stnType = entry.substring(entry.indexOf('#') + 1);
|
||||
configMgr.addStation(zone, stnId, stnType, configMgr
|
||||
|
||||
configMgr.addNewStation(zone, stnId, stnType, configMgr
|
||||
.getAddedStations().contains(stnId));
|
||||
} else { // Station mode
|
||||
if (regionalRdo.getSelection()) {
|
||||
// entry is a zone selected from additional zones
|
||||
AreaIdXML zoneXML = configMgr.getAdjAreaXML(entry);
|
||||
maZones.add(entry);
|
||||
Collections.sort(maZones);
|
||||
additionalZones.remove(entry);
|
||||
maRegionalList.remove(maRegionalList.getSelectionIndex());
|
||||
configMgr.addArea(entry,
|
||||
entry.charAt(2) == 'Z' ? ZoneType.MARITIME
|
||||
: ZoneType.REGULAR);
|
||||
configMgr.addArea(zoneXML);
|
||||
}
|
||||
String stn = monitorAreaList.getItem(monitorAreaList
|
||||
.getSelectionIndex());
|
||||
String stnId = stn.substring(0, stn.indexOf('#'));
|
||||
String stnType = stn.substring(stn.indexOf('#') + 1);
|
||||
configMgr.addStation(entry, stnId, stnType, configMgr
|
||||
configMgr.addNewStation(entry, stnId, stnType, configMgr
|
||||
.getAddedStations().contains(stnId));
|
||||
}
|
||||
|
||||
maStationsChanged = true;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1308,7 +1338,7 @@ public abstract class MonitoringAreaConfigDlg extends CaveSWTDialog implements
|
|||
if (mode == Mode.Zone) {
|
||||
String zone = monitorAreaList.getItem(monitorAreaList
|
||||
.getSelectionIndex());
|
||||
configMgr.removeStation(zone, entry);
|
||||
configMgr.removeStationFromArea(zone, entry);
|
||||
java.util.List<String> zones = configMgr.getAreaByStationId(entry
|
||||
.substring(0, entry.indexOf('#')));
|
||||
if (zones.size() == 0) {
|
||||
|
@ -1324,11 +1354,15 @@ public abstract class MonitoringAreaConfigDlg extends CaveSWTDialog implements
|
|||
.toArray(new String[additionalStns.size()]));
|
||||
}
|
||||
}
|
||||
|
||||
} else { // Station mode
|
||||
String stn = monitorAreaList.getItem(monitorAreaList
|
||||
.getSelectionIndex());
|
||||
configMgr.removeStation(entry, stn);
|
||||
configMgr.removeStationFromArea(entry, stn);
|
||||
|
||||
}
|
||||
|
||||
maStationsChanged = true;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1411,7 +1445,7 @@ public abstract class MonitoringAreaConfigDlg extends CaveSWTDialog implements
|
|||
public void addZoneToMA(String zone) {
|
||||
maZones.add(zone);
|
||||
Collections.sort(maZones);
|
||||
populateLeftLists();
|
||||
populateLeftLists(zone);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1423,7 +1457,7 @@ public abstract class MonitoringAreaConfigDlg extends CaveSWTDialog implements
|
|||
public void addStationToMA(String stnWithType) {
|
||||
maStations.add(stnWithType);
|
||||
Collections.sort(maStations);
|
||||
populateLeftLists();
|
||||
populateLeftLists("");
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -1453,11 +1487,26 @@ public abstract class MonitoringAreaConfigDlg extends CaveSWTDialog implements
|
|||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Testing input in the form.
|
||||
*
|
||||
* @param area
|
||||
* @param latString
|
||||
* @param lonString
|
||||
* @return
|
||||
*/
|
||||
public boolean formIsValid(String area, String latString, String lonString) {
|
||||
boolean retVal = true;
|
||||
if (area.equals("") || area.length() != 6
|
||||
|| (area.charAt(2) != 'C' && area.charAt(2) != 'Z')) {
|
||||
displayInputErrorMsg(String.format(INVALID_AREA_MSG, area));
|
||||
|| (area.charAt(2) != C && area.charAt(2) != Z)) {
|
||||
StringBuilder invalidMsg = new StringBuilder(INVALID_AREA_MSG_C);
|
||||
if (appName.equals(AppName.SNOW)) {
|
||||
invalidMsg.append(".");
|
||||
} else {
|
||||
invalidMsg.append(" ");
|
||||
invalidMsg.append(INVALID_AREA_MSG_Z);
|
||||
}
|
||||
displayInputErrorMsg(String.format(invalidMsg.toString(), area));
|
||||
retVal = false;
|
||||
}
|
||||
if (latString == null || latString.isEmpty() || lonString == null
|
||||
|
@ -1514,6 +1563,7 @@ public abstract class MonitoringAreaConfigDlg extends CaveSWTDialog implements
|
|||
* @see
|
||||
* com.raytheon.uf.viz.monitor.ui.dialogs.INewZoneStnAction#latLonErrorMsg()
|
||||
*/
|
||||
@Override
|
||||
public void latLonErrorMsg(String latStr, String lonStr) {
|
||||
MessageBox messageBox = new MessageBox(shell, SWT.ICON_INFORMATION
|
||||
| SWT.OK);
|
||||
|
@ -1526,8 +1576,8 @@ public abstract class MonitoringAreaConfigDlg extends CaveSWTDialog implements
|
|||
*/
|
||||
protected void resetStatus() {
|
||||
this.timeWindowChanged = false;
|
||||
this.maZonesRemoved = false;
|
||||
this.maStationsRemoved = false;
|
||||
this.maZonesChanged = false;
|
||||
this.maStationsChanged = false;
|
||||
this.shipDistanceChanged = false;
|
||||
this.fogChkChanged = false;
|
||||
}
|
||||
|
@ -1541,8 +1591,8 @@ public abstract class MonitoringAreaConfigDlg extends CaveSWTDialog implements
|
|||
if (!configMgr.getAddedZones().isEmpty()
|
||||
|| !configMgr.getAddedStations().isEmpty()
|
||||
|| this.timeWindowChanged || this.shipDistanceChanged
|
||||
|| this.fogChkChanged || this.maZonesRemoved
|
||||
|| this.maStationsRemoved) {
|
||||
|| this.fogChkChanged || this.maZonesChanged
|
||||
|| this.maStationsChanged) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
@ -1612,4 +1662,4 @@ public abstract class MonitoringAreaConfigDlg extends CaveSWTDialog implements
|
|||
* @return manager
|
||||
*/
|
||||
protected abstract FSSObsMonitorConfigurationManager getInstance();
|
||||
}
|
||||
}
|
|
@ -100,6 +100,8 @@ import com.vividsolutions.jts.io.ParseException;
|
|||
* Sep 15, 2014 3220 skorolev Added refreshZoneTableData method.
|
||||
* Nov 03, 2014 3741 skorolev Updated zoom procedures.
|
||||
* Sep 25, 2015 3873 skorolev Added center definition for moving platforms.
|
||||
* Nov 09, 2015 3841 dhladky Update all tables when zones/stations are updated.
|
||||
* Dec 02, 2015 3873 dhladky Pulled 3841 to 16.1.1.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -231,7 +233,7 @@ public abstract class ZoneTableDlg extends CaveSWTDialog implements
|
|||
protected abstract void shellDisposeAction();
|
||||
|
||||
/** List of opened plots. **/
|
||||
private Map<String, CaveSWTDialog> openedDlgs = new HashMap<String, CaveSWTDialog>();
|
||||
private final Map<String, CaveSWTDialog> openedDlgs = new HashMap<String, CaveSWTDialog>();
|
||||
|
||||
/** row index in the station table. **/
|
||||
public int rowIndex;
|
||||
|
@ -490,10 +492,7 @@ public abstract class ZoneTableDlg extends CaveSWTDialog implements
|
|||
public void updateTableDlg(ObHourReports obHrData) {
|
||||
nominalTime = obHrData.getNominalTime();
|
||||
updateZoneTable(nominalTime);
|
||||
if (!selectedZone.equals("")
|
||||
&& obHrData.getHourReports().containsKey(selectedZone)) {
|
||||
updateStationTable(nominalTime);
|
||||
}
|
||||
updateStationTable(nominalTime);
|
||||
updateNominalTimeLabel(nominalTime);
|
||||
}
|
||||
|
||||
|
@ -795,8 +794,8 @@ public abstract class ZoneTableDlg extends CaveSWTDialog implements
|
|||
private void zoomToZone(String zone) throws Exception {
|
||||
Coordinate zoneCenter = MonitorAreaUtils.getZoneCenter(zone);
|
||||
if (zoneCenter == null) { // Test a newly added zone.
|
||||
AreaIdXML zoneXML = configMgr.getAreaXml(zone);
|
||||
if (zoneXML != null // Coordinates do not the null values.
|
||||
AreaIdXML zoneXML = getMonitorAreaConfigInstance().getAreaXml(zone);
|
||||
if (zoneXML != null
|
||||
&& (zoneXML.getCLon() != null || zoneXML.getCLat() != null)) {
|
||||
zoneCenter = new Coordinate(zoneXML.getCLon(),
|
||||
zoneXML.getCLat());
|
||||
|
@ -1013,6 +1012,7 @@ public abstract class ZoneTableDlg extends CaveSWTDialog implements
|
|||
*/
|
||||
public void refreshZoneTableData(ObMultiHrsReports obData) {
|
||||
obData.getObHourReports().updateZones();
|
||||
obData.updateTableCache();
|
||||
this.updateTableDlg(obData.getObHourReports());
|
||||
}
|
||||
}
|
||||
}
|
|
@ -66,15 +66,17 @@ import com.raytheon.viz.ui.personalities.awips.CAVE;
|
|||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Aug 4, 2011 njensen Initial creation
|
||||
* Apr 23, 2013 1939 randerso Return null from initializeSerialization
|
||||
* Nov 14, 2013 2361 njensen Remove initializeSerialization()
|
||||
* Nov 06, 2014 3356 njensen Always initialize ILocalizationAdapter
|
||||
* in case cache preference is not enabled
|
||||
* Feb 23, 2015 4164 dlovely Call AlertViz initialize.
|
||||
* Jun 26, 2015 4474 bsteffen Register the PathManager as an OSGi service.
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------- -------- --------- --------------------------------------------
|
||||
* Aug 04, 2011 10477 njensen Initial creation
|
||||
* Apr 23, 2013 1939 randerso Return null from initializeSerialization
|
||||
* Nov 14, 2013 2361 njensen Remove initializeSerialization()
|
||||
* Nov 06, 2014 3356 njensen Always initialize ILocalizationAdapter in
|
||||
* case cache preference is not enabled
|
||||
* Feb 23, 2015 4164 dlovely Call AlertViz initialize.
|
||||
* Jun 26, 2015 4474 bsteffen Register the PathManager as an OSGi service.
|
||||
* Dec 04, 2015 5169 bsteffen Allow ProductAlertObserver to send messages
|
||||
* to the AutoUpdater
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -215,11 +217,7 @@ public class ThinClientComponent extends CAVE implements IThinClientComponent {
|
|||
@Override
|
||||
protected void initializeObservers() {
|
||||
ThinClientNotificationManagerJob.getInstance();
|
||||
IPreferenceStore store = Activator.getDefault().getPreferenceStore();
|
||||
if (store.getBoolean(ThinClientPreferenceConstants.P_DISABLE_JMS) == false) {
|
||||
// JMS Enabled, register product alerts
|
||||
registerProductAlerts();
|
||||
}
|
||||
registerProductAlerts();
|
||||
initializeAlertViz();
|
||||
}
|
||||
|
||||
|
|
|
@ -28,7 +28,6 @@ import com.raytheon.uf.viz.core.alerts.AlertMessage;
|
|||
import com.raytheon.uf.viz.thinclient.Activator;
|
||||
import com.raytheon.uf.viz.thinclient.preferences.ThinClientPreferenceConstants;
|
||||
import com.raytheon.uf.viz.thinclient.refresh.TimedRefresher.RefreshTimerTask;
|
||||
import com.raytheon.viz.alerts.jobs.AutoUpdater;
|
||||
import com.raytheon.viz.alerts.observers.ProductAlertObserver;
|
||||
|
||||
/**
|
||||
|
@ -40,10 +39,12 @@ import com.raytheon.viz.alerts.observers.ProductAlertObserver;
|
|||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Nov 10, 2011 mschenke Initial creation
|
||||
* Feb 21, 2014 DR 16744 D. Friedman Update all alert observers
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------- -------- ---------- -------------------------------------------
|
||||
* Nov 10, 2011 7393 mschenke Initial creation
|
||||
* Feb 21, 2014 16744 dfriedman Update all alert observers
|
||||
* Dec 04, 2015 5169 bsteffen Allow ProductAlertObserver to send messages
|
||||
* to the AutoUpdater
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -71,8 +72,6 @@ public class DataRefreshTask implements RefreshTimerTask {
|
|||
s.add(am.dataURI);
|
||||
}
|
||||
ProductAlertObserver.processDataURIAlerts(s);
|
||||
|
||||
new AutoUpdater().alertArrived(alerts);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -29,6 +29,7 @@ import java.util.Set;
|
|||
import java.util.TimeZone;
|
||||
|
||||
import com.raytheon.uf.common.dataplugin.PluginDataObject;
|
||||
import com.raytheon.uf.common.dataplugin.grid.GridConstants;
|
||||
import com.raytheon.uf.common.dataquery.requests.DbQueryRequest;
|
||||
import com.raytheon.uf.common.dataquery.requests.RequestConstraint;
|
||||
import com.raytheon.uf.common.dataquery.requests.RequestConstraint.ConstraintType;
|
||||
|
@ -51,18 +52,20 @@ import com.raytheon.viz.grid.inv.RadarUpdater;
|
|||
import com.raytheon.viz.grid.util.RadarAdapter;
|
||||
|
||||
/**
|
||||
* TODO Add Description
|
||||
* Replacement for {@link DataUpdateTree} which will perform updates by querying
|
||||
* the server for updates for any tree items.
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Dec 13, 2011 bsteffen Initial creation
|
||||
* Feb 21, 2014 DR 16744 D. Friedman Add radar/grid updates
|
||||
* Apr 1, 2014 DR 17220 D. Friedman Handle uninitialized grid inventory
|
||||
* Dec 15, 2014 3923 bsteffen Retrieve pdo for grid instead of dataURI.
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------- -------- ---------- ------------------------------------------
|
||||
* Dec 13, 2011 bsteffen Initial creation
|
||||
* Feb 21, 2014 16744 dfriedman Add radar/grid updates
|
||||
* Apr 01, 2014 17220 dfriedman Handle uninitialized grid inventory
|
||||
* Dec 15, 2014 3923 bsteffen Retrieve pdo for grid instead of dataURI.
|
||||
* Dec 04, 2015 5169 bsteffen Do not send duplicate grid updates.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -107,6 +110,14 @@ public class ThinClientDataUpdateTree extends DataUpdateTree {
|
|||
continue;
|
||||
}
|
||||
Map<String, RequestConstraint> metadata = pair.metadata;
|
||||
RequestConstraint pluginConstraint = metadata
|
||||
.get(PluginDataObject.PLUGIN_NAME_ID);
|
||||
if (pluginConstraint != null
|
||||
&& (pluginConstraint.evaluate(GridConstants.GRID) || pluginConstraint
|
||||
.evaluate("radar"))) {
|
||||
/* Grid and radar do their updates differently. */
|
||||
continue;
|
||||
}
|
||||
metadata = new HashMap<String, RequestConstraint>(metadata);
|
||||
metadata.put("insertTime", new RequestConstraint(time,
|
||||
ConstraintType.GREATER_THAN));
|
||||
|
@ -176,7 +187,8 @@ public class ThinClientDataUpdateTree extends DataUpdateTree {
|
|||
private void getGridUpdates(String time, Set<AlertMessage> messages) {
|
||||
Map<String, RequestConstraint> newQuery = new HashMap<String, RequestConstraint>();
|
||||
DbQueryRequest dbRequest = new DbQueryRequest();
|
||||
newQuery.put("pluginName", new RequestConstraint("grid"));
|
||||
newQuery.put(PluginDataObject.PLUGIN_NAME_ID, new RequestConstraint(
|
||||
GridConstants.GRID));
|
||||
newQuery.put("insertTime", new RequestConstraint(time,
|
||||
ConstraintType.GREATER_THAN));
|
||||
dbRequest.setConstraints(newQuery);
|
||||
|
|
|
@ -41,12 +41,12 @@ import org.eclipse.swt.widgets.Group;
|
|||
import org.eclipse.swt.widgets.Label;
|
||||
import org.eclipse.swt.widgets.Shell;
|
||||
import org.eclipse.swt.widgets.Text;
|
||||
import org.opengis.referencing.FactoryException;
|
||||
import org.opengis.referencing.datum.PixelInCell;
|
||||
import org.opengis.referencing.operation.TransformException;
|
||||
|
||||
import com.raytheon.uf.common.geospatial.ReferencedCoordinate;
|
||||
import com.raytheon.uf.common.hydro.spatial.HRAP;
|
||||
import com.raytheon.uf.common.status.IUFStatusHandler;
|
||||
import com.raytheon.uf.common.status.UFStatus;
|
||||
import com.raytheon.uf.viz.app.launcher.handlers.AppLauncherHandler;
|
||||
import com.raytheon.viz.mpe.ui.MPEDisplayManager;
|
||||
import com.raytheon.viz.mpe.ui.actions.GetClimateSource;
|
||||
|
@ -68,6 +68,8 @@ import com.vividsolutions.jts.geom.Coordinate;
|
|||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Apr 13, 2009 snaples Initial creation
|
||||
* Dec 08, 2015 5179 bkowal Ensure the grid remains displayed when this dialog
|
||||
* is closed. Eliminate warnings and e print stack trace.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -77,8 +79,11 @@ import com.vividsolutions.jts.geom.Coordinate;
|
|||
|
||||
public class EditTempStationsDialog extends AbstractMPEDialog {
|
||||
|
||||
private static final IUFStatusHandler statusHandler = UFStatus
|
||||
.getHandler(EditTempStationsDialog.class);
|
||||
|
||||
private DailyQcUtils dqc = DailyQcUtils.getInstance();
|
||||
|
||||
|
||||
private Font font;
|
||||
|
||||
private String[] eval = new String[6];
|
||||
|
@ -95,7 +100,7 @@ public class EditTempStationsDialog extends AbstractMPEDialog {
|
|||
|
||||
private int pcpn_time_step = MPEDisplayManager.pcpn_time_step;
|
||||
|
||||
private int pcpn_time = dqc.pcpn_time;
|
||||
private int pcpn_time = DailyQcUtils.pcpn_time;
|
||||
|
||||
private StringBuilder tstnData = new StringBuilder();
|
||||
|
||||
|
@ -135,33 +140,21 @@ public class EditTempStationsDialog extends AbstractMPEDialog {
|
|||
|
||||
String tClimateSource = null;
|
||||
|
||||
// Ts ts[] = DailyQcUtils.ts;
|
||||
int tsmax = DailyQcUtils.tsmax;
|
||||
|
||||
int tsmax = dqc.tsmax;
|
||||
|
||||
int isom = dqc.isom;
|
||||
int isom = DailyQcUtils.isom;
|
||||
|
||||
int win_x;
|
||||
|
||||
int win_y;
|
||||
|
||||
// int gage_char[] = DailyQcUtils.gage_char;
|
||||
|
||||
int method = dqc.method;
|
||||
|
||||
// int qflag[] = DailyQcUtils.qflag;
|
||||
|
||||
// int dflag[] = DailyQcUtils.dflag;
|
||||
|
||||
String mbuf;
|
||||
|
||||
int naflag;
|
||||
|
||||
// ArrayList<Station> station = DailyQcUtils.temperature_stations;
|
||||
|
||||
// ReadTemperatureStationList rt = new ReadTemperatureStationList();
|
||||
|
||||
int max_stations = dqc.temperature_stations.size();
|
||||
int max_stations = DailyQcUtils.temperature_stations.size();
|
||||
|
||||
int i, m, x, y;
|
||||
|
||||
|
@ -169,9 +162,7 @@ public class EditTempStationsDialog extends AbstractMPEDialog {
|
|||
|
||||
int initial_pos;
|
||||
|
||||
// int[] func = DailyQcUtils.func;
|
||||
|
||||
int pcpn_day = dqc.pcpn_day;
|
||||
int pcpn_day = DailyQcUtils.pcpn_day;
|
||||
|
||||
Coordinate coord = new Coordinate();
|
||||
|
||||
|
@ -187,11 +178,11 @@ public class EditTempStationsDialog extends AbstractMPEDialog {
|
|||
try {
|
||||
coord = rcoord.asLatLon();
|
||||
} catch (Exception e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
statusHandler
|
||||
.error("Failed to convert ReferencedCoordinate to Coordinate.",
|
||||
e);
|
||||
}
|
||||
}
|
||||
// Envelope env = new Envelope(coord);
|
||||
|
||||
AbstractVizPerspectiveManager mgr = VizPerspectiveListener
|
||||
.getCurrentPerspectiveManager();
|
||||
|
@ -271,31 +262,32 @@ public class EditTempStationsDialog extends AbstractMPEDialog {
|
|||
|
||||
for (i = 0; i < max_stations; i++) {
|
||||
|
||||
if (dqc.tdata[pcpn_day].tstn[i].tlevel2[time_pos].data == -999) {
|
||||
if (DailyQcUtils.tdata[pcpn_day].tstn[i].tlevel2[time_pos].data == -999) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if ((dqc.tdata[pcpn_day].tstn[i].tlevel2[time_pos].data > QcTempOptionsDialog
|
||||
if ((DailyQcUtils.tdata[pcpn_day].tstn[i].tlevel2[time_pos].data > QcTempOptionsDialog
|
||||
.getPointFilterReverseValue())
|
||||
&& (dqc.tdata[pcpn_day].tstn[i].tlevel2[time_pos].data < 110.0)) {
|
||||
&& (DailyQcUtils.tdata[pcpn_day].tstn[i].tlevel2[time_pos].data < 110.0)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if ((dqc.temperature_stations.get(i).elev > 0)
|
||||
&& (dqc.temperature_stations.get(i).elev < dqc.elevation_filter_value)) {
|
||||
if ((DailyQcUtils.temperature_stations.get(i).elev > 0)
|
||||
&& (DailyQcUtils.temperature_stations.get(i).elev < DailyQcUtils.elevation_filter_value)) {
|
||||
continue;
|
||||
}
|
||||
if (dqc.tdata[pcpn_day].tstn[i].tlevel2[time_pos].data < QcTempOptionsDialog
|
||||
if (DailyQcUtils.tdata[pcpn_day].tstn[i].tlevel2[time_pos].data < QcTempOptionsDialog
|
||||
.getPointFilterValue()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
lat = dqc.temperature_stations.get(i).lat;
|
||||
lon = dqc.temperature_stations.get(i).lon;
|
||||
lat = DailyQcUtils.temperature_stations.get(i).lat;
|
||||
lon = DailyQcUtils.temperature_stations.get(i).lon;
|
||||
|
||||
for (m = 0; m < tsmax; m++) {
|
||||
char kd = dqc.temperature_stations.get(i).parm.charAt(4);
|
||||
if ((kd == dqc.ts[m].abr.charAt(1) && dqc.dflag[m + 1] == 1)) {
|
||||
char kd = DailyQcUtils.temperature_stations.get(i).parm
|
||||
.charAt(4);
|
||||
if ((kd == DailyQcUtils.ts[m].abr.charAt(1) && DailyQcUtils.dflag[m + 1] == 1)) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -305,8 +297,8 @@ public class EditTempStationsDialog extends AbstractMPEDialog {
|
|||
}
|
||||
|
||||
for (m = 0; m < 9; m++) {
|
||||
if (m == dqc.tdata[pcpn_day].tstn[i].tlevel2[time_pos].qual
|
||||
&& dqc.qflag[m] == 1) {
|
||||
if (m == DailyQcUtils.tdata[pcpn_day].tstn[i].tlevel2[time_pos].qual
|
||||
&& DailyQcUtils.qflag[m] == 1) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -325,8 +317,9 @@ public class EditTempStationsDialog extends AbstractMPEDialog {
|
|||
gridCell = rc.asGridCell(HRAP.getInstance().getGridGeometry(),
|
||||
PixelInCell.CELL_CORNER);
|
||||
} catch (Exception e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
statusHandler
|
||||
.error("Failed to convert ReferencedCoordinate to Coordinate.",
|
||||
e);
|
||||
}
|
||||
int x1 = (short) gridCell.x;
|
||||
int y1 = (short) gridCell.y;
|
||||
|
@ -334,16 +327,12 @@ public class EditTempStationsDialog extends AbstractMPEDialog {
|
|||
rc = new ReferencedCoordinate(coord);
|
||||
Coordinate hw = null;
|
||||
try {
|
||||
try {
|
||||
hw = rc.asGridCell(HRAP.getInstance().getGridGeometry(),
|
||||
PixelInCell.CELL_CORNER);
|
||||
} catch (TransformException e) {
|
||||
e.printStackTrace();
|
||||
} catch (FactoryException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
hw = rc.asGridCell(HRAP.getInstance().getGridGeometry(),
|
||||
PixelInCell.CELL_CORNER);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
statusHandler
|
||||
.error("Failed to convert ReferencedCoordinate to Coordinate.",
|
||||
e);
|
||||
}
|
||||
win_x = (int) hw.x;
|
||||
win_y = (int) hw.y;
|
||||
|
@ -362,42 +351,39 @@ public class EditTempStationsDialog extends AbstractMPEDialog {
|
|||
}
|
||||
|
||||
reset_value = 0;
|
||||
initial_qual = dqc.tdata[pcpn_day].tstn[isave].tlevel2[time_pos].qual;
|
||||
initial_qual = DailyQcUtils.tdata[pcpn_day].tstn[isave].tlevel2[time_pos].qual;
|
||||
new_qual = initial_qual;
|
||||
|
||||
// Updated to allow editing of time distributed station as in OB 9.x
|
||||
// if (initial_qual == 6) {
|
||||
//
|
||||
// MessageDialog.openError(shell, "Error Time Distributed Station",
|
||||
// "You cannot quality control a time distributed station");
|
||||
// return;
|
||||
// }
|
||||
|
||||
tstnData.append(dqc.temperature_stations.get(isave).hb5);
|
||||
tstnData.append(DailyQcUtils.temperature_stations.get(isave).hb5);
|
||||
tstnData.append(" ");
|
||||
tstnData.append(dqc.temperature_stations.get(isave).parm);
|
||||
tstnData.append(DailyQcUtils.temperature_stations.get(isave).parm);
|
||||
tstnData.append("\n");
|
||||
tstnData.append(dqc.temperature_stations.get(isave).name);
|
||||
tstnData.append(DailyQcUtils.temperature_stations.get(isave).name);
|
||||
tstnData.append("\n");
|
||||
tstnData.append(String.format("%d", dqc.temperature_stations.get(isave).elev));
|
||||
tstnData.append(String.format("%d",
|
||||
DailyQcUtils.temperature_stations.get(isave).elev));
|
||||
tstnData.append(" ft ");
|
||||
tstnData.append("\n");
|
||||
tstnData.append(String.format("Lat: %5.2f Lon: %5.2f",
|
||||
dqc.temperature_stations.get(isave).lat, dqc.temperature_stations.get(isave).lon));
|
||||
DailyQcUtils.temperature_stations.get(isave).lat,
|
||||
DailyQcUtils.temperature_stations.get(isave).lon));
|
||||
tstnData.append("\n");
|
||||
if (dqc.temperature_stations.get(isave).max[isom] > -99) {
|
||||
if (DailyQcUtils.temperature_stations.get(isave).max[isom] > -99) {
|
||||
GetClimateSource gc = new GetClimateSource();
|
||||
tClimateSource = gc.getClimateSource(dqc.temperature_stations.get(isave).cparm);
|
||||
tClimateSource = gc
|
||||
.getClimateSource(DailyQcUtils.temperature_stations
|
||||
.get(isave).cparm);
|
||||
|
||||
tstnData.append(String.format(
|
||||
"monthly average high %5.1f low %5.1f source: %s\n",
|
||||
dqc.temperature_stations.get(isave).max[isom], dqc.temperature_stations.get(isave).min[isom],
|
||||
DailyQcUtils.temperature_stations.get(isave).max[isom],
|
||||
DailyQcUtils.temperature_stations.get(isave).min[isom],
|
||||
tClimateSource));
|
||||
}
|
||||
if (dqc.tdata[pcpn_day].tstn[isave].tlevel2[time_pos].data > -50) {
|
||||
if (DailyQcUtils.tdata[pcpn_day].tstn[isave].tlevel2[time_pos].data > -50) {
|
||||
tstnData.append(String
|
||||
.format("estimate %d ",
|
||||
dqc.tdata[pcpn_day].tstn[isave].tlevel2[time_pos].estimate));
|
||||
DailyQcUtils.tdata[pcpn_day].tstn[isave].tlevel2[time_pos].estimate));
|
||||
}
|
||||
|
||||
createTstationDataComp();
|
||||
|
@ -424,13 +410,13 @@ public class EditTempStationsDialog extends AbstractMPEDialog {
|
|||
hb5Lbl.setLayoutData(gd);
|
||||
|
||||
editVal = new Text(dataComp, SWT.LEFT | SWT.SINGLE | SWT.BORDER);
|
||||
if (dqc.tdata[pcpn_day].tstn[isave].tlevel2[time_pos].data < -50) {
|
||||
if (DailyQcUtils.tdata[pcpn_day].tstn[isave].tlevel2[time_pos].data < -50) {
|
||||
mbuf = "M";
|
||||
editVal.setText(mbuf);
|
||||
} else {
|
||||
mbuf = String
|
||||
.format("%d",
|
||||
(int) dqc.tdata[pcpn_day].tstn[isave].tlevel2[time_pos].data);
|
||||
(int) DailyQcUtils.tdata[pcpn_day].tstn[isave].tlevel2[time_pos].data);
|
||||
editVal.setText(mbuf.trim());
|
||||
|
||||
}
|
||||
|
@ -457,7 +443,6 @@ public class EditTempStationsDialog extends AbstractMPEDialog {
|
|||
stnQualGroup.setLayoutData(gd);
|
||||
|
||||
// Create a container to hold the label and the combo box.
|
||||
// GridData gd = new GridData(SWT.FILL, SWT.DEFAULT, true, false);
|
||||
Composite stnQualComp = new Composite(stnQualGroup, SWT.NONE);
|
||||
GridLayout stnQualCompLayout = new GridLayout(2, true);
|
||||
stnQualCompLayout.marginWidth = 0;
|
||||
|
@ -466,7 +451,7 @@ public class EditTempStationsDialog extends AbstractMPEDialog {
|
|||
stnQualComp.setLayoutData(gd);
|
||||
|
||||
if (initial_qual < 0
|
||||
|| dqc.tdata[pcpn_day].tstn[isave].tlevel2[time_pos].data < -500) {
|
||||
|| DailyQcUtils.tdata[pcpn_day].tstn[isave].tlevel2[time_pos].data < -500) {
|
||||
naflag = 1;
|
||||
} else {
|
||||
naflag = 0;
|
||||
|
@ -524,15 +509,17 @@ public class EditTempStationsDialog extends AbstractMPEDialog {
|
|||
*/
|
||||
private void createStnLocComp() {
|
||||
|
||||
if (dqc.temperature_stations.get(isave).xadd == -1 && dqc.temperature_stations.get(isave).yadd == -1) {
|
||||
if (DailyQcUtils.temperature_stations.get(isave).xadd == -1
|
||||
&& DailyQcUtils.temperature_stations.get(isave).yadd == -1) {
|
||||
initial_pos = 0;
|
||||
} else if (dqc.temperature_stations.get(isave).xadd == 0
|
||||
&& dqc.temperature_stations.get(isave).yadd == -1) {
|
||||
} else if (DailyQcUtils.temperature_stations.get(isave).xadd == 0
|
||||
&& DailyQcUtils.temperature_stations.get(isave).yadd == -1) {
|
||||
initial_pos = 2;
|
||||
} else if (dqc.temperature_stations.get(isave).xadd == -1
|
||||
&& dqc.temperature_stations.get(isave).yadd == 0) {
|
||||
} else if (DailyQcUtils.temperature_stations.get(isave).xadd == -1
|
||||
&& DailyQcUtils.temperature_stations.get(isave).yadd == 0) {
|
||||
initial_pos = 1;
|
||||
} else if (dqc.temperature_stations.get(isave).xadd == 0 && dqc.temperature_stations.get(isave).yadd == 0) {
|
||||
} else if (DailyQcUtils.temperature_stations.get(isave).xadd == 0
|
||||
&& DailyQcUtils.temperature_stations.get(isave).yadd == 0) {
|
||||
initial_pos = 3;
|
||||
}
|
||||
Group stnLocGroup = new Group(shell, SWT.NONE);
|
||||
|
@ -543,7 +530,6 @@ public class EditTempStationsDialog extends AbstractMPEDialog {
|
|||
stnLocGroup.setLayoutData(gd);
|
||||
|
||||
// Create a container to hold the label and the combo box.
|
||||
// GridData gd = new GridData(SWT.FILL, SWT.DEFAULT, true, false);
|
||||
Composite stnLocComp = new Composite(stnLocGroup, SWT.NONE);
|
||||
GridLayout stnLocCompLayout = new GridLayout(2, true);
|
||||
stnLocCompLayout.marginWidth = 0;
|
||||
|
@ -585,7 +571,6 @@ public class EditTempStationsDialog extends AbstractMPEDialog {
|
|||
stnConGroup.setLayoutData(gd);
|
||||
|
||||
// Create a container to hold the label and the combo box.
|
||||
// GridData gd = new GridData(SWT.FILL, SWT.DEFAULT, true, false);
|
||||
Composite stnConComp = new Composite(stnConGroup, SWT.NONE);
|
||||
GridLayout stnConCompLayout = new GridLayout(2, true);
|
||||
stnConCompLayout.marginWidth = 5;
|
||||
|
@ -600,13 +585,13 @@ public class EditTempStationsDialog extends AbstractMPEDialog {
|
|||
sc[i] = new Label(stnConComp, SWT.LEFT);
|
||||
sc[i].setText(dqc.ttimefile[dqc.dqcTimeStringIndex][i]);
|
||||
sv[i] = new Text(stnConComp, SWT.LEFT | SWT.BORDER);
|
||||
if (dqc.tdata[pcpn_day].tstn[isave].tlevel2[i].data < -99) {
|
||||
if (DailyQcUtils.tdata[pcpn_day].tstn[isave].tlevel2[i].data < -99) {
|
||||
muf = "M";
|
||||
sv[i].setText(muf);
|
||||
} else {
|
||||
muf = String
|
||||
.format("%d",
|
||||
(int) dqc.tdata[pcpn_day].tstn[isave].tlevel2[i].data);
|
||||
(int) DailyQcUtils.tdata[pcpn_day].tstn[isave].tlevel2[i].data);
|
||||
sv[i].setText(muf.trim());
|
||||
}
|
||||
eval[i] = sv[i].getText();
|
||||
|
@ -683,8 +668,9 @@ public class EditTempStationsDialog extends AbstractMPEDialog {
|
|||
@Override
|
||||
public void widgetSelected(SelectionEvent e) {
|
||||
AppLauncherHandler alh = new AppLauncherHandler();
|
||||
String lid = dqc.temperature_stations.get(isave).hb5;
|
||||
char[] dataType = dqc.temperature_stations.get(isave).parm.toCharArray();
|
||||
String lid = DailyQcUtils.temperature_stations.get(isave).hb5;
|
||||
char[] dataType = DailyQcUtils.temperature_stations.get(isave).parm
|
||||
.toCharArray();
|
||||
/*
|
||||
* For temperature, use the shef extremum code 'X' for the daily
|
||||
* maximum temperature, 'N' for the daily minimum temperature
|
||||
|
@ -705,12 +691,12 @@ public class EditTempStationsDialog extends AbstractMPEDialog {
|
|||
|
||||
final String TSL_BUNDLE_LOC = "bundles/run-TimeSeriesLite.xml";
|
||||
try {
|
||||
System.out.println("Launching TSL " + lid + ", "
|
||||
+ dataType.toString());
|
||||
statusHandler.info("Launching TSL " + lid + ", "
|
||||
+ dataType.toString() + " ...");
|
||||
alh.execute(TSL_BUNDLE_LOC, lid, dataType.toString());
|
||||
} catch (ExecutionException ee) {
|
||||
// TODO Auto-generated catch block
|
||||
ee.printStackTrace();
|
||||
} catch (ExecutionException e1) {
|
||||
statusHandler.error("Failed to launch TSL " + lid + ", "
|
||||
+ dataType.toString() + ".", e1);
|
||||
}
|
||||
retval = 2;
|
||||
}
|
||||
|
@ -733,14 +719,14 @@ public class EditTempStationsDialog extends AbstractMPEDialog {
|
|||
|
||||
for (k = 0; k < 6; k++) {
|
||||
|
||||
dqc.tdata[pcpn_day].tstn[isave].tlevel2[k].qual = dqc.tdata[pcpn_day].tstn[isave].tlevel1[k].qual;
|
||||
DailyQcUtils.tdata[pcpn_day].tstn[isave].tlevel2[k].qual = DailyQcUtils.tdata[pcpn_day].tstn[isave].tlevel1[k].qual;
|
||||
|
||||
dqc.tdata[pcpn_day].tstn[isave].tlevel2[k].data = dqc.tdata[pcpn_day].tstn[isave].tlevel1[k].data;
|
||||
DailyQcUtils.tdata[pcpn_day].tstn[isave].tlevel2[k].data = DailyQcUtils.tdata[pcpn_day].tstn[isave].tlevel1[k].data;
|
||||
|
||||
}
|
||||
|
||||
reset_value = 1;
|
||||
new_qual = dqc.tdata[pcpn_day].tstn[isave].tlevel1[time_pos].qual;
|
||||
new_qual = DailyQcUtils.tdata[pcpn_day].tstn[isave].tlevel1[time_pos].qual;
|
||||
|
||||
} else {
|
||||
reset_value = 0;
|
||||
|
@ -749,7 +735,6 @@ public class EditTempStationsDialog extends AbstractMPEDialog {
|
|||
}
|
||||
|
||||
protected void changeStationQuality(Integer data) {
|
||||
// logMessage ("thru station_quality %d\n", (int) data);
|
||||
if (pcpn_time_step == 0) {
|
||||
time_pos = pcpn_time;
|
||||
} else {
|
||||
|
@ -761,23 +746,23 @@ public class EditTempStationsDialog extends AbstractMPEDialog {
|
|||
|
||||
protected void changeStationLocation(Integer data) {
|
||||
if (data == 0) {
|
||||
dqc.temperature_stations.get(isave).xadd = -1;
|
||||
dqc.temperature_stations.get(isave).yadd = -1;
|
||||
DailyQcUtils.temperature_stations.get(isave).xadd = -1;
|
||||
DailyQcUtils.temperature_stations.get(isave).yadd = -1;
|
||||
}
|
||||
|
||||
else if (data == 2) {
|
||||
dqc.temperature_stations.get(isave).xadd = 0;
|
||||
dqc.temperature_stations.get(isave).yadd = -1;
|
||||
DailyQcUtils.temperature_stations.get(isave).xadd = 0;
|
||||
DailyQcUtils.temperature_stations.get(isave).yadd = -1;
|
||||
}
|
||||
|
||||
else if (data == 1) {
|
||||
dqc.temperature_stations.get(isave).xadd = -1;
|
||||
dqc.temperature_stations.get(isave).yadd = 0;
|
||||
DailyQcUtils.temperature_stations.get(isave).xadd = -1;
|
||||
DailyQcUtils.temperature_stations.get(isave).yadd = 0;
|
||||
}
|
||||
|
||||
else if (data == 3) {
|
||||
dqc.temperature_stations.get(isave).xadd = 0;
|
||||
dqc.temperature_stations.get(isave).yadd = 0;
|
||||
DailyQcUtils.temperature_stations.get(isave).xadd = 0;
|
||||
DailyQcUtils.temperature_stations.get(isave).yadd = 0;
|
||||
}
|
||||
|
||||
return;
|
||||
|
@ -785,7 +770,7 @@ public class EditTempStationsDialog extends AbstractMPEDialog {
|
|||
|
||||
protected void changeCustomFile(int data) {
|
||||
|
||||
String pathName = getStationListPath(dqc.currentQcArea);
|
||||
String pathName = getStationListPath(DailyQcUtils.currentQcArea);
|
||||
String tstation_list_custom_file = pathName + "_label_position";
|
||||
int i;
|
||||
int time_pos = 0;
|
||||
|
@ -793,13 +778,12 @@ public class EditTempStationsDialog extends AbstractMPEDialog {
|
|||
int idif;
|
||||
String cstr;
|
||||
int k, p;
|
||||
// int[] pcp_in_use = DailyQcUtils.pcp_in_use;
|
||||
Button rpbutton = QcTempOptionsDialog.renderGridsBtn;
|
||||
BufferedWriter out = null;
|
||||
int pcp_flag = dqc.pcp_flag;
|
||||
int grids_flag = dqc.grids_flag;
|
||||
int points_flag = dqc.points_flag;
|
||||
int map_flag = dqc.map_flag;
|
||||
int pcp_flag = DailyQcUtils.pcp_flag;
|
||||
int grids_flag = DailyQcUtils.grids_flag;
|
||||
int points_flag = DailyQcUtils.points_flag;
|
||||
int map_flag = DailyQcUtils.map_flag;
|
||||
|
||||
if (pcpn_time_step == 0) {
|
||||
time_pos = pcpn_time;
|
||||
|
@ -813,16 +797,17 @@ public class EditTempStationsDialog extends AbstractMPEDialog {
|
|||
out = new BufferedWriter(new FileWriter(tstation_list_custom_file));
|
||||
|
||||
for (i = 0; i < max_stations; i++) {
|
||||
String rec = String.format("%s %s %d %d\n", dqc.temperature_stations.get(i).hb5,
|
||||
dqc.temperature_stations.get(i).parm, dqc.temperature_stations.get(i).xadd,
|
||||
dqc.temperature_stations.get(i).yadd);
|
||||
String rec = String.format("%s %s %d %d\n",
|
||||
DailyQcUtils.temperature_stations.get(i).hb5,
|
||||
DailyQcUtils.temperature_stations.get(i).parm,
|
||||
DailyQcUtils.temperature_stations.get(i).xadd,
|
||||
DailyQcUtils.temperature_stations.get(i).yadd);
|
||||
out.write(rec);
|
||||
}
|
||||
out.close();
|
||||
} catch (IOException e) {
|
||||
System.out.println(String.format("Could not open file: %s\n",
|
||||
tstation_list_custom_file));
|
||||
e.printStackTrace();
|
||||
statusHandler.error("Failed to write file: "
|
||||
+ tstation_list_custom_file + ".", e);
|
||||
return;
|
||||
} finally {
|
||||
try {
|
||||
|
@ -830,7 +815,8 @@ public class EditTempStationsDialog extends AbstractMPEDialog {
|
|||
out.close();
|
||||
}
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
statusHandler.error("Failed to close file: "
|
||||
+ tstation_list_custom_file + ".", e);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -845,18 +831,18 @@ public class EditTempStationsDialog extends AbstractMPEDialog {
|
|||
|
||||
idif = (int) Math
|
||||
.abs(val
|
||||
- dqc.tdata[pcpn_day].tstn[isave].tlevel2[time_pos].data);
|
||||
- DailyQcUtils.tdata[pcpn_day].tstn[isave].tlevel2[time_pos].data);
|
||||
|
||||
if (idif > 1 && p == -1 && reset_value == 0) {
|
||||
|
||||
dqc.tdata[pcpn_day].tstn[isave].tlevel2[time_pos].data = val;
|
||||
dqc.tdata[pcpn_day].tstn[isave].tlevel2[time_pos].qual = 2;
|
||||
DailyQcUtils.tdata[pcpn_day].tstn[isave].tlevel2[time_pos].data = val;
|
||||
DailyQcUtils.tdata[pcpn_day].tstn[isave].tlevel2[time_pos].qual = 2;
|
||||
|
||||
}
|
||||
|
||||
else {
|
||||
|
||||
dqc.tdata[pcpn_day].tstn[isave].tlevel2[time_pos].qual = (short) new_qual;
|
||||
DailyQcUtils.tdata[pcpn_day].tstn[isave].tlevel2[time_pos].qual = (short) new_qual;
|
||||
|
||||
}
|
||||
|
||||
|
@ -876,22 +862,22 @@ public class EditTempStationsDialog extends AbstractMPEDialog {
|
|||
|
||||
idif = (int) Math
|
||||
.abs(val
|
||||
- dqc.tdata[pcpn_day].tstn[isave].tlevel2[k].data);
|
||||
- DailyQcUtils.tdata[pcpn_day].tstn[isave].tlevel2[k].data);
|
||||
|
||||
if (p != -1) {
|
||||
dqc.tdata[pcpn_day].tstn[isave].tlevel2[k].data = -99;
|
||||
dqc.tdata[pcpn_day].tstn[isave].tlevel2[k].qual = -99;
|
||||
DailyQcUtils.tdata[pcpn_day].tstn[isave].tlevel2[k].data = -99;
|
||||
DailyQcUtils.tdata[pcpn_day].tstn[isave].tlevel2[k].qual = -99;
|
||||
} else {
|
||||
if (idif > 1) {
|
||||
dqc.tdata[pcpn_day].tstn[isave].tlevel2[k].data = val;
|
||||
dqc.tdata[pcpn_day].tstn[isave].tlevel2[k].qual = 2;
|
||||
DailyQcUtils.tdata[pcpn_day].tstn[isave].tlevel2[k].data = val;
|
||||
DailyQcUtils.tdata[pcpn_day].tstn[isave].tlevel2[k].qual = 2;
|
||||
}
|
||||
}
|
||||
cstr = null;
|
||||
}
|
||||
}
|
||||
if (dqc.tdata[pcpn_day].used[time_pos] != 0) {
|
||||
dqc.tdata[pcpn_day].used[time_pos] = 2;
|
||||
if (DailyQcUtils.tdata[pcpn_day].used[time_pos] != 0) {
|
||||
DailyQcUtils.tdata[pcpn_day].used[time_pos] = 2;
|
||||
}
|
||||
|
||||
if (pcpn_time_step == 0) {
|
||||
|
@ -902,16 +888,14 @@ public class EditTempStationsDialog extends AbstractMPEDialog {
|
|||
time_pos = 200 + pcpn_day;
|
||||
}
|
||||
|
||||
dqc.pcp_in_use[time_pos] = -1;
|
||||
|
||||
for (k = 0; k < 4; k++) {
|
||||
|
||||
time_pos = 150 + pcpn_day * 4 + k;
|
||||
|
||||
dqc.pcp_in_use[time_pos] = -1;
|
||||
DailyQcUtils.pcp_in_use[time_pos] = -1;
|
||||
|
||||
if (dqc.tdata[pcpn_day].used[k] != 0) {
|
||||
dqc.tdata[pcpn_day].used[k] = 2;
|
||||
if (DailyQcUtils.tdata[pcpn_day].used[k] != 0) {
|
||||
DailyQcUtils.tdata[pcpn_day].used[k] = 2;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -930,7 +914,7 @@ public class EditTempStationsDialog extends AbstractMPEDialog {
|
|||
time_pos = 200 + pcpn_day;
|
||||
}
|
||||
|
||||
if (points_flag == 1 && dqc.pcp_in_use[time_pos] == -1) {
|
||||
if (points_flag == 1 && DailyQcUtils.pcp_in_use[time_pos] == -1) {
|
||||
k = 0;
|
||||
} else if (points_flag == 1 && grids_flag == -1 && map_flag == -1) {
|
||||
k = 0;
|
||||
|
@ -953,19 +937,16 @@ public class EditTempStationsDialog extends AbstractMPEDialog {
|
|||
BadTValues bv = new BadTValues();
|
||||
bv.update_bad_tvalues(pcpn_day);
|
||||
|
||||
// logMessage("estimate\n");
|
||||
|
||||
EstDailyTStations eds = new EstDailyTStations();
|
||||
eds.estimate_daily_tstations(pcpn_day, dqc.temperature_stations, max_stations);
|
||||
|
||||
// logMessage("qc\n");
|
||||
eds.estimate_daily_tstations(pcpn_day,
|
||||
DailyQcUtils.temperature_stations, max_stations);
|
||||
|
||||
QCTStations qcs = new QCTStations();
|
||||
qcs.quality_control_tstations(pcpn_day, dqc.temperature_stations, max_stations);
|
||||
qcs.quality_control_tstations(pcpn_day,
|
||||
DailyQcUtils.temperature_stations, max_stations);
|
||||
|
||||
// logMessage("restore\n");
|
||||
|
||||
bv.restore_bad_tvalues(pcpn_day, dqc.temperature_stations, max_stations);
|
||||
bv.restore_bad_tvalues(pcpn_day, DailyQcUtils.temperature_stations,
|
||||
max_stations);
|
||||
|
||||
OtherPrecipOptions op = new OtherPrecipOptions();
|
||||
op.send_expose();
|
||||
|
@ -974,7 +955,7 @@ public class EditTempStationsDialog extends AbstractMPEDialog {
|
|||
}
|
||||
|
||||
private String getStationListPath(String qcArea) {
|
||||
String station_dir = dqc.mpe_station_list_dir;
|
||||
String station_dir = DailyQcUtils.mpe_station_list_dir;
|
||||
String dir;
|
||||
|
||||
if (qcArea != null) {
|
||||
|
|
|
@ -85,6 +85,7 @@ import com.raytheon.viz.mpe.ui.rsc.MPEFieldResourceData.MPEFieldFrame;
|
|||
* Mar 19, 2014 17109 snaples Removed code that added an hour to SATPRE, the base file reference time has been adjusted.
|
||||
* Nov 05, 2015 18095 lbousaidi Fixed hour substitued for satellite field precip when drawing polygon.
|
||||
* Dec 04, 2015 5165/14513 mduff Set this resource on the display manager if not set in the display manager.
|
||||
* Dec 08, 2015 5180 bkowal Made the hour substitution special case precise.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -193,12 +194,14 @@ public class MPEFieldResource extends
|
|||
if (subData == null) {
|
||||
try {
|
||||
Date date = frame.getDate();
|
||||
// SATPRE MPE file time stamp is the start time of the
|
||||
// hour
|
||||
// i.e. a 12z -13z product has a time stamp of 12z.
|
||||
/*
|
||||
* SATPRE MPE file time stamp is the start time of the
|
||||
* hour. i.e. a 12z -13z product has a time stamp of
|
||||
* 12z.
|
||||
*/
|
||||
Calendar cal = Calendar.getInstance();
|
||||
cal.setTime(date);
|
||||
if (edit.getSubDrawSource().name().contains("satPre")) {
|
||||
if (edit.getSubDrawSource() == DisplayFieldData.satPre) {
|
||||
cal.add(Calendar.HOUR, -1);
|
||||
}
|
||||
|
||||
|
|
|
@ -24,6 +24,7 @@ import java.util.ArrayList;
|
|||
import java.util.Date;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.SortedMap;
|
||||
import java.util.TreeMap;
|
||||
import java.util.regex.Matcher;
|
||||
|
@ -31,12 +32,15 @@ import java.util.regex.Pattern;
|
|||
|
||||
import org.hibernate.Session;
|
||||
|
||||
import com.raytheon.uf.common.dataplugin.PluginDataObject;
|
||||
import com.raytheon.uf.common.dataplugin.PluginException;
|
||||
import com.raytheon.uf.common.dataplugin.gfe.db.objects.GridParmInfo;
|
||||
import com.raytheon.uf.common.dataplugin.grid.GridConstants;
|
||||
import com.raytheon.uf.common.dataplugin.grid.GridRecord;
|
||||
import com.raytheon.uf.common.dataplugin.level.Level;
|
||||
import com.raytheon.uf.common.dataquery.db.QueryParam.QueryOperand;
|
||||
import com.raytheon.uf.common.time.DataTime;
|
||||
import com.raytheon.uf.common.time.TimeRange;
|
||||
import com.raytheon.uf.edex.database.DataAccessLayerException;
|
||||
import com.raytheon.uf.edex.database.query.DatabaseQuery;
|
||||
import com.raytheon.uf.edex.plugin.grid.dao.GridDao;
|
||||
|
@ -61,7 +65,8 @@ import com.raytheon.uf.edex.plugin.grid.dao.GridDao;
|
|||
* Aug 30, 2013 2298 rjpeter Make getPluginName abstract
|
||||
* 10/16/2014 3454 bphillip Upgrading to Hibernate 4
|
||||
* Aug 14, 2015 17801 bhunderm Fixed logic to choose the parm with lesser
|
||||
* duration when have multiple grids for same fcsthr.
|
||||
* duration when have multiple grids for same fcsthr.
|
||||
* Dec 03, 2015 5168 randerso Added ability to retrieve D2D data by fcsthr or timerange
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -69,13 +74,12 @@ import com.raytheon.uf.edex.plugin.grid.dao.GridDao;
|
|||
* @version 1.0
|
||||
*/
|
||||
|
||||
// **********************************************************************
|
||||
// TODO: Can this be merged into GridDao/D2DGridDatabase?
|
||||
// **********************************************************************
|
||||
public class GFED2DDao extends GridDao {
|
||||
private static final String FCST_TIME = "dataTime.fcstTime";
|
||||
private static final String FCSTTIME_ID = PluginDataObject.DATATIME_ID
|
||||
+ ".fcstTime";
|
||||
|
||||
private static final String REF_TIME = "dataTime.refTime";
|
||||
private static final String REFTIME_ID = PluginDataObject.DATATIME_ID
|
||||
+ ".refTime";
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
|
@ -100,10 +104,10 @@ public class GFED2DDao extends GridDao {
|
|||
public List<Integer> getForecastTimes(String d2dModelName, Date refTime)
|
||||
throws DataAccessLayerException {
|
||||
DatabaseQuery query = new DatabaseQuery(GridRecord.class.getName());
|
||||
query.addDistinctParameter(FCST_TIME);
|
||||
query.addDistinctParameter(FCSTTIME_ID);
|
||||
query.addQueryParam(GridConstants.DATASET_ID, d2dModelName);
|
||||
query.addQueryParam(REF_TIME, refTime);
|
||||
query.addOrder(FCST_TIME, true);
|
||||
query.addQueryParam(REFTIME_ID, refTime);
|
||||
query.addOrder(FCSTTIME_ID, true);
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
List<Integer> vals = (List<Integer>) this.queryByCriteria(query);
|
||||
|
@ -112,7 +116,7 @@ public class GFED2DDao extends GridDao {
|
|||
|
||||
/**
|
||||
* Retrieves a GridRecord from the grib metadata database based on a ParmID,
|
||||
* TimeRange, and GridParmInfo.
|
||||
* forecastTime, and GridParmInfo.
|
||||
*
|
||||
* @param d2dModelName
|
||||
* @param refTime
|
||||
|
@ -135,17 +139,24 @@ public class GFED2DDao extends GridDao {
|
|||
try {
|
||||
s = getSession();
|
||||
// TODO: clean up so we only make one db query
|
||||
SortedMap<Integer, Integer> rawTimes = queryByParmId(d2dModelName,
|
||||
SortedMap<DataTime, Integer> rawTimes = queryByParmId(d2dModelName,
|
||||
refTime, d2dParmName, d2dLevel, s);
|
||||
|
||||
// if forecastTime is null just pick one,
|
||||
// this is for static data since all times are the same
|
||||
Integer id = null;
|
||||
if (forecastTime == null) {
|
||||
forecastTime = rawTimes.keySet().iterator().next();
|
||||
id = rawTimes.values().iterator().next();
|
||||
} else {
|
||||
for (Entry<DataTime, Integer> entry : rawTimes.entrySet()) {
|
||||
if (entry.getKey().getFcstTime() == forecastTime) {
|
||||
id = entry.getValue();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
GridRecord retVal = (GridRecord) s.get(GridRecord.class,
|
||||
rawTimes.get(forecastTime));
|
||||
GridRecord retVal = (GridRecord) s.get(GridRecord.class, id);
|
||||
return retVal;
|
||||
|
||||
} finally {
|
||||
|
@ -153,8 +164,63 @@ public class GFED2DDao extends GridDao {
|
|||
try {
|
||||
s.close();
|
||||
} catch (Exception e) {
|
||||
logger.error(
|
||||
"Error occurred closing database session", e);
|
||||
logger.error("Error occurred closing database session", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves a GridRecord from the grib metadata database based on a ParmID,
|
||||
* TimeRange, and GridParmInfo.
|
||||
*
|
||||
* @param d2dModelName
|
||||
* @param refTime
|
||||
* @param d2dParmName
|
||||
* @param d2dLevel
|
||||
* @param timeRange
|
||||
* The valid period of the desired GridRecord, null for any
|
||||
* record
|
||||
* @param info
|
||||
* The GridParmInfo for the requested d2d grid.
|
||||
* @return The GridRecord from the grib metadata database
|
||||
* @throws DataAccessLayerException
|
||||
* If errors occur while querying the metadata database
|
||||
*/
|
||||
public GridRecord getGrid(String d2dModelName, Date refTime,
|
||||
String d2dParmName, Level d2dLevel, TimeRange timeRange,
|
||||
GridParmInfo info) throws DataAccessLayerException {
|
||||
Session s = null;
|
||||
|
||||
try {
|
||||
s = getSession();
|
||||
// TODO: clean up so we only make one db query
|
||||
SortedMap<DataTime, Integer> rawTimes = queryByParmId(d2dModelName,
|
||||
refTime, d2dParmName, d2dLevel, s);
|
||||
|
||||
// if forecastTime is null just pick one,
|
||||
// this is for static data since all times are the same
|
||||
Integer id = null;
|
||||
if (timeRange == null) {
|
||||
id = rawTimes.values().iterator().next();
|
||||
} else {
|
||||
for (Entry<DataTime, Integer> entry : rawTimes.entrySet()) {
|
||||
if (entry.getKey().getValidPeriod().equals(timeRange)) {
|
||||
id = entry.getValue();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
GridRecord retVal = (GridRecord) s.get(GridRecord.class, id);
|
||||
return retVal;
|
||||
|
||||
} finally {
|
||||
if (s != null) {
|
||||
try {
|
||||
s.close();
|
||||
} catch (Exception e) {
|
||||
logger.error("Error occurred closing database session", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -176,21 +242,21 @@ public class GFED2DDao extends GridDao {
|
|||
* @throws DataAccessLayerException
|
||||
* If errors occur while querying the metadata database
|
||||
*/
|
||||
public SortedMap<Integer, Integer> queryByParmId(String d2dModelName,
|
||||
public SortedMap<DataTime, Integer> queryByParmId(String d2dModelName,
|
||||
Date refTime, String d2dParmName, Level d2dLevel, Session s)
|
||||
throws DataAccessLayerException {
|
||||
|
||||
DatabaseQuery query;
|
||||
query = new DatabaseQuery(GridRecord.class.getName());
|
||||
query.addReturnedField(FCST_TIME);
|
||||
query.addReturnedField(PluginDataObject.DATATIME_ID);
|
||||
query.addReturnedField("id");
|
||||
query.addReturnedField(GridConstants.PARAMETER_ABBREVIATION);
|
||||
query.addQueryParam(GridConstants.DATASET_ID, d2dModelName);
|
||||
query.addQueryParam(REF_TIME, refTime);
|
||||
query.addQueryParam(REFTIME_ID, refTime);
|
||||
query.addQueryParam(GridConstants.PARAMETER_ABBREVIATION, d2dParmName
|
||||
+ "%hr", QueryOperand.LIKE);
|
||||
query.addQueryParam(GridConstants.LEVEL_ID, d2dLevel.getId());
|
||||
query.addOrder(FCST_TIME, true);
|
||||
query.addOrder(FCSTTIME_ID, true);
|
||||
query.addOrder(GridConstants.PARAMETER_ABBREVIATION, true);
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
|
@ -211,30 +277,30 @@ public class GFED2DDao extends GridDao {
|
|||
}
|
||||
}
|
||||
|
||||
SortedMap<Integer, Integer> dataTimes = new TreeMap<Integer, Integer>();
|
||||
SortedMap<DataTime, Integer> dataTimes = new TreeMap<DataTime, Integer>();
|
||||
if (firstTry.isEmpty()) {
|
||||
query = new DatabaseQuery(GridRecord.class.getName());
|
||||
query.addReturnedField(FCST_TIME);
|
||||
query.addReturnedField(PluginDataObject.DATATIME_ID);
|
||||
query.addReturnedField("id");
|
||||
query.addQueryParam(GridConstants.DATASET_ID, d2dModelName);
|
||||
query.addQueryParam(REF_TIME, refTime);
|
||||
query.addQueryParam(REFTIME_ID, refTime);
|
||||
query.addQueryParam(GridConstants.PARAMETER_ABBREVIATION,
|
||||
d2dParmName);
|
||||
query.addQueryParam(GridConstants.LEVEL_ID, d2dLevel.getId());
|
||||
query.addOrder(FCST_TIME, true);
|
||||
query.addOrder(FCSTTIME_ID, true);
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
List<Object[]> secondTry = (List<Object[]>) this
|
||||
.queryByCriteria(query);
|
||||
|
||||
for (Object[] row : secondTry) {
|
||||
dataTimes.put((Integer) row[0], (Integer) row[1]);
|
||||
dataTimes.put((DataTime) row[0], (Integer) row[1]);
|
||||
}
|
||||
} else {
|
||||
int i = 0;
|
||||
while (i < firstTry.size()) {
|
||||
Object[] row = firstTry.get(i++);
|
||||
Integer fcstHr = (Integer) row[0];
|
||||
DataTime dataTime = (DataTime) row[0];
|
||||
Integer id = (Integer) row[1];
|
||||
Matcher matcher = pattern.matcher((String) row[2]);
|
||||
int dur = Integer.MAX_VALUE;
|
||||
|
@ -244,7 +310,8 @@ public class GFED2DDao extends GridDao {
|
|||
|
||||
while (i < firstTry.size()) {
|
||||
Object[] nextRow = firstTry.get(i);
|
||||
if (fcstHr.equals(nextRow[0])) {
|
||||
DataTime nextDataTime = (DataTime) nextRow[0];
|
||||
if (dataTime.getFcstTime() == nextDataTime.getFcstTime()) {
|
||||
i++;
|
||||
String nextParam = (String) nextRow[2];
|
||||
Matcher nextMatcher = pattern.matcher(nextParam);
|
||||
|
@ -259,33 +326,33 @@ public class GFED2DDao extends GridDao {
|
|||
break;
|
||||
}
|
||||
}
|
||||
dataTimes.put(fcstHr, id);
|
||||
dataTimes.put(dataTime, id);
|
||||
}
|
||||
}
|
||||
return dataTimes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve the available Forecast Hours by D2D parm id.
|
||||
* Retrieve the available Data Times by D2D parm id.
|
||||
*
|
||||
* @param d2dModelName
|
||||
* @param refTime
|
||||
* @param d2dParmName
|
||||
* @param d2dLevel
|
||||
* @return the list of forecast hours, empty if none
|
||||
* @return the list of data times, empty if none
|
||||
* @throws DataAccessLayerException
|
||||
*/
|
||||
public List<Integer> queryFcstHourByParmId(String d2dModelName,
|
||||
public List<DataTime> queryDataTimeByParmId(String d2dModelName,
|
||||
Date refTime, String d2dParmName, Level d2dLevel)
|
||||
throws DataAccessLayerException {
|
||||
List<Integer> timeList = new ArrayList<Integer>();
|
||||
List<DataTime> timeList = new ArrayList<>();
|
||||
Session s = null;
|
||||
try {
|
||||
s = getSession();
|
||||
|
||||
SortedMap<Integer, Integer> results = queryByParmId(d2dModelName,
|
||||
SortedMap<DataTime, Integer> results = queryByParmId(d2dModelName,
|
||||
refTime, d2dParmName, d2dLevel, s);
|
||||
for (Integer o : results.keySet()) {
|
||||
for (DataTime o : results.keySet()) {
|
||||
timeList.add(o);
|
||||
}
|
||||
} finally {
|
||||
|
@ -293,8 +360,7 @@ public class GFED2DDao extends GridDao {
|
|||
try {
|
||||
s.close();
|
||||
} catch (Exception e) {
|
||||
logger.error(
|
||||
"Error occurred closing database session", e);
|
||||
logger.error("Error occurred closing database session", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -314,9 +380,9 @@ public class GFED2DDao extends GridDao {
|
|||
public List<Date> getModelRunTimes(String d2dModelName, int maxRecords)
|
||||
throws DataAccessLayerException {
|
||||
DatabaseQuery query = new DatabaseQuery(GridRecord.class.getName());
|
||||
query.addDistinctParameter(REF_TIME);
|
||||
query.addDistinctParameter(REFTIME_ID);
|
||||
query.addQueryParam(GridConstants.DATASET_ID, d2dModelName);
|
||||
query.addOrder(REF_TIME, false);
|
||||
query.addOrder(REFTIME_ID, false);
|
||||
if (maxRecords > 0) {
|
||||
query.setMaxResults(maxRecords);
|
||||
}
|
||||
|
|
|
@ -44,6 +44,7 @@ import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
|
|||
* Sep 12, 2012 #1117 dgilling Create field to hold list of
|
||||
* valid levels for each parameter.
|
||||
* Mar 20, 2013 #1774 randerso Added getMinVal and getMaxVal
|
||||
* Dec 03, 2015 #5168 randerso Added dataTimeRangeValid flag
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -61,6 +62,13 @@ public class ParameterInfo {
|
|||
|
||||
public static final float MAX_VALUE = 10000f;
|
||||
|
||||
/**
|
||||
* True if the valid period in the grib data is correct and should be used
|
||||
* by GFE
|
||||
*/
|
||||
@XmlElement(required = false)
|
||||
private boolean useDatabaseTimeRange = false;
|
||||
|
||||
@XmlElement
|
||||
@XmlJavaTypeAdapter(CollapsedStringAdapter.class)
|
||||
private String short_name;
|
||||
|
@ -123,6 +131,13 @@ public class ParameterInfo {
|
|||
this.short_name = parameterName;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return true if database time range should be used
|
||||
*/
|
||||
public boolean useDatabaseTimeRange() {
|
||||
return useDatabaseTimeRange;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the long_name
|
||||
*/
|
||||
|
@ -203,7 +218,7 @@ public class ParameterInfo {
|
|||
*/
|
||||
public float getMinVal() {
|
||||
float min = MIN_VALUE;
|
||||
if (valid_range != null && valid_range.length == 2) {
|
||||
if ((valid_range != null) && (valid_range.length == 2)) {
|
||||
min = valid_range[0];
|
||||
}
|
||||
return min;
|
||||
|
@ -214,7 +229,7 @@ public class ParameterInfo {
|
|||
*/
|
||||
public float getMaxVal() {
|
||||
float min = MAX_VALUE;
|
||||
if (valid_range != null && valid_range.length == 2) {
|
||||
if ((valid_range != null) && (valid_range.length == 2)) {
|
||||
min = valid_range[1];
|
||||
}
|
||||
return min;
|
||||
|
|
|
@ -62,6 +62,7 @@ import com.raytheon.uf.common.dataplugin.gfe.server.request.CommitGridRequest;
|
|||
import com.raytheon.uf.common.dataplugin.gfe.server.request.GetGridRequest;
|
||||
import com.raytheon.uf.common.dataplugin.gfe.server.request.SaveGridRequest;
|
||||
import com.raytheon.uf.common.dataplugin.gfe.slice.IGridSlice;
|
||||
import com.raytheon.uf.common.dataplugin.grid.GridPathProvider;
|
||||
import com.raytheon.uf.common.dataplugin.grid.GridRecord;
|
||||
import com.raytheon.uf.common.dataplugin.satellite.SatelliteRecord;
|
||||
import com.raytheon.uf.common.message.WsId;
|
||||
|
@ -137,6 +138,7 @@ import com.raytheon.uf.edex.database.purge.PurgeLogger;
|
|||
* ingested while deactivated gets recognized
|
||||
* 10/27/2014 #3766 randerso Fixed return type and javadoc for createNewDb
|
||||
* 03/05/2015 #4169 randerso Fix error handling in getDatabase
|
||||
* 12/03/2015 #5168 randerso Added check to skip running smartInit for static data at non-zero fcsthr
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -1285,6 +1287,13 @@ public class GridParmManager {
|
|||
List<GridUpdateNotification> guns = new LinkedList<GridUpdateNotification>();
|
||||
for (GridRecord record : gridRecords) {
|
||||
|
||||
// ignore static parameters for non-zero forecast hours
|
||||
if ((record.getDataTime().getFcstTime() > 0)
|
||||
&& GridPathProvider.STATIC_PARAMETERS.contains(record
|
||||
.getParameter().getAbbreviation())) {
|
||||
continue;
|
||||
}
|
||||
|
||||
String d2dModelName = record.getDatasetId();
|
||||
Date refTime = record.getDataTime().getRefTime();
|
||||
DatabaseID dbId = D2DGridDatabase.getDbId(d2dModelName, refTime,
|
||||
|
@ -1308,6 +1317,25 @@ public class GridParmManager {
|
|||
SmartInitQueue queue = SmartInitQueue.getQueue();
|
||||
if (queue != null) {
|
||||
Date validTime = gun.getReplacementTimeRange().getStart();
|
||||
TimeRange validPeriod = record.getDataTime()
|
||||
.getValidPeriod();
|
||||
|
||||
statusHandler
|
||||
.info("D2D grid received for "
|
||||
+ record.getParameter().getAbbreviation()
|
||||
+ "_"
|
||||
+ record.getLevel()
|
||||
+ " at "
|
||||
+ (validPeriod.isValid() ? validPeriod
|
||||
: record.getDataTime()
|
||||
.getValidTimeAsDate())
|
||||
+ "\nFiring smartInit for "
|
||||
+ dbId
|
||||
+ " at "
|
||||
+ validTime
|
||||
+ "\nGridUpdateNotification.replacementTimeRange = "
|
||||
+ gun.getReplacementTimeRange());
|
||||
|
||||
queue.queue(siteID, config, dbId, validTime, false,
|
||||
SmartInitRecord.LIVE_SMART_INIT_PRIORITY);
|
||||
}
|
||||
|
|
|
@ -80,6 +80,7 @@ import com.raytheon.uf.common.status.IUFStatusHandler;
|
|||
import com.raytheon.uf.common.status.PerformanceStatus;
|
||||
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.common.time.TimeRange;
|
||||
import com.raytheon.uf.common.time.util.TimeUtil;
|
||||
import com.raytheon.uf.common.util.mapping.MultipleMappingException;
|
||||
|
@ -120,6 +121,7 @@ import com.raytheon.uf.edex.database.DataAccessLayerException;
|
|||
* 03/05/2015 #4169 randerso Fix error handling in getDatabase
|
||||
* 06/29/2015 #4537 rferrel Allow for durations less then 1 hour.
|
||||
* 07/13/2015 #4537 randerso Additional changes to allow D2DParms with sub-hourly durations/intervals
|
||||
* 12/03/2015 #5168 randerso Added flag to use database time range if valid
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -261,11 +263,15 @@ public class D2DGridDatabase extends VGridDatabase {
|
|||
|
||||
private final Level level;
|
||||
|
||||
private boolean useDatabaseTimeRange = false;
|
||||
|
||||
public D2DParm(ParmID parmId, GridParmInfo gpi,
|
||||
Map<Integer, TimeRange> fcstHrToTimeRange, String... components) {
|
||||
Map<Integer, TimeRange> fcstHrToTimeRange,
|
||||
boolean dataTimeRangeValid, String... components) {
|
||||
this.parmId = parmId;
|
||||
this.gpi = gpi;
|
||||
this.fcstHrToTimeRange = fcstHrToTimeRange;
|
||||
this.useDatabaseTimeRange = dataTimeRangeValid;
|
||||
this.components = components;
|
||||
|
||||
this.timeRangeToFcstHr = new HashMap<TimeRange, Integer>(
|
||||
|
@ -307,6 +313,13 @@ public class D2DGridDatabase extends VGridDatabase {
|
|||
return level;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return true if time range in database should be used
|
||||
*/
|
||||
public boolean useDatabaseTimeRange() {
|
||||
return useDatabaseTimeRange;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return this.parmId.toString();
|
||||
|
@ -498,7 +511,7 @@ public class D2DGridDatabase extends VGridDatabase {
|
|||
String d2dParmName = getD2DParmName(gfeParmName);
|
||||
|
||||
D2DParm d2dParm = new D2DParm(pid, gpi, possibleInventorySlots,
|
||||
d2dParmName);
|
||||
atts.useDatabaseTimeRange(), d2dParmName);
|
||||
this.gfeParms.put(pid, d2dParm);
|
||||
this.d2dParms.put(compositeName(gfeParmName, level), d2dParm);
|
||||
}
|
||||
|
@ -547,6 +560,7 @@ public class D2DGridDatabase extends VGridDatabase {
|
|||
String vD2dParmName = getD2DParmName(vGfeParmName);
|
||||
|
||||
D2DParm d2dParm = new D2DParm(pid, gpi, possibleInventorySlots,
|
||||
uatts.useDatabaseTimeRange() && vatts.useDatabaseTimeRange(),
|
||||
uD2dParmName, vD2dParmName);
|
||||
this.gfeParms.put(pid, d2dParm);
|
||||
this.d2dParms.put(compositeName(uGfeParmName, level), d2dParm);
|
||||
|
@ -604,11 +618,11 @@ public class D2DGridDatabase extends VGridDatabase {
|
|||
D2DParm parm = this.gfeParms.get(id);
|
||||
if (parm != null) {
|
||||
// get database inventory
|
||||
List<Integer> dbInv = null;
|
||||
List<DataTime> dbInv = null;
|
||||
try {
|
||||
// get database inventory where all components are available
|
||||
for (String component : parm.getComponents()) {
|
||||
List<Integer> compInv = d2dDao.queryFcstHourByParmId(
|
||||
List<DataTime> compInv = d2dDao.queryDataTimeByParmId(
|
||||
d2dModelName, refTime, component, parm.getLevel());
|
||||
|
||||
if (dbInv == null) {
|
||||
|
@ -624,15 +638,22 @@ public class D2DGridDatabase extends VGridDatabase {
|
|||
}
|
||||
|
||||
SortedSet<TimeRange> invSet = new TreeSet<TimeRange>();
|
||||
for (Integer forecastTime : dbInv) {
|
||||
TimeRange tr = parm.getFcstHrToTimeRange().get(forecastTime);
|
||||
if (tr != null) {
|
||||
invSet.add(tr);
|
||||
for (DataTime dataTime : dbInv) {
|
||||
TimeRange tr = null;
|
||||
if (parm.useDatabaseTimeRange()) {
|
||||
tr = dataTime.getValidPeriod();
|
||||
|
||||
} else {
|
||||
statusHandler.warn("No time range found for "
|
||||
+ parm.getParmId() + " at forecast time "
|
||||
+ forecastTime);
|
||||
tr = parm.getFcstHrToTimeRange()
|
||||
.get(dataTime.getFcstTime());
|
||||
|
||||
if (tr == null) {
|
||||
statusHandler.warn("No time range found for "
|
||||
+ parm.getParmId() + " at forecast time "
|
||||
+ dataTime.getFcstTime());
|
||||
}
|
||||
}
|
||||
invSet.add(tr);
|
||||
}
|
||||
inventory = new ArrayList<TimeRange>(invSet);
|
||||
} else {
|
||||
|
@ -836,16 +857,23 @@ public class D2DGridDatabase extends VGridDatabase {
|
|||
if (parm == null) {
|
||||
throw new GfeException("Unknown parmId: " + parmId);
|
||||
}
|
||||
if (!GridPathProvider.STATIC_PARAMETERS.contains(parmId
|
||||
.getParmName())) {
|
||||
fcstHr = parm.getTimeRangeToFcstHr().get(timeRange);
|
||||
if (fcstHr == null) {
|
||||
throw new GfeException("Invalid time range " + timeRange
|
||||
+ " for " + parmId);
|
||||
boolean staticParm = GridPathProvider.STATIC_PARAMETERS
|
||||
.contains(parmId.getParmName());
|
||||
if (!staticParm && parm.useDatabaseTimeRange()) {
|
||||
d2dRecord = d2dDao.getGrid(d2dModelName, refTime,
|
||||
parm.getComponents()[0], parm.getLevel(), timeRange,
|
||||
gpi);
|
||||
} else {
|
||||
if (!staticParm) {
|
||||
fcstHr = parm.getTimeRangeToFcstHr().get(timeRange);
|
||||
if (fcstHr == null) {
|
||||
throw new GfeException("Invalid time range "
|
||||
+ timeRange + " for " + parmId);
|
||||
}
|
||||
}
|
||||
d2dRecord = d2dDao.getGrid(d2dModelName, refTime,
|
||||
parm.getComponents()[0], parm.getLevel(), fcstHr, gpi);
|
||||
}
|
||||
d2dRecord = d2dDao.getGrid(d2dModelName, refTime,
|
||||
parm.getComponents()[0], parm.getLevel(), fcstHr, gpi);
|
||||
} catch (Exception e) {
|
||||
throw new GfeException(
|
||||
"Error retrieving D2D Grid record from database for "
|
||||
|
@ -1294,7 +1322,7 @@ public class D2DGridDatabase extends VGridDatabase {
|
|||
public GridUpdateNotification update(GridRecord record) {
|
||||
String d2dParamName = record.getParameter().getAbbreviation();
|
||||
Level level = record.getLevel();
|
||||
Integer fcstHour = record.getDataTime().getFcstTime();
|
||||
DataTime dataTime = record.getDataTime();
|
||||
|
||||
D2DParm parm = getD2DParm(d2dParamName, level);
|
||||
if (parm == null) {
|
||||
|
@ -1316,14 +1344,14 @@ public class D2DGridDatabase extends VGridDatabase {
|
|||
// if wind see if other component is available
|
||||
if (otherComponent != null) {
|
||||
// get the other components times
|
||||
List<Integer> otherTimes;
|
||||
List<DataTime> otherTimes;
|
||||
try {
|
||||
// TODO: could just query for desired fcstHour instead of all
|
||||
otherTimes = d2dDao.queryFcstHourByParmId(d2dModelName,
|
||||
otherTimes = d2dDao.queryDataTimeByParmId(d2dModelName,
|
||||
refTime, otherComponent, parm.getLevel());
|
||||
|
||||
// if we don't have the other component for this time
|
||||
if (!otherTimes.contains(fcstHour)) {
|
||||
if (!otherTimes.contains(dataTime)) {
|
||||
// need to wait for other component
|
||||
return null;
|
||||
}
|
||||
|
@ -1336,11 +1364,16 @@ public class D2DGridDatabase extends VGridDatabase {
|
|||
}
|
||||
}
|
||||
|
||||
TimeRange tr = getTimeRange(parmID, fcstHour);
|
||||
if (tr == null) {
|
||||
statusHandler.warn("Unexpected fcst hour (" + fcstHour + ") for "
|
||||
+ parmID);
|
||||
return null;
|
||||
TimeRange tr = null;
|
||||
if (parm.useDatabaseTimeRange()) {
|
||||
tr = dataTime.getValidPeriod();
|
||||
} else {
|
||||
tr = getTimeRange(parmID, dataTime.getFcstTime());
|
||||
if (tr == null) {
|
||||
statusHandler.warn("Unexpected fcst hour ("
|
||||
+ dataTime.getFcstTime() + ") for " + parmID);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
List<GridDataHistory> histList = new ArrayList<GridDataHistory>();
|
||||
histList.add(new GridDataHistory(
|
||||
|
|
|
@ -350,8 +350,25 @@
|
|||
</levels>
|
||||
</gridParameterInfo>
|
||||
<gridParameterInfo xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="parameterInfo">
|
||||
<short_name>tp</short_name>
|
||||
<long_name>total precipitation</long_name>
|
||||
<useDatabaseTimeRange>true</useDatabaseTimeRange>
|
||||
<short_name>tp3hr</short_name>
|
||||
<long_name>total precipitation 3hr</long_name>
|
||||
<units>mm</units>
|
||||
<udunits>millimeter</udunits>
|
||||
<uiname>totPrecip</uiname>
|
||||
<valid_range>0.0</valid_range>
|
||||
<valid_range>1000.0</valid_range>
|
||||
<fillValue>-99999.0</fillValue>
|
||||
<n3D>0</n3D>
|
||||
<levelsDesc>SFC</levelsDesc>
|
||||
<levels>
|
||||
<level>SFC</level>
|
||||
</levels>
|
||||
</gridParameterInfo>
|
||||
<gridParameterInfo xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="parameterInfo">
|
||||
<useDatabaseTimeRange>true</useDatabaseTimeRange>
|
||||
<short_name>tp6hr</short_name>
|
||||
<long_name>total precipitation 6hr</long_name>
|
||||
<units>mm</units>
|
||||
<udunits>millimeter</udunits>
|
||||
<uiname>totPrecip</uiname>
|
||||
|
|
|
@ -1,24 +1,24 @@
|
|||
##
|
||||
# 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.
|
||||
##
|
||||
# SOFTWARE HISTORY
|
||||
#
|
||||
#
|
||||
# Date Ticket# Engineer Description
|
||||
# ------------ ---------- ----------- --------------------------
|
||||
# 02/16/12 14439 jdynina modified haines thresholds
|
||||
|
@ -26,12 +26,14 @@
|
|||
# 07/25/12 #957 dgilling implement edit areas as args to calc methods.
|
||||
# 10/05/12 15158 ryu add Forecaster.getDb()
|
||||
# 04/04/13 #1787 randerso fix validTime check to work with accumulative parms
|
||||
# fix logging so you can actually determine why
|
||||
# fix logging so you can actually determine why
|
||||
# a smartInit is not calculating a parameter
|
||||
# 10/29/2013 #2476 njensen Improved getting wx/discrete keys when retrieving data
|
||||
# 10/27/2014 #3766 randerso Changed _getLatest to include error text returned from InitClient.createDB()
|
||||
# Apr 23, 2015 4259 njensen Updated for new JEP API
|
||||
#
|
||||
# Apr 23, 2015 #4259 njensen Updated for new JEP API
|
||||
# Dec 03, 2015 #5168 randerso Fixed problems running calc methods with both accumulative
|
||||
# and non-accumulative weather elements as inputs
|
||||
#
|
||||
##
|
||||
import string, sys, re, time, types, getopt, fnmatch, LogStream, DatabaseID, JUtil, AbsTime, TimeRange
|
||||
import SmartInitParams
|
||||
|
@ -40,7 +42,35 @@ pytime = time
|
|||
|
||||
import RollBackImporter
|
||||
rollbackImporter = RollBackImporter.RollBackImporter()
|
||||
|
||||
|
||||
MAX_TIME = 2**31-1
|
||||
|
||||
def printTR(tr):
|
||||
if tr is None:
|
||||
return "None"
|
||||
|
||||
if hasattr(tr, 'java_name'):
|
||||
tr = TimeRange.encodeJavaTimeRange(tr)
|
||||
|
||||
msg = '('
|
||||
stime = time.gmtime(tr[0])
|
||||
etime = time.gmtime(tr[1])
|
||||
stime = time.strftime('%Y%m%d_%H%M', stime)
|
||||
etime = time.strftime('%Y%m%d_%H%M', etime)
|
||||
msg += stime + ", " + etime
|
||||
msg += ')'
|
||||
return msg
|
||||
|
||||
def printTRs(trList):
|
||||
msg = '['
|
||||
for tr in trList:
|
||||
s = printTR(tr)
|
||||
msg += s
|
||||
msg += ', '
|
||||
|
||||
msg += ']'
|
||||
return msg
|
||||
|
||||
#--------------------------------------------------------------------------
|
||||
# Main program that calls model-specific algorithms to generate ifp grids.
|
||||
|
@ -81,7 +111,7 @@ class MDB:
|
|||
for db in self.__dbs:
|
||||
keyLow = key.lower()
|
||||
for k in JUtil.javaStringListToPylist(db.getKeys()):
|
||||
if k.lower() == keyLow:
|
||||
if k.lower() == keyLow:
|
||||
return db.getItem(key)
|
||||
|
||||
#for db in self.__dbs:
|
||||
|
@ -286,15 +316,13 @@ class GridUtilities:
|
|||
return hainesT + hainesM
|
||||
|
||||
|
||||
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
# Weather Element calculations
|
||||
#-------------------------------------------------------------------------
|
||||
class Forecaster(GridUtilities):
|
||||
def __init__(self, srcName, dstName=None):
|
||||
self._srcName = srcName
|
||||
self._dstName = dstName
|
||||
self._dstName = dstName
|
||||
self._ndbkeys = None
|
||||
self.__dbParms = None
|
||||
#host, port = self._getServer()
|
||||
|
@ -302,7 +330,7 @@ class Forecaster(GridUtilities):
|
|||
#if Options is not None and Options.has_key('userID'):
|
||||
# self._client = ifpc.IFPC(host, port, Options['userID'])
|
||||
#else:
|
||||
# self._client = ifpc.IFPC(host, port)
|
||||
# self._client = ifpc.IFPC(host, port)
|
||||
self.whichHainesIndex = "HIGH" # or "LOW", or "MEDIUM"
|
||||
|
||||
if self._srcName is not None:
|
||||
|
@ -327,10 +355,10 @@ class Forecaster(GridUtilities):
|
|||
msg = "No databases for " + self._srcName
|
||||
LogStream.logProblem(msg)
|
||||
return
|
||||
|
||||
|
||||
if self.newdb() is None:
|
||||
return
|
||||
|
||||
|
||||
self.__topo = self.getTopo() * .3048
|
||||
srcdbkeys = self.srcdb().getKeys()
|
||||
if "staticTopo_Dflt" in srcdbkeys:
|
||||
|
@ -342,13 +370,13 @@ class Forecaster(GridUtilities):
|
|||
self.__stopo = None
|
||||
else:
|
||||
self.__stopo = None
|
||||
|
||||
# TODO: this is a work around to keep smart init running
|
||||
# until we get the staticTopo_Dflt parameter populated
|
||||
|
||||
# TODO: this is a work around to keep smart init running
|
||||
# until we get the staticTopo_Dflt parameter populated
|
||||
# if self.__stopo is None:
|
||||
# LogStream.logProblem("staticTopo not available, using topo")
|
||||
# self.__stopo = self.__topo
|
||||
|
||||
|
||||
self._editAreas = self._client.getEditAreaNames()
|
||||
self._empty = self.__topo * 0
|
||||
self._minus = self._empty - 1
|
||||
|
@ -525,22 +553,22 @@ class Forecaster(GridUtilities):
|
|||
# Returns the topography grid.
|
||||
#--------------------------------------------------------------------------
|
||||
def getTopo(self):
|
||||
topo = self._client.getTopo()
|
||||
topo = self._client.getTopo()
|
||||
topo = topo.getNDArray()
|
||||
return topo
|
||||
return topo
|
||||
|
||||
#--------------------------------------------------------------------------
|
||||
# Returns a dictionary of magical values that will be used in other
|
||||
# functions.
|
||||
#--------------------------------------------------------------------------
|
||||
def magicArgs(self):
|
||||
rval = { "topo" : (self.__topo, (0, sys.maxint)),
|
||||
"stopo" : (self.__stopo, (0, sys.maxint)),
|
||||
"ctime" : (None, (0, sys.maxint)),
|
||||
"stime" : (None, (0, sys.maxint)),
|
||||
"mtime" : (None, (0, sys.maxint))}
|
||||
rval = { "topo" : (self.__topo, (0, MAX_TIME)),
|
||||
"stopo" : (self.__stopo, (0, MAX_TIME)),
|
||||
"ctime" : (None, (0, MAX_TIME)),
|
||||
"stime" : (None, (0, MAX_TIME)),
|
||||
"mtime" : (None, (0, MAX_TIME))}
|
||||
for i in self._editAreas:
|
||||
rval[i] = (None, (0, sys.maxint))
|
||||
rval[i] = (None, (0, MAX_TIME))
|
||||
return rval
|
||||
|
||||
#--------------------------------------------------------------------------
|
||||
|
@ -548,8 +576,8 @@ class Forecaster(GridUtilities):
|
|||
#--------------------------------------------------------------------------
|
||||
def run(self):
|
||||
dbName = SmartInitParams.params['dbName']
|
||||
validTime = SmartInitParams.params['validTime']
|
||||
|
||||
validTime = SmartInitParams.params['validTime']
|
||||
|
||||
dbInfo = dbName.split(':')
|
||||
self.__dbName = dbInfo[0]
|
||||
|
||||
|
@ -557,7 +585,7 @@ class Forecaster(GridUtilities):
|
|||
self.__init()
|
||||
if self.newdb() is None:
|
||||
return
|
||||
|
||||
|
||||
msgDest = "Destination database:" + self.newdb().getModelIdentifier()
|
||||
|
||||
if validTime is not None:
|
||||
|
@ -569,7 +597,7 @@ class Forecaster(GridUtilities):
|
|||
self._ifpio = IFPIO(self.srcdb(), self.newdb())
|
||||
self._ifpio.setLevels(self.levels())
|
||||
methods = self.__getMethods()
|
||||
times = self.__sortTimes(methods, validTime)
|
||||
times = self.__sortTimes(methods, validTime)
|
||||
tr, numGrids = self.__process(methods, times, int(dbInfo[1]))
|
||||
stop = time.time()
|
||||
msgTime = "Elapsed time: " + ("%-.1f" % (stop - start)) + "sec."
|
||||
|
@ -588,7 +616,7 @@ class Forecaster(GridUtilities):
|
|||
modelTime = AbsTime.AbsTime(db.getModelTime())
|
||||
modelTime = modelTime.unixTime()
|
||||
else:
|
||||
modelTime = 0
|
||||
modelTime = 0
|
||||
modelIdentifier = db.getShortModelIdentifier()
|
||||
|
||||
if modelTime != 0:
|
||||
|
@ -630,14 +658,14 @@ class Forecaster(GridUtilities):
|
|||
" is empty.")
|
||||
else:
|
||||
srcdbs.append(db)
|
||||
|
||||
|
||||
srcdb = MDB(srcdbs)
|
||||
|
||||
# I (njensen) removed most of what was here. It was looking at
|
||||
# the available D2D netcdf data, and then forming a GFE db id
|
||||
# from that for the target. Instead I'm just passing in
|
||||
# from that for the target. Instead I'm just passing in
|
||||
# the target from Java.
|
||||
|
||||
|
||||
newdb = self.__dbName.replace("D2D", "")
|
||||
if fcstName and fcstName != modelName:
|
||||
newdb = newdb.replace(modelName, fcstName)
|
||||
|
@ -654,7 +682,7 @@ class Forecaster(GridUtilities):
|
|||
break
|
||||
if singletonNeeded:
|
||||
newdb = newdb[:-13] + '00000000_0000'
|
||||
newdb = self.getDb(newdb)
|
||||
newdb = self.getDb(newdb)
|
||||
else:
|
||||
sr = client.createDB(newdb)
|
||||
if sr.isOkay():
|
||||
|
@ -663,7 +691,7 @@ class Forecaster(GridUtilities):
|
|||
msg = "Unable to create database for " + str(newdb) + ":\n" + \
|
||||
str(sr.message())
|
||||
LogStream.logProblem(msg)
|
||||
newdb = None
|
||||
newdb = None
|
||||
|
||||
return srcdb, newdb
|
||||
|
||||
|
@ -726,7 +754,7 @@ class Forecaster(GridUtilities):
|
|||
#--------------------------------------------------------------------------
|
||||
# Returns true if the two timeRanges overlap (share a common time period).
|
||||
#--------------------------------------------------------------------------
|
||||
def _overlaps(self, tr1, tr2):
|
||||
def _overlaps(self, tr1, tr2):
|
||||
if self._contains(tr2, tr1[0]) or self._contains(tr1, tr2[0]):
|
||||
return 1
|
||||
return 0
|
||||
|
@ -762,7 +790,7 @@ class Forecaster(GridUtilities):
|
|||
wenameLevel = wename
|
||||
else:
|
||||
wenameLevel = wename + "_SFC"
|
||||
#if wenameLevel not in self.newdb().keys():
|
||||
#if wenameLevel not in self.newdb().keys():
|
||||
if wenameLevel not in JUtil.javaStringListToPylist(self.newdb().getKeys()):
|
||||
msg = wenameLevel + " not in " + \
|
||||
self.newdb().getModelIdentifier() + " " + "SKIPPING"
|
||||
|
@ -770,7 +798,7 @@ class Forecaster(GridUtilities):
|
|||
continue
|
||||
rval = filter(lambda x,y=wenameLevel : x[0] != y, rval)
|
||||
rval.append((wenameLevel, mthd, fargs))
|
||||
return rval
|
||||
return rval
|
||||
|
||||
#--------------------------------------------------------------------------
|
||||
# Gets and returns a list of dependencies.
|
||||
|
@ -796,13 +824,13 @@ class Forecaster(GridUtilities):
|
|||
rval = []
|
||||
methods = self.__getObjMethods(self.__class__)
|
||||
while len(methods):
|
||||
rval += self.__getdeps(methods[0], methods)
|
||||
rval += self.__getdeps(methods[0], methods)
|
||||
return rval
|
||||
|
||||
def __request(self, db, pname, time):
|
||||
if pname[-2:] == "_c":
|
||||
if pname[-2:] == "_c":
|
||||
time = self.__getSrcWE(
|
||||
pname[:-2] + "_MB500", 0).getTimeRange(time[0])
|
||||
pname[:-2] + "_MB500", 0).getTimeRange(time[0])
|
||||
rval = (pname[:-2], time, 1)
|
||||
else:
|
||||
time = self.__getSrcWE(pname, 0).getTimeRange(time[0])
|
||||
|
@ -825,9 +853,11 @@ class Forecaster(GridUtilities):
|
|||
# Internal function that returns the time periods shared by tr and times.
|
||||
#--------------------------------------------------------------------------
|
||||
def __compTimes(self, tr, times):
|
||||
# TODO: surely there's a better way to do this
|
||||
|
||||
for time in times:
|
||||
if len(time) == 0:
|
||||
return []
|
||||
return []
|
||||
|
||||
rval = []
|
||||
if len(times) == 1:
|
||||
|
@ -858,7 +888,7 @@ class Forecaster(GridUtilities):
|
|||
rval = []
|
||||
calced = []
|
||||
for we, mthd, args in methods:
|
||||
# LogStream.logEvent("Evaluating times for calc"+we)
|
||||
# LogStream.logEvent("Evaluating times for", mthd.func_name)
|
||||
calced.append(we)
|
||||
args = filter(lambda x, ma=self.magicArgs().keys() + [we]:
|
||||
x not in ma, args)
|
||||
|
@ -866,7 +896,7 @@ class Forecaster(GridUtilities):
|
|||
for a in args:
|
||||
nargs = nargs + self.__unpackParm(a)
|
||||
|
||||
ttimes = []
|
||||
ttimes = []
|
||||
for p in nargs:
|
||||
# p is an arg, e.g. gh_MB900
|
||||
try:
|
||||
|
@ -883,7 +913,7 @@ class Forecaster(GridUtilities):
|
|||
for i in range(size):
|
||||
jtr = ranges.get(i)
|
||||
valid = False
|
||||
|
||||
|
||||
if validTime is None:
|
||||
valid = True
|
||||
else:
|
||||
|
@ -891,33 +921,24 @@ class Forecaster(GridUtilities):
|
|||
# need both accumulative and non-accumulative parms
|
||||
valid = validTime.getTime() >= jtr.getStart().getTime() and \
|
||||
validTime.getTime() <= jtr.getEnd().getTime()
|
||||
|
||||
|
||||
if valid:
|
||||
timelist = TimeRange.encodeJavaTimeRange(jtr)
|
||||
timelist = TimeRange.encodeJavaTimeRange(jtr)
|
||||
pylist.append(timelist)
|
||||
|
||||
ttimes.append(pylist)
|
||||
|
||||
# msg = "Times available for " + p + " " + str(validTime) + ":\n"
|
||||
# timeList = ttimes[len(ttimes)-1]
|
||||
# for xtime in timeList:
|
||||
# msg += '('
|
||||
# stime = time.gmtime(xtime[0])
|
||||
# etime = time.gmtime(xtime[1])
|
||||
# stime = time.strftime('%Y%m%d_%H%M', stime)
|
||||
# etime = time.strftime('%Y%m%d_%H%M', etime)
|
||||
# msg += stime + ", " + etime
|
||||
# msg += ')\n'
|
||||
# LogStream.logEvent(msg)
|
||||
|
||||
# msg = "Times available for " + p + " " + str(validTime) + ":\n"
|
||||
# timeList = ttimes[-1]
|
||||
# msg += printTRs(timeList)
|
||||
# LogStream.logEvent(msg)
|
||||
|
||||
# compare the times of each parm and find where they match up
|
||||
times = self.__compTimes(None, ttimes)
|
||||
# LogStream.logEvent("nargs:",nargs)
|
||||
# LogStream.logEvent("ttimes:",ttimes)
|
||||
# LogStream.logEvent("times:",times)
|
||||
# LogStream.logEvent("times:", printTRs(times))
|
||||
|
||||
hadDataButSkipped = {}
|
||||
for i in range(len(ttimes)):
|
||||
for i in range(len(ttimes)):
|
||||
timeList = ttimes[i]
|
||||
parmName = nargs[i]
|
||||
for xtime in timeList:
|
||||
|
@ -926,29 +947,32 @@ class Forecaster(GridUtilities):
|
|||
hadDataButSkipped[xtime].append(parmName)
|
||||
else:
|
||||
hadDataButSkipped[xtime] = [parmName]
|
||||
# LogStream.logEvent("hadDataButSkipped:",hadDataButSkipped)
|
||||
# msg = "hadDataButSkipped: {"
|
||||
# for tr in hadDataButSkipped:
|
||||
# msg += printTR(tr)
|
||||
# msg += ": "
|
||||
# msg += str(hadDataButSkipped[tr])
|
||||
# msg += ", "
|
||||
# msg += "}"
|
||||
# LogStream.logEvent(msg)
|
||||
|
||||
hadNoData = []
|
||||
hadNoData = []
|
||||
for i in range(len(nargs)):
|
||||
timeList = ttimes[i]
|
||||
parmName = nargs[i]
|
||||
if len(timeList) == 0:
|
||||
hadNoData.append(parmName)
|
||||
# LogStream.logEvent("hadNoData:",hadNoData)
|
||||
# LogStream.logEvent("hadNoData:",hadNoData)
|
||||
|
||||
missing = {}
|
||||
missing = {}
|
||||
for xtime in hadDataButSkipped:
|
||||
stime = time.gmtime(xtime[0])
|
||||
etime = time.gmtime(xtime[1])
|
||||
stime = time.strftime('%Y%m%d_%H%M', stime)
|
||||
etime = time.strftime('%Y%m%d_%H%M', etime)
|
||||
msg = stime + ", " + etime
|
||||
msg = printTR(xtime)
|
||||
missing[msg] = []
|
||||
|
||||
|
||||
for parmName in nargs:
|
||||
if not hadDataButSkipped[xtime].__contains__(parmName):
|
||||
missing[msg].append(parmName)
|
||||
|
||||
|
||||
if len(missing) == 0 and len(hadNoData) > 0:
|
||||
msg = ''
|
||||
if (validTime is not None):
|
||||
|
@ -956,9 +980,9 @@ class Forecaster(GridUtilities):
|
|||
vtime = time.gmtime(vtime)
|
||||
msg = time.strftime('%Y%m%d_%H%M', vtime)
|
||||
missing[msg] = hadNoData
|
||||
# LogStream.logEvent("missing:",missing)
|
||||
# LogStream.logEvent("missing:",missing)
|
||||
|
||||
if len(missing):
|
||||
if len(missing):
|
||||
LogStream.logEvent("Skipping calc" + we + " for some times due to the following " +
|
||||
"missing data:", missing)
|
||||
# these become the times to run the method for
|
||||
|
@ -980,102 +1004,119 @@ class Forecaster(GridUtilities):
|
|||
|
||||
def __recursiveArg(self, cache, arg, time):
|
||||
p = self.newdb().getItem(arg)
|
||||
#p = self.newdb()[arg + "_SFC"]
|
||||
tr = p.getTimeRange(time[0])
|
||||
pytr = TimeRange.encodeJavaTimeRange(tr)
|
||||
pkeys = TimeRange.javaTimeRangeListToPyList(p.getKeys())
|
||||
if pytr in pkeys:
|
||||
|
||||
# tr = p.getTimeRange(time[0])
|
||||
tr = TimeRange.TimeRange(AbsTime.AbsTime(time[0]), AbsTime.AbsTime(time[1])).toJavaObj()
|
||||
times = p.getKeys(tr)
|
||||
if times:
|
||||
tr = times[0]
|
||||
LogStream.logEvent("retrieving", arg, printTR(tr))
|
||||
|
||||
pytr = TimeRange.encodeJavaTimeRange(tr)
|
||||
jslice = p.getItem(tr)
|
||||
slice = jslice.getNDArray()
|
||||
if type(slice) is ndarray and slice.dtype == int8:
|
||||
# discrete or weather
|
||||
keys = JUtil.javaObjToPyVal(jslice.getKeyList())
|
||||
slice = [slice, keys]
|
||||
slice = [slice, keys]
|
||||
cache[arg] = (slice, pytr)
|
||||
else:
|
||||
else:
|
||||
LogStream.logEvent("no data for", arg, printTR(tr))
|
||||
cache[arg] = (None, time)
|
||||
|
||||
def __argFill(self, cache, method, time):
|
||||
we, mthd, args = method
|
||||
LogStream.logEvent("getting arguments for", mthd.func_name, printTR(time))
|
||||
|
||||
gargs = []
|
||||
if self._ndbkeys is None:
|
||||
self._ndbkeys = JUtil.javaStringListToPylist(self.newdb().getKeys())
|
||||
ndbkeys = self._ndbkeys
|
||||
ndbkeys = self._ndbkeys
|
||||
for arg in args:
|
||||
if arg in self._editAreas:
|
||||
if cache[arg][0] is None:
|
||||
p = self.newdb().getItem(we)
|
||||
ea = p.getEditArea(arg).getNDArray()
|
||||
cache[arg] = (ea, (0, sys.maxint))
|
||||
cache[arg] = (ea, (0, MAX_TIME))
|
||||
gargs.append(cache[arg][0])
|
||||
continue
|
||||
if not cache.has_key(arg):
|
||||
if not cache.has_key(arg):
|
||||
if arg in ndbkeys:
|
||||
self.__recursiveArg(cache, arg, time)
|
||||
else:
|
||||
val = self._ifpio.get(self.__request(self.srcdb(),
|
||||
arg, time))
|
||||
req = self.__request(self.srcdb(), arg, time)
|
||||
val = self._ifpio.get(req)
|
||||
if arg[-2:] == "_c":
|
||||
self.pres = val[0]
|
||||
val = val[1]
|
||||
cache[arg] = (val, time)
|
||||
cache[arg] = (val, TimeRange.encodeJavaTimeRange(req[1]))
|
||||
else:
|
||||
if cache[arg][1] is not None and \
|
||||
not self._overlaps(time, cache[arg][1]):
|
||||
not self._overlaps(time, cache[arg][1]):
|
||||
if arg in ndbkeys:
|
||||
self.__recursiveArg(cache, arg, time)
|
||||
val = cache[arg][0]
|
||||
else:
|
||||
val = self._ifpio.get(self.__request(self.srcdb(),
|
||||
arg, time))
|
||||
if arg[-2:] == "_c":
|
||||
self.pres = val[0]
|
||||
val = val[1]
|
||||
cache[arg] = (val, time)
|
||||
|
||||
else:
|
||||
req = self.__request(self.srcdb(), arg, time)
|
||||
val = self._ifpio.get(req)
|
||||
if arg[-2:] == "_c":
|
||||
self.pres = val[0]
|
||||
val = val[1]
|
||||
cache[arg] = (val, TimeRange.encodeJavaTimeRange(req[1]))
|
||||
else:
|
||||
LogStream.logEvent("using cached", arg, printTR(cache[arg][1]))
|
||||
|
||||
gargs.append(cache[arg][0])
|
||||
return gargs
|
||||
|
||||
def __runMethod(self, method, time, cache):
|
||||
we, mthd, args = method
|
||||
|
||||
|
||||
if self.mostRecentCacheClear != time:
|
||||
self.mostRecentCacheClear = time
|
||||
self.mostRecentCacheClear = time
|
||||
for key in cache.keys():
|
||||
cacheValue = cache[key]
|
||||
if len(cacheValue) == 2 and key.find('_') > -1:
|
||||
# these are WeatherElements, if they are for time ranges that
|
||||
# we've completed calculations for, immediately set them to
|
||||
# None to free up the memory
|
||||
if time[0] != cacheValue[1][0]:
|
||||
if len(cacheValue) == 2:
|
||||
# if they are for time ranges that we've completed calculations for,
|
||||
# immediately set them to None to free up the memory
|
||||
if not self._overlaps(cacheValue[1],time):
|
||||
LogStream.logEvent("Clearing", key, printTR(cacheValue[1]))
|
||||
cache[key] = (None, cacheValue[1])
|
||||
|
||||
|
||||
gargs = self.__argFill(cache, method, time)
|
||||
|
||||
doStore = False
|
||||
if mthd.im_func is Forecaster.__exists.im_func:
|
||||
msg = "Get : " + we + " " + self._timeRangeStr(time)
|
||||
LogStream.logEvent(msg)
|
||||
else:
|
||||
LogStream.logEvent(msg)
|
||||
else:
|
||||
doStore = True
|
||||
msg = "Calc : " + we + " " + self._timeRangeStr(time)
|
||||
LogStream.logEvent(msg)
|
||||
|
||||
LogStream.logEvent(msg)
|
||||
|
||||
try:
|
||||
rval = apply(mthd, tuple(gargs))
|
||||
|
||||
if type(rval) is not ndarray and rval is not None:
|
||||
if type(rval) is not tuple:
|
||||
jrval = rval
|
||||
rval = rval.getNDArray()
|
||||
if type(rval) is ndarray and rval.dtype == int8:
|
||||
# discrete or weather
|
||||
keys = JUtil.javaObjToPyVal(jrval.getKeyList())
|
||||
rval = [rval, keys]
|
||||
|
||||
if rval is not None:
|
||||
if type(rval) is not ndarray and rval is not None:
|
||||
if type(rval) is not tuple:
|
||||
jrval = rval
|
||||
rval = rval.getNDArray()
|
||||
if type(rval) is ndarray and rval.dtype == int8:
|
||||
# discrete or weather
|
||||
keys = JUtil.javaObjToPyVal(jrval.getKeyList())
|
||||
rval = [rval, keys]
|
||||
else:
|
||||
LogStream.logEvent("No value returned from calc"+str(we))
|
||||
|
||||
s = 'grid'
|
||||
if rval is None:
|
||||
s = 'None'
|
||||
LogStream.logEvent("Caching", we, s, printTR(time))
|
||||
cache[we] = (rval, time)
|
||||
|
||||
|
||||
if rval is not None and cache['mtime'][0] is not None and doStore:
|
||||
parm = self.__getNewWE(we)
|
||||
parm = self.__getNewWE(we)
|
||||
LogStream.logEvent("Storing", we, printTR(cache['mtime'][0]))
|
||||
self._ifpio.store(parm, cache['mtime'][0], cache[we][0])
|
||||
except:
|
||||
LogStream.logProblem("Error while running method " + str(we) +
|
||||
|
@ -1094,12 +1135,12 @@ class Forecaster(GridUtilities):
|
|||
for i in xrange(len(methods)):
|
||||
for t in times[i]:
|
||||
lst.append((methods[i], t, i))
|
||||
lst.sort(self.__tsort)
|
||||
lst.sort(self.__tsort)
|
||||
return lst
|
||||
|
||||
def __exists(self, mtime, wename):
|
||||
#parm = self.__getNewWE(wename + "_SFC")
|
||||
parm = self.__getNewWE(wename)
|
||||
def __exists(self, mtime, wename):
|
||||
#parm = self.__getNewWE(wename + "_SFC")
|
||||
parm = self.__getNewWE(wename)
|
||||
return parm.getItem(mtime)
|
||||
|
||||
def __prune(self, lst):
|
||||
|
@ -1112,7 +1153,7 @@ class Forecaster(GridUtilities):
|
|||
#parm = self.__getNewWE(m[0] + "_SFC")
|
||||
tr = TimeRange.encodeJavaTimeRange(parm.getTimeRange(t[0]))
|
||||
if tr is None:
|
||||
continue
|
||||
continue
|
||||
parmtr = TimeRange.javaTimeRangeListToPyList(parm.getKeys())
|
||||
if tr in parmtr:
|
||||
# Skip (maybe)
|
||||
|
@ -1152,35 +1193,35 @@ class Forecaster(GridUtilities):
|
|||
def sourceBaseTime(self):
|
||||
modelTime = self.srcdb().getModelTime()
|
||||
if modelTime is None:
|
||||
modelTime = 0
|
||||
modelTime = 0
|
||||
t = AbsTime.AbsTime(modelTime)
|
||||
return t.unixTime()
|
||||
|
||||
|
||||
# JULIYA MODIFY HERE
|
||||
def __process(self, methods, times, mode):
|
||||
numGrids = 0
|
||||
trSpan = None
|
||||
cache = self.magicArgs()
|
||||
cache = self.magicArgs()
|
||||
all = mode#Options['all'] manual=1 automatic=0
|
||||
list = self.__flattenTimes(methods, times)
|
||||
list = self.__flattenTimes(methods, times)
|
||||
if not all:
|
||||
list = self.__prune(list)
|
||||
|
||||
self.mostRecentCacheClear = None
|
||||
for m, t, i in list:
|
||||
cache['ctime'] = (t, (0, sys.maxint))
|
||||
cache['ctime'] = (t, (0, MAX_TIME))
|
||||
parm = self.__getNewWE(m[0])
|
||||
tr = parm.getTimeRange(t[0])
|
||||
|
||||
# A valid time range was not found so the parameter
|
||||
|
||||
# A valid time range was not found so the parameter
|
||||
# cannot be calculated, so continue
|
||||
if not tr.isValid():
|
||||
continue
|
||||
|
||||
cache['mtime'] = (tr, (0, sys.maxint))
|
||||
cache['wename'] = (m[0], (0, sys.maxint))
|
||||
cache['stime'] = (t[0] - self.sourceBaseTime(), (0, sys.maxint))
|
||||
|
||||
|
||||
cache['mtime'] = (tr, (0, MAX_TIME))
|
||||
cache['wename'] = (m[0], (0, MAX_TIME))
|
||||
cache['stime'] = (t[0] - self.sourceBaseTime(), (0, MAX_TIME))
|
||||
|
||||
try:
|
||||
self.__runMethod(m, t, cache)
|
||||
numGrids = numGrids + 1
|
||||
|
@ -1206,7 +1247,7 @@ class IFPIO:
|
|||
|
||||
def getSrcWE(self, wename, lock=1):
|
||||
rval = None
|
||||
try:
|
||||
try:
|
||||
rval = self.__srcwes[wename]
|
||||
except:
|
||||
rval = self.eta.getItem(wename)
|
||||
|
@ -1221,21 +1262,27 @@ class IFPIO:
|
|||
self.__newwes[wename] = rval
|
||||
return rval
|
||||
|
||||
def get(self, qv):
|
||||
def get(self, qv):
|
||||
if len(qv) == 2:
|
||||
name, time = qv
|
||||
docube = 0
|
||||
else:
|
||||
name, time, docube = qv
|
||||
name, time, docube = qv
|
||||
if not docube:
|
||||
slice = self.getSrcWE(name, 0).getItem(time)
|
||||
p = self.getSrcWE(name, 0)
|
||||
times = p.getKeys(time)
|
||||
if times:
|
||||
time = times[0]
|
||||
LogStream.logEvent("retrieving", name, printTR(time))
|
||||
|
||||
slice = p.getItem(time)
|
||||
out = slice.getNDArray()
|
||||
if type(out) is ndarray and out.dtype == int8:
|
||||
if type(out) is ndarray and out.dtype == int8:
|
||||
# discrete or weather
|
||||
keys = JUtil.javaObjToPyVal(slice.getKeyList())
|
||||
out = [out, keys]
|
||||
out = [out, keys]
|
||||
else:
|
||||
out = self._getcube(self.eta, name, time)
|
||||
out = self._getcube(name, time)
|
||||
return out
|
||||
|
||||
#--------------------------------------------------------------------------
|
||||
|
@ -1251,20 +1298,14 @@ class IFPIO:
|
|||
return self._levels
|
||||
|
||||
#--------------------------------------------------------------------------
|
||||
# Returns the data cube for the specified db, parm, and time.
|
||||
# Returns the data cube for the specified parm, and time.
|
||||
#--------------------------------------------------------------------------
|
||||
def _getcube(self, db, parm, time):
|
||||
def _getcube(self, parm, time):
|
||||
lvls = self.levels()
|
||||
lst = []
|
||||
pres = []
|
||||
for l in lvls:
|
||||
p = self.getSrcWE(parm + "_" + l, 0)
|
||||
jslice = p.getItem(time)
|
||||
slice = jslice.getNDArray()
|
||||
if type(slice) is ndarray and slice.dtype == int8:
|
||||
# discrete or weather
|
||||
keys = JUtil.javaObjToPyVal(jslice.getKeyList())
|
||||
slice = [slice, keys]
|
||||
slice = self.get((parm + "_" + l, time))
|
||||
lst.append(slice)
|
||||
pres.append(int(l[2:]))
|
||||
# only scalars will be ndarray, otherwise it was vector, discrete, or wx
|
||||
|
@ -1275,7 +1316,7 @@ class IFPIO:
|
|||
ml.append(i[0])
|
||||
dl.append(i[1])
|
||||
rval = (array(ml), array(dl))
|
||||
else:
|
||||
else:
|
||||
rval = array(lst)
|
||||
return (pres, rval)
|
||||
|
||||
|
@ -1284,15 +1325,15 @@ class IFPIO:
|
|||
# specified time
|
||||
#--------------------------------------------------------------------------
|
||||
def store(self, newwe, time, grid):
|
||||
gridType = newwe.getGridType()
|
||||
gridType = newwe.getGridType()
|
||||
if gridType == "SCALAR":
|
||||
grid = clip(grid, newwe.getMinAllowedValue(), newwe.getMaxAllowedValue())
|
||||
elif gridType == "VECTOR":
|
||||
mag = clip(grid[0], newwe.getMinAllowedValue(), newwe.getMaxAllowedValue())
|
||||
dir = clip(grid[1], 0, 359.5)
|
||||
grid = (mag, dir)
|
||||
tr = TimeRange.encodeJavaTimeRange(time)
|
||||
# safety checks
|
||||
tr = TimeRange.encodeJavaTimeRange(time)
|
||||
# safety checks
|
||||
wrongType = None
|
||||
saved = False
|
||||
if type(grid) is ndarray:
|
||||
|
@ -1311,18 +1352,18 @@ class IFPIO:
|
|||
dirGrid = dirGrid.astype('float32')
|
||||
# vector save
|
||||
newwe.setItemVector(newwe.getTimeRange(tr[0]), magGrid, dirGrid)
|
||||
saved = True
|
||||
saved = True
|
||||
elif type(grid[0]) is ndarray and type(grid[1]) is list:
|
||||
bgrid = grid[0]
|
||||
if bgrid.dtype != dtype('byte'):
|
||||
bgrid = bgrid.astype('byte')
|
||||
|
||||
|
||||
if gridType == "DISCRETE":
|
||||
newwe.setItemDiscrete(newwe.getTimeRange(tr[0]), bgrid, str(grid[1]))
|
||||
elif gridType == "WEATHER":
|
||||
newwe.setItemWeather(newwe.getTimeRange(tr[0]), bgrid, str(grid[1]))
|
||||
|
||||
saved = True
|
||||
|
||||
saved = True
|
||||
if not saved:
|
||||
if wrongType is None:
|
||||
wrongType = type(grid)
|
||||
|
@ -1332,10 +1373,10 @@ class IFPIO:
|
|||
#--------------------------------------------------------------------------
|
||||
# Main program
|
||||
#--------------------------------------------------------------------------
|
||||
def runFromJava(dbName, model, validTime):
|
||||
def runFromJava(dbName, model, validTime):
|
||||
SmartInitParams.params['dbName'] = dbName
|
||||
SmartInitParams.params['validTime'] = validTime
|
||||
|
||||
|
||||
mod = __import__(model)
|
||||
mod.main()
|
||||
rollbackImporter.rollback()
|
||||
|
|
|
@ -61,6 +61,7 @@ import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement;
|
|||
* ------------- -------- ----------- --------------------------
|
||||
* Jun 11, 2014 2061 bsteffen Remove IDecoderGettable
|
||||
* Sep 04, 2014 3220 skorolev Removed cwa and monitorUse from record.
|
||||
* Dec 02, 2015 3873 dhladky Method naming fixes.
|
||||
*
|
||||
* </pre>
|
||||
*/
|
||||
|
@ -119,7 +120,7 @@ public class FSSObsRecord extends PersistablePluginDataObject implements
|
|||
@Transient
|
||||
@DynamicSerializeElement
|
||||
@XmlElement
|
||||
private boolean isStationary;
|
||||
private boolean stationary;
|
||||
|
||||
// Actual time of the observation
|
||||
@Transient
|
||||
|
@ -439,13 +440,6 @@ public class FSSObsRecord extends PersistablePluginDataObject implements
|
|||
return location.getElevation();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the isStationary
|
||||
*/
|
||||
public boolean isStationary() {
|
||||
return isStationary;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the refHour
|
||||
*/
|
||||
|
@ -718,18 +712,6 @@ public class FSSObsRecord extends PersistablePluginDataObject implements
|
|||
this.location = location;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param isStationary
|
||||
* the isStationary to set
|
||||
*/
|
||||
public void setIsStationary(boolean isStationary) {
|
||||
this.isStationary = isStationary;
|
||||
}
|
||||
|
||||
public boolean getIsStationary() {
|
||||
return isStationary;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param timeObs
|
||||
* the timeObs to set
|
||||
|
@ -1114,4 +1096,21 @@ public class FSSObsRecord extends PersistablePluginDataObject implements
|
|||
public String getPluginName() {
|
||||
return PLUGIN_NAME;
|
||||
}
|
||||
|
||||
/**
|
||||
* Is this a moving or stationary platform
|
||||
* @return
|
||||
*/
|
||||
public boolean isStationary() {
|
||||
return stationary;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set moving or stationary platform
|
||||
* @param stationary
|
||||
*/
|
||||
public void setStationary(boolean stationary) {
|
||||
this.stationary = stationary;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -37,8 +37,9 @@ import com.raytheon.uf.common.time.util.TimeUtil;
|
|||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Mar 8, 2011 skorolev Initial creation
|
||||
* Mar 8, 2011 skorolev Initial creation
|
||||
* Jul 23, 2014 3410 bclement location changed to floats
|
||||
* Dec 02, 2015 3873 dhladky Added reportType, stationary
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -132,6 +133,10 @@ public class FSSObsRecordTransform {
|
|||
private static final String WIND_GUST = "windGust";
|
||||
|
||||
private static final String WIND_SPEED = "windSpeed";
|
||||
|
||||
private static final String STATIONARY = "stationary";
|
||||
|
||||
private static final String REPORT_TYPE = "reportType";
|
||||
|
||||
public static final String[] FSSOBS_PARAMS = { DATA_URI, LONGITUDE,
|
||||
LATITUDE, ELEVATION, CEILING, DEWPOINT, DEWPOINT_DEPR,
|
||||
|
@ -143,7 +148,7 @@ public class FSSObsRecordTransform {
|
|||
SKY_COVER, SNOW_INC_HOURLY, SNOW_INC_TOTAL, SNOW_DEPTH,
|
||||
STATION_NAME, TEMPERATURE, TIME_OBS, REF_HOUR, CLOUD_AMOUNT_TOT,
|
||||
VISIBILITY, WAVE_HEIGHT, WV_HGT, WV_PD, WV_STEEPNESS, WIND_DIR,
|
||||
WIND_GUST, WIND_SPEED };
|
||||
WIND_GUST, WIND_SPEED, STATIONARY, REPORT_TYPE };
|
||||
|
||||
public static final String FSSOBS_PARAMS_LIST;
|
||||
|
||||
|
@ -181,10 +186,15 @@ public class FSSObsRecordTransform {
|
|||
return records.toArray(new FSSObsRecord[records.size()]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Reconstitutes an FSSObsRecord from the pointData view.
|
||||
* @param pdv
|
||||
* @return
|
||||
*/
|
||||
private static FSSObsRecord toFSSObsRecord(PointDataView pdv) {
|
||||
FSSObsRecord obs = null;
|
||||
if (pdv != null) {
|
||||
// String uri = pdv.getString(DATA_URI);
|
||||
|
||||
obs = new FSSObsRecord();
|
||||
obs.setDataURI(pdv.getString(DATA_URI));
|
||||
SurfaceObsLocation loc = new SurfaceObsLocation(
|
||||
|
@ -194,6 +204,8 @@ public class FSSObsRecordTransform {
|
|||
loc.assignLocation(lat, lon);
|
||||
loc.setElevation(pdv.getNumber(ELEVATION).intValue());
|
||||
obs.setLocation(loc);
|
||||
obs.setStationary(Boolean.parseBoolean(pdv.getString(STATIONARY)));
|
||||
obs.setReportType(pdv.getString(REPORT_TYPE));
|
||||
obs.setCeiling(pdv.getFloat(CEILING));
|
||||
obs.setDewpoint(pdv.getNumber(DEWPOINT).floatValue());
|
||||
obs.setDewpointDepr(pdv.getFloat(DEWPOINT_DEPR));
|
||||
|
|
|
@ -20,6 +20,8 @@
|
|||
package com.raytheon.uf.common.monitor.config;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
|
@ -36,6 +38,7 @@ 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.localization.exception.LocalizationException;
|
||||
import com.raytheon.uf.common.monitor.MonitorAreaUtils;
|
||||
import com.raytheon.uf.common.monitor.data.AdjacentWfoMgr;
|
||||
import com.raytheon.uf.common.monitor.events.MonitorConfigEvent;
|
||||
|
@ -44,11 +47,13 @@ import com.raytheon.uf.common.monitor.xml.AreaIdXML;
|
|||
import com.raytheon.uf.common.monitor.xml.AreaIdXML.ZoneType;
|
||||
import com.raytheon.uf.common.monitor.xml.MonAreaConfigXML;
|
||||
import com.raytheon.uf.common.monitor.xml.StationIdXML;
|
||||
import com.raytheon.uf.common.serialization.SerializationException;
|
||||
import com.raytheon.uf.common.serialization.SingleTypeJAXBManager;
|
||||
import com.raytheon.uf.common.site.SiteMap;
|
||||
import com.raytheon.uf.common.status.IUFStatusHandler;
|
||||
import com.raytheon.uf.common.status.UFStatus;
|
||||
import com.raytheon.uf.common.status.UFStatus.Priority;
|
||||
import com.vividsolutions.jts.io.ParseException;
|
||||
|
||||
/**
|
||||
* Fog, SAFESEAS and SNOW Monitor configuration manager.
|
||||
|
@ -71,6 +76,10 @@ import com.raytheon.uf.common.status.UFStatus.Priority;
|
|||
* Sep 04 2014 3220 skorolev Added fileUpdated method.
|
||||
* Feb 24 2015 3220 dhladky Made sure config file is read in on change.
|
||||
* Sep 17 2015 3873 skorolev Corrected getInstance, addArea, addAdjArea and added getAdjAreaConfigXml.
|
||||
* Oct 20 2015 3841 skorolev Changed save method.
|
||||
* Dec 02 2015 3873 dhladky Pulled 3841 changes to 16.1.1.
|
||||
*
|
||||
*
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -192,16 +201,14 @@ public class FSSObsMonitorConfigurationManager implements
|
|||
boolean monitorAreaFileExists = true;
|
||||
boolean adjacentAreaFileExists = true;
|
||||
// Read area configuration XML file.
|
||||
try {
|
||||
IPathManager pm = PathManagerFactory.getPathManager();
|
||||
LocalizationContext lc = pm.getContext(
|
||||
LocalizationType.COMMON_STATIC, LocalizationLevel.SITE);
|
||||
this.currentSite = lc.getContextName();
|
||||
lacf = pm.getLocalizationFile(lc, configFileName);
|
||||
String monitorAreaFilePath = lacf.getFile().getAbsolutePath();
|
||||
MonAreaConfigXML configXmltmp = jaxb
|
||||
.unmarshalFromXmlFile(monitorAreaFilePath.toString());
|
||||
configXml = configXmltmp;
|
||||
IPathManager pm = PathManagerFactory.getPathManager();
|
||||
LocalizationContext lc = pm.getContext(LocalizationType.COMMON_STATIC,
|
||||
LocalizationLevel.SITE);
|
||||
this.currentSite = lc.getContextName();
|
||||
lacf = pm.getLocalizationFile(lc, configFileName);
|
||||
try (InputStream inStrm = lacf.openInputStream()) {
|
||||
configXml = (MonAreaConfigXML) jaxb
|
||||
.unmarshalFromInputStream(inStrm);
|
||||
} catch (Exception e) {
|
||||
statusHandler
|
||||
.handle(Priority.WARN,
|
||||
|
@ -212,12 +219,11 @@ public class FSSObsMonitorConfigurationManager implements
|
|||
monitorAreaFileExists = false;
|
||||
}
|
||||
// Read adjacent area configuration XML file.
|
||||
String adjacentAreaFilePath = pm.getFile(
|
||||
pm.getContext(LocalizationType.COMMON_STATIC,
|
||||
LocalizationLevel.SITE), adjAreaConfigFileName)
|
||||
.getAbsolutePath();
|
||||
try {
|
||||
IPathManager pm = PathManagerFactory.getPathManager();
|
||||
String adjacentAreaFilePath = pm.getFile(
|
||||
pm.getContext(LocalizationType.COMMON_STATIC,
|
||||
LocalizationLevel.SITE), adjAreaConfigFileName)
|
||||
.getAbsolutePath();
|
||||
MonAreaConfigXML configXmltmp = jaxb
|
||||
.unmarshalFromXmlFile(adjacentAreaFilePath.toString());
|
||||
adjAreaConfigXml = configXmltmp;
|
||||
|
@ -230,108 +236,138 @@ public class FSSObsMonitorConfigurationManager implements
|
|||
adjacentAreaFileExists = false;
|
||||
}
|
||||
|
||||
try {
|
||||
// Check for a monitor area config file, if one does not exist,
|
||||
// create and use defaults
|
||||
/**
|
||||
* Note: Read in "county" for CONUS site, "forecast zone" for OCONUS
|
||||
* site [DR#9905]
|
||||
*/
|
||||
if (!monitorAreaFileExists) {
|
||||
List<String> zones;
|
||||
if (SiteMap.getInstance().getSite4LetterId(currentSite)
|
||||
.charAt(0) == 'K') { // CONUS site
|
||||
zones = MonitorAreaUtils.getUniqueCounties(currentSite);
|
||||
} else { // OCONUS site
|
||||
zones = MonitorAreaUtils.getForecastZones(currentSite);
|
||||
}
|
||||
List<String> marineZones = MonitorAreaUtils
|
||||
.getMarineZones(currentSite);
|
||||
if (!zones.isEmpty()) {
|
||||
for (String zone : zones) {
|
||||
AreaIdXML zoneXml = new AreaIdXML();
|
||||
zoneXml.setAreaId(zone);
|
||||
zoneXml.setType(ZoneType.REGULAR);
|
||||
List<StationIdXML> stations = MonitorAreaUtils
|
||||
// Check for a monitor area config file, if one does not exist,
|
||||
// create and use defaults
|
||||
/**
|
||||
* Note: Read in "county" for CONUS site, "forecast zone" for OCONUS
|
||||
* site [DR#9905]
|
||||
*/
|
||||
if (!monitorAreaFileExists) {
|
||||
List<String> zones;
|
||||
if (SiteMap.getInstance().getSite4LetterId(currentSite).charAt(0) == 'K') { // CONUS
|
||||
// site
|
||||
zones = MonitorAreaUtils.getUniqueCounties(currentSite);
|
||||
} else { // OCONUS site
|
||||
zones = MonitorAreaUtils.getForecastZones(currentSite);
|
||||
}
|
||||
List<String> marineZones = MonitorAreaUtils
|
||||
.getMarineZones(currentSite);
|
||||
if (!zones.isEmpty()) {
|
||||
for (String zone : zones) {
|
||||
AreaIdXML zoneXml = new AreaIdXML();
|
||||
zoneXml.setAreaId(zone);
|
||||
zoneXml.setType(ZoneType.REGULAR);
|
||||
List<StationIdXML> stations;
|
||||
try {
|
||||
stations = MonitorAreaUtils
|
||||
.getZoneReportingStationXMLs(zone);
|
||||
if (!stations.isEmpty()) {
|
||||
for (StationIdXML station : stations) {
|
||||
zoneXml.addStationIdXml(station);
|
||||
}
|
||||
}
|
||||
configXml.addAreaId(zoneXml);
|
||||
} catch (ParseException e) {
|
||||
statusHandler.handle(Priority.PROBLEM,
|
||||
"Could not get stations from zone " + zone, e);
|
||||
}
|
||||
configXml.addAreaId(zoneXml);
|
||||
}
|
||||
// add marine zones if any exist
|
||||
if (!marineZones.isEmpty()) {
|
||||
for (String zone : marineZones) {
|
||||
AreaIdXML zoneXml = new AreaIdXML();
|
||||
zoneXml.setAreaId(zone);
|
||||
zoneXml.setType(ZoneType.MARITIME);
|
||||
}
|
||||
// add marine zones if any exist
|
||||
if (!marineZones.isEmpty()) {
|
||||
for (String zone : marineZones) {
|
||||
AreaIdXML zoneXml = new AreaIdXML();
|
||||
zoneXml.setAreaId(zone);
|
||||
zoneXml.setType(ZoneType.MARITIME);
|
||||
try {
|
||||
List<StationIdXML> stations = MonitorAreaUtils
|
||||
.getZoneReportingStationXMLs(zone);
|
||||
|
||||
if (!stations.isEmpty()) {
|
||||
for (StationIdXML station : stations) {
|
||||
zoneXml.addStationIdXml(station);
|
||||
}
|
||||
}
|
||||
configXml.addAreaId(zoneXml);
|
||||
} catch (ParseException e) {
|
||||
statusHandler.handle(Priority.PROBLEM,
|
||||
"Could not get stations from zone " + zone, e);
|
||||
}
|
||||
configXml.addAreaId(zoneXml);
|
||||
}
|
||||
configXml.setTimeWindow(DEFAULT_TIME);
|
||||
}
|
||||
configXml.setTimeWindow(DEFAULT_TIME);
|
||||
try {
|
||||
saveConfigXml();
|
||||
} catch (LocalizationException | SerializationException e1) {
|
||||
statusHandler.handle(Priority.PROBLEM,
|
||||
"Could not save area configuration file.", e1);
|
||||
}
|
||||
// Check for an adjacent area config file, if one does not exist,
|
||||
// create and use defaults
|
||||
if (!adjacentAreaFileExists) {
|
||||
AdjacentWfoMgr adjMgr = new AdjacentWfoMgr(currentSite);
|
||||
List<String> zones = adjMgr.getAdjZones();
|
||||
if (!zones.isEmpty()) {
|
||||
for (String zone : zones) {
|
||||
List<String> adjZones = adjMgr.getAdjZones();
|
||||
if (!adjZones.isEmpty()) {
|
||||
for (String zone : adjZones) {
|
||||
AreaIdXML zoneXml = new AreaIdXML();
|
||||
zoneXml.setAreaId(zone);
|
||||
zoneXml.setType(ZoneType.REGULAR);
|
||||
List<StationIdXML> stations = MonitorAreaUtils
|
||||
.getZoneReportingStationXMLs(zone);
|
||||
if (!stations.isEmpty()) {
|
||||
for (StationIdXML station : stations) {
|
||||
zoneXml.addStationIdXml(station);
|
||||
try {
|
||||
List<StationIdXML> stations = MonitorAreaUtils
|
||||
.getZoneReportingStationXMLs(zone);
|
||||
|
||||
if (!stations.isEmpty()) {
|
||||
for (StationIdXML station : stations) {
|
||||
zoneXml.addStationIdXml(station);
|
||||
}
|
||||
}
|
||||
} catch (ParseException e) {
|
||||
statusHandler.handle(Priority.PROBLEM,
|
||||
"Could not get stations from zone " + zone,
|
||||
e);
|
||||
}
|
||||
adjAreaConfigXml.addAreaId(zoneXml);
|
||||
}
|
||||
}
|
||||
saveAdjacentAreaConfigXml();
|
||||
try {
|
||||
saveAdjacentAreaConfigXml();
|
||||
} catch (SerializationException | LocalizationException
|
||||
| IOException e) {
|
||||
statusHandler.handle(Priority.PROBLEM,
|
||||
"Could not save adjacent area configuration file.",
|
||||
e);
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
statusHandler.handle(Priority.ERROR, e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Saves the monitor area XML configuration data to the current XML file
|
||||
* name.
|
||||
*
|
||||
* @throws LocalizationException
|
||||
* @throws SerializationException
|
||||
*/
|
||||
public void saveConfigXml() {
|
||||
public void saveConfigXml() throws LocalizationException,
|
||||
SerializationException {
|
||||
// Save the xml object to disk
|
||||
IPathManager pm = PathManagerFactory.getPathManager();
|
||||
LocalizationContext lc = pm.getContext(LocalizationType.COMMON_STATIC,
|
||||
LocalizationLevel.SITE);
|
||||
LocalizationFile newXmlFile = pm.getLocalizationFile(lc,
|
||||
getConfigFileName());
|
||||
if (newXmlFile.getFile().getParentFile().exists() == false) {
|
||||
newXmlFile.getFile().getParentFile().mkdirs();
|
||||
}
|
||||
|
||||
try {
|
||||
jaxb.marshalToXmlFile(configXml, newXmlFile.getFile()
|
||||
.getAbsolutePath());
|
||||
newXmlFile.save();
|
||||
lacf = newXmlFile;
|
||||
lacf.addFileUpdatedObserver(this);
|
||||
setPopulated(true);
|
||||
String path = newXmlFile.getFile().getAbsolutePath();
|
||||
jaxb.marshalToXmlFile(configXml, path);
|
||||
} catch (Exception e) {
|
||||
statusHandler.handle(Priority.ERROR, e.getMessage());
|
||||
statusHandler.handle(Priority.ERROR,
|
||||
"There was a problem to save configuration XML file: "
|
||||
+ getConfigFileName(), e);
|
||||
}
|
||||
lacf = newXmlFile;
|
||||
lacf.addFileUpdatedObserver(this);
|
||||
setPopulated(true);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -339,53 +375,40 @@ public class FSSObsMonitorConfigurationManager implements
|
|||
* name.
|
||||
*
|
||||
* @param filename
|
||||
* adjacentAreaConfig.xml
|
||||
* adjacentAreaConfig.xml adjAreaConfigXml
|
||||
* @throws SerializationException
|
||||
* @throws IOException
|
||||
*/
|
||||
public void saveAdjacentAreaConfigXml() {
|
||||
public void saveAdjacentAreaConfigXml() throws SerializationException,
|
||||
LocalizationException, IOException {
|
||||
// Save the xml object to disk
|
||||
IPathManager pm = PathManagerFactory.getPathManager();
|
||||
LocalizationContext lc = pm.getContext(LocalizationType.COMMON_STATIC,
|
||||
LocalizationLevel.SITE);
|
||||
LocalizationFile newXmlFile = pm.getLocalizationFile(lc,
|
||||
getAdjAreaConfigFileName());
|
||||
if (newXmlFile.getFile().getParentFile().exists() == false) {
|
||||
newXmlFile.getFile().getParentFile().mkdirs();
|
||||
}
|
||||
|
||||
try {
|
||||
jaxb.marshalToXmlFile(adjAreaConfigXml, newXmlFile.getFile()
|
||||
.getAbsolutePath());
|
||||
newXmlFile.save();
|
||||
String path = newXmlFile.getFile().getAbsolutePath();
|
||||
jaxb.marshalToXmlFile(adjAreaConfigXml, path);
|
||||
} catch (Exception e) {
|
||||
statusHandler.handle(Priority.ERROR, e.getMessage());
|
||||
statusHandler.handle(Priority.ERROR,
|
||||
"There was a problem saving Adjacent Area Configuration XML file: "
|
||||
+ getAdjAreaConfigFileName(), e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a new Area to the configuration. This method only adds the area, the
|
||||
* other info will need to be added to the area via the other methods in
|
||||
* this class.
|
||||
* Adds Area XML.
|
||||
*
|
||||
* @param areaId
|
||||
* @param type
|
||||
* Type of zone
|
||||
* @param areaXML
|
||||
*/
|
||||
public void addArea(String areaId, ZoneType type) {
|
||||
public void addArea(AreaIdXML areaXML) {
|
||||
List<AreaIdXML> areaXmlList = configXml.getAreaIds();
|
||||
boolean areaExists = false;
|
||||
for (AreaIdXML area : areaXmlList) {
|
||||
if (area.getAreaId().equals(areaId)) {
|
||||
area.setType(type);
|
||||
areaExists = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (areaExists == false) {
|
||||
AreaIdXML area = new AreaIdXML();
|
||||
area.setAreaId(areaId);
|
||||
area.setType(type);
|
||||
configXml.addAreaId(area);
|
||||
if (!addedZones.contains(areaId)) {
|
||||
addedZones.add(areaId);
|
||||
if (!areaXmlList.contains(areaXML)) {
|
||||
configXml.addAreaId(areaXML);
|
||||
if (!addedZones.contains(areaXML.getAreaId())) {
|
||||
addedZones.add(areaXML.getAreaId());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -404,7 +427,7 @@ public class FSSObsMonitorConfigurationManager implements
|
|||
* @param type
|
||||
* The area type
|
||||
*/
|
||||
public void addArea(String areaId, double lat, double lon, ZoneType type) {
|
||||
public void addNewArea(String areaId, double lat, double lon, ZoneType type) {
|
||||
List<AreaIdXML> areaXmlList = configXml.getAreaIds();
|
||||
boolean areaExists = false;
|
||||
for (AreaIdXML area : areaXmlList) {
|
||||
|
@ -440,12 +463,15 @@ public class FSSObsMonitorConfigurationManager implements
|
|||
* The station id
|
||||
* @param type
|
||||
* The station type
|
||||
* @param existingStation
|
||||
* Does the station already exist
|
||||
* @param added
|
||||
* Station has been added (true | false)
|
||||
*/
|
||||
public void addStation(String areaId, String stationId, String type,
|
||||
boolean existingStation) {
|
||||
public void addNewStation(String areaId, String stationId, String type,
|
||||
boolean added) {
|
||||
List<AreaIdXML> areaList = configXml.getAreaIds();
|
||||
if (!configXml.containsArea(areaId)) {
|
||||
areaList = adjAreaConfigXml.getAreaIds();
|
||||
}
|
||||
if (stationId.contains("#")) {
|
||||
stationId = stationId.substring(0, stationId.indexOf("#"));
|
||||
}
|
||||
|
@ -454,8 +480,13 @@ public class FSSObsMonitorConfigurationManager implements
|
|||
StationIdXML stationXml = new StationIdXML();
|
||||
stationXml.setName(stationId);
|
||||
stationXml.setType(type);
|
||||
if (added) {
|
||||
stationXml.setAdded(added);
|
||||
}
|
||||
area.addStationIdXml(stationXml);
|
||||
addedStations.add(stationId + "#" + type);
|
||||
if (!addedStations.contains(stationId)) {
|
||||
addedStations.add(stationId + "#" + type);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -609,6 +640,22 @@ public class FSSObsMonitorConfigurationManager implements
|
|||
return stations;
|
||||
}
|
||||
|
||||
public List<String> getNewlyAddedStations(List<AreaIdXML> areaXml) {
|
||||
ArrayList<String> retVal = new ArrayList<String>();
|
||||
for (AreaIdXML area : areaXml) {
|
||||
List<StationIdXML> stationList = area.getStationIds();
|
||||
if (!stationList.isEmpty()) {
|
||||
for (StationIdXML stn : stationList) {
|
||||
if (stn.isAdded()) {
|
||||
retVal.add(stn.getName() + "#" + stn.getType());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return retVal;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a list of all monitoring areas.
|
||||
*
|
||||
|
@ -645,34 +692,34 @@ public class FSSObsMonitorConfigurationManager implements
|
|||
* @param station
|
||||
* Station to remove from the area
|
||||
*/
|
||||
public void removeStation(String area, String station) {
|
||||
station = station.substring(0, station.indexOf("#"));
|
||||
public void removeStationFromArea(String area, String station) {
|
||||
List<AreaIdXML> areaList = configXml.getAreaIds();
|
||||
for (AreaIdXML areaXml : areaList) {
|
||||
if (areaXml.getAreaId().equals(area)) {
|
||||
List<StationIdXML> stationList = areaXml.getStationIds();
|
||||
if (!stationList.isEmpty()) {
|
||||
for (int i = 0; i < stationList.size(); i++) {
|
||||
if (stationList.get(i).getName().equals(station)) {
|
||||
StationIdXML stationXml = stationList.get(i);
|
||||
if (stationXml.getName().equals(station.split("#")[0])) {
|
||||
stationList.remove(i);
|
||||
areaXml.getStationIds();
|
||||
i--;
|
||||
}
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes a station from the monitoring area.
|
||||
* Removes a station from all monitoring areas.
|
||||
*
|
||||
* @param station
|
||||
* The station to remove
|
||||
*/
|
||||
public void removeStation(String station) {
|
||||
List<AreaIdXML> areaList = configXml.getAreaIds();
|
||||
for (AreaIdXML areaXml : areaList) {
|
||||
List<StationIdXML> stationList = areaXml.getStationIds();
|
||||
public void removeStation(String station, List<AreaIdXML> areaListXML) {
|
||||
for (AreaIdXML areaXML : areaListXML) {
|
||||
List<StationIdXML> stationList = areaXML.getStationIds();
|
||||
if (!stationList.isEmpty()) {
|
||||
for (int i = 0; i < stationList.size(); i++) {
|
||||
StationIdXML stationXml = stationList.get(i);
|
||||
|
@ -703,39 +750,69 @@ public class FSSObsMonitorConfigurationManager implements
|
|||
}
|
||||
|
||||
/**
|
||||
* Removes an area from the monitoring area.
|
||||
* Gets an AdjAreaXml.
|
||||
*
|
||||
* @param zone
|
||||
* from additional list
|
||||
* @return
|
||||
*/
|
||||
public AreaIdXML getAdjAreaXML(String zone) {
|
||||
List<AreaIdXML> areaList = adjAreaConfigXml.getAreaIds();
|
||||
for (AreaIdXML adjAreaXml : areaList) {
|
||||
if (adjAreaXml.getAreaId().equals(zone)) {
|
||||
return adjAreaXml;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes an area XML from the area configuration.
|
||||
*
|
||||
* @param area
|
||||
* The area to remove
|
||||
*/
|
||||
public void removeArea(String area) {
|
||||
public void removeArea(AreaIdXML area) {
|
||||
List<AreaIdXML> areaList = configXml.getAreaIds();
|
||||
for (int i = 0; i < areaList.size(); i++) {
|
||||
if (areaList.get(i).getAreaId().equals(area)) {
|
||||
areaList.remove(i);
|
||||
break;
|
||||
}
|
||||
}
|
||||
for (int i = 0; i < addedZones.size(); i++) {
|
||||
if (addedZones.get(i).equals(area)) {
|
||||
addedZones.remove(i);
|
||||
break;
|
||||
if (areaList.contains(area)) {
|
||||
areaList.remove(area);
|
||||
if (addedZones.contains(area.getAreaId())) {
|
||||
addedZones.remove(area.getAreaId());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes an added area.
|
||||
* Replaces existing area XML in the area configuration.
|
||||
*
|
||||
* @param area
|
||||
* The area to remove
|
||||
* @param areaOld
|
||||
* @param areaNew
|
||||
*/
|
||||
public void removeAddedArea(String area) {
|
||||
for (int i = 0; i < addedZones.size(); i++) {
|
||||
if (addedZones.get(i).equals(area)) {
|
||||
addedZones.remove(i);
|
||||
break;
|
||||
}
|
||||
public void replaceArea(AreaIdXML areaOld, AreaIdXML areaNew) {
|
||||
List<AreaIdXML> areaList = configXml.getAreaIds();
|
||||
int idx = areaList.indexOf(areaOld);
|
||||
areaList.set(idx, areaNew);
|
||||
if (addedZones.contains(areaOld)) {
|
||||
addedZones.set(addedZones.indexOf(areaOld), areaNew.getAreaId());
|
||||
} else {
|
||||
addedZones.add(areaNew.getAreaId());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Replaces existing area XML in the adjusted area configuration
|
||||
*
|
||||
* @param areaOld
|
||||
* @param areaNew
|
||||
*/
|
||||
public void replaceAdjArea(AreaIdXML areaOld, AreaIdXML areaNew) {
|
||||
List<AreaIdXML> areaList = adjAreaConfigXml.getAreaIds();
|
||||
int idx = areaList.indexOf(areaOld);
|
||||
areaList.set(idx, areaNew);
|
||||
if (addedZones.contains(areaOld)) {
|
||||
addedZones.set(addedZones.indexOf(areaOld), areaNew.getAreaId());
|
||||
} else {
|
||||
addedZones.add(areaNew.getAreaId());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -805,6 +882,15 @@ public class FSSObsMonitorConfigurationManager implements
|
|||
return configXml;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets Adjacent Configuration Xml
|
||||
*
|
||||
* @return the adjAreaConfigXml
|
||||
*/
|
||||
public MonAreaConfigXML getAdjAreaConfigXml() {
|
||||
return adjAreaConfigXml;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets Added Zones
|
||||
*
|
||||
|
@ -855,13 +941,12 @@ public class FSSObsMonitorConfigurationManager implements
|
|||
String result = null;
|
||||
List<AreaIdXML> areaList = configXml.getAreaIds();
|
||||
for (AreaIdXML area : areaList) {
|
||||
if (area.getAreaId().equals(theZone)) {
|
||||
if (area.getAreaId().equals(theZone)
|
||||
&& area.containsStation(theStation)) {
|
||||
List<StationIdXML> stationList = area.getStationIds();
|
||||
if (!stationList.isEmpty()) {
|
||||
for (StationIdXML station : stationList) {
|
||||
if (station.getName().equals(theStation)) {
|
||||
return station.getType();
|
||||
}
|
||||
for (StationIdXML station : stationList) {
|
||||
if (station.getName().equals(theStation)) {
|
||||
result = station.getType();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -974,45 +1059,42 @@ public class FSSObsMonitorConfigurationManager implements
|
|||
}
|
||||
|
||||
/**
|
||||
* Remove Adjacent Area.
|
||||
* Remove Adjacent Area XML.
|
||||
*
|
||||
* @param zone
|
||||
*/
|
||||
public void removeAdjArea(String zone) {
|
||||
public void removeAdjArea(AreaIdXML zone) {
|
||||
List<AreaIdXML> adjAreaList = adjAreaConfigXml.getAreaIds();
|
||||
for (int i = 0; i < adjAreaList.size(); i++) {
|
||||
if (adjAreaList.get(i).getAreaId().equals(zone)) {
|
||||
adjAreaList.remove(i);
|
||||
break;
|
||||
if (adjAreaList.contains(zone)) {
|
||||
adjAreaList.remove(zone);
|
||||
if (addedZones.contains(zone.getAreaId())) {
|
||||
addedZones.remove(zone.getAreaId());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Add Adjacent Area.
|
||||
* Add Adjacent Area XML.
|
||||
*
|
||||
* @param areaId
|
||||
* @param type
|
||||
* @param areaXML
|
||||
*/
|
||||
public void addAdjArea(String areaId, ZoneType type) {
|
||||
public void addAdjArea(AreaIdXML areaXML) {
|
||||
List<AreaIdXML> adjAreaList = adjAreaConfigXml.getAreaIds();
|
||||
boolean areaExists = false;
|
||||
for (AreaIdXML area : adjAreaList) {
|
||||
if (area.getAreaId().equals(areaId)) {
|
||||
area.setType(type);
|
||||
areaExists = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (areaExists == false) {
|
||||
AreaIdXML area = new AreaIdXML();
|
||||
area.setAreaId(areaId);
|
||||
area.setType(type);
|
||||
adjAreaConfigXml.addAreaId(area);
|
||||
if (!adjAreaList.contains(areaXML)) {
|
||||
adjAreaConfigXml.addAreaId(areaXML);
|
||||
}
|
||||
}
|
||||
|
||||
public List<MonitorConfigListener> getListeners() {
|
||||
return listeners;
|
||||
/**
|
||||
* Gets configuration manager for monitor.
|
||||
*
|
||||
* @param name
|
||||
* @return
|
||||
*/
|
||||
public static FSSObsMonitorConfigurationManager getObsManager(
|
||||
MonName monitor) {
|
||||
FSSObsMonitorConfigurationManager instance = getInstance(monitor);
|
||||
instance.readConfigXml();
|
||||
return instance;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,6 +20,8 @@
|
|||
package com.raytheon.uf.common.monitor.xml;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import javax.xml.bind.annotation.XmlAccessType;
|
||||
import javax.xml.bind.annotation.XmlAccessorType;
|
||||
|
@ -36,6 +38,8 @@ import javax.xml.bind.annotation.XmlElements;
|
|||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Dec 21, 2009 lvenable Initial creation
|
||||
* Sep 03, 2015 3841 skorolev Added containsStation method
|
||||
*
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -46,7 +50,7 @@ import javax.xml.bind.annotation.XmlElements;
|
|||
public class AreaIdXML {
|
||||
|
||||
@XmlElements({ @XmlElement(name = "StationID", type = StationIdXML.class) })
|
||||
private ArrayList<StationIdXML> stationIds = new ArrayList<StationIdXML>();
|
||||
private List<StationIdXML> stationIds = new ArrayList<StationIdXML>();
|
||||
|
||||
@XmlAttribute(name = "id")
|
||||
private String areaId;
|
||||
|
@ -67,11 +71,11 @@ public class AreaIdXML {
|
|||
public AreaIdXML() {
|
||||
}
|
||||
|
||||
public ArrayList<StationIdXML> getStationIds() {
|
||||
public List<StationIdXML> getStationIds() {
|
||||
return stationIds;
|
||||
}
|
||||
|
||||
public void setStationIds(ArrayList<StationIdXML> stationIds) {
|
||||
public void setStationIds(List<StationIdXML> stationIds) {
|
||||
this.stationIds = stationIds;
|
||||
}
|
||||
|
||||
|
@ -138,4 +142,21 @@ public class AreaIdXML {
|
|||
public void setCLon(Double lon) {
|
||||
cLon = lon;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param station
|
||||
* @return
|
||||
*/
|
||||
public boolean containsStation(String station) {
|
||||
if (!stationIds.isEmpty()) {
|
||||
Iterator<StationIdXML> itr = getStationIds().iterator();
|
||||
while (itr.hasNext()) {
|
||||
if (itr.next().getName().equals(station)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -20,6 +20,8 @@
|
|||
package com.raytheon.uf.common.monitor.xml;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import javax.xml.bind.annotation.XmlAccessType;
|
||||
import javax.xml.bind.annotation.XmlAccessorType;
|
||||
|
@ -37,6 +39,8 @@ import javax.xml.bind.annotation.XmlRootElement;
|
|||
* ------------ ---------- ----------- --------------------------
|
||||
* Dec 21, 2009 lvenable Initial creation
|
||||
* May 15, 2014 3086 skorolev Changed type for timeWindow element.
|
||||
* Sep 03, 2015 3841 skorolev Added containsArea method.
|
||||
*
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -48,7 +52,7 @@ import javax.xml.bind.annotation.XmlRootElement;
|
|||
public class MonAreaConfigXML {
|
||||
|
||||
@XmlElements({ @XmlElement(name = "AreaID", type = AreaIdXML.class) })
|
||||
private ArrayList<AreaIdXML> areaIds = new ArrayList<AreaIdXML>();
|
||||
private List<AreaIdXML> areaIds = new ArrayList<AreaIdXML>();
|
||||
|
||||
/**
|
||||
* Time period in minutes during which stations are monitoring.
|
||||
|
@ -71,11 +75,11 @@ public class MonAreaConfigXML {
|
|||
public MonAreaConfigXML() {
|
||||
}
|
||||
|
||||
public ArrayList<AreaIdXML> getAreaIds() {
|
||||
public List<AreaIdXML> getAreaIds() {
|
||||
return areaIds;
|
||||
}
|
||||
|
||||
public void setAreaIds(ArrayList<AreaIdXML> areaIds) {
|
||||
public void setAreaIds(List<AreaIdXML> areaIds) {
|
||||
this.areaIds = areaIds;
|
||||
}
|
||||
|
||||
|
@ -130,4 +134,21 @@ public class MonAreaConfigXML {
|
|||
public void addAreaId(AreaIdXML areaXml) {
|
||||
areaIds.add(areaXml);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if areaXML exist for area ID.
|
||||
*
|
||||
* @param area
|
||||
* area ID
|
||||
* @return areaXML
|
||||
*/
|
||||
public boolean containsArea(String areaId) {
|
||||
Iterator<AreaIdXML> itr = getAreaIds().iterator();
|
||||
while (itr.hasNext()) {
|
||||
if (itr.next().getAreaId().equals(areaId)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -32,6 +32,8 @@ import javax.xml.bind.annotation.XmlAttribute;
|
|||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Dec 21, 2009 lvenable Initial creation
|
||||
* Aug 25, 2015 3481 skorolev Added attribute for newly added station
|
||||
*
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -47,6 +49,9 @@ public class StationIdXML {
|
|||
@XmlAttribute(name = "name")
|
||||
private String name;
|
||||
|
||||
@XmlAttribute(name = "added", required = false)
|
||||
private boolean added;
|
||||
|
||||
public static final String MARITIME = "MARITIME";
|
||||
|
||||
public static final String METAR = "METAR";
|
||||
|
@ -79,4 +84,12 @@ public class StationIdXML {
|
|||
this.name = name;
|
||||
}
|
||||
|
||||
public boolean isAdded() {
|
||||
return added;
|
||||
}
|
||||
|
||||
public void setAdded(boolean added) {
|
||||
this.added = added;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -63,4 +63,6 @@
|
|||
<parameter name="skyCover" numDims="2" type="STRING" size="8" dimension="maxSkyCover"/>
|
||||
<parameter name="totCloudAmount" numDims="1" type="INT" />
|
||||
<parameter name="stnName" numDims="1" type="STRING" size="64"/>
|
||||
<parameter name="reportType" numDims="1" type="STRING" size="64"/>
|
||||
<parameter name="stationary" numDims="1" type="STRING" size="64"/>
|
||||
</pointDataDescription>
|
|
@ -45,6 +45,7 @@ import com.raytheon.uf.edex.decodertools.time.TimeTools;
|
|||
* Dec 3, 2010 skorolev Initial creation
|
||||
* Jul 23, 2014 3410 bclement location changed to floats
|
||||
* Sep 18, 2015 3873 skorolev Fixed assigning timeObs for maritime record.
|
||||
* Dec 02, 2015 3873 dhladky Added missing point data params.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -283,6 +284,8 @@ public class FSSObsDataTransform {
|
|||
private static final String SOIL_TEMPERATURE = "soilTemperature";
|
||||
|
||||
private static final String SOIL_MOISTURE = "soilMoisture";
|
||||
|
||||
private static final String STATIONARY = "stationary";
|
||||
|
||||
static {
|
||||
StringBuffer sb = new StringBuffer();
|
||||
|
@ -313,6 +316,12 @@ public class FSSObsDataTransform {
|
|||
OBS_PARAMS_LIST = sb.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Read the metar record, creating an FSSObs record.
|
||||
* @param container
|
||||
* @return
|
||||
* @throws JAXBException
|
||||
*/
|
||||
public static FSSObsRecord fromMetarRecord(PointDataContainer container)
|
||||
throws JAXBException {
|
||||
container.setCurrentSz(container.getAllocatedSz());
|
||||
|
@ -474,6 +483,12 @@ public class FSSObsDataTransform {
|
|||
MESOWEST_PARAMS_LIST = sb.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Read the maritime record, creating an FSSObs record.
|
||||
* @param container
|
||||
* @return
|
||||
* @throws JAXBException
|
||||
*/
|
||||
public static FSSObsRecord fromMaritimeRecord(PointDataContainer container)
|
||||
throws JAXBException {
|
||||
container.setCurrentSz(container.getAllocatedSz());
|
||||
|
@ -562,6 +577,7 @@ public class FSSObsDataTransform {
|
|||
}
|
||||
|
||||
/**
|
||||
* Read the MESOWEST record, creating an FSSOBS record.
|
||||
* @param result
|
||||
* @return
|
||||
*/
|
||||
|
@ -628,10 +644,17 @@ public class FSSObsDataTransform {
|
|||
return fssr;
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the view and write to HDF5 file
|
||||
* @param record
|
||||
* @return
|
||||
*/
|
||||
public static PointDataView buildView(FSSObsRecord record) {
|
||||
pdc = PointDataContainer.build(fsspdd);
|
||||
PointDataView pdv = pdc.append();
|
||||
|
||||
pdv.setString(STATIONARY, Boolean.toString(record.isStationary()));
|
||||
pdv.setString(REPORT_TYPE, record.getReportType());
|
||||
pdv.setFloat(CEILING, record.getCeiling());
|
||||
pdv.setFloat(DEWPOINT, record.getDewpoint());
|
||||
pdv.setFloat(DEWPOINT_DEPR, record.getDewpointDepr());
|
||||
|
@ -690,8 +713,6 @@ public class FSSObsDataTransform {
|
|||
pdv.setFloat(WIND_GUST, record.getWindGust());
|
||||
pdv.setFloat(HI_RES_WV_HGT, record.getHighResWaveHeight());
|
||||
|
||||
// pdv.setLong(TIME_NOMINAL, record.getRefHour().getTimeInMillis());
|
||||
|
||||
record.setPointDataView(pdv);
|
||||
return pdv;
|
||||
}
|
||||
|
|
|
@ -29,6 +29,7 @@ import com.raytheon.edex.site.SiteUtil;
|
|||
import com.raytheon.edex.urifilter.URIFilter;
|
||||
import com.raytheon.edex.urifilter.URIGenerateMessage;
|
||||
import com.raytheon.uf.common.dataplugin.PluginDataObject;
|
||||
import com.raytheon.uf.common.dataplugin.annotations.DataURI;
|
||||
import com.raytheon.uf.common.dataplugin.fssobs.FSSObsRecord;
|
||||
import com.raytheon.uf.common.geospatial.SpatialException;
|
||||
import com.raytheon.uf.common.monitor.MonitorAreaUtils;
|
||||
|
@ -37,6 +38,7 @@ import com.raytheon.uf.common.monitor.config.FSSObsMonitorConfigurationManager.M
|
|||
import com.raytheon.uf.common.monitor.data.ObConst;
|
||||
import com.raytheon.uf.common.monitor.events.MonitorConfigEvent;
|
||||
import com.raytheon.uf.common.monitor.events.MonitorConfigListener;
|
||||
import com.raytheon.uf.common.monitor.xml.AreaIdXML;
|
||||
import com.raytheon.uf.common.status.IUFStatusHandler;
|
||||
import com.raytheon.uf.common.status.UFStatus;
|
||||
import com.raytheon.uf.common.status.UFStatus.Priority;
|
||||
|
@ -60,6 +62,9 @@ import com.vividsolutions.jts.geom.Coordinate;
|
|||
* Aug 18, 2014 3530 bclement removed constructDataURI() call
|
||||
* Sep 04, 2014 3220 skorolev Replaced 3 URI filters with one.
|
||||
* Sep 18, 2015 3873 skorolev Added moving platforms testing.
|
||||
* Oct 19, 2015 3841 skorolev Corrected isNearZone.
|
||||
* Nov 12, 2015 3841 dhladky Augmented Slav's moving platform fix.
|
||||
* Dec 02, 2015 3873 dhladky Fixed performance problems, missing params.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -72,6 +77,16 @@ public class FSSObsGenerator extends CompositeProductGenerator implements
|
|||
private static final transient IUFStatusHandler statusHandler = UFStatus
|
||||
.getHandler(FSSObsGenerator.class);
|
||||
|
||||
/** List of fixed types **/
|
||||
protected static final String[] stationaryTypes = new String[] {
|
||||
ObConst.METAR, ObConst.MESONET, ObConst.SPECI,
|
||||
ObConst.SYNOPTIC_CMAN, ObConst.SYNOPTIC_MOORED_BUOY };
|
||||
|
||||
/** list of moving types **/
|
||||
protected static final String[] movingTypes = new String[] {
|
||||
ObConst.SYNOPTIC_SHIP, ObConst.DRIFTING_BUOY,
|
||||
ObConst.SYNOPTIC_MAROB };
|
||||
|
||||
/** Name of composite generator */
|
||||
private static final String genName = "FSSObs";
|
||||
|
||||
|
@ -79,7 +94,7 @@ public class FSSObsGenerator extends CompositeProductGenerator implements
|
|||
private static final String productType = "fssobs";
|
||||
|
||||
/** Stations to filter */
|
||||
private Set<String> allStations = new HashSet<String>();
|
||||
private final Set<String> allStations = new HashSet<String>();
|
||||
|
||||
public FSSObsMonitorConfigurationManager fogmcm = null;
|
||||
|
||||
|
@ -87,6 +102,9 @@ public class FSSObsGenerator extends CompositeProductGenerator implements
|
|||
|
||||
public FSSObsMonitorConfigurationManager snowmcm = null;
|
||||
|
||||
/** Zone constant char */
|
||||
private static final char Z = 'Z';
|
||||
|
||||
/**
|
||||
* Public construction
|
||||
*/
|
||||
|
@ -105,76 +123,147 @@ public class FSSObsGenerator extends CompositeProductGenerator implements
|
|||
public void generateProduct(URIGenerateMessage genMessage) {
|
||||
|
||||
FSSObsConfig fss_config = null;
|
||||
boolean isStationary = true;
|
||||
|
||||
try {
|
||||
fss_config = new FSSObsConfig(genMessage, this);
|
||||
this.setPluginDao(new FSSObsDAO(productType));
|
||||
} catch (Exception e) {
|
||||
statusHandler.handle(Priority.PROBLEM, e.getLocalizedMessage(), e);
|
||||
statusHandler.handle(Priority.PROBLEM,
|
||||
"Couldn't read FSSObs configuration information.", e);
|
||||
}
|
||||
List<FSSObsRecord> fssRecs = new ArrayList<FSSObsRecord>();
|
||||
for (String uri : genMessage.getUris()) {
|
||||
// Test if moving platforms are within configuration distance
|
||||
if (uri.contains(ObConst.SYNOPTIC_SHIP)
|
||||
|| uri.contains(ObConst.DRIFTING_BUOY)
|
||||
|| uri.contains(ObConst.SYNOPTIC_MAROB)) {
|
||||
isStationary = false;
|
||||
try {
|
||||
if (!isNearZone(uri)) {
|
||||
continue;
|
||||
|
||||
boolean isStationary = true;
|
||||
String reportType = null;
|
||||
boolean inRange = false;
|
||||
|
||||
// check if moving type
|
||||
for (String t : movingTypes) {
|
||||
if (uri.contains(t)) {
|
||||
reportType = t;
|
||||
isStationary = false;
|
||||
|
||||
try {
|
||||
if (isNearZone(uri)) {
|
||||
inRange = true;
|
||||
statusHandler.handle(Priority.INFO,
|
||||
"===> Moving platform in Range " + uri);
|
||||
}
|
||||
} catch (SpatialException e) {
|
||||
statusHandler
|
||||
.handle(Priority.PROBLEM,
|
||||
"URI: "
|
||||
+ uri
|
||||
+ " could not be checked for Location information.",
|
||||
e);
|
||||
// If the location info is bad. we don't want it.
|
||||
inRange = false;
|
||||
}
|
||||
} catch (SpatialException e) {
|
||||
statusHandler.handle(Priority.PROBLEM,
|
||||
e.getLocalizedMessage(), e);
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
FSSObsRecord fssObsRec = new FSSObsRecord();
|
||||
fssObsRec.setIsStationary(isStationary);
|
||||
fssObsRec = fss_config.getTableRow(uri);
|
||||
FSSObsDataTransform.buildView(fssObsRec);
|
||||
fssRecs.add(fssObsRec);
|
||||
if (isStationary) {
|
||||
// determine stationary type
|
||||
for (String t : stationaryTypes) {
|
||||
if (uri.contains(t)) {
|
||||
reportType = t;
|
||||
inRange = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// We only want what we know how to decode
|
||||
if (reportType != null && inRange) {
|
||||
|
||||
FSSObsRecord fssObsRec = new FSSObsRecord();
|
||||
fssObsRec.setReportType(reportType);
|
||||
fssObsRec.setStationary(isStationary);
|
||||
fssObsRec = fss_config.getTableRow(uri);
|
||||
FSSObsDataTransform.buildView(fssObsRec);
|
||||
fssRecs.add(fssObsRec);
|
||||
}
|
||||
}
|
||||
|
||||
if (!fssRecs.isEmpty()) {
|
||||
this.setPluginDataObjects((PluginDataObject[]) fssRecs
|
||||
this.setPluginDataObjects(fssRecs
|
||||
.toArray(new PluginDataObject[fssRecs.size()]));
|
||||
statusHandler.handle(Priority.INFO, "===> Successfully generated "
|
||||
+ fssRecs.size() + " records.");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Test distance between moving platform and zone centroud.
|
||||
* Checks if ship is near monitoring zones and should be included in FSSObs
|
||||
* data.
|
||||
*
|
||||
* @param uri
|
||||
* @return
|
||||
* sfcobs URI
|
||||
* @return true if ship is in vicinity of zone
|
||||
* @throws SpatialException
|
||||
*/
|
||||
private boolean isNearZone(String uri) throws SpatialException {
|
||||
boolean retVal = false;
|
||||
Set<String> marineZone = new HashSet<String>();
|
||||
for (String z : getSSConfig().getAreaList()) {
|
||||
if (z.charAt(2) == 'Z') {
|
||||
marineZone.add(z);
|
||||
}
|
||||
}
|
||||
for (String z : getFogConfig().getAreaList()) {
|
||||
if (z.charAt(2) == 'Z') {
|
||||
marineZone.add(z);
|
||||
}
|
||||
}
|
||||
String[] items = uri.split(DataURI.SEPARATOR);
|
||||
double latShip = Double.parseDouble(items[6]);
|
||||
double lonShip = Double.parseDouble(items[7]);
|
||||
|
||||
double ssShipDist = getSSConfig().getShipDistance();
|
||||
if (ssShipDist != 0.0) {
|
||||
// check SAFSEAS zones
|
||||
retVal = checkMarineZones(getSSConfig(), ssShipDist, latShip,
|
||||
lonShip);
|
||||
}
|
||||
|
||||
double fogShipDist = getFogConfig().getShipDistance();
|
||||
// take the biggest distance
|
||||
double configDist = ssShipDist > fogShipDist ? ssShipDist : fogShipDist;
|
||||
if (configDist != 0.0) {
|
||||
String[] items = uri.split("/");
|
||||
double latShip = Double.parseDouble(items[6]);
|
||||
double lonShip = Double.parseDouble(items[7]);
|
||||
for (String zone : marineZone) {
|
||||
Coordinate coor = MonitorAreaUtils.getZoneCenter(zone);
|
||||
double shipTozone = distance(latShip, lonShip, coor.y, coor.x);
|
||||
|
||||
if (fogShipDist != 0.0 && !retVal) {
|
||||
// check Fog zones
|
||||
retVal = checkMarineZones(getFogConfig(), fogShipDist, latShip,
|
||||
lonShip);
|
||||
}
|
||||
|
||||
return retVal;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* Test distance between moving platform and marine zone centroid.
|
||||
*
|
||||
* @param cfg
|
||||
* configuration manager
|
||||
* @param configDist
|
||||
* configuration distance
|
||||
* @param lat
|
||||
* ship latitude
|
||||
* @param lon
|
||||
* ship longitude
|
||||
* @return true if distance less configDist
|
||||
*/
|
||||
private boolean checkMarineZones(FSSObsMonitorConfigurationManager cfg,
|
||||
double configDist, double lat, double lon) {
|
||||
boolean retVal = false;
|
||||
for (String zone : cfg.getAreaList()) {
|
||||
if (zone.charAt(2) == Z) {
|
||||
// initial distance
|
||||
double shipTozone = configDist;
|
||||
try {
|
||||
Coordinate coor = MonitorAreaUtils.getZoneCenter(zone);
|
||||
// zone should have center coordinates.
|
||||
if (coor != null) {
|
||||
shipTozone = distance(lat, lon, coor.y, coor.x);
|
||||
} else {
|
||||
// newly added zone
|
||||
AreaIdXML ssXML = cfg.getAreaXml(zone);
|
||||
shipTozone = distance(lat, lon, ssXML.getCLat(),
|
||||
ssXML.getCLon());
|
||||
}
|
||||
} catch (SpatialException e) {
|
||||
statusHandler.handle(Priority.PROBLEM, "Couldn't find marine zone within distance. lon: "+lon+" lat: "+lat+" dist: "+configDist, e);
|
||||
}
|
||||
if (shipTozone < configDist) {
|
||||
retVal = true;
|
||||
}
|
||||
|
@ -324,4 +413,4 @@ public class FSSObsGenerator extends CompositeProductGenerator implements
|
|||
return snowmcm;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
|
@ -27,6 +27,7 @@ import com.vividsolutions.jts.geom.Coordinate;
|
|||
* Feb 15, 2013 1638 mschenke Moved DataURINotificationMessage to uf.common.dataplugin
|
||||
* Sep 04, 2014 3220 skorolev Removed CWA from filter.
|
||||
* Sep 17, 2015 3873 skorolev Added pattern for moving platforms.
|
||||
* Dec 02, 2015 3873 dhladky Revamped for better performance.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -37,30 +38,12 @@ public class FSSObsURIFilter extends URIFilter {
|
|||
private static final transient IUFStatusHandler statusHandler = UFStatus
|
||||
.getHandler(URIFilter.class);
|
||||
|
||||
/** Station ID **/
|
||||
private String stn;
|
||||
|
||||
/** Station coordinates **/
|
||||
private Coordinate stationCoor = null;
|
||||
|
||||
/** Patterns used for matching URI's **/
|
||||
private HashMap<String, Pattern> patternKeys = null;
|
||||
|
||||
/** METAR Pattern **/
|
||||
private Pattern metarPattern = null;
|
||||
|
||||
/** Maritime Pattern **/
|
||||
private Pattern maritimePattern = null;
|
||||
|
||||
/** Mesowest Pattern **/
|
||||
private Pattern mesowestPattern = null;
|
||||
|
||||
/** Pattern for moving platforms **/
|
||||
private Pattern movingPattern = null;
|
||||
|
||||
/** Current data type #METAR, #Maritime or #Mesonet **/
|
||||
private String dataType;
|
||||
|
||||
/** All filtered stations */
|
||||
private Set<String> stations = null;
|
||||
|
||||
|
@ -95,34 +78,45 @@ public class FSSObsURIFilter extends URIFilter {
|
|||
*/
|
||||
@Override
|
||||
public void setMatchURIs() {
|
||||
|
||||
Pattern pat = Pattern.compile("#");
|
||||
/**
|
||||
* For non moving platforms we setup specific patterns as they are fixed locations.
|
||||
*/
|
||||
for (String st : stations) {
|
||||
String[] tokens = pat.split(st);
|
||||
setStn(tokens[0]);
|
||||
setDataType(tokens[1]);
|
||||
switch (getDataType()) {
|
||||
String station = tokens[0];
|
||||
String dataType = tokens[1];
|
||||
switch (dataType) {
|
||||
case ObConst.METAR:
|
||||
setMetarPattern();
|
||||
getMatchURIs().put(getMetarPattern(), 0l);
|
||||
Pattern metarPattern = getMetarPattern(station);
|
||||
statusHandler.info("Adding Pattern for type: "+ObConst.METAR+" Pattern: "+metarPattern.toString());
|
||||
getMatchURIs().put(metarPattern, 0l);
|
||||
break;
|
||||
case ObConst.MARITIME:
|
||||
setMaritimePattern();
|
||||
getMatchURIs().put(getMaritimePattern(), 0l);
|
||||
Pattern maritimePattern = getMaritimePattern(station);
|
||||
statusHandler.info("Adding Pattern for type: "+ObConst.MARITIME+" Pattern: "+maritimePattern.toString());
|
||||
getMatchURIs().put(maritimePattern, 0l);
|
||||
break;
|
||||
case ObConst.MESONET:
|
||||
setMesowestPattern();
|
||||
getMatchURIs().put(getMesowestPattern(), 0l);
|
||||
Pattern mesowestPattern = getMesowestPattern(station);
|
||||
statusHandler.info("Adding Pattern for type: "+ObConst.MESONET+" Pattern: "+mesowestPattern.toString());
|
||||
getMatchURIs().put(mesowestPattern, 0l);
|
||||
break;
|
||||
default:
|
||||
statusHandler.error("Get unknown data type " + getDataType());
|
||||
statusHandler.error("Get unknown data type " + dataType);
|
||||
break;
|
||||
}
|
||||
}
|
||||
String[] repTyps = { ObConst.SYNOPTIC_SHIP, ObConst.DRIFTING_BUOY,
|
||||
ObConst.SYNOPTIC_MAROB };
|
||||
for (String rt : repTyps) {
|
||||
setMovingPattern(rt);
|
||||
getMatchURIs().put(getMovingPattern(), 0l);
|
||||
|
||||
/**
|
||||
* Moving types aren't fixed, we use a general pattern and then filter upon discovery.
|
||||
*/
|
||||
|
||||
for (String rt : FSSObsGenerator.movingTypes) {
|
||||
Pattern movingPattern = getMovingPattern(rt);
|
||||
statusHandler.info("Adding Pattern for type: "+rt+" Pattern: "+movingPattern.toString());
|
||||
getMatchURIs().put(movingPattern, 0l);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -275,121 +269,53 @@ public class FSSObsURIFilter extends URIFilter {
|
|||
|
||||
/**
|
||||
* Gets Metar Pattern.
|
||||
*
|
||||
* @return MetarPattern
|
||||
*/
|
||||
public Pattern getMetarPattern() {
|
||||
private Pattern getMetarPattern(String station) {
|
||||
// "/obs/2010-11-01_14:15:00.0/METAR<SPECI???>/null/K0A9/36.371/-82.173"
|
||||
Pattern metarPattern = Pattern.compile("/obs/" + wildCard + uriSeperator
|
||||
+ wildCard + uriSeperator + "null" + uriSeperator + station
|
||||
+ uriSeperator);
|
||||
return metarPattern;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets Metar Pattern.
|
||||
* Gets Maritime Pattern
|
||||
*/
|
||||
public void setMetarPattern() {
|
||||
// "/obs/2010-11-01_14:15:00.0/METAR<SPECI???>/null/K0A9/36.371/-82.173"
|
||||
metarPattern = Pattern.compile("/obs/" + wildCard + uriSeperator
|
||||
+ wildCard + uriSeperator + "null" + uriSeperator + getStn()
|
||||
+ uriSeperator);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets Maritime Pattern.
|
||||
*
|
||||
* @return MaritimePattern
|
||||
*/
|
||||
public Pattern getMaritimePattern() {
|
||||
return maritimePattern;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets Maritime Pattern
|
||||
*/
|
||||
public void setMaritimePattern() {
|
||||
private Pattern getMaritimePattern(String station) {
|
||||
// /sfcobs/2010-10-28_10:36:00.0/1004[5]/null/BEPB6/32.373/-64.703
|
||||
maritimePattern = Pattern.compile("/sfcobs/" + wildCard + uriSeperator
|
||||
+ wildCard + uriSeperator + "null" + uriSeperator + getStn()
|
||||
Pattern maritimePattern = Pattern.compile("/sfcobs/" + wildCard + uriSeperator
|
||||
+ wildCard + uriSeperator + "null" + uriSeperator + station
|
||||
+ uriSeperator);
|
||||
return maritimePattern;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets Mesowest Pattern.
|
||||
*
|
||||
* @return the mesowestPattern
|
||||
*/
|
||||
public Pattern getMesowestPattern() {
|
||||
return mesowestPattern;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets Mesowest Pattern.
|
||||
*
|
||||
* @param mesowestPattern
|
||||
* the mesowestPattern to set
|
||||
*/
|
||||
public void setMesowestPattern() {
|
||||
private Pattern getMesowestPattern(String station) {
|
||||
// There is no dataURI for ldadmesonet data
|
||||
// /ldadmesonet/2011-06-29_22:10:00.0/mesonet/NWSRAWS/RINN4/41.1181/-74.2403
|
||||
mesowestPattern = Pattern.compile("/ldadmesonet/" + wildCard
|
||||
Pattern mesowestPattern = Pattern.compile("/ldadmesonet/" + wildCard
|
||||
+ uriSeperator + wildCard + uriSeperator + wildCard
|
||||
+ uriSeperator + getStn());
|
||||
+ uriSeperator + station);
|
||||
return mesowestPattern;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets pattern for moving platforms and MAROBs
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public Pattern getMovingPattern() {
|
||||
return movingPattern;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets pattern for ships "1003", drifting buoys "1006" and MAROBs "1007".
|
||||
*
|
||||
* @param reportType
|
||||
*/
|
||||
public void setMovingPattern(String reportType) {
|
||||
private Pattern getMovingPattern(String reportType) {
|
||||
// /sfcobs/2010-10-28_10:36:00.0/1003<6,7>/null/BEPB6/32.373/-64.703
|
||||
this.movingPattern = Pattern.compile("/sfcobs/" + wildCard
|
||||
Pattern movingPattern = Pattern.compile("/sfcobs/" + wildCard
|
||||
+ uriSeperator + reportType + uriSeperator + wildCard
|
||||
+ uriSeperator);
|
||||
return movingPattern;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets station name
|
||||
*
|
||||
* @return the stn
|
||||
*/
|
||||
public String getStn() {
|
||||
return stn;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets station name.
|
||||
*
|
||||
* @param stn
|
||||
* the stn to set
|
||||
*/
|
||||
public void setStn(String stn) {
|
||||
this.stn = stn;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets data type.
|
||||
*
|
||||
* @param the
|
||||
* dataType to set
|
||||
*/
|
||||
public void setDataType(String type) {
|
||||
this.dataType = type;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets data type.
|
||||
*
|
||||
* @return the dataType
|
||||
*/
|
||||
public String getDataType() {
|
||||
return dataType;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -60,6 +60,7 @@ import com.raytheon.uf.edex.pointdata.PointDataQuery;
|
|||
* Apr 28, 2014 3086 skorolev Updated getStations method.
|
||||
* Sep 04, 2014 3220 skorolev Removed getStations method.
|
||||
* Sep 18, 2015 3873 skorolev Removed identical constant definitions.
|
||||
* Dec 02, 2015 3873 dhladky Logging change.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -352,7 +353,7 @@ public class FSSObsUtils {
|
|||
case "":
|
||||
break;
|
||||
default:
|
||||
statusHandler.error("Get unknown sky cover " + sc);
|
||||
statusHandler.warn("Get unknown sky cover " + sc);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -46,6 +46,7 @@ import com.raytheon.uf.edex.plugin.fssobs.FSSObsUtils;
|
|||
* Aug 30, 2013 2298 rjpeter Make getPluginName abstract
|
||||
* Sep 04, 2014 3220 skorolev Removed cwa and monitorUse from data set.
|
||||
* Sep 18, 2015 3873 skorolev Removed identical constant definitions.
|
||||
* Dec 02, 2015 3873 dhladky Logging change.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -85,32 +86,25 @@ public class FSSObsConfig {
|
|||
public FSSObsRecord getTableRow(String uri) {
|
||||
String dt = uri.substring(1)
|
||||
.substring(0, uri.substring(1).indexOf("/"));
|
||||
if (dt.equals("obs")) {
|
||||
try {
|
||||
tableRow = FSSObsUtils.getRecordFromMetar(uri);
|
||||
|
||||
} catch (PluginException e) {
|
||||
statusHandler.handle(Priority.PROBLEM, e.getLocalizedMessage(),
|
||||
e);
|
||||
}
|
||||
} else if (dt.equals("sfcobs")) {
|
||||
try {
|
||||
try {
|
||||
|
||||
if (dt.equals("obs")) {
|
||||
tableRow = FSSObsUtils.getRecordFromMetar(uri);
|
||||
} else if (dt.equals("sfcobs")) {
|
||||
tableRow = FSSObsUtils.getRecordFromMaritime(uri);
|
||||
} catch (PluginException e) {
|
||||
statusHandler.handle(Priority.PROBLEM, e.getLocalizedMessage(),
|
||||
e);
|
||||
}
|
||||
} else if (dt.equals("ldadmesonet")) {
|
||||
try {
|
||||
} else if (dt.equals("ldadmesonet")) {
|
||||
tableRow = FSSObsUtils.getRecordFromMesowest(uri);
|
||||
} catch (Exception e) {
|
||||
statusHandler.handle(Priority.PROBLEM, e.getLocalizedMessage(),
|
||||
e);
|
||||
}
|
||||
|
||||
} catch (PluginException e) {
|
||||
statusHandler.handle(Priority.PROBLEM, "Could not create type: "
|
||||
+ dt + " URI: " + uri, e);
|
||||
}
|
||||
|
||||
if (tableRow.getRelativeHumidity() == ObConst.MISSING) {
|
||||
Float RH = FSSObsUtils.getRH(tableRow.getDewpoint(),
|
||||
tableRow.getTemperature());
|
||||
tableRow.getTemperature());
|
||||
tableRow.setRelativeHumidity(RH);
|
||||
}
|
||||
float[] snowData = FSSObsUtils.getSnowData(tableRow);
|
||||
|
|
Loading…
Add table
Reference in a new issue