Mercurial > dive4elements > river
annotate backend/src/main/java/org/dive4elements/river/importer/parsers/DA66Parser.java @ 9726:0a5239a1e46e 3.2.x
Upgrade to Log4j 2
author | Tom Gottfried <tom@intevation.de> |
---|---|
date | Wed, 02 Mar 2022 10:26:50 +0100 |
parents | 5e38e2924c07 |
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:
5844
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:
5844
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; |
4681
aa718770308e
Less than sceleton for DA66-CrossSection parser added.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
10 |
5829
18619c1e7c2a
Repaired internal references.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5828
diff
changeset
|
11 import org.dive4elements.artifacts.common.utils.FileTools; |
4681
aa718770308e
Less than sceleton for DA66-CrossSection parser added.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
12 |
5829
18619c1e7c2a
Repaired internal references.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5828
diff
changeset
|
13 import org.dive4elements.river.importer.XY; |
4735
94b39073f0f7
Moved EpsilonComparator to utils package becaus its not only useful for TIM parsing. Used EpsilonComparator in DA60 and DA66 case. Maybe TODO: Use in PRF, too.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4729
diff
changeset
|
14 |
8187
3bb1c62ad732
Moved package org.dive4elements.river.utils to org.dive4elements.river.backend.utils.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5992
diff
changeset
|
15 import org.dive4elements.river.backend.utils.EpsilonComparator; |
4681
aa718770308e
Less than sceleton for DA66-CrossSection parser added.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
16 |
aa718770308e
Less than sceleton for DA66-CrossSection parser added.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
17 import java.io.File; |
aa718770308e
Less than sceleton for DA66-CrossSection parser added.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
18 import java.io.IOException; |
aa718770308e
Less than sceleton for DA66-CrossSection parser added.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
19 |
4735
94b39073f0f7
Moved EpsilonComparator to utils package becaus its not only useful for TIM parsing. Used EpsilonComparator in DA60 and DA66 case. Maybe TODO: Use in PRF, too.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4729
diff
changeset
|
20 import java.util.ArrayList; |
94b39073f0f7
Moved EpsilonComparator to utils package becaus its not only useful for TIM parsing. Used EpsilonComparator in DA60 and DA66 case. Maybe TODO: Use in PRF, too.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4729
diff
changeset
|
21 import java.util.HashMap; |
94b39073f0f7
Moved EpsilonComparator to utils package becaus its not only useful for TIM parsing. Used EpsilonComparator in DA60 and DA66 case. Maybe TODO: Use in PRF, too.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4729
diff
changeset
|
22 import java.util.List; |
94b39073f0f7
Moved EpsilonComparator to utils package becaus its not only useful for TIM parsing. Used EpsilonComparator in DA60 and DA66 case. Maybe TODO: Use in PRF, too.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4729
diff
changeset
|
23 import java.util.Map; |
94b39073f0f7
Moved EpsilonComparator to utils package becaus its not only useful for TIM parsing. Used EpsilonComparator in DA60 and DA66 case. Maybe TODO: Use in PRF, too.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4729
diff
changeset
|
24 import java.util.TreeMap; |
4681
aa718770308e
Less than sceleton for DA66-CrossSection parser added.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
25 |
4735
94b39073f0f7
Moved EpsilonComparator to utils package becaus its not only useful for TIM parsing. Used EpsilonComparator in DA60 and DA66 case. Maybe TODO: Use in PRF, too.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4729
diff
changeset
|
26 import java.util.regex.Matcher; |
94b39073f0f7
Moved EpsilonComparator to utils package becaus its not only useful for TIM parsing. Used EpsilonComparator in DA60 and DA66 case. Maybe TODO: Use in PRF, too.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4729
diff
changeset
|
27 import java.util.regex.Pattern; |
4681
aa718770308e
Less than sceleton for DA66-CrossSection parser added.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
28 |
9726 | 29 import org.apache.logging.log4j.Logger; |
30 import org.apache.logging.log4j.LogManager; | |
4681
aa718770308e
Less than sceleton for DA66-CrossSection parser added.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
31 |
aa718770308e
Less than sceleton for DA66-CrossSection parser added.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
32 |
aa718770308e
Less than sceleton for DA66-CrossSection parser added.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
33 /** |
aa718770308e
Less than sceleton for DA66-CrossSection parser added.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
34 * To create cross-sections, generate: Map<double,list<xy>> from files |
aa718770308e
Less than sceleton for DA66-CrossSection parser added.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
35 * in da66 format. |
aa718770308e
Less than sceleton for DA66-CrossSection parser added.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
36 */ |
4715
2f7a509f5acf
Implement new CrossSectionParser interface.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4712
diff
changeset
|
37 public class DA66Parser extends LineParser implements CrossSectionParser |
4681
aa718770308e
Less than sceleton for DA66-CrossSection parser added.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
38 { |
8200
9d2e69f971f5
sed -i src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8187
diff
changeset
|
39 /** Private log. */ |
9726 | 40 private static Logger log = LogManager.getLogger(DA66Parser.class); |
4681
aa718770308e
Less than sceleton for DA66-CrossSection parser added.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
41 |
8843 | 42 private static final String HEAD_HEAD = "00"; |
43 private static final String HEAD_GEOM = "66"; // "Values" | |
44 private static final String HEAD_ENDG = "88"; // Probably never used. | |
4712
70842db72ee4
Include improved DA66Parser into importer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4681
diff
changeset
|
45 |
4717
e67d396ed65d
Documentation of DA66Parser.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4715
diff
changeset
|
46 /** Regex to match lines of files in da66 format. */ |
4712
70842db72ee4
Include improved DA66Parser into importer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4681
diff
changeset
|
47 private static final Pattern LINE_PATTERN = |
70842db72ee4
Include improved DA66Parser into importer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4681
diff
changeset
|
48 Pattern.compile("^([0-9 -]{2})" + // Type (00|66|88) |
4681
aa718770308e
Less than sceleton for DA66-CrossSection parser added.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
49 "([0-9 -]{5})" + // unset |
aa718770308e
Less than sceleton for DA66-CrossSection parser added.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
50 "([0-9 -]{2})" + // id |
aa718770308e
Less than sceleton for DA66-CrossSection parser added.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
51 "([0-9 -]{9})" + // station |
aa718770308e
Less than sceleton for DA66-CrossSection parser added.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
52 "([0-9 -]{2})" + // running number |
4712
70842db72ee4
Include improved DA66Parser into importer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4681
diff
changeset
|
53 "([0-9 -]{1})?" + // point id |
4681
aa718770308e
Less than sceleton for DA66-CrossSection parser added.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
54 /* |
aa718770308e
Less than sceleton for DA66-CrossSection parser added.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
55 Would be great if we could express the pattern as this: |
aa718770308e
Less than sceleton for DA66-CrossSection parser added.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
56 ([0-9 -]{1})([0-9 -JKMLMNOPQR]{7})([0-9 -]{7})+ |
aa718770308e
Less than sceleton for DA66-CrossSection parser added.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
57 */ |
4712
70842db72ee4
Include improved DA66Parser into importer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4681
diff
changeset
|
58 "([0-9 -JKMLMNOPQR]{7})?" + // y |
70842db72ee4
Include improved DA66Parser into importer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4681
diff
changeset
|
59 "([0-9 -]{7})?" + // z |
70842db72ee4
Include improved DA66Parser into importer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4681
diff
changeset
|
60 "([0-9 -]{1})?" + // point id |
70842db72ee4
Include improved DA66Parser into importer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4681
diff
changeset
|
61 "([0-9 -JKMLMNOPQR]{7})?" + // y |
70842db72ee4
Include improved DA66Parser into importer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4681
diff
changeset
|
62 "([0-9 -]{7})?" + // z |
70842db72ee4
Include improved DA66Parser into importer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4681
diff
changeset
|
63 "([0-9 -]{1})?" + // point id |
70842db72ee4
Include improved DA66Parser into importer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4681
diff
changeset
|
64 "([0-9 -JKMLMNOPQR]{7})?" + // y |
70842db72ee4
Include improved DA66Parser into importer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4681
diff
changeset
|
65 "([0-9 -]{7})?" + // z |
70842db72ee4
Include improved DA66Parser into importer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4681
diff
changeset
|
66 "([0-9 -]{1})?" + // point id |
70842db72ee4
Include improved DA66Parser into importer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4681
diff
changeset
|
67 "([0-9 -JKMLMNOPQR]{7})?" + // y |
70842db72ee4
Include improved DA66Parser into importer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4681
diff
changeset
|
68 "([0-9 -]{7})?" // z |
4681
aa718770308e
Less than sceleton for DA66-CrossSection parser added.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
69 ); |
aa718770308e
Less than sceleton for DA66-CrossSection parser added.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
70 |
4723
83304d3651ec
DA66Parser: Whitespace cosmetics.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4722
diff
changeset
|
71 |
4712
70842db72ee4
Include improved DA66Parser into importer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4681
diff
changeset
|
72 /** Indices to match group of main regex. */ |
70842db72ee4
Include improved DA66Parser into importer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4681
diff
changeset
|
73 private static enum FIELD { |
70842db72ee4
Include improved DA66Parser into importer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4681
diff
changeset
|
74 HEAD ( 1), |
70842db72ee4
Include improved DA66Parser into importer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4681
diff
changeset
|
75 UNSET ( 2), |
70842db72ee4
Include improved DA66Parser into importer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4681
diff
changeset
|
76 ID ( 3), |
70842db72ee4
Include improved DA66Parser into importer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4681
diff
changeset
|
77 STATION ( 4), |
70842db72ee4
Include improved DA66Parser into importer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4681
diff
changeset
|
78 RUNNR ( 5), |
70842db72ee4
Include improved DA66Parser into importer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4681
diff
changeset
|
79 POINT_1_ID( 6), |
70842db72ee4
Include improved DA66Parser into importer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4681
diff
changeset
|
80 POINT_1_Y ( 7), |
70842db72ee4
Include improved DA66Parser into importer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4681
diff
changeset
|
81 POINT_1_Z ( 8), |
70842db72ee4
Include improved DA66Parser into importer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4681
diff
changeset
|
82 POINT_2_ID( 9), |
70842db72ee4
Include improved DA66Parser into importer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4681
diff
changeset
|
83 POINT_2_Y (10), |
70842db72ee4
Include improved DA66Parser into importer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4681
diff
changeset
|
84 POINT_2_Z (11), |
70842db72ee4
Include improved DA66Parser into importer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4681
diff
changeset
|
85 POINT_3_ID(12), |
70842db72ee4
Include improved DA66Parser into importer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4681
diff
changeset
|
86 POINT_3_Y (13), |
70842db72ee4
Include improved DA66Parser into importer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4681
diff
changeset
|
87 POINT_3_Z (14), |
70842db72ee4
Include improved DA66Parser into importer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4681
diff
changeset
|
88 POINT_4_ID(15), |
70842db72ee4
Include improved DA66Parser into importer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4681
diff
changeset
|
89 POINT_4_Y (16), |
70842db72ee4
Include improved DA66Parser into importer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4681
diff
changeset
|
90 POINT_4_Z (17); |
4735
94b39073f0f7
Moved EpsilonComparator to utils package becaus its not only useful for TIM parsing. Used EpsilonComparator in DA60 and DA66 case. Maybe TODO: Use in PRF, too.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4729
diff
changeset
|
91 |
4712
70842db72ee4
Include improved DA66Parser into importer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4681
diff
changeset
|
92 private int idx; |
70842db72ee4
Include improved DA66Parser into importer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4681
diff
changeset
|
93 FIELD(int idx) { |
70842db72ee4
Include improved DA66Parser into importer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4681
diff
changeset
|
94 this.idx = idx; |
70842db72ee4
Include improved DA66Parser into importer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4681
diff
changeset
|
95 } |
70842db72ee4
Include improved DA66Parser into importer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4681
diff
changeset
|
96 int getIdx() { |
70842db72ee4
Include improved DA66Parser into importer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4681
diff
changeset
|
97 return idx; |
70842db72ee4
Include improved DA66Parser into importer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4681
diff
changeset
|
98 } |
70842db72ee4
Include improved DA66Parser into importer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4681
diff
changeset
|
99 } |
70842db72ee4
Include improved DA66Parser into importer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4681
diff
changeset
|
100 |
4723
83304d3651ec
DA66Parser: Whitespace cosmetics.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4722
diff
changeset
|
101 |
4712
70842db72ee4
Include improved DA66Parser into importer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4681
diff
changeset
|
102 /** Header lines of da66 can define a type. */ |
4681
aa718770308e
Less than sceleton for DA66-CrossSection parser added.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
103 private static enum Type { |
aa718770308e
Less than sceleton for DA66-CrossSection parser added.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
104 DATE ( 0), |
aa718770308e
Less than sceleton for DA66-CrossSection parser added.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
105 HEKTOSTONE_LEFT ( 1), //grm. "Standlinie" |
aa718770308e
Less than sceleton for DA66-CrossSection parser added.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
106 HEKTOSTONE_RIGHT ( 2), |
aa718770308e
Less than sceleton for DA66-CrossSection parser added.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
107 CHANNEL_LEFT ( 3), //grm. "Fahrrinne" |
aa718770308e
Less than sceleton for DA66-CrossSection parser added.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
108 CHANNEL_RIGHT ( 4), |
aa718770308e
Less than sceleton for DA66-CrossSection parser added.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
109 CHANNEL_2_LEFT ( 5), |
aa718770308e
Less than sceleton for DA66-CrossSection parser added.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
110 CHANNEL_2_RIGHT ( 6), |
aa718770308e
Less than sceleton for DA66-CrossSection parser added.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
111 GIW_1972 ( 7), |
aa718770308e
Less than sceleton for DA66-CrossSection parser added.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
112 GROIN_DIST_LEFT ( 8), //grm. "Buhnenkopfabstand links" |
aa718770308e
Less than sceleton for DA66-CrossSection parser added.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
113 GROIN_HEIGHT_LEFT ( 9), |
aa718770308e
Less than sceleton for DA66-CrossSection parser added.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
114 GROIN_SLOPE_LEFT (10), |
aa718770308e
Less than sceleton for DA66-CrossSection parser added.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
115 GROIN_DIST_RIGHT (11), |
aa718770308e
Less than sceleton for DA66-CrossSection parser added.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
116 GROIN_HEIGHT_RIGHT (12), |
aa718770308e
Less than sceleton for DA66-CrossSection parser added.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
117 GROIN_SLOPE_RIGHT (13), |
aa718770308e
Less than sceleton for DA66-CrossSection parser added.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
118 STRIKE_LEFT (14), //grm. "Streichlinie links" |
aa718770308e
Less than sceleton for DA66-CrossSection parser added.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
119 AXIS (15), |
aa718770308e
Less than sceleton for DA66-CrossSection parser added.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
120 STRIKE_RIGHT (16), |
aa718770308e
Less than sceleton for DA66-CrossSection parser added.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
121 GROIN_BACK_SLOPE_LEFT (17), //grm. "Buhnenrueckenneigung" |
aa718770308e
Less than sceleton for DA66-CrossSection parser added.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
122 GROIN_BACK_SLOPE_RIGHT (18), |
aa718770308e
Less than sceleton for DA66-CrossSection parser added.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
123 GIW_1932 (19), |
aa718770308e
Less than sceleton for DA66-CrossSection parser added.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
124 GIW_1982 (20), |
aa718770308e
Less than sceleton for DA66-CrossSection parser added.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
125 STAND_ISLAND_1 (21), |
aa718770308e
Less than sceleton for DA66-CrossSection parser added.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
126 STAND_ISLAND_2 (22), |
aa718770308e
Less than sceleton for DA66-CrossSection parser added.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
127 STAND_ISLAND_3 (23), |
aa718770308e
Less than sceleton for DA66-CrossSection parser added.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
128 STAND_ISLAND_4 (24), |
aa718770308e
Less than sceleton for DA66-CrossSection parser added.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
129 UNSPECIFIED_1 (25), |
aa718770308e
Less than sceleton for DA66-CrossSection parser added.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
130 UNSPECIFIED_2 (26), |
aa718770308e
Less than sceleton for DA66-CrossSection parser added.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
131 HHW (27), |
aa718770308e
Less than sceleton for DA66-CrossSection parser added.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
132 OLD_PROFILE_NULL (28), |
aa718770308e
Less than sceleton for DA66-CrossSection parser added.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
133 AW_1978 (29), |
aa718770308e
Less than sceleton for DA66-CrossSection parser added.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
134 SIGN_LEFT (30), |
aa718770308e
Less than sceleton for DA66-CrossSection parser added.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
135 SIGN_RIGHT (31), |
aa718770308e
Less than sceleton for DA66-CrossSection parser added.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
136 DIST_SIGNAL_CHANNEL_LEFT (32), |
aa718770308e
Less than sceleton for DA66-CrossSection parser added.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
137 DIST_SIGNAL_CHANNEL_RIGHT(33), |
aa718770308e
Less than sceleton for DA66-CrossSection parser added.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
138 UNSPECIFIED_3 (34), |
aa718770308e
Less than sceleton for DA66-CrossSection parser added.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
139 UNSPECIFIED_4 (35), |
aa718770308e
Less than sceleton for DA66-CrossSection parser added.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
140 UNSPECIFIED_5 (36), |
aa718770308e
Less than sceleton for DA66-CrossSection parser added.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
141 UNSPECIFIED_6 (37), |
aa718770308e
Less than sceleton for DA66-CrossSection parser added.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
142 SHORE_LEFT (38), |
aa718770308e
Less than sceleton for DA66-CrossSection parser added.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
143 SHORE_RIGHT (39), |
aa718770308e
Less than sceleton for DA66-CrossSection parser added.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
144 UNSPECIFIED_7 (40); |
aa718770308e
Less than sceleton for DA66-CrossSection parser added.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
145 |
aa718770308e
Less than sceleton for DA66-CrossSection parser added.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
146 private final int id; |
aa718770308e
Less than sceleton for DA66-CrossSection parser added.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
147 Type(int id) { |
aa718770308e
Less than sceleton for DA66-CrossSection parser added.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
148 this.id = id; |
aa718770308e
Less than sceleton for DA66-CrossSection parser added.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
149 } |
aa718770308e
Less than sceleton for DA66-CrossSection parser added.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
150 public int getId() { |
aa718770308e
Less than sceleton for DA66-CrossSection parser added.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
151 return id; |
aa718770308e
Less than sceleton for DA66-CrossSection parser added.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
152 } |
aa718770308e
Less than sceleton for DA66-CrossSection parser added.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
153 } |
aa718770308e
Less than sceleton for DA66-CrossSection parser added.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
154 |
4723
83304d3651ec
DA66Parser: Whitespace cosmetics.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4722
diff
changeset
|
155 |
4681
aa718770308e
Less than sceleton for DA66-CrossSection parser added.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
156 /** Available types. */ |
aa718770308e
Less than sceleton for DA66-CrossSection parser added.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
157 private static HashMap<Integer, Type> typeMap; |
aa718770308e
Less than sceleton for DA66-CrossSection parser added.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
158 |
4723
83304d3651ec
DA66Parser: Whitespace cosmetics.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4722
diff
changeset
|
159 |
4681
aa718770308e
Less than sceleton for DA66-CrossSection parser added.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
160 /** Types we can deal with. */ |
aa718770308e
Less than sceleton for DA66-CrossSection parser added.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
161 private static List<Type> implementedTypes; |
aa718770308e
Less than sceleton for DA66-CrossSection parser added.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
162 |
4723
83304d3651ec
DA66Parser: Whitespace cosmetics.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4722
diff
changeset
|
163 |
4681
aa718770308e
Less than sceleton for DA66-CrossSection parser added.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
164 static { |
aa718770308e
Less than sceleton for DA66-CrossSection parser added.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
165 typeMap = new HashMap<Integer, Type>(); |
aa718770308e
Less than sceleton for DA66-CrossSection parser added.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
166 for (Type t: Type.values()) { |
aa718770308e
Less than sceleton for DA66-CrossSection parser added.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
167 typeMap.put(new Integer(t.getId()), t); |
aa718770308e
Less than sceleton for DA66-CrossSection parser added.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
168 } |
4712
70842db72ee4
Include improved DA66Parser into importer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4681
diff
changeset
|
169 // TODO populate and respect header type. |
4681
aa718770308e
Less than sceleton for DA66-CrossSection parser added.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
170 implementedTypes = new ArrayList<Type>(); |
aa718770308e
Less than sceleton for DA66-CrossSection parser added.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
171 //implementedTypes.add(..); |
aa718770308e
Less than sceleton for DA66-CrossSection parser added.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
172 } |
aa718770308e
Less than sceleton for DA66-CrossSection parser added.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
173 |
4712
70842db72ee4
Include improved DA66Parser into importer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4681
diff
changeset
|
174 |
70842db72ee4
Include improved DA66Parser into importer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4681
diff
changeset
|
175 /** The current line to which add points. */ |
70842db72ee4
Include improved DA66Parser into importer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4681
diff
changeset
|
176 private List<XY> currentLine; |
70842db72ee4
Include improved DA66Parser into importer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4681
diff
changeset
|
177 |
70842db72ee4
Include improved DA66Parser into importer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4681
diff
changeset
|
178 |
70842db72ee4
Include improved DA66Parser into importer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4681
diff
changeset
|
179 /** Data collected so far, last element will be currentLine. */ |
4681
aa718770308e
Less than sceleton for DA66-CrossSection parser added.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
180 protected Map<Double, List<XY>> data; |
aa718770308e
Less than sceleton for DA66-CrossSection parser added.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
181 |
aa718770308e
Less than sceleton for DA66-CrossSection parser added.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
182 |
4717
e67d396ed65d
Documentation of DA66Parser.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4715
diff
changeset
|
183 /** Trivial constructor. */ |
4681
aa718770308e
Less than sceleton for DA66-CrossSection parser added.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
184 public DA66Parser() { |
4735
94b39073f0f7
Moved EpsilonComparator to utils package becaus its not only useful for TIM parsing. Used EpsilonComparator in DA60 and DA66 case. Maybe TODO: Use in PRF, too.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4729
diff
changeset
|
185 data = new TreeMap<Double, List<XY>>(EpsilonComparator.CMP); |
4681
aa718770308e
Less than sceleton for DA66-CrossSection parser added.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
186 } |
aa718770308e
Less than sceleton for DA66-CrossSection parser added.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
187 |
4717
e67d396ed65d
Documentation of DA66Parser.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4715
diff
changeset
|
188 |
e67d396ed65d
Documentation of DA66Parser.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4715
diff
changeset
|
189 /** Get the description of the cross section parsed. */ |
4715
2f7a509f5acf
Implement new CrossSectionParser interface.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4712
diff
changeset
|
190 @Override |
2f7a509f5acf
Implement new CrossSectionParser interface.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4712
diff
changeset
|
191 public String getDescription() { |
4729
0df1cac6c4b5
Removed removeExtension implementations, which have been moved to FileTools,
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4727
diff
changeset
|
192 return FileTools.removeExtension(getFileName()); |
4715
2f7a509f5acf
Implement new CrossSectionParser interface.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4712
diff
changeset
|
193 } |
2f7a509f5acf
Implement new CrossSectionParser interface.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4712
diff
changeset
|
194 |
4717
e67d396ed65d
Documentation of DA66Parser.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4715
diff
changeset
|
195 |
e67d396ed65d
Documentation of DA66Parser.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4715
diff
changeset
|
196 /** Get the year of this cross sections measurement. */ |
4715
2f7a509f5acf
Implement new CrossSectionParser interface.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4712
diff
changeset
|
197 @Override |
2f7a509f5acf
Implement new CrossSectionParser interface.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4712
diff
changeset
|
198 public Integer getYear() { |
4726
4f7d264c27f5
DA66Parser: Do not return a 'year' for measurement, as none is given.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4723
diff
changeset
|
199 return null; |
4715
2f7a509f5acf
Implement new CrossSectionParser interface.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4712
diff
changeset
|
200 } |
2f7a509f5acf
Implement new CrossSectionParser interface.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4712
diff
changeset
|
201 |
4717
e67d396ed65d
Documentation of DA66Parser.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4715
diff
changeset
|
202 |
e67d396ed65d
Documentation of DA66Parser.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4715
diff
changeset
|
203 /** |
e67d396ed65d
Documentation of DA66Parser.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4715
diff
changeset
|
204 * Return the data parsed. |
e67d396ed65d
Documentation of DA66Parser.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4715
diff
changeset
|
205 * @return map of stations (km) to list of points. |
e67d396ed65d
Documentation of DA66Parser.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4715
diff
changeset
|
206 */ |
4715
2f7a509f5acf
Implement new CrossSectionParser interface.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4712
diff
changeset
|
207 @Override |
4681
aa718770308e
Less than sceleton for DA66-CrossSection parser added.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
208 public Map<Double, List<XY>> getData() { |
aa718770308e
Less than sceleton for DA66-CrossSection parser added.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
209 return data; |
aa718770308e
Less than sceleton for DA66-CrossSection parser added.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
210 } |
aa718770308e
Less than sceleton for DA66-CrossSection parser added.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
211 |
aa718770308e
Less than sceleton for DA66-CrossSection parser added.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
212 |
4791
fc571444da50
DA66Parser: Added doc, removed TODO, whitespace cosmetics.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4746
diff
changeset
|
213 /** |
fc571444da50
DA66Parser: Added doc, removed TODO, whitespace cosmetics.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4746
diff
changeset
|
214 * Walk a directory tree, parse its *.da66 files and store the |
fc571444da50
DA66Parser: Added doc, removed TODO, whitespace cosmetics.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4746
diff
changeset
|
215 * data found. |
fc571444da50
DA66Parser: Added doc, removed TODO, whitespace cosmetics.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4746
diff
changeset
|
216 */ |
4681
aa718770308e
Less than sceleton for DA66-CrossSection parser added.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
217 public void parseDA66s(File root, final Callback callback) { |
aa718770308e
Less than sceleton for DA66-CrossSection parser added.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
218 |
aa718770308e
Less than sceleton for DA66-CrossSection parser added.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
219 FileTools.walkTree(root, new FileTools.FileVisitor() { |
aa718770308e
Less than sceleton for DA66-CrossSection parser added.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
220 @Override |
aa718770308e
Less than sceleton for DA66-CrossSection parser added.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
221 public boolean visit(File file) { |
aa718770308e
Less than sceleton for DA66-CrossSection parser added.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
222 if (file.isFile() && file.canRead() |
aa718770308e
Less than sceleton for DA66-CrossSection parser added.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
223 && file.getName().toLowerCase().endsWith(".d66") |
4715
2f7a509f5acf
Implement new CrossSectionParser interface.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4712
diff
changeset
|
224 && (callback == null || callback.accept(file))) { |
4681
aa718770308e
Less than sceleton for DA66-CrossSection parser added.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
225 reset(); |
aa718770308e
Less than sceleton for DA66-CrossSection parser added.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
226 try { |
aa718770308e
Less than sceleton for DA66-CrossSection parser added.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
227 parse(file); |
8200
9d2e69f971f5
sed -i src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8187
diff
changeset
|
228 log.info("parsing done"); |
4681
aa718770308e
Less than sceleton for DA66-CrossSection parser added.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
229 if (callback != null) { |
4715
2f7a509f5acf
Implement new CrossSectionParser interface.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4712
diff
changeset
|
230 callback.parsed(DA66Parser.this); |
4681
aa718770308e
Less than sceleton for DA66-CrossSection parser added.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
231 } |
aa718770308e
Less than sceleton for DA66-CrossSection parser added.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
232 } |
aa718770308e
Less than sceleton for DA66-CrossSection parser added.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
233 catch (IOException ioe) { |
8200
9d2e69f971f5
sed -i src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8187
diff
changeset
|
234 log.error("IOException while parsing file"); |
4681
aa718770308e
Less than sceleton for DA66-CrossSection parser added.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
235 return false; |
aa718770308e
Less than sceleton for DA66-CrossSection parser added.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
236 } |
aa718770308e
Less than sceleton for DA66-CrossSection parser added.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
237 } |
aa718770308e
Less than sceleton for DA66-CrossSection parser added.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
238 return true; |
aa718770308e
Less than sceleton for DA66-CrossSection parser added.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
239 } |
aa718770308e
Less than sceleton for DA66-CrossSection parser added.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
240 }); |
aa718770308e
Less than sceleton for DA66-CrossSection parser added.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
241 } |
aa718770308e
Less than sceleton for DA66-CrossSection parser added.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
242 |
aa718770308e
Less than sceleton for DA66-CrossSection parser added.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
243 |
4712
70842db72ee4
Include improved DA66Parser into importer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4681
diff
changeset
|
244 /** |
70842db72ee4
Include improved DA66Parser into importer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4681
diff
changeset
|
245 * Get the Index of the last cross-section lines point. |
70842db72ee4
Include improved DA66Parser into importer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4681
diff
changeset
|
246 * @return last points index, -1 if not available. |
70842db72ee4
Include improved DA66Parser into importer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4681
diff
changeset
|
247 */ |
70842db72ee4
Include improved DA66Parser into importer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4681
diff
changeset
|
248 private int lastPointIdx() { |
70842db72ee4
Include improved DA66Parser into importer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4681
diff
changeset
|
249 if (currentLine == null || currentLine.isEmpty()) { |
70842db72ee4
Include improved DA66Parser into importer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4681
diff
changeset
|
250 return -1; |
70842db72ee4
Include improved DA66Parser into importer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4681
diff
changeset
|
251 } |
70842db72ee4
Include improved DA66Parser into importer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4681
diff
changeset
|
252 XY lastPoint = this.currentLine.get(currentLine.size()-1); |
70842db72ee4
Include improved DA66Parser into importer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4681
diff
changeset
|
253 return lastPoint.getIndex(); |
70842db72ee4
Include improved DA66Parser into importer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4681
diff
changeset
|
254 } |
70842db72ee4
Include improved DA66Parser into importer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4681
diff
changeset
|
255 |
70842db72ee4
Include improved DA66Parser into importer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4681
diff
changeset
|
256 |
4720
9f7cd65daac2
DA66Parser: Try to guess whether station is given in km or in cm.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4719
diff
changeset
|
257 /** Returns station, deciding if it could in cm, in which case convert. */ |
9f7cd65daac2
DA66Parser: Try to guess whether station is given in km or in cm.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4719
diff
changeset
|
258 private double stationInKm(double station) { |
9f7cd65daac2
DA66Parser: Try to guess whether station is given in km or in cm.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4719
diff
changeset
|
259 if (station > 10000) { |
9f7cd65daac2
DA66Parser: Try to guess whether station is given in km or in cm.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4719
diff
changeset
|
260 return station/100000d; |
9f7cd65daac2
DA66Parser: Try to guess whether station is given in km or in cm.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4719
diff
changeset
|
261 } |
9f7cd65daac2
DA66Parser: Try to guess whether station is given in km or in cm.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4719
diff
changeset
|
262 else { |
9f7cd65daac2
DA66Parser: Try to guess whether station is given in km or in cm.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4719
diff
changeset
|
263 return station; |
9f7cd65daac2
DA66Parser: Try to guess whether station is given in km or in cm.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4719
diff
changeset
|
264 } |
9f7cd65daac2
DA66Parser: Try to guess whether station is given in km or in cm.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4719
diff
changeset
|
265 } |
9f7cd65daac2
DA66Parser: Try to guess whether station is given in km or in cm.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4719
diff
changeset
|
266 |
4791
fc571444da50
DA66Parser: Added doc, removed TODO, whitespace cosmetics.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4746
diff
changeset
|
267 |
4746
0b60b77d4d00
DA66Parser: Handle coding convention that was introduced to overcome fixed
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4745
diff
changeset
|
268 /** Apply the convention how to deal with numbers < -99.999 .*/ |
0b60b77d4d00
DA66Parser: Handle coding convention that was introduced to overcome fixed
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4745
diff
changeset
|
269 private String applyLetterConvention(String orig) { |
0b60b77d4d00
DA66Parser: Handle coding convention that was introduced to overcome fixed
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4745
diff
changeset
|
270 if (orig.endsWith("-")) { |
0b60b77d4d00
DA66Parser: Handle coding convention that was introduced to overcome fixed
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4745
diff
changeset
|
271 return "-" + orig.replace("-",""); |
0b60b77d4d00
DA66Parser: Handle coding convention that was introduced to overcome fixed
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4745
diff
changeset
|
272 } |
0b60b77d4d00
DA66Parser: Handle coding convention that was introduced to overcome fixed
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4745
diff
changeset
|
273 else if (orig.endsWith("J")) { |
0b60b77d4d00
DA66Parser: Handle coding convention that was introduced to overcome fixed
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4745
diff
changeset
|
274 return "-" + orig.replace("J","1"); |
0b60b77d4d00
DA66Parser: Handle coding convention that was introduced to overcome fixed
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4745
diff
changeset
|
275 } |
0b60b77d4d00
DA66Parser: Handle coding convention that was introduced to overcome fixed
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4745
diff
changeset
|
276 else if (orig.endsWith("K")) { |
0b60b77d4d00
DA66Parser: Handle coding convention that was introduced to overcome fixed
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4745
diff
changeset
|
277 return "-" + orig.replace("K","2"); |
0b60b77d4d00
DA66Parser: Handle coding convention that was introduced to overcome fixed
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4745
diff
changeset
|
278 } |
0b60b77d4d00
DA66Parser: Handle coding convention that was introduced to overcome fixed
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4745
diff
changeset
|
279 else if (orig.endsWith("L")) { |
0b60b77d4d00
DA66Parser: Handle coding convention that was introduced to overcome fixed
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4745
diff
changeset
|
280 return "-" + orig.replace("L","3"); |
0b60b77d4d00
DA66Parser: Handle coding convention that was introduced to overcome fixed
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4745
diff
changeset
|
281 } |
0b60b77d4d00
DA66Parser: Handle coding convention that was introduced to overcome fixed
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4745
diff
changeset
|
282 else if (orig.endsWith("M")) { |
0b60b77d4d00
DA66Parser: Handle coding convention that was introduced to overcome fixed
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4745
diff
changeset
|
283 return "-" + orig.replace("M","4"); |
0b60b77d4d00
DA66Parser: Handle coding convention that was introduced to overcome fixed
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4745
diff
changeset
|
284 } |
0b60b77d4d00
DA66Parser: Handle coding convention that was introduced to overcome fixed
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4745
diff
changeset
|
285 else if (orig.endsWith("N")) { |
0b60b77d4d00
DA66Parser: Handle coding convention that was introduced to overcome fixed
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4745
diff
changeset
|
286 return "-" + orig.replace("N","5"); |
0b60b77d4d00
DA66Parser: Handle coding convention that was introduced to overcome fixed
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4745
diff
changeset
|
287 } |
0b60b77d4d00
DA66Parser: Handle coding convention that was introduced to overcome fixed
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4745
diff
changeset
|
288 else if (orig.endsWith("O")) { |
0b60b77d4d00
DA66Parser: Handle coding convention that was introduced to overcome fixed
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4745
diff
changeset
|
289 return "-" + orig.replace("O","6"); |
0b60b77d4d00
DA66Parser: Handle coding convention that was introduced to overcome fixed
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4745
diff
changeset
|
290 } |
0b60b77d4d00
DA66Parser: Handle coding convention that was introduced to overcome fixed
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4745
diff
changeset
|
291 else if (orig.endsWith("P")) { |
0b60b77d4d00
DA66Parser: Handle coding convention that was introduced to overcome fixed
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4745
diff
changeset
|
292 return "-" + orig.replace("P","7"); |
0b60b77d4d00
DA66Parser: Handle coding convention that was introduced to overcome fixed
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4745
diff
changeset
|
293 } |
0b60b77d4d00
DA66Parser: Handle coding convention that was introduced to overcome fixed
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4745
diff
changeset
|
294 else if (orig.endsWith("Q")) { |
0b60b77d4d00
DA66Parser: Handle coding convention that was introduced to overcome fixed
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4745
diff
changeset
|
295 return "-" + orig.replace("Q","8"); |
0b60b77d4d00
DA66Parser: Handle coding convention that was introduced to overcome fixed
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4745
diff
changeset
|
296 } |
0b60b77d4d00
DA66Parser: Handle coding convention that was introduced to overcome fixed
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4745
diff
changeset
|
297 else if (orig.endsWith("R")) { |
0b60b77d4d00
DA66Parser: Handle coding convention that was introduced to overcome fixed
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4745
diff
changeset
|
298 return "-" + orig.replace("R","9"); |
0b60b77d4d00
DA66Parser: Handle coding convention that was introduced to overcome fixed
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4745
diff
changeset
|
299 } |
0b60b77d4d00
DA66Parser: Handle coding convention that was introduced to overcome fixed
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4745
diff
changeset
|
300 else { |
0b60b77d4d00
DA66Parser: Handle coding convention that was introduced to overcome fixed
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4745
diff
changeset
|
301 return orig; |
0b60b77d4d00
DA66Parser: Handle coding convention that was introduced to overcome fixed
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4745
diff
changeset
|
302 } |
0b60b77d4d00
DA66Parser: Handle coding convention that was introduced to overcome fixed
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4745
diff
changeset
|
303 } |
4720
9f7cd65daac2
DA66Parser: Try to guess whether station is given in km or in cm.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4719
diff
changeset
|
304 |
4712
70842db72ee4
Include improved DA66Parser into importer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4681
diff
changeset
|
305 /** |
70842db72ee4
Include improved DA66Parser into importer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4681
diff
changeset
|
306 * Add a Point (YZ,Index) to the current cross section line. |
70842db72ee4
Include improved DA66Parser into importer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4681
diff
changeset
|
307 * @param y The y coordinate of new point. |
70842db72ee4
Include improved DA66Parser into importer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4681
diff
changeset
|
308 * @param z The z coordinate of new point. |
70842db72ee4
Include improved DA66Parser into importer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4681
diff
changeset
|
309 * @param idx Ignored, the parameter of new point. |
70842db72ee4
Include improved DA66Parser into importer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4681
diff
changeset
|
310 * @return true if point could been added, false otherwise (e.g. not |
70842db72ee4
Include improved DA66Parser into importer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4681
diff
changeset
|
311 * parsable y or z values. |
70842db72ee4
Include improved DA66Parser into importer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4681
diff
changeset
|
312 */ |
70842db72ee4
Include improved DA66Parser into importer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4681
diff
changeset
|
313 private boolean addPoint(String y, String z, String idx) { |
70842db72ee4
Include improved DA66Parser into importer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4681
diff
changeset
|
314 if (z == null || y == null || idx == null) { |
8200
9d2e69f971f5
sed -i src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8187
diff
changeset
|
315 log.error("Incomplete point definition"); |
4712
70842db72ee4
Include improved DA66Parser into importer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4681
diff
changeset
|
316 return false; |
70842db72ee4
Include improved DA66Parser into importer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4681
diff
changeset
|
317 } |
70842db72ee4
Include improved DA66Parser into importer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4681
diff
changeset
|
318 |
4735
94b39073f0f7
Moved EpsilonComparator to utils package becaus its not only useful for TIM parsing. Used EpsilonComparator in DA60 and DA66 case. Maybe TODO: Use in PRF, too.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4729
diff
changeset
|
319 double iy; |
94b39073f0f7
Moved EpsilonComparator to utils package becaus its not only useful for TIM parsing. Used EpsilonComparator in DA60 and DA66 case. Maybe TODO: Use in PRF, too.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4729
diff
changeset
|
320 double iz; |
4746
0b60b77d4d00
DA66Parser: Handle coding convention that was introduced to overcome fixed
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4745
diff
changeset
|
321 // Handle letter convention. |
0b60b77d4d00
DA66Parser: Handle coding convention that was introduced to overcome fixed
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4745
diff
changeset
|
322 y = applyLetterConvention(y); |
4712
70842db72ee4
Include improved DA66Parser into importer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4681
diff
changeset
|
323 try { |
4727
c6d70560285f
DA66Parser: Scale x and y, as they are given in mm. Now we can actually look at the data!
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4726
diff
changeset
|
324 iy = Double.parseDouble(y) / 1000d; |
c6d70560285f
DA66Parser: Scale x and y, as they are given in mm. Now we can actually look at the data!
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4726
diff
changeset
|
325 iz = Double.parseDouble(z) / 1000d; |
4712
70842db72ee4
Include improved DA66Parser into importer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4681
diff
changeset
|
326 } |
70842db72ee4
Include improved DA66Parser into importer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4681
diff
changeset
|
327 catch(java.lang.NumberFormatException nfe) { |
8200
9d2e69f971f5
sed -i src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8187
diff
changeset
|
328 log.error("Could not parse Number: " + nfe.getMessage()); |
4712
70842db72ee4
Include improved DA66Parser into importer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4681
diff
changeset
|
329 return false; |
70842db72ee4
Include improved DA66Parser into importer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4681
diff
changeset
|
330 } |
70842db72ee4
Include improved DA66Parser into importer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4681
diff
changeset
|
331 |
70842db72ee4
Include improved DA66Parser into importer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4681
diff
changeset
|
332 // We ignore idx, and increment instead. |
4735
94b39073f0f7
Moved EpsilonComparator to utils package becaus its not only useful for TIM parsing. Used EpsilonComparator in DA60 and DA66 case. Maybe TODO: Use in PRF, too.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4729
diff
changeset
|
333 int index; |
4712
70842db72ee4
Include improved DA66Parser into importer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4681
diff
changeset
|
334 int lastPointIdx = lastPointIdx(); |
70842db72ee4
Include improved DA66Parser into importer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4681
diff
changeset
|
335 if (lastPointIdx <= 0) { |
70842db72ee4
Include improved DA66Parser into importer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4681
diff
changeset
|
336 index = 1; |
70842db72ee4
Include improved DA66Parser into importer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4681
diff
changeset
|
337 } else { |
70842db72ee4
Include improved DA66Parser into importer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4681
diff
changeset
|
338 index = lastPointIdx + 1; |
70842db72ee4
Include improved DA66Parser into importer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4681
diff
changeset
|
339 } |
70842db72ee4
Include improved DA66Parser into importer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4681
diff
changeset
|
340 |
70842db72ee4
Include improved DA66Parser into importer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4681
diff
changeset
|
341 currentLine.add(new XY(iy, iz, index)); |
70842db72ee4
Include improved DA66Parser into importer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4681
diff
changeset
|
342 return true; |
70842db72ee4
Include improved DA66Parser into importer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4681
diff
changeset
|
343 } |
70842db72ee4
Include improved DA66Parser into importer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4681
diff
changeset
|
344 |
70842db72ee4
Include improved DA66Parser into importer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4681
diff
changeset
|
345 |
70842db72ee4
Include improved DA66Parser into importer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4681
diff
changeset
|
346 /** Called before consuming first line of file. */ |
70842db72ee4
Include improved DA66Parser into importer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4681
diff
changeset
|
347 public void reset() { |
70842db72ee4
Include improved DA66Parser into importer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4681
diff
changeset
|
348 data.clear(); |
70842db72ee4
Include improved DA66Parser into importer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4681
diff
changeset
|
349 currentLine = new ArrayList<XY>(); |
70842db72ee4
Include improved DA66Parser into importer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4681
diff
changeset
|
350 } |
70842db72ee4
Include improved DA66Parser into importer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4681
diff
changeset
|
351 |
70842db72ee4
Include improved DA66Parser into importer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4681
diff
changeset
|
352 |
70842db72ee4
Include improved DA66Parser into importer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4681
diff
changeset
|
353 /** |
70842db72ee4
Include improved DA66Parser into importer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4681
diff
changeset
|
354 * Called for each line. Try to extract info from a da66 line. |
70842db72ee4
Include improved DA66Parser into importer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4681
diff
changeset
|
355 */ |
4681
aa718770308e
Less than sceleton for DA66-CrossSection parser added.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
356 @Override |
aa718770308e
Less than sceleton for DA66-CrossSection parser added.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
357 protected void handleLine(int lineNum, String line) { |
4712
70842db72ee4
Include improved DA66Parser into importer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4681
diff
changeset
|
358 String head = line.substring(0,2); |
70842db72ee4
Include improved DA66Parser into importer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4681
diff
changeset
|
359 if (HEAD_HEAD.equals(head)) { |
8200
9d2e69f971f5
sed -i src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8187
diff
changeset
|
360 //log.debug("New station"); |
4712
70842db72ee4
Include improved DA66Parser into importer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4681
diff
changeset
|
361 Matcher m = LINE_PATTERN.matcher(line); |
70842db72ee4
Include improved DA66Parser into importer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4681
diff
changeset
|
362 if (m.find()) { |
70842db72ee4
Include improved DA66Parser into importer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4681
diff
changeset
|
363 // Actually matches! |
4792
8b609ea08128
DA66Parser: Added TODOs about riveraxis.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4791
diff
changeset
|
364 // TODO 'move' last line to match river axis |
8b609ea08128
DA66Parser: Added TODOs about riveraxis.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4791
diff
changeset
|
365 // TODO find river axis intersection |
4712
70842db72ee4
Include improved DA66Parser into importer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4681
diff
changeset
|
366 currentLine = new ArrayList<XY>(); |
8856 | 367 double station = stationInKm( |
368 Double.parseDouble(m.group(FIELD.STATION.getIdx()))); | |
4720
9f7cd65daac2
DA66Parser: Try to guess whether station is given in km or in cm.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4719
diff
changeset
|
369 data.put(station, currentLine); |
4712
70842db72ee4
Include improved DA66Parser into importer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4681
diff
changeset
|
370 } |
70842db72ee4
Include improved DA66Parser into importer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4681
diff
changeset
|
371 else { |
8200
9d2e69f971f5
sed -i src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8187
diff
changeset
|
372 log.error("HEAD line bad."); |
4712
70842db72ee4
Include improved DA66Parser into importer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4681
diff
changeset
|
373 } |
4681
aa718770308e
Less than sceleton for DA66-CrossSection parser added.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
374 } |
4712
70842db72ee4
Include improved DA66Parser into importer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4681
diff
changeset
|
375 else if (HEAD_GEOM.equals(head)) { |
4681
aa718770308e
Less than sceleton for DA66-CrossSection parser added.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
376 Matcher m = LINE_PATTERN.matcher(line); |
4712
70842db72ee4
Include improved DA66Parser into importer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4681
diff
changeset
|
377 if (m.find()) { |
8200
9d2e69f971f5
sed -i src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8187
diff
changeset
|
378 //log.info("Station: " + m.group(FIELD.STATION.getIdx())); |
4712
70842db72ee4
Include improved DA66Parser into importer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4681
diff
changeset
|
379 // TODO if last station differs, error and abort |
70842db72ee4
Include improved DA66Parser into importer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4681
diff
changeset
|
380 if (m.group(FIELD.POINT_1_ID.getIdx()) != null) { |
70842db72ee4
Include improved DA66Parser into importer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4681
diff
changeset
|
381 // Point 1 |
70842db72ee4
Include improved DA66Parser into importer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4681
diff
changeset
|
382 if(addPoint( |
70842db72ee4
Include improved DA66Parser into importer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4681
diff
changeset
|
383 m.group(FIELD.POINT_1_Y.getIdx()), |
70842db72ee4
Include improved DA66Parser into importer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4681
diff
changeset
|
384 m.group(FIELD.POINT_1_Z.getIdx()), |
70842db72ee4
Include improved DA66Parser into importer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4681
diff
changeset
|
385 m.group(FIELD.POINT_1_ID.getIdx()))) { |
70842db72ee4
Include improved DA66Parser into importer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4681
diff
changeset
|
386 // Point added. |
70842db72ee4
Include improved DA66Parser into importer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4681
diff
changeset
|
387 } |
70842db72ee4
Include improved DA66Parser into importer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4681
diff
changeset
|
388 else { |
70842db72ee4
Include improved DA66Parser into importer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4681
diff
changeset
|
389 // Problematic point. |
8200
9d2e69f971f5
sed -i src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8187
diff
changeset
|
390 log.error("A point could not be added"); |
4712
70842db72ee4
Include improved DA66Parser into importer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4681
diff
changeset
|
391 } |
70842db72ee4
Include improved DA66Parser into importer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4681
diff
changeset
|
392 } |
70842db72ee4
Include improved DA66Parser into importer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4681
diff
changeset
|
393 if (m.group(FIELD.POINT_2_ID.getIdx()) != null) { |
70842db72ee4
Include improved DA66Parser into importer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4681
diff
changeset
|
394 // Point 2 |
70842db72ee4
Include improved DA66Parser into importer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4681
diff
changeset
|
395 if(addPoint( |
70842db72ee4
Include improved DA66Parser into importer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4681
diff
changeset
|
396 m.group(FIELD.POINT_2_Y.getIdx()), |
70842db72ee4
Include improved DA66Parser into importer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4681
diff
changeset
|
397 m.group(FIELD.POINT_2_Z.getIdx()), |
70842db72ee4
Include improved DA66Parser into importer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4681
diff
changeset
|
398 m.group(FIELD.POINT_2_ID.getIdx()))) { |
70842db72ee4
Include improved DA66Parser into importer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4681
diff
changeset
|
399 // Point added. |
70842db72ee4
Include improved DA66Parser into importer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4681
diff
changeset
|
400 } |
70842db72ee4
Include improved DA66Parser into importer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4681
diff
changeset
|
401 else { |
70842db72ee4
Include improved DA66Parser into importer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4681
diff
changeset
|
402 // Problematic point. |
8200
9d2e69f971f5
sed -i src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8187
diff
changeset
|
403 log.error("A point could not be added"); |
4712
70842db72ee4
Include improved DA66Parser into importer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4681
diff
changeset
|
404 } |
70842db72ee4
Include improved DA66Parser into importer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4681
diff
changeset
|
405 } |
70842db72ee4
Include improved DA66Parser into importer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4681
diff
changeset
|
406 if (m.group(FIELD.POINT_3_ID.getIdx()) != null) { |
70842db72ee4
Include improved DA66Parser into importer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4681
diff
changeset
|
407 // Point 3 |
70842db72ee4
Include improved DA66Parser into importer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4681
diff
changeset
|
408 if(addPoint( |
70842db72ee4
Include improved DA66Parser into importer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4681
diff
changeset
|
409 m.group(FIELD.POINT_3_Y.getIdx()), |
70842db72ee4
Include improved DA66Parser into importer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4681
diff
changeset
|
410 m.group(FIELD.POINT_3_Z.getIdx()), |
70842db72ee4
Include improved DA66Parser into importer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4681
diff
changeset
|
411 m.group(FIELD.POINT_3_ID.getIdx()))) { |
70842db72ee4
Include improved DA66Parser into importer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4681
diff
changeset
|
412 // Point added. |
70842db72ee4
Include improved DA66Parser into importer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4681
diff
changeset
|
413 } |
70842db72ee4
Include improved DA66Parser into importer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4681
diff
changeset
|
414 else { |
70842db72ee4
Include improved DA66Parser into importer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4681
diff
changeset
|
415 // Problematic point. |
8200
9d2e69f971f5
sed -i src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8187
diff
changeset
|
416 log.error("A point could not be added"); |
4712
70842db72ee4
Include improved DA66Parser into importer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4681
diff
changeset
|
417 } |
70842db72ee4
Include improved DA66Parser into importer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4681
diff
changeset
|
418 } |
70842db72ee4
Include improved DA66Parser into importer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4681
diff
changeset
|
419 if (m.group(FIELD.POINT_4_ID.getIdx()) != null) { |
70842db72ee4
Include improved DA66Parser into importer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4681
diff
changeset
|
420 // Point 4 |
70842db72ee4
Include improved DA66Parser into importer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4681
diff
changeset
|
421 if(addPoint( |
70842db72ee4
Include improved DA66Parser into importer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4681
diff
changeset
|
422 m.group(FIELD.POINT_4_Y.getIdx()), |
70842db72ee4
Include improved DA66Parser into importer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4681
diff
changeset
|
423 m.group(FIELD.POINT_4_Z.getIdx()), |
70842db72ee4
Include improved DA66Parser into importer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4681
diff
changeset
|
424 m.group(FIELD.POINT_4_ID.getIdx()))) { |
70842db72ee4
Include improved DA66Parser into importer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4681
diff
changeset
|
425 // Point added. |
70842db72ee4
Include improved DA66Parser into importer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4681
diff
changeset
|
426 } |
70842db72ee4
Include improved DA66Parser into importer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4681
diff
changeset
|
427 else { |
70842db72ee4
Include improved DA66Parser into importer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4681
diff
changeset
|
428 // Problematic point. |
8200
9d2e69f971f5
sed -i src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8187
diff
changeset
|
429 log.error("A point could not be added"); |
4712
70842db72ee4
Include improved DA66Parser into importer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4681
diff
changeset
|
430 } |
70842db72ee4
Include improved DA66Parser into importer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4681
diff
changeset
|
431 } |
70842db72ee4
Include improved DA66Parser into importer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4681
diff
changeset
|
432 } |
70842db72ee4
Include improved DA66Parser into importer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4681
diff
changeset
|
433 else { |
8200
9d2e69f971f5
sed -i src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8187
diff
changeset
|
434 log.warn("Line could not be parsed: "); |
9d2e69f971f5
sed -i src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8187
diff
changeset
|
435 log.warn(line); |
4712
70842db72ee4
Include improved DA66Parser into importer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4681
diff
changeset
|
436 } |
4681
aa718770308e
Less than sceleton for DA66-CrossSection parser added.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
437 } |
4712
70842db72ee4
Include improved DA66Parser into importer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4681
diff
changeset
|
438 else if (HEAD_GEOM.equals(head)) { |
8200
9d2e69f971f5
sed -i src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8187
diff
changeset
|
439 log.debug("Hit a 88"); |
4712
70842db72ee4
Include improved DA66Parser into importer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4681
diff
changeset
|
440 } |
70842db72ee4
Include improved DA66Parser into importer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4681
diff
changeset
|
441 else { |
8200
9d2e69f971f5
sed -i src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8187
diff
changeset
|
442 log.error("Do not know how to treat da66 line:"); |
9d2e69f971f5
sed -i src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8187
diff
changeset
|
443 log.error(line); |
4712
70842db72ee4
Include improved DA66Parser into importer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4681
diff
changeset
|
444 } |
70842db72ee4
Include improved DA66Parser into importer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4681
diff
changeset
|
445 } |
70842db72ee4
Include improved DA66Parser into importer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4681
diff
changeset
|
446 |
70842db72ee4
Include improved DA66Parser into importer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4681
diff
changeset
|
447 |
70842db72ee4
Include improved DA66Parser into importer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4681
diff
changeset
|
448 /** Called when file is fully consumed. */ |
70842db72ee4
Include improved DA66Parser into importer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4681
diff
changeset
|
449 @Override |
70842db72ee4
Include improved DA66Parser into importer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4681
diff
changeset
|
450 protected void finish() { |
4792
8b609ea08128
DA66Parser: Added TODOs about riveraxis.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4791
diff
changeset
|
451 // TODO 'move' last line to match river axis |
8200
9d2e69f971f5
sed -i src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8187
diff
changeset
|
452 log.info("Parsed " + data.size() + " lines"); |
4681
aa718770308e
Less than sceleton for DA66-CrossSection parser added.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
453 } |
aa718770308e
Less than sceleton for DA66-CrossSection parser added.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
454 |
aa718770308e
Less than sceleton for DA66-CrossSection parser added.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
455 |
aa718770308e
Less than sceleton for DA66-CrossSection parser added.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
456 /** Parses files given as arguments. */ |
aa718770308e
Less than sceleton for DA66-CrossSection parser added.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
457 public static void main(String [] args) { |
aa718770308e
Less than sceleton for DA66-CrossSection parser added.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
458 |
aa718770308e
Less than sceleton for DA66-CrossSection parser added.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
459 DA66Parser parser = new DA66Parser(); |
aa718770308e
Less than sceleton for DA66-CrossSection parser added.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
460 |
8200
9d2e69f971f5
sed -i src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8187
diff
changeset
|
461 log.warn("Start parsing files."); |
4681
aa718770308e
Less than sceleton for DA66-CrossSection parser added.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
462 for (String arg: args) { |
aa718770308e
Less than sceleton for DA66-CrossSection parser added.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
463 parser.parseDA66s(new File(arg), null); |
8200
9d2e69f971f5
sed -i src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8187
diff
changeset
|
464 log.warn("Parsing a file."); |
4681
aa718770308e
Less than sceleton for DA66-CrossSection parser added.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
465 } |
8200
9d2e69f971f5
sed -i src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8187
diff
changeset
|
466 log.error("Finished parsing files."); |
4681
aa718770308e
Less than sceleton for DA66-CrossSection parser added.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
467 } |
aa718770308e
Less than sceleton for DA66-CrossSection parser added.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
468 } |
aa718770308e
Less than sceleton for DA66-CrossSection parser added.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
469 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |