Omaha #3235 Properly clear the coordinates map. Switch to slf4j. Update manifest. Precompile patterns. Add some Javadoc.

Change-Id: I405b8abc09fcfd5346af1880fe0807bade54af37

Former-commit-id: 579f14356a [formerly 579f14356a [formerly b8d9c02463b595ac3adef027cd1f2a03ddc95e4e]]
Former-commit-id: 229783d3b0
Former-commit-id: 99c6d288fd
This commit is contained in:
Nathan Bowler 2014-06-24 09:28:51 -04:00
parent 4b343962dd
commit 91d5e4fcbb
6 changed files with 203 additions and 166 deletions

View file

@ -2,9 +2,9 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2 Bundle-ManifestVersion: 2
Bundle-Name: Tcg Plug-in Bundle-Name: Tcg Plug-in
Bundle-SymbolicName: com.raytheon.uf.edex.plugin.tcg Bundle-SymbolicName: com.raytheon.uf.edex.plugin.tcg
Bundle-Version: 1.12.1174.qualifier Bundle-Version: 1.14.0.qualifier
Bundle-Vendor: RAYTHEON Bundle-Vendor: RAYTHEON
Bundle-RequiredExecutionEnvironment: JavaSE-1.6 Bundle-RequiredExecutionEnvironment: JavaSE-1.7
Require-Bundle: com.raytheon.uf.common.dataplugin.tcg;bundle-version="1.0.0", Require-Bundle: com.raytheon.uf.common.dataplugin.tcg;bundle-version="1.0.0",
com.raytheon.uf.edex.decodertools, com.raytheon.uf.edex.decodertools,
com.raytheon.uf.common.pointdata, com.raytheon.uf.common.pointdata,
@ -14,11 +14,11 @@ Require-Bundle: com.raytheon.uf.common.dataplugin.tcg;bundle-version="1.0.0",
javax.measure, javax.measure,
com.raytheon.uf.edex.database, com.raytheon.uf.edex.database,
com.raytheon.uf.common.serialization, com.raytheon.uf.common.serialization,
com.raytheon.uf.common.dataplugin com.raytheon.uf.common.dataplugin,
org.slf4j
Import-Package: com.raytheon.edex.esb, Import-Package: com.raytheon.edex.esb,
com.raytheon.uf.common.datastorage.records, com.raytheon.uf.common.datastorage.records,
com.raytheon.uf.common.status, com.raytheon.uf.common.status,
com.raytheon.uf.common.time, com.raytheon.uf.common.time,
com.raytheon.uf.common.wmo, com.raytheon.uf.common.wmo,
com.raytheon.uf.edex.core, com.raytheon.uf.edex.core
org.apache.commons.logging

View file

