Omaha #3629 Replacing matchElement()
Change-Id: Ie8ae1347a1aeb99532e42c7a3af7d200cf4c3a1e Former-commit-id:776420f2d9
[formerly6a0703ad98
[formerly6d59eb314d
] [formerly776420f2d9
[formerly 6f898cc3d7f30651846847c5645ec26ac448ec83]]] Former-commit-id:6a0703ad98
[formerly6d59eb314d
] Former-commit-id:6a0703ad98
Former-commit-id:17f328433b
This commit is contained in:
parent
90437c8065
commit
4cfbeb826a
20 changed files with 219 additions and 136 deletions
|
@ -47,6 +47,7 @@ import com.raytheon.uf.edex.decodertools.time.TimeTools;
|
|||
* 20071010 391 jkorman Initial coding.
|
||||
* Sep 18, 2014 3627 mapeters Updated deprecated {@link TimeTools} usage.
|
||||
* Sep 26, 2014 3629 mapeters Replaced static imports.
|
||||
* Sep 30, 2014 3629 mapeters Replaced {@link AbstractSfcObsDecoder#matchElement()} calls.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -110,17 +111,13 @@ public class DRIBUSec1Decoder extends AbstractSectionDecoder {
|
|||
break;
|
||||
}
|
||||
|
||||
if (AbstractSfcObsDecoder.matchElement(element,
|
||||
DRIBUSec2Decoder.SEC_2_PATTERN)) {
|
||||
if (DRIBUSec2Decoder.SEC_2_PATTERN.matcher(element).find()) {
|
||||
break;
|
||||
} else if (AbstractSfcObsDecoder.matchElement(element,
|
||||
ISynoptic.SEC_3_LEAD)) {
|
||||
} else if (ISynoptic.SEC_3_LEAD_PATTERN.matcher(element).find()) {
|
||||
break;
|
||||
} else if (AbstractSfcObsDecoder.matchElement(element,
|
||||
ISynoptic.SEC_4_LEAD)) {
|
||||
} else if (ISynoptic.SEC_4_LEAD_PATTERN.matcher(element).find()) {
|
||||
break;
|
||||
} else if (AbstractSfcObsDecoder.matchElement(element,
|
||||
ISynoptic.SEC_5_LEAD)) {
|
||||
} else if (ISynoptic.SEC_5_LEAD_PATTERN.matcher(element).find()) {
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
|
@ -49,6 +49,8 @@ import com.raytheon.uf.edex.decodertools.core.IDecoderConstants;
|
|||
* ------------ ---------- ----------- --------------------------
|
||||
* 20071010 391 jkorman Initial coding.
|
||||
* Sep 26, 2014 3629 mapeters Removed unused fields, replaced static imports.
|
||||
* Sep 30, 2014 3629 mapeters Replaced {@link AbstractSfcObsDecoder#matchElement()}
|
||||
* calls, changed SEC_2_PATTERN from String to Pattern.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -57,7 +59,7 @@ import com.raytheon.uf.edex.decodertools.core.IDecoderConstants;
|
|||
*/
|
||||
public class DRIBUSec2Decoder extends AbstractSectionDecoder {
|
||||
|
||||
public static final String SEC_2_PATTERN = "222[/0-9]{2}";
|
||||
public static final Pattern SEC_2_PATTERN = Pattern.compile("222[/0-9]{2}");
|
||||
|
||||
private DataItem seaTemp = null;
|
||||
|
||||
|
@ -84,7 +86,6 @@ public class DRIBUSec2Decoder extends AbstractSectionDecoder {
|
|||
* Thrown when an relevant error has occurred.
|
||||
*/
|
||||
public void decode(ReportParser reportParser) throws DecoderException {
|
||||
Pattern sec2 = Pattern.compile(SEC_2_PATTERN);
|
||||
init();
|
||||
if (reportParser == null) {
|
||||
// nothing to do.
|
||||
|
@ -92,7 +93,7 @@ public class DRIBUSec2Decoder extends AbstractSectionDecoder {
|
|||
}
|
||||
String element = null;
|
||||
|
||||
if (reportParser.positionTo(sec2)) {
|
||||
if (reportParser.positionTo(SEC_2_PATTERN)) {
|
||||
while (true) {
|
||||
// if we run out of data, exit.
|
||||
if (reportParser.next()) {
|
||||
|
@ -103,14 +104,11 @@ public class DRIBUSec2Decoder extends AbstractSectionDecoder {
|
|||
break;
|
||||
}
|
||||
|
||||
if (AbstractSfcObsDecoder.matchElement(element,
|
||||
ISynoptic.SEC_3_LEAD)) {
|
||||
if (ISynoptic.SEC_3_LEAD_PATTERN.matcher(element).find()) {
|
||||
break;
|
||||
} else if (AbstractSfcObsDecoder.matchElement(element,
|
||||
ISynoptic.SEC_4_LEAD)) {
|
||||
} else if (ISynoptic.SEC_4_LEAD_PATTERN.matcher(element).find()) {
|
||||
break;
|
||||
} else if (AbstractSfcObsDecoder.matchElement(element,
|
||||
ISynoptic.SEC_5_LEAD)) {
|
||||
} else if (ISynoptic.SEC_5_LEAD_PATTERN.matcher(element).find()) {
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
|
@ -19,15 +19,12 @@
|
|||
**/
|
||||
package com.raytheon.edex.plugin.sfcobs.decoder.buoy;
|
||||
|
||||
import static com.raytheon.edex.plugin.sfcobs.decoder.AbstractSfcObsDecoder.matchElement;
|
||||
import static com.raytheon.edex.plugin.sfcobs.decoder.synoptic.ISynoptic.SEC_3_LEAD;
|
||||
import static com.raytheon.edex.plugin.sfcobs.decoder.synoptic.ISynoptic.SEC_4_LEAD;
|
||||
import static com.raytheon.edex.plugin.sfcobs.decoder.synoptic.ISynoptic.SEC_5_LEAD;
|
||||
|
||||
import com.raytheon.edex.exception.DecoderException;
|
||||
import com.raytheon.edex.plugin.sfcobs.decoder.AbstractSfcObsDecoder;
|
||||
import com.raytheon.edex.plugin.sfcobs.decoder.ReportParser;
|
||||
import com.raytheon.edex.plugin.sfcobs.decoder.synoptic.AbstractSectionDecoder;
|
||||
import com.raytheon.edex.plugin.sfcobs.decoder.synoptic.AbstractSynopticDecoder;
|
||||
import com.raytheon.edex.plugin.sfcobs.decoder.synoptic.ISynoptic;
|
||||
import com.raytheon.uf.common.dataplugin.sfcobs.ObsCommon;
|
||||
|
||||
/**
|
||||
|
@ -42,6 +39,7 @@ import com.raytheon.uf.common.dataplugin.sfcobs.ObsCommon;
|
|||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* 20070928 391 jkorman Initial Coding.
|
||||
* Sep 30, 2014 3629 mapeters Replaced {@link AbstractSfcObsDecoder#matchElement()} calls.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -73,7 +71,7 @@ public class DRIBUSec3Decoder extends AbstractSectionDecoder {
|
|||
return;
|
||||
}
|
||||
String element = null;
|
||||
if (reportParser.positionTo(SEC_3_LEAD)) {
|
||||
if (reportParser.positionTo(ISynoptic.SEC_3_LEAD_STRING)) {
|
||||
while (true) {
|
||||
// if we run out of data, exit.
|
||||
if (reportParser.next()) {
|
||||
|
@ -84,9 +82,9 @@ public class DRIBUSec3Decoder extends AbstractSectionDecoder {
|
|||
break;
|
||||
}
|
||||
|
||||
if (matchElement(element, SEC_4_LEAD)) {
|
||||
if (ISynoptic.SEC_4_LEAD_PATTERN.matcher(element).find()) {
|
||||
break;
|
||||
} else if (matchElement(element, SEC_5_LEAD)) {
|
||||
} else if (ISynoptic.SEC_5_LEAD_PATTERN.matcher(element).find()) {
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
|
@ -19,15 +19,12 @@
|
|||
**/
|
||||
package com.raytheon.edex.plugin.sfcobs.decoder.buoy;
|
||||
|
||||
import static com.raytheon.edex.plugin.sfcobs.decoder.AbstractSfcObsDecoder.getInt;
|
||||
import static com.raytheon.edex.plugin.sfcobs.decoder.AbstractSfcObsDecoder.matchElement;
|
||||
import static com.raytheon.edex.plugin.sfcobs.decoder.synoptic.ISynoptic.SEC_4_LEAD;
|
||||
import static com.raytheon.edex.plugin.sfcobs.decoder.synoptic.ISynoptic.SEC_5_LEAD;
|
||||
|
||||
import com.raytheon.edex.exception.DecoderException;
|
||||
import com.raytheon.edex.plugin.sfcobs.decoder.AbstractSfcObsDecoder;
|
||||
import com.raytheon.edex.plugin.sfcobs.decoder.ReportParser;
|
||||
import com.raytheon.edex.plugin.sfcobs.decoder.synoptic.AbstractSectionDecoder;
|
||||
import com.raytheon.edex.plugin.sfcobs.decoder.synoptic.AbstractSynopticDecoder;
|
||||
import com.raytheon.edex.plugin.sfcobs.decoder.synoptic.ISynoptic;
|
||||
import com.raytheon.uf.common.dataplugin.sfcobs.ObsCommon;
|
||||
|
||||
/**
|
||||
|
@ -41,6 +38,7 @@ import com.raytheon.uf.common.dataplugin.sfcobs.ObsCommon;
|
|||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* 20071010 391 jkorman Initial coding.
|
||||
* Sep 30, 2014 3629 mapeters Replaced {@link AbstractSfcObsDecoder#matchElement()} calls.
|
||||
* </pre>
|
||||
*
|
||||
* @author jkorman
|
||||
|
@ -77,7 +75,7 @@ public class DRIBUSec4Decoder extends AbstractSectionDecoder {
|
|||
return;
|
||||
}
|
||||
String element = null;
|
||||
if (reportParser.positionTo(SEC_4_LEAD)) {
|
||||
if (reportParser.positionTo(ISynoptic.SEC_4_LEAD_STRING)) {
|
||||
while (true) {
|
||||
// if we run out of data, exit.
|
||||
if (reportParser.next()) {
|
||||
|
@ -88,13 +86,14 @@ public class DRIBUSec4Decoder extends AbstractSectionDecoder {
|
|||
break;
|
||||
}
|
||||
|
||||
if (matchElement(element, SEC_5_LEAD)) {
|
||||
if (ISynoptic.SEC_5_LEAD_PATTERN.matcher(element).find()) {
|
||||
break;
|
||||
}
|
||||
|
||||
if ("7".equals(element.substring(0, 1))) {
|
||||
driftSpeed = getInt(element, 1, 3);
|
||||
driftDirection = getInt(element, 3, 5);
|
||||
driftSpeed = AbstractSfcObsDecoder.getInt(element, 1, 3);
|
||||
driftDirection = AbstractSfcObsDecoder
|
||||
.getInt(element, 3, 5);
|
||||
closeGroup(7);
|
||||
}
|
||||
|
||||
|
|
|
@ -19,7 +19,10 @@
|
|||
**/
|
||||
package com.raytheon.edex.plugin.sfcobs.decoder.buoy;
|
||||
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import com.raytheon.edex.exception.DecoderException;
|
||||
import com.raytheon.edex.plugin.sfcobs.decoder.AbstractSfcObsDecoder;
|
||||
import com.raytheon.edex.plugin.sfcobs.decoder.synoptic.AbstractSynopticDecoder;
|
||||
import com.raytheon.uf.common.dataplugin.PluginDataObject;
|
||||
import com.raytheon.uf.common.dataplugin.sfcobs.ObsCommon;
|
||||
|
@ -36,6 +39,9 @@ import com.raytheon.uf.common.pointdata.spatial.SurfaceObsLocation;
|
|||
* ------------ ---------- ----------- --------------------------
|
||||
* 20070928 391 jkorman Initial Coding.
|
||||
* Jul 23, 2014 3410 bclement location changed to floats
|
||||
* Sep 30, 2014 3629 mapeters Replaced {@link AbstractSfcObsDecoder#matchElement()}
|
||||
* calls, added Pattern constants.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @author jkorman
|
||||
|
@ -47,6 +53,22 @@ public class DRIBUSynopticDecoder extends AbstractSynopticDecoder {
|
|||
// private Integer dateMM = null; // Month
|
||||
// private Integer dateJ = null; // Units digit of year
|
||||
// private Integer dategg = null; // Minutes
|
||||
|
||||
private static final Pattern PATTERN_1357d5 = Pattern
|
||||
.compile("[1357]\\d{5}");
|
||||
|
||||
private static final Pattern PATTERN_1357d4 = Pattern
|
||||
.compile("[1357]\\d{4}/");
|
||||
|
||||
private static final Pattern PATTERN_1357d3 = Pattern
|
||||
.compile("[1357]\\d{3}//");
|
||||
|
||||
private static final Pattern PATTERN_d6 = Pattern.compile("\\d{6}");
|
||||
|
||||
private static final Pattern PATTERN_d5 = Pattern.compile("\\d{5}/");
|
||||
|
||||
private static final Pattern PATTERN_d4 = Pattern.compile("\\d{4}//");
|
||||
|
||||
private Float buoyLatitude = null;
|
||||
|
||||
private Float buoyLongitude = null;
|
||||
|
@ -184,14 +206,14 @@ public class DRIBUSynopticDecoder extends AbstractSynopticDecoder {
|
|||
String element = reportParser.getElement();
|
||||
Integer lat = null;
|
||||
float divisor = 1000.0f;
|
||||
if (matchElement(element, "[1357]\\d{5}")) {
|
||||
if (PATTERN_1357d5.matcher(element).find()) {
|
||||
buoyQuadrant = getInt(element, 0, 1);
|
||||
lat = getInt(element, 1, 6);
|
||||
} else if (matchElement(element, "[1357]\\d{4}/")) {
|
||||
} else if (PATTERN_1357d4.matcher(element).find()) {
|
||||
buoyQuadrant = getInt(element, 0, 1);
|
||||
lat = getInt(element, 1, 5);
|
||||
divisor = 100.0f;
|
||||
} else if (matchElement(element, "[1357]\\d{3}//")) {
|
||||
} else if (PATTERN_1357d3.matcher(element).find()) {
|
||||
buoyQuadrant = getInt(element, 0, 1);
|
||||
lat = getInt(element, 1, 4);
|
||||
divisor = 10.0f;
|
||||
|
@ -217,12 +239,12 @@ public class DRIBUSynopticDecoder extends AbstractSynopticDecoder {
|
|||
String element = reportParser.getElement();
|
||||
Integer lon = null;
|
||||
float divisor = 1000.0f;
|
||||
if (matchElement(element, "\\d{6}")) {
|
||||
if (PATTERN_d6.matcher(element).find()) {
|
||||
lon = getInt(element, 0, 6);
|
||||
} else if (matchElement(element, "\\d{5}/")) {
|
||||
} else if (PATTERN_d5.matcher(element).find()) {
|
||||
lon = getInt(element, 0, 5);
|
||||
divisor = 100.0f;
|
||||
} else if (matchElement(element, "\\d{4}//")) {
|
||||
} else if (PATTERN_d4.matcher(element).find()) {
|
||||
lon = getInt(element, 0, 4);
|
||||
divisor = 10.0f;
|
||||
}
|
||||
|
|
|
@ -23,6 +23,7 @@ import java.text.SimpleDateFormat;
|
|||
import java.util.ArrayList;
|
||||
import java.util.Calendar;
|
||||
import java.util.TimeZone;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import com.raytheon.edex.exception.DecoderException;
|
||||
import com.raytheon.edex.plugin.sfcobs.decoder.AbstractSfcObsDecoder;
|
||||
|
@ -47,6 +48,7 @@ import com.raytheon.uf.edex.decodertools.time.TimeTools;
|
|||
* ------------ ---------- ----------- --------------------------
|
||||
* 20070928 391 jkorman Initial Coding.
|
||||
* May 14, 2014 2536 bclement removed TimeTools usage
|
||||
* Sep 30, 2014 3629 mapeters Added LAT_PATTERN, LON_PATTERN.
|
||||
* </pre>
|
||||
*
|
||||
* @author jkorman
|
||||
|
@ -54,6 +56,11 @@ import com.raytheon.uf.edex.decodertools.time.TimeTools;
|
|||
*/
|
||||
public abstract class AbstractSynopticDecoder extends AbstractSfcObsDecoder {
|
||||
|
||||
protected static final Pattern LAT_PATTERN = Pattern.compile("99\\d{3}");
|
||||
|
||||
protected static final Pattern LON_PATTERN = Pattern
|
||||
.compile("[1357]((0\\d{3})|(1(([0-7]\\d{2})|(800))))");
|
||||
|
||||
private static final int LINE_CUT_LENGTH = 58;
|
||||
|
||||
private static final ArrayList<String> wxAbrev = new ArrayList<String>();
|
||||
|
|
|
@ -23,6 +23,7 @@ import org.apache.commons.logging.Log;
|
|||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
import com.raytheon.edex.exception.DecoderException;
|
||||
import com.raytheon.edex.plugin.sfcobs.decoder.AbstractSfcObsDecoder;
|
||||
import com.raytheon.edex.plugin.sfcobs.decoder.synoptic.regional.Sec5MaritimeDecoder;
|
||||
import com.raytheon.uf.common.dataplugin.PluginDataObject;
|
||||
import com.raytheon.uf.common.dataplugin.sfcobs.ObsCommon;
|
||||
|
@ -45,6 +46,7 @@ import com.raytheon.uf.edex.pointdata.spatial.ObStationDao;
|
|||
* Dec 17, 2007 600 bphillip Added dao pool usage
|
||||
* 20080116 798 jkorman Changed logging levels.
|
||||
* Feb 27, 2013 1638 mschenke Moved ObStationDao to edex pointdata plugin
|
||||
* Sep 30, 2014 3629 mapeters Replaced {@link AbstractSfcObsDecoder#matchElement()} calls.
|
||||
* </pre>
|
||||
*
|
||||
* @author jkorman
|
||||
|
@ -79,7 +81,7 @@ public class CMANSynopticDecoder extends LandSynopticDecoder {
|
|||
if (isValid) {
|
||||
reportParser.next();
|
||||
element = reportParser.getElement();
|
||||
if (matchElement(element, ISynoptic.YYGGI_SUB_W)) {
|
||||
if (ISynoptic.YYGGI_SUB_W.matcher(element).find()) {
|
||||
try {
|
||||
|
||||
Integer month = getHeader().getMonth();
|
||||
|
|
|
@ -19,6 +19,8 @@
|
|||
**/
|
||||
package com.raytheon.edex.plugin.sfcobs.decoder.synoptic;
|
||||
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
|
@ -32,6 +34,7 @@ package com.raytheon.edex.plugin.sfcobs.decoder.synoptic;
|
|||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* 20070925 391 jkorman Initial Coding.
|
||||
* Sep 30, 2014 3629 mapeters Changed constants to Patterns, added Pattern constants.
|
||||
* </pre>
|
||||
*
|
||||
* @author jkorman
|
||||
|
@ -39,26 +42,40 @@ package com.raytheon.edex.plugin.sfcobs.decoder.synoptic;
|
|||
*/
|
||||
public interface ISynoptic {
|
||||
|
||||
public static final String GENERAL_GROUP = "[0-9/]{5}";
|
||||
public static final Pattern GENERAL_GROUP = Pattern
|
||||
.compile("[0-9/]{5}");
|
||||
|
||||
public static final String YYGGI_SUB_W = "([012]\\d{1}|3[01])[0-5]\\d{1}[/0134]";
|
||||
public static final Pattern YYGGI_SUB_W = Pattern
|
||||
.compile("([012]\\d{1}|3[01])[0-5]\\d{1}[/0134]");
|
||||
|
||||
public static final String SEC_1_IRIXHVV = "[0-4][0-7][0-9/](\\d{2}|//)";
|
||||
public static final Pattern SEC_1_IRIXHVV = Pattern
|
||||
.compile("[0-4][0-7][0-9/](\\d{2}|//)");
|
||||
|
||||
public static final String SEC_1_NDDFF = "([/0-9])(//|([012]\\d)|(3[0-6]))(//|\\d{2})";
|
||||
public static final Pattern SEC_1_NDDFF = Pattern
|
||||
.compile("([/0-9])(//|([012]\\d)|(3[0-6]))(//|\\d{2})");
|
||||
|
||||
public static final String SEC_1_TEMPDEW = "[0128](\\d{4} | ////)";
|
||||
public static final Pattern SEC_5_72_CTEMP = Pattern
|
||||
.compile("1[01][0-9/]{2}");
|
||||
|
||||
public static final String SEC_5_72_CTEMP = "1[01][0-9/]{2}";
|
||||
public static final Pattern SEC_5_72_CMAXMIN = Pattern
|
||||
.compile("[01][0-9/]{2}[01][0-9/]{2}");
|
||||
|
||||
public static final String SEC_5_72_CMAXMIN = "[01][0-9/]{2}[01][0-9/]{2}";
|
||||
public static final Pattern SEC_2_LEAD = Pattern
|
||||
.compile("222[0-9/]{2}");
|
||||
|
||||
public static final String SEC_2_LEAD = "222[0-9/]{2}";
|
||||
public static final String SEC_3_LEAD_STRING = "333";
|
||||
|
||||
public static final String SEC_3_LEAD = "333";
|
||||
public static final Pattern SEC_3_LEAD_PATTERN = Pattern
|
||||
.compile(SEC_3_LEAD_STRING);
|
||||
|
||||
public static final String SEC_4_LEAD = "444";
|
||||
public static final String SEC_4_LEAD_STRING = "444";
|
||||
|
||||
public static final String SEC_5_LEAD = "555";
|
||||
public static final Pattern SEC_4_LEAD_PATTERN = Pattern
|
||||
.compile(SEC_4_LEAD_STRING);
|
||||
|
||||
public static final String SEC_5_LEAD_STRING = "555";
|
||||
|
||||
public static final Pattern SEC_5_LEAD_PATTERN = Pattern
|
||||
.compile(SEC_5_LEAD_STRING);
|
||||
|
||||
}
|
||||
|
|
|
@ -26,6 +26,7 @@ import org.apache.commons.logging.Log;
|
|||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
import com.raytheon.edex.exception.DecoderException;
|
||||
import com.raytheon.edex.plugin.sfcobs.decoder.AbstractSfcObsDecoder;
|
||||
import com.raytheon.edex.plugin.sfcobs.decoder.synoptic.regional.Sec5Block72Decoder;
|
||||
import com.raytheon.uf.common.dataplugin.PluginDataObject;
|
||||
import com.raytheon.uf.common.dataplugin.sfcobs.ObsCommon;
|
||||
|
@ -52,6 +53,7 @@ import com.raytheon.uf.edex.pointdata.spatial.ObStationDao;
|
|||
* Dec 17, 2007 600 bphillip Added dao pool usage
|
||||
* 20080116 798 jkorman Changed logging levels.
|
||||
* Feb 27, 2013 1638 mschenke Moved ObStationDao to edex pointdata plugin
|
||||
* Sep 30, 2014 3629 mapeters Replaced {@link AbstractSfcObsDecoder#matchElement()} calls.
|
||||
* </pre>
|
||||
*
|
||||
* @author jkorman
|
||||
|
@ -88,7 +90,7 @@ public class LandSynopticDecoder extends AbstractSynopticDecoder {
|
|||
if (isValid) {
|
||||
reportParser.next();
|
||||
element = reportParser.getElement();
|
||||
if (matchElement(element, ISynoptic.YYGGI_SUB_W)) {
|
||||
if (ISynoptic.YYGGI_SUB_W.matcher(element).find()) {
|
||||
try {
|
||||
Integer month = getHeader().getMonth();
|
||||
if (month != -1) {
|
||||
|
|
|
@ -23,6 +23,7 @@ import org.apache.commons.logging.Log;
|
|||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
import com.raytheon.edex.exception.DecoderException;
|
||||
import com.raytheon.edex.plugin.sfcobs.decoder.AbstractSfcObsDecoder;
|
||||
import com.raytheon.uf.common.dataplugin.PluginDataObject;
|
||||
import com.raytheon.uf.common.dataplugin.sfcobs.ObsCommon;
|
||||
|
||||
|
@ -38,6 +39,7 @@ import com.raytheon.uf.common.dataplugin.sfcobs.ObsCommon;
|
|||
* ------------ ---------- ----------- --------------------------
|
||||
* 20071010 391 jkorman Initial coding.
|
||||
* 20071217 453 jkorman Added code to report MAROB report type.
|
||||
* Sep 30, 2014 3629 mapeters Replaced {@link AbstractSfcObsDecoder#matchElement()} calls.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -77,7 +79,7 @@ public class MAROBSynopticDecoder extends SHIPSynopticDecoder {
|
|||
setReportIdentifier(reportParser.getElement());
|
||||
reportParser.next();
|
||||
element = reportParser.getElement();
|
||||
if (matchElement(element, ISynoptic.YYGGI_SUB_W)) {
|
||||
if (ISynoptic.YYGGI_SUB_W.matcher(element).find()) {
|
||||
try {
|
||||
Integer month = getHeader().getMonth();
|
||||
if (month != -1) {
|
||||
|
|
|
@ -19,10 +19,13 @@
|
|||
**/
|
||||
package com.raytheon.edex.plugin.sfcobs.decoder.synoptic;
|
||||
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
import com.raytheon.edex.exception.DecoderException;
|
||||
import com.raytheon.edex.plugin.sfcobs.decoder.AbstractSfcObsDecoder;
|
||||
import com.raytheon.uf.common.dataplugin.PluginDataObject;
|
||||
import com.raytheon.uf.common.dataplugin.sfcobs.ObsCommon;
|
||||
import com.raytheon.uf.common.pointdata.spatial.SurfaceObsLocation;
|
||||
|
@ -40,6 +43,8 @@ import com.raytheon.uf.edex.decodertools.core.IDecoderConstants;
|
|||
* ------------ ---------- ----------- --------------------------
|
||||
* 20070928 391 jkorman Initial Coding.
|
||||
* Jul 23, 2014 3410 bclement location changed to floats
|
||||
* Sep 30, 2014 3629 mapeters Replaced {@link AbstractSfcObsDecoder#matchElement()}
|
||||
* calls, added ELEV_PATTERN.
|
||||
* </pre>
|
||||
*
|
||||
* @author jkorman
|
||||
|
@ -47,6 +52,9 @@ import com.raytheon.uf.edex.decodertools.core.IDecoderConstants;
|
|||
*/
|
||||
public class MobileSynopticDecoder extends AbstractSynopticDecoder {
|
||||
|
||||
private static final Pattern ELEV_PATTERN = Pattern
|
||||
.compile("[/0-9]{4}[1-8]");
|
||||
|
||||
// The logger
|
||||
private Log logger = LogFactory.getLog(getClass());
|
||||
|
||||
|
@ -92,7 +100,7 @@ public class MobileSynopticDecoder extends AbstractSynopticDecoder {
|
|||
setReportIdentifier(reportParser.getElement());
|
||||
reportParser.next();
|
||||
element = reportParser.getElement();
|
||||
if (matchElement(element, ISynoptic.YYGGI_SUB_W)) {
|
||||
if (ISynoptic.YYGGI_SUB_W.matcher(element).find()) {
|
||||
try {
|
||||
Integer month = getHeader().getMonth();
|
||||
if (month != -1) {
|
||||
|
@ -171,7 +179,7 @@ public class MobileSynopticDecoder extends AbstractSynopticDecoder {
|
|||
reportParser.next();
|
||||
String element = reportParser.getElement();
|
||||
|
||||
if (matchElement(element, "99\\d{3}")) {
|
||||
if (LAT_PATTERN.matcher(element).find()) {
|
||||
Integer lat = getInt(element, 2, 5);
|
||||
if (lat != null) {
|
||||
mobileLatitude = lat.floatValue() / 10.0f;
|
||||
|
@ -190,7 +198,7 @@ public class MobileSynopticDecoder extends AbstractSynopticDecoder {
|
|||
reportParser.next();
|
||||
String element = reportParser.getElement();
|
||||
|
||||
if (matchElement(element, "[1357]((0\\d{3})|(1(([0-7]\\d{2})|(800))))")) {
|
||||
if (LON_PATTERN.matcher(element).find()) {
|
||||
Integer lon = getInt(element, 2, 5);
|
||||
if (lon != null) {
|
||||
mobileLongitude = lon.floatValue() / 10.0f;
|
||||
|
@ -257,7 +265,7 @@ public class MobileSynopticDecoder extends AbstractSynopticDecoder {
|
|||
reportParser.next();
|
||||
String element = reportParser.getElement();
|
||||
|
||||
if (matchElement(element, "[/0-9]{4}[1-8]")) {
|
||||
if (ELEV_PATTERN.matcher(element).find()) {
|
||||
Integer elev = getInt(element, 0, 4);
|
||||
if (elev != null) {
|
||||
if (elev >= 0) {
|
||||
|
|
|
@ -23,6 +23,7 @@ import org.apache.commons.logging.Log;
|
|||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
import com.raytheon.edex.exception.DecoderException;
|
||||
import com.raytheon.edex.plugin.sfcobs.decoder.AbstractSfcObsDecoder;
|
||||
import com.raytheon.edex.plugin.sfcobs.decoder.synoptic.regional.Sec5MaritimeDecoder;
|
||||
import com.raytheon.uf.common.dataplugin.PluginDataObject;
|
||||
import com.raytheon.uf.common.dataplugin.sfcobs.ObsCommon;
|
||||
|
@ -49,12 +50,14 @@ import com.raytheon.uf.edex.pointdata.spatial.ObStationDao;
|
|||
* 20120619 DR 14015 mporricelli Added elevation for fixed buoys
|
||||
* Feb 27, 2013 1638 mschenke Moved ObStationDao to edex pointdata plugin
|
||||
* Jul 23, 2014 3410 bclement location changed to floats
|
||||
* Sep 30, 2014 3629 mapeters Replaced {@link AbstractSfcObsDecoder#matchElement()} calls.
|
||||
* </pre>
|
||||
*
|
||||
* @author jkorman
|
||||
* @version 1.0
|
||||
*/
|
||||
public class SHIPSynopticDecoder extends AbstractSynopticDecoder {
|
||||
|
||||
// The logger
|
||||
private Log logger = LogFactory.getLog(getClass());
|
||||
|
||||
|
@ -123,7 +126,7 @@ public class SHIPSynopticDecoder extends AbstractSynopticDecoder {
|
|||
}
|
||||
reportParser.next();
|
||||
element = reportParser.getElement();
|
||||
if (matchElement(element, ISynoptic.YYGGI_SUB_W)) {
|
||||
if (ISynoptic.YYGGI_SUB_W.matcher(element).find()) {
|
||||
try {
|
||||
Integer month = getHeader().getMonth();
|
||||
if (month != -1) {
|
||||
|
@ -219,7 +222,7 @@ public class SHIPSynopticDecoder extends AbstractSynopticDecoder {
|
|||
reportParser.next();
|
||||
String element = reportParser.getElement();
|
||||
|
||||
if (matchElement(element, "99\\d{3}")) {
|
||||
if (LAT_PATTERN.matcher(element).find()) {
|
||||
Integer lat = getInt(element, 2, 5);
|
||||
if ((lat != null) && (lat >= 0)) {
|
||||
shipLatitude = lat.floatValue() / 10.0f;
|
||||
|
@ -237,7 +240,7 @@ public class SHIPSynopticDecoder extends AbstractSynopticDecoder {
|
|||
reportParser.next();
|
||||
String element = reportParser.getElement();
|
||||
|
||||
if (matchElement(element, "[1357]((0\\d{3})|(1(([0-7]\\d{2})|(800))))")) {
|
||||
if (LON_PATTERN.matcher(element).find()) {
|
||||
Integer lon = getInt(element, 1, 5);
|
||||
if ((lon != null) && (lon >= 0)) {
|
||||
shipLongitude = lon.floatValue() / 10.0f;
|
||||
|
|
|
@ -19,6 +19,8 @@
|
|||
**/
|
||||
package com.raytheon.edex.plugin.sfcobs.decoder.synoptic;
|
||||
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import javax.measure.converter.UnitConverter;
|
||||
import javax.measure.unit.SI;
|
||||
|
||||
|
@ -54,6 +56,9 @@ import com.raytheon.uf.edex.decodertools.core.IDecoderConstants;
|
|||
* 20071109 391 jkorman Factored out time constants.
|
||||
* Sep 18, 2014 #3627 mapeters Convert units using {@link UnitConverter}.
|
||||
* Sep 26, 2014 #3629 mapeters Replaced static imports.
|
||||
* Sep 30, 2014 3629 mapeters Replaced {@link AbstractSfcObsDecoder#matchElement()}
|
||||
* calls, added HUMIDITY_PATTERN.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @author jkorman
|
||||
|
@ -61,6 +66,8 @@ import com.raytheon.uf.edex.decodertools.core.IDecoderConstants;
|
|||
*/
|
||||
public class SynopticGroups {
|
||||
|
||||
private static final Pattern HUMIDITY_PATTERN = Pattern.compile("2\\d{4}");
|
||||
|
||||
private static final int PREFIX_START = 0;
|
||||
|
||||
private static final String RH_PREFIX = "29";
|
||||
|
@ -88,7 +95,7 @@ public class SynopticGroups {
|
|||
int lookingForSect) {
|
||||
DataItem decodedItem = null;
|
||||
|
||||
if (AbstractSfcObsDecoder.matchElement(groupData, "2\\d{4}")) {
|
||||
if (HUMIDITY_PATTERN.matcher(groupData).find()) {
|
||||
Integer val = Integer.parseInt(groupData.substring(2, 5));
|
||||
if ((val != null) && (val >= 0)) {
|
||||
if (lookingForSect == 1) {
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
package com.raytheon.edex.plugin.sfcobs.decoder.synoptic;
|
||||
|
||||
import java.util.Calendar;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import com.raytheon.edex.exception.DecoderException;
|
||||
import com.raytheon.edex.plugin.sfcobs.decoder.AbstractSfcObsDecoder;
|
||||
|
@ -48,6 +49,8 @@ import com.raytheon.uf.edex.decodertools.time.TimeTools;
|
|||
* Sep 18, 2014 #3627 mapeters Updated deprecated {@link TimeTools} usage,
|
||||
* removed unused lowCloudAmount field.
|
||||
* Sep 26, 2014 #3629 mapeters Replaced static imports.
|
||||
* Sep 30, 2014 #3629 mapeters Replaced {@link AbstractSfcObsDecoder#matchElement()}
|
||||
* calls, added PATTERN_8094.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -55,6 +58,9 @@ import com.raytheon.uf.edex.decodertools.time.TimeTools;
|
|||
* @version 1.0
|
||||
*/
|
||||
public class SynopticSec1Decoder extends AbstractSectionDecoder {
|
||||
|
||||
private static final Pattern PATTERN_8094 = Pattern.compile("8[/0-9]{4}");
|
||||
|
||||
// The report observation hour - from 9 group
|
||||
private Integer obsTimeHour = null;
|
||||
|
||||
|
@ -144,8 +150,7 @@ public class SynopticSec1Decoder extends AbstractSectionDecoder {
|
|||
break;
|
||||
}
|
||||
if (!irix && !winds
|
||||
&& AbstractSfcObsDecoder.matchElement(element,
|
||||
ISynoptic.SEC_1_IRIXHVV)) {
|
||||
&& ISynoptic.SEC_1_IRIXHVV.matcher(element).find()) {
|
||||
// iSubR = getInt(element, 0, 1);
|
||||
AbstractSfcObsDecoder.getInt(element, 0, 1);
|
||||
|
||||
|
@ -157,8 +162,7 @@ public class SynopticSec1Decoder extends AbstractSectionDecoder {
|
|||
irix = true;
|
||||
continue;
|
||||
} else if (!winds
|
||||
&& AbstractSfcObsDecoder.matchElement(element,
|
||||
ISynoptic.SEC_1_NDDFF)) {
|
||||
&& ISynoptic.SEC_1_NDDFF.matcher(element).find()) {
|
||||
totalCloud = AbstractSfcObsDecoder.getInt(element, 0, 1);
|
||||
Integer temp = AbstractSfcObsDecoder.getInt(element, 1, 3);
|
||||
if ((temp != null) && (temp >= 0)) {
|
||||
|
@ -186,14 +190,13 @@ public class SynopticSec1Decoder extends AbstractSectionDecoder {
|
|||
}
|
||||
continue;
|
||||
} else if (winds
|
||||
&& AbstractSfcObsDecoder.matchElement(element,
|
||||
ISynoptic.SEC_2_LEAD)) {
|
||||
&& ISynoptic.SEC_2_LEAD.matcher(element).find()) {
|
||||
break;
|
||||
} else if (ISynoptic.SEC_3_LEAD.equals(element)) {
|
||||
} else if (ISynoptic.SEC_3_LEAD_STRING.equals(element)) {
|
||||
break;
|
||||
} else if (ISynoptic.SEC_4_LEAD.equals(element)) {
|
||||
} else if (ISynoptic.SEC_4_LEAD_STRING.equals(element)) {
|
||||
break;
|
||||
} else if (ISynoptic.SEC_5_LEAD.equals(element)) {
|
||||
} else if (ISynoptic.SEC_5_LEAD_STRING.equals(element)) {
|
||||
break;
|
||||
} else if ("80000".equals(element)) {
|
||||
break;
|
||||
|
@ -253,8 +256,7 @@ public class SynopticSec1Decoder extends AbstractSectionDecoder {
|
|||
winds = true;
|
||||
} else if ("8".equals(element.substring(0, 1)) && doGroup(8)) {
|
||||
if (!winds
|
||||
&& AbstractSfcObsDecoder.matchElement(element,
|
||||
"8[/0-9]{4}")) {
|
||||
&& PATTERN_8094.matcher(element).find()) {
|
||||
if ((lowCloudType = AbstractSfcObsDecoder.getInt(element,
|
||||
2, 3)) < 0) {
|
||||
lowCloudType = null;
|
||||
|
|
|
@ -19,8 +19,6 @@
|
|||
**/
|
||||
package com.raytheon.edex.plugin.sfcobs.decoder.synoptic;
|
||||
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import com.raytheon.edex.exception.DecoderException;
|
||||
import com.raytheon.edex.plugin.sfcobs.decoder.AbstractSfcObsDecoder;
|
||||
import com.raytheon.edex.plugin.sfcobs.decoder.DataItem;
|
||||
|
@ -42,6 +40,7 @@ import com.raytheon.uf.edex.decodertools.core.IDecoderConstants;
|
|||
* 20071109 391 jkorman Added guard for short data.
|
||||
* 2013/8 757 T. Lee Checked missing wave height from ship report
|
||||
* Sep 26, 2014 3629 mapeters Replaced static imports.
|
||||
* Sep 30, 2014 3629 mapeters Conformed to changes in {@link ISynoptic} constants.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -108,13 +107,12 @@ public class SynopticSec2Decoder extends AbstractSectionDecoder {
|
|||
* Thrown when an relevant error has occurred.
|
||||
*/
|
||||
public void decode(ReportParser reportParser) throws DecoderException {
|
||||
Pattern pattern = Pattern.compile(ISynoptic.SEC_2_LEAD);
|
||||
init();
|
||||
if (reportParser == null) {
|
||||
// nothing to do.
|
||||
return;
|
||||
}
|
||||
if (reportParser.positionTo(pattern)) {
|
||||
if (reportParser.positionTo(ISynoptic.SEC_2_LEAD)) {
|
||||
String element = reportParser.getElement();
|
||||
// need to decode the Ds vs data
|
||||
shipDirection = AbstractSfcObsDecoder.getInt(element, 3, 4);
|
||||
|
@ -129,11 +127,11 @@ public class SynopticSec2Decoder extends AbstractSectionDecoder {
|
|||
break;
|
||||
}
|
||||
|
||||
if (ISynoptic.SEC_3_LEAD.equals(element)) {
|
||||
if (ISynoptic.SEC_3_LEAD_STRING.equals(element)) {
|
||||
break;
|
||||
} else if (ISynoptic.SEC_4_LEAD.equals(element)) {
|
||||
} else if (ISynoptic.SEC_4_LEAD_STRING.equals(element)) {
|
||||
break;
|
||||
} else if (ISynoptic.SEC_5_LEAD.equals(element)) {
|
||||
} else if (ISynoptic.SEC_5_LEAD_STRING.equals(element)) {
|
||||
break;
|
||||
} else if ("80000".equals(element)) {
|
||||
break;
|
||||
|
|
|
@ -59,7 +59,7 @@ import com.raytheon.uf.edex.decodertools.core.IDecoderConstants;
|
|||
* Sep 18, 2014 #3627 mapeters Convert units using {@link UnitConverter}, removed
|
||||
* unused duration field, made patterns constant.
|
||||
* Sep 26, 2014 #3629 mapeters Replaced static imports.
|
||||
*
|
||||
* Sep 30, 2014 #3629 mapeters Conformed to changes in ISynoptic constants.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -129,7 +129,7 @@ public class SynopticSec3Decoder extends AbstractSectionDecoder {
|
|||
return;
|
||||
}
|
||||
String element = null;
|
||||
if (reportParser.positionTo(ISynoptic.SEC_3_LEAD)) {
|
||||
if (reportParser.positionTo(ISynoptic.SEC_3_LEAD_STRING)) {
|
||||
while (true) {
|
||||
// if we run out of data, exit.
|
||||
if (reportParser.next()) {
|
||||
|
@ -139,9 +139,9 @@ public class SynopticSec3Decoder extends AbstractSectionDecoder {
|
|||
} else {
|
||||
break;
|
||||
}
|
||||
if (ISynoptic.SEC_4_LEAD.equals(element)) {
|
||||
if (ISynoptic.SEC_4_LEAD_STRING.equals(element)) {
|
||||
break;
|
||||
} else if (ISynoptic.SEC_5_LEAD.equals(element)) {
|
||||
} else if (ISynoptic.SEC_5_LEAD_STRING.equals(element)) {
|
||||
break;
|
||||
} else if ("80000".equals(element)) {
|
||||
break;
|
||||
|
|
|
@ -19,12 +19,8 @@
|
|||
**/
|
||||
package com.raytheon.edex.plugin.sfcobs.decoder.synoptic;
|
||||
|
||||
import static com.raytheon.edex.plugin.sfcobs.decoder.AbstractSfcObsDecoder.getInt;
|
||||
import static com.raytheon.edex.plugin.sfcobs.decoder.AbstractSfcObsDecoder.matchElement;
|
||||
import static com.raytheon.edex.plugin.sfcobs.decoder.synoptic.ISynoptic.GENERAL_GROUP;
|
||||
import static com.raytheon.edex.plugin.sfcobs.decoder.synoptic.ISynoptic.SEC_4_LEAD;
|
||||
|
||||
import com.raytheon.edex.exception.DecoderException;
|
||||
import com.raytheon.edex.plugin.sfcobs.decoder.AbstractSfcObsDecoder;
|
||||
import com.raytheon.edex.plugin.sfcobs.decoder.ReportParser;
|
||||
import com.raytheon.uf.common.dataplugin.sfcobs.AncCloud;
|
||||
import com.raytheon.uf.common.dataplugin.sfcobs.ObsCommon;
|
||||
|
@ -40,6 +36,7 @@ import com.raytheon.uf.common.dataplugin.sfcobs.ObsCommon;
|
|||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* 20071010 391 jkorman Initial coding.
|
||||
* Sep 30, 2014 3629 mapeters Replaced {@link AbstractSfcObsDecoder#matchElement()} calls.
|
||||
* </pre>
|
||||
*
|
||||
* @author jkorman
|
||||
|
@ -90,15 +87,16 @@ public class SynopticSec4Decoder extends AbstractSectionDecoder {
|
|||
// nothing to do.
|
||||
return;
|
||||
}
|
||||
if (reportParser.positionTo(SEC_4_LEAD)) {
|
||||
if (reportParser.positionTo(ISynoptic.SEC_4_LEAD_STRING)) {
|
||||
|
||||
if (reportParser.next()) {
|
||||
String element = reportParser.getElement();
|
||||
if (matchElement(element, GENERAL_GROUP)) {
|
||||
cloudAmount = getInt(element, 0, 1);
|
||||
cloudGenus = getInt(element, 1, 2);
|
||||
cloudAltitude = getInt(element, 2, 4);
|
||||
cloudDescription = getInt(element, 4, 5);
|
||||
if (ISynoptic.GENERAL_GROUP.matcher(element).find()) {
|
||||
cloudAmount = AbstractSfcObsDecoder.getInt(element, 0, 1);
|
||||
cloudGenus = AbstractSfcObsDecoder.getInt(element, 1, 2);
|
||||
cloudAltitude = AbstractSfcObsDecoder.getInt(element, 2, 4);
|
||||
cloudDescription = AbstractSfcObsDecoder.getInt(element, 4,
|
||||
5);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -47,6 +47,7 @@ import com.raytheon.uf.common.dataplugin.sfcobs.ObsCommon;
|
|||
* 20071010 391 jkorman Initial coding.
|
||||
* Sep 18, 2014 #3627 mapeters Convert units using {@link UnitConverter}.
|
||||
* Sep 26, 2014 #3629 mapeters Replaced static imports.
|
||||
* Sep 30, 2014 #3629 mapeters Replaced {@link AbstractSfcObsDecoder#matchElement()} calls.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -98,7 +99,7 @@ public class Sec5Block72Decoder extends SynopticSec5Decoder {
|
|||
// nothing to do.
|
||||
return;
|
||||
}
|
||||
if (reportParser.positionTo(ISynoptic.SEC_5_LEAD)) {
|
||||
if (reportParser.positionTo(ISynoptic.SEC_5_LEAD_STRING)) {
|
||||
String element = null;
|
||||
|
||||
while (true) {
|
||||
|
@ -111,8 +112,8 @@ public class Sec5Block72Decoder extends SynopticSec5Decoder {
|
|||
break;
|
||||
}
|
||||
if (isBlock72Data) {
|
||||
if (AbstractSfcObsDecoder.matchElement(element,
|
||||
ISynoptic.SEC_5_72_CTEMP)) {
|
||||
if (ISynoptic.SEC_5_72_CTEMP.matcher(element)
|
||||
.find()) {
|
||||
// City temperature.
|
||||
Double val = decodeFahrenheit(element.substring(1, 4));
|
||||
if (val != null) {
|
||||
|
@ -120,8 +121,8 @@ public class Sec5Block72Decoder extends SynopticSec5Decoder {
|
|||
cityTemperature.setDataValue(val);
|
||||
cityTemperature.setDataPeriod(0);
|
||||
}
|
||||
} else if (AbstractSfcObsDecoder.matchElement(element,
|
||||
ISynoptic.SEC_5_72_CMAXMIN)) {
|
||||
} else if (ISynoptic.SEC_5_72_CMAXMIN.matcher(
|
||||
element).find()) {
|
||||
// City maximum/minimum temperature.
|
||||
Double val = decodeFahrenheit(element.substring(0, 3));
|
||||
if (val != null) {
|
||||
|
|
|
@ -19,20 +19,19 @@
|
|||
**/
|
||||
package com.raytheon.edex.plugin.sfcobs.decoder.synoptic.regional;
|
||||
|
||||
import static com.raytheon.edex.plugin.sfcobs.decoder.AbstractSfcObsDecoder.getInt;
|
||||
import static com.raytheon.edex.plugin.sfcobs.decoder.AbstractSfcObsDecoder.matchElement;
|
||||
import static com.raytheon.edex.plugin.sfcobs.decoder.synoptic.ISynoptic.SEC_5_LEAD;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Calendar;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import javax.measure.converter.UnitConverter;
|
||||
import javax.measure.unit.NonSI;
|
||||
import javax.measure.unit.SI;
|
||||
|
||||
import com.raytheon.edex.exception.DecoderException;
|
||||
import com.raytheon.edex.plugin.sfcobs.decoder.AbstractSfcObsDecoder;
|
||||
import com.raytheon.edex.plugin.sfcobs.decoder.ReportParser;
|
||||
import com.raytheon.edex.plugin.sfcobs.decoder.synoptic.AbstractSynopticDecoder;
|
||||
import com.raytheon.edex.plugin.sfcobs.decoder.synoptic.ISynoptic;
|
||||
import com.raytheon.edex.plugin.sfcobs.decoder.synoptic.SynopticSec5Decoder;
|
||||
import com.raytheon.uf.common.dataplugin.sfcobs.InterWinds;
|
||||
import com.raytheon.uf.common.dataplugin.sfcobs.ObsCommon;
|
||||
|
@ -56,7 +55,9 @@ import com.raytheon.uf.edex.decodertools.time.TimeTools;
|
|||
* ------------ ---------- ----------- --------------------------
|
||||
* 20071010 391 jkorman Initial coding.
|
||||
* Sep 18, 2014 #3627 mapeters Convert units using {@link UnitConverter},
|
||||
* updated deprecated {@link TimeTools} usage.
|
||||
* updated deprecated {@link TimeTools} usage.\
|
||||
* Sep 30, 2014 #3629 mapeters Replaced {@link AbstractSfcObsDecoder#matchElement()}
|
||||
* calls, added Pattern constants.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -64,6 +65,25 @@ import com.raytheon.uf.edex.decodertools.time.TimeTools;
|
|||
* @version 1.0
|
||||
*/
|
||||
public class Sec5MaritimeDecoder extends SynopticSec5Decoder {
|
||||
|
||||
private static final Pattern WIND_SPEED_10_M = Pattern
|
||||
.compile("11[/0-9]{3}");
|
||||
|
||||
private static final Pattern WIND_SPEED_20_M = Pattern
|
||||
.compile("22[/0-9]{3}");
|
||||
|
||||
private static final Pattern PEAK_WIND_3 = Pattern.compile("3[/0-9]{4}");
|
||||
|
||||
private static final Pattern CMAN_PEAK_WIND_4 = Pattern.compile("4[/0-9]{5}");
|
||||
|
||||
private static final Pattern PEAK_WIND_4 = Pattern.compile("4[/0-9]{4}");
|
||||
|
||||
private static final Pattern CONT_WIND_SPEED = Pattern.compile("6[/0-9]{4}");
|
||||
|
||||
private static final Pattern CONT_WIND_SPEED_INTERNAL = Pattern
|
||||
.compile("[/0-9]{6}");
|
||||
|
||||
private static final Pattern TIDE = Pattern.compile("TIDE[/0-9]{4}");
|
||||
|
||||
private static final UnitConverter knotsToMSec = NonSI.KNOT
|
||||
.getConverterTo(SI.METERS_PER_SECOND);
|
||||
|
@ -118,7 +138,7 @@ public class Sec5MaritimeDecoder extends SynopticSec5Decoder {
|
|||
// nothing to do.
|
||||
return;
|
||||
}
|
||||
if (reportParser.positionTo(SEC_5_LEAD)) {
|
||||
if (reportParser.positionTo(ISynoptic.SEC_5_LEAD_STRING)) {
|
||||
String element = null;
|
||||
|
||||
while (true) {
|
||||
|
@ -130,51 +150,59 @@ public class Sec5MaritimeDecoder extends SynopticSec5Decoder {
|
|||
} else {
|
||||
break;
|
||||
}
|
||||
if (doGroup(1) && matchElement(element, "11[/0-9]{3}")) {
|
||||
if (doGroup(1) && WIND_SPEED_10_M.matcher(element).find()) {
|
||||
// extrapolated 10 meter wind speed
|
||||
Integer temp = getInt(element, 2, 5);
|
||||
Integer temp = AbstractSfcObsDecoder.getInt(element, 2, 5);
|
||||
if ((temp != null) && (temp >= 0)) {
|
||||
wind10mSpeed = temp.doubleValue() / 10.0;
|
||||
}
|
||||
closeGroup(1);
|
||||
} else if (doGroup(2) && matchElement(element, "22[/0-9]{3}")) {
|
||||
} else if (doGroup(2)
|
||||
&& WIND_SPEED_20_M.matcher(element).find()) {
|
||||
// extrapolated 20 meter wind speed
|
||||
Integer temp = getInt(element, 2, 5);
|
||||
Integer temp = AbstractSfcObsDecoder.getInt(element, 2, 5);
|
||||
if ((temp != null) && (temp >= 0)) {
|
||||
wind20mSpeed = temp.doubleValue() / 10.0;
|
||||
}
|
||||
closeGroup(2);
|
||||
} else if (doGroup(3) && matchElement(element, "3[/0-9]{4}")) {
|
||||
} else if (doGroup(3) && PEAK_WIND_3.matcher(element).find()) {
|
||||
// peak wind data time
|
||||
pkWindTimeHour = getInt(element, 1, 3);
|
||||
pkWindTimeMinute = getInt(element, 3, 5);
|
||||
pkWindTimeHour = AbstractSfcObsDecoder
|
||||
.getInt(element, 1, 3);
|
||||
pkWindTimeMinute = AbstractSfcObsDecoder.getInt(element, 3,
|
||||
5);
|
||||
closeGroup(3);
|
||||
} else if (doGroup(4) && matchElement(element, "4[/0-9]{5}")) {
|
||||
} else if (doGroup(4)
|
||||
&& CMAN_PEAK_WIND_4.matcher(element).find()) {
|
||||
// peak wind data time from CMAN
|
||||
pkWindDirection = getInt(element, 1, 3);
|
||||
pkWindDirection = AbstractSfcObsDecoder.getInt(element, 1,
|
||||
3);
|
||||
if ((pkWindDirection != null) && (pkWindDirection >= 0)) {
|
||||
pkWindDirection *= 10;
|
||||
}
|
||||
Integer spd = getInt(element, 3, 6);
|
||||
Integer spd = AbstractSfcObsDecoder.getInt(element, 3, 6);
|
||||
if ((spd != null) && (spd >= 0)) {
|
||||
pkWindSpeed = spd.doubleValue();
|
||||
}
|
||||
closeGroup(4);
|
||||
} else if (doGroup(4) && matchElement(element, "4[/0-9]{4}")) {
|
||||
} else if (doGroup(4) && PEAK_WIND_4.matcher(element).find()) {
|
||||
// peak wind data time
|
||||
pkWindDirection = getInt(element, 1, 3);
|
||||
pkWindDirection = AbstractSfcObsDecoder.getInt(element, 1,
|
||||
3);
|
||||
if ((pkWindDirection != null) && (pkWindDirection >= 0)) {
|
||||
pkWindDirection *= 10;
|
||||
}
|
||||
Integer spd = getInt(element, 3, 5);
|
||||
Integer spd = AbstractSfcObsDecoder.getInt(element, 3, 5);
|
||||
if ((spd != null) && (spd >= 0)) {
|
||||
pkWindSpeed = spd.doubleValue();
|
||||
}
|
||||
closeGroup(4);
|
||||
} else if (doGroup(6) && matchElement(element, "6[/0-9]{4}")) {
|
||||
} else if (doGroup(6)
|
||||
&& CONT_WIND_SPEED.matcher(element).find()) {
|
||||
// Continuous wind speed data
|
||||
windTimeHour = getInt(element, 1, 3);
|
||||
windTimeMinute = getInt(element, 3, 5);
|
||||
windTimeHour = AbstractSfcObsDecoder.getInt(element, 1, 3);
|
||||
windTimeMinute = AbstractSfcObsDecoder
|
||||
.getInt(element, 3, 5);
|
||||
|
||||
windSpeeds = new Double[NUM_WINDS];
|
||||
Arrays.fill(windSpeeds, new Double(-9999.0));
|
||||
|
@ -189,9 +217,11 @@ public class Sec5MaritimeDecoder extends SynopticSec5Decoder {
|
|||
} else {
|
||||
break;
|
||||
}
|
||||
if (matchElement(element, "[/0-9]{6}")) {
|
||||
Integer wd = getInt(element, 0, 3);
|
||||
Integer ws = getInt(element, 3, 6);
|
||||
if (CONT_WIND_SPEED_INTERNAL.matcher(element).find()) {
|
||||
Integer wd = AbstractSfcObsDecoder.getInt(element,
|
||||
0, 3);
|
||||
Integer ws = AbstractSfcObsDecoder.getInt(element,
|
||||
3, 6);
|
||||
if ((wd != null) && (wd >= 0)) {
|
||||
windDirs[i] = wd;
|
||||
}
|
||||
|
@ -201,7 +231,7 @@ public class Sec5MaritimeDecoder extends SynopticSec5Decoder {
|
|||
}
|
||||
}
|
||||
closeGroup(6);
|
||||
} else if (matchElement(element, "TIDE[/0-9]{4}")) {
|
||||
} else if (TIDE.matcher(element).find()) {
|
||||
// Tidal data in feet.
|
||||
|
||||
}
|
||||
|
|
|
@ -180,12 +180,8 @@ public class TestSfcObsDecoders extends TestCase {
|
|||
true,true,true,false,false,
|
||||
};
|
||||
|
||||
|
||||
Pattern p = Pattern.compile(ISynoptic.YYGGI_SUB_W);
|
||||
|
||||
|
||||
for(int i = 0;i < testData.length;i++) {
|
||||
Matcher m = p.matcher(testData[i]);
|
||||
Matcher m = ISynoptic.YYGGI_SUB_W.matcher(testData[i]);
|
||||
assertEquals(m.find(),testMatch[i]);
|
||||
}
|
||||
}
|
||||
|
@ -202,12 +198,8 @@ public class TestSfcObsDecoders extends TestCase {
|
|||
true,true,true,true,
|
||||
};
|
||||
|
||||
|
||||
Pattern p = Pattern.compile(ISynoptic.SEC_1_NDDFF);
|
||||
|
||||
|
||||
for(int i = 0;i < testData.length;i++) {
|
||||
Matcher m = p.matcher(testData[i]);
|
||||
Matcher m = ISynoptic.SEC_1_NDDFF.matcher(testData[i]);
|
||||
assertEquals(m.find(),testMatch[i]);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue