[PATCH] Backend: WST parser. Detect ranges of years in column-datum
Wald Commits
scm-commit at wald.intevation.org
Fri Jun 28 19:24:59 CEST 2013
# HG changeset patch
# User Sascha L. Teichmann <teichmann at intevation.de>
# Date 1372440286 -7200
# Node ID b2eab164a4415cc119fa64e62a5705a7754aef8f
# Parent 1c68d4b2a1c0ba258cc7306068e12aa4e14768c2
Backend: WST parser. Detect ranges of years in column-datum
diff -r 1c68d4b2a1c0 -r b2eab164a441 backend/src/main/java/org/dive4elements/river/importer/parsers/WstParser.java
--- a/backend/src/main/java/org/dive4elements/river/importer/parsers/WstParser.java Fri Jun 28 17:47:27 2013 +0200
+++ b/backend/src/main/java/org/dive4elements/river/importer/parsers/WstParser.java Fri Jun 28 19:24:46 2013 +0200
@@ -61,6 +61,9 @@
public static final Pattern UNIT =
Pattern.compile("[^\\[]*\\[([^]]+)\\].*");
+ public static final Pattern YEAR_INTERVAL =
+ Pattern.compile("(\\d{4})\\s*[-/]\\s*(\\d{4})");
+
public static final double INTERVAL_GAP = 0.00001d;
protected ImportWst wst;
@@ -84,6 +87,13 @@
public static ImportTimeInterval guessDate(String string) {
try {
+ Matcher m = YEAR_INTERVAL.matcher(string);
+ if (m.matches()) {
+ return new ImportTimeInterval(
+ DateGuesser.guessDate(m.group(1)),
+ DateGuesser.guessDate(m.group(2)));
+ }
+
return new ImportTimeInterval(
DateGuesser.guessDate(string));
}
More information about the Dive4elements-commits
mailing list