@ -22,8 +22,8 @@ package com.raytheon.uf.edex.plugin.tcg;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import org.apache.commons.logging.Log; import org.slf4j.Logger;
import org.apache.commons.logging.LogFactory; import org.slf4j.LoggerFactory;
import com.raytheon.edex.esb.Headers; import com.raytheon.edex.esb.Headers;
import com.raytheon.uf.common.dataplugin.PluginDataObject; import com.raytheon.uf.common.dataplugin.PluginDataObject;
@ -42,6 +42,7 @@ import com.raytheon.uf.edex.plugin.tcg.decoder.TCGDataAdapter;
* ------------ ---------- ----------- -------------------------- * ------------ ---------- ----------- --------------------------
* Oct 28, 2009 jsanchez Initial creation * Oct 28, 2009 jsanchez Initial creation
* May 14, 2014 2536 bclement moved WMO Header to common * May 14, 2014 2536 bclement moved WMO Header to common
* Jun 24, 2014 3235 nabowle Switch to slf4j.
* *
* </pre> * </pre>
* *
@ -49,7 +50,8 @@ import com.raytheon.uf.edex.plugin.tcg.decoder.TCGDataAdapter;
* @version 1.0 * @version 1.0
*/ */
public class TCGDecoder { public class TCGDecoder {
private Log logger = LogFactory.getLog(getClass()); private static final Logger logger = LoggerFactory
.getLogger(TCGDecoder.class);
private final String pluginName; private final String pluginName;

View file

@ -1,19 +1,19 @@
/** /**
* This software was developed and / or modified by Raytheon Company, * This software was developed and / or modified by Raytheon Company,
* pursuant to Contract DG133W-05-CQ-1067 with the US Government. * pursuant to Contract DG133W-05-CQ-1067 with the US Government.
* *
* U.S. EXPORT CONTROLLED TECHNICAL DATA * U.S. EXPORT CONTROLLED TECHNICAL DATA
* This software product contains export-restricted data whose * This software product contains export-restricted data whose
* export/transfer/disclosure is restricted by U.S. law. Dissemination * export/transfer/disclosure is restricted by U.S. law. Dissemination
* to non-U.S. persons whether in the United States or abroad requires * to non-U.S. persons whether in the United States or abroad requires
* an export license or other authorization. * an export license or other authorization.
* *
* Contractor Name: Raytheon Company * Contractor Name: Raytheon Company
* Contractor Address: 6825 Pine Street, Suite 340 * Contractor Address: 6825 Pine Street, Suite 340
* Mail Stop B8 * Mail Stop B8
* Omaha, NE 68106 * Omaha, NE 68106
* 402.291.0100 * 402.291.0100
* *
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for * See the AWIPS II Master Rights File ("Master Rights File.pdf") for
* further licensing information. * further licensing information.
**/ **/
@ -23,6 +23,7 @@ import java.util.ArrayList;
import java.util.Calendar; import java.util.Calendar;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map.Entry;
import java.util.TimeZone; import java.util.TimeZone;
import java.util.regex.Matcher; import java.util.regex.Matcher;
import java.util.regex.Pattern; import java.util.regex.Pattern;
@ -36,19 +37,21 @@ import com.raytheon.uf.edex.plugin.tcg.TropicalCycloneGuidanceDao;
import com.vividsolutions.jts.geom.Coordinate; import com.vividsolutions.jts.geom.Coordinate;
/** /**
* TODO Add Description * Parses a subset of Tropical Cyclone Guidance data that contain multiple storm
* * track predictions from various models such as BAM(S/M/D) and LBAR.
*
* <pre> * <pre>
* *
* SOFTWARE HISTORY * SOFTWARE HISTORY
* *
* Date Ticket# Engineer Description * Date Ticket# Engineer Description
* ------------ ---------- ----------- -------------------------- * ------------ ---------- ----------- --------------------------
* Oct 26, 2009 jsanchez Initial creation * Oct 26, 2009 jsanchez Initial creation
* Aug 30, 2013 2298 rjpeter Make getPluginName abstract * Aug 30, 2013 2298 rjpeter Make getPluginName abstract
* * Jun 23, 2014 3235 nabowle Clear the coordinates map properly.
*
* </pre> * </pre>
* *
* @author jsanchez * @author jsanchez
* @version 1.0 * @version 1.0
*/ */
@ -68,6 +71,7 @@ public class HURData extends TCGDataAdapter {
List<TropicalCycloneGuidance> reports = new ArrayList<TropicalCycloneGuidance>(); List<TropicalCycloneGuidance> reports = new ArrayList<TropicalCycloneGuidance>();
List<InternalReport> parts = InternalReport.identifyMessage(message); List<InternalReport> parts = InternalReport.identifyMessage(message);
List<Coordinate> list;
if (parts != null) { if (parts != null) {
clearData(); clearData();
@ -83,8 +87,9 @@ public class HURData extends TCGDataAdapter {
} else if (InternalType.MODEL_INFO.equals(t)) { } else if (InternalType.MODEL_INFO.equals(t)) {
parseModelInfo(s); parseModelInfo(s);
} else if (InternalType.END.equals(t)) { } else if (InternalType.END.equals(t)) {
for (String model : coordinates.keySet()) { for (Entry<String, List<Coordinate>> entry : coordinates
List<Coordinate> list = coordinates.get(model); .entrySet()) {
list = entry.getValue();
if (list.size() == forecastTimes.size()) { if (list.size() == forecastTimes.size()) {
for (int i = 0; i < list.size(); i++) { for (int i = 0; i < list.size(); i++) {
TropicalCycloneGuidance rpt = new TropicalCycloneGuidance(); TropicalCycloneGuidance rpt = new TropicalCycloneGuidance();
@ -98,7 +103,7 @@ public class HURData extends TCGDataAdapter {
rpt.setStormName(stormName); rpt.setStormName(stormName);
rpt.setType(stormType); rpt.setType(stormType);
rpt.setProductType(productType); rpt.setProductType(productType);
rpt.setModelName(model); rpt.setModelName(entry.getKey());
rpt.setLocation(location); rpt.setLocation(location);
rpt.setInsertTime(Calendar.getInstance(TimeZone rpt.setInsertTime(Calendar.getInstance(TimeZone
.getTimeZone("GMT"))); .getTimeZone("GMT")));
@ -131,16 +136,14 @@ public class HURData extends TCGDataAdapter {
} }
private void parseModelInfo(String modelInfo) { private void parseModelInfo(String modelInfo) {
Pattern modelPtrn = Pattern.compile(InternalReport.MODEL_PTRN); Matcher m = InternalReport.MODEL_PTRN.matcher(modelInfo);
Pattern latlonPtrn = Pattern.compile(InternalReport.LATLON_PTRN);
Matcher m = modelPtrn.matcher(modelInfo);
if (m.find()) { if (m.find()) {
String model = m.group(); String model = m.group();
List<Coordinate> coordinate = coordinates.get(model); List<Coordinate> coordinate = coordinates.get(model);
if (coordinate == null) { if (coordinate == null) {
coordinate = new ArrayList<Coordinate>(); coordinate = new ArrayList<Coordinate>();
} }
m = latlonPtrn.matcher(modelInfo); m = InternalReport.LATLON_PTRN.matcher(modelInfo);
while (m.find()) { while (m.find()) {
String latlon[] = m.group().split(" "); String latlon[] = m.group().split(" ");
int n = latlon.length - 1; int n = latlon.length - 1;
@ -214,16 +217,9 @@ public class HURData extends TCGDataAdapter {
} }
} }
private void refreshMaps() {
coordinates.put("BAMS", null);
coordinates.put("BAMD", null);
coordinates.put("BAMD", null);
coordinates.put("LBAR", null);
}
@Override @Override
public void clearData() { public void clearData() {
refreshMaps(); coordinates.clear();
forecastTimes.clear(); forecastTimes.clear();
stationId = null; stationId = null;
stormType = TCGStormType.UNKNOWN; stormType = TCGStormType.UNKNOWN;

View file

@ -1,19 +1,19 @@
/** /**
* This software was developed and / or modified by Raytheon Company, * This software was developed and / or modified by Raytheon Company,
* pursuant to Contract DG133W-05-CQ-1067 with the US Government. * pursuant to Contract DG133W-05-CQ-1067 with the US Government.
* *
* U.S. EXPORT CONTROLLED TECHNICAL DATA * U.S. EXPORT CONTROLLED TECHNICAL DATA
* This software product contains export-restricted data whose * This software product contains export-restricted data whose
* export/transfer/disclosure is restricted by U.S. law. Dissemination * export/transfer/disclosure is restricted by U.S. law. Dissemination
* to non-U.S. persons whether in the United States or abroad requires * to non-U.S. persons whether in the United States or abroad requires
* an export license or other authorization. * an export license or other authorization.
* *
* Contractor Name: Raytheon Company * Contractor Name: Raytheon Company
* Contractor Address: 6825 Pine Street, Suite 340 * Contractor Address: 6825 Pine Street, Suite 340
* Mail Stop B8 * Mail Stop B8
* Omaha, NE 68106 * Omaha, NE 68106
* 402.291.0100 * 402.291.0100
* *
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for * See the AWIPS II Master Rights File ("Master Rights File.pdf") for
* further licensing information. * further licensing information.
**/ **/
@ -28,12 +28,12 @@ import java.util.List;
import java.util.regex.Matcher; import java.util.regex.Matcher;
import java.util.regex.Pattern; import java.util.regex.Pattern;
import org.apache.commons.logging.Log; import org.slf4j.Logger;
import org.apache.commons.logging.LogFactory; import org.slf4j.LoggerFactory;
/** /**
* TODO Add Description * TODO Add Description
* *
* <pre> * <pre>
* *
* SOFTWARE HISTORY * SOFTWARE HISTORY
@ -41,95 +41,126 @@ import org.apache.commons.logging.LogFactory;
* Date Ticket# Engineer Description * Date Ticket# Engineer Description
* ------------ ---------- ----------- -------------------------- * ------------ ---------- ----------- --------------------------
* Oct 26, 2009 jsanchez Initial creation * Oct 26, 2009 jsanchez Initial creation
* Jun 24, 2014 3235 nabowle Switch to slf4j. Precompile patterns.
* *
* </pre> * </pre>
* *
* @author jsanchez * @author jsanchez
* @version 1.0 * @version 1.0
*/ */
public class InternalReport { public class InternalReport {
private static Log logger = LogFactory.getLog(InternalReport.class); private static final Logger LOGGER = LoggerFactory
.getLogger(InternalReport.class);
//CHGHUR or CHGQLM or TCEAT4
public static final String PRODUCT_PTRN = "^((CHG|TCE)(.*))"; // CHGHUR or CHGQLM or TCEAT4
public static final Pattern PRODUCT_PTRN = Pattern
.compile("^((CHG|TCE)(.*))");
/* /*
* Below are patterns mostly used for CHGQLM * Below are patterns mostly used for CHGQLM
*/ */
//TROPICAL STORM IDA 11L // TROPICAL STORM IDA 11L
public static final String STORM_TYPE_INFO = "^((TROPICAL|HURRICANE|TYPHOON|EXTRATROPICAL|DISTURBANCE) +(.*))"; public static final Pattern STORM_TYPE_INFO = Pattern
.compile("^((TROPICAL|HURRICANE|TYPHOON|EXTRATROPICAL|DISTURBANCE) +(.*))");
public static final String HOUR_PTRN = "(\\d{1,2})"; public static final String HOUR_PTRN = "(\\d{1,2})";
public static final String MONTH_PTRN = "(\\w{3,3})"; public static final String MONTH_PTRN = "(\\w{3,3})";
public static final String DAY_PTRN = "(\\d{1,2})"; public static final String DAY_PTRN = "(\\d{1,2})";
//INITIAL TIME 18Z NOV 4
public static final String INIT_TIME_INFO = "^((INITIAL TIME)(\\s{2,3})" + HOUR_PTRN + "Z " + MONTH_PTRN + "(\\s{1,2})" + DAY_PTRN + ")"; // INITIAL TIME 18Z NOV 4
public static final Pattern INIT_TIME_INFO = Pattern
// 18 12.1 82.2 47./ 1.7 .compile("^((INITIAL TIME)(\\s{2,3})" + HOUR_PTRN + "Z "
public static final String FORECAST_POSITION_INFO = "^((\\s{1,3})(\\d{1,3})(\\s{12,14})((\\d{0,2}).\\d) +(.*))"; + MONTH_PTRN + "(\\s{1,2})" + DAY_PTRN + ")");
// 18 12.1 82.2 47./ 1.7
public static final Pattern FORECAST_POSITION_INFO = Pattern
.compile("^((\\s{1,3})(\\d{1,3})(\\s{12,14})((\\d{0,2}).\\d) +(.*))");
/* /*
* Below are patterns mostly used for CHGHUR * Below are patterns mostly used for CHGHUR
*/ */
//16.5N 102.2W public static final String LATLON = "(((\\d{0,2}|90).\\d{1,1}[NS])(\\s{1,4})(\\d{0,3}.\\d{1,1}[EW]))";
public static final String LATLON_PTRN ="(((\\d{0,2}|90).\\d{1,1}[NS])(\\s{1,4})(\\d{0,3}.\\d{1,1}[EW]))";
//BAMS // 16.5N 102.2W
public static final String MODEL_PTRN ="(\\w{4,4})"; public static final Pattern LATLON_PTRN = Pattern.compile(LATLON);
//BAMS 16.5N 102.2W 17.5N 102.0W 18.2N 101.7W 18.6N 102.0W public static final String MODEL = "(\\w{4,4})";
public static final String MODEL_INFO ="^(" + MODEL_PTRN + "(\\s{4,4})" + LATLON_PTRN + "+(.*))";
// BAMS
//091029 1200 public static final Pattern MODEL_PTRN = Pattern.compile(MODEL);
public static final String DATETIME= "(\\d{6,6}\\s{2,2}\\d{4,4})";
// BAMS 16.5N 102.2W 17.5N 102.0W 18.2N 101.7W 18.6N 102.0W
// 091029 1200 091030 0000 091030 1200 091031 0000 public static final Pattern MODEL_INFO = Pattern.compile("^(" + MODEL
public static final String DATETIME_INFO = "((.*)" + DATETIME + "+(.*))"; + "(\\s{4,4})" + LATLON + "+(.*))");
//(EP952009) // 091029 1200
public static final String DATETIME = "(\\d{6,6}\\s{2,2}\\d{4,4})";
// 091029 1200 091030 0000 091030 1200 091031 0000
public static final Pattern DATETIME_INFO = Pattern.compile("((.*)"
+ DATETIME + "+(.*))");
// (EP952009)
public static final String STATIONID_PTRN = "\\(\\w{2,2}\\d{6,6}\\)"; public static final String STATIONID_PTRN = "\\(\\w{2,2}\\d{6,6}\\)";
//20091029 1200 // 20091029 1200
public static final String REFTIME_PTRN = "(\\d{8,8} \\d{4,4})"; public static final String REFTIME_PTRN = "(\\d{8,8} \\d{4,4})";
//DISTURBANCE INVEST (EP952009) 20091029 1200 UTC // DISTURBANCE INVEST (EP952009) 20091029 1200 UTC
public static final String DATA_INFO = "((.*) " + STATIONID_PTRN + " " + REFTIME_PTRN + " " + "UTC)"; public static final Pattern DATA_INFO = Pattern.compile("((.*) "
+ STATIONID_PTRN + " " + REFTIME_PTRN + " " + "UTC)");
// ...INITIAL CONDITIONS...
public static final String INIT_CONDITION_PTRN = "((.*)(...INITIAL CONDITIONS...)+(.*))"; // ...INITIAL CONDITIONS...
public static final Pattern INIT_CONDITION_PTRN = Pattern
//STORM DISSIPATED AT 54 HRS AT THE ABOVE PSN. .compile("((.*)(...INITIAL CONDITIONS...)+(.*))");
public static final String STORM_DISSIPATED = "^(STORM DISSIPATED +(.*))";
// STORM DISSIPATED AT 54 HRS AT THE ABOVE PSN.
public static final Pattern STORM_DISSIPATED = Pattern
.compile("^(STORM DISSIPATED +(.*))");
/* /*
* Below are used for TCE * Below are used for TCE
*/ */
public static final String NWS_INFO = "^((NWS TPC)(.*)(\\w{2,2}\\d{6,6}))"; public static final Pattern NWS_INFO = Pattern
//1100 PM CDT FRI SEP 12 2008 .compile("^((NWS TPC)(.*)(\\w{2,2}\\d{6,6}))");
public static final String TCE_REFTIME_INFO = "^(\\d{3,4} (AM|PM) \\w{3,3} \\w{3,3} \\w{3,3}\\s{1,2}\\d{1,2}(.*))";
// 1100 PM CDT FRI SEP 12 2008
public static final String TCE_REFHOUR = "^((.*)(\\.\\.\\.\\d{4,4}Z\\.\\.\\.)(.*))"; public static final Pattern TCE_REFTIME_INFO = Pattern
.compile("^(\\d{3,4} (AM|PM) \\w{3,3} \\w{3,3} \\w{3,3}\\s{1,2}\\d{1,2}(.*))");
public static final String LAT_PTRN = "(LATITUDE \\d{0,2}.\\d)";
//RESERVE UNIT RECONNAISSANCE AIRCRAFT...TO BE NEAR LATITUDE 28.7 public static final Pattern TCE_REFHOUR = Pattern
public static final String LATITUDE_INFO = "^((.*)" + LAT_PTRN + "(.*))"; .compile("^((.*)(\\.\\.\\.\\d{4,4}Z\\.\\.\\.)(.*))");
public static final String LON_PTRN = "(LONGITUDE \\d{0,3}.\\d)"; public static final Pattern LAT_PTRN = Pattern
//NORTH...LONGITUDE 94.5 WEST OR ABOUT 45 MILES...75 KM... .compile("(LATITUDE \\d{0,2}.\\d)");
public static final String LONGITUDE_INFO = "^((.*)" + LON_PTRN + "(.*))";
//FORECASTER STEWART // RESERVE UNIT RECONNAISSANCE AIRCRAFT...TO BE NEAR LATITUDE 28.7
public static final String FORECASTER_PTRN = "^((FORECASTER)(.*))"; public static final Pattern LATITUDE_INFO = Pattern.compile("^((.*)"
+ LAT_PTRN + "(.*))");
public static final Pattern LON_PTRN = Pattern
.compile("(LONGITUDE \\d{0,3}.\\d)");
// NORTH...LONGITUDE 94.5 WEST OR ABOUT 45 MILES...75 KM...
public static final Pattern LONGITUDE_INFO = Pattern.compile("^((.*)"
+ LON_PTRN + "(.*))");
// FORECASTER STEWART
public static final Pattern FORECASTER_PTRN = Pattern
.compile("^((FORECASTER)(.*))");
private final InternalType lineType; private final InternalType lineType;
private final String reportLine; private final String reportLine;
private List<InternalReport> subLines = null; private List<InternalReport> subLines = null;
public InternalReport(InternalType type, String line) { public InternalReport(InternalType type, String line) {
lineType = type; lineType = type;
reportLine = line; reportLine = line;
@ -150,21 +181,22 @@ public class InternalReport {
} }
/** /**
* *
* @return * @return
*/ */
public List<InternalReport> getSubLines() { public List<InternalReport> getSubLines() {
return subLines; return subLines;
} }
/** /**
* *
* @param buffer Buffer to receive String formatted internal data. If this * @param buffer
* reference is null, a new StringBuilder instance is created. * Buffer to receive String formatted internal data. If this
* reference is null, a new StringBuilder instance is created.
* @return The populated StringBuilder instance. * @return The populated StringBuilder instance.
*/ */
public StringBuilder toString(StringBuilder buffer) { public StringBuilder toString(StringBuilder buffer) {
if(buffer == null) { if (buffer == null) {
buffer = new StringBuilder(); buffer = new StringBuilder();
} }
buffer.append("["); buffer.append("[");
@ -174,16 +206,17 @@ public class InternalReport {
buffer.append("}\n"); buffer.append("}\n");
return buffer; return buffer;
} }
/** /**
* Create a string representation of this class instance. * Create a string representation of this class instance.
*
* @return The string representation of this class instance. * @return The string representation of this class instance.
*/ */
@Override @Override
public String toString() { public String toString() {
StringBuilder sb = toString(null); StringBuilder sb = toString(null);
if(subLines != null) { if (subLines != null) {
for(InternalReport r : subLines) { for (InternalReport r : subLines) {
sb.append(" "); sb.append(" ");
r.toString(sb); r.toString(sb);
} }
@ -191,26 +224,26 @@ public class InternalReport {
return sb.toString(); return sb.toString();
} }
public static List<InternalReport> identifyMessage(byte [] message) { public static List<InternalReport> identifyMessage(byte[] message) {
List<InternalReport> reports = new ArrayList<InternalReport>(); List<InternalReport> reports = new ArrayList<InternalReport>();
List<String> lines = separateLines(message); List<String> lines = separateLines(message);
if(lines != null) { if (lines != null) {
Pattern p1 = Pattern.compile(PRODUCT_PTRN); Pattern p1 = PRODUCT_PTRN;
Pattern p2 = Pattern.compile(DATA_INFO); Pattern p2 = DATA_INFO;
Pattern p3 = Pattern.compile(DATETIME_INFO); Pattern p3 = DATETIME_INFO;
Pattern p4 = Pattern.compile(MODEL_INFO); Pattern p4 = MODEL_INFO;
Pattern p5 = Pattern.compile(INIT_CONDITION_PTRN); Pattern p5 = INIT_CONDITION_PTRN;
Pattern p6 = Pattern.compile(STORM_TYPE_INFO); Pattern p6 = STORM_TYPE_INFO;
Pattern p7 = Pattern.compile(INIT_TIME_INFO); Pattern p7 = INIT_TIME_INFO;
Pattern p8 = Pattern.compile(FORECAST_POSITION_INFO); Pattern p8 = FORECAST_POSITION_INFO;
Pattern p9 = Pattern.compile(STORM_DISSIPATED); Pattern p9 = STORM_DISSIPATED;
Pattern p10 = Pattern.compile(NWS_INFO); Pattern p10 = NWS_INFO;
Pattern p11 = Pattern.compile(TCE_REFTIME_INFO); Pattern p11 = TCE_REFTIME_INFO;
Pattern p12 = Pattern.compile(LATITUDE_INFO); Pattern p12 = LATITUDE_INFO;
Pattern p13 = Pattern.compile(LONGITUDE_INFO); Pattern p13 = LONGITUDE_INFO;
Pattern p14 = Pattern.compile(FORECASTER_PTRN); Pattern p14 = FORECASTER_PTRN;
Pattern p15 = Pattern.compile(TCE_REFHOUR); Pattern p15 = TCE_REFHOUR;
InternalType t1 = InternalType.PRODUCT; InternalType t1 = InternalType.PRODUCT;
InternalType t2 = InternalType.DATA_INFO; InternalType t2 = InternalType.DATA_INFO;
InternalType t3 = InternalType.DATETIME_INFO; InternalType t3 = InternalType.DATETIME_INFO;
@ -226,15 +259,17 @@ public class InternalReport {
InternalType t13 = InternalType.LONGITUDE; InternalType t13 = InternalType.LONGITUDE;
InternalType t14 = InternalType.END; InternalType t14 = InternalType.END;
InternalType t15 = InternalType.TCE_REFHOUR; InternalType t15 = InternalType.TCE_REFHOUR;
Pattern patterns[] = {p1,p2,p3,p4,p5,p6,p7,p8,p9,p10,p11,p12,p13,p14,p15}; Pattern patterns[] = { p1, p2, p3, p4, p5, p6, p7, p8, p9, p10,
InternalType types[] = {t1,t2,t3,t4,t5,t6,t7,t8,t9,t10,t11,t12,t13,t14,t15}; p11, p12, p13, p14, p15 };
InternalType types[] = { t1, t2, t3, t4, t5, t6, t7, t8, t9, t10,
for(String s : lines) { t11, t12, t13, t14, t15 };
for(int i = 0; i < patterns.length; i++){
for (String s : lines) {
for (int i = 0; i < patterns.length; i++) {
Matcher m = patterns[i].matcher(s); Matcher m = patterns[i].matcher(s);
if(m.matches()){ if (m.matches()) {
InternalReport rptLine = new InternalReport(types[i],s); InternalReport rptLine = new InternalReport(types[i], s);
reports.add(rptLine); reports.add(rptLine);
break; break;
} }
@ -244,9 +279,9 @@ public class InternalReport {
} }
return reports; return reports;
} }
/** /**
* *
* @param message * @param message
* @return * @return
*/ */
@ -266,18 +301,18 @@ public class InternalReport {
} }
} }
} catch (Exception e) { } catch (Exception e) {
logger.error("Error reading from reader",e); LOGGER.error("Error reading from reader", e);
} finally { } finally {
if (reader != null) { if (reader != null) {
try { try {
reader.close(); reader.close();
} catch (IOException ioe) { } catch (IOException ioe) {
logger.error("Error closing reader", ioe); LOGGER.error("Error closing reader", ioe);
} }
} }
} }
} }
return reportLines; return reportLines;
} }
} }

View file

@ -1,19 +1,19 @@
/** /**
* This software was developed and / or modified by Raytheon Company, * This software was developed and / or modified by Raytheon Company,
* pursuant to Contract DG133W-05-CQ-1067 with the US Government. * pursuant to Contract DG133W-05-CQ-1067 with the US Government.
* *
* U.S. EXPORT CONTROLLED TECHNICAL DATA * U.S. EXPORT CONTROLLED TECHNICAL DATA
* This software product contains export-restricted data whose * This software product contains export-restricted data whose
* export/transfer/disclosure is restricted by U.S. law. Dissemination * export/transfer/disclosure is restricted by U.S. law. Dissemination
* to non-U.S. persons whether in the United States or abroad requires * to non-U.S. persons whether in the United States or abroad requires
* an export license or other authorization. * an export license or other authorization.
* *
* Contractor Name: Raytheon Company * Contractor Name: Raytheon Company
* Contractor Address: 6825 Pine Street, Suite 340 * Contractor Address: 6825 Pine Street, Suite 340
* Mail Stop B8 * Mail Stop B8
* Omaha, NE 68106 * Omaha, NE 68106
* 402.291.0100 * 402.291.0100
* *
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for * See the AWIPS II Master Rights File ("Master Rights File.pdf") for
* further licensing information. * further licensing information.
**/ **/
@ -35,23 +35,29 @@ import com.raytheon.uf.edex.plugin.tcg.TropicalCycloneGuidanceDao;
/** /**
* TODO Add Description * TODO Add Description
* *
* <pre> * <pre>
* *
* SOFTWARE HISTORY * SOFTWARE HISTORY
* *
* Date Ticket# Engineer Description * Date Ticket# Engineer Description
* ------------ ---------- ----------- -------------------------- * ------------ ---------- ----------- --------------------------
* Nov 12, 2009 jsanchez Initial creation * Nov 12, 2009 jsanchez Initial creation
* Aug 30, 2013 2298 rjpeter Make getPluginName abstract * Aug 30, 2013 2298 rjpeter Make getPluginName abstract
* * Jun 24, 2014 3235 nabowle InternalReport patterns are now
* precompiled.
*
* </pre> * </pre>
* *
* @author jsanchez * @author jsanchez
* @version 1.0 * @version 1.0
*/ */
public class TCEData extends TCGDataAdapter { public class TCEData extends TCGDataAdapter {
private static final Pattern STATION_ID_PATTERN = Pattern.compile("(\\w{2,2}\\d{6,6})");
private static final Pattern REF_HOUR_PATTERN = Pattern.compile("(\\d{4,4})");
private float latitude = -9999; private float latitude = -9999;
private float longitude = -9999; private float longitude = -9999;
@ -132,8 +138,7 @@ public class TCEData extends TCGDataAdapter {
} }
private void parseStationIdInfo(String stationIdInfo) { private void parseStationIdInfo(String stationIdInfo) {
Pattern p = Pattern.compile("(\\w{2,2}\\d{6,6})"); Matcher m = STATION_ID_PATTERN.matcher(stationIdInfo);
Matcher m = p.matcher(stationIdInfo);
if (m.find()) { if (m.find()) {
stationId = m.group(); stationId = m.group();
} }
@ -147,8 +152,7 @@ public class TCEData extends TCGDataAdapter {
} }
private void parseRefhour(String refhourInfo) { private void parseRefhour(String refhourInfo) {
Pattern p = Pattern.compile("(\\d{4,4})"); Matcher m = REF_HOUR_PATTERN.matcher(refhourInfo);
Matcher m = p.matcher(refhourInfo);
if (m.find()) { if (m.find()) {
hour = Integer.parseInt(m.group().substring(0, 2)); hour = Integer.parseInt(m.group().substring(0, 2));
minute = Integer.parseInt(m.group().substring(2)); minute = Integer.parseInt(m.group().substring(2));
@ -156,8 +160,7 @@ public class TCEData extends TCGDataAdapter {
} }
private void parseLatitude(String latitudeInfo) { private void parseLatitude(String latitudeInfo) {
Pattern p = Pattern.compile(InternalReport.LAT_PTRN); Matcher m = InternalReport.LAT_PTRN.matcher(latitudeInfo);
Matcher m = p.matcher(latitudeInfo);
if (m.find()) { if (m.find()) {
latitude = Float.parseFloat(m.group().substring(8).trim()); latitude = Float.parseFloat(m.group().substring(8).trim());
if (latitudeInfo.contains("SOUTH")) { if (latitudeInfo.contains("SOUTH")) {
@ -168,8 +171,7 @@ public class TCEData extends TCGDataAdapter {
} }
private void parseLongitude(String longitudeInfo) { private void parseLongitude(String longitudeInfo) {
Pattern p = Pattern.compile(InternalReport.LON_PTRN); Matcher m = InternalReport.LON_PTRN.matcher(longitudeInfo);
Matcher m = p.matcher(longitudeInfo);
if (m.find()) { if (m.find()) {
longitude = Float.parseFloat(m.group().substring(10).trim()); longitude = Float.parseFloat(m.group().substring(10).trim());
if (longitudeInfo.contains("WEST")) { if (longitudeInfo.contains("WEST")) {

View file

@ -1,19 +1,19 @@
/** /**
* This software was developed and / or modified by Raytheon Company, * This software was developed and / or modified by Raytheon Company,
* pursuant to Contract DG133W-05-CQ-1067 with the US Government. * pursuant to Contract DG133W-05-CQ-1067 with the US Government.
* *
* U.S. EXPORT CONTROLLED TECHNICAL DATA * U.S. EXPORT CONTROLLED TECHNICAL DATA
* This software product contains export-restricted data whose * This software product contains export-restricted data whose
* export/transfer/disclosure is restricted by U.S. law. Dissemination * export/transfer/disclosure is restricted by U.S. law. Dissemination
* to non-U.S. persons whether in the United States or abroad requires * to non-U.S. persons whether in the United States or abroad requires
* an export license or other authorization. * an export license or other authorization.
* *
* Contractor Name: Raytheon Company * Contractor Name: Raytheon Company
* Contractor Address: 6825 Pine Street, Suite 340 * Contractor Address: 6825 Pine Street, Suite 340
* Mail Stop B8 * Mail Stop B8
* Omaha, NE 68106 * Omaha, NE 68106
* 402.291.0100 * 402.291.0100
* *
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for * See the AWIPS II Master Rights File ("Master Rights File.pdf") for
* further licensing information. * further licensing information.
**/ **/
@ -26,8 +26,8 @@ import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.TimeZone; import java.util.TimeZone;
import org.apache.commons.logging.Log; import org.slf4j.Logger;
import org.apache.commons.logging.LogFactory; import org.slf4j.LoggerFactory;
import com.raytheon.edex.esb.Headers; import com.raytheon.edex.esb.Headers;
import com.raytheon.uf.common.dataplugin.tcg.TCGStormType; import com.raytheon.uf.common.dataplugin.tcg.TCGStormType;
@ -40,7 +40,7 @@ import com.raytheon.uf.common.wmo.WMOHeader;
import com.raytheon.uf.edex.plugin.tcg.TropicalCycloneGuidanceDao; import com.raytheon.uf.edex.plugin.tcg.TropicalCycloneGuidanceDao;
/** /**
* TODO Add Description * Base class for Tropical Cyclone Guidance (TCG) products.
* *
* <pre> * <pre>
* *
@ -52,6 +52,7 @@ import com.raytheon.uf.edex.plugin.tcg.TropicalCycloneGuidanceDao;
* Jun 28, 2012 #826 dgilling Ensure getDataTime properly * Jun 28, 2012 #826 dgilling Ensure getDataTime properly
* handles time zones. * handles time zones.
* May 14, 2014 2536 bclement moved WMO Header to common, removed constructDataURI() call * May 14, 2014 2536 bclement moved WMO Header to common, removed constructDataURI() call
* Jun 24, 2014 3235 nabowle Switch to slf4j.
* *
* </pre> * </pre>
* *
@ -60,7 +61,8 @@ import com.raytheon.uf.edex.plugin.tcg.TropicalCycloneGuidanceDao;
*/ */
public abstract class TCGDataAdapter { public abstract class TCGDataAdapter {
protected static Log logger = LogFactory.getLog(TCGDataAdapter.class); protected static Logger logger = LoggerFactory
.getLogger(TCGDataAdapter.class);
protected PointDataDescription pointDataDescription; protected PointDataDescription pointDataDescription;
@ -136,7 +138,7 @@ public abstract class TCGDataAdapter {
/** /**
* Does this parser contain any more reports. * Does this parser contain any more reports.
* *
* @return Does this parser contain any more reports. * @return Does this parser contain any more reports.
*/ */
public boolean hasNext() { public boolean hasNext() {
@ -154,7 +156,7 @@ public abstract class TCGDataAdapter {
/** /**
* Get the next available report. Returns a null reference if no more * Get the next available report. Returns a null reference if no more
* reports are available. * reports are available.
* *
* @return The next available report. * @return The next available report.
*/ */
public TropicalCycloneGuidance next() { public TropicalCycloneGuidance next() {
@ -200,7 +202,7 @@ public abstract class TCGDataAdapter {
} }
/** /**
* *
* @param obsData * @param obsData
* @return * @return
*/ */