You are viewing an old version of this page. View the current version.
Compare with Current
View Page History
Version 1
Next »
/* ================================================================
* Delft FEWS
* ================================================================
*
* Project Info: http://www.wldelft.nl/soft/fews/index.html
* Project Lead: Karel Heynert (karel.heynert@wldelft.nl)
*
* (C) Copyright 2003, by WL | Delft Hydraulics
* P.O. Box 177
* 2600 MH Delft
* The Netherlands
* http://www.wldelft.nl
*
* DELFT-FEWS is a sophisticated collection of modules designed
* for building a FEWS customised to the specific requirements
* of individual agencies. An open modelling approach allows users
* to add their own modules in an efficient way.
*
* ----------------------------------------------------------------
* LmwWallonieTimeSeriesParser.java
* ----------------------------------------------------------------
* (C) Copyright 2003, by WL | Delft Hydraulics
*
* Original Author: pelgrim
* Contributor(s):
*
* Changes:
* --------
* 9/24/13 : Version 1 ();
*
*
*/
package nl.wldelft.timeseriesparsers;
import nl.wldelft.util.TimeZoneUtils;
import nl.wldelft.util.io.LineReader;
import nl.wldelft.util.io.TextParser;
import nl.wldelft.util.timeseries.DefaultTimeSeriesHeader;
import nl.wldelft.util.timeseries.TimeSeriesContentHandler;
import java.util.HashMap;
import java.util.Map;
public class LmwWallonieTimeSeriesParser implements TextParser<TimeSeriesContentHandler> {
@Override
public void parse(LineReader reader, String virtualFileName, TimeSeriesContentHandler contentHandler) throws Exception {
contentHandler.addMissingValue("*.***");
Map<String, String> paraMap = new HashMap<>();
paraMap.put("1", "height");
paraMap.put("2", "discharge");
paraMap.put("5", "rain");
Map<String, String> unitMap = new HashMap<>();
unitMap.put("1", "m");
unitMap.put("2", "m3/s");
unitMap.put("5", "mm");
DefaultTimeSeriesHeader header = new DefaultTimeSeriesHeader();
String buffer;
while ((buffer = reader.readLine()) != null) {
String locId = buffer.substring(0, 11).trim();
header.setLocationId(locId);
String param = locId.substring(locId.length() - 1);
header.setParameterId(paraMap.get(param));
header.setUnit(unitMap.get(param));
String date = buffer.substring(32).trim();
for (int j = 0; j < 3; j++) {
String valueLine = reader.readLine();
for (int i = 0; i < 8; i++) {
String hours = j * 8 + i > 10 ? "" + (j * 8 + i) : " " + (j * 8 + i);
contentHandler.setTime(TimeZoneUtils.parseTimeZone("GMT+01:00"), "yyyyMMddHH", date + hours);
contentHandler.setValue('.', valueLine.substring(i * 9, (i + 1) * 9));
contentHandler.setTimeSeriesHeader(header);
contentHandler.applyCurrentFields();
}
}
}
}
}