Mercurial > dive4elements > river
comparison 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 |
comparison
equal
deleted
inserted
replaced
4711:35dd03e04e38 | 4712:70842db72ee4 |
---|---|
226 | 226 |
227 public void parseDependencies() throws IOException { | 227 public void parseDependencies() throws IOException { |
228 parseGauges(); | 228 parseGauges(); |
229 parseAnnotations(); | 229 parseAnnotations(); |
230 parsePRFs(); | 230 parsePRFs(); |
231 parseDA66s(); | |
231 parseHYKs(); | 232 parseHYKs(); |
232 parseWst(); | 233 parseWst(); |
233 parseExtraWsts(); | 234 parseExtraWsts(); |
234 parseFixations(); | 235 parseFixations(); |
235 parseOfficialLines(); | 236 parseOfficialLines(); |
883 hyks.add(hyk); | 884 hyks.add(hyk); |
884 } | 885 } |
885 }); | 886 }); |
886 } | 887 } |
887 | 888 |
889 | |
890 /** Create a DA66 Parser and parse the da66 files found. */ | |
891 // TODO this is a copy of parsePRFs, extract interfaces (e.g. CrossSectionParser). | |
892 public void parseDA66s() { | |
893 if (Config.INSTANCE.skipDA66s()) { | |
894 log.info("skip parsing DA66s"); | |
895 return; | |
896 } | |
897 | |
898 log.info("looking for DA66 files"); | |
899 DA66Parser parser = new DA66Parser(); | |
900 File riverDir = wstFile | |
901 .getParentFile() // Basisdaten | |
902 .getParentFile() // Hydrologie | |
903 .getParentFile(); // <river> | |
904 | |
905 parser.parseDA66s(riverDir, new DA66Parser.Callback() { | |
906 | |
907 Set<HashedFile> da66s = new HashSet<HashedFile>(); | |
908 | |
909 @Override | |
910 public boolean da66Accept(File file) { | |
911 HashedFile hf = new HashedFile(file); | |
912 boolean success = da66s.add(hf); | |
913 return true; | |
914 // TODO for some reason they are all duplicates, reenable the check! | |
915 /* | |
916 if (!success) { | |
917 log.warn("DA66 file '" + file + "' seems to be a duplicate."); | |
918 } | |
919 return success; | |
920 */ | |
921 } | |
922 | |
923 @Override | |
924 public void da66Parsed(DA66Parser parser) { | |
925 log.debug("callback from DA66 parser"); | |
926 | |
927 // TODO populate with real-world data | |
928 String description = "dummy";//parser.getDescription(); | |
929 Integer year = 2012;//parser.getYear(); | |
930 ImportTimeInterval ti = year != null | |
931 ? new ImportTimeInterval(yearToDate(year)) | |
932 : null; | |
933 | |
934 List<ImportCrossSectionLine> lines = | |
935 new ArrayList<ImportCrossSectionLine>(); | |
936 | |
937 for (Map.Entry<Double, List<XY>> entry: parser.getData().entrySet()) { | |
938 Double km = entry.getKey(); | |
939 List<XY> points = entry.getValue(); | |
940 lines.add(new ImportCrossSectionLine(km, points)); | |
941 } | |
942 | |
943 crossSections.add(new ImportCrossSection( | |
944 ImportRiver.this, description, ti, lines)); | |
945 } | |
946 }); | |
947 } | |
948 | |
949 /** Create a PRFParser and let it parse the prf files found. */ | |
888 public void parsePRFs() { | 950 public void parsePRFs() { |
889 if (Config.INSTANCE.skipPRFs()) { | 951 if (Config.INSTANCE.skipPRFs()) { |
890 log.info("skip parsing PRFs"); | 952 log.info("skip parsing PRFs"); |
891 return; | 953 return; |
892 } | 954 } |
986 } | 1048 } |
987 } | 1049 } |
988 } | 1050 } |
989 | 1051 |
990 public void storeCrossSections() { | 1052 public void storeCrossSections() { |
991 if (!Config.INSTANCE.skipPRFs()) { | 1053 if (!Config.INSTANCE.skipPRFs() || !Config.INSTANCE.skipDA66s()) { |
992 log.info("store cross sections"); | 1054 log.info("store cross sections"); |
993 getPeer(); | 1055 getPeer(); |
994 for (ImportCrossSection crossSection: crossSections) { | 1056 for (ImportCrossSection crossSection: crossSections) { |
995 crossSection.storeDependencies(); | 1057 crossSection.storeDependencies(); |
996 } | 1058 } |