ASM #15551 - WarnGen: only WCN should be used while including TOR/SVR watches in WarnGen products

Change-Id: I286bc4cc809fcc9257f72051f1bb74f8acc24c05

Former-commit-id: b32ea40289 [formerly 2374673f8d] [formerly b32ea40289 [formerly 2374673f8d] [formerly ae13ea419e [formerly 59890eef397f3282ef26f259ca85ffea3db7b710]]]
Former-commit-id: ae13ea419e
Former-commit-id: 3fcdc279ea [formerly 075df9d234]
Former-commit-id: 415af39911
This commit is contained in:
Qinglu.Lin 2014-09-02 14:33:11 -04:00
parent 95f1799dc6
commit 7ec0ec8877
3 changed files with 108 additions and 63 deletions

View file

@ -76,6 +76,7 @@ import com.vividsolutions.jts.geom.Polygon;
* Jul 17, 2014 3419 jsanchez Initial creation * Jul 17, 2014 3419 jsanchez Initial creation
* Aug 20, 2014 ASM #16703 D. Friedman Ensure watches have a state attribute. * Aug 20, 2014 ASM #16703 D. Friedman Ensure watches have a state attribute.
* Aug 28, 2014 ASM #15658 D. Friedman Add marine zones. * Aug 28, 2014 ASM #15658 D. Friedman Add marine zones.
* Aug 29, 2014 ASM #15551 Qinglu Lin Sorting watches by ETN in processRecords().
* *
* </pre> * </pre>
* *
@ -409,6 +410,8 @@ public class WatchUtil {
watches.add(watch); watches.add(watch);
} }
// keep the code for their use in the future
/*
// Sorts the watches based on state name. // Sorts the watches based on state name.
Collections.sort(watches, new Comparator<Watch>() { Collections.sort(watches, new Comparator<Watch>() {
@ -426,6 +429,25 @@ public class WatchUtil {
return state1.compareTo(state2); return state1.compareTo(state2);
} }
}); });
*/
// Sorts the watches based on ETN.
Collections.sort(watches, new Comparator<Watch>() {
@Override
public int compare(Watch watch1, Watch watch2) {
String etn1 = watch1.getEtn();
String etn2 = watch2.getEtn();
if (etn1 == etn2)
return 0;
else if (etn1 == null)
return 1;
else if (etn2 == null)
return -1;
else
return etn1.compareTo(etn2);
}
});
return watches; return watches;
} }

View file

