Mercurial > dive4elements > river
diff flys-backend/src/main/java/de/intevation/flys/importer/ImportRiver.java @ 4712:70842db72ee4
Include improved DA66Parser into importer.
author | Felix Wolfsteller <felix.wolfsteller@intevation.de> |
---|---|
date | Wed, 19 Dec 2012 14:04:12 +0100 |
parents | e7b238247c4e |
children | 6016b9aa827a |
line wrap: on
line diff
--- a/flys-backend/src/main/java/de/intevation/flys/importer/ImportRiver.java Wed Dec 19 13:59:57 2012 +0100 +++ b/flys-backend/src/main/java/de/intevation/flys/importer/ImportRiver.java Wed Dec 19 14:04:12 2012 +0100 @@ -228,6 +228,7 @@ parseGauges(); parseAnnotations(); parsePRFs(); + parseDA66s(); parseHYKs(); parseWst(); parseExtraWsts(); @@ -885,6 +886,67 @@ }); } + + /** Create a DA66 Parser and parse the da66 files found. */ + // TODO this is a copy of parsePRFs, extract interfaces (e.g. CrossSectionParser). + public void parseDA66s() { + if (Config.INSTANCE.skipDA66s()) { + log.info("skip parsing DA66s"); + return; + } + + log.info("looking for DA66 files"); + DA66Parser parser = new DA66Parser(); + File riverDir = wstFile + .getParentFile() // Basisdaten + .getParentFile() // Hydrologie + .getParentFile(); // <river> + + parser.parseDA66s(riverDir, new DA66Parser.Callback() { + + Set<HashedFile> da66s = new HashSet<HashedFile>(); + + @Override + public boolean da66Accept(File file) { + HashedFile hf = new HashedFile(file); + boolean success = da66s.add(hf); + return true; + // TODO for some reason they are all duplicates, reenable the check! + /* + if (!success) { + log.warn("DA66 file '" + file + "' seems to be a duplicate."); + } + return success; + */ + } + + @Override + public void da66Parsed(DA66Parser parser) { + log.debug("callback from DA66 parser"); + + // TODO populate with real-world data + String description = "dummy";//parser.getDescription(); + Integer year = 2012;//parser.getYear(); + ImportTimeInterval ti = year != null + ? new ImportTimeInterval(yearToDate(year)) + : null; + + List<ImportCrossSectionLine> lines = + new ArrayList<ImportCrossSectionLine>(); + + for (Map.Entry<Double, List<XY>> entry: parser.getData().entrySet()) { + Double km = entry.getKey(); + List<XY> points = entry.getValue(); + lines.add(new ImportCrossSectionLine(km, points)); + } + + crossSections.add(new ImportCrossSection( + ImportRiver.this, description, ti, lines)); + } + }); + } + + /** Create a PRFParser and let it parse the prf files found. */ public void parsePRFs() { if (Config.INSTANCE.skipPRFs()) { log.info("skip parsing PRFs"); @@ -988,7 +1050,7 @@ } public void storeCrossSections() { - if (!Config.INSTANCE.skipPRFs()) { + if (!Config.INSTANCE.skipPRFs() || !Config.INSTANCE.skipDA66s()) { log.info("store cross sections"); getPeer(); for (ImportCrossSection crossSection: crossSections) {