From a96d35a1face1ad3b6abb7d558368eec9ba52deb Mon Sep 17 00:00:00 2001 From: Steve Harris Date: Mon, 17 Sep 2012 15:42:31 -0500 Subject: [PATCH] 12.10.1-5 baseline Former-commit-id: 28dc700c3ef97a134c8871c2c52086fe7db43035 --- .../uf/viz/ccfp/rsc/CcfpResource.java | 4 +- .../uf/viz/monitor/ffmp/FFMPMonitor.java | 10 +- .../viz/monitor/ffmp/ui/rsc/FFMPResource.java | 6 +- .../viz/core/rsc/VizGroupResourceData.java | 5 +- .../viz/grid/rsc/FfgVizGroupResourceData.java | 43 +++++- .../timeseries/TimeSeriesDataManager.java | 4 +- .../dialogs/AlarmDisplayWindow.java | 102 ++++++++----- .../alarmalert/dialogs/CurrentAlarmQueue.java | 47 +++--- .../texteditor/dialogs/TextEditorDialog.java | 61 ++++---- .../config/DbAreaSourceDataAdaptor.java | 31 +++- .../viz/warngen/template/TemplateRunner.java | 135 ++++++++++-------- .../warngen/extremeWindWarningFollowup.vm | 4 +- .../warngen/impactSevereWeatherStatement.vm | 4 +- .../base/warngen/impactTornadoWarning.vm | 2 +- .../base/warngen/severeWeatherStatement.vm | 4 +- .../warngen/significantWeatherAdvisory.vm | 2 +- .../warngen/specialMarineWarningFollowup.vm | 6 +- .../uf/common/dataplugin/ffmp/FFMPBasin.java | 21 +-- .../dataplugin/warning/util/GeometryUtil.java | 45 +++++- 19 files changed, 344 insertions(+), 192 deletions(-) diff --git a/cave/com.raytheon.uf.viz.ccfp/src/com/raytheon/uf/viz/ccfp/rsc/CcfpResource.java b/cave/com.raytheon.uf.viz.ccfp/src/com/raytheon/uf/viz/ccfp/rsc/CcfpResource.java index 543b7370c5..ed1f457f7e 100644 --- a/cave/com.raytheon.uf.viz.ccfp/src/com/raytheon/uf/viz/ccfp/rsc/CcfpResource.java +++ b/cave/com.raytheon.uf.viz.ccfp/src/com/raytheon/uf/viz/ccfp/rsc/CcfpResource.java @@ -24,7 +24,7 @@ import java.util.ArrayList; import java.util.Collection; import java.util.Collections; import java.util.HashMap; -import java.util.HashSet; +import java.util.LinkedHashSet; import java.util.List; import java.util.Map; @@ -533,7 +533,7 @@ public class CcfpResource extends synchronized (unprocessedRecords) { records = unprocessedRecords.get(dataTime); if (records == null) { - records = new HashSet(); + records = new LinkedHashSet(); unprocessedRecords.put(dataTime, records); brandNew = true; } diff --git a/cave/com.raytheon.uf.viz.monitor.ffmp/src/com/raytheon/uf/viz/monitor/ffmp/FFMPMonitor.java b/cave/com.raytheon.uf.viz.monitor.ffmp/src/com/raytheon/uf/viz/monitor/ffmp/FFMPMonitor.java index 971db0c94c..2165ed632f 100644 --- a/cave/com.raytheon.uf.viz.monitor.ffmp/src/com/raytheon/uf/viz/monitor/ffmp/FFMPMonitor.java +++ b/cave/com.raytheon.uf.viz.monitor.ffmp/src/com/raytheon/uf/viz/monitor/ffmp/FFMPMonitor.java @@ -647,6 +647,13 @@ public class FFMPMonitor extends ResourceMonitor { Date previousQueryTime = ffmpAvailableUriQueryDates.get(siteKey).get( sourceName); SourceXML source = getSourceConfig().getSource(sourceName); + + if (source.getSourceType().equals( + SOURCE_TYPE.GUIDANCE.getSourceType())) { + // Always look back for guidance types because of long expiration times, + // prevents mosaic brittleness from occurring. + retrieveNew = true; + } if (retrieveNew || ((time != null) && ((previousQueryTime == null) || (time @@ -2322,14 +2329,11 @@ public class FFMPMonitor extends ResourceMonitor { final String fsiteKey; - final boolean fisProductLoad; - public FFMPLoadRecord(boolean isProductLoad, String siteKey, FFMPRecord ffmpRec, String source, String huc) throws Exception { this.fffmpRec = ffmpRec; this.fsource = source; this.fsiteKey = siteKey; - this.fisProductLoad = isProductLoad; this.fhuc = huc; } diff --git a/cave/com.raytheon.uf.viz.monitor.ffmp/src/com/raytheon/uf/viz/monitor/ffmp/ui/rsc/FFMPResource.java b/cave/com.raytheon.uf.viz.monitor.ffmp/src/com/raytheon/uf/viz/monitor/ffmp/ui/rsc/FFMPResource.java index fad201b45c..9398040477 100644 --- a/cave/com.raytheon.uf.viz.monitor.ffmp/src/com/raytheon/uf/viz/monitor/ffmp/ui/rsc/FFMPResource.java +++ b/cave/com.raytheon.uf.viz.monitor.ffmp/src/com/raytheon/uf/viz/monitor/ffmp/ui/rsc/FFMPResource.java @@ -3339,13 +3339,15 @@ public class FFMPResource extends ArrayList qpeTimes = new ArrayList(); if (qpeBasin != null) { + for (Date date : qpeBasin.getValues().keySet()) { double dtime = FFMPGuiUtils.getTimeDiff(mostRecentRefTime, date); - fgd.setQpe(dtime, (double) qpeBasin.getAccumValue(date, + double currVal = qpeBasin.getAccumValue(date, mostRecentRefTime, getQpeSourceExpiration(), - isRate())); + isRate()); + fgd.setQpe(dtime, currVal); qpeTimes.add(dtime); } } diff --git a/cave/com.raytheon.viz.core/src/com/raytheon/viz/core/rsc/VizGroupResourceData.java b/cave/com.raytheon.viz.core/src/com/raytheon/viz/core/rsc/VizGroupResourceData.java index 91c3a17caa..8a0828a0d5 100644 --- a/cave/com.raytheon.viz.core/src/com/raytheon/viz/core/rsc/VizGroupResourceData.java +++ b/cave/com.raytheon.viz.core/src/com/raytheon/viz/core/rsc/VizGroupResourceData.java @@ -53,7 +53,8 @@ import com.raytheon.uf.viz.core.rsc.ResourceList; * * Date Ticket# Engineer Description * ------------ ---------- ----------- -------------------------- - * Jan 28, 2011 mpduff Initial creation + * Jan 28, 2011 mpduff Initial creation. + * Sep 11, 2012 1162 mpduff Made mergeMetaDataMap method public. * * * @@ -117,7 +118,7 @@ public class VizGroupResourceData extends AbstractRequestableResourceData return resource; } - private void mergeMetadataMap() { + public void mergeMetadataMap() { if ((this.metadataMap == null) || this.metadataMap.isEmpty()) { this.metadataMap = new HashMap(); diff --git a/cave/com.raytheon.viz.grid/src/com/raytheon/viz/grid/rsc/FfgVizGroupResourceData.java b/cave/com.raytheon.viz.grid/src/com/raytheon/viz/grid/rsc/FfgVizGroupResourceData.java index 0c5b2634dd..8ef549e06b 100644 --- a/cave/com.raytheon.viz.grid/src/com/raytheon/viz/grid/rsc/FfgVizGroupResourceData.java +++ b/cave/com.raytheon.viz.grid/src/com/raytheon/viz/grid/rsc/FfgVizGroupResourceData.java @@ -19,6 +19,19 @@ **/ package com.raytheon.viz.grid.rsc; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collection; +import java.util.Collections; +import java.util.HashSet; +import java.util.Iterator; +import java.util.List; +import java.util.Set; + +import com.raytheon.uf.common.time.DataTime; +import com.raytheon.uf.viz.core.drawables.ResourcePair; +import com.raytheon.uf.viz.core.exception.VizException; +import com.raytheon.uf.viz.core.rsc.AbstractRequestableResourceData; import com.raytheon.viz.core.rsc.VizGroupResourceData; @@ -31,7 +44,8 @@ import com.raytheon.viz.core.rsc.VizGroupResourceData; * * Date Ticket# Engineer Description * ------------ ---------- ----------- -------------------------- - * Jan 28, 2011 mpduff Initial creation + * Jan 28, 2011 mpduff Initial creation. + * Sep 11, 2012 1162 mpduff Override getAvailableTimes method. * * * @@ -44,4 +58,31 @@ public class FfgVizGroupResourceData extends VizGroupResourceData { // Make name generator here nameGenerator = new FfgGridNameGenerator(); } + + @Override + public DataTime[] getAvailableTimes() throws VizException { + Set baseTimes = new HashSet(); + Iterator rpIter = resourceList.iterator(); + super.mergeMetadataMap(); + + List availableTimes = new ArrayList(); + + while (rpIter.hasNext()) { + ResourcePair rp = rpIter.next(); + + if (rp.getResourceData() instanceof AbstractRequestableResourceData) { + AbstractRequestableResourceData arrd = (AbstractRequestableResourceData) rp + .getResourceData(); + Collection times = Arrays.asList(arrd + .getAvailableTimes()); + + baseTimes.addAll(times); + } + } + + availableTimes.addAll(baseTimes); + Collections.sort(availableTimes); + + return availableTimes.toArray(new DataTime[availableTimes.size()]); + } } diff --git a/cave/com.raytheon.viz.hydro/src/com/raytheon/viz/hydro/timeseries/TimeSeriesDataManager.java b/cave/com.raytheon.viz.hydro/src/com/raytheon/viz/hydro/timeseries/TimeSeriesDataManager.java index ceda995796..0addfee89b 100644 --- a/cave/com.raytheon.viz.hydro/src/com/raytheon/viz/hydro/timeseries/TimeSeriesDataManager.java +++ b/cave/com.raytheon.viz.hydro/src/com/raytheon/viz/hydro/timeseries/TimeSeriesDataManager.java @@ -79,7 +79,7 @@ public class TimeSeriesDataManager extends HydroDataManager { private static final String TIME_SERIES_DATA_QUERY = "select lid,obstime,lid,product_id from latestobsvalue"; - private String INGEST_FILTER_QUERY = "select lid,pe,ts,extremum,dur from ingestfilter where lid=':lid' and ingest = 'T' order by pe asc,dur asc,ts asc,extremum asc"; + private String INGEST_FILTER_QUERY = "select lid,pe,ts,extremum,dur from ingestfilter where lid=':lid' and ingest = 'T' order by pe asc,ts_rank asc,dur asc,ts asc,extremum asc"; private String SHEF_PE_QUERY = "select name||' '|| eng_unit from shefpe where pe=':pe'"; @@ -1386,4 +1386,4 @@ public class TimeSeriesDataManager extends HydroDataManager { public Map getStationDisplayMap() { return stnDisplayMap; } -} \ No newline at end of file +} diff --git a/cave/com.raytheon.viz.texteditor/src/com/raytheon/viz/texteditor/alarmalert/dialogs/AlarmDisplayWindow.java b/cave/com.raytheon.viz.texteditor/src/com/raytheon/viz/texteditor/alarmalert/dialogs/AlarmDisplayWindow.java index f6c7545f1d..f8982b781e 100644 --- a/cave/com.raytheon.viz.texteditor/src/com/raytheon/viz/texteditor/alarmalert/dialogs/AlarmDisplayWindow.java +++ b/cave/com.raytheon.viz.texteditor/src/com/raytheon/viz/texteditor/alarmalert/dialogs/AlarmDisplayWindow.java @@ -42,7 +42,8 @@ import com.raytheon.viz.texteditor.print.PrintDisplay; import com.raytheon.viz.ui.dialogs.CaveSWTDialog; /** - * TODO Add Description + * This is a dialog to display the desired products from the current alarm + * queue. * *
  * 
@@ -58,6 +59,7 @@ import com.raytheon.viz.ui.dialogs.CaveSWTDialog;
  * Nov 15, 2011 11616      rferrel     Change font to fixed width; and text now
  *                                     uses the font.
  * Feb 03, 2012 14317      mhuang      Make alarm display window wider
+ * Sep  6, 2012 13365      rferrel     Accumulate and Display fix.
  * 
  * 
* @@ -67,6 +69,15 @@ import com.raytheon.viz.ui.dialogs.CaveSWTDialog; public class AlarmDisplayWindow extends CaveSWTDialog { + /** + * State to place the accumulate into after adding products in the preopen. + */ + public static enum ACCUMULATE_STATE { + UNCHANGE, TRUE, FALSE + } + + private ACCUMULATE_STATE accum_state; + private Font font; private StyledText text; @@ -75,6 +86,8 @@ public class AlarmDisplayWindow extends CaveSWTDialog { private static boolean accumulate; + private Button accumButton; + private Button printWindow; private Button printBuffer; @@ -85,10 +98,12 @@ public class AlarmDisplayWindow extends CaveSWTDialog { /** * @param parentShell - * @param style + * @param prodList + * @param accum_state */ protected AlarmDisplayWindow(Shell parentShell, - java.util.List prodList) { + java.util.List prodList, + ACCUMULATE_STATE accum_state) { super(parentShell, SWT.RESIZE, CAVE.PERSPECTIVE_INDEPENDENT | CAVE.INDEPENDENT_SHELL); setText("Alarm Display Window"); @@ -96,6 +111,7 @@ public class AlarmDisplayWindow extends CaveSWTDialog { if (prods == null) { prods = new ArrayList(); } + this.accum_state = accum_state; } @Override @@ -132,7 +148,6 @@ public class AlarmDisplayWindow extends CaveSWTDialog { private void initializeComponents() { createMenus(); createTextArea(); - populateText(); } /** @@ -166,16 +181,9 @@ public class AlarmDisplayWindow extends CaveSWTDialog { final Button clearButton = new Button(buttonMenuComp, SWT.PUSH); clearButton.setText("Clear"); - final Button accumButton = new Button(buttonMenuComp, SWT.CHECK); + accumButton = new Button(buttonMenuComp, SWT.CHECK); accumButton.setText("Accumulate"); - accumButton.setSelection(accumulate); - if (accumulate) { - accumButton.setBackground(Display.getCurrent().getSystemColor( - SWT.COLOR_YELLOW)); - } else { - accumButton.setBackground(Display.getCurrent().getSystemColor( - SWT.COLOR_WIDGET_BACKGROUND)); - } + setAccumulate(accumulate); printWindow.addSelectionListener(new SelectionAdapter() { @Override @@ -215,14 +223,7 @@ public class AlarmDisplayWindow extends CaveSWTDialog { accumButton.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent event) { - accumulate = !accumulate; - if (accumulate) { - accumButton.setBackground(Display.getCurrent() - .getSystemColor(SWT.COLOR_YELLOW)); - } else { - accumButton.setBackground(Display.getCurrent() - .getSystemColor(SWT.COLOR_WIDGET_BACKGROUND)); - } + setAccumulate(!accumulate); } }); } @@ -236,22 +237,28 @@ public class AlarmDisplayWindow extends CaveSWTDialog { } private void populateText() { - if (prods != null) { - if (!prods.isEmpty()) { - for (int i = 0; i < prods.size(); i++) { - addText(prods.get(i).getProduct()); - } - } else { - addText(actualText); - } + if (prods == null || prods.isEmpty()) { + text.setText(actualText); } else { - addText(actualText); + if (accumulate) { + text.setText(actualText); + } else { + text.setText(""); + } + boolean saveAccumulate = accumulate; + + // Make sure all products in the list are displayed then restore + // accumulate. + accumulate = true; + for (StdTextProduct prod : prods) { + addText(prod.getProduct()); + } + accumulate = saveAccumulate; } } public void setProds(java.util.List prodList) { prods = prodList; - text.setText(actualText); populateText(); } @@ -269,20 +276,39 @@ public class AlarmDisplayWindow extends CaveSWTDialog { } /** + * Sets the accumulate to the desired state and if active updates the + * display. + * * @param accumulate * the accumulate to set */ public void setAccumulate(boolean accumulate) { AlarmDisplayWindow.accumulate = accumulate; + if (accumButton != null && !accumButton.isDisposed()) { + accumButton.setSelection(accumulate); + if (accumulate) { + accumButton.setBackground(Display.getCurrent().getSystemColor( + SWT.COLOR_YELLOW)); + } else { + accumButton.setBackground(Display.getCurrent().getSystemColor( + SWT.COLOR_WIDGET_BACKGROUND)); + } + } } - /** - * @param args - */ - public static void main(String[] args) { - // TODO take this method out - AlarmDisplayWindow curr = new AlarmDisplayWindow(new Shell(), null); - curr.open(); + @Override + protected void preOpened() { + super.preOpened(); + populateText(); + switch (accum_state) { + case TRUE: + setAccumulate(true); + break; + case FALSE: + setAccumulate(false); + break; + } + accum_state = ACCUMULATE_STATE.UNCHANGE; } @Override diff --git a/cave/com.raytheon.viz.texteditor/src/com/raytheon/viz/texteditor/alarmalert/dialogs/CurrentAlarmQueue.java b/cave/com.raytheon.viz.texteditor/src/com/raytheon/viz/texteditor/alarmalert/dialogs/CurrentAlarmQueue.java index ea12b4095d..c110ad1010 100644 --- a/cave/com.raytheon.viz.texteditor/src/com/raytheon/viz/texteditor/alarmalert/dialogs/CurrentAlarmQueue.java +++ b/cave/com.raytheon.viz.texteditor/src/com/raytheon/viz/texteditor/alarmalert/dialogs/CurrentAlarmQueue.java @@ -53,6 +53,7 @@ import com.raytheon.uf.common.status.UFStatus; import com.raytheon.uf.common.status.UFStatus.Priority; import com.raytheon.uf.edex.services.textdbsrv.IQueryTransport; import com.raytheon.viz.core.mode.CAVEMode; +import com.raytheon.viz.texteditor.alarmalert.dialogs.AlarmDisplayWindow.ACCUMULATE_STATE; import com.raytheon.viz.texteditor.alarmalert.util.AlarmAlertFunctions; import com.raytheon.viz.texteditor.alarmalert.util.AlarmAlertLists; import com.raytheon.viz.texteditor.alarmalert.util.CurrentAlarmEvent; @@ -90,8 +91,9 @@ import com.raytheon.viz.ui.dialogs.ModeListener; * May 23, 2012 14952 rferrel Now use refTime/createtime to display * selected product * Aug 28, 2012 14795 mgamazaychikov Fixed problem with "Unhadled event loop" - * exception associated with closing - * "Current Alarm Queue" GUI + * exception associated with closing "Current + * Alarm Queue" GUI + * Sep 6, 2012 13365 rferrel Accumulate and Display fix. * * * @author mnash @@ -383,7 +385,8 @@ public class CurrentAlarmQueue extends CaveSWTDialog implements } if (alarmDisplayDlg == null) { - alarmDisplayDlg = new AlarmDisplayWindow(shell, prods); + alarmDisplayDlg = new AlarmDisplayWindow(shell, prods, + ACCUMULATE_STATE.UNCHANGE); alarmDisplayDlg.open(); if (list != null && !list.isDisposed() && list.getItemCount() == 0) { close(); @@ -391,7 +394,8 @@ public class CurrentAlarmQueue extends CaveSWTDialog implements } else { if (alarmDisplayDlg.getShell() == null || alarmDisplayDlg.getShell().isDisposed()) { - alarmDisplayDlg = new AlarmDisplayWindow(shell, prods); + alarmDisplayDlg = new AlarmDisplayWindow(shell, prods, + ACCUMULATE_STATE.UNCHANGE); alarmDisplayDlg.open(); if (list != null && !list.isDisposed() && list.getItemCount() == 0) { @@ -445,36 +449,25 @@ public class CurrentAlarmQueue extends CaveSWTDialog implements list.removeAll(); AlarmAlertFunctions.getAlarmalertbell().close(); } - if (alarmDisplayDlg == null) { - java.util.List prods = new ArrayList(); - if (command.length > 0) { - for (int i = 0; i < command.length; i++) { - prods.addAll(produceTextProduct(command[i])); - } + + java.util.List prods = new ArrayList(); + if (command.length > 0) { + for (int i = 0; i < command.length; i++) { + prods.addAll(produceTextProduct(command[i])); } - alarmDisplayDlg = new AlarmDisplayWindow(shell, prods); - alarmDisplayDlg.setAccumulate(true); + } + + if (alarmDisplayDlg == null) { + alarmDisplayDlg = new AlarmDisplayWindow(shell, prods, + ACCUMULATE_STATE.TRUE); alarmDisplayDlg.open(); } else { if (alarmDisplayDlg.getShell() == null || alarmDisplayDlg.getShell().isDisposed()) { - java.util.List prods = new ArrayList(); - if (command.length > 0) { - for (int i = 0; i < command.length; i++) { - prods.addAll(produceTextProduct(command[i])); - } - } - alarmDisplayDlg = new AlarmDisplayWindow(shell, prods); - alarmDisplayDlg.setAccumulate(true); + alarmDisplayDlg = new AlarmDisplayWindow(shell, prods, + ACCUMULATE_STATE.TRUE); alarmDisplayDlg.open(); } else { - alarmDisplayDlg.setAccumulate(true); - java.util.List prods = new ArrayList(); - if (command.length > 0) { - for (int i = 0; i < command.length; i++) { - prods.addAll(produceTextProduct(command[i])); - } - } alarmDisplayDlg.setProds(prods); alarmDisplayDlg.setAccumulate(true); alarmDisplayDlg.setDialogFocus(); diff --git a/cave/com.raytheon.viz.texteditor/src/com/raytheon/viz/texteditor/dialogs/TextEditorDialog.java b/cave/com.raytheon.viz.texteditor/src/com/raytheon/viz/texteditor/dialogs/TextEditorDialog.java index df13ccbbb9..b8e843f94a 100644 --- a/cave/com.raytheon.viz.texteditor/src/com/raytheon/viz/texteditor/dialogs/TextEditorDialog.java +++ b/cave/com.raytheon.viz.texteditor/src/com/raytheon/viz/texteditor/dialogs/TextEditorDialog.java @@ -283,9 +283,10 @@ import com.raytheon.viz.ui.dialogs.SWTMessageBox; * 18JUL2012 14457 rferrel Add mouse listener to clear site's update obs when clicked on. * 25JUL2012 14459 rferrel Strip WMH headers when getting all METARs. * 13AUG2012 14613 M.Gamazaychikov Ensured the WMO and MND header times are the same. - * 20AUG2012 15340 D.Friedman Use callbacks for stop sign dialog. Prevent NOR in header. + * 20AUG2012 15340 D.Friedman Use callbacks for stop sign dialog. Prevent NOR in header. + * 10SEP2012 15334 rferrel No longer wrap text pasted to an empty text field. * 10Sep2012 15103 M.Gamazaychikov DR15103 -do not clear AFOS command from the text box - * when obs are updated and refactored executeCommand + * when obs are updated and refactored executeCommand * 10SEP2012 15401 D.Friedman Fix QC problem caused by DR 15340. * * @@ -4116,6 +4117,13 @@ public class TextEditorDialog extends CaveSWTDialog implements VerifyListener, private void pasteText() { // AWIPS I just does the pasted in both overwrite and insert mode. try { + // When pasting to empty editor assume text is properly formatted + // and does not need wrapping. + boolean doWrap = true; + if (textEditor.getText().trim().length() == 0) { + doWrap = false; + textEditor.setText(""); + } int start = -1; if (textEditor.getSelectionCount() == 0) { start = textEditor.getCaretOffset(); @@ -4123,7 +4131,9 @@ public class TextEditorDialog extends CaveSWTDialog implements VerifyListener, start = textEditor.getSelectionRange().x; } textEditor.paste(); - rewrap(start, textEditor.getCaretOffset()); + if (doWrap) { + rewrap(start, textEditor.getCaretOffset()); + } } catch (IllegalArgumentException ex) { // Ignore } @@ -4368,7 +4378,8 @@ public class TextEditorDialog extends CaveSWTDialog implements VerifyListener, final CAVEMode mode = CAVEMode.getMode(); StdTextProduct prod = getStdTextProduct(); String afosId = prod.getCccid() + prod.getNnnid() + prod.getXxxid(); - final String title = QualityControl.getProductWarningType(prod.getNnnid()); + final String title = QualityControl.getProductWarningType(prod + .getNnnid()); final StringBuilder productMessage = new StringBuilder(); final StringBuilder modeMessage = new StringBuilder(); @@ -4382,7 +4393,7 @@ public class TextEditorDialog extends CaveSWTDialog implements VerifyListener, } else if (warnGenFlag) { productMessage.append("You are about to SEND a " + afosId + "\n"); productMessage.append(title).append(".\n"); - + QualityControl qcCheck = new QualityControl(); if (qcCheck.checkWarningInfo(headerTF.getText().toUpperCase(), textEditor.getText().toUpperCase(), prod.getNnnid()) == false) { @@ -4393,7 +4404,8 @@ public class TextEditorDialog extends CaveSWTDialog implements VerifyListener, @Override public void dialogDismissed(Object dialogResult) { if (Boolean.TRUE.equals(dialogResult)) - finishSendProduct1(resend, title, mode, productMessage, modeMessage); + finishSendProduct1(resend, title, mode, + productMessage, modeMessage); } }); @@ -4403,7 +4415,9 @@ public class TextEditorDialog extends CaveSWTDialog implements VerifyListener, finishSendProduct1(resend, title, mode, productMessage, modeMessage); } - private void finishSendProduct1(final boolean resend, String title, CAVEMode mode, StringBuilder productMessage, StringBuilder modeMessage) { + private void finishSendProduct1(final boolean resend, String title, + CAVEMode mode, StringBuilder productMessage, + StringBuilder modeMessage) { Pattern p = Pattern.compile(".\\%[s]."); Matcher m = p.matcher(STORED_SENT_MSG); @@ -4468,7 +4482,8 @@ public class TextEditorDialog extends CaveSWTDialog implements VerifyListener, token); OUPRequest req = new OUPRequest(); OfficialUserProduct oup = new OfficialUserProduct(); - StdTextProduct prod = getStdTextProduct(); // TODO: makes me nervous... + StdTextProduct prod = getStdTextProduct(); // TODO: makes me + // nervous... String awipsWanPil = prod.getSite() + prod.getNnnid() + prod.getXxxid(); String awipsID = prod.getNnnid() + prod.getXxxid(); @@ -4623,15 +4638,14 @@ public class TextEditorDialog extends CaveSWTDialog implements VerifyListener, boolean successful = false; /* - * DR14613 - string currectDate is derived from Date now - * ensuring the same time in WMO heading and in the - * MND heading. + * DR14613 - string currectDate is derived from Date now ensuring the + * same time in WMO heading and in the MND heading. */ Date now = SimulatedTime.getSystemTime().getTime(); String currentDate = getCurrentDate(now); TextDisplayModel tdmInst = TextDisplayModel.getInstance(); - // Convert the text in the text editor to uppercase + // Convert the text in the text editor to uppercase if (!isAutoSave) { if (!verifyRequiredFields()) { return false; @@ -4667,10 +4681,10 @@ public class TextEditorDialog extends CaveSWTDialog implements VerifyListener, VtecObject vtecObj = VtecUtil.parseMessage(productText); if (warnGenFlag) { - /* + /* * DR14613 - string currectDate is derived from Date now - * ensuring the same time in WMO heading and in the - * MND heading. + * ensuring the same time in WMO heading and in the MND + * heading. */ productText = updateVtecTimes(productText, vtecObj, now); productText = updateHeaderTimes(productText, now); @@ -5134,9 +5148,9 @@ public class TextEditorDialog extends CaveSWTDialog implements VerifyListener, } private String getCurrentDate(Date now) { - /* - * DR14613 - pass the Date now as an argument - */ + /* + * DR14613 - pass the Date now as an argument + */ SimpleDateFormat formatter = new SimpleDateFormat("ddHHmm"); formatter.setTimeZone(TimeZone.getTimeZone("GMT")); return (formatter.format(now)); @@ -5163,11 +5177,11 @@ public class TextEditorDialog extends CaveSWTDialog implements VerifyListener, product = product.replace( vtecFormatter.format(vtecObj.getStartTime().getTime()), vtecFormatter.format(now)); - } + } return product; } - + /** * Update the MND header time using the Date now. * @@ -5176,7 +5190,7 @@ public class TextEditorDialog extends CaveSWTDialog implements VerifyListener, * @return */ private String updateHeaderTimes(String product, Date now) { - // Update the header time + // Update the header time Matcher m = datePtrn.matcher(product); if (m.find()) { SimpleDateFormat headerFormat = new SimpleDateFormat( @@ -5187,9 +5201,8 @@ public class TextEditorDialog extends CaveSWTDialog implements VerifyListener, product = product.replace(m.group(1), headerFormat.format(now) .toUpperCase()); } - return product; + return product; } - public void setCurrentWmoId(String wmoId) { TextDisplayModel.getInstance().setWmoId(token, wmoId); @@ -7311,7 +7324,7 @@ public class TextEditorDialog extends CaveSWTDialog implements VerifyListener, job.setSystem(true); job.schedule(); } - + private static String fixNOR(String bbb) { if ("NOR".equals(bbb)) return ""; diff --git a/cave/com.raytheon.viz.warngen/src/com/raytheon/viz/warngen/config/DbAreaSourceDataAdaptor.java b/cave/com.raytheon.viz.warngen/src/com/raytheon/viz/warngen/config/DbAreaSourceDataAdaptor.java index 9a7b476aef..6f6549c7e9 100644 --- a/cave/com.raytheon.viz.warngen/src/com/raytheon/viz/warngen/config/DbAreaSourceDataAdaptor.java +++ b/cave/com.raytheon.viz.warngen/src/com/raytheon/viz/warngen/config/DbAreaSourceDataAdaptor.java @@ -15,6 +15,7 @@ import com.raytheon.uf.common.geospatial.SpatialQueryResult; import com.raytheon.viz.warngen.PreferenceUtil; import com.raytheon.viz.warngen.gis.ClosestPoint; import com.raytheon.viz.warngen.gis.GisUtil; +import com.raytheon.viz.warngen.gis.GisUtil.Direction; import com.vividsolutions.jts.geom.Coordinate; import com.vividsolutions.jts.geom.Geometry; @@ -94,9 +95,33 @@ public class DbAreaSourceDataAdaptor extends AbstractDbSourceDataAdaptor { partOfArea = GisUtil.asStringList(GisUtil.calculatePortion(geom, intersection, gc, "")); - String suppressedDirections = String.valueOf(attributes - .get(suppressedDirectionsField)); - partOfArea.remove(suppressedDirections); + if (attributes.get(suppressedDirectionsField) != null) { + String suppressedDirections = String.valueOf( + attributes.get(suppressedDirectionsField)) + .toLowerCase(); + // supdirs can be 'nse', for example + // TODO create an enum constructor for Directions + for (int i = 0; i < suppressedDirections.length(); i++) { + switch (suppressedDirections.charAt(i)) { + case 'n': + partOfArea.remove(Direction.NORTH.toString()); + break; + case 's': + partOfArea.remove(Direction.SOUTH.toString()); + break; + case 'e': + partOfArea.remove(Direction.EAST.toString()); + break; + case 'w': + partOfArea.remove(Direction.WEST.toString()); + break; + case 'c': + partOfArea.remove(Direction.CENTRAL.toString()); + break; + } + } + + } } return partOfArea; diff --git a/cave/com.raytheon.viz.warngen/src/com/raytheon/viz/warngen/template/TemplateRunner.java b/cave/com.raytheon.viz.warngen/src/com/raytheon/viz/warngen/template/TemplateRunner.java index c39ec708da..5570b83ee6 100644 --- a/cave/com.raytheon.viz.warngen/src/com/raytheon/viz/warngen/template/TemplateRunner.java +++ b/cave/com.raytheon.viz.warngen/src/com/raytheon/viz/warngen/template/TemplateRunner.java @@ -125,8 +125,8 @@ import com.vividsolutions.jts.io.WKTReader; * Jul 16, 2012 15091 Qinglu Lin Compute intersection area, which is used for prevent 2nd timezone * from appearing in 2nd and 3rd bullets when not necessary. * Aug 13, 2012 14493 Qinglu Lin Handled MND time, event time, and TML time specially for COR to NEW. + * Aug 29, 2011 15351 jsanchez Set the timezone for TML time. * Sep 10, 2012 15295 snaples Added property setting for runtime log to createScript. - * * * * @author njensen @@ -242,7 +242,7 @@ public class TemplateRunner { AffectedAreas[] cancelareas = null; Map intersectAreas = null; Wx wx = null; - long wwaMNDTime = 0l; + long wwaMNDTime = 0l; try { t0 = System.currentTimeMillis(); areas = Area.findAffectedAreas(config, warnPolygon, warningArea, @@ -375,7 +375,7 @@ public class TemplateRunner { startTime.getTime(), DateUtil.roundDateTo15(endTime) .getTime(), warnPolygon); if (selectedAction == WarningAction.COR) { - wwaMNDTime = wx.getStartTime().getTime(); + wwaMNDTime = wx.getStartTime().getTime(); } else { context.put("now", simulatedTime); context.put("start", wx.getStartTime()); @@ -391,7 +391,7 @@ public class TemplateRunner { context.put("duration", duration); context.put("event", eventTime); - context.put("TMLtime", eventTime); + context.put("TMLtime", eventTime); context.put("ugcline", FipsUtil.getUgcLine(areas, wx.getEndTime(), 15)); context.put("areaPoly", GisUtil.convertCoords(warngenLayer @@ -550,67 +550,78 @@ public class TemplateRunner { context.put("etn", etn); context.put("start", oldWarn.getIssueTime().getTime()); if (oldWarn.getAct().equals("NEW")) { - context.put("now", new Date(wwaMNDTime)); + context.put("now", new Date(wwaMNDTime)); } else context.put("now", simulatedTime); context.put("event", oldWarn.getIssueTime().getTime()); - - String message = oldWarn.getRawmessage(); - if (!stormTrackState.originalTrack) { - context.put("TMLtime", oldWarn.getStartTime().getTime()); - } else { - int hour = 0; - int minute = 0; - int tmlIndex = message.indexOf("TIME...MOT...LOC"); - int zIndex = -1; - if (tmlIndex > 0) { - zIndex = message.indexOf("Z", tmlIndex); - if (zIndex > 0) { - int startIndex = tmlIndex+16+1; - String tmlTime = null; - tmlTime = message.substring(startIndex,startIndex+4); - if (tmlTime.length() == 4) { - hour = Integer.parseInt(tmlTime.substring(0,2)); - minute = Integer.parseInt(tmlTime.substring(2,4)); - } else if (tmlTime.length() == 3) { - hour = Integer.parseInt(tmlTime.substring(0,1)); - minute = Integer.parseInt(tmlTime.substring(1,3)); - } else { - throw new VizException("The length of hour and minute for TML time is neither 3 nor 4."); - } - Calendar c = Calendar.getInstance(); - c.set(Calendar.HOUR_OF_DAY,hour); - c.set(Calendar.MINUTE, minute); - context.put("TMLtime", c.getTime()); - } else { - throw new VizException("Z, therefore hour and minute, cannot be found in TIME...MOT...LOC line."); - } - } else { - // To prevent errors resulting from undefined context("TMLtime") - context.put("TMLtime", oldWarn.getIssueTime().getTime()); - } - } - - // corEventtime for "COR to NEW", not for "COR to CON, CAN, or CANCON" - if (oldWarn.getAct().equals("NEW")) { - int untilIndex = message.indexOf("UNTIL"); - int atIndex = -1; - int elipsisIndex = -1; - if (untilIndex > 0) { - atIndex = message.indexOf("AT", untilIndex); - if (atIndex > 0) { - int hhmmIndex = atIndex+3; - elipsisIndex = message.indexOf("...", hhmmIndex); - if (elipsisIndex > 0) { - context.put("corToNewMarker","cortonewmarker"); - context.put("corEventtime",message.substring(hhmmIndex,elipsisIndex)); - } - } - } - if (untilIndex < 0 || atIndex < 0 || elipsisIndex < 0) - throw new VizException("Cannot find * AT line."); - } - + + String message = oldWarn.getRawmessage(); + if (!stormTrackState.originalTrack) { + context.put("TMLtime", oldWarn.getStartTime().getTime()); + } else { + int hour = 0; + int minute = 0; + int tmlIndex = message.indexOf("TIME...MOT...LOC"); + int zIndex = -1; + if (tmlIndex > 0) { + zIndex = message.indexOf("Z", tmlIndex); + if (zIndex > 0) { + int startIndex = tmlIndex + 16 + 1; + String tmlTime = null; + tmlTime = message.substring(startIndex, + startIndex + 4); + if (tmlTime.length() == 4) { + hour = Integer + .parseInt(tmlTime.substring(0, 2)); + minute = Integer.parseInt(tmlTime.substring(2, + 4)); + } else if (tmlTime.length() == 3) { + hour = Integer + .parseInt(tmlTime.substring(0, 1)); + minute = Integer.parseInt(tmlTime.substring(1, + 3)); + } else { + throw new VizException( + "The length of hour and minute for TML time is neither 3 nor 4."); + } + Calendar c = Calendar.getInstance(TimeZone + .getTimeZone("GMT")); + c.set(Calendar.HOUR_OF_DAY, hour); + c.set(Calendar.MINUTE, minute); + context.put("TMLtime", c.getTime()); + } else { + throw new VizException( + "Z, therefore hour and minute, cannot be found in TIME...MOT...LOC line."); + } + } else { + // To prevent errors resulting from undefined + // context("TMLtime") + context.put("TMLtime", oldWarn.getIssueTime().getTime()); + } + } + + // corEventtime for "COR to NEW", not for + // "COR to CON, CAN, or CANCON" + if (oldWarn.getAct().equals("NEW")) { + int untilIndex = message.indexOf("UNTIL"); + int atIndex = -1; + int elipsisIndex = -1; + if (untilIndex > 0) { + atIndex = message.indexOf("AT", untilIndex); + if (atIndex > 0) { + int hhmmIndex = atIndex + 3; + elipsisIndex = message.indexOf("...", hhmmIndex); + if (elipsisIndex > 0) { + context.put("corToNewMarker", "cortonewmarker"); + context.put("corEventtime", message.substring( + hhmmIndex, elipsisIndex)); + } + } + } + if (untilIndex < 0 || atIndex < 0 || elipsisIndex < 0) + throw new VizException("Cannot find * AT line."); + } + Calendar cal = oldWarn.getEndTime(); cal.add(Calendar.MILLISECOND, 1); context.put("expire", cal.getTime()); diff --git a/edexOsgi/build.edex/esb/data/utility/common_static/base/warngen/extremeWindWarningFollowup.vm b/edexOsgi/build.edex/esb/data/utility/common_static/base/warngen/extremeWindWarningFollowup.vm index ca65bb9b66..4a41250f6c 100644 --- a/edexOsgi/build.edex/esb/data/utility/common_static/base/warngen/extremeWindWarningFollowup.vm +++ b/edexOsgi/build.edex/esb/data/utility/common_static/base/warngen/extremeWindWarningFollowup.vm @@ -336,7 +336,7 @@ THIS IS A TEST MESSAGE. DO NOT TAKE ACTION BASED ON THIS MESSAGE. #printcoords(${areaPoly}, ${list}) TIME...MOT...LOC ## -${dateUtil.format(${event}, ${timeFormat.time})}Z ## +${dateUtil.format(${TMLtime}, ${timeFormat.time})}Z ## ${mathUtil.roundAndPad(${movementDirection})}DEG ## ${mathUtil.round(${movementInKnots})}KT ## #foreach(${eventCoord} in ${eventLocation}) @@ -487,7 +487,7 @@ LAT...LON ## #end TIME...MOT...LOC ## -${dateUtil.format(${event}, ${timeFormat.time})}Z ## +${dateUtil.format(${TMLtime}, ${timeFormat.time})}Z ## ${mathUtil.roundAndPad(${movementDirection})}DEG ## ${mathUtil.round(${movementInKnots})}KT ## #foreach(${eventCoord} in ${eventLocation}) diff --git a/edexOsgi/build.edex/esb/data/utility/common_static/base/warngen/impactSevereWeatherStatement.vm b/edexOsgi/build.edex/esb/data/utility/common_static/base/warngen/impactSevereWeatherStatement.vm index 3aac4392af..4695eea693 100644 --- a/edexOsgi/build.edex/esb/data/utility/common_static/base/warngen/impactSevereWeatherStatement.vm +++ b/edexOsgi/build.edex/esb/data/utility/common_static/base/warngen/impactSevereWeatherStatement.vm @@ -302,7 +302,7 @@ REMEMBER...A TORNADO WARNING STILL REMAINS IN EFFECT FOR !** PORTION AND COUNTY #printcoords(${areaPoly}, ${list}) TIME...MOT...LOC ## -${dateUtil.format(${now}, ${timeFormat.time})}Z ## +${dateUtil.format(${TMLtime}, ${timeFormat.time})}Z ## ${mathUtil.roundAndPad(${movementDirection})}DEG ## ${mathUtil.round(${movementInKnots})}KT ## #foreach(${eventCoord} in ${eventLocation}) @@ -1161,7 +1161,7 @@ THIS IS A TEST MESSAGE. DO NOT TAKE ACTION BASED ON THIS MESSAGE. #printcoords(${areaPoly}, ${list}) TIME...MOT...LOC ## -${dateUtil.format(${event}, ${timeFormat.time})}Z ## +${dateUtil.format(${TMLtime}, ${timeFormat.time})}Z ## ${mathUtil.roundAndPad(${movementDirection})}DEG ## ${mathUtil.round(${movementInKnots})}KT ## #foreach(${eventCoord} in ${eventLocation}) diff --git a/edexOsgi/build.edex/esb/data/utility/common_static/base/warngen/impactTornadoWarning.vm b/edexOsgi/build.edex/esb/data/utility/common_static/base/warngen/impactTornadoWarning.vm index 4ca6ee4802..ae7916a2fa 100644 --- a/edexOsgi/build.edex/esb/data/utility/common_static/base/warngen/impactTornadoWarning.vm +++ b/edexOsgi/build.edex/esb/data/utility/common_static/base/warngen/impactTornadoWarning.vm @@ -627,7 +627,7 @@ THIS IS A TEST MESSAGE. DO NOT TAKE ACTION BASED ON THIS MESSAGE. #printcoords(${areaPoly}, ${list}) TIME...MOT...LOC ## -${dateUtil.format(${event}, ${timeFormat.time})}Z ## +${dateUtil.format(${TMLtime}, ${timeFormat.time})}Z ## ${mathUtil.roundAndPad(${movementDirection})}DEG ## ${mathUtil.round(${movementInKnots})}KT ## #foreach(${eventCoord} in ${eventLocation}) diff --git a/edexOsgi/build.edex/esb/data/utility/common_static/base/warngen/severeWeatherStatement.vm b/edexOsgi/build.edex/esb/data/utility/common_static/base/warngen/severeWeatherStatement.vm index da9149404a..4d724743de 100644 --- a/edexOsgi/build.edex/esb/data/utility/common_static/base/warngen/severeWeatherStatement.vm +++ b/edexOsgi/build.edex/esb/data/utility/common_static/base/warngen/severeWeatherStatement.vm @@ -277,7 +277,7 @@ REMEMBER...A TORNADO WARNING STILL REMAINS IN EFFECT FOR !** PORTION AND COUNTY #printcoords(${areaPoly}, ${list}) TIME...MOT...LOC ## -${dateUtil.format(${now}, ${timeFormat.time})}Z ## +${dateUtil.format(${TMLtime}, ${timeFormat.time})}Z ## ${mathUtil.roundAndPad(${movementDirection})}DEG ## ${mathUtil.round(${movementInKnots})}KT ## #foreach(${eventCoord} in ${eventLocation}) @@ -859,7 +859,7 @@ THIS IS A TEST MESSAGE. DO NOT TAKE ACTION BASED ON THIS MESSAGE. #printcoords(${areaPoly}, ${list}) TIME...MOT...LOC ## -${dateUtil.format(${event}, ${timeFormat.time})}Z ## +${dateUtil.format(${TMLtime}, ${timeFormat.time})}Z ## ${mathUtil.roundAndPad(${movementDirection})}DEG ## ${mathUtil.round(${movementInKnots})}KT ## #foreach(${eventCoord} in ${eventLocation}) diff --git a/edexOsgi/build.edex/esb/data/utility/common_static/base/warngen/significantWeatherAdvisory.vm b/edexOsgi/build.edex/esb/data/utility/common_static/base/warngen/significantWeatherAdvisory.vm index d0ceee0fff..c250d6c47e 100644 --- a/edexOsgi/build.edex/esb/data/utility/common_static/base/warngen/significantWeatherAdvisory.vm +++ b/edexOsgi/build.edex/esb/data/utility/common_static/base/warngen/significantWeatherAdvisory.vm @@ -322,7 +322,7 @@ THIS IS A TEST MESSAGE. DO NOT TAKE ACTION BASED ON THIS MESSAGE. #printcoords(${areaPoly}, ${list}) TIME...MOT...LOC ## -${dateUtil.format(${event}, ${timeFormat.time})}Z ## +${dateUtil.format(${TMLtime}, ${timeFormat.time})}Z ## ${mathUtil.roundAndPad(${movementDirection})}DEG ## ${mathUtil.round(${movementInKnots})}KT ## #foreach(${eventCoord} in ${eventLocation}) diff --git a/edexOsgi/build.edex/esb/data/utility/common_static/base/warngen/specialMarineWarningFollowup.vm b/edexOsgi/build.edex/esb/data/utility/common_static/base/warngen/specialMarineWarningFollowup.vm index 0779831aa9..6aad13d52d 100644 --- a/edexOsgi/build.edex/esb/data/utility/common_static/base/warngen/specialMarineWarningFollowup.vm +++ b/edexOsgi/build.edex/esb/data/utility/common_static/base/warngen/specialMarineWarningFollowup.vm @@ -563,7 +563,7 @@ THIS IS A TEST MESSAGE. DO NOT TAKE ACTION BASED ON THIS MESSAGE. #printcoords(${areaPoly}, ${list}) TIME...MOT...LOC ## -${dateUtil.format(${event}, ${timeFormat.time})}Z ## +${dateUtil.format(${TMLtime}, ${timeFormat.time})}Z ## ${mathUtil.roundAndPad(${movementDirection})}DEG ## ${mathUtil.round(${movementInKnots})}KT ## #foreach(${eventCoord} in ${eventLocation}) @@ -976,7 +976,7 @@ THIS IS A TEST MESSAGE. DO NOT TAKE ACTION BASED ON THIS MESSAGE. #printcoords(${areaPoly}, ${list}) TIME...MOT...LOC ## -${dateUtil.format(${event}, ${timeFormat.time})}Z ## +${dateUtil.format(${TMLtime}, ${timeFormat.time})}Z ## ${mathUtil.roundAndPad(${movementDirection})}DEG ## ${mathUtil.round(${movementInKnots})}KT ## #foreach(${eventCoord} in ${eventLocation}) @@ -1402,7 +1402,7 @@ THIS IS A TEST MESSAGE. DO NOT TAKE ACTION BASED ON THIS MESSAGE. #printcoords(${areaPoly}, ${list}) TIME...MOT...LOC ## -${dateUtil.format(${now}, ${timeFormat.time})}Z ## +${dateUtil.format(${TMLtime}, ${timeFormat.time})}Z ## ${mathUtil.roundAndPad(${movementDirection})}DEG ## ${mathUtil.round(${movementInKnots})}KT ## #foreach(${eventCoord} in ${eventLocation}) diff --git a/edexOsgi/com.raytheon.uf.common.dataplugin.ffmp/src/com/raytheon/uf/common/dataplugin/ffmp/FFMPBasin.java b/edexOsgi/com.raytheon.uf.common.dataplugin.ffmp/src/com/raytheon/uf/common/dataplugin/ffmp/FFMPBasin.java index 43bd34031e..273200bba5 100644 --- a/edexOsgi/com.raytheon.uf.common.dataplugin.ffmp/src/com/raytheon/uf/common/dataplugin/ffmp/FFMPBasin.java +++ b/edexOsgi/com.raytheon.uf.common.dataplugin.ffmp/src/com/raytheon/uf/common/dataplugin/ffmp/FFMPBasin.java @@ -161,11 +161,13 @@ public class FFMPBasin implements ISerializableObject, Cloneable { ArrayList keys = new ArrayList(); - for (Date date : values.descendingKeySet()) { + for (Date date : values.keySet()) { if (date.before(beforeDate) && date.after(afterDate)) { keys.add(date); } } + + float factor = 0.0f; for (Date key : keys) { Date tdate = key; @@ -179,30 +181,29 @@ public class FFMPBasin implements ISerializableObject, Cloneable { if (val > 0.0f) { - float factor = 0.0f; - if ((prevDate.getTime() - tdate.getTime()) > expirationTime) { // handle the gap and accumulate the book ends // of it - factor = (float) ((prevDate.getTime() - (prevDate - .getTime() - expirationTime)) / (1000.0 * 60.0 * 60.0)); + factor = ((prevDate.getTime() - (prevDate + .getTime() - expirationTime)) / (1000.0f * 60.0f * 60.0f)); } else { - factor = (float) ((prevDate.getTime() - tdate - .getTime()) / (1000.0 * 60.0 * 60.0)); + factor = ((prevDate.getTime() - tdate + .getTime()) / (1000.0f * 60.0f * 60.0f)); } // do absolute values so it dosen't matter which way // you traverse the list val = val * Math.abs(factor); + } } - + dvalue += val; prevDate = key; } } } - + return dvalue; } @@ -341,7 +342,7 @@ public class FFMPBasin implements ISerializableObject, Cloneable { @Override public int compare(Date o1, Date o2) { // Null checks? - return (o2.before(o1) ? -1 : (o1.equals(o2) ? 0 : 1)); + return (int)Math.signum(o2.getTime() - o1.getTime()) ; } }); diff --git a/edexOsgi/com.raytheon.uf.common.dataplugin.warning/src/com/raytheon/uf/common/dataplugin/warning/util/GeometryUtil.java b/edexOsgi/com.raytheon.uf.common.dataplugin.warning/src/com/raytheon/uf/common/dataplugin/warning/util/GeometryUtil.java index 737400556a..0ce2c7f5f2 100644 --- a/edexOsgi/com.raytheon.uf.common.dataplugin.warning/src/com/raytheon/uf/common/dataplugin/warning/util/GeometryUtil.java +++ b/edexOsgi/com.raytheon.uf.common.dataplugin.warning/src/com/raytheon/uf/common/dataplugin/warning/util/GeometryUtil.java @@ -1,19 +1,23 @@ package com.raytheon.uf.common.dataplugin.warning.util; import java.util.ArrayList; +import java.util.Collection; import java.util.HashSet; import java.util.List; import java.util.Set; import java.util.TreeSet; +import com.vividsolutions.jts.geom.Coordinate; import com.vividsolutions.jts.geom.Geometry; import com.vividsolutions.jts.geom.GeometryCollection; import com.vividsolutions.jts.geom.GeometryFactory; +import com.vividsolutions.jts.geom.LineString; import com.vividsolutions.jts.geom.Polygon; import com.vividsolutions.jts.geom.TopologyException; import com.vividsolutions.jts.geom.prep.PreparedGeometry; import com.vividsolutions.jts.geom.prep.PreparedGeometryFactory; import com.vividsolutions.jts.operation.overlay.snap.GeometrySnapper; +import com.vividsolutions.jts.operation.polygonize.Polygonizer; public class GeometryUtil { @@ -217,21 +221,52 @@ public class GeometryUtil { Geometry section = null; try { section = g1.intersection(g2); - } catch (TopologyException e) { - // This exception is due to g2 having interior intersections - section = g1.intersection(g2.buffer(0)); + } catch (TopologyException e) { + // This exception is due to g2 having interior + // intersections + section = clean(g1).intersection(g2.buffer(0)); } - + if (section != null) { setUserData(section, (CountyUserData) g2.getUserData()); section.setUserData(g2.getUserData()); intersections.add(section); - } + } } } } } + /** + * Returns a geometry from the noded line strings of g. + * + * @param g + * geometry to be cleaned up + * @return + */ + private static Geometry clean(Geometry g) { + Coordinate[] coords = g.getCoordinates(); + + // create a line string + GeometryFactory gf = new GeometryFactory(); + LineString ls = gf.createLineString(coords); + + // node the line string (insert vertices where lines cross) + com.vividsolutions.jts.geom.Point pt = gf.createPoint(ls + .getCoordinate()); + Geometry nodedLines = ls.union(pt); + + // create the polygon(s) from the noded line + Polygonizer polygonizer = new Polygonizer(); + polygonizer.add(nodedLines); + Collection polygons = polygonizer.getPolygons(); + + g = gf.createMultiPolygon( + polygons.toArray(new Polygon[polygons.size()])).buffer(0); + + return g; + } + /** * Get the difference between the 2 geometries *