VLab Issue #4637 - Fix NCP AWW display issues

Change-Id: I7df6d95cd665805046a807d0900ee934da61c18e

Former-commit-id: 79957a312a [formerly f31a665a587f7fa324afcfcc332eceb1518c96d6]
Former-commit-id: 2d3c8c0413
This commit is contained in:
Stephen Gilbert 2014-09-18 14:12:12 -04:00
parent 11b29f54b5
commit 4818e4f5c1
5 changed files with 881 additions and 303 deletions

View file

@ -56,10 +56,11 @@ import com.raytheon.uf.edex.decodertools.core.IDecoderConstants;
* 1. if AwwParser.processWMO failed, simply
* drop the record by throwing an exception
* 2. comment out the end check "if(record == null")
* because it is a dead code.
* because it is a dead code. [DS- removed 8/14]
* Aug 08, 2013 1028 G. Hull rm underscores from reportType and set mndTime in URI
* Aug 30, 2013 2298 rjpeter Make getPluginName abstract
* Mar 21, 2103 1112 S. Russell *.WCN files, get the watch number
* Aug 13, 2014 (none?) D. Sushon refactor to be sure all bulletins get decoded, removed some dead code, marked possibly dead code as such
* </pre>
*
* This code has been developed by the SIB for use in the AWIPS2 system.
@ -79,7 +80,10 @@ public class AwwDecoder extends AbstractDecoder {
public AwwDecoder() throws DecoderException {
}
public PluginDataObject[] decode(byte[] data, Headers headers) throws DecoderException {
public PluginDataObject[] decode(byte[] data, Headers headers)
throws DecoderException {
List<PluginDataObject> outPdo = new ArrayList<PluginDataObject>();
String traceId = "";
if (headers != null) {
@ -108,202 +112,235 @@ public class AwwDecoder extends AbstractDecoder {
messageData = sep.next();
String theMessage = new String(messageData);
/* May have multiple duplicate bulletins, only get the first bulletin
* and eliminate the remaining bulletins after the first bulletin. */
Scanner cc = new Scanner(theMessage).useDelimiter(etx);
if (cc.hasNext()) {
theBulletin = cc.next();
} else {
// System.out.println("setting.... theBulletin = theMessage;");
theBulletin = theMessage;
}
// Set MND (Mass News Disseminator) time string and convert it into
// Calendar object
MndTime mt = new MndTime(theBulletin.getBytes());
mndTime = mt.getMndTime();
do {
// Decode and set WMO line
AwwRecord record = AwwParser.processWMO(theBulletin, mndTime);
if (record == null) {
throw new AwwDecoderException("Error on decoding Aww Record");
}
// Set MND (Mass News Disseminator) time string and convert it into
// Calendar object
MndTime mt = new MndTime(theBulletin.getBytes());
mndTime = mt.getMndTime();
boolean isWtchFlag = AwwDecoder.isWtch(record);// Ticket 456
// boolean isSevereWeatherStatusFlag =
// AwwDecoder.isSevereWeatherStatus(record);
// Get report type
String reportType = AwwParser.getReportType(theBulletin);
ArrayList<String> segmentList = new ArrayList<String>();
segmentList.clear();
// Break the bulletin message into segments by a "$$"
Scanner sc = new Scanner(theBulletin).useDelimiter(segmentDelim);
boolean isWCN = false;
String wcnLbl = AwwRecord.AwwReportType.WATCH_COUNTY_NOTIFICATION.name();
wcnLbl = wcnLbl.replace("_", " ");
if (reportType.equals(wcnLbl)) {
isWCN = true;
}
while (sc.hasNext()) {
String segment = sc.next();
Matcher ugcMatcher = ugcPattern.matcher(segment);
// discard if the segment did not have an UGC line.
if (ugcMatcher.find() || isWtchFlag) { // ????? not sure if this
// logic is correct
segmentList.add(segment);
// Decode and set WMO line
AwwRecord record = AwwParser.processWMO(theBulletin, mndTime);
if (record == null) {
throw new AwwDecoderException("Error on decoding Aww Record");
}
}
if (record != null) {
try {
// process each segment in a order of UGC, VTEC, H-VTEC, FIPS,
// LATLON...
for (String segment : segmentList) {
Matcher ugcMatcher = ugcPattern.matcher(segment);
AwwUgc ugc = null;
boolean isWtchFlag = AwwDecoder.isWtch(record);// Ticket 456
// TRAC 1112
if (isWCN) {
String watchNumber = AwwParser.retrieveWatchNumberFromWCN(segment);
if (watchNumber != null) {
record.setWatchNumber(watchNumber);
if (ugcMatcher.find()) {
ugc = AwwParser.processUgc(ugcMatcher.group(), segment, mndTime, watchesList);
// boolean isSevereWeatherStatusFlag =
// AwwDecoder.isSevereWeatherStatus(record); //dead code?
// Get report type
String reportType = AwwParser.getReportType(theBulletin);
ArrayList<String> segmentList = new ArrayList<String>();
segmentList.clear();
// Break the bulletin message into segments by a "$$"
Scanner sc = new Scanner(theBulletin).useDelimiter(segmentDelim);
boolean isWCN = false;
String wcnLbl = AwwRecord.AwwReportType.WATCH_COUNTY_NOTIFICATION
.name();
wcnLbl = wcnLbl.replace("_", " ");
if (reportType.equals(wcnLbl)) {
isWCN = true;
}
while (sc.hasNext()) {
String segment = sc.next();
Matcher ugcMatcher = ugcPattern.matcher(segment);
// discard if the segment did not have an UGC line.
if (ugcMatcher.find() || isWtchFlag) { // ????? not sure if this
// logic is correct
segmentList.add(segment);
}
}
if (record != null) {
try {
// process each segment in a order of UGC, VTEC, H-VTEC,
// FIPS, LATLON...
for (String segment : segmentList) {
Matcher ugcMatcher = ugcPattern.matcher(segment);
AwwUgc ugc = null;
// TRAC 1112
if (isWCN) {
String watchNumber = AwwParser
.retrieveWatchNumberFromWCN(segment);
if (watchNumber != null) {
record.setWatchNumber(watchNumber);
if (ugcMatcher.find()) {
ugc = AwwParser.processUgc(
ugcMatcher.group(), segment,
mndTime, watchesList);
}
}
}
}
// local forecast
else if (isWtchFlag) {
ugc = AwwParser.processUgcForWtch(AwwParser.WTCH_BOX_UGC_LINE, segment, mndTime, record.getIssueOffice(), watchesList);
// else if(isSevereWeatherStatusFlag)
// ugc =
// AwwParser.processUgcForSereveWeatherStatus(ugcMatcher.group(),
// segment, mndTime, record.getIssueOffice(),
// watchesList);
String watchNumber = AwwParser.processUgcToRetrieveWatchNumberForThunderstormOrTornado(segment);
record.setWatchNumber(watchNumber);
// } else if(isSevereWeatherStatusFlag) {
// String watchNumber =
// AwwParser.processUgcToRetrieveWatchNumberForStatusReport(segment);
// record.setWatchNumber(watchNumber);
} else if (ugcMatcher.find()) {
ugc = AwwParser.processUgc(ugcMatcher.group(), segment, mndTime, watchesList);
}
if (ugc != null) {
record.addAwwUGC(ugc);
/* Collect watch numbers which are the event tracking
* numbers in VTEC lines as one of primary keys in AWW
* record to prevent not writing raw data to DB note: 1.
* each bulletin may have multiple segments 2. each
* segment has one UGC line but may have multiple VTEC
* lines and have more than one watch number */
/* not quite sure the following logic is correct to
* retrieve and then store the watch number. thus
* comment it out now. M. Gao */
// if (watchesList.size() > 0) {
// String collectWatches = null;
// for (int idxWatch = 0; idxWatch < watchesList.size();
// idxWatch++) {
//
// if (idxWatch == 0) {
// collectWatches = watchesList.get(idxWatch);
// } else {
// collectWatches = collectWatches.concat("/")
// .concat(watchesList.get(idxWatch));
// }
// }
// // System.out.println("==collection length=" +
// // collectWatches.length() );
// record.setWatchNumber(collectWatches);
// } else {
//
// // The special reports may not have VTEC line; given
// // a default watch number "0000".
// record.setWatchNumber("0000");
// }
/* construct VTEC object and then add it to the current
* Ugc for SevereWeatherStatus aww reocrd */
if (AwwParser.isSegmentTextValid(segment)) {
/* parse and then set the Watch Number for Status
* Report */
String watchNumber = AwwParser.processUgcToRetrieveWatchNumberForStatusReport(segment);
// local forecast
else if (isWtchFlag) {
ugc = AwwParser.processUgcForWtch(
AwwParser.WTCH_BOX_UGC_LINE, segment,
mndTime, record.getIssueOffice(),
watchesList);
// else if(isSevereWeatherStatusFlag) ---dead code?
// ugc =
// AwwParser.processUgcForSereveWeatherStatus(ugcMatcher.group(),
// segment, mndTime, record.getIssueOffice(),
// watchesList);
String watchNumber = AwwParser
.processUgcToRetrieveWatchNumberForThunderstormOrTornado(segment);
record.setWatchNumber(watchNumber);
AwwVtec awwVtec = AwwParser.processVtectForSevereWeatherStatus(theBulletin, record.getIssueTime(), record.getIssueOffice());
Set<AwwVtec> awwVtecSet = new HashSet<AwwVtec>();
awwVtecSet.add(awwVtec);
ugc.setAwwVtecLine(awwVtecSet);
/* now calculate status latlon info and then add to
* ugc */
List<AwwLatlons> pointAwwLatLonsList = AwwLatLonUtil.getAwwLatLonsListBySereveWeatherStatusPointLine(awwVtec.getVtecLine());
for (AwwLatlons eachAwwLatlons : pointAwwLatLonsList) {
ugc.addAwwLatLon(eachAwwLatlons);
}
// } else if(isSevereWeatherStatusFlag) { dead code?
// String watchNumber =
// AwwParser.processUgcToRetrieveWatchNumberForStatusReport(segment);
// record.setWatchNumber(watchNumber);
} else if (ugcMatcher.find()) {
ugc = AwwParser.processUgc(ugcMatcher.group(),
segment, mndTime, watchesList);
}
if (ugc != null) {
record.addAwwUGC(ugc);
/*
* Collect watch numbers which are the event
* tracking numbers in VTEC lines as one of primary
* keys in AWW record to prevent not writing raw
* data to DB note: 1. each bulletin may have
* multiple segments 2. each segment has one UGC
* line but may have multiple VTEC lines and have
* more than one watch number
*/
/*
* not quite sure the following logic is correct to
* retrieve and then store the watch number. thus
* comment it out now. M. Gao
*/
// if (watchesList.size() > 0) {
// String collectWatches = null;
// for (int idxWatch = 0; idxWatch <
// watchesList.size();
// idxWatch++) {
//
// if (idxWatch == 0) {
// collectWatches = watchesList.get(idxWatch);
// } else {
// collectWatches = collectWatches.concat("/")
// .concat(watchesList.get(idxWatch));
// }
// }
// // System.out.println("==collection length=" +
// // collectWatches.length() );
// record.setWatchNumber(collectWatches);
// } else {
//
// // The special reports may not have VTEC line;
// // given a default watch number "0000".
// record.setWatchNumber("0000");
// }
/*
* construct VTEC object and then add it to the
* current Ugc for SevereWeatherStatus aww reocrd
*/
if (AwwParser.isSegmentTextValid(segment)) {
/*
* parse and then set the Watch Number for
* Status Report
*/
String watchNumber = AwwParser
.processUgcToRetrieveWatchNumberForStatusReport(segment);
record.setWatchNumber(watchNumber);
AwwVtec awwVtec = AwwParser
.processVtectForSevereWeatherStatus(
theBulletin,
record.getIssueTime(),
record.getIssueOffice());
Set<AwwVtec> awwVtecSet = new HashSet<AwwVtec>();
awwVtecSet.add(awwVtec);
ugc.setAwwVtecLine(awwVtecSet);
/*
* now calculate status latlon info and then add
* to ugc
*/
List<AwwLatlons> pointAwwLatLonsList = AwwLatLonUtil
.getAwwLatLonsListBySereveWeatherStatusPointLine(awwVtec
.getVtecLine());
for (AwwLatlons eachAwwLatlons : pointAwwLatLonsList) {
ugc.addAwwLatLon(eachAwwLatlons);
}
}
}
}
} catch (Exception e) {
logger.error("Error processing decoded segment", e);
record = null;
}
}
if (record != null) {
// T976 - check if the record has a valid UGC. If not return an
// empty PluginDataObject array
if ((record.getAwwUGC() == null)
|| (record.getAwwUGC().size() == 0)) {
return new PluginDataObject[0];
}
} catch (Exception e) {
logger.error("Error processing decoded segment", e);
record = null;
}
}
/* Check the AWW record object. If not, throws exception. */
if (record != null) {
// T976 - check if the record has a valid UGC. If not return an
// empty PluginDataObject array
if ((record.getAwwUGC() == null) || (record.getAwwUGC().size() == 0)) {
return new PluginDataObject[0];
}
record.setReportType(reportType.trim());
record.setTraceId(traceId);
// Set MND remark before the URI is constructed
if ((mt.getMndTimeString() == null)
|| mt.getMndTimeString().trim().isEmpty()) {
record.setMndTime("unknown");
} else {
record.setMndTime(mt.getMndTimeString());
}
record.setReportType(reportType.trim());
record.setTraceId(traceId);
// Set MND remark before the URI is constructed
if ((mt.getMndTimeString() == null) || mt.getMndTimeString().trim().isEmpty()) {
record.setMndTime("unknown");
try {
record.constructDataURI();
} catch (PluginException e) {
throw new DecoderException(this.getClass()
.getCanonicalName()
+ ":Error constructing dataURI:", e);
}
} else {
record.setMndTime(mt.getMndTimeString());
throw new DecoderException(this.getClass().getCanonicalName()
+ ":Error Aww Record object is NULL");
}
try {
record.constructDataURI();
} catch (PluginException e) {
throw new DecoderException("Error constructing dataURI", e);
// Decode and set attention line
record.setAttentionWFO(AwwParser.processATTN(theBulletin));
// Replace special characters to a blank so that it may be readable.
if (theBulletin.length() < 40000) {
record.setBullMessage(UtilN
.removeLeadingWhiteSpaces(theBulletin
.replace('\r', ' ').replace('\003', ' ')
.replace('\000', ' ').replace('\001', ' ')
.replace('\036', ' ')));
}
} else {
throw new DecoderException("Error Aww Reocrd object is NULL");
}
// Decode and set attention line
record.setAttentionWFO(AwwParser.processATTN(theBulletin));
// Replace special characters to a blank so that it may be readable.
if (theBulletin.length() < 40000) {
record.setBullMessage(UtilN
.removeLeadingWhiteSpaces(theBulletin.replace('\r', ' ').replace('\003', ' ').replace('\000', ' ').replace('\001', ' ').replace('\036', ' ')));
}
// Return the AwwRecord record object.
// if (record == null) {
// return new PluginDataObject[0];
// } else {
// return new PluginDataObject[] {record};
// }
/* The reason the above is commented out is the check to see if record
* == null is a dead code. It will never get executed according the
* logic before the if statement. */
return new PluginDataObject[] { record };
outPdo.add(record);
if (cc.hasNext()) {
theBulletin = cc.next();
}
} while (cc.hasNext());
return outPdo.toArray(new PluginDataObject[] {});
}
/**

View file

@ -19,6 +19,8 @@
* 01/26/2011 N/A M. Gao Refactor:
* change the WMO regular expression more flexible.
* 08/01/2013 1028 G. Hull sanity check on AwwReportType.
* 9/15/2014 4637 J. Huber Changed parser for WCN's to read VTEC lines to parse out the watch
* number instead of the WATCH NOTIFICATION string.
*
* </pre>
*
@ -53,6 +55,7 @@ import com.raytheon.uf.common.time.util.TimeUtil;
import com.raytheon.uf.edex.database.DataAccessLayerException;
public class AwwParser {
private final static String VTEC_EXP = "(/([A-Z]{1}).([A-Z]{3}).([A-Z]{4}).([A-Z]{2}).([A-Z]{1}).([0-9]{4}).([0-9]{6}T[0-9]{4})Z-([0-9]{6}T[0-9]{4})Z/\\x0d\\x0d\\x0a)+";
private static Logger logger = Logger.getLogger(AwwParser.class
.getCanonicalName());
@ -315,19 +318,18 @@ public class AwwParser {
}
/* TRAC 1112 Extract the watch number from a *.WCN file segment */
/*
* RM 4697 Use VTEC Line to extract watch number instead of WATCH COUNTY
* NOTIFCATION text string
*/
public static String retrieveWatchNumberFromWCN(String segment) {
String watchNmbr = null;
int watchNmbrLength = 4;
int lengthDiff = 0;
String s = "WATCH COUNTY NOTIFICATION FOR WATCH\\s+(\\d+)\\s+";
Pattern p = Pattern.compile(s);
Pattern p = Pattern.compile(VTEC_EXP);
Matcher m = p.matcher(segment);
if (m.find()) {
watchNmbr = m.group(1);
watchNmbr = (watchNmbr != null) ? watchNmbr.trim() : watchNmbr;
watchNmbr = m.group(7);
watchNmbr = watchNmbr.replaceAll("^0+", "");
}
return watchNmbr;
}
@ -392,9 +394,6 @@ public class AwwParser {
String trackingNumber;
int[] latlonIndex = new int[1];
// Regular expression for VTEC line
final String VTEC_EXP = "(/([A-Z]{1}).([A-Z]{3}).([A-Z]{4}).([A-Z]{2}).([A-Z]{1}).([0-9]{4}).([0-9]{6}T[0-9]{4})Z-([0-9]{6}T[0-9]{4})Z/\\x0d\\x0d\\x0a)+";
// Pattern used to extract VTEC line
final Pattern vtecPattern = Pattern.compile(VTEC_EXP);
@ -629,9 +628,6 @@ public class AwwParser {
String trackingNumber;
int[] latlonIndex = new int[1];
// Regular expression for VTEC line
final String VTEC_EXP = "(/([A-Z]{1}).([A-Z]{3}).([A-Z]{4}).([A-Z]{2}).([A-Z]{1}).([0-9]{4}).([0-9]{6}T[0-9]{4})Z-([0-9]{6}T[0-9]{4})Z/\\x0d\\x0d\\x0a)+";
// final String WTCH_VTEC_EXP =
// "WW\\s\\d{3}\\sTORNADO\\s([A-Z]{2}\\s)+CW\\s(\\d{6}Z)\\s\\-\\s(\\d{6}Z)";
final String WTCH_VTEC_EXP = "WW\\s(\\d{1,4})\\s(TORNADO|SEVERE TSTM)\\s((\\w+|\\s+)*)\\s(\\d{6}Z)\\s\\-\\s(\\d{6}Z)";
// Pattern used to extract VTEC line

View file

@ -197,8 +197,8 @@ public class WcnCountyQueryResult {
ArrayList<ArrayList<Object[]>> list = fipsMultiResultMap.get(fips);
if (list == null) {
logger.log(Level.WARNING, "_______ No result for fips: " + fips);
if (list == null) {// mute? clouds output when CAVE is on during ingest
logger.log(Level.FINEST, "_______ No result for fips: " + fips);
return new ArrayList<ArrayList<Object[]>>();
}

View file

@ -28,6 +28,9 @@ import java.util.Iterator;
import java.util.List;
import java.util.Set;
import java.util.StringTokenizer;
import java.util.logging.Level;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.eclipse.swt.graphics.RGB;
import org.geotools.geometry.jts.ReferencedEnvelope;
@ -83,7 +86,10 @@ import com.vividsolutions.jts.io.WKBReader;
* Added label/time for union. Modified fill alpha to 0.5.
* Remove constraint & metamap in initResource().
* 08/14/2013 1028 G. Hull Move to aww project. Use AwwReportType enum.
*
* 9/15/2014 4637 J. Huber Fixed a duplicate key issue in the display hash map as well as as logic error in
* parsing the ugc line where it started with a string that need to be re-parsed. Also
* incorporating changes made by Dimitry for actually handling the > in UGC as well as
* modifying times as appropriate.
* </pre>
*
* @author ujosyula
@ -101,6 +107,8 @@ public class WcnResource extends
private List<WcnRscDataObj> modifyList;
int timesThrough = 2;
public class WcnRscDataObj implements IRscDataObject {
String datauri; // used as a key string
@ -172,10 +180,28 @@ public class WcnResource extends
WcnRscDataObj existingWcnData = wcnDataMap
.get(wcnRscDataObj.datauri);
// RM 4697 make unique keys so that all ugc entries are mapped.
if (existingWcnData == null
|| wcnRscDataObj.issueTime
.greaterThan(existingWcnData.issueTime)) {
wcnDataMap.put(wcnRscDataObj.datauri, wcnRscDataObj);
.greaterThan(existingWcnData.issueTime)
|| wcnDataMap.containsKey(wcnRscDataObj.datauri)) {
if (wcnDataMap.containsKey(wcnRscDataObj.datauri)) {
String s = "";
String r = "";
// Put all counties in the WCN into the hash map key to
// avoid iterator clean up issues
for (int i = 0; i < wcnRscDataObj.countyFips.size(); i++) {
s = wcnRscDataObj.countyFips.get(i);
r = r + " " + s;
}
wcnDataMap.put(wcnRscDataObj.datauri + " " + r,
wcnRscDataObj);
} else {
wcnDataMap.put(wcnRscDataObj.datauri, wcnRscDataObj);
}
}
return true;
@ -207,9 +233,84 @@ public class WcnResource extends
}
}
private void fipsRangeReparse(String inUgcPart, String countyname,
List<String> outList) {
final String inclusiveDelim = ">";
String county = countyname;
String countyFips;
if (inUgcPart.length() == 10) { // "([A-Z]{3}[0-9]{3}[>][0-9]{3})"
String intervalToken = inUgcPart.substring(3, 10);
county = inUgcPart.substring(0, 3);
// Format in NAMDDD1>DDD2
StringTokenizer twoTokens = new StringTokenizer(intervalToken,
inclusiveDelim);
String firstToken = twoTokens.nextToken();
String secondToken = twoTokens.nextToken();
Integer countyBegin = Integer.parseInt(firstToken);
Integer countyEnd = Integer.parseInt(secondToken);
for (int counter = countyBegin; counter <= countyEnd; counter++) {
String inclusiveToken = Integer.toString(counter);
// set "1" to "001" ...etc
if (counter < 10) {
inclusiveToken = "00".concat(inclusiveToken);
}
// set "10" to "010" ...etc
else if (counter < 100) {
inclusiveToken = "0".concat(inclusiveToken);
}
countyFips = county.concat(inclusiveToken);
outList.add(countyFips);
// UGC.addAwwFIPS(currentFips);
}
} else if (inUgcPart.length() == 7) { // "([0-9]{3}[>][0-9]{3})"
// A continuation of previous county FIPS
// with format DDD1>DDD2
StringTokenizer twoTokens = new StringTokenizer(inUgcPart,
inclusiveDelim);
String firstToken = twoTokens.nextToken();
String secondToken = twoTokens.nextToken();
Integer countyBegin = Integer.parseInt(firstToken);
Integer countyEnd = Integer.parseInt(secondToken);
for (int counter = countyBegin; counter <= countyEnd; counter++) {
String inclusiveToken = Integer.toString(counter);
// set "1" to "001" ...etc
if (counter < 10) {
inclusiveToken = "00".concat(inclusiveToken);
}
// set "10" to "010" ...etc
else if (counter < 100) {
inclusiveToken = "0".concat(inclusiveToken);
}
countyFips = county.concat(inclusiveToken);
outList.add(countyFips);
// UGC.addAwwFIPS(currentFips);
}
} else {
outList.add(inUgcPart);// risky?
}
}
private ArrayList<WcnRscDataObj> getAwwtData(AwwRecord awwRecord) {
WcnRscDataObj wcnStatusData = null;
List<WcnRscDataObj> wcnDataList = new ArrayList<WcnRscDataObj>();
final String ENDTIME_REGEX = "([0-9]{6})";
final Pattern endTimePattern = Pattern.compile(ENDTIME_REGEX);
try {
Set<AwwUgc> awwUgc = awwRecord.getAwwUGC();
for (AwwUgc awwugcs : awwUgc) {
@ -228,18 +329,16 @@ public class WcnResource extends
wcnStatusData.reportType = AwwReportType.TORNADO_WATCH;// "TORNADO";
}
if (!(wcnStatusData.isCounty = isCountyUgs(awwugcs))) {// verify
// =
// isn't
// typo
// System.err.println("****** " +
// awwugcs.getEventTrackingNumber() + "-"
if (!(wcnStatusData.isCounty = isCountyUgs(awwugcs))) {
// System.err.println("****** "
// + awwugcs.getEventTrackingNumber() + "-"
// + awwugcs.getProdPurgeTime() + " **************");// TODO
setMarineZonesFips(awwugcs.getAwwFIPS(), wcnStatusData);// T456
}
String ugcline = awwugcs.getUgc();// get the ugc line to find
// the counties
if (ugcline != null && ugcline != "") {
wcnStatusData.watchNumber = awwugcs
.getEventTrackingNumber();
wcnStatusData.countyUgc = new ArrayList<String>();
@ -251,61 +350,92 @@ public class WcnResource extends
while (strugcs.hasMoreTokens()) {
temp = strugcs.nextToken("-");
if (temp != null) {
if (temp.contains("\r\r\n")) {
boolean dontSkip = true;
Matcher endTimeMatcher = endTimePattern.matcher(temp);
if (endTimeMatcher.find()) {
dontSkip = false;
}
if (temp != null && dontSkip) {
if (temp.startsWith("\r\r\n")) { // was
// .contains("\r\r\n")
String temp1 = temp.substring(3);
temp = temp1;
}
if (temp.contains(countyname)) {
// System.out.println(temp + ":"
// + awwugcs.getEventTrackingNumber()
// + ":" + countyname + ":"
// + wcnStatusData.datauri);
(wcnStatusData.countyUgc).add(temp);
// awwugcs.setUgc(temp);
} else {
// WcnCountyQueryResult
// .trackError(
// System.getProperties()
// .getProperty(
// "user.home")
// + "//caveData//log.txt",
// "2:"
// + temp
// + ":"
// + awwugcs
// .getEventTrackingNumber()
// + ":" + countyname
// + ":"
// + wcnStatusData.datauri);
// System.err.println(temp + ":"
// + awwugcs.getEventTrackingNumber()
// + ":" + countyname + ":"
// + wcnStatusData.datauri);
try {
if (6 == temp.length()
&& 0 < (Integer.parseInt(temp
.substring(0, 3)))) {
awwugcs.setUgc(temp.substring(0, 3));
countyname = temp.substring(0, 3);
if (temp.length() == 6) {
if ((0 == Character.getNumericValue(temp
.toCharArray()[3]))
&& (0 == Character
.getNumericValue(temp
.toCharArray()[4]))
&& (0 == Character
.getNumericValue(temp
.toCharArray()[5]))) {
} else {
(wcnStatusData.countyUgc).add(temp);
// awwugcs.setUgc(temp);
}
} catch (NumberFormatException nfe) {
// do nothing? or??
// awwugcs.setUgc(temp.substring(0, 3));
} else {
fipsRangeReparse(temp, countyname,
(wcnStatusData.countyUgc));
}
} else if (temp.length() == 7) {
fipsRangeReparse(temp, countyname,
(wcnStatusData.countyUgc));
} else {
if (!"".equalsIgnoreCase(temp)
&& Character.isLetter(temp
.toCharArray()[0])) {
countyname = temp.substring(0, 3);
} finally { // String temp1 = temp.substring(0,
// 3); temp = temp1;
// System.err.println(countyname);
(wcnStatusData.countyUgc).add(countyname
.concat(temp));
String temp2 = countyname.substring(0, 3)
+ temp.substring(3);
(wcnStatusData.countyUgc).add(temp2
// countyname.concat(temp.substring(3))
);
// (wcnStatusData.countyUgc).add(temp);
}
String temp2 = countyname.substring(0, 3)
+ temp;
if (temp2.length() > 6) {
if (9 == temp2.length()) {
(wcnStatusData.countyUgc).add(temp2
.substring(3, 9));
} else {
// (wcnStatusData.countyUgc).add(temp2
// .substring(0, 6));
fipsRangeReparse(temp2.substring(0, 6),
countyname,
(wcnStatusData.countyUgc));
}
} else {
if (!(6 > temp2.length())
&& (0 == Character
.getNumericValue(temp2
.toCharArray()[3]))
&& (0 == Character
.getNumericValue(temp2
.toCharArray()[4]))
&& (0 == Character
.getNumericValue(temp2
.toCharArray()[5]))) {
System.err.println(temp2);
} else {
(wcnStatusData.countyUgc).add(temp2);
}
}
}
i++;
}
}
if (i > 1) {
wcnStatusData.countyUgc.remove(i - 1);
wcnStatusData.countyUgc.remove(i - 2);
wcnStatusData.countyUgc.remove(wcnStatusData.countyUgc
.size() - 1);// cleanup
}
wcnStatusData = getCountyNameLatLon(wcnStatusData);
@ -329,6 +459,14 @@ public class WcnResource extends
if ((awwVtech.getAction().equalsIgnoreCase("COR"))
|| (awwVtech.getAction()
.equalsIgnoreCase("CAN"))
|| (awwVtech.getAction()
.equalsIgnoreCase("NEW"))
|| (awwVtech.getAction()
.equalsIgnoreCase("EXA"))
|| (awwVtech.getAction()
.equalsIgnoreCase("EXB"))
|| (awwVtech.getAction()
.equalsIgnoreCase("EXT"))
|| (awwVtech.getAction()
.equalsIgnoreCase("EXP"))) {
modifyList.add(wcnStatusData);
@ -367,15 +505,15 @@ public class WcnResource extends
}
} catch (NumberFormatException nfe) {
// // may need to handle..
// System.err
// .println("****** NumberFormatException fired off somewhere **********************************************"
// + "\n" + nfe.getLocalizedMessage());
// may need to handle..
System.err
.println("****** NumberFormatException **** ****** *** *** ****** *** *** ****** *** *** ******"
+ "\n" + nfe.getLocalizedMessage());
} catch (Exception e) {
System.out.println("at line 212" + e);// TODO what is this?
logger.warning("In getAwwtData(AwwRecord awwRecord)\n"
+ e.getClass().getCanonicalName() + ":"
+ e.getLocalizedMessage());
e.printStackTrace();
}
preProcessFrameUpdate();
@ -383,6 +521,20 @@ public class WcnResource extends
return (ArrayList<WcnRscDataObj>) wcnDataList;
}
// prior:
// "select AsBinary(the_geom), AsBinary(the_geom_0_001), wfo,name,id, lat, lon from mapdata.marinezones where ";
private static String queryPrefixMZ_LatLons = "select wfo,name,id, lat, lon from mapdata.marinezones";
// where ST_SetSrid('BOX3D(-180.0 -90.0, 180.0 90.0)'::box3d,4326)";
// private static final double ENV_MIN_X = -180.0;
// private static final double ENV_MAX_X = 180.0;
// private static final double ENV_MIN_Y = -90;
// private static final double ENV_MAX_Y = 90.0;
// private String geoConstraint =
// String.format("the_geom_0_001 && ST_SetSrid('BOX3D(%f %f, %f %f)'::box3d,4326)",
// ENV_MIN_X, ENV_MIN_Y, ENV_MAX_X, ENV_MAX_Y);
private WcnRscDataObj getCountyNameLatLon(WcnRscDataObj wdata) {
wdata.countyPoints = new ArrayList<LatLonPoint>();
wdata.countyNames = new ArrayList<String>();
@ -392,10 +544,13 @@ public class WcnResource extends
try {
int i = 0;
for (Iterator<String> iterator = wdata.countyUgc.iterator(); iterator
.hasNext();) {
String theKey = iterator.next();
Station station = stationTable.getStation(StationField.STID,
iterator.next());
theKey);
if (station != null) {
LatLonPoint point = new LatLonPoint(station.getLatitude(),
station.getLongitude(), LatLonPoint.INDEGREES);
@ -404,16 +559,53 @@ public class WcnResource extends
wdata.stateNames.add(station.getState());
wdata.countyLat[i] = station.getLatitude();
wdata.countyLon[i] = station.getLongitude();
i++;
// if (wdata.isCounty) { // will do always work w/marine
// zones? //TODO cleanup if no
String s = station.getStnnum();
wdata.countyFips.add(s.length() == 4 ? "0" + s : s);
// }// T456 AwwUgc.getAwwFIPS
if (wdata.isCounty) {
String s = station.getStnnum();
wdata.countyFips.add(s.length() == 4 ? "0" + s : s);
}// T456 AwwUgc.getAwwFIPS
} else {
// ELSE:
// <station>
// <stid>GUC110</stid> == maps.id
// <stnnum>69110</stnnum> ???
// <stnname>Saipan</stnname> == maps.name
// <state>GU</state> ...
// <country>US</country> ...
// <latitude>15.19</latitude> == maps.lat
// <longitude>145.76</longitude> == maps.lon
// <elevation>0</elevation> 0..
// <priority>0</priority>
// <wfo>GUM</wfo> == maps.wfo
// </station>
List<Object[]> results = DirectDbQuery.executeQuery(
queryPrefixMZ_LatLons.toString() + " where id = '"
+ theKey + "'", "maps", QueryLanguage.SQL);
LatLonPoint point = new LatLonPoint(
Float.parseFloat(results.get(0)[3].toString()),
Float.parseFloat(results.get(0)[4].toString()),
LatLonPoint.INDEGREES);
wdata.countyPoints.add(point);
wdata.countyNames.add(results.get(0)[1].toString());
wdata.stateNames.add("");
wdata.countyLat[i] = Float.parseFloat(results.get(0)[3]
.toString());
wdata.countyLon[i] = Float.parseFloat(results.get(0)[4]
.toString());
wdata.countyFips.add(results.get(0)[2].toString());
}
i++;
}
} catch (IndexOutOfBoundsException idxOobEx) {
logger.log(Level.FINEST,
"In getCountyNameLatLon(WcnRscDataObj wdata)\n" // mute?
+ idxOobEx.getClass().getCanonicalName()
+ ":"
+ idxOobEx.getLocalizedMessage());
} catch (Exception e) {
System.out.println("wcnResource.java at Line 245" + e);
logger.warning("In getCountyNameLatLon(WcnRscDataObj wdata)\n"
+ e.getClass().getCanonicalName() + ":"
+ e.getLocalizedMessage());
@ -434,11 +626,9 @@ public class WcnResource extends
private void modifyQueue() {
if (modifyList != null) {
// int idx = 0;
for (WcnRscDataObj modify : modifyList) {
for (IRscDataObject rscDataObj : newRscDataObjsQueue) {
WcnRscDataObj candidate = (WcnRscDataObj) rscDataObj;
// System.out.print(idx + ":" + candidate.eventType);
if (modify.evTrack.equalsIgnoreCase(candidate.evTrack)
&& modify.evOfficeId
@ -449,19 +639,23 @@ public class WcnResource extends
.equalsIgnoreCase(candidate.evProductClass)
&& modify.evSignificance
.equalsIgnoreCase(candidate.evSignificance)) {
// System.out.print(idx + ":" + candidate.eventType);
if (candidate.eventType.equalsIgnoreCase("CAN")) {
// System.err.print(modify.issueTime
// .getDisplayString()
// + "**"
// + modify.evEndTime.getDisplayString());
// candidate.evEndTime = modify.issueTime;
// candidate.eventTime = new DataTime(
// candidate.eventTime.getRefTimeAsCalendar(),
// new TimeRange(candidate.eventTime
// .getRefTimeAsCalendar(),
// candidate.evEndTime
// .getRefTimeAsCalendar()));// ?
candidate.evEndTime = modify.issueTime;
// (modify.issueTime.getValidTimeAsDate().getTime()
// <= modify.evEndTime
// .getValidTimeAsDate().getTime() ?
// modify.issueTime
// : modify.evEndTime);
candidate.eventTime = new DataTime(
candidate.eventTime.getRefTimeAsCalendar(),
new TimeRange(candidate.eventTime
.getRefTimeAsCalendar(),
candidate.evEndTime
.getRefTimeAsCalendar()));// ?
} else if (candidate.eventType.equalsIgnoreCase("COR")) {
candidate.evEndTime = modify.evEndTime;
candidate.eventTime = new DataTime(
@ -471,13 +665,46 @@ public class WcnResource extends
candidate.evEndTime
.getRefTimeAsCalendar()));// ?
} else if (candidate.eventType.equalsIgnoreCase("EXP")) {
// candidate.evEndTime = modify.issueTime;
// candidate.eventTime = new DataTime(
// candidate.eventTime.getRefTimeAsCalendar(),
// new TimeRange(candidate.eventTime
// .getRefTimeAsCalendar(),
// candidate.evEndTime
// .getRefTimeAsCalendar()));
candidate.evEndTime = modify.issueTime;
candidate.eventTime = new DataTime(
candidate.eventTime.getRefTimeAsCalendar(),
new TimeRange(candidate.eventTime
.getRefTimeAsCalendar(),
candidate.evEndTime
.getRefTimeAsCalendar()));
} else if (candidate.eventType.equalsIgnoreCase("EXA")) {
candidate.evEndTime = modify.evEndTime;
candidate.eventTime = new DataTime(
candidate.eventTime.getRefTimeAsCalendar(),
new TimeRange(candidate.eventTime
.getRefTimeAsCalendar(),
candidate.evEndTime
.getRefTimeAsCalendar()));
} else if (candidate.eventType.equalsIgnoreCase("EXT")) {
candidate.evEndTime = modify.evEndTime;
candidate.eventTime = new DataTime(
candidate.eventTime.getRefTimeAsCalendar(),
new TimeRange(candidate.eventTime
.getRefTimeAsCalendar(),
candidate.evEndTime
.getRefTimeAsCalendar()));
} else if (candidate.eventType.equalsIgnoreCase("NEW")) {
candidate.eventTime = modify.eventTime;
candidate.evEndTime = modify.evEndTime;
candidate.eventTime = new DataTime(
candidate.eventTime.getRefTimeAsCalendar(),
new TimeRange(candidate.eventTime
.getRefTimeAsCalendar(),
candidate.evEndTime
.getRefTimeAsCalendar()));
} else if (candidate.eventType.equalsIgnoreCase("EXB")) {
candidate.evEndTime = modify.evEndTime;
candidate.eventTime = new DataTime(
candidate.eventTime.getRefTimeAsCalendar(),
new TimeRange(candidate.eventTime
.getRefTimeAsCalendar(),
candidate.evEndTime
.getRefTimeAsCalendar()));
} else if (candidate.eventType.equalsIgnoreCase("CON")) {
candidate.evEndTime = modify.evEndTime;
candidate.eventTime = new DataTime(
@ -487,7 +714,7 @@ public class WcnResource extends
candidate.evEndTime
.getRefTimeAsCalendar()));
} else {
candidate.evEndTime = modify.issueTime;
candidate.evEndTime = modify.evEndTime;
candidate.eventTime = new DataTime(
candidate.eventTime.getRefTimeAsCalendar(),
new TimeRange(candidate.eventTime
@ -498,8 +725,6 @@ public class WcnResource extends
}
}
// System.out.println();
// idx++;
}
}// end if !null
}
@ -655,6 +880,24 @@ public class WcnResource extends
draw = true;
}
if (getCurrentFrameTime().getValidTimeAsDate().getTime() <= wcnData
.getDataTime().getValidPeriod().getEnd().getTime()
|| getCurrentFrameTime().getValidTimeAsDate().getTime() >= wcnData
.getDataTime().getValidPeriod().getStart()
.getTime()) {
draw = true;// verify this rule;
}
if (getCurrentFrameTime().getValidTimeAsDate().getTime() > wcnData
.getDataTime().getValidPeriod().getEnd().getTime()) {
draw = false;
}
if (getCurrentFrameTime().getValidTimeAsDate().getTime() < wcnData
.getDataTime().getValidPeriod().getStart().getTime()) {
draw = false;
}
if (getCurrentFrameTime().getValidTimeAsDate().getTime() == (wcnData
.getDataTime().getValidPeriod().getEnd().getTime())) {
// do not draw endtime frame, that's what nmap2 does
@ -687,7 +930,10 @@ public class WcnResource extends
}
}
} catch (Exception e) {
System.out.println("error at line 392 " + e);
logger.warning("In paintFrame(AbstractFrameData frameData, IGraphicsTarget target,PaintProperties paintProps)\n"
+ e.getClass().getCanonicalName()
+ ":"
+ e.getLocalizedMessage());
}
}
if (wcnRscData.getWatchBoxFillEnable()) {
@ -728,7 +974,8 @@ public class WcnResource extends
enabledText.add(wcnData.watchNumber);
}
if (wcnRscData.getWatchBoxTimeEnable()) {
if (wcnRscData.getWatchBoxTimeEnable()) { // change from
// box-time?
DataTime startTime = new DataTime(wcnData.eventTime
.getValidPeriod().getStart());
DataTime endTime = new DataTime(wcnData.eventTime
@ -778,7 +1025,6 @@ public class WcnResource extends
/*
* 0 for drawoutline 1 for shaded shape 2 for union
*/
public void drawCountyOutline(WcnRscDataObj wcnData,
IGraphicsTarget target, RGB color, int symbolWidth,
LineStyle lineStyle, PaintProperties paintProps,
@ -930,7 +1176,7 @@ public class WcnResource extends
}
}
} catch (Exception e) {
System.out.println("wcnResource.java at Line 427" + e);
System.out.println("wcnResource.java at Line 427" + e);// TODO fix
}
}
@ -1027,7 +1273,6 @@ public class WcnResource extends
Collection<Geometry> gw = new ArrayList<Geometry>(), gu = new ArrayList<Geometry>();
for (int i = 0; i < wrdo.countyFips.size(); i++) {
// System.out.print("i" + i);
// another loop handles multiple rows in maps
// mapdata.county table
for (ArrayList<Object[]> results : queryResult
@ -1041,7 +1286,7 @@ public class WcnResource extends
for (Object[] result : results) {
int k = 0;
byte[] wkb1 = (byte[]) result[k];
// System.out.print("k" + k);
MultiPolygon countyGeo = null;
try {
countyGeo = (MultiPolygon) wkbReader
@ -1148,6 +1393,13 @@ public class WcnResource extends
return;
}
if (getCurrentFrameTime().getValidTimeAsDate().getTime() <= wData
.getDataTime().getValidPeriod().getEnd().getTime()
|| getCurrentFrameTime().getValidTimeAsDate().getTime() >= wData
.getDataTime().getValidPeriod().getStart().getTime()) {
// draw = true;// verify this rule; // // // // // // // // //TODO
}
if (shadedShape != null && shadedShape.isDrawable()
&& drawOutlineOrShadedshapeorUnion == 1) {
try {

View file

@ -1,5 +1,6 @@
package gov.noaa.nws.ncep.viz.rsc.aww.wou;
import gov.noaa.nws.ncep.common.dataplugin.aww.AwwFips;
import gov.noaa.nws.ncep.common.dataplugin.aww.AwwRecord;
import gov.noaa.nws.ncep.common.dataplugin.aww.AwwRecord.AwwReportType;
import gov.noaa.nws.ncep.common.dataplugin.aww.AwwUgc;
@ -25,6 +26,9 @@ import java.util.Iterator;
import java.util.List;
import java.util.Set;
import java.util.StringTokenizer;
import java.util.logging.Level;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.eclipse.swt.graphics.RGB;
import org.geotools.geometry.jts.ReferencedEnvelope;
@ -80,6 +84,9 @@ import com.vividsolutions.jts.io.WKBReader;
* Added label/time for union. Fixed a bug for querying county. Modified fill alpha to 0.5.
* 09/13/12 857 Q. Zhou Remove constraint & metamap in initResource().
* 08/14/13 1028 G. Hull Move to aww project. Use AwwReportType enum.
* 9/15/14 4637 J. Huber Added fipsRangeReparse to handle "character" in UGC line. Also added logic on when to use it.
* Also fixed a clean up error for the county list array which prevented some counties from being
* displayed.
*
* </pre>
*
@ -102,6 +109,9 @@ public class WouResource extends
// Area change flag
private boolean areaChangeFlag = false;
private static java.util.logging.Logger logger = java.util.logging.Logger
.getLogger(WouResource.class.getCanonicalName());
private class WouRscDataObj implements IRscDataObject {
String datauri; // used as a key string
@ -137,6 +147,10 @@ public class WouResource extends
String evSignificance;
boolean isCounty; // TODO
List<String> countyFips = new ArrayList<String>(); // probably TODO
@Override
public DataTime getDataTime() {
return eventTime;
@ -220,9 +234,8 @@ public class WouResource extends
@Override
public boolean updateFrameData(IRscDataObject rscDataObj) {
if (!(rscDataObj instanceof WouRscDataObj)) {
System.out
.println("WouResource.updateFrameData: expecting objects "
+ " of type WouRscDataObj???");
logger.warning("WouResource.updateFrameData: expecting objects "
+ " of type WouRscDataObj???");
return false;
}
@ -269,10 +282,11 @@ public class WouResource extends
wData.rebuild = true;
}
if (oldStatus != newStatus) {
if (newStatus)
if (newStatus) {
wData.numOfActCnties++;
else
} else {
wData.numOfActCnties--;
}
}
}
} else {
@ -355,10 +369,11 @@ public class WouResource extends
WouRscDataObj wouStatusData = null;
List<WouRscDataObj> wouDataList = new ArrayList<WouRscDataObj>();
final String ENDTIME_REGEX = "([0-9]{6})";
final Pattern endTimePattern = Pattern.compile(ENDTIME_REGEX);
try {
Set<AwwUgc> awwUgc = awwRecord.getAwwUGC();
for (AwwUgc awwugcs : awwUgc) {
wouStatusData = new WouRscDataObj();
wouStatusData.issueTime = new DataTime(awwRecord.getIssueTime());
@ -366,6 +381,10 @@ public class WouResource extends
.getReportType(awwRecord.getReportType());
wouStatusData.datauri = awwRecord.getDataURI();
if (!(wouStatusData.isCounty = isCountyUgs(awwugcs))) {
setMarineZonesFips(awwugcs.getAwwFIPS(), wouStatusData);
}
String ugcline = awwugcs.getUgc();// get the ugc line to find
// the counties
if (ugcline != null && ugcline != "") {
@ -378,27 +397,100 @@ public class WouResource extends
StringTokenizer strugcs = new StringTokenizer(ugcline);
while (strugcs.hasMoreTokens()) {
temp = strugcs.nextToken("-");
if (temp != null) {
if (temp.contains("\r\r\n")) {
boolean dontSkip = true;
Matcher endTimeMatcher = endTimePattern.matcher(temp);
if (endTimeMatcher.find()) {
dontSkip = false;
}
// Pull together a county list expanding the ">"
// character if necessary
if (temp != null && dontSkip) {
if (temp.startsWith("\r\r\n")) {
String temp1 = temp.substring(3);
temp = temp1;
}
if (temp.contains(countyname)) {
(wouStatusData.countyUgc).add(temp);
if (temp.length() == 6) {
if ((0 == Character.getNumericValue(temp
.toCharArray()[3]))
&& (0 == Character
.getNumericValue(temp
.toCharArray()[4]))
&& (0 == Character
.getNumericValue(temp
.toCharArray()[5]))) {
// not in mapdata.marinezones yet, keep
// parsing
} else {
(wouStatusData.countyUgc).add(temp);
}
} else {
fipsRangeReparse(temp, countyname,
(wouStatusData.countyUgc));
}
} else if (temp.length() == 7) {
fipsRangeReparse(temp, countyname,
(wouStatusData.countyUgc));
} else {
(wouStatusData.countyUgc).add(countyname
.concat(temp));
if (!"".equalsIgnoreCase(temp)
&& Character.isLetter(temp
.toCharArray()[0])) {
countyname = temp.substring(0, 3);
String temp2 = countyname.substring(0, 3)
+ temp.substring(3);
(wouStatusData.countyUgc).add(temp2);
}
// (wouStatusData.countyUgc).add(countyname.concat(temp));
String temp2 = countyname.substring(0, 3)
+ temp;
if (temp2.length() > 6) {
if (9 == temp2.length()) {
(wouStatusData.countyUgc).add(temp2
.substring(3, 9));
} else {
// (wcnStatusData.countyUgc).add(temp2
// .substring(0, 6));
fipsRangeReparse(temp2.substring(0, 6),
countyname,
(wouStatusData.countyUgc));
}
} else {
if (!(6 > temp2.length())
&& (0 == Character
.getNumericValue(temp2
.toCharArray()[3]))
&& (0 == Character
.getNumericValue(temp2
.toCharArray()[4]))
&& (0 == Character
.getNumericValue(temp2
.toCharArray()[5]))) {
// not in mapdata.marinezones yet, keep
// parsing
// System.err.println(temp2);
} else {
(wouStatusData.countyUgc).add(temp2);
}
}
}
i++;
}
}
if (i > 1) {
wouStatusData.countyUgc.remove(i - 1);
wouStatusData.countyUgc.remove(i - 2);
wouStatusData.countyUgc.remove(wouStatusData.countyUgc
.size() - 1);// cleanup
}
wouStatusData = getCountyNameLatLon(wouStatusData);
}
int vtechNumber = awwugcs.getAwwVtecLine().size();
if (vtechNumber > 0) {
for (AwwVtec awwVtech : awwugcs.getAwwVtecLine()) {
@ -417,6 +509,10 @@ public class WouResource extends
if ((awwVtech.getAction().equalsIgnoreCase("COR"))
|| (awwVtech.getAction()
.equalsIgnoreCase("CAN"))
|| (awwVtech.getAction()
.equalsIgnoreCase("NEW"))
|| (awwVtech.getAction()
.equalsIgnoreCase("EXT"))
|| (awwVtech.getAction()
.equalsIgnoreCase("EXP"))) {
modifyList.add(wouStatusData);
@ -449,12 +545,16 @@ public class WouResource extends
wouDataList.add(wouStatusData);
}
} catch (Exception e) {
System.out.println("at line 212" + e);
logger.warning("In getCountyNameLatLon(WouRscDataObj wdata)\n"
+ e.getClass().getCanonicalName() + ":"
+ e.getLocalizedMessage());
}
return (ArrayList<WouRscDataObj>) wouDataList;
}
private static String queryPrefixMZ_LatLons = "select wfo,name,id, lat, lon from mapdata.marinezones";
private WouRscDataObj getCountyNameLatLon(WouRscDataObj wdata) {
wdata.countyPoints = new ArrayList<LatLonPoint>();
wdata.countyNames = new ArrayList<String>();
@ -466,8 +566,11 @@ public class WouResource extends
int i = 0;
for (Iterator<String> iterator = wdata.countyUgc.iterator(); iterator
.hasNext();) {
String theKey = iterator.next();
Station station = stationTable.getStation(StationField.STID,
iterator.next());
theKey);
if (station != null) {
LatLonPoint point = new LatLonPoint(station.getLatitude(),
station.getLongitude(), LatLonPoint.INDEGREES);
@ -476,13 +579,56 @@ public class WouResource extends
wdata.stateNames.add(station.getState());
wdata.countyLat[i] = station.getLatitude();
wdata.countyLon[i] = station.getLongitude();
i++;
if (wdata.isCounty) {
String s = station.getStnnum();
wdata.countyFips.add(s.length() == 4 ? "0" + s : s);
}
} else {
// ELSE:
// <station>
// <stid>GUC110</stid> == maps.id
// <stnnum>69110</stnnum> ???
// <stnname>Saipan</stnname> == maps.name
// <state>GU</state> ...
// <country>US</country> ...
// <latitude>15.19</latitude> == maps.lat
// <longitude>145.76</longitude> == maps.lon
// <elevation>0</elevation> 0..
// <priority>0</priority>
// <wfo>GUM</wfo> == maps.wfo
// </station>
List<Object[]> results = DirectDbQuery.executeQuery(
queryPrefixMZ_LatLons.toString() + " where id = '"
+ theKey + "'", "maps", QueryLanguage.SQL);
LatLonPoint point = new LatLonPoint(
Float.parseFloat(results.get(0)[3].toString()),
Float.parseFloat(results.get(0)[4].toString()),
LatLonPoint.INDEGREES);
wdata.countyPoints.add(point);
wdata.countyNames.add(results.get(0)[1].toString());
wdata.stateNames.add("");
wdata.countyLat[i] = Float.parseFloat(results.get(0)[3]
.toString());
wdata.countyLon[i] = Float.parseFloat(results.get(0)[4]
.toString());
wdata.countyFips.add(results.get(0)[2].toString());
}
i++;
}
} catch (IndexOutOfBoundsException idxOobEx) {
logger.log(Level.FINEST,
"In getCountyNameLatLon(WouRscDataObj wdata)\n" // mute?
+ idxOobEx.getClass().getCanonicalName()
+ ":"
+ idxOobEx.getLocalizedMessage());
} catch (Exception e) {
System.out.println("wouResource.java at Line 245" + e);
logger.warning("In getCountyNameLatLon(WouRscDataObj wdata)\n"
+ e.getClass().getCanonicalName() + ":"
+ e.getLocalizedMessage());
}
wdata.countyNumPoints = wdata.countyNames.size();
return wdata;
@ -492,7 +638,7 @@ public class WouResource extends
@Override
protected boolean preProcessFrameUpdate() {
// modifyQueue();
modifyQueue();
return true;
}
@ -512,9 +658,7 @@ public class WouResource extends
&& modify.evSignificance
.equalsIgnoreCase(candidate.evSignificance)) {
if (candidate.eventType.equalsIgnoreCase("CAN")
|| candidate.eventType.equalsIgnoreCase("COR")
|| candidate.eventType.equalsIgnoreCase("EXP")) {
} else {
candidate.evEndTime = modify.issueTime;
candidate.eventTime = new DataTime(
candidate.eventTime.getRefTimeAsCalendar(),
@ -522,6 +666,47 @@ public class WouResource extends
.getRefTimeAsCalendar(),
candidate.evEndTime
.getRefTimeAsCalendar()));
} else if (candidate.eventType.equalsIgnoreCase("COR")) {
candidate.evEndTime = modify.evEndTime;
candidate.eventTime = new DataTime(
candidate.eventTime.getRefTimeAsCalendar(),
new TimeRange(candidate.eventTime
.getRefTimeAsCalendar(),
candidate.evEndTime
.getRefTimeAsCalendar()));
} else if (candidate.eventType.equalsIgnoreCase("EXT")) {
candidate.evEndTime = modify.evEndTime;
candidate.eventTime = new DataTime(
candidate.eventTime.getRefTimeAsCalendar(),
new TimeRange(candidate.eventTime
.getRefTimeAsCalendar(),
candidate.evEndTime
.getRefTimeAsCalendar()));
} else if (candidate.eventType.equalsIgnoreCase("NEW")) {
candidate.eventTime = modify.eventTime;
candidate.evEndTime = modify.evEndTime;
candidate.eventTime = new DataTime(
candidate.eventTime.getRefTimeAsCalendar(),
new TimeRange(candidate.eventTime
.getRefTimeAsCalendar(),
candidate.evEndTime
.getRefTimeAsCalendar()));
} else if (candidate.eventType.equalsIgnoreCase("CON")) {
candidate.evEndTime = modify.evEndTime;
candidate.eventTime = new DataTime(
candidate.eventTime.getRefTimeAsCalendar(),
new TimeRange(candidate.eventTime
.getRefTimeAsCalendar(),
candidate.evEndTime
.getRefTimeAsCalendar()));
} else {
candidate.evEndTime = modify.evEndTime; // issueTime
candidate.eventTime = new DataTime(
candidate.eventTime.getRefTimeAsCalendar(),
new TimeRange(candidate.eventTime
.getRefTimeAsCalendar(),
candidate.evEndTime
.getRefTimeAsCalendar()));
}
}
@ -805,7 +990,9 @@ public class WouResource extends
}
}
} catch (Exception e) {
System.out.println("error at line 392 " + e);
logger.warning("In getCountyNameLatLon(WouRscDataObj wdata)\n"
+ e.getClass().getCanonicalName() + ":"
+ e.getLocalizedMessage());
}
}
}
@ -1035,7 +1222,9 @@ public class WouResource extends
}
}
} catch (Exception e) {
System.out.println("wouResource.java at Line 427" + e);
logger.warning("In getCountyNameLatLon(WouRscDataObj wdata)\n"
+ e.getClass().getCanonicalName() + ":"
+ e.getLocalizedMessage());
}
}
}
@ -1075,7 +1264,6 @@ public class WouResource extends
}
}
@SuppressWarnings("deprecation")
private void drawSevereThunderstormWatchUnion(FrameData currFrameData,
IGraphicsTarget target) throws VizException {
LineStyle lineStyle = LineStyle.SOLID;
@ -1377,6 +1565,111 @@ public class WouResource extends
return cntyName;
}
private void fipsRangeReparse(String inUgcPart, String countyname,
List<String> outList) {
final String inclusiveDelim = ">";
String county = countyname;
String countyFips;
if (inUgcPart.length() == 10) { // "([A-Z]{3}[0-9]{3}[>][0-9]{3})"
String intervalToken = inUgcPart.substring(3, 10);
county = inUgcPart.substring(0, 3);
// Format in NAMDDD1>DDD2
StringTokenizer twoTokens = new StringTokenizer(intervalToken,
inclusiveDelim);
String firstToken = twoTokens.nextToken();
String secondToken = twoTokens.nextToken();
Integer countyBegin = Integer.parseInt(firstToken);
Integer countyEnd = Integer.parseInt(secondToken);
for (int counter = countyBegin; counter <= countyEnd; counter++) {
String inclusiveToken = Integer.toString(counter);
// set "1" to "001" ...etc
if (counter < 10) {
inclusiveToken = "00".concat(inclusiveToken);
}
// set "10" to "010" ...etc
else if (counter < 100) {
inclusiveToken = "0".concat(inclusiveToken);
}
countyFips = county.concat(inclusiveToken);
outList.add(countyFips);
// UGC.addAwwFIPS(currentFips);
}
} else if (inUgcPart.length() == 7) { // "([0-9]{3}[>][0-9]{3})"
// A continuation of previous county FIPS
// with format DDD1>DDD2
StringTokenizer twoTokens = new StringTokenizer(inUgcPart,
inclusiveDelim);
String firstToken = twoTokens.nextToken();
String secondToken = twoTokens.nextToken();
Integer countyBegin = Integer.parseInt(firstToken);
Integer countyEnd = Integer.parseInt(secondToken);
for (int counter = countyBegin; counter <= countyEnd; counter++) {
String inclusiveToken = Integer.toString(counter);
// set "1" to "001" ...etc
if (counter < 10) {
inclusiveToken = "00".concat(inclusiveToken);
}
// set "10" to "010" ...etc
else if (counter < 100) {
inclusiveToken = "0".concat(inclusiveToken);
}
countyFips = county.concat(inclusiveToken);
outList.add(countyFips);
// UGC.addAwwFIPS(currentFips);
}
} else {
outList.add(inUgcPart);// risky?
}
}
void setMarineZonesFips(Set<AwwFips> awwFipsSet, WouRscDataObj wrdo) {
if (awwFipsSet != null && wrdo != null) {
for (AwwFips eachAwwFips : awwFipsSet) {
wrdo.countyFips.add(eachAwwFips.getFips());
}
}
}
boolean isCountyUgs(AwwUgc au) {
Set<AwwFips> awwFipsSet = au.getAwwFIPS();
boolean out = false;
if (awwFipsSet == null) {
return false;
} else {
for (AwwFips eachAwwFips : awwFipsSet) {
String eachFips = eachAwwFips.getFips();
if (eachFips == null || eachFips.isEmpty()
|| eachFips.length() != 6) {
return false;
}
out = ('C' == eachFips.charAt(2));
}
}
return out;
}
@Override
public String getName() {
String legendString = super.getName();