Mercurial > dive4elements > river
comparison flys-backend/src/main/java/de/intevation/flys/importer/ImportRiver.java @ 2815:3febaed762b8
Added new parser (stub) to read MINFO sediment density files; prepared import process to handle those files.
flys-backend/trunk@4232 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Ingo Weinzierl <ingo.weinzierl@intevation.de> |
---|---|
date | Fri, 13 Apr 2012 09:57:37 +0000 |
parents | 8926571e47fb |
children | 8979f2294af9 |
comparison
equal
deleted
inserted
replaced
2814:bfd6a7ef0ad5 | 2815:3febaed762b8 |
---|---|
28 import de.intevation.flys.importer.parsers.PRFParser; | 28 import de.intevation.flys.importer.parsers.PRFParser; |
29 import de.intevation.flys.importer.parsers.HYKParser; | 29 import de.intevation.flys.importer.parsers.HYKParser; |
30 import de.intevation.flys.importer.parsers.AnnotationsParser; | 30 import de.intevation.flys.importer.parsers.AnnotationsParser; |
31 import de.intevation.flys.importer.parsers.AnnotationClassifier; | 31 import de.intevation.flys.importer.parsers.AnnotationClassifier; |
32 import de.intevation.flys.importer.parsers.PegelGltParser; | 32 import de.intevation.flys.importer.parsers.PegelGltParser; |
33 import de.intevation.flys.importer.parsers.SedimentDensityParser; | |
33 import de.intevation.flys.importer.parsers.WstParser; | 34 import de.intevation.flys.importer.parsers.WstParser; |
34 | 35 |
35 import org.hibernate.Session; | 36 import org.hibernate.Session; |
36 import org.hibernate.Query; | 37 import org.hibernate.Query; |
37 import org.hibernate.exception.ConstraintViolationException; | 38 import org.hibernate.exception.ConstraintViolationException; |
65 | 66 |
66 public static final String BED_HEIGHT_SINGLE_DIR = "Einzeljahre"; | 67 public static final String BED_HEIGHT_SINGLE_DIR = "Einzeljahre"; |
67 | 68 |
68 public static final String BED_HEIGHT_EPOCH_DIR = "Epochen"; | 69 public static final String BED_HEIGHT_EPOCH_DIR = "Epochen"; |
69 | 70 |
71 public static final String SEDIMENT_DENSITY_DIR = "Sedimentdichte"; | |
72 | |
70 | 73 |
71 protected String name; | 74 protected String name; |
72 | 75 |
73 protected File wstFile; | 76 protected File wstFile; |
74 | 77 |
94 | 97 |
95 protected List<ImportBedHeight> bedHeightSingles; | 98 protected List<ImportBedHeight> bedHeightSingles; |
96 | 99 |
97 protected List<ImportBedHeight> bedHeightEpochs; | 100 protected List<ImportBedHeight> bedHeightEpochs; |
98 | 101 |
102 protected List<ImportSedimentDensity> sedimentDensities; | |
103 | |
99 protected ImportWst wst; | 104 protected ImportWst wst; |
100 | 105 |
101 protected ImportUnit wstUnit; | 106 protected ImportUnit wstUnit; |
102 | 107 |
103 protected AnnotationClassifier annotationClassifier; | 108 protected AnnotationClassifier annotationClassifier; |
104 | 109 |
105 protected River peer; | 110 protected River peer; |
106 | 111 |
107 public ImportRiver() { | 112 public ImportRiver() { |
108 hyks = new ArrayList<ImportHYK>(); | 113 hyks = new ArrayList<ImportHYK>(); |
109 crossSections = new ArrayList<ImportCrossSection>(); | 114 crossSections = new ArrayList<ImportCrossSection>(); |
110 extraWsts = new ArrayList<ImportWst>(); | 115 extraWsts = new ArrayList<ImportWst>(); |
111 fixations = new ArrayList<ImportWst>(); | 116 fixations = new ArrayList<ImportWst>(); |
112 officialLines = new ArrayList<ImportWst>(); | 117 officialLines = new ArrayList<ImportWst>(); |
113 floodWater = new ArrayList<ImportWst>(); | 118 floodWater = new ArrayList<ImportWst>(); |
114 floodProtection = new ArrayList<ImportWst>(); | 119 floodProtection = new ArrayList<ImportWst>(); |
120 sedimentDensities = new ArrayList<ImportSedimentDensity>(); | |
115 } | 121 } |
116 | 122 |
117 public ImportRiver( | 123 public ImportRiver( |
118 String name, | 124 String name, |
119 File wstFile, | 125 File wstFile, |
174 parseFixations(); | 180 parseFixations(); |
175 parseOfficialLines(); | 181 parseOfficialLines(); |
176 parseFloodWater(); | 182 parseFloodWater(); |
177 parseFloodProtection(); | 183 parseFloodProtection(); |
178 parseBedHeight(); | 184 parseBedHeight(); |
185 parseSedimentDensity(); | |
179 } | 186 } |
180 | 187 |
181 public void parseFloodProtection() throws IOException { | 188 public void parseFloodProtection() throws IOException { |
182 if (Config.INSTANCE.skipFloodProtection()) { | 189 if (Config.INSTANCE.skipFloodProtection()) { |
183 log.info("skip parsing flood protection"); | 190 log.info("skip parsing flood protection"); |
242 else { | 249 else { |
243 parseBedHeightEpochs(epochDir); | 250 parseBedHeightEpochs(epochDir); |
244 } | 251 } |
245 | 252 |
246 log.info("Finished parsing bed heights."); | 253 log.info("Finished parsing bed heights."); |
254 } | |
255 | |
256 | |
257 protected void parseSedimentDensity() throws IOException { | |
258 log.debug("Parse sediment density"); | |
259 | |
260 if (Config.INSTANCE.skipSedimentDensity()) { | |
261 log.info("skip parsing sediment density."); | |
262 return; | |
263 } | |
264 | |
265 File minfoDir = getMinfoDir(); | |
266 File sediment = new File(minfoDir, SEDIMENT_DENSITY_DIR); | |
267 | |
268 File[] files = sediment.listFiles(); | |
269 | |
270 if (files == null) { | |
271 log.warn("Cannot parse directory '" + sediment + "'"); | |
272 return; | |
273 } | |
274 | |
275 SedimentDensityParser parser = new SedimentDensityParser(); | |
276 | |
277 for (File file: files) { | |
278 parser.parse(file); | |
279 } | |
280 | |
281 sedimentDensities = parser.getSedimentDensities(); | |
282 | |
283 log.info("Parsed " + sedimentDensities.size() + " sediment densities."); | |
247 } | 284 } |
248 | 285 |
249 | 286 |
250 protected void parseBedHeightSingles(File dir) throws IOException { | 287 protected void parseBedHeightSingles(File dir) throws IOException { |
251 log.debug("Parse bed height singles"); | 288 log.debug("Parse bed height singles"); |
610 storeFixations(); | 647 storeFixations(); |
611 storeOfficialLines(); | 648 storeOfficialLines(); |
612 storeFloodWater(); | 649 storeFloodWater(); |
613 storeFloodProtection(); | 650 storeFloodProtection(); |
614 storeBedHeight(); | 651 storeBedHeight(); |
652 storeSedimentDensity(); | |
615 } | 653 } |
616 | 654 |
617 public void storeWstUnit() { | 655 public void storeWstUnit() { |
618 if (wst == null) { | 656 if (wst == null) { |
619 wstUnit = new ImportUnit("NN + m"); | 657 wstUnit = new ImportUnit("NN + m"); |
769 } | 807 } |
770 } | 808 } |
771 } | 809 } |
772 else { | 810 else { |
773 log.info("No epoch bed heights to store."); | 811 log.info("No epoch bed heights to store."); |
812 } | |
813 } | |
814 | |
815 public void storeSedimentDensity() { | |
816 if (!Config.INSTANCE.skipSedimentDensity()) { | |
817 log.info("store sediment density"); | |
818 | |
819 // TODO | |
774 } | 820 } |
775 } | 821 } |
776 | 822 |
777 public void storeAnnotations() { | 823 public void storeAnnotations() { |
778 if (!Config.INSTANCE.skipAnnotations()) { | 824 if (!Config.INSTANCE.skipAnnotations()) { |