diff --git a/cave/com.raytheon.viz.warngen/src/com/raytheon/viz/warngen/text/AbstractLockingBehavior.java b/cave/com.raytheon.viz.warngen/src/com/raytheon/viz/warngen/text/AbstractLockingBehavior.java index 8379232b92..b9149a023e 100644 --- a/cave/com.raytheon.viz.warngen/src/com/raytheon/viz/warngen/text/AbstractLockingBehavior.java +++ b/cave/com.raytheon.viz.warngen/src/com/raytheon/viz/warngen/text/AbstractLockingBehavior.java @@ -53,6 +53,7 @@ import com.raytheon.viz.warngen.gis.AffectedAreas; * moved the following methods from InitialLockingBehavior to this class: * bulletIndices(), header(), firstBullet(), secondBullet(), getImmediateCausesPtrn(); * updated body(), header(), and secondBullet(); + * Mar 13, 2013 DR 15892 D. Friedman Fix bullet parsing. * * * @@ -141,10 +142,13 @@ abstract public class AbstractLockingBehavior implements ICommonPatterns { private Integer[] bulletIndices() { List bulletIndices = new ArrayList(); - int index = text.indexOf("* "); + /* Assumes first line cannot be a bullet and that the '*' is + * at the start of a line. + */ + int index = text.indexOf("\n* "); while (index >= 0) { - bulletIndices.add(index); - index = text.indexOf("* ", index + 2); + bulletIndices.add(index + 1); + index = text.indexOf("\n* ", index + 3); } return bulletIndices.toArray(new Integer[bulletIndices.size()]); diff --git a/cave/com.raytheon.viz.warngen/src/com/raytheon/viz/warngen/text/FollowUpLockingBehavior.java b/cave/com.raytheon.viz.warngen/src/com/raytheon/viz/warngen/text/FollowUpLockingBehavior.java index a2783bc14c..029573a5b0 100644 --- a/cave/com.raytheon.viz.warngen/src/com/raytheon/viz/warngen/text/FollowUpLockingBehavior.java +++ b/cave/com.raytheon.viz.warngen/src/com/raytheon/viz/warngen/text/FollowUpLockingBehavior.java @@ -39,6 +39,8 @@ import com.raytheon.viz.warngen.gis.AffectedAreas; * ------------ ---------- ----------- -------------------------- * Sep 24, 2012 15322 jsanchez Initial creation * Jan 8, 2013 15664 Qinglu Lin Updated body(). + * Mar 13, 2013 15892 D. Friedman Fix headline locking. Do not + * lock "AND" or "FOR". * * * @@ -51,10 +53,8 @@ public class FollowUpLockingBehavior extends AbstractLockingBehavior { */ @Override public void body() { - if (action != WarningAction.COR) - headlines(); - else - super.body(); + headlines(); + super.body(); } /** @@ -66,7 +66,7 @@ public class FollowUpLockingBehavior extends AbstractLockingBehavior { // should be blank. Pattern headlinePtrn = Pattern .compile( - "^\\.\\.\\.(A|THE) (.*) (WARNING|ADVISORY) .*(REMAINS|EXPIRE|CANCELLED).*(\\.\\.\\.)$", + "^\\.\\.\\.(AN?|THE) (.*) (WARNING|ADVISORY) .*(REMAINS|EXPIRE|CANCELLED).*(\\.\\.\\.)$", Pattern.MULTILINE); Matcher m = headlinePtrn.matcher(text); @@ -187,16 +187,8 @@ public class FollowUpLockingBehavior extends AbstractLockingBehavior { + LOCK_START + "..." + LOCK_END; } // Locks warning type (i.e. SEVERE THUNDERSTORM) - headline = headline.replaceAll("(A|THE) (" + warningType + ")", - LOCK_START + "$0" + LOCK_END); - - // Locks the 'FOR' in the headline - headline = headline.replaceFirst(" FOR ", " " + LOCK_START + "FOR" - + LOCK_END + " "); - - // Locks the 'AND' in the headline - headline = headline.replaceFirst(" AND ", " " + LOCK_START + "AND" - + LOCK_END + " "); + headline = headline.replaceAll("(AN?|THE)( [\\w\\s]*?)(" + warningType + ")", + LOCK_START + "$1" + LOCK_END + "$2" + LOCK_START + "$3" + LOCK_END); return headline; } diff --git a/cave/com.raytheon.viz.warngen/src/com/raytheon/viz/warngen/text/ICommonPatterns.java b/cave/com.raytheon.viz.warngen/src/com/raytheon/viz/warngen/text/ICommonPatterns.java index 233810cd35..ff694fcd7d 100644 --- a/cave/com.raytheon.viz.warngen/src/com/raytheon/viz/warngen/text/ICommonPatterns.java +++ b/cave/com.raytheon.viz.warngen/src/com/raytheon/viz/warngen/text/ICommonPatterns.java @@ -32,6 +32,7 @@ import java.util.regex.Pattern; * ------------ ---------- ----------- -------------------------- * Sep 24, 2012 15332 jsanchez Initial creation * Oct 18, 2012 15332 jsanchez Replaced listOfAreaNamesPtrn with String pattern. + * Mar 13, 2013 DR 15892 D. Friedman Allow some punctuation in area names. * * * @@ -55,7 +56,7 @@ public interface ICommonPatterns { // LOCK_END can be added at the start of the line if a previous line has // been locked. public static final String listOfAreaName = "^((" + LOCK_END - + "){0,1}(((\\w+\\s{1})+\\w{2}-)*((\\w+\\s{1})+\\w{2}-)))"; + + "){0,1}((([\\w\\./'-]+\\s{1})+\\w{2}-)*(([\\w\\./'-]+\\s{1})+\\w{2}-)))"; // LOCK_END should not be found at the beginning of a first bullet since the // previous line should be blank. diff --git a/cave/com.raytheon.viz.warngen/src/com/raytheon/viz/warngen/util/FipsUtil.java b/cave/com.raytheon.viz.warngen/src/com/raytheon/viz/warngen/util/FipsUtil.java index 9f608b8cfa..520034ecf9 100644 --- a/cave/com.raytheon.viz.warngen/src/com/raytheon/viz/warngen/util/FipsUtil.java +++ b/cave/com.raytheon.viz.warngen/src/com/raytheon/viz/warngen/util/FipsUtil.java @@ -340,7 +340,7 @@ public class FipsUtil { * @param fips * @return */ - private static ArrayList getListCounties(String fips) { + public static ArrayList getListCounties(String fips) { ArrayList rval = new ArrayList(); String matchStr = ""; diff --git a/cave/com.raytheon.viz.warngen/src/com/raytheon/viz/warngen/util/FollowUpUtil.java b/cave/com.raytheon.viz.warngen/src/com/raytheon/viz/warngen/util/FollowUpUtil.java index 600c60c2de..e1e9949106 100644 --- a/cave/com.raytheon.viz.warngen/src/com/raytheon/viz/warngen/util/FollowUpUtil.java +++ b/cave/com.raytheon.viz.warngen/src/com/raytheon/viz/warngen/util/FollowUpUtil.java @@ -28,6 +28,7 @@ import com.raytheon.viz.warngen.text.ICommonPatterns; * ------------ ---------- ----------- -------------------------- * Jul 22, 2008 #1284 bwoodle Initial creation * Oct 18, 2012 15332 jsanchez Fixed refactor bugs. + * Mar 13, 2013 DR 15892 D. Friedman Handle SMW format in canceledAreasFromText * * * @@ -43,6 +44,8 @@ public class FollowUpUtil { public static final Pattern vtecPtrn = Pattern .compile("/[OTEX]\\.([A-Z]{3})\\.[A-Za-z0-9]{4}\\.[A-Z]{2}\\.[WAYSFON]\\.\\d{4}\\.\\d{6}T\\d{4}Z-\\d{6}T\\d{4}Z/"); + private static final String SMW_CANCELED_AREAS_HEADER = "THE AFFECTED AREAS WERE..."; + /** * This method checks whether a particular followup should be available * given a Warning Record, a vtec Action, and a template configuration @@ -173,7 +176,8 @@ public class FollowUpUtil { String headline = ""; Pattern listOfAreaNamePtrn = Pattern .compile(ICommonPatterns.listOfAreaName); - for (String line : originalText.trim().split("\n")) { + String[] splitLines = originalText.trim().split("\n"); + for (String line : splitLines) { if (line.contains("TEST") || line.trim().length() == 0) { continue; } @@ -198,8 +202,15 @@ public class FollowUpUtil { headline += line; } } - String[] ugcs = ugcLine.split("-"); - String[] names = namesLine.split("-"); + String[] ugcs = FipsUtil.getListCounties(ugcLine).toArray(new String[0]); + String[] names; + boolean smwAreas = false; + if (namesLine.length() > 0) + names = namesLine.split("-"); + else { + names = parseSMWCanceledAreas(splitLines); + smwAreas = true; + } String[] areas = headline.split("\\.\\.\\."); ArrayList al = new ArrayList(); @@ -222,13 +233,21 @@ public class FollowUpUtil { areasNotation = "COUNTIES"; } } + + if (ugc.length() < 3) + continue; // TODO: log? fips = ugc.substring(ugc.length() - 3); if (i < names.length) { - name = names[i].substring(0, names[i].length() - 3); - stateAbbreviation = names[i].substring(names[i].length() - 2); - } + if (!smwAreas && names[i].length() >= 3) { + name = names[i].substring(0, names[i].length() - 3); + stateAbbreviation = names[i].substring(names[i].length() - 2); + } else { + name = names[i]; + } + } else + break; if (name != null) { for (String area : areas) { @@ -334,4 +353,32 @@ public class FollowUpUtil { return rval; } + + /** Parses the canceled areas of an SMW, which have a different format + * from other products. + */ + private static String[] parseSMWCanceledAreas(String[] splitLines) { + StringBuilder text = new StringBuilder(64); + boolean inAreas = false; + for (String line : splitLines) { + String trimmedLine = line.trim(); + if (SMW_CANCELED_AREAS_HEADER.equals(trimmedLine)) + inAreas = true; + else if (inAreas) { + if (trimmedLine.length() > 0) { + text.append(trimmedLine); + text.append('\n'); + } else + break; + } + } + int len = text.length(); + if (len >= 4 && "...\n".equals(text.substring(len - 4))) + text.delete(len - 4, len); + String[] areas = text.toString().split("\\.\\.\\.\\n"); + // Unwrap lines. + for (int i = 0; i < areas.length; ++i) + areas[i] = areas[i].replace("\n", " "); + return areas; + } } diff --git a/edexOsgi/build.edex/esb/data/utility/common_static/base/warngen/VM_global_library.vm b/edexOsgi/build.edex/esb/data/utility/common_static/base/warngen/VM_global_library.vm index 1ada94dece..1a2cc5eb84 100644 --- a/edexOsgi/build.edex/esb/data/utility/common_static/base/warngen/VM_global_library.vm +++ b/edexOsgi/build.edex/esb/data/utility/common_static/base/warngen/VM_global_library.vm @@ -5,6 +5,7 @@ ##### Qinglu Lin 08-13-2012 DR 14493. Use corToNewMarker and corEventtime. ##### D. Friedman 11-09-2012 DR 15430. Rework included watches. ##### QINGLU LIN 12-27-2012 DR 15594. Added $lock to headlineLocList. +##### D. Friedman 03-13-2013 DR 15892. Do not lock portion of state in firstBullet. #################################################################################################### Mile Marker Test Code macro "mmarkers" use (called out of VM_global_library.vm): @@ -750,7 +751,7 @@ THE ${area.name}## #if(${intFIPS.parseInt($FIPS)} < 500 || ${area.stateabbr} == "TX") ${area.name} ${area.areaNotation} IN #areaFormat(${area.partOfParentRegion} true false) ${area.parentRegion}... #else -${area.name} IN #areaFormat(${area.partOfParentRegion} true false) ${area.parentRegion}... +${area.name} IN #areaFormat(${area.partOfParentRegion} true false) ${area.parentRegion}... #end #end ## COMMENTED OUT 5 LINES BELOW THIS IS GENERALLY NOT UTILIZED - you can unREMARK if desired 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 f50dd40412..58862f7b0d 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 @@ -4,6 +4,7 @@ ## Evan Bookbinder 4-25-2012 for OB 12.3.1 (corText) ## QINGLU LIN 7-31-2012 DR 15217 use roundAndPad ## Qinglu Lin 12-27-2012 DR 15594. Appended true to headlineLocList's parameter list. +## D. Friedman 03-13-2013 DR 15892. Use printcoords. ################################################ ## ### CREATE PHRASING DEPENDING ON WHETHER WE ISSUE EXP PRIOR TO EXPIRATION TIME OR NOT @@ -482,10 +483,7 @@ THIS IS A TEST MESSAGE.## THIS IS A TEST MESSAGE. DO NOT TAKE ACTION BASED ON THIS MESSAGE. #end -LAT...LON ## -#foreach(${coord} in ${areaPoly}) -#llFormat(${coord.y}) #llFormat(${coord.x}) ## -#end +#printcoords(${areaPoly}, ${list}) TIME...MOT...LOC ## ${dateUtil.format(${event}, ${timeFormat.time})}Z ## 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 bfab17d4a0..afb5392f3f 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 @@ -8,6 +8,7 @@ ## Evan Bookbinder 4-25-2012 for OB 12.3.1 (MND) ## QINGLU LIN 7-31-2012 DR 15217 use roundAndPad ## ## Qinglu Lin 12-27-2012 DR 15594. Appended true to headlineLocList's parameter list. +## D. Friemdan 13-03-2013 DR 15892. Do not lock locations in headline. ###################################################### ## ##SET SOME INITIAL VARIABLES @@ -120,7 +121,7 @@ THIS IS A TEST MESSAGE. ## #end #if(${windSpeed} >= 40 || ${hailSize} >= 0.70) ...SIGNIFICANT WEATHER ADVISORY FOR ## -#headlineLocList(${areas} true false true false true) #secondBullet(${dateUtil},${expire},${timeFormat},${localtimezone},${secondtimezone}) +#headlineLocList(${areas} true false true false false) #secondBullet(${dateUtil},${expire},${timeFormat},${localtimezone},${secondtimezone}) ...## #elseif(${windSpeed} == 0 && ${hailSize} == 0) !** YOU DID NOT SELECT ANY WIND OR HAIL THREATS. PLEASE RE-GENERATE THIS ADVISORY **!