();
try {
- VAAParser parser = new VAAParser(pluginName, data, traceId,
- headers);
+ VAAParser parser = new VAAParser(data, traceId, headers);
for (VAARecord record : parser) {
if (record != null) {
- try {
- record.constructDataURI();
- if (!checkForDup(record)) {
- obsList.add(record);
- }
- } catch (PluginException e) {
- logger.error(traceId
- + "- Unable to construct dataURI", e);
- record = null;
- }
+ // overwrite will only happen if a correction is issued
+ // within the same minute as the original
+ record.setOverwriteAllowed(true);
+ obsList.add(record);
}
}
} catch (Exception e) {
@@ -119,37 +105,4 @@ public class VAADecoder {
return decodedData;
}
- /**
- *
- * @return
- */
- public boolean isFailSafe() {
- return failSafe;
- }
-
- /**
- *
- * @param value
- */
- public void setFailSafe(boolean value) {
- failSafe = value;
- }
-
- /**
- *
- * @param vaa
- * @return
- */
- private boolean checkForDup(VAARecord vaa) {
- boolean isDup = false;
-
- try {
- VAARecordDao dao = new VAARecordDao(pluginName);
- Object[] res = dao.queryDataUriColumn(vaa.getDataURI());
- isDup = (res != null) && (res.length > 0);
- } catch (Exception e) {
- logger.error("Unable to create VAARecordDao", e);
- }
- return isDup;
- }
}
diff --git a/edexOsgi/com.raytheon.uf.edex.plugin.vaa/src/com/raytheon/uf/edex/plugin/vaa/VAARecordDao.java b/edexOsgi/com.raytheon.uf.edex.plugin.vaa/src/com/raytheon/uf/edex/plugin/vaa/VAARecordDao.java
deleted file mode 100644
index b404497892..0000000000
--- a/edexOsgi/com.raytheon.uf.edex.plugin.vaa/src/com/raytheon/uf/edex/plugin/vaa/VAARecordDao.java
+++ /dev/null
@@ -1,93 +0,0 @@
-/**
- * This software was developed and / or modified by Raytheon Company,
- * pursuant to Contract DG133W-05-CQ-1067 with the US Government.
- *
- * U.S. EXPORT CONTROLLED TECHNICAL DATA
- * This software product contains export-restricted data whose
- * export/transfer/disclosure is restricted by U.S. law. Dissemination
- * to non-U.S. persons whether in the United States or abroad requires
- * an export license or other authorization.
- *
- * Contractor Name: Raytheon Company
- * Contractor Address: 6825 Pine Street, Suite 340
- * Mail Stop B8
- * Omaha, NE 68106
- * 402.291.0100
- *
- * See the AWIPS II Master Rights File ("Master Rights File.pdf") for
- * further licensing information.
- **/
-package com.raytheon.uf.edex.plugin.vaa;
-
-import java.util.List;
-
-import com.raytheon.edex.db.dao.DefaultPluginDao;
-import com.raytheon.uf.common.dataplugin.PluginException;
-import com.raytheon.uf.common.dataplugin.vaa.VAARecord;
-import com.raytheon.uf.edex.database.DataAccessLayerException;
-
-/**
- *
- *
- *
- *
- * SOFTWARE HISTORY
- *
- * Date Ticket# Engineer Description
- * ------------ ---------- ----------- --------------------------
- * Nov 04, 2009 jkorman Initial creation
- *
- *
- *
- * @author jkorman
- * @version 1.0
- */
-public class VAARecordDao extends DefaultPluginDao {
-
- /**
- * Creates a new ObsStationDao
- * @throws PluginException
- */
- public VAARecordDao(String pluginName) throws PluginException {
- super(pluginName);
- }
-
- /**
- * Retrieves an Volcanic Ash report using the datauri .
- *
- * @param dataURI
- * The dataURI to match against.
- * @return The report record if it exists.
- */
- public VAARecord queryByDataURI(String dataURI) {
- VAARecord report = null;
- List> obs = null;
- try {
- obs = queryBySingleCriteria("dataURI", dataURI);
- } catch (DataAccessLayerException e) {
- e.printStackTrace();
- }
- if ((obs != null) && (obs.size() > 0)) {
- report = (VAARecord) obs.get(0);
- }
- return report;
- }
-
- /**
- * Queries for to determine if a given data uri exists on the sfcobs table.
- *
- * @param dataUri
- * The DataURI to find.
- * @return An array of objects. If not null, there should only be a single
- * element.
- */
- public Object[] queryDataUriColumn(final String dataUri) {
-
- String sql = "select datauri from awips.vaa where datauri='"
- + dataUri + "';";
-
- Object[] results = executeSQLQuery(sql);
-
- return results;
- }
-}
diff --git a/edexOsgi/com.raytheon.uf.edex.plugin.vaa/src/com/raytheon/uf/edex/plugin/vaa/decoder/InternalReport.java b/edexOsgi/com.raytheon.uf.edex.plugin.vaa/src/com/raytheon/uf/edex/plugin/vaa/decoder/InternalReport.java
index dce81be52e..7235b37dea 100644
--- a/edexOsgi/com.raytheon.uf.edex.plugin.vaa/src/com/raytheon/uf/edex/plugin/vaa/decoder/InternalReport.java
+++ b/edexOsgi/com.raytheon.uf.edex.plugin.vaa/src/com/raytheon/uf/edex/plugin/vaa/decoder/InternalReport.java
@@ -32,7 +32,7 @@ import com.raytheon.edex.esb.Headers;
import com.raytheon.uf.edex.wmo.message.WMOHeader;
/**
- * TODO Add Description
+ * Data structure for a Volcanic Ash Advisory
*
*
*
@@ -41,6 +41,7 @@ import com.raytheon.uf.edex.wmo.message.WMOHeader;
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Nov 19, 2009 jkorman Initial creation
+ * Nov 26, 2013 2582 njensen Fix where OBS DTG is on separate lines
*
*
*
@@ -49,22 +50,26 @@ import com.raytheon.uf.edex.wmo.message.WMOHeader;
*/
public class InternalReport {
- // private static Log logger = LogFactory.getLog(InternalReport.class);
- public static final String VAAC_CNTR_P = "^((VAAC)(?:\\:) +(.*))";
+ public static final Pattern VAAC_CNTR_P = Pattern
+ .compile("^((VAAC)(?:\\:) +(.*))");
// PSN: N1642 W06210
// LOCATION: N1642 W06210
- public static final String VOL_PSN_P = "(^(LOCATION|PSN)(?:\\:) +(.*))";
+ public static final Pattern VOL_PSN_P = Pattern
+ .compile("(^(LOCATION|PSN)(?:\\:) +(.*))");
- public static final String LAT_LON_P = "([NS])(\\d{2,2})(\\d{2,2}) +([EW])(\\d{3,3})(\\d{2,2})";
+ public static final Pattern LAT_LON_P = Pattern
+ .compile("([NS])(\\d{2,2})(\\d{2,2}) +([EW])(\\d{3,3})(\\d{2,2})");
- public static final String DTG_P = "^(OBS) +(VA|ASH) +DTG: +(.*)";
+ public static final Pattern DTG_P = Pattern
+ .compile("^(OBS) +(VA|ASH) +DTG: +(.*)");
- public static final String ANAL_P = "^(OBS) +(VA|ASH) +(CLD|CLOUD): +(.*)";
+ public static final Pattern ANAL_P = Pattern
+ .compile("^(OBS) +(VA|ASH) +(CLD|CLOUD): +(.*)");
- //
- public static final String FCST_P = "^(FCST) +(VA|ASH) +(CLD|CLOUD) \\+(\\d{1,2})HR: +(.*)";
+ public static final Pattern FCST_P = Pattern
+ .compile("^(FCST) +(VA|ASH) +(CLD|CLOUD) \\+(\\d{1,2})HR: +(.*)");
//
// public static final String DATE_LINE =
@@ -167,26 +172,21 @@ public class InternalReport {
}
List lines = separateLines(message);
if (lines != null) {
- Pattern p1 = Pattern.compile(VAAC_CNTR_P);
- Pattern p2 = Pattern.compile(VOL_PSN_P);
- Pattern p3 = Pattern.compile(FCST_P);
- Pattern p4 = Pattern.compile(ANAL_P);
- Pattern p5 = Pattern.compile(DTG_P);
-
Matcher m;
+ String previousLine = null;
for (String s : lines) {
if (s.length() > 0) {
- m = p1.matcher(s);
+ m = VAAC_CNTR_P.matcher(s);
if (m.find()) {
reports.add(new InternalReport(InternalType.VAAC_CNTR,
m.group(3)));
} else {
- m = p2.matcher(s);
+ m = VOL_PSN_P.matcher(s);
if (m.find()) {
reports.add(new InternalReport(
InternalType.VOLCANO_PSN, s));
} else {
- m = p3.matcher(s);
+ m = FCST_P.matcher(s);
if (m.find()) {
reports.add(new InternalReport(
InternalType.FCST, s));
@@ -196,9 +196,15 @@ public class InternalReport {
reports.add(new InternalReport(
InternalType.ADVISORY_LEAD, s));
} else if (s.startsWith("DTG:")) {
- reports.add(new InternalReport(
- InternalType.MESSAGE_DTG, s
- .substring(5)));
+ if (previousLine != null
+ && previousLine.startsWith("OBS")) {
+ reports.add(new InternalReport(
+ InternalType.OBS_DTG, s));
+ } else {
+ reports.add(new InternalReport(
+ InternalType.MESSAGE_DTG, s
+ .substring(5)));
+ }
} else if (s.startsWith("VOLCANO:")) {
reports.add(new InternalReport(
InternalType.VOLCANO_ID, s.substring(9)));
@@ -222,12 +228,12 @@ public class InternalReport {
InternalType.ERUPTION_DETAIL, s
.substring(18)));
} else if (s.startsWith("OBS")) {
- m = p4.matcher(s);
+ m = ANAL_P.matcher(s);
if (m.find()) {
reports.add(new InternalReport(
InternalType.OBS, s));
} else {
- m = p5.matcher(s);
+ m = DTG_P.matcher(s);
if (m.find()) {
reports.add(new InternalReport(
InternalType.OBS_DTG, s));
@@ -253,7 +259,7 @@ public class InternalReport {
}
}
}
-
+ previousLine = s;
} // for
}
return adjust(reports);
@@ -302,7 +308,6 @@ public class InternalReport {
* @return The adjusted report list.
*/
private static List adjust(List reports) {
- boolean advisoryLead = false;
if (reports != null) {
InternalReport currRpt = null;
for (int i = 0; i < reports.size();) {
@@ -314,7 +319,6 @@ public class InternalReport {
break;
}
case ADVISORY_LEAD: {
- advisoryLead = true;
// fall through
}
case MESSAGE_DTG:
@@ -360,11 +364,9 @@ public class InternalReport {
}
public static final void main(String[] args) {
-
- Pattern p = Pattern.compile(VOL_PSN_P);
Matcher m;
- m = p.matcher("PSN: N1642 W06210");
+ m = VOL_PSN_P.matcher("PSN: N1642 W06210");
if (m.find()) {
for (int i = 1; i <= m.groupCount(); i++) {
System.out.println(String.format(" %3d %s", i, m.group(i)));
@@ -372,7 +374,7 @@ public class InternalReport {
}
System.out
.println("--------------------------------------------------------");
- m = p.matcher("LOCATION: N1642 W06210");
+ m = VOL_PSN_P.matcher("LOCATION: N1642 W06210");
if (m.find()) {
for (int i = 1; i <= m.groupCount(); i++) {
System.out.println(String.format(" %3d %s", i, m.group(i)));
@@ -380,8 +382,7 @@ public class InternalReport {
}
System.out
.println("--------------------------------------------------------");
- p = Pattern.compile(VAAC_CNTR_P);
- m = p.matcher("VAAC: WASHINGTON");
+ m = VAAC_CNTR_P.matcher("VAAC: WASHINGTON");
if (m.find()) {
for (int i = 1; i <= m.groupCount(); i++) {
System.out.println(String.format(" %3d %s", i, m.group(i)));
@@ -389,8 +390,7 @@ public class InternalReport {
}
System.out
.println("--------------------------------------------------------");
- p = Pattern.compile(LAT_LON_P);
- m = p.matcher("N1642 W06210");
+ m = LAT_LON_P.matcher("N1642 W06210");
if (m.find()) {
for (int i = 1; i <= m.groupCount(); i++) {
System.out.println(String.format(" %3d %s", i, m.group(i)));
@@ -403,7 +403,7 @@ public class InternalReport {
String FCST_1_P = "(\\d{2}/\\d{4}Z +)";
- p = Pattern.compile(FCST_P);
+ Pattern p = Pattern.compile(FCST_P);
// m =
// p.matcher("FCST VA CLD +6HR: 05/0130Z SFC/FL220 5NM WIDE LINE N1638 W06614 - N1643 W06214");
// m =
diff --git a/edexOsgi/com.raytheon.uf.edex.plugin.vaa/src/com/raytheon/uf/edex/plugin/vaa/decoder/VAAParser.java b/edexOsgi/com.raytheon.uf.edex.plugin.vaa/src/com/raytheon/uf/edex/plugin/vaa/decoder/VAAParser.java
index 43b20a9e02..0dbd464a3f 100644
--- a/edexOsgi/com.raytheon.uf.edex.plugin.vaa/src/com/raytheon/uf/edex/plugin/vaa/decoder/VAAParser.java
+++ b/edexOsgi/com.raytheon.uf.edex.plugin.vaa/src/com/raytheon/uf/edex/plugin/vaa/decoder/VAAParser.java
@@ -36,7 +36,7 @@ import com.raytheon.uf.common.time.DataTime;
import com.raytheon.uf.edex.wmo.message.WMOHeader;
/**
- *
+ * Parser for Volcanic Ash Advisories
*
*
*
@@ -45,6 +45,7 @@ import com.raytheon.uf.edex.wmo.message.WMOHeader;
* ------------ ---------- ----------- --------------------------
* Nov 05, 2009 3267 jkorman Initial creation
* Aug 30, 2013 2298 rjpeter Make getPluginName abstract
+ * Nov 26, 2013 2582 njensen Cleanup
*
*
*
@@ -53,6 +54,7 @@ import com.raytheon.uf.edex.wmo.message.WMOHeader;
*/
public class VAAParser implements Iterable {
+ // TODO should use JTS coordinate
private static class LatLon {
public Double lat;
@@ -70,7 +72,21 @@ public class VAAParser implements Iterable {
public String shapeType;
}
- private final String pluginName;
+ private static final Pattern COR_P = Pattern.compile("(C[A-Z]{2})( +.*)?");
+
+ private static final Pattern SUMMIT_ELEV_P = Pattern
+ .compile("(\\d+) +FT +\\((\\d+) +[Mm]\\)");
+
+ private static final Pattern LINE_P = Pattern.compile("WID +LINE +BTN");
+
+ private static final Pattern DTG_P = Pattern.compile("(\\d{8}/\\d{4})(Z)");
+
+ private static final ThreadLocal SDF = new ThreadLocal() {
+ @Override
+ protected SimpleDateFormat initialValue() {
+ return new SimpleDateFormat("yyyyMMdd/HHmmZ");
+ }
+ };
private final WMOHeader wmoHeader;
@@ -78,17 +94,13 @@ public class VAAParser implements Iterable {
private final List records = new ArrayList();
- private List reports;
-
/**
*
* @param message
* @param wmoHeader
* @param pdd
*/
- public VAAParser(String name, byte[] message, String traceId,
- Headers headers) {
- pluginName = name;
+ public VAAParser(byte[] message, String traceId, Headers headers) {
this.traceId = traceId;
wmoHeader = new WMOHeader(message, headers);
setData(message, headers);
@@ -112,14 +124,15 @@ public class VAAParser implements Iterable {
*/
private void setData(byte[] message, Headers headers) {
- reports = InternalReport.identifyMessage(message, headers);
+ List reports = InternalReport.identifyMessage(message,
+ headers);
VAARecord vaa = new VAARecord();
vaa.setTraceId(traceId);
vaa.setWmoHeader(wmoHeader.getWmoHeader());
String cor = wmoHeader.getBBBIndicator();
if (cor != null) {
- Matcher m = Pattern.compile("(C[A-Z]{2})( +.*)?").matcher(cor);
+ Matcher m = COR_P.matcher(cor);
if (m.find()) {
vaa.setCorIndicator(m.group(1));
}
@@ -208,8 +221,7 @@ public class VAAParser implements Iterable {
*/
private LatLon parseLatLon(String latLon) {
LatLon latlon = null;
- Pattern p = Pattern.compile(InternalReport.LAT_LON_P);
- Matcher m = p.matcher(latLon);
+ Matcher m = InternalReport.LAT_LON_P.matcher(latLon);
if (m.find()) {
latlon = new LatLon();
latlon.lat = Double.parseDouble(m.group(2));
@@ -230,8 +242,7 @@ public class VAAParser implements Iterable {
*/
private int parseSummitElev(String summitElev) {
int elevation = -9999;
- Matcher m = Pattern.compile("(\\d+) +FT +\\((\\d+) +[Mm]\\)").matcher(
- summitElev);
+ Matcher m = SUMMIT_ELEV_P.matcher(summitElev);
if (m.find()) {
elevation = Integer.parseInt(m.group(2));
}
@@ -245,17 +256,15 @@ public class VAAParser implements Iterable {
DataTime dt = null;
// 20091104/1708Z
- SimpleDateFormat dtFmt = new SimpleDateFormat("yyyyMMdd/HHmmZ");
if (dtg != null) {
- Pattern p = Pattern.compile("(\\d{8}/\\d{4})(Z)");
- Matcher m = p.matcher(dtg);
+ Matcher m = DTG_P.matcher(dtg);
if (m.find()) {
if ("Z".equals(m.group(2))) {
dtg = m.group(1) + "GMT";
}
}
ParsePosition pos = new ParsePosition(0);
- Date d = dtFmt.parse(dtg, pos);
+ Date d = SDF.get().parse(dtg, pos);
if (pos.getErrorIndex() < 0) {
dt = new DataTime(d);
}
@@ -271,9 +280,7 @@ public class VAAParser implements Iterable {
*/
private void parseAnalData(InternalReport rpt, VAARecord vaa) {
String rptData = unPack(rpt, false);
-
- Pattern p = Pattern.compile(InternalReport.ANAL_P);
- Matcher m = p.matcher(rptData);
+ Matcher m = InternalReport.ANAL_P.matcher(rptData);
if (m.find()) {
if ("OBS".equals(m.group(1))) {
vaa.setAnal00Hr(unPack(rpt, true));
@@ -315,11 +322,9 @@ public class VAAParser implements Iterable {
*/
private void parseFcstData(InternalReport rpt, VAARecord vaa) {
String rptData = unPack(rpt, false);
-
String fcstPd = null;
- Pattern p = Pattern.compile(InternalReport.FCST_P);
- Matcher m = p.matcher(rptData);
+ Matcher m = InternalReport.FCST_P.matcher(rptData);
if (m.find()) {
if ("FCST".equals(m.group(1))) {
if ("6".equals(m.group(4))) {
@@ -368,19 +373,15 @@ public class VAAParser implements Iterable {
* @return
*/
private List parseFeature(String rptData) {
- Pattern latLonP = Pattern.compile(InternalReport.LAT_LON_P);
- Pattern lineP = Pattern.compile("WID +LINE +BTN");
- Pattern areaP = Pattern.compile(" ");
-
List features = new ArrayList();
String[] descriptions = rptData.split("SFC/");
if ((descriptions != null) && (descriptions.length > 1)) {
for (String description : descriptions) {
- Matcher m = lineP.matcher(description);
+ Matcher m = LINE_P.matcher(description);
if (m.find()) {
// parse as a line
- m = latLonP.matcher(description);
+ m = InternalReport.LAT_LON_P.matcher(description);
int pos = 0;
List points = new ArrayList();
while (m.find(pos)) {
@@ -398,7 +399,7 @@ public class VAAParser implements Iterable {
}
} else {
// handle as an area
- m = latLonP.matcher(description);
+ m = InternalReport.LAT_LON_P.matcher(description);
int pos = 0;
List points = new ArrayList();
while (m.find(pos)) {
@@ -473,7 +474,7 @@ public class VAAParser implements Iterable {
+ "\r\r\n\u0003";
Headers headers = new Headers();
headers.put("ingestFileName", "FVXX20.20110106");
- VAAParser p = new VAAParser("vaa", msg1.getBytes(), "TEST01", headers);
+ VAAParser p = new VAAParser(msg1.getBytes(), "TEST01", headers);
Iterator it = p.iterator();
while (it.hasNext()) {
VAARecord r = it.next();
@@ -481,39 +482,5 @@ public class VAAParser implements Iterable {
System.out.println(r.getMessage());
}
- // Matcher m =
- // Pattern.compile("(\\d+) +FT +\\((\\d+) +[Mm]\\)").matcher("3002 FT (915 M)");
- // if(m.find()) {
- // for(int i = 0;i <= m.groupCount();i++) {
- // System.out.println(m.group(i));
- // }
- // }
}
- // ashdescription ::= 'SFC' '/' 'FL' digit digit digit ( line | area ) (
- // movement ) .
- //
- // area ::= segments .
- //
- // line ::= digits 'NM' 'WID' 'LINE' 'BTN' segment '.' .
- //
- // movement ::=
- //
- // segments ::= segment ( spaces - spaces latlon ) .
- //
- // segment ::= latlon spaces - spaces latlon.
- //
- // latlon ::= lat spaces lon.
- //
- // lat ::= ['N' | 'S'] digit digit minutes .
- // lon ::= ['E' | 'W'] digit digit digit minutes . // 1(([0-7]\d)|(80))
- //
- // minutes ::= ( '0' | '1' | '2' | '3' | '4' | '5' ) digit .
- //
- // digits ::= digit ( digits ) .
- //
- // digit ::= '0' | '1' | '2' | '3' | '4' | '5' | '6' | '7' | '8' | '9' .
- //
- // spaces ::= space ( spaces ) .
- //
- // space ::= ' ' .
}