ASM #123 Zone UGC line not locked
Change-Id: I5eb7ed0bee68599fe4ece0810fe76cb5c794d29c Former-commit-id:b51bdd9107
[formerlye489658072
] [formerlyb51bdd9107
[formerlye489658072
] [formerly13c81f9468
[formerly 108895dccefb42c71d0f47b13bfd64591e8dca98]]] Former-commit-id:13c81f9468
Former-commit-id:895a652b4c
[formerlycaf57dbabe
] Former-commit-id:1bdf714eba
This commit is contained in:
parent
1aec51b7c4
commit
f8c13f1d3b
2 changed files with 68 additions and 5 deletions
|
@ -54,6 +54,7 @@ import com.raytheon.viz.warngen.gis.AffectedAreas;
|
|||
* bulletIndices(), header(), firstBullet(), secondBullet(), getImmediateCausesPtrn();
|
||||
* updated body(), header(), and secondBullet();
|
||||
* Mar 13, 2013 DR 15892 D. Friedman Fix bullet parsing.
|
||||
* May 1, 2014 DR 16627 Qinglu Lin Added hasStateAbbrev(), isOtherType(), lockListOfNames(), and updated lock().
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -115,7 +116,11 @@ abstract public class AbstractLockingBehavior implements ICommonPatterns {
|
|||
ugc();
|
||||
htec();
|
||||
vtec();
|
||||
areaNames();
|
||||
if (isDesiredPil() && !hasStateAbbrev()) {
|
||||
lockListOfNames();
|
||||
} else {
|
||||
areaNames();
|
||||
}
|
||||
mnd();
|
||||
date();
|
||||
body();
|
||||
|
@ -129,9 +134,9 @@ abstract public class AbstractLockingBehavior implements ICommonPatterns {
|
|||
}
|
||||
|
||||
protected void body() {
|
||||
header();
|
||||
firstBullet();
|
||||
secondBullet();
|
||||
header();
|
||||
firstBullet();
|
||||
secondBullet();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -534,4 +539,61 @@ abstract public class AbstractLockingBehavior implements ICommonPatterns {
|
|||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check out if warning text has state abbreviations, e.g., " MD".
|
||||
*/
|
||||
private boolean hasStateAbbrev() {
|
||||
Pattern stateAbbrevPtrn = Pattern.compile(listOfAreaName + newline,
|
||||
Pattern.MULTILINE);
|
||||
Matcher m = stateAbbrevPtrn.matcher(this.text);
|
||||
if (m.find()) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check out if pil of the product is SPS or NOW.
|
||||
*/
|
||||
public boolean isDesiredPil() {
|
||||
String[] type = {"SPS", "NOW"};
|
||||
int index = text.indexOf("000000") + 8;
|
||||
String pilAndCWA = text.substring(index, index + 6);
|
||||
for (String s: type) {
|
||||
if (pilAndCWA.contains(s)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Locks the list of area names in which state abbreviations, e.g., " MD",
|
||||
* are not included.
|
||||
*/
|
||||
private void lockListOfNames() {
|
||||
String[] timePattern = {" AM ", " PM ", "NOON", "MIDNIGHT"};
|
||||
String text1 = "";
|
||||
int indexOfDash = text.indexOf('-');
|
||||
String text2 = text.substring(indexOfDash, text.length() - 1);
|
||||
int indexOfTimePattern;
|
||||
for (String s: timePattern) {
|
||||
indexOfTimePattern = text2.indexOf(s);
|
||||
if (indexOfTimePattern != -1) {
|
||||
text1 = text2.substring(0, indexOfTimePattern);
|
||||
break;
|
||||
}
|
||||
}
|
||||
int index1, index2;
|
||||
if (text1.length() > 0) {
|
||||
index1 = text1.indexOf("</L>");
|
||||
index2 = text1.lastIndexOf("-");
|
||||
text2 = text1.substring(index1 + 4, index2 + 1);
|
||||
index1 = text.indexOf(text2);
|
||||
text = text.substring(0, index1) + "<L>" + text2 + "</L>"
|
||||
+ text.substring(index1 + text2.length(), text.length() - 1);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -38,6 +38,7 @@ import java.util.regex.Pattern;
|
|||
* is dropped, a name has more than one word, two names are separated by slash (/),
|
||||
* or a name has an apostrophe (') for Significant Weather Advisory, Special Weather
|
||||
* Statement, and Short Term Forecast.
|
||||
* May 1, 2014 DR 16627 Qinglu Lin Roll back the changes to listOfAreaName on January 6, 2014.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -61,7 +62,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}){0,1}(\\s{1,}\\w{1,}([\\/\\']\\w{0,}\\s{0,}\\w{0,}){0,}){0,}-)*))";
|
||||
+ "){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.
|
||||
|
|
Loading…
Add table
Reference in a new issue