comparison backend/src/main/java/org/dive4elements/river/importer/parsers/WaterlevelParser.java @ 6319:550cb41d37d9

issue1354: TimeIntervals in Waterlevels from csv files.
author Felix Wolfsteller <felix.wolfsteller@intevation.de>
date Wed, 12 Jun 2013 12:36:43 +0200
parents 62dca91ca229
children ad2fdc34910a
comparison
equal deleted inserted replaced
6318:bc09f8fff694 6319:550cb41d37d9
18 import java.util.regex.Matcher; 18 import java.util.regex.Matcher;
19 import java.util.regex.Pattern; 19 import java.util.regex.Pattern;
20 20
21 import org.apache.log4j.Logger; 21 import org.apache.log4j.Logger;
22 22
23 import org.dive4elements.river.importer.ImportTimeInterval;
23 import org.dive4elements.river.importer.ImportUnit; 24 import org.dive4elements.river.importer.ImportUnit;
24 25
25 import org.dive4elements.river.importer.ImportRange; 26 import org.dive4elements.river.importer.ImportRange;
26 import org.dive4elements.river.importer.ImportWst; 27 import org.dive4elements.river.importer.ImportWst;
27 import org.dive4elements.river.importer.ImportWstColumn; 28 import org.dive4elements.river.importer.ImportWstColumn;
89 current = new ImportWst(currentDescription); 90 current = new ImportWst(currentDescription);
90 current.setNumberColumns(1); 91 current.setNumberColumns(1);
91 column = current.getColumn(0); 92 column = current.getColumn(0);
92 column.setName(currentDescription); 93 column.setName(currentDescription);
93 column.setDescription(currentDescription); 94 column.setDescription(currentDescription);
95
96 // Try to extract and set the TimeInterval.
97 Matcher m = WaterlevelDifferencesParser.YEARS_IN_COLUMN.matcher(currentDescription);
98
99 if (m.matches()) {
100 int startYear = Integer.parseInt(m.group(1));
101 int endYear = Integer.parseInt(m.group(2));
102 ImportTimeInterval time = new ImportTimeInterval(
103 getStartDateFromYear(startYear),
104 getEndDateFromYear(endYear)
105 );
106 column.setTimeInterval(time);
107 } else {
108 log.debug("No time interval in column header found: " + currentDescription);
109 }
110
94 current.setKind(7); 111 current.setKind(7);
95 } 112 }
96 113
97 114
98 @Override 115 @Override

http://dive4elements.wald.intevation.org