Mercurial > dive4elements > river
annotate backend/src/main/java/org/dive4elements/river/importer/parsers/BedHeightParser.java @ 9651:eb3dfe900d8c
Importer (s/u-info) extensions: better exception handling
author | mschaefer |
---|---|
date | Mon, 23 Mar 2020 15:00:04 +0100 |
parents | 4c5eeaff554c |
children |
rev | line source |
---|---|
5844
4dd33b86dc61
Added header to river backend.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5838
diff
changeset
|
1 /* Copyright (C) 2011, 2012, 2013 by Bundesanstalt für Gewässerkunde |
4dd33b86dc61
Added header to river backend.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5838
diff
changeset
|
2 * Software engineering by Intevation GmbH |
4dd33b86dc61
Added header to river backend.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5838
diff
changeset
|
3 * |
5992
4c3ccf2b0304
Removed trailing whitespace.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5901
diff
changeset
|
4 * This file is Free Software under the GNU AGPL (>=v3) |
5844
4dd33b86dc61
Added header to river backend.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5838
diff
changeset
|
5 * and comes with ABSOLUTELY NO WARRANTY! Check out the |
5992
4c3ccf2b0304
Removed trailing whitespace.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5901
diff
changeset
|
6 * documentation coming with Dive4Elements River for details. |
5844
4dd33b86dc61
Added header to river backend.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5838
diff
changeset
|
7 */ |
4dd33b86dc61
Added header to river backend.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5838
diff
changeset
|
8 |
5829
18619c1e7c2a
Repaired internal references.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5828
diff
changeset
|
9 package org.dive4elements.river.importer.parsers; |
2811
8926571e47fb
Finished importing MINFO bed heights (single and epoch).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
10 |
8926571e47fb
Finished importing MINFO bed heights (single and epoch).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
11 import java.io.File; |
8975
a0a0a7f912ab
Added new columns bed_height.comment and sounding_width_info; extended the bed height parser for the new meta data and the min/max_height columns
mschaefer
parents:
8856
diff
changeset
|
12 import java.io.FileInputStream; |
a0a0a7f912ab
Added new columns bed_height.comment and sounding_width_info; extended the bed height parser for the new meta data and the min/max_height columns
mschaefer
parents:
8856
diff
changeset
|
13 import java.io.IOException; |
a0a0a7f912ab
Added new columns bed_height.comment and sounding_width_info; extended the bed height parser for the new meta data and the min/max_height columns
mschaefer
parents:
8856
diff
changeset
|
14 import java.io.InputStreamReader; |
a0a0a7f912ab
Added new columns bed_height.comment and sounding_width_info; extended the bed height parser for the new meta data and the min/max_height columns
mschaefer
parents:
8856
diff
changeset
|
15 import java.io.LineNumberReader; |
2811
8926571e47fb
Finished importing MINFO bed heights (single and epoch).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
16 import java.math.BigDecimal; |
8926571e47fb
Finished importing MINFO bed heights (single and epoch).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
17 import java.text.NumberFormat; |
8926571e47fb
Finished importing MINFO bed heights (single and epoch).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
18 import java.text.ParseException; |
8926571e47fb
Finished importing MINFO bed heights (single and epoch).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
19 import java.util.ArrayList; |
8926571e47fb
Finished importing MINFO bed heights (single and epoch).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
20 import java.util.Date; |
8975
a0a0a7f912ab
Added new columns bed_height.comment and sounding_width_info; extended the bed height parser for the new meta data and the min/max_height columns
mschaefer
parents:
8856
diff
changeset
|
21 import java.util.EnumMap; |
2811
8926571e47fb
Finished importing MINFO bed heights (single and epoch).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
22 import java.util.List; |
8975
a0a0a7f912ab
Added new columns bed_height.comment and sounding_width_info; extended the bed height parser for the new meta data and the min/max_height columns
mschaefer
parents:
8856
diff
changeset
|
23 import java.util.Locale; |
6273
e7526a074c0d
Bed height parser: check for duplicate stations
Tom Gottfried <tom.gottfried@intevation.de>
parents:
6236
diff
changeset
|
24 import java.util.TreeSet; |
2811
8926571e47fb
Finished importing MINFO bed heights (single and epoch).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
25 import java.util.regex.Matcher; |
8926571e47fb
Finished importing MINFO bed heights (single and epoch).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
26 import java.util.regex.Pattern; |
8926571e47fb
Finished importing MINFO bed heights (single and epoch).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
27 |
8926571e47fb
Finished importing MINFO bed heights (single and epoch).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
28 import org.apache.log4j.Logger; |
8975
a0a0a7f912ab
Added new columns bed_height.comment and sounding_width_info; extended the bed height parser for the new meta data and the min/max_height columns
mschaefer
parents:
8856
diff
changeset
|
29 import org.dive4elements.river.backend.utils.DateUtil; |
a0a0a7f912ab
Added new columns bed_height.comment and sounding_width_info; extended the bed height parser for the new meta data and the min/max_height columns
mschaefer
parents:
8856
diff
changeset
|
30 import org.dive4elements.river.backend.utils.EpsilonComparator; |
8559
6d8d7425a6b5
Bed heights are just bed heights since a while ('single' is obsolete).
"Tom Gottfried <tom@intevation.de>"
parents:
8557
diff
changeset
|
31 import org.dive4elements.river.importer.ImportBedHeight; |
8975
a0a0a7f912ab
Added new columns bed_height.comment and sounding_width_info; extended the bed height parser for the new meta data and the min/max_height columns
mschaefer
parents:
8856
diff
changeset
|
32 import org.dive4elements.river.importer.ImportBedHeightType; |
8559
6d8d7425a6b5
Bed heights are just bed heights since a while ('single' is obsolete).
"Tom Gottfried <tom@intevation.de>"
parents:
8557
diff
changeset
|
33 import org.dive4elements.river.importer.ImportBedHeightValue; |
5829
18619c1e7c2a
Repaired internal references.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5828
diff
changeset
|
34 import org.dive4elements.river.importer.ImportElevationModel; |
18619c1e7c2a
Repaired internal references.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5828
diff
changeset
|
35 import org.dive4elements.river.importer.ImportLocationSystem; |
18619c1e7c2a
Repaired internal references.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5828
diff
changeset
|
36 import org.dive4elements.river.importer.ImportRange; |
18619c1e7c2a
Repaired internal references.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5828
diff
changeset
|
37 import org.dive4elements.river.importer.ImportTimeInterval; |
18619c1e7c2a
Repaired internal references.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5828
diff
changeset
|
38 import org.dive4elements.river.importer.ImportUnit; |
18619c1e7c2a
Repaired internal references.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5828
diff
changeset
|
39 import org.dive4elements.river.importer.ImporterSession; |
8989
2693bfaf503d
Fixed several BigDecimal(double) creations by BigDecimal(String) parsing to avoid unnecessary decimal digits
mschaefer
parents:
8975
diff
changeset
|
40 import org.dive4elements.river.importer.common.AbstractParser; |
8975
a0a0a7f912ab
Added new columns bed_height.comment and sounding_width_info; extended the bed height parser for the new meta data and the min/max_height columns
mschaefer
parents:
8856
diff
changeset
|
41 import org.dive4elements.river.model.BedHeightType; |
2811
8926571e47fb
Finished importing MINFO bed heights (single and epoch).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
42 |
8557
29ab66ce06aa
Abstract parser for bed heights is obsolete.
"Tom Gottfried <tom@intevation.de>"
parents:
8556
diff
changeset
|
43 public class BedHeightParser { |
2811
8926571e47fb
Finished importing MINFO bed heights (single and epoch).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
44 |
8926571e47fb
Finished importing MINFO bed heights (single and epoch).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
45 private static final Logger log = |
8975
a0a0a7f912ab
Added new columns bed_height.comment and sounding_width_info; extended the bed height parser for the new meta data and the min/max_height columns
mschaefer
parents:
8856
diff
changeset
|
46 Logger.getLogger(BedHeightParser.class); |
2811
8926571e47fb
Finished importing MINFO bed heights (single and epoch).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
47 |
8926571e47fb
Finished importing MINFO bed heights (single and epoch).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
48 public static final String ENCODING = "ISO-8859-1"; |
8926571e47fb
Finished importing MINFO bed heights (single and epoch).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
49 |
8926571e47fb
Finished importing MINFO bed heights (single and epoch).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
50 public static final Locale DEFAULT_LOCALE = Locale.GERMAN; |
8926571e47fb
Finished importing MINFO bed heights (single and epoch).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
51 |
8926571e47fb
Finished importing MINFO bed heights (single and epoch).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
52 public static final String START_META_CHAR = "#"; |
8926571e47fb
Finished importing MINFO bed heights (single and epoch).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
53 public static final String SEPERATOR_CHAR = ";"; |
8926571e47fb
Finished importing MINFO bed heights (single and epoch).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
54 |
8926571e47fb
Finished importing MINFO bed heights (single and epoch).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
55 public static final Pattern META_YEAR = |
8975
a0a0a7f912ab
Added new columns bed_height.comment and sounding_width_info; extended the bed height parser for the new meta data and the min/max_height columns
mschaefer
parents:
8856
diff
changeset
|
56 Pattern.compile("^Jahr: [^0-9]*(\\d*).*", Pattern.CASE_INSENSITIVE); |
2811
8926571e47fb
Finished importing MINFO bed heights (single and epoch).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
57 |
8926571e47fb
Finished importing MINFO bed heights (single and epoch).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
58 public static final Pattern META_TIMEINTERVAL = |
8975
a0a0a7f912ab
Added new columns bed_height.comment and sounding_width_info; extended the bed height parser for the new meta data and the min/max_height columns
mschaefer
parents:
8856
diff
changeset
|
59 Pattern.compile("^Zeitraum: Epoche (\\d*)-(\\d*).*", Pattern.CASE_INSENSITIVE); |
2811
8926571e47fb
Finished importing MINFO bed heights (single and epoch).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
60 |
8926571e47fb
Finished importing MINFO bed heights (single and epoch).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
61 public static final Pattern META_TYPE = |
8975
a0a0a7f912ab
Added new columns bed_height.comment and sounding_width_info; extended the bed height parser for the new meta data and the min/max_height columns
mschaefer
parents:
8856
diff
changeset
|
62 Pattern.compile("^Aufnahmeart: (.*).*", Pattern.CASE_INSENSITIVE); |
2811
8926571e47fb
Finished importing MINFO bed heights (single and epoch).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
63 |
8926571e47fb
Finished importing MINFO bed heights (single and epoch).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
64 public static final Pattern META_LOCATION_SYSTEM = |
8975
a0a0a7f912ab
Added new columns bed_height.comment and sounding_width_info; extended the bed height parser for the new meta data and the min/max_height columns
mschaefer
parents:
8856
diff
changeset
|
65 Pattern.compile("^Lagesystem: (.*).*", Pattern.CASE_INSENSITIVE); |
2811
8926571e47fb
Finished importing MINFO bed heights (single and epoch).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
66 |
8926571e47fb
Finished importing MINFO bed heights (single and epoch).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
67 public static final Pattern META_CUR_ELEVATION_SYSTEM = |
8975
a0a0a7f912ab
Added new columns bed_height.comment and sounding_width_info; extended the bed height parser for the new meta data and the min/max_height columns
mschaefer
parents:
8856
diff
changeset
|
68 Pattern.compile("^H.hensystem:\\s(.*)?? \\[(.*)\\].*", Pattern.CASE_INSENSITIVE); |
2811
8926571e47fb
Finished importing MINFO bed heights (single and epoch).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
69 |
8926571e47fb
Finished importing MINFO bed heights (single and epoch).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
70 public static final Pattern META_OLD_ELEVATION_SYSTEM = |
8975
a0a0a7f912ab
Added new columns bed_height.comment and sounding_width_info; extended the bed height parser for the new meta data and the min/max_height columns
mschaefer
parents:
8856
diff
changeset
|
71 Pattern.compile("^urspr.ngliches H.hensystem:\\s(.*)?? \\[(.*)\\].*", Pattern.CASE_INSENSITIVE); |
2811
8926571e47fb
Finished importing MINFO bed heights (single and epoch).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
72 |
8926571e47fb
Finished importing MINFO bed heights (single and epoch).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
73 public static final Pattern META_RANGE = |
8975
a0a0a7f912ab
Added new columns bed_height.comment and sounding_width_info; extended the bed height parser for the new meta data and the min/max_height columns
mschaefer
parents:
8856
diff
changeset
|
74 Pattern.compile("^Strecke:\\D*(\\d++.?\\d*) ?- ?(\\d++.?\\d*).*", Pattern.CASE_INSENSITIVE); |
2811
8926571e47fb
Finished importing MINFO bed heights (single and epoch).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
75 |
8926571e47fb
Finished importing MINFO bed heights (single and epoch).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
76 public static final Pattern META_EVALUATION_BY = |
8975
a0a0a7f912ab
Added new columns bed_height.comment and sounding_width_info; extended the bed height parser for the new meta data and the min/max_height columns
mschaefer
parents:
8856
diff
changeset
|
77 Pattern.compile("^Auswerter: (.*).*", Pattern.CASE_INSENSITIVE); |
a0a0a7f912ab
Added new columns bed_height.comment and sounding_width_info; extended the bed height parser for the new meta data and the min/max_height columns
mschaefer
parents:
8856
diff
changeset
|
78 |
a0a0a7f912ab
Added new columns bed_height.comment and sounding_width_info; extended the bed height parser for the new meta data and the min/max_height columns
mschaefer
parents:
8856
diff
changeset
|
79 public static final Pattern META_SOUNDING_WIDTH = Pattern.compile("^ausgewertete Peilbreite:\\s*(\\S.*).*", Pattern.CASE_INSENSITIVE); |
2811
8926571e47fb
Finished importing MINFO bed heights (single and epoch).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
80 |
8926571e47fb
Finished importing MINFO bed heights (single and epoch).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
81 public static final Pattern META_COMMENTS = |
8975
a0a0a7f912ab
Added new columns bed_height.comment and sounding_width_info; extended the bed height parser for the new meta data and the min/max_height columns
mschaefer
parents:
8856
diff
changeset
|
82 Pattern.compile("^Weitere Bemerkungen: (.*).*", Pattern.CASE_INSENSITIVE); |
2811
8926571e47fb
Finished importing MINFO bed heights (single and epoch).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
83 |
8975
a0a0a7f912ab
Added new columns bed_height.comment and sounding_width_info; extended the bed height parser for the new meta data and the min/max_height columns
mschaefer
parents:
8856
diff
changeset
|
84 private static final Pattern META_COLUMNTITLES = Pattern.compile("^Fluss-km\\s*;.+", Pattern.CASE_INSENSITIVE); |
2811
8926571e47fb
Finished importing MINFO bed heights (single and epoch).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
85 |
8975
a0a0a7f912ab
Added new columns bed_height.comment and sounding_width_info; extended the bed height parser for the new meta data and the min/max_height columns
mschaefer
parents:
8856
diff
changeset
|
86 private enum ColTitlePattern { |
a0a0a7f912ab
Added new columns bed_height.comment and sounding_width_info; extended the bed height parser for the new meta data and the min/max_height columns
mschaefer
parents:
8856
diff
changeset
|
87 KM("Fluss-km.*"), // |
a0a0a7f912ab
Added new columns bed_height.comment and sounding_width_info; extended the bed height parser for the new meta data and the min/max_height columns
mschaefer
parents:
8856
diff
changeset
|
88 HEIGHT("mittlere Sohlh.he\\s*\\[(.*)\\].*"), // |
a0a0a7f912ab
Added new columns bed_height.comment and sounding_width_info; extended the bed height parser for the new meta data and the min/max_height columns
mschaefer
parents:
8856
diff
changeset
|
89 UNCERTAINTY("Unsicherheit\\s*\\[(.*)\\].*"), // |
a0a0a7f912ab
Added new columns bed_height.comment and sounding_width_info; extended the bed height parser for the new meta data and the min/max_height columns
mschaefer
parents:
8856
diff
changeset
|
90 GAP("Datenl.cke.*"), // |
a0a0a7f912ab
Added new columns bed_height.comment and sounding_width_info; extended the bed height parser for the new meta data and the min/max_height columns
mschaefer
parents:
8856
diff
changeset
|
91 WIDTH("Peilbreite\\s*\\[(.*)\\].*"), // |
a0a0a7f912ab
Added new columns bed_height.comment and sounding_width_info; extended the bed height parser for the new meta data and the min/max_height columns
mschaefer
parents:
8856
diff
changeset
|
92 MINHEIGHT("Minimale Sohlh.he\\s*\\[(.*)\\].*"), // |
9034
8aa7d9eaaa21
Added bed_height_values section heights height01 to height10
mschaefer
parents:
8989
diff
changeset
|
93 MAXHEIGHT("Maximale Sohlh.he\\s*\\[(.*)\\].*"), // |
8aa7d9eaaa21
Added bed_height_values section heights height01 to height10
mschaefer
parents:
8989
diff
changeset
|
94 HEIGHT01("Feld\\s*1\\s*\\[(.*)\\].*"), // |
8aa7d9eaaa21
Added bed_height_values section heights height01 to height10
mschaefer
parents:
8989
diff
changeset
|
95 HEIGHT02("Feld\\s*2\\s*\\[(.*)\\].*"), // |
8aa7d9eaaa21
Added bed_height_values section heights height01 to height10
mschaefer
parents:
8989
diff
changeset
|
96 HEIGHT03("Feld\\s*3\\s*\\[(.*)\\].*"), // |
8aa7d9eaaa21
Added bed_height_values section heights height01 to height10
mschaefer
parents:
8989
diff
changeset
|
97 HEIGHT04("Feld\\s*4\\s*\\[(.*)\\].*"), // |
8aa7d9eaaa21
Added bed_height_values section heights height01 to height10
mschaefer
parents:
8989
diff
changeset
|
98 HEIGHT05("Feld\\s*5\\s*\\[(.*)\\].*"), // |
8aa7d9eaaa21
Added bed_height_values section heights height01 to height10
mschaefer
parents:
8989
diff
changeset
|
99 HEIGHT06("Feld\\s*6\\s*\\[(.*)\\].*"), // |
8aa7d9eaaa21
Added bed_height_values section heights height01 to height10
mschaefer
parents:
8989
diff
changeset
|
100 HEIGHT07("Feld\\s*7\\s*\\[(.*)\\].*"), // |
8aa7d9eaaa21
Added bed_height_values section heights height01 to height10
mschaefer
parents:
8989
diff
changeset
|
101 HEIGHT08("Feld\\s*8\\s*\\[(.*)\\].*"), // |
8aa7d9eaaa21
Added bed_height_values section heights height01 to height10
mschaefer
parents:
8989
diff
changeset
|
102 HEIGHT09("Feld\\s*9\\s*\\[(.*)\\].*"), // |
8aa7d9eaaa21
Added bed_height_values section heights height01 to height10
mschaefer
parents:
8989
diff
changeset
|
103 HEIGHT10("Feld\\s*10\\s*\\[(.*)\\].*"); |
8975
a0a0a7f912ab
Added new columns bed_height.comment and sounding_width_info; extended the bed height parser for the new meta data and the min/max_height columns
mschaefer
parents:
8856
diff
changeset
|
104 |
a0a0a7f912ab
Added new columns bed_height.comment and sounding_width_info; extended the bed height parser for the new meta data and the min/max_height columns
mschaefer
parents:
8856
diff
changeset
|
105 private final Pattern pattern; |
a0a0a7f912ab
Added new columns bed_height.comment and sounding_width_info; extended the bed height parser for the new meta data and the min/max_height columns
mschaefer
parents:
8856
diff
changeset
|
106 |
a0a0a7f912ab
Added new columns bed_height.comment and sounding_width_info; extended the bed height parser for the new meta data and the min/max_height columns
mschaefer
parents:
8856
diff
changeset
|
107 private ColTitlePattern(final String regexp) { |
a0a0a7f912ab
Added new columns bed_height.comment and sounding_width_info; extended the bed height parser for the new meta data and the min/max_height columns
mschaefer
parents:
8856
diff
changeset
|
108 this.pattern = Pattern.compile(regexp, Pattern.CASE_INSENSITIVE); |
a0a0a7f912ab
Added new columns bed_height.comment and sounding_width_info; extended the bed height parser for the new meta data and the min/max_height columns
mschaefer
parents:
8856
diff
changeset
|
109 } |
a0a0a7f912ab
Added new columns bed_height.comment and sounding_width_info; extended the bed height parser for the new meta data and the min/max_height columns
mschaefer
parents:
8856
diff
changeset
|
110 |
a0a0a7f912ab
Added new columns bed_height.comment and sounding_width_info; extended the bed height parser for the new meta data and the min/max_height columns
mschaefer
parents:
8856
diff
changeset
|
111 public Pattern getPattern() { |
a0a0a7f912ab
Added new columns bed_height.comment and sounding_width_info; extended the bed height parser for the new meta data and the min/max_height columns
mschaefer
parents:
8856
diff
changeset
|
112 return this.pattern; |
a0a0a7f912ab
Added new columns bed_height.comment and sounding_width_info; extended the bed height parser for the new meta data and the min/max_height columns
mschaefer
parents:
8856
diff
changeset
|
113 } |
9034
8aa7d9eaaa21
Added bed_height_values section heights height01 to height10
mschaefer
parents:
8989
diff
changeset
|
114 |
8aa7d9eaaa21
Added bed_height_values section heights height01 to height10
mschaefer
parents:
8989
diff
changeset
|
115 public static ColTitlePattern getSectionPattern(final int index) { |
8aa7d9eaaa21
Added bed_height_values section heights height01 to height10
mschaefer
parents:
8989
diff
changeset
|
116 return ColTitlePattern.valueOf(String.format("HEIGHT%02d", index)); |
8aa7d9eaaa21
Added bed_height_values section heights height01 to height10
mschaefer
parents:
8989
diff
changeset
|
117 } |
8975
a0a0a7f912ab
Added new columns bed_height.comment and sounding_width_info; extended the bed height parser for the new meta data and the min/max_height columns
mschaefer
parents:
8856
diff
changeset
|
118 } |
a0a0a7f912ab
Added new columns bed_height.comment and sounding_width_info; extended the bed height parser for the new meta data and the min/max_height columns
mschaefer
parents:
8856
diff
changeset
|
119 |
a0a0a7f912ab
Added new columns bed_height.comment and sounding_width_info; extended the bed height parser for the new meta data and the min/max_height columns
mschaefer
parents:
8856
diff
changeset
|
120 private final EnumMap<ColTitlePattern, Integer> cols = new EnumMap<>(ColTitlePattern.class); |
a0a0a7f912ab
Added new columns bed_height.comment and sounding_width_info; extended the bed height parser for the new meta data and the min/max_height columns
mschaefer
parents:
8856
diff
changeset
|
121 |
a0a0a7f912ab
Added new columns bed_height.comment and sounding_width_info; extended the bed height parser for the new meta data and the min/max_height columns
mschaefer
parents:
8856
diff
changeset
|
122 protected static NumberFormat nf = NumberFormat.getInstance(DEFAULT_LOCALE); |
2811
8926571e47fb
Finished importing MINFO bed heights (single and epoch).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
123 |
8926571e47fb
Finished importing MINFO bed heights (single and epoch).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
124 |
8559
6d8d7425a6b5
Bed heights are just bed heights since a while ('single' is obsolete).
"Tom Gottfried <tom@intevation.de>"
parents:
8557
diff
changeset
|
125 protected List<ImportBedHeight> bedHeights; |
2811
8926571e47fb
Finished importing MINFO bed heights (single and epoch).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
126 |
8926571e47fb
Finished importing MINFO bed heights (single and epoch).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
127 |
8975
a0a0a7f912ab
Added new columns bed_height.comment and sounding_width_info; extended the bed height parser for the new meta data and the min/max_height columns
mschaefer
parents:
8856
diff
changeset
|
128 protected ImportBedHeight newImportBedHeight(final String description) { |
8559
6d8d7425a6b5
Bed heights are just bed heights since a while ('single' is obsolete).
"Tom Gottfried <tom@intevation.de>"
parents:
8557
diff
changeset
|
129 return new ImportBedHeight(description); |
8557
29ab66ce06aa
Abstract parser for bed heights is obsolete.
"Tom Gottfried <tom@intevation.de>"
parents:
8556
diff
changeset
|
130 } |
2811
8926571e47fb
Finished importing MINFO bed heights (single and epoch).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
131 |
8926571e47fb
Finished importing MINFO bed heights (single and epoch).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
132 |
6273
e7526a074c0d
Bed height parser: check for duplicate stations
Tom Gottfried <tom.gottfried@intevation.de>
parents:
6236
diff
changeset
|
133 protected TreeSet<Double> kmExists; |
2811
8926571e47fb
Finished importing MINFO bed heights (single and epoch).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
134 |
8926571e47fb
Finished importing MINFO bed heights (single and epoch).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
135 public BedHeightParser() { |
8975
a0a0a7f912ab
Added new columns bed_height.comment and sounding_width_info; extended the bed height parser for the new meta data and the min/max_height columns
mschaefer
parents:
8856
diff
changeset
|
136 this.bedHeights = new ArrayList<>(); |
a0a0a7f912ab
Added new columns bed_height.comment and sounding_width_info; extended the bed height parser for the new meta data and the min/max_height columns
mschaefer
parents:
8856
diff
changeset
|
137 this.kmExists = new TreeSet<>(EpsilonComparator.CMP); |
2811
8926571e47fb
Finished importing MINFO bed heights (single and epoch).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
138 } |
8926571e47fb
Finished importing MINFO bed heights (single and epoch).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
139 |
8926571e47fb
Finished importing MINFO bed heights (single and epoch).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
140 |
8559
6d8d7425a6b5
Bed heights are just bed heights since a while ('single' is obsolete).
"Tom Gottfried <tom@intevation.de>"
parents:
8557
diff
changeset
|
141 public List<ImportBedHeight> getBedHeights() { |
8975
a0a0a7f912ab
Added new columns bed_height.comment and sounding_width_info; extended the bed height parser for the new meta data and the min/max_height columns
mschaefer
parents:
8856
diff
changeset
|
142 return this.bedHeights; |
2811
8926571e47fb
Finished importing MINFO bed heights (single and epoch).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
143 } |
8926571e47fb
Finished importing MINFO bed heights (single and epoch).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
144 |
8926571e47fb
Finished importing MINFO bed heights (single and epoch).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
145 |
8975
a0a0a7f912ab
Added new columns bed_height.comment and sounding_width_info; extended the bed height parser for the new meta data and the min/max_height columns
mschaefer
parents:
8856
diff
changeset
|
146 public void parse(final File file) throws IOException { |
2811
8926571e47fb
Finished importing MINFO bed heights (single and epoch).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
147 log.info("Parsing bed height single file '" + file + "'"); |
8975
a0a0a7f912ab
Added new columns bed_height.comment and sounding_width_info; extended the bed height parser for the new meta data and the min/max_height columns
mschaefer
parents:
8856
diff
changeset
|
148 final ImportBedHeight obj = newImportBedHeight(file.getName().replaceAll("\\.csv", "")); |
a0a0a7f912ab
Added new columns bed_height.comment and sounding_width_info; extended the bed height parser for the new meta data and the min/max_height columns
mschaefer
parents:
8856
diff
changeset
|
149 this.kmExists.clear(); |
a0a0a7f912ab
Added new columns bed_height.comment and sounding_width_info; extended the bed height parser for the new meta data and the min/max_height columns
mschaefer
parents:
8856
diff
changeset
|
150 this.cols.clear(); |
a0a0a7f912ab
Added new columns bed_height.comment and sounding_width_info; extended the bed height parser for the new meta data and the min/max_height columns
mschaefer
parents:
8856
diff
changeset
|
151 for (final ColTitlePattern col : ColTitlePattern.values()) |
a0a0a7f912ab
Added new columns bed_height.comment and sounding_width_info; extended the bed height parser for the new meta data and the min/max_height columns
mschaefer
parents:
8856
diff
changeset
|
152 this.cols.put(col, -1); |
2811
8926571e47fb
Finished importing MINFO bed heights (single and epoch).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
153 LineNumberReader in = null; |
8926571e47fb
Finished importing MINFO bed heights (single and epoch).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
154 try { |
8975
a0a0a7f912ab
Added new columns bed_height.comment and sounding_width_info; extended the bed height parser for the new meta data and the min/max_height columns
mschaefer
parents:
8856
diff
changeset
|
155 in = new LineNumberReader(new InputStreamReader(new FileInputStream(file), ENCODING)); |
2811
8926571e47fb
Finished importing MINFO bed heights (single and epoch).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
156 |
8926571e47fb
Finished importing MINFO bed heights (single and epoch).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
157 String line = null; |
8926571e47fb
Finished importing MINFO bed heights (single and epoch).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
158 while ((line = in.readLine()) != null) { |
8926571e47fb
Finished importing MINFO bed heights (single and epoch).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
159 if ((line = line.trim()).length() == 0) { |
8926571e47fb
Finished importing MINFO bed heights (single and epoch).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
160 continue; |
8926571e47fb
Finished importing MINFO bed heights (single and epoch).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
161 } |
8926571e47fb
Finished importing MINFO bed heights (single and epoch).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
162 |
8926571e47fb
Finished importing MINFO bed heights (single and epoch).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
163 if (line.startsWith(START_META_CHAR)) { |
8926571e47fb
Finished importing MINFO bed heights (single and epoch).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
164 handleMetaLine(obj, line); |
8926571e47fb
Finished importing MINFO bed heights (single and epoch).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
165 } |
8926571e47fb
Finished importing MINFO bed heights (single and epoch).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
166 else { |
8926571e47fb
Finished importing MINFO bed heights (single and epoch).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
167 handleDataLine(obj, line); |
8926571e47fb
Finished importing MINFO bed heights (single and epoch).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
168 } |
8926571e47fb
Finished importing MINFO bed heights (single and epoch).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
169 } |
8926571e47fb
Finished importing MINFO bed heights (single and epoch).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
170 |
8926571e47fb
Finished importing MINFO bed heights (single and epoch).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
171 log.info("File contained " + obj.getValueCount() + " values."); |
8975
a0a0a7f912ab
Added new columns bed_height.comment and sounding_width_info; extended the bed height parser for the new meta data and the min/max_height columns
mschaefer
parents:
8856
diff
changeset
|
172 this.bedHeights.add(obj); |
2811
8926571e47fb
Finished importing MINFO bed heights (single and epoch).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
173 } |
8926571e47fb
Finished importing MINFO bed heights (single and epoch).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
174 finally { |
8926571e47fb
Finished importing MINFO bed heights (single and epoch).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
175 if (in != null) { |
8926571e47fb
Finished importing MINFO bed heights (single and epoch).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
176 in.close(); |
8926571e47fb
Finished importing MINFO bed heights (single and epoch).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
177 } |
8926571e47fb
Finished importing MINFO bed heights (single and epoch).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
178 } |
8926571e47fb
Finished importing MINFO bed heights (single and epoch).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
179 } |
8926571e47fb
Finished importing MINFO bed heights (single and epoch).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
180 |
8926571e47fb
Finished importing MINFO bed heights (single and epoch).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
181 |
8975
a0a0a7f912ab
Added new columns bed_height.comment and sounding_width_info; extended the bed height parser for the new meta data and the min/max_height columns
mschaefer
parents:
8856
diff
changeset
|
182 protected static String stripMetaLine(final String line) { |
a0a0a7f912ab
Added new columns bed_height.comment and sounding_width_info; extended the bed height parser for the new meta data and the min/max_height columns
mschaefer
parents:
8856
diff
changeset
|
183 final String tmp = line.substring(1, line.length()); |
2811
8926571e47fb
Finished importing MINFO bed heights (single and epoch).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
184 |
8926571e47fb
Finished importing MINFO bed heights (single and epoch).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
185 if (tmp.startsWith(" ")) { |
8926571e47fb
Finished importing MINFO bed heights (single and epoch).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
186 return tmp.substring(1, tmp.length()); |
8926571e47fb
Finished importing MINFO bed heights (single and epoch).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
187 } |
8926571e47fb
Finished importing MINFO bed heights (single and epoch).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
188 else { |
8926571e47fb
Finished importing MINFO bed heights (single and epoch).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
189 return tmp; |
8926571e47fb
Finished importing MINFO bed heights (single and epoch).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
190 } |
8926571e47fb
Finished importing MINFO bed heights (single and epoch).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
191 } |
8926571e47fb
Finished importing MINFO bed heights (single and epoch).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
192 |
8926571e47fb
Finished importing MINFO bed heights (single and epoch).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
193 |
8975
a0a0a7f912ab
Added new columns bed_height.comment and sounding_width_info; extended the bed height parser for the new meta data and the min/max_height columns
mschaefer
parents:
8856
diff
changeset
|
194 protected void handleMetaLine(final ImportBedHeight obj, final String line) { |
a0a0a7f912ab
Added new columns bed_height.comment and sounding_width_info; extended the bed height parser for the new meta data and the min/max_height columns
mschaefer
parents:
8856
diff
changeset
|
195 final String meta = stripMetaLine(line); |
2811
8926571e47fb
Finished importing MINFO bed heights (single and epoch).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
196 |
8926571e47fb
Finished importing MINFO bed heights (single and epoch).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
197 if (handleMetaYear(obj, meta)) { |
8926571e47fb
Finished importing MINFO bed heights (single and epoch).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
198 return; |
8926571e47fb
Finished importing MINFO bed heights (single and epoch).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
199 } |
8926571e47fb
Finished importing MINFO bed heights (single and epoch).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
200 else if (handleMetaTimeInterval(obj, meta)) { |
8926571e47fb
Finished importing MINFO bed heights (single and epoch).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
201 return; |
8926571e47fb
Finished importing MINFO bed heights (single and epoch).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
202 } |
8926571e47fb
Finished importing MINFO bed heights (single and epoch).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
203 else if (handleMetaComment(obj, meta)) { |
8926571e47fb
Finished importing MINFO bed heights (single and epoch).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
204 return; |
8926571e47fb
Finished importing MINFO bed heights (single and epoch).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
205 } |
8926571e47fb
Finished importing MINFO bed heights (single and epoch).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
206 else if (handleMetaEvaluationBy(obj, meta)) { |
8926571e47fb
Finished importing MINFO bed heights (single and epoch).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
207 return; |
8926571e47fb
Finished importing MINFO bed heights (single and epoch).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
208 } |
8926571e47fb
Finished importing MINFO bed heights (single and epoch).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
209 else if (handleMetaRange(obj, meta)) { |
8926571e47fb
Finished importing MINFO bed heights (single and epoch).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
210 return; |
8926571e47fb
Finished importing MINFO bed heights (single and epoch).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
211 } |
8926571e47fb
Finished importing MINFO bed heights (single and epoch).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
212 else if (handleMetaType(obj, meta)) { |
8926571e47fb
Finished importing MINFO bed heights (single and epoch).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
213 return; |
8926571e47fb
Finished importing MINFO bed heights (single and epoch).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
214 } |
8926571e47fb
Finished importing MINFO bed heights (single and epoch).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
215 else if (handleMetaLocationSystem(obj, meta)) { |
8926571e47fb
Finished importing MINFO bed heights (single and epoch).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
216 return; |
8926571e47fb
Finished importing MINFO bed heights (single and epoch).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
217 } |
8926571e47fb
Finished importing MINFO bed heights (single and epoch).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
218 else if (handleMetaCurElevationModel(obj, meta)) { |
8926571e47fb
Finished importing MINFO bed heights (single and epoch).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
219 return; |
8926571e47fb
Finished importing MINFO bed heights (single and epoch).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
220 } |
8926571e47fb
Finished importing MINFO bed heights (single and epoch).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
221 else if (handleMetaOldElevationModel(obj, meta)) { |
8926571e47fb
Finished importing MINFO bed heights (single and epoch).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
222 return; |
8926571e47fb
Finished importing MINFO bed heights (single and epoch).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
223 } |
8975
a0a0a7f912ab
Added new columns bed_height.comment and sounding_width_info; extended the bed height parser for the new meta data and the min/max_height columns
mschaefer
parents:
8856
diff
changeset
|
224 else if (handleMetaSoundingWidth(obj, meta)) { |
a0a0a7f912ab
Added new columns bed_height.comment and sounding_width_info; extended the bed height parser for the new meta data and the min/max_height columns
mschaefer
parents:
8856
diff
changeset
|
225 return; |
a0a0a7f912ab
Added new columns bed_height.comment and sounding_width_info; extended the bed height parser for the new meta data and the min/max_height columns
mschaefer
parents:
8856
diff
changeset
|
226 } |
a0a0a7f912ab
Added new columns bed_height.comment and sounding_width_info; extended the bed height parser for the new meta data and the min/max_height columns
mschaefer
parents:
8856
diff
changeset
|
227 else if (handleMetaColumnTitles(obj, meta)) { |
a0a0a7f912ab
Added new columns bed_height.comment and sounding_width_info; extended the bed height parser for the new meta data and the min/max_height columns
mschaefer
parents:
8856
diff
changeset
|
228 return; |
a0a0a7f912ab
Added new columns bed_height.comment and sounding_width_info; extended the bed height parser for the new meta data and the min/max_height columns
mschaefer
parents:
8856
diff
changeset
|
229 } |
2811
8926571e47fb
Finished importing MINFO bed heights (single and epoch).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
230 else { |
3662
0d27d02b1208
backend: Completed the error messages of the importer.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2811
diff
changeset
|
231 log.warn("BHP: Meta line did not match any known type: " + line); |
2811
8926571e47fb
Finished importing MINFO bed heights (single and epoch).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
232 } |
8926571e47fb
Finished importing MINFO bed heights (single and epoch).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
233 } |
8926571e47fb
Finished importing MINFO bed heights (single and epoch).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
234 |
8926571e47fb
Finished importing MINFO bed heights (single and epoch).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
235 |
8975
a0a0a7f912ab
Added new columns bed_height.comment and sounding_width_info; extended the bed height parser for the new meta data and the min/max_height columns
mschaefer
parents:
8856
diff
changeset
|
236 protected boolean handleMetaYear(final ImportBedHeight obj, final String line) { |
a0a0a7f912ab
Added new columns bed_height.comment and sounding_width_info; extended the bed height parser for the new meta data and the min/max_height columns
mschaefer
parents:
8856
diff
changeset
|
237 final Matcher m = META_YEAR.matcher(line); |
2811
8926571e47fb
Finished importing MINFO bed heights (single and epoch).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
238 if (m.matches()) { |
8975
a0a0a7f912ab
Added new columns bed_height.comment and sounding_width_info; extended the bed height parser for the new meta data and the min/max_height columns
mschaefer
parents:
8856
diff
changeset
|
239 final String tmp = m.group(1).trim(); |
5327
5376aa576604
Allow empty years in bed height parser.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5278
diff
changeset
|
240 if (tmp.length() > 0) { |
5376aa576604
Allow empty years in bed height parser.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5278
diff
changeset
|
241 obj.setYear(Integer.parseInt(tmp)); |
2811
8926571e47fb
Finished importing MINFO bed heights (single and epoch).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
242 } |
5327
5376aa576604
Allow empty years in bed height parser.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5278
diff
changeset
|
243 else { |
5376aa576604
Allow empty years in bed height parser.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5278
diff
changeset
|
244 log.warn("BHP: No year given."); |
2811
8926571e47fb
Finished importing MINFO bed heights (single and epoch).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
245 } |
5327
5376aa576604
Allow empty years in bed height parser.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5278
diff
changeset
|
246 return true; |
2811
8926571e47fb
Finished importing MINFO bed heights (single and epoch).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
247 } |
8926571e47fb
Finished importing MINFO bed heights (single and epoch).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
248 return false; |
8926571e47fb
Finished importing MINFO bed heights (single and epoch).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
249 } |
8926571e47fb
Finished importing MINFO bed heights (single and epoch).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
250 |
8926571e47fb
Finished importing MINFO bed heights (single and epoch).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
251 |
8975
a0a0a7f912ab
Added new columns bed_height.comment and sounding_width_info; extended the bed height parser for the new meta data and the min/max_height columns
mschaefer
parents:
8856
diff
changeset
|
252 protected boolean handleMetaTimeInterval(final ImportBedHeight obj, final String line) { |
a0a0a7f912ab
Added new columns bed_height.comment and sounding_width_info; extended the bed height parser for the new meta data and the min/max_height columns
mschaefer
parents:
8856
diff
changeset
|
253 final Matcher m = META_TIMEINTERVAL.matcher(line); |
2811
8926571e47fb
Finished importing MINFO bed heights (single and epoch).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
254 if (m.matches()) { |
8975
a0a0a7f912ab
Added new columns bed_height.comment and sounding_width_info; extended the bed height parser for the new meta data and the min/max_height columns
mschaefer
parents:
8856
diff
changeset
|
255 final String lo = m.group(1).trim(); |
a0a0a7f912ab
Added new columns bed_height.comment and sounding_width_info; extended the bed height parser for the new meta data and the min/max_height columns
mschaefer
parents:
8856
diff
changeset
|
256 final String up = m.group(2).trim(); |
a0a0a7f912ab
Added new columns bed_height.comment and sounding_width_info; extended the bed height parser for the new meta data and the min/max_height columns
mschaefer
parents:
8856
diff
changeset
|
257 log.debug("Found time interval: " + lo + " - " + up); |
a0a0a7f912ab
Added new columns bed_height.comment and sounding_width_info; extended the bed height parser for the new meta data and the min/max_height columns
mschaefer
parents:
8856
diff
changeset
|
258 try { |
a0a0a7f912ab
Added new columns bed_height.comment and sounding_width_info; extended the bed height parser for the new meta data and the min/max_height columns
mschaefer
parents:
8856
diff
changeset
|
259 final int lower = Integer.valueOf(lo); |
a0a0a7f912ab
Added new columns bed_height.comment and sounding_width_info; extended the bed height parser for the new meta data and the min/max_height columns
mschaefer
parents:
8856
diff
changeset
|
260 final int upper = Integer.valueOf(up); |
a0a0a7f912ab
Added new columns bed_height.comment and sounding_width_info; extended the bed height parser for the new meta data and the min/max_height columns
mschaefer
parents:
8856
diff
changeset
|
261 final Date fromYear = DateUtil.getStartDateFromYear(lower); |
a0a0a7f912ab
Added new columns bed_height.comment and sounding_width_info; extended the bed height parser for the new meta data and the min/max_height columns
mschaefer
parents:
8856
diff
changeset
|
262 final Date toYear = DateUtil.getEndDateFromYear(upper); |
a0a0a7f912ab
Added new columns bed_height.comment and sounding_width_info; extended the bed height parser for the new meta data and the min/max_height columns
mschaefer
parents:
8856
diff
changeset
|
263 obj.setTimeInterval(new ImportTimeInterval(fromYear, toYear)); |
a0a0a7f912ab
Added new columns bed_height.comment and sounding_width_info; extended the bed height parser for the new meta data and the min/max_height columns
mschaefer
parents:
8856
diff
changeset
|
264 } |
a0a0a7f912ab
Added new columns bed_height.comment and sounding_width_info; extended the bed height parser for the new meta data and the min/max_height columns
mschaefer
parents:
8856
diff
changeset
|
265 catch (final NumberFormatException e) { |
a0a0a7f912ab
Added new columns bed_height.comment and sounding_width_info; extended the bed height parser for the new meta data and the min/max_height columns
mschaefer
parents:
8856
diff
changeset
|
266 log.warn("BHP: could not parse timeinterval", e); |
a0a0a7f912ab
Added new columns bed_height.comment and sounding_width_info; extended the bed height parser for the new meta data and the min/max_height columns
mschaefer
parents:
8856
diff
changeset
|
267 } |
2811
8926571e47fb
Finished importing MINFO bed heights (single and epoch).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
268 return true; |
8926571e47fb
Finished importing MINFO bed heights (single and epoch).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
269 } |
8926571e47fb
Finished importing MINFO bed heights (single and epoch).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
270 return false; |
8926571e47fb
Finished importing MINFO bed heights (single and epoch).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
271 } |
8926571e47fb
Finished importing MINFO bed heights (single and epoch).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
272 |
8926571e47fb
Finished importing MINFO bed heights (single and epoch).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
273 |
8975
a0a0a7f912ab
Added new columns bed_height.comment and sounding_width_info; extended the bed height parser for the new meta data and the min/max_height columns
mschaefer
parents:
8856
diff
changeset
|
274 protected boolean handleMetaComment(final ImportBedHeight obj, final String line) { |
a0a0a7f912ab
Added new columns bed_height.comment and sounding_width_info; extended the bed height parser for the new meta data and the min/max_height columns
mschaefer
parents:
8856
diff
changeset
|
275 final Matcher m = META_COMMENTS.matcher(line); |
a0a0a7f912ab
Added new columns bed_height.comment and sounding_width_info; extended the bed height parser for the new meta data and the min/max_height columns
mschaefer
parents:
8856
diff
changeset
|
276 if (m.matches()) { |
a0a0a7f912ab
Added new columns bed_height.comment and sounding_width_info; extended the bed height parser for the new meta data and the min/max_height columns
mschaefer
parents:
8856
diff
changeset
|
277 final String tmp = m.group(1).replace(SEPERATOR_CHAR, "").trim(); |
9038
4c5eeaff554c
Database column "comment" renamed to "notes" (restrictions in Oracle)
mschaefer
parents:
9034
diff
changeset
|
278 obj.setNotes(tmp); |
8975
a0a0a7f912ab
Added new columns bed_height.comment and sounding_width_info; extended the bed height parser for the new meta data and the min/max_height columns
mschaefer
parents:
8856
diff
changeset
|
279 return true; |
2811
8926571e47fb
Finished importing MINFO bed heights (single and epoch).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
280 } |
8926571e47fb
Finished importing MINFO bed heights (single and epoch).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
281 return false; |
8926571e47fb
Finished importing MINFO bed heights (single and epoch).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
282 } |
8926571e47fb
Finished importing MINFO bed heights (single and epoch).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
283 |
8926571e47fb
Finished importing MINFO bed heights (single and epoch).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
284 |
8975
a0a0a7f912ab
Added new columns bed_height.comment and sounding_width_info; extended the bed height parser for the new meta data and the min/max_height columns
mschaefer
parents:
8856
diff
changeset
|
285 protected boolean handleMetaEvaluationBy(final ImportBedHeight obj, final String line) { |
a0a0a7f912ab
Added new columns bed_height.comment and sounding_width_info; extended the bed height parser for the new meta data and the min/max_height columns
mschaefer
parents:
8856
diff
changeset
|
286 final Matcher m = META_EVALUATION_BY.matcher(line); |
2811
8926571e47fb
Finished importing MINFO bed heights (single and epoch).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
287 if (m.matches()) { |
8975
a0a0a7f912ab
Added new columns bed_height.comment and sounding_width_info; extended the bed height parser for the new meta data and the min/max_height columns
mschaefer
parents:
8856
diff
changeset
|
288 final String tmp = m.group(1).replace(";", "").trim(); |
a0a0a7f912ab
Added new columns bed_height.comment and sounding_width_info; extended the bed height parser for the new meta data and the min/max_height columns
mschaefer
parents:
8856
diff
changeset
|
289 obj.setEvaluationBy(tmp); |
a0a0a7f912ab
Added new columns bed_height.comment and sounding_width_info; extended the bed height parser for the new meta data and the min/max_height columns
mschaefer
parents:
8856
diff
changeset
|
290 return true; |
a0a0a7f912ab
Added new columns bed_height.comment and sounding_width_info; extended the bed height parser for the new meta data and the min/max_height columns
mschaefer
parents:
8856
diff
changeset
|
291 } |
a0a0a7f912ab
Added new columns bed_height.comment and sounding_width_info; extended the bed height parser for the new meta data and the min/max_height columns
mschaefer
parents:
8856
diff
changeset
|
292 return false; |
a0a0a7f912ab
Added new columns bed_height.comment and sounding_width_info; extended the bed height parser for the new meta data and the min/max_height columns
mschaefer
parents:
8856
diff
changeset
|
293 } |
2811
8926571e47fb
Finished importing MINFO bed heights (single and epoch).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
294 |
8926571e47fb
Finished importing MINFO bed heights (single and epoch).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
295 |
8975
a0a0a7f912ab
Added new columns bed_height.comment and sounding_width_info; extended the bed height parser for the new meta data and the min/max_height columns
mschaefer
parents:
8856
diff
changeset
|
296 protected boolean handleMetaRange(final ImportBedHeight obj, final String line) { |
a0a0a7f912ab
Added new columns bed_height.comment and sounding_width_info; extended the bed height parser for the new meta data and the min/max_height columns
mschaefer
parents:
8856
diff
changeset
|
297 final Matcher m = META_RANGE.matcher(line); |
a0a0a7f912ab
Added new columns bed_height.comment and sounding_width_info; extended the bed height parser for the new meta data and the min/max_height columns
mschaefer
parents:
8856
diff
changeset
|
298 if (m.matches() && m.groupCount() >= 2) { |
a0a0a7f912ab
Added new columns bed_height.comment and sounding_width_info; extended the bed height parser for the new meta data and the min/max_height columns
mschaefer
parents:
8856
diff
changeset
|
299 final String a = m.group(1).replace(";", "").trim(); |
a0a0a7f912ab
Added new columns bed_height.comment and sounding_width_info; extended the bed height parser for the new meta data and the min/max_height columns
mschaefer
parents:
8856
diff
changeset
|
300 final String b = m.group(2).replace(";", "").trim(); |
a0a0a7f912ab
Added new columns bed_height.comment and sounding_width_info; extended the bed height parser for the new meta data and the min/max_height columns
mschaefer
parents:
8856
diff
changeset
|
301 try { |
8989
2693bfaf503d
Fixed several BigDecimal(double) creations by BigDecimal(String) parsing to avoid unnecessary decimal digits
mschaefer
parents:
8975
diff
changeset
|
302 final BigDecimal lower = AbstractParser.parseDecimal(a); |
2693bfaf503d
Fixed several BigDecimal(double) creations by BigDecimal(String) parsing to avoid unnecessary decimal digits
mschaefer
parents:
8975
diff
changeset
|
303 final BigDecimal upper = AbstractParser.parseDecimal(b); |
8975
a0a0a7f912ab
Added new columns bed_height.comment and sounding_width_info; extended the bed height parser for the new meta data and the min/max_height columns
mschaefer
parents:
8856
diff
changeset
|
304 obj.setRange(new ImportRange(lower, upper)); |
a0a0a7f912ab
Added new columns bed_height.comment and sounding_width_info; extended the bed height parser for the new meta data and the min/max_height columns
mschaefer
parents:
8856
diff
changeset
|
305 return true; |
a0a0a7f912ab
Added new columns bed_height.comment and sounding_width_info; extended the bed height parser for the new meta data and the min/max_height columns
mschaefer
parents:
8856
diff
changeset
|
306 } |
8989
2693bfaf503d
Fixed several BigDecimal(double) creations by BigDecimal(String) parsing to avoid unnecessary decimal digits
mschaefer
parents:
8975
diff
changeset
|
307 catch (final Exception e) { |
8975
a0a0a7f912ab
Added new columns bed_height.comment and sounding_width_info; extended the bed height parser for the new meta data and the min/max_height columns
mschaefer
parents:
8856
diff
changeset
|
308 log.warn("BHP: could not parse range", e); |
a0a0a7f912ab
Added new columns bed_height.comment and sounding_width_info; extended the bed height parser for the new meta data and the min/max_height columns
mschaefer
parents:
8856
diff
changeset
|
309 } |
a0a0a7f912ab
Added new columns bed_height.comment and sounding_width_info; extended the bed height parser for the new meta data and the min/max_height columns
mschaefer
parents:
8856
diff
changeset
|
310 } |
a0a0a7f912ab
Added new columns bed_height.comment and sounding_width_info; extended the bed height parser for the new meta data and the min/max_height columns
mschaefer
parents:
8856
diff
changeset
|
311 return false; |
a0a0a7f912ab
Added new columns bed_height.comment and sounding_width_info; extended the bed height parser for the new meta data and the min/max_height columns
mschaefer
parents:
8856
diff
changeset
|
312 } |
a0a0a7f912ab
Added new columns bed_height.comment and sounding_width_info; extended the bed height parser for the new meta data and the min/max_height columns
mschaefer
parents:
8856
diff
changeset
|
313 |
a0a0a7f912ab
Added new columns bed_height.comment and sounding_width_info; extended the bed height parser for the new meta data and the min/max_height columns
mschaefer
parents:
8856
diff
changeset
|
314 |
a0a0a7f912ab
Added new columns bed_height.comment and sounding_width_info; extended the bed height parser for the new meta data and the min/max_height columns
mschaefer
parents:
8856
diff
changeset
|
315 protected boolean handleMetaType(final ImportBedHeight obj, final String line) { |
a0a0a7f912ab
Added new columns bed_height.comment and sounding_width_info; extended the bed height parser for the new meta data and the min/max_height columns
mschaefer
parents:
8856
diff
changeset
|
316 final Matcher m = META_TYPE.matcher(line); |
a0a0a7f912ab
Added new columns bed_height.comment and sounding_width_info; extended the bed height parser for the new meta data and the min/max_height columns
mschaefer
parents:
8856
diff
changeset
|
317 if (m.matches()) { |
a0a0a7f912ab
Added new columns bed_height.comment and sounding_width_info; extended the bed height parser for the new meta data and the min/max_height columns
mschaefer
parents:
8856
diff
changeset
|
318 final String tmp = m.group(1).replace(";", "").trim(); |
a0a0a7f912ab
Added new columns bed_height.comment and sounding_width_info; extended the bed height parser for the new meta data and the min/max_height columns
mschaefer
parents:
8856
diff
changeset
|
319 final BedHeightType bht = BedHeightType.fetchBedHeightTypeForType(tmp, ImporterSession.getInstance().getDatabaseSession()); |
5273
db196abd16ca
Use lookup table from bedd_height from database in importer.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
3960
diff
changeset
|
320 if (bht != null) { |
db196abd16ca
Use lookup table from bedd_height from database in importer.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
3960
diff
changeset
|
321 obj.setType(new ImportBedHeightType(bht)); |
3798
90f91ba077a8
Made importer more robust
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3662
diff
changeset
|
322 return true; |
90f91ba077a8
Made importer more robust
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3662
diff
changeset
|
323 } |
5901
92bc0aa3831d
BHP: more informative error instead of warning if file can not be imported.
Tom Gottfried <tom@intevation.de>
parents:
5845
diff
changeset
|
324 log.error("Unknown bed height type: '" + tmp + "'. File ignored."); |
2811
8926571e47fb
Finished importing MINFO bed heights (single and epoch).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
325 } |
8926571e47fb
Finished importing MINFO bed heights (single and epoch).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
326 return false; |
8926571e47fb
Finished importing MINFO bed heights (single and epoch).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
327 } |
8926571e47fb
Finished importing MINFO bed heights (single and epoch).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
328 |
8926571e47fb
Finished importing MINFO bed heights (single and epoch).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
329 |
8975
a0a0a7f912ab
Added new columns bed_height.comment and sounding_width_info; extended the bed height parser for the new meta data and the min/max_height columns
mschaefer
parents:
8856
diff
changeset
|
330 protected boolean handleMetaLocationSystem(final ImportBedHeight obj, final String line) { |
a0a0a7f912ab
Added new columns bed_height.comment and sounding_width_info; extended the bed height parser for the new meta data and the min/max_height columns
mschaefer
parents:
8856
diff
changeset
|
331 final Matcher m = META_LOCATION_SYSTEM.matcher(line); |
2811
8926571e47fb
Finished importing MINFO bed heights (single and epoch).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
332 if (m.matches()) { |
8975
a0a0a7f912ab
Added new columns bed_height.comment and sounding_width_info; extended the bed height parser for the new meta data and the min/max_height columns
mschaefer
parents:
8856
diff
changeset
|
333 final String tmp = m.group(1).replace(";", "").trim(); |
a0a0a7f912ab
Added new columns bed_height.comment and sounding_width_info; extended the bed height parser for the new meta data and the min/max_height columns
mschaefer
parents:
8856
diff
changeset
|
334 obj.setLocationSystem(new ImportLocationSystem(tmp, tmp)); |
2811
8926571e47fb
Finished importing MINFO bed heights (single and epoch).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
335 return true; |
8926571e47fb
Finished importing MINFO bed heights (single and epoch).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
336 } |
8926571e47fb
Finished importing MINFO bed heights (single and epoch).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
337 return false; |
8926571e47fb
Finished importing MINFO bed heights (single and epoch).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
338 } |
8557
29ab66ce06aa
Abstract parser for bed heights is obsolete.
"Tom Gottfried <tom@intevation.de>"
parents:
8556
diff
changeset
|
339 |
8689
ea676691e533
(issue1763) Reduce code-duplication (patch by Sascha Teichmann).
Tom Gottfried <tom@intevation.de>
parents:
8688
diff
changeset
|
340 |
8975
a0a0a7f912ab
Added new columns bed_height.comment and sounding_width_info; extended the bed height parser for the new meta data and the min/max_height columns
mschaefer
parents:
8856
diff
changeset
|
341 protected boolean handleMetaCurElevationModel(final ImportBedHeight obj, final String line) { |
a0a0a7f912ab
Added new columns bed_height.comment and sounding_width_info; extended the bed height parser for the new meta data and the min/max_height columns
mschaefer
parents:
8856
diff
changeset
|
342 final Matcher m = META_CUR_ELEVATION_SYSTEM.matcher(line); |
a0a0a7f912ab
Added new columns bed_height.comment and sounding_width_info; extended the bed height parser for the new meta data and the min/max_height columns
mschaefer
parents:
8856
diff
changeset
|
343 if (m.matches()) { |
a0a0a7f912ab
Added new columns bed_height.comment and sounding_width_info; extended the bed height parser for the new meta data and the min/max_height columns
mschaefer
parents:
8856
diff
changeset
|
344 final String name = m.group(1).trim(); |
a0a0a7f912ab
Added new columns bed_height.comment and sounding_width_info; extended the bed height parser for the new meta data and the min/max_height columns
mschaefer
parents:
8856
diff
changeset
|
345 final String unit = m.group(2).trim(); |
a0a0a7f912ab
Added new columns bed_height.comment and sounding_width_info; extended the bed height parser for the new meta data and the min/max_height columns
mschaefer
parents:
8856
diff
changeset
|
346 obj.setCurElevationModel(new ImportElevationModel(name, new ImportUnit(unit))); |
a0a0a7f912ab
Added new columns bed_height.comment and sounding_width_info; extended the bed height parser for the new meta data and the min/max_height columns
mschaefer
parents:
8856
diff
changeset
|
347 return true; |
8689
ea676691e533
(issue1763) Reduce code-duplication (patch by Sascha Teichmann).
Tom Gottfried <tom@intevation.de>
parents:
8688
diff
changeset
|
348 } |
8975
a0a0a7f912ab
Added new columns bed_height.comment and sounding_width_info; extended the bed height parser for the new meta data and the min/max_height columns
mschaefer
parents:
8856
diff
changeset
|
349 return false; |
8689
ea676691e533
(issue1763) Reduce code-duplication (patch by Sascha Teichmann).
Tom Gottfried <tom@intevation.de>
parents:
8688
diff
changeset
|
350 } |
ea676691e533
(issue1763) Reduce code-duplication (patch by Sascha Teichmann).
Tom Gottfried <tom@intevation.de>
parents:
8688
diff
changeset
|
351 |
8557
29ab66ce06aa
Abstract parser for bed heights is obsolete.
"Tom Gottfried <tom@intevation.de>"
parents:
8556
diff
changeset
|
352 |
8975
a0a0a7f912ab
Added new columns bed_height.comment and sounding_width_info; extended the bed height parser for the new meta data and the min/max_height columns
mschaefer
parents:
8856
diff
changeset
|
353 protected boolean handleMetaOldElevationModel(final ImportBedHeight obj, final String line) { |
a0a0a7f912ab
Added new columns bed_height.comment and sounding_width_info; extended the bed height parser for the new meta data and the min/max_height columns
mschaefer
parents:
8856
diff
changeset
|
354 final Matcher m = META_OLD_ELEVATION_SYSTEM.matcher(line); |
a0a0a7f912ab
Added new columns bed_height.comment and sounding_width_info; extended the bed height parser for the new meta data and the min/max_height columns
mschaefer
parents:
8856
diff
changeset
|
355 if (m.matches()) { |
a0a0a7f912ab
Added new columns bed_height.comment and sounding_width_info; extended the bed height parser for the new meta data and the min/max_height columns
mschaefer
parents:
8856
diff
changeset
|
356 final String name = m.group(1).trim(); |
a0a0a7f912ab
Added new columns bed_height.comment and sounding_width_info; extended the bed height parser for the new meta data and the min/max_height columns
mschaefer
parents:
8856
diff
changeset
|
357 final String unit = m.group(2).trim(); |
a0a0a7f912ab
Added new columns bed_height.comment and sounding_width_info; extended the bed height parser for the new meta data and the min/max_height columns
mschaefer
parents:
8856
diff
changeset
|
358 obj.setOldElevationModel(new ImportElevationModel(name, new ImportUnit(unit))); |
a0a0a7f912ab
Added new columns bed_height.comment and sounding_width_info; extended the bed height parser for the new meta data and the min/max_height columns
mschaefer
parents:
8856
diff
changeset
|
359 return true; |
a0a0a7f912ab
Added new columns bed_height.comment and sounding_width_info; extended the bed height parser for the new meta data and the min/max_height columns
mschaefer
parents:
8856
diff
changeset
|
360 } |
a0a0a7f912ab
Added new columns bed_height.comment and sounding_width_info; extended the bed height parser for the new meta data and the min/max_height columns
mschaefer
parents:
8856
diff
changeset
|
361 return false; |
a0a0a7f912ab
Added new columns bed_height.comment and sounding_width_info; extended the bed height parser for the new meta data and the min/max_height columns
mschaefer
parents:
8856
diff
changeset
|
362 } |
a0a0a7f912ab
Added new columns bed_height.comment and sounding_width_info; extended the bed height parser for the new meta data and the min/max_height columns
mschaefer
parents:
8856
diff
changeset
|
363 |
a0a0a7f912ab
Added new columns bed_height.comment and sounding_width_info; extended the bed height parser for the new meta data and the min/max_height columns
mschaefer
parents:
8856
diff
changeset
|
364 protected boolean handleMetaSoundingWidth(final ImportBedHeight obj, final String line) { |
a0a0a7f912ab
Added new columns bed_height.comment and sounding_width_info; extended the bed height parser for the new meta data and the min/max_height columns
mschaefer
parents:
8856
diff
changeset
|
365 final Matcher m = META_SOUNDING_WIDTH.matcher(line); |
a0a0a7f912ab
Added new columns bed_height.comment and sounding_width_info; extended the bed height parser for the new meta data and the min/max_height columns
mschaefer
parents:
8856
diff
changeset
|
366 if (m.matches()) { |
a0a0a7f912ab
Added new columns bed_height.comment and sounding_width_info; extended the bed height parser for the new meta data and the min/max_height columns
mschaefer
parents:
8856
diff
changeset
|
367 final String tmp = m.group(1).replace(SEPERATOR_CHAR, "").trim(); |
a0a0a7f912ab
Added new columns bed_height.comment and sounding_width_info; extended the bed height parser for the new meta data and the min/max_height columns
mschaefer
parents:
8856
diff
changeset
|
368 obj.setSoundingWidthInfo(tmp); |
a0a0a7f912ab
Added new columns bed_height.comment and sounding_width_info; extended the bed height parser for the new meta data and the min/max_height columns
mschaefer
parents:
8856
diff
changeset
|
369 return true; |
a0a0a7f912ab
Added new columns bed_height.comment and sounding_width_info; extended the bed height parser for the new meta data and the min/max_height columns
mschaefer
parents:
8856
diff
changeset
|
370 } |
a0a0a7f912ab
Added new columns bed_height.comment and sounding_width_info; extended the bed height parser for the new meta data and the min/max_height columns
mschaefer
parents:
8856
diff
changeset
|
371 return false; |
a0a0a7f912ab
Added new columns bed_height.comment and sounding_width_info; extended the bed height parser for the new meta data and the min/max_height columns
mschaefer
parents:
8856
diff
changeset
|
372 } |
a0a0a7f912ab
Added new columns bed_height.comment and sounding_width_info; extended the bed height parser for the new meta data and the min/max_height columns
mschaefer
parents:
8856
diff
changeset
|
373 |
a0a0a7f912ab
Added new columns bed_height.comment and sounding_width_info; extended the bed height parser for the new meta data and the min/max_height columns
mschaefer
parents:
8856
diff
changeset
|
374 |
a0a0a7f912ab
Added new columns bed_height.comment and sounding_width_info; extended the bed height parser for the new meta data and the min/max_height columns
mschaefer
parents:
8856
diff
changeset
|
375 /** |
a0a0a7f912ab
Added new columns bed_height.comment and sounding_width_info; extended the bed height parser for the new meta data and the min/max_height columns
mschaefer
parents:
8856
diff
changeset
|
376 * Tries to parse a line as column titles line |
a0a0a7f912ab
Added new columns bed_height.comment and sounding_width_info; extended the bed height parser for the new meta data and the min/max_height columns
mschaefer
parents:
8856
diff
changeset
|
377 */ |
a0a0a7f912ab
Added new columns bed_height.comment and sounding_width_info; extended the bed height parser for the new meta data and the min/max_height columns
mschaefer
parents:
8856
diff
changeset
|
378 protected boolean handleMetaColumnTitles(final ImportBedHeight obj, final String line) { |
a0a0a7f912ab
Added new columns bed_height.comment and sounding_width_info; extended the bed height parser for the new meta data and the min/max_height columns
mschaefer
parents:
8856
diff
changeset
|
379 final Matcher m = META_COLUMNTITLES.matcher(line); |
a0a0a7f912ab
Added new columns bed_height.comment and sounding_width_info; extended the bed height parser for the new meta data and the min/max_height columns
mschaefer
parents:
8856
diff
changeset
|
380 if (m.matches()) { |
a0a0a7f912ab
Added new columns bed_height.comment and sounding_width_info; extended the bed height parser for the new meta data and the min/max_height columns
mschaefer
parents:
8856
diff
changeset
|
381 final Matcher cm; |
a0a0a7f912ab
Added new columns bed_height.comment and sounding_width_info; extended the bed height parser for the new meta data and the min/max_height columns
mschaefer
parents:
8856
diff
changeset
|
382 final String[] titles = line.split(SEPERATOR_CHAR, 0); |
a0a0a7f912ab
Added new columns bed_height.comment and sounding_width_info; extended the bed height parser for the new meta data and the min/max_height columns
mschaefer
parents:
8856
diff
changeset
|
383 for (int i = 0; i <= titles.length - 1; i++) { |
a0a0a7f912ab
Added new columns bed_height.comment and sounding_width_info; extended the bed height parser for the new meta data and the min/max_height columns
mschaefer
parents:
8856
diff
changeset
|
384 for (final ColTitlePattern col : ColTitlePattern.values()) { |
a0a0a7f912ab
Added new columns bed_height.comment and sounding_width_info; extended the bed height parser for the new meta data and the min/max_height columns
mschaefer
parents:
8856
diff
changeset
|
385 if (col.getPattern().matcher(titles[i]).matches()) { |
a0a0a7f912ab
Added new columns bed_height.comment and sounding_width_info; extended the bed height parser for the new meta data and the min/max_height columns
mschaefer
parents:
8856
diff
changeset
|
386 this.cols.put(col, i); |
a0a0a7f912ab
Added new columns bed_height.comment and sounding_width_info; extended the bed height parser for the new meta data and the min/max_height columns
mschaefer
parents:
8856
diff
changeset
|
387 break; |
a0a0a7f912ab
Added new columns bed_height.comment and sounding_width_info; extended the bed height parser for the new meta data and the min/max_height columns
mschaefer
parents:
8856
diff
changeset
|
388 } |
a0a0a7f912ab
Added new columns bed_height.comment and sounding_width_info; extended the bed height parser for the new meta data and the min/max_height columns
mschaefer
parents:
8856
diff
changeset
|
389 } |
a0a0a7f912ab
Added new columns bed_height.comment and sounding_width_info; extended the bed height parser for the new meta data and the min/max_height columns
mschaefer
parents:
8856
diff
changeset
|
390 } |
a0a0a7f912ab
Added new columns bed_height.comment and sounding_width_info; extended the bed height parser for the new meta data and the min/max_height columns
mschaefer
parents:
8856
diff
changeset
|
391 return true; |
a0a0a7f912ab
Added new columns bed_height.comment and sounding_width_info; extended the bed height parser for the new meta data and the min/max_height columns
mschaefer
parents:
8856
diff
changeset
|
392 } |
a0a0a7f912ab
Added new columns bed_height.comment and sounding_width_info; extended the bed height parser for the new meta data and the min/max_height columns
mschaefer
parents:
8856
diff
changeset
|
393 return false; |
a0a0a7f912ab
Added new columns bed_height.comment and sounding_width_info; extended the bed height parser for the new meta data and the min/max_height columns
mschaefer
parents:
8856
diff
changeset
|
394 } |
a0a0a7f912ab
Added new columns bed_height.comment and sounding_width_info; extended the bed height parser for the new meta data and the min/max_height columns
mschaefer
parents:
8856
diff
changeset
|
395 |
a0a0a7f912ab
Added new columns bed_height.comment and sounding_width_info; extended the bed height parser for the new meta data and the min/max_height columns
mschaefer
parents:
8856
diff
changeset
|
396 protected void handleDataLine(final ImportBedHeight obj, final String line) { |
a0a0a7f912ab
Added new columns bed_height.comment and sounding_width_info; extended the bed height parser for the new meta data and the min/max_height columns
mschaefer
parents:
8856
diff
changeset
|
397 final String[] values = line.split(SEPERATOR_CHAR, 0); |
8681
1f878c82262f
(issue1763) Fix filtering of lines when parsing bed heights.
Tom Gottfried <tom@intevation.de>
parents:
8561
diff
changeset
|
398 if (values.length < 2) { |
1f878c82262f
(issue1763) Fix filtering of lines when parsing bed heights.
Tom Gottfried <tom@intevation.de>
parents:
8561
diff
changeset
|
399 // Do not import line without data or only km |
8557
29ab66ce06aa
Abstract parser for bed heights is obsolete.
"Tom Gottfried <tom@intevation.de>"
parents:
8556
diff
changeset
|
400 return; |
29ab66ce06aa
Abstract parser for bed heights is obsolete.
"Tom Gottfried <tom@intevation.de>"
parents:
8556
diff
changeset
|
401 } |
29ab66ce06aa
Abstract parser for bed heights is obsolete.
"Tom Gottfried <tom@intevation.de>"
parents:
8556
diff
changeset
|
402 Double km; |
29ab66ce06aa
Abstract parser for bed heights is obsolete.
"Tom Gottfried <tom@intevation.de>"
parents:
8556
diff
changeset
|
403 try { |
29ab66ce06aa
Abstract parser for bed heights is obsolete.
"Tom Gottfried <tom@intevation.de>"
parents:
8556
diff
changeset
|
404 km = new Double(nf.parse(values[0]).doubleValue()); |
8975
a0a0a7f912ab
Added new columns bed_height.comment and sounding_width_info; extended the bed height parser for the new meta data and the min/max_height columns
mschaefer
parents:
8856
diff
changeset
|
405 if (this.kmExists.contains(km)) { |
a0a0a7f912ab
Added new columns bed_height.comment and sounding_width_info; extended the bed height parser for the new meta data and the min/max_height columns
mschaefer
parents:
8856
diff
changeset
|
406 log.warn("duplicate station '" + values[0] + "': -> ignored"); |
8557
29ab66ce06aa
Abstract parser for bed heights is obsolete.
"Tom Gottfried <tom@intevation.de>"
parents:
8556
diff
changeset
|
407 return; |
29ab66ce06aa
Abstract parser for bed heights is obsolete.
"Tom Gottfried <tom@intevation.de>"
parents:
8556
diff
changeset
|
408 } |
8975
a0a0a7f912ab
Added new columns bed_height.comment and sounding_width_info; extended the bed height parser for the new meta data and the min/max_height columns
mschaefer
parents:
8856
diff
changeset
|
409 this.kmExists.add(km); |
8557
29ab66ce06aa
Abstract parser for bed heights is obsolete.
"Tom Gottfried <tom@intevation.de>"
parents:
8556
diff
changeset
|
410 } |
8975
a0a0a7f912ab
Added new columns bed_height.comment and sounding_width_info; extended the bed height parser for the new meta data and the min/max_height columns
mschaefer
parents:
8856
diff
changeset
|
411 catch (final ParseException e) { |
9651
eb3dfe900d8c
Importer (s/u-info) extensions: better exception handling
mschaefer
parents:
9038
diff
changeset
|
412 log.warn("Error parsing km '" + values[0] + "': " + e.getMessage()); |
8557
29ab66ce06aa
Abstract parser for bed heights is obsolete.
"Tom Gottfried <tom@intevation.de>"
parents:
8556
diff
changeset
|
413 return; |
29ab66ce06aa
Abstract parser for bed heights is obsolete.
"Tom Gottfried <tom@intevation.de>"
parents:
8556
diff
changeset
|
414 } |
8975
a0a0a7f912ab
Added new columns bed_height.comment and sounding_width_info; extended the bed height parser for the new meta data and the min/max_height columns
mschaefer
parents:
8856
diff
changeset
|
415 final ImportBedHeightValue value = new ImportBedHeightValue(obj, km, parse(values, ColTitlePattern.HEIGHT), |
a0a0a7f912ab
Added new columns bed_height.comment and sounding_width_info; extended the bed height parser for the new meta data and the min/max_height columns
mschaefer
parents:
8856
diff
changeset
|
416 parse(values, ColTitlePattern.UNCERTAINTY), parse(values, ColTitlePattern.GAP), parse(values, ColTitlePattern.WIDTH), |
a0a0a7f912ab
Added new columns bed_height.comment and sounding_width_info; extended the bed height parser for the new meta data and the min/max_height columns
mschaefer
parents:
8856
diff
changeset
|
417 parse(values, ColTitlePattern.MINHEIGHT), parse(values, ColTitlePattern.MAXHEIGHT)); |
9034
8aa7d9eaaa21
Added bed_height_values section heights height01 to height10
mschaefer
parents:
8989
diff
changeset
|
418 for (int i = 1; i <= 10; i++) |
8aa7d9eaaa21
Added bed_height_values section heights height01 to height10
mschaefer
parents:
8989
diff
changeset
|
419 value.setSectionHeight(i, parse(values, ColTitlePattern.getSectionPattern(i))); |
8557
29ab66ce06aa
Abstract parser for bed heights is obsolete.
"Tom Gottfried <tom@intevation.de>"
parents:
8556
diff
changeset
|
420 |
29ab66ce06aa
Abstract parser for bed heights is obsolete.
"Tom Gottfried <tom@intevation.de>"
parents:
8556
diff
changeset
|
421 obj.addValue(value); |
29ab66ce06aa
Abstract parser for bed heights is obsolete.
"Tom Gottfried <tom@intevation.de>"
parents:
8556
diff
changeset
|
422 } |
8975
a0a0a7f912ab
Added new columns bed_height.comment and sounding_width_info; extended the bed height parser for the new meta data and the min/max_height columns
mschaefer
parents:
8856
diff
changeset
|
423 |
a0a0a7f912ab
Added new columns bed_height.comment and sounding_width_info; extended the bed height parser for the new meta data and the min/max_height columns
mschaefer
parents:
8856
diff
changeset
|
424 private Double parse(final String[] values, final ColTitlePattern col) { |
a0a0a7f912ab
Added new columns bed_height.comment and sounding_width_info; extended the bed height parser for the new meta data and the min/max_height columns
mschaefer
parents:
8856
diff
changeset
|
425 final int idx = this.cols.get(col).intValue(); |
a0a0a7f912ab
Added new columns bed_height.comment and sounding_width_info; extended the bed height parser for the new meta data and the min/max_height columns
mschaefer
parents:
8856
diff
changeset
|
426 if ((idx >= 0) && (idx < values.length) && !values[idx].trim().isEmpty()) { |
a0a0a7f912ab
Added new columns bed_height.comment and sounding_width_info; extended the bed height parser for the new meta data and the min/max_height columns
mschaefer
parents:
8856
diff
changeset
|
427 try { |
a0a0a7f912ab
Added new columns bed_height.comment and sounding_width_info; extended the bed height parser for the new meta data and the min/max_height columns
mschaefer
parents:
8856
diff
changeset
|
428 return nf.parse(values[idx]).doubleValue(); |
a0a0a7f912ab
Added new columns bed_height.comment and sounding_width_info; extended the bed height parser for the new meta data and the min/max_height columns
mschaefer
parents:
8856
diff
changeset
|
429 } |
a0a0a7f912ab
Added new columns bed_height.comment and sounding_width_info; extended the bed height parser for the new meta data and the min/max_height columns
mschaefer
parents:
8856
diff
changeset
|
430 catch (final ParseException e) { |
a0a0a7f912ab
Added new columns bed_height.comment and sounding_width_info; extended the bed height parser for the new meta data and the min/max_height columns
mschaefer
parents:
8856
diff
changeset
|
431 log.warn("unparseable " + col.toString() + " '" + values[idx] + "'"); |
a0a0a7f912ab
Added new columns bed_height.comment and sounding_width_info; extended the bed height parser for the new meta data and the min/max_height columns
mschaefer
parents:
8856
diff
changeset
|
432 } |
a0a0a7f912ab
Added new columns bed_height.comment and sounding_width_info; extended the bed height parser for the new meta data and the min/max_height columns
mschaefer
parents:
8856
diff
changeset
|
433 } |
a0a0a7f912ab
Added new columns bed_height.comment and sounding_width_info; extended the bed height parser for the new meta data and the min/max_height columns
mschaefer
parents:
8856
diff
changeset
|
434 return null; |
a0a0a7f912ab
Added new columns bed_height.comment and sounding_width_info; extended the bed height parser for the new meta data and the min/max_height columns
mschaefer
parents:
8856
diff
changeset
|
435 } |
2811
8926571e47fb
Finished importing MINFO bed heights (single and epoch).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
436 } |