@ -141,6 +141,8 @@ import com.vividsolutions.jts.io.WKTReader;
* added determineAffectedMarinePortions(). * added determineAffectedMarinePortions().
* Jul 21, 2014 3419 jsanchez Refactored WatchUtil. * Jul 21, 2014 3419 jsanchez Refactored WatchUtil.
* Aug 15, 2014 DR15701 mgamazaychikov Removed static field watchUtil. * Aug 15, 2014 DR15701 mgamazaychikov Removed static field watchUtil.
* Aug 28, 2014 ASM #15551 Qinglu Lin Replaced 1200 PM/1200 AM by NOON/MIDNIGHT, removed days in
* included tornado/severe thunderstorm watch message.
* </pre> * </pre>
* *
* @author njensen * @author njensen
@ -872,7 +874,37 @@ public class TemplateRunner {
System.out.println("velocity time: " System.out.println("velocity time: "
+ (System.currentTimeMillis() - tz0)); + (System.currentTimeMillis() - tz0));
String text = script.toString(); String watches[] = {"TORNADO WATCH", "SEVERE THUNDERSTORM WATCH"};
int index1 = -1, index2 = -1, index1ToUse = -1;
String doubleDollar = "$$";
boolean firstTime = true;
for (String s: watches) {
index1 = script.indexOf(s, 0);
if (index1 > 0) {
index2 = script.indexOf(doubleDollar, index1);
}
if (firstTime && index1 > -1) {
index1ToUse = index1;
firstTime = false;
}
}
String days[] = {"SUNDAY", "MONDAY", "TUESDAY", "WEDNESDAY", "THURSDAY", "FRIDAY", "SATURDAY"};
String substring = "", text;
if (index1ToUse > -1 && index2 > -1) {
substring = script.substring(index1ToUse, index2).toUpperCase();
// remove day
for (String day: days) {
substring = substring.replaceAll(day + " ", "");
}
// replace 1200 PM/1200 AM with NOON/MIDNIGHT
substring = substring.replaceAll("1200 PM", "NOON");
substring = substring.replaceAll("1200 AM", "MIDNIGHT");
// concatenate strings
text = script.substring(0, index1ToUse - 1);
text = text + " " + substring + script.substring(index2, script.length());
} else {
text = script.toString();
}
WarningTextHandler handler = WarningTextHandlerFactory.getHandler( WarningTextHandler handler = WarningTextHandlerFactory.getHandler(
selectedAction, text, config.getAutoLockText()); selectedAction, text, config.getAutoLockText());
String handledText = handler.handle(text, areas, cancelareas, String handledText = handler.handle(text, areas, cancelareas,

View file

@ -13,6 +13,7 @@
##### Qinglu Lin 03-17-2014 DR 16309. Updated inserttorwatches and insertsvrwatches. ##### Qinglu Lin 03-17-2014 DR 16309. Updated inserttorwatches and insertsvrwatches.
##### Qinglu Lin 05-21-2014 DR 16309. Updated inserttorwatches and insertsvrwatches by changing 'FOR##' to 'FOR ##'. ##### Qinglu Lin 05-21-2014 DR 16309. Updated inserttorwatches and insertsvrwatches by changing 'FOR##' to 'FOR ##'.
##### D. Friedman 08-28-2014 ASM #15658. Add marine watch wording. ##### D. Friedman 08-28-2014 ASM #15658. Add marine watch wording.
##### Qinglu Lin 08-29-2014 ASM #15551. Overhauled inserttorwatches and insertsvrwatches.
#################################################################################################### ####################################################################################################
#* #*
Mile Marker Test Code Mile Marker Test Code
@ -190,102 +191,92 @@ ${drainage.name}##
########END MACRO ########END MACRO
#macro(inserttorwatches $watches $list $secondtimezone $dateUtil $timeFormat) #macro(inserttorwatches $watches $list $secondtimezone $dateUtil $timeFormat)
#set($keys = []) #set($tornadoWatches = [])
#set($mymap = {}) #set($ALSO = "")
#foreach(${watch} in ${watches}) #foreach(${watch} in ${watches})
#if(${watch.getPhenSig()} == 'TO.A') #if(${watch.getPhenSig()} == 'TO.A')
#set($key = ${watch.action} + ${watch.etn} + ${watch.startTime} + ${watch.endTime}) #set($success = $tornadoWatches.add($watch))
#if (${list.contains(${keys}, $key)}) #end
#set($value = ${mymap.get($key)}) #end
#set($lastEtn = "")
#set($lastEndTime = "")
#foreach(${watch} in ${tornadoWatches})
#if($lastEtn != "" && ${watch.etn} != ${lastEtn})
. ##
#end
#set($endTime = ${watch.endTime})
#if(${watch.etn} == ${lastEtn})
#if(${endTime} == ${lastEndTime})
...##
#else #else
#set($value = []) ...UNTIL ${dateUtil.format(${endTime}, ${timeFormat.plain}, 15, ${localtimezone})} FOR ##
#set($success = $keys.add($key))
#end #end
#set($success = $value.add($watch)) #else
#set($success = ${mymap.put($key,$value)}) A TORNADO WATCH${ALSO} REMAINS IN EFFECT UNTIL ${dateUtil.format(${endTime}, ${timeFormat.plain}, 15, ${localtimezone})} FOR ##
#set($ALSO = " ALSO")
#end #end
#end
#set($torWatchAlso = "")
#foreach(${key} in ${keys})
#set($tornadoWatches = ${mymap.get($key)})
#set($tornadoWatch = ${tornadoWatches.get(0)})
A TORNADO WATCH ${torWatchAlso}REMAINS IN EFFECT UNTIL ${dateUtil.format(${tornadoWatch.endTime}, ${timeFormat.plain}, 15, ${localtimezone})}##
${dateUtil.period(${tornadoWatch.endTime},${timeFormat.plain}, 15, ${localtimezone})}##
#if(${secondtimezone}) #if(${secondtimezone})
/${dateUtil.format(${watch.getEndTime()}, ${timeFormat.plain}, 15, ${secondtimezone})}/## /${dateUtil.format(${watch.getEndTime()}, ${timeFormat.plain}, 15, ${secondtimezone})}/##
#end #end
FOR ##
#set($numPortions = ${list.size(${tornadoWatches})})
#set($count = 0)
#foreach(${watch} in ${tornadoWatches})
#set($count = $count + 1)
#if(!${watch.marineAreas}) #if(!${watch.marineAreas})
#areaFormat(${watch.partOfState} true false true)${watch.state}## #areaFormat(${watch.partOfState} true false true)${watch.state}##
#else #else
#formatMarineAreas(${watch.marineAreas}) #formatMarineAreas(${watch.marineAreas})
#end #end
#if($count == $numPortions - 1) #set($lastEtn = ${watch.etn})
AND ## #set($lastEndTime = ${watch.endTime})
#elseif($count < $numPortions)
...##
#end #end
#if(${lastEtn} != "")
.
#end #end
#set($torWatchAlso = "ALSO ")
. ##
#end
#end #end
########END MACRO ########END MACRO
#macro(insertsvrwatches $watches $list $secondtimezone $dateUtil $timeFormat) #macro(insertsvrwatches $watches $list $secondtimezone $dateUtil $timeFormat)
#set($keys = []) #set($svrWatches = [])
#set($mymap = {}) #set($ALSO = "")
#foreach(${watch} in ${watches}) #foreach(${watch} in ${watches})
#if(${watch.getPhenSig()} == 'SV.A') #if(${watch.getPhenSig()} == 'SV.A')
#set($key = ${watch.action} + ${watch.etn} + ${watch.startTime} + ${watch.endTime}) #set($success = $svrWatches.add($watch))
#if (${list.contains(${keys}, $key)}) #end
#set($value = ${mymap.get($key)}) #end
#set($lastEtn = "")
#set($lastEndTime = "")
#foreach(${watch} in ${svrWatches})
#if($lastEtn != "" && ${watch.etn} != ${lastEtn})
. ##
#end
#set($endTime = ${watch.endTime})
#if(${watch.etn} == ${lastEtn})
#if(${endTime} == ${lastEndTime})
...##
#else #else
#set($value = []) ...UNTIL ${dateUtil.format(${endTime}, ${timeFormat.plain}, 15, ${localtimezone})} FOR ##
#set($success = $keys.add($key))
#end #end
#set($success = $value.add($watch)) #else
#set($success = ${mymap.put($key,$value)}) A SEVERE THUNDERSTORM WATCH${ALSO} REMAINS IN EFFECT UNTIL ${dateUtil.format(${endTime}, ${timeFormat.plain}, 15, ${localtimezone})} FOR ##
#set($ALSO = " ALSO")
#end #end
#end
#set($svrWatchAlso = "")
#foreach(${key} in ${keys})
#set($severeWatches = ${mymap.get($key)})
#set($svrWatch = ${severeWatches.get(0)})
A SEVERE THUNDERSTORM WATCH ${svrWatchAlso}REMAINS IN EFFECT UNTIL ${dateUtil.format(${svrWatch.endTime}, ${timeFormat.plain}, 15, ${localtimezone})}##
${dateUtil.period(${svrWatch.endTime},${timeFormat.plain}, 15, ${localtimezone})}##
#if(${secondtimezone}) #if(${secondtimezone})
/${dateUtil.format(${watch.getEndTime()}, ${timeFormat.plain}, 15, ${secondtimezone})}/## /${dateUtil.format(${watch.getEndTime()}, ${timeFormat.plain}, 15, ${secondtimezone})}/##
#end #end
FOR ##
#set($numPortions = ${list.size(${severeWatches})})
#set($count = 0)
#foreach(${watch} in ${severeWatches})
#set($count = $count + 1)
#if(!${watch.marineAreas}) #if(!${watch.marineAreas})
#areaFormat(${watch.partOfState} true false true)${watch.state}## #areaFormat(${watch.partOfState} true false true)${watch.state}##
#else #else
#formatMarineAreas(${watch.marineAreas}) #formatMarineAreas(${watch.marineAreas})
#end #end
#if($count == $numPortions - 1) #set($lastEtn = ${watch.etn})
AND ## #set($lastEndTime = ${watch.endTime})
#elseif($count < $numPortions) #end
...## #if(${lastEtn} != "")
.
#end #end
#end #end
#set($svrWatchAlso = "ALSO ") ########END MACRO
. ##
#end
#end
########END
#macro(formatMarineAreas $marineAreas) #macro(formatMarineAreas $marineAreas)
#set($macount = 0) #set($macount = 0)