Mercurial > dive4elements > river
annotate flys-backend/src/main/java/de/intevation/flys/importer/parsers/DA66Parser.java @ 4727:c6d70560285f
DA66Parser: Scale x and y, as they are given in mm. Now we can actually look at the data!
author | Felix Wolfsteller <felix.wolfsteller@intevation.de> |
---|---|
date | Thu, 27 Dec 2012 16:15:51 +0100 |
parents | 4f7d264c27f5 |
children | 0df1cac6c4b5 |
rev | line source |
---|---|
4681
aa718770308e
Less than sceleton for DA66-CrossSection parser added.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
1 package de.intevation.flys.importer.parsers; |
aa718770308e
Less than sceleton for DA66-CrossSection parser added.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
2 |
aa718770308e
Less than sceleton for DA66-CrossSection parser added.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
3 import java.util.ArrayList; |
aa718770308e
Less than sceleton for DA66-CrossSection parser added.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
4 import java.util.HashMap; |
aa718770308e
Less than sceleton for DA66-CrossSection parser added.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
5 import java.util.Map; |
aa718770308e
Less than sceleton for DA66-CrossSection parser added.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
6 import java.util.List; |
aa718770308e
Less than sceleton for DA66-CrossSection parser added.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
7 import java.util.TreeMap; |
aa718770308e
Less than sceleton for DA66-CrossSection parser added.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
8 |
aa718770308e
Less than sceleton for DA66-CrossSection parser added.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
9 import java.util.regex.Pattern; |
aa718770308e
Less than sceleton for DA66-CrossSection parser added.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
10 import java.util.regex.Matcher; |
aa718770308e
Less than sceleton for DA66-CrossSection parser added.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
11 |
aa718770308e
Less than sceleton for DA66-CrossSection parser added.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
12 import java.io.File; |
aa718770308e
Less than sceleton for DA66-CrossSection parser added.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
13 import java.io.IOException; |
aa718770308e
Less than sceleton for DA66-CrossSection parser added.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
14 |
aa718770308e
Less than sceleton for DA66-CrossSection parser added.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
15 import org.apache.log4j.Logger; |
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 de.intevation.flys.importer.XY; |
aa718770308e
Less than sceleton for DA66-CrossSection parser added.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
18 |
aa718770308e
Less than sceleton for DA66-CrossSection parser added.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
19 import de.intevation.artifacts.common.utils.FileTools; |
aa718770308e
Less than sceleton for DA66-CrossSection parser added.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
20 |
aa718770308e
Less than sceleton for DA66-CrossSection parser added.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
21 |
aa718770308e
Less than sceleton for DA66-CrossSection parser added.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
22 /** |
aa718770308e
Less than sceleton for DA66-CrossSection parser added.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
23 * 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
|
24 * in da66 format. |
aa718770308e
Less than sceleton for DA66-CrossSection parser added.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
25 */ |
4715
2f7a509f5acf
Implement new CrossSectionParser interface.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4712
diff
changeset
|
26 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
|
27 { |
aa718770308e
Less than sceleton for DA66-CrossSection parser added.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
28 /** Private logger. */ |
aa718770308e
Less than sceleton for DA66-CrossSection parser added.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
29 private static Logger logger = Logger.getLogger(DA66Parser.class); |
aa718770308e
Less than sceleton for DA66-CrossSection parser added.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
30 |
4712
70842db72ee4
Include improved DA66Parser into importer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4681
diff
changeset
|
31 private static String HEAD_HEAD = "00"; |
70842db72ee4
Include improved DA66Parser into importer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4681
diff
changeset
|
32 private static String HEAD_GEOM = "66"; // "Values" |
70842db72ee4
Include improved DA66Parser into importer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4681
diff
changeset
|
33 private static String HEAD_ENDG = "88"; // Probably never used. |
70842db72ee4
Include improved DA66Parser into importer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4681
diff
changeset
|
34 |
4717
e67d396ed65d
Documentation of DA66Parser.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4715
diff
changeset
|
35 /** 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
|
36 private static final Pattern LINE_PATTERN = |
70842db72ee4
Include improved DA66Parser into importer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4681
diff
changeset
|
37 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
|
38 "([0-9 -]{5})" + // unset |
aa718770308e
Less than sceleton for DA66-CrossSection parser added.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
39 "([0-9 -]{2})" + // id |
aa718770308e
Less than sceleton for DA66-CrossSection parser added.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
40 "([0-9 -]{9})" + // station |
aa718770308e
Less than sceleton for DA66-CrossSection parser added.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
41 "([0-9 -]{2})" + // running number |
4712
70842db72ee4
Include improved DA66Parser into importer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4681
diff
changeset
|
42 "([0-9 -]{1})?" + // point id |
4681
aa718770308e
Less than sceleton for DA66-CrossSection parser added.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
43 /* |
aa718770308e
Less than sceleton for DA66-CrossSection parser added.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
44 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
|
45 ([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
|
46 */ |
4712
70842db72ee4
Include improved DA66Parser into importer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4681
diff
changeset
|
47 "([0-9 -JKMLMNOPQR]{7})?" + // y |
70842db72ee4
Include improved DA66Parser into importer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4681
diff
changeset
|
48 "([0-9 -]{7})?" + // z |
70842db72ee4
Include improved DA66Parser into importer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4681
diff
changeset
|
49 "([0-9 -]{1})?" + // point id |
70842db72ee4
Include improved DA66Parser into importer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4681
diff
changeset
|
50 "([0-9 -JKMLMNOPQR]{7})?" + // y |
70842db72ee4
Include improved DA66Parser into importer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4681
diff
changeset
|
51 "([0-9 -]{7})?" + // z |
70842db72ee4
Include improved DA66Parser into importer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4681
diff
changeset
|
52 "([0-9 -]{1})?" + // point id |
70842db72ee4
Include improved DA66Parser into importer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4681
diff
changeset
|
53 "([0-9 -JKMLMNOPQR]{7})?" + // y |
70842db72ee4
Include improved DA66Parser into importer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4681
diff
changeset
|
54 "([0-9 -]{7})?" + // z |
70842db72ee4
Include improved DA66Parser into importer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4681
diff
changeset
|
55 "([0-9 -]{1})?" + // point id |
70842db72ee4
Include improved DA66Parser into importer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4681
diff
changeset
|
56 "([0-9 -JKMLMNOPQR]{7})?" + // y |
70842db72ee4
Include improved DA66Parser into importer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4681
diff
changeset
|
57 "([0-9 -]{7})?" // z |
4681
aa718770308e
Less than sceleton for DA66-CrossSection parser added.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
58 ); |
aa718770308e
Less than sceleton for DA66-CrossSection parser added.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
59 //Pattern.compile("^([0-9 -]{2})"); |
aa718770308e
Less than sceleton for DA66-CrossSection parser added.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
60 |
4723
83304d3651ec
DA66Parser: Whitespace cosmetics.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4722
diff
changeset
|
61 |
4712
70842db72ee4
Include improved DA66Parser into importer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4681
diff
changeset
|
62 /** Indices to match group of main regex. */ |
70842db72ee4
Include improved DA66Parser into importer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4681
diff
changeset
|
63 private static enum FIELD { |
70842db72ee4
Include improved DA66Parser into importer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4681
diff
changeset
|
64 HEAD ( 1), |
70842db72ee4
Include improved DA66Parser into importer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4681
diff
changeset
|
65 UNSET ( 2), |
70842db72ee4
Include improved DA66Parser into importer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4681
diff
changeset
|
66 ID ( 3), |
70842db72ee4
Include improved DA66Parser into importer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4681
diff
changeset
|
67 STATION ( 4), |
70842db72ee4
Include improved DA66Parser into importer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4681
diff
changeset
|
68 RUNNR ( 5), |
70842db72ee4
Include improved DA66Parser into importer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4681
diff
changeset
|
69 POINT_1_ID( 6), |
70842db72ee4
Include improved DA66Parser into importer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4681
diff
changeset
|
70 POINT_1_Y ( 7), |
70842db72ee4
Include improved DA66Parser into importer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4681
diff
changeset
|
71 POINT_1_Z ( 8), |
70842db72ee4
Include improved DA66Parser into importer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4681
diff
changeset
|
72 POINT_2_ID( 9), |
70842db72ee4
Include improved DA66Parser into importer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4681
diff
changeset
|
73 POINT_2_Y (10), |
70842db72ee4
Include improved DA66Parser into importer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4681
diff
changeset
|
74 POINT_2_Z (11), |
70842db72ee4
Include improved DA66Parser into importer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4681
diff
changeset
|
75 POINT_3_ID(12), |
70842db72ee4
Include improved DA66Parser into importer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4681
diff
changeset
|
76 POINT_3_Y (13), |
70842db72ee4
Include improved DA66Parser into importer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4681
diff
changeset
|
77 POINT_3_Z (14), |
70842db72ee4
Include improved DA66Parser into importer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4681
diff
changeset
|
78 POINT_4_ID(15), |
70842db72ee4
Include improved DA66Parser into importer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4681
diff
changeset
|
79 POINT_4_Y (16), |
70842db72ee4
Include improved DA66Parser into importer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4681
diff
changeset
|
80 POINT_4_Z (17); |
70842db72ee4
Include improved DA66Parser into importer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4681
diff
changeset
|
81 |
70842db72ee4
Include improved DA66Parser into importer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4681
diff
changeset
|
82 private int idx; |
70842db72ee4
Include improved DA66Parser into importer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4681
diff
changeset
|
83 FIELD(int idx) { |
70842db72ee4
Include improved DA66Parser into importer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4681
diff
changeset
|
84 this.idx = idx; |
70842db72ee4
Include improved DA66Parser into importer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4681
diff
changeset
|
85 } |
70842db72ee4
Include improved DA66Parser into importer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4681
diff
changeset
|
86 int getIdx() { |
70842db72ee4
Include improved DA66Parser into importer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4681
diff
changeset
|
87 return idx; |
70842db72ee4
Include improved DA66Parser into importer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4681
diff
changeset
|
88 } |
70842db72ee4
Include improved DA66Parser into importer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4681
diff
changeset
|
89 } |
70842db72ee4
Include improved DA66Parser into importer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4681
diff
changeset
|
90 |
4723
83304d3651ec
DA66Parser: Whitespace cosmetics.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4722
diff
changeset
|
91 |
4712
70842db72ee4
Include improved DA66Parser into importer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4681
diff
changeset
|
92 /** 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
|
93 private static enum Type { |
aa718770308e
Less than sceleton for DA66-CrossSection parser added.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
94 DATE ( 0), |
aa718770308e
Less than sceleton for DA66-CrossSection parser added.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
95 HEKTOSTONE_LEFT ( 1), //grm. "Standlinie" |
aa718770308e
Less than sceleton for DA66-CrossSection parser added.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
96 HEKTOSTONE_RIGHT ( 2), |
aa718770308e
Less than sceleton for DA66-CrossSection parser added.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
97 CHANNEL_LEFT ( 3), //grm. "Fahrrinne" |
aa718770308e
Less than sceleton for DA66-CrossSection parser added.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
98 CHANNEL_RIGHT ( 4), |
aa718770308e
Less than sceleton for DA66-CrossSection parser added.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
99 CHANNEL_2_LEFT ( 5), |
aa718770308e
Less than sceleton for DA66-CrossSection parser added.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
100 CHANNEL_2_RIGHT ( 6), |
aa718770308e
Less than sceleton for DA66-CrossSection parser added.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
101 GIW_1972 ( 7), |
aa718770308e
Less than sceleton for DA66-CrossSection parser added.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
102 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
|
103 GROIN_HEIGHT_LEFT ( 9), |
aa718770308e
Less than sceleton for DA66-CrossSection parser added.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
104 GROIN_SLOPE_LEFT (10), |
aa718770308e
Less than sceleton for DA66-CrossSection parser added.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
105 GROIN_DIST_RIGHT (11), |
aa718770308e
Less than sceleton for DA66-CrossSection parser added.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
106 GROIN_HEIGHT_RIGHT (12), |
aa718770308e
Less than sceleton for DA66-CrossSection parser added.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
107 GROIN_SLOPE_RIGHT (13), |
aa718770308e
Less than sceleton for DA66-CrossSection parser added.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
108 STRIKE_LEFT (14), //grm. "Streichlinie links" |
aa718770308e
Less than sceleton for DA66-CrossSection parser added.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
109 AXIS (15), |
aa718770308e
Less than sceleton for DA66-CrossSection parser added.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
110 STRIKE_RIGHT (16), |
aa718770308e
Less than sceleton for DA66-CrossSection parser added.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
111 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
|
112 GROIN_BACK_SLOPE_RIGHT (18), |
aa718770308e
Less than sceleton for DA66-CrossSection parser added.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
113 GIW_1932 (19), |
aa718770308e
Less than sceleton for DA66-CrossSection parser added.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
114 GIW_1982 (20), |
aa718770308e
Less than sceleton for DA66-CrossSection parser added.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
115 STAND_ISLAND_1 (21), |
aa718770308e
Less than sceleton for DA66-CrossSection parser added.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
116 STAND_ISLAND_2 (22), |
aa718770308e
Less than sceleton for DA66-CrossSection parser added.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
117 STAND_ISLAND_3 (23), |
aa718770308e
Less than sceleton for DA66-CrossSection parser added.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
118 STAND_ISLAND_4 (24), |
aa718770308e
Less than sceleton for DA66-CrossSection parser added.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
119 UNSPECIFIED_1 (25), |
aa718770308e
Less than sceleton for DA66-CrossSection parser added.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
120 UNSPECIFIED_2 (26), |
aa718770308e
Less than sceleton for DA66-CrossSection parser added.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
121 HHW (27), |
aa718770308e
Less than sceleton for DA66-CrossSection parser added.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
122 OLD_PROFILE_NULL (28), |
aa718770308e
Less than sceleton for DA66-CrossSection parser added.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
123 AW_1978 (29), |
aa718770308e
Less than sceleton for DA66-CrossSection parser added.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
124 SIGN_LEFT (30), |
aa718770308e
Less than sceleton for DA66-CrossSection parser added.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
125 SIGN_RIGHT (31), |
aa718770308e
Less than sceleton for DA66-CrossSection parser added.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
126 DIST_SIGNAL_CHANNEL_LEFT (32), |
aa718770308e
Less than sceleton for DA66-CrossSection parser added.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
127 DIST_SIGNAL_CHANNEL_RIGHT(33), |
aa718770308e
Less than sceleton for DA66-CrossSection parser added.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
128 UNSPECIFIED_3 (34), |
aa718770308e
Less than sceleton for DA66-CrossSection parser added.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
129 UNSPECIFIED_4 (35), |
aa718770308e
Less than sceleton for DA66-CrossSection parser added.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
130 UNSPECIFIED_5 (36), |
aa718770308e
Less than sceleton for DA66-CrossSection parser added.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
131 UNSPECIFIED_6 (37), |
aa718770308e
Less than sceleton for DA66-CrossSection parser added.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
132 SHORE_LEFT (38), |
aa718770308e
Less than sceleton for DA66-CrossSection parser added.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
133 SHORE_RIGHT (39), |
aa718770308e
Less than sceleton for DA66-CrossSection parser added.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
134 UNSPECIFIED_7 (40); |
aa718770308e
Less than sceleton for DA66-CrossSection parser added.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
135 |
aa718770308e
Less than sceleton for DA66-CrossSection parser added.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
136 private final int id; |
aa718770308e
Less than sceleton for DA66-CrossSection parser added.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
137 Type(int id) { |
aa718770308e
Less than sceleton for DA66-CrossSection parser added.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
138 this.id = id; |
aa718770308e
Less than sceleton for DA66-CrossSection parser added.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
139 } |
aa718770308e
Less than sceleton for DA66-CrossSection parser added.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
140 public int getId() { |
aa718770308e
Less than sceleton for DA66-CrossSection parser added.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
141 return id; |
aa718770308e
Less than sceleton for DA66-CrossSection parser added.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
142 } |
aa718770308e
Less than sceleton for DA66-CrossSection parser added.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
143 } |
aa718770308e
Less than sceleton for DA66-CrossSection parser added.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
144 |
4723
83304d3651ec
DA66Parser: Whitespace cosmetics.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4722
diff
changeset
|
145 |
4681
aa718770308e
Less than sceleton for DA66-CrossSection parser added.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
146 /** Available types. */ |
aa718770308e
Less than sceleton for DA66-CrossSection parser added.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
147 private static HashMap<Integer, Type> typeMap; |
aa718770308e
Less than sceleton for DA66-CrossSection parser added.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
148 |
4723
83304d3651ec
DA66Parser: Whitespace cosmetics.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4722
diff
changeset
|
149 |
4681
aa718770308e
Less than sceleton for DA66-CrossSection parser added.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
150 /** Types we can deal with. */ |
aa718770308e
Less than sceleton for DA66-CrossSection parser added.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
151 private static List<Type> implementedTypes; |
aa718770308e
Less than sceleton for DA66-CrossSection parser added.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
152 |
4723
83304d3651ec
DA66Parser: Whitespace cosmetics.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4722
diff
changeset
|
153 |
4681
aa718770308e
Less than sceleton for DA66-CrossSection parser added.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
154 static { |
aa718770308e
Less than sceleton for DA66-CrossSection parser added.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
155 typeMap = new HashMap<Integer, Type>(); |
aa718770308e
Less than sceleton for DA66-CrossSection parser added.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
156 for (Type t: Type.values()) { |
aa718770308e
Less than sceleton for DA66-CrossSection parser added.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
157 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
|
158 } |
4712
70842db72ee4
Include improved DA66Parser into importer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4681
diff
changeset
|
159 // 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
|
160 implementedTypes = new ArrayList<Type>(); |
aa718770308e
Less than sceleton for DA66-CrossSection parser added.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
161 //implementedTypes.add(..); |
aa718770308e
Less than sceleton for DA66-CrossSection parser added.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
162 } |
aa718770308e
Less than sceleton for DA66-CrossSection parser added.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
163 |
4712
70842db72ee4
Include improved DA66Parser into importer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4681
diff
changeset
|
164 |
70842db72ee4
Include improved DA66Parser into importer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4681
diff
changeset
|
165 /** The current line to which add points. */ |
70842db72ee4
Include improved DA66Parser into importer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4681
diff
changeset
|
166 private List<XY> currentLine; |
70842db72ee4
Include improved DA66Parser into importer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4681
diff
changeset
|
167 |
70842db72ee4
Include improved DA66Parser into importer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4681
diff
changeset
|
168 |
70842db72ee4
Include improved DA66Parser into importer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4681
diff
changeset
|
169 /** 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
|
170 protected Map<Double, List<XY>> data; |
aa718770308e
Less than sceleton for DA66-CrossSection parser added.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
171 |
aa718770308e
Less than sceleton for DA66-CrossSection parser added.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
172 |
4717
e67d396ed65d
Documentation of DA66Parser.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4715
diff
changeset
|
173 /** Trivial constructor. */ |
4681
aa718770308e
Less than sceleton for DA66-CrossSection parser added.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
174 public DA66Parser() { |
aa718770308e
Less than sceleton for DA66-CrossSection parser added.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
175 data = new TreeMap<Double, List<XY>>(); |
aa718770308e
Less than sceleton for DA66-CrossSection parser added.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
176 } |
aa718770308e
Less than sceleton for DA66-CrossSection parser added.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
177 |
4717
e67d396ed65d
Documentation of DA66Parser.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4715
diff
changeset
|
178 |
e67d396ed65d
Documentation of DA66Parser.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4715
diff
changeset
|
179 /** Get the description of the cross section parsed. */ |
4715
2f7a509f5acf
Implement new CrossSectionParser interface.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4712
diff
changeset
|
180 @Override |
2f7a509f5acf
Implement new CrossSectionParser interface.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4712
diff
changeset
|
181 public String getDescription() { |
4722
c3e2b0d343dc
DA66Parser: Use filename without extension as description for cross section.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4720
diff
changeset
|
182 return removeExtension(getFileName()); |
4715
2f7a509f5acf
Implement new CrossSectionParser interface.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4712
diff
changeset
|
183 } |
2f7a509f5acf
Implement new CrossSectionParser interface.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4712
diff
changeset
|
184 |
4717
e67d396ed65d
Documentation of DA66Parser.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4715
diff
changeset
|
185 |
e67d396ed65d
Documentation of DA66Parser.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4715
diff
changeset
|
186 /** Get the year of this cross sections measurement. */ |
4715
2f7a509f5acf
Implement new CrossSectionParser interface.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4712
diff
changeset
|
187 @Override |
2f7a509f5acf
Implement new CrossSectionParser interface.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4712
diff
changeset
|
188 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
|
189 return null; |
4715
2f7a509f5acf
Implement new CrossSectionParser interface.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4712
diff
changeset
|
190 } |
2f7a509f5acf
Implement new CrossSectionParser interface.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4712
diff
changeset
|
191 |
4717
e67d396ed65d
Documentation of DA66Parser.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4715
diff
changeset
|
192 |
e67d396ed65d
Documentation of DA66Parser.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4715
diff
changeset
|
193 /** |
e67d396ed65d
Documentation of DA66Parser.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4715
diff
changeset
|
194 * Return the data parsed. |
e67d396ed65d
Documentation of DA66Parser.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4715
diff
changeset
|
195 * @return map of stations (km) to list of points. |
e67d396ed65d
Documentation of DA66Parser.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4715
diff
changeset
|
196 */ |
4715
2f7a509f5acf
Implement new CrossSectionParser interface.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4712
diff
changeset
|
197 @Override |
4681
aa718770308e
Less than sceleton for DA66-CrossSection parser added.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
198 public Map<Double, List<XY>> getData() { |
aa718770308e
Less than sceleton for DA66-CrossSection parser added.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
199 return data; |
aa718770308e
Less than sceleton for DA66-CrossSection parser added.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
200 } |
aa718770308e
Less than sceleton for DA66-CrossSection parser added.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
201 |
aa718770308e
Less than sceleton for DA66-CrossSection parser added.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
202 |
4717
e67d396ed65d
Documentation of DA66Parser.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4715
diff
changeset
|
203 // TODO yet unused, use for description. |
4681
aa718770308e
Less than sceleton for DA66-CrossSection parser added.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
204 private static final String removeExtension(String name) { |
aa718770308e
Less than sceleton for DA66-CrossSection parser added.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
205 int index = name.lastIndexOf('.'); |
aa718770308e
Less than sceleton for DA66-CrossSection parser added.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
206 return index == -1 |
aa718770308e
Less than sceleton for DA66-CrossSection parser added.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
207 ? name |
aa718770308e
Less than sceleton for DA66-CrossSection parser added.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
208 : name.substring(0, index); |
aa718770308e
Less than sceleton for DA66-CrossSection parser added.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
209 } |
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 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
|
212 |
4712
70842db72ee4
Include improved DA66Parser into importer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4681
diff
changeset
|
213 // TODO use the removeExtension/guess description and date. |
4681
aa718770308e
Less than sceleton for DA66-CrossSection parser added.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
214 FileTools.walkTree(root, new FileTools.FileVisitor() { |
aa718770308e
Less than sceleton for DA66-CrossSection parser added.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
215 @Override |
aa718770308e
Less than sceleton for DA66-CrossSection parser added.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
216 public boolean visit(File file) { |
aa718770308e
Less than sceleton for DA66-CrossSection parser added.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
217 if (file.isFile() && file.canRead() |
aa718770308e
Less than sceleton for DA66-CrossSection parser added.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
218 && file.getName().toLowerCase().endsWith(".d66") |
4715
2f7a509f5acf
Implement new CrossSectionParser interface.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4712
diff
changeset
|
219 && (callback == null || callback.accept(file))) { |
4681
aa718770308e
Less than sceleton for DA66-CrossSection parser added.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
220 reset(); |
aa718770308e
Less than sceleton for DA66-CrossSection parser added.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
221 try { |
aa718770308e
Less than sceleton for DA66-CrossSection parser added.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
222 parse(file); |
aa718770308e
Less than sceleton for DA66-CrossSection parser added.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
223 logger.info("parsing done"); |
aa718770308e
Less than sceleton for DA66-CrossSection parser added.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
224 if (callback != null) { |
4715
2f7a509f5acf
Implement new CrossSectionParser interface.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4712
diff
changeset
|
225 callback.parsed(DA66Parser.this); |
4681
aa718770308e
Less than sceleton for DA66-CrossSection parser added.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
226 } |
aa718770308e
Less than sceleton for DA66-CrossSection parser added.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
227 } |
aa718770308e
Less than sceleton for DA66-CrossSection parser added.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
228 catch (IOException ioe) { |
aa718770308e
Less than sceleton for DA66-CrossSection parser added.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
229 logger.error("IOException while parsing file"); |
aa718770308e
Less than sceleton for DA66-CrossSection parser added.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
230 return false; |
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 return true; |
aa718770308e
Less than sceleton for DA66-CrossSection parser added.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
234 } |
aa718770308e
Less than sceleton for DA66-CrossSection parser added.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
235 }); |
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 |
4712
70842db72ee4
Include improved DA66Parser into importer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4681
diff
changeset
|
239 /** |
70842db72ee4
Include improved DA66Parser into importer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4681
diff
changeset
|
240 * 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
|
241 * @return last points index, -1 if not available. |
70842db72ee4
Include improved DA66Parser into importer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4681
diff
changeset
|
242 */ |
70842db72ee4
Include improved DA66Parser into importer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4681
diff
changeset
|
243 private int lastPointIdx() { |
70842db72ee4
Include improved DA66Parser into importer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4681
diff
changeset
|
244 if (currentLine == null || currentLine.isEmpty()) { |
70842db72ee4
Include improved DA66Parser into importer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4681
diff
changeset
|
245 return -1; |
70842db72ee4
Include improved DA66Parser into importer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4681
diff
changeset
|
246 } |
70842db72ee4
Include improved DA66Parser into importer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4681
diff
changeset
|
247 XY lastPoint = this.currentLine.get(currentLine.size()-1); |
70842db72ee4
Include improved DA66Parser into importer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4681
diff
changeset
|
248 return lastPoint.getIndex(); |
70842db72ee4
Include improved DA66Parser into importer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4681
diff
changeset
|
249 } |
70842db72ee4
Include improved DA66Parser into importer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4681
diff
changeset
|
250 |
70842db72ee4
Include improved DA66Parser into importer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4681
diff
changeset
|
251 |
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
|
252 /** 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
|
253 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
|
254 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
|
255 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
|
256 } |
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 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
|
258 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
|
259 } |
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 } |
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 |
4712
70842db72ee4
Include improved DA66Parser into importer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4681
diff
changeset
|
263 /** |
70842db72ee4
Include improved DA66Parser into importer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4681
diff
changeset
|
264 * 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
|
265 * @param y The y coordinate of new point. |
70842db72ee4
Include improved DA66Parser into importer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4681
diff
changeset
|
266 * @param z The z coordinate of new point. |
70842db72ee4
Include improved DA66Parser into importer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4681
diff
changeset
|
267 * @param idx Ignored, the parameter of new point. |
70842db72ee4
Include improved DA66Parser into importer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4681
diff
changeset
|
268 * @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
|
269 * parsable y or z values. |
70842db72ee4
Include improved DA66Parser into importer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4681
diff
changeset
|
270 */ |
70842db72ee4
Include improved DA66Parser into importer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4681
diff
changeset
|
271 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
|
272 if (z == null || y == null || idx == null) { |
70842db72ee4
Include improved DA66Parser into importer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4681
diff
changeset
|
273 logger.error("Incomplete point definition"); |
70842db72ee4
Include improved DA66Parser into importer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4681
diff
changeset
|
274 return false; |
70842db72ee4
Include improved DA66Parser into importer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4681
diff
changeset
|
275 } |
70842db72ee4
Include improved DA66Parser into importer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4681
diff
changeset
|
276 |
70842db72ee4
Include improved DA66Parser into importer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4681
diff
changeset
|
277 Double iy; |
70842db72ee4
Include improved DA66Parser into importer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4681
diff
changeset
|
278 Double iz; |
70842db72ee4
Include improved DA66Parser into importer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4681
diff
changeset
|
279 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
|
280 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
|
281 iz = Double.parseDouble(z) / 1000d; |
4712
70842db72ee4
Include improved DA66Parser into importer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4681
diff
changeset
|
282 } |
70842db72ee4
Include improved DA66Parser into importer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4681
diff
changeset
|
283 catch(java.lang.NumberFormatException nfe) { |
70842db72ee4
Include improved DA66Parser into importer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4681
diff
changeset
|
284 logger.error("Could not parse Number: " + nfe.getMessage()); |
70842db72ee4
Include improved DA66Parser into importer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4681
diff
changeset
|
285 return false; |
70842db72ee4
Include improved DA66Parser into importer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4681
diff
changeset
|
286 } |
70842db72ee4
Include improved DA66Parser into importer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4681
diff
changeset
|
287 |
70842db72ee4
Include improved DA66Parser into importer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4681
diff
changeset
|
288 // We ignore idx, and increment instead. |
70842db72ee4
Include improved DA66Parser into importer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4681
diff
changeset
|
289 Integer index; |
70842db72ee4
Include improved DA66Parser into importer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4681
diff
changeset
|
290 int lastPointIdx = lastPointIdx(); |
70842db72ee4
Include improved DA66Parser into importer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4681
diff
changeset
|
291 if (lastPointIdx <= 0) { |
70842db72ee4
Include improved DA66Parser into importer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4681
diff
changeset
|
292 index = 1; |
70842db72ee4
Include improved DA66Parser into importer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4681
diff
changeset
|
293 } else { |
70842db72ee4
Include improved DA66Parser into importer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4681
diff
changeset
|
294 index = lastPointIdx + 1; |
70842db72ee4
Include improved DA66Parser into importer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4681
diff
changeset
|
295 } |
70842db72ee4
Include improved DA66Parser into importer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4681
diff
changeset
|
296 |
70842db72ee4
Include improved DA66Parser into importer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4681
diff
changeset
|
297 currentLine.add(new XY(iy, iz, index)); |
70842db72ee4
Include improved DA66Parser into importer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4681
diff
changeset
|
298 return true; |
70842db72ee4
Include improved DA66Parser into importer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4681
diff
changeset
|
299 } |
70842db72ee4
Include improved DA66Parser into importer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4681
diff
changeset
|
300 |
70842db72ee4
Include improved DA66Parser into importer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4681
diff
changeset
|
301 |
70842db72ee4
Include improved DA66Parser into importer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4681
diff
changeset
|
302 /** Called before consuming first line of file. */ |
70842db72ee4
Include improved DA66Parser into importer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4681
diff
changeset
|
303 public void reset() { |
70842db72ee4
Include improved DA66Parser into importer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4681
diff
changeset
|
304 data.clear(); |
70842db72ee4
Include improved DA66Parser into importer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4681
diff
changeset
|
305 currentLine = new ArrayList<XY>(); |
70842db72ee4
Include improved DA66Parser into importer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4681
diff
changeset
|
306 } |
70842db72ee4
Include improved DA66Parser into importer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4681
diff
changeset
|
307 |
70842db72ee4
Include improved DA66Parser into importer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4681
diff
changeset
|
308 |
70842db72ee4
Include improved DA66Parser into importer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4681
diff
changeset
|
309 /** |
70842db72ee4
Include improved DA66Parser into importer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4681
diff
changeset
|
310 * 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
|
311 */ |
4681
aa718770308e
Less than sceleton for DA66-CrossSection parser added.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
312 @Override |
aa718770308e
Less than sceleton for DA66-CrossSection parser added.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
313 protected void handleLine(int lineNum, String line) { |
4712
70842db72ee4
Include improved DA66Parser into importer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4681
diff
changeset
|
314 String head = line.substring(0,2); |
70842db72ee4
Include improved DA66Parser into importer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4681
diff
changeset
|
315 if (HEAD_HEAD.equals(head)) { |
4715
2f7a509f5acf
Implement new CrossSectionParser interface.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4712
diff
changeset
|
316 //logger.debug("New station"); |
4712
70842db72ee4
Include improved DA66Parser into importer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4681
diff
changeset
|
317 Matcher m = LINE_PATTERN.matcher(line); |
70842db72ee4
Include improved DA66Parser into importer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4681
diff
changeset
|
318 if (m.find()) { |
70842db72ee4
Include improved DA66Parser into importer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4681
diff
changeset
|
319 // Actually matches! |
70842db72ee4
Include improved DA66Parser into importer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4681
diff
changeset
|
320 currentLine = new ArrayList<XY>(); |
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
|
321 double station = stationInKm(Double.parseDouble(m.group(FIELD.STATION.getIdx()))); |
9f7cd65daac2
DA66Parser: Try to guess whether station is given in km or in cm.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4719
diff
changeset
|
322 data.put(station, currentLine); |
4712
70842db72ee4
Include improved DA66Parser into importer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4681
diff
changeset
|
323 } |
70842db72ee4
Include improved DA66Parser into importer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4681
diff
changeset
|
324 else { |
70842db72ee4
Include improved DA66Parser into importer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4681
diff
changeset
|
325 logger.error("HEAD line bad."); |
70842db72ee4
Include improved DA66Parser into importer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4681
diff
changeset
|
326 } |
4681
aa718770308e
Less than sceleton for DA66-CrossSection parser added.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
327 } |
4712
70842db72ee4
Include improved DA66Parser into importer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4681
diff
changeset
|
328 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
|
329 Matcher m = LINE_PATTERN.matcher(line); |
4712
70842db72ee4
Include improved DA66Parser into importer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4681
diff
changeset
|
330 if (m.find()) { |
70842db72ee4
Include improved DA66Parser into importer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4681
diff
changeset
|
331 //logger.info("Station: " + m.group(FIELD.STATION.getIdx())); |
70842db72ee4
Include improved DA66Parser into importer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4681
diff
changeset
|
332 // TODO if last station differs, error and abort |
70842db72ee4
Include improved DA66Parser into importer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4681
diff
changeset
|
333 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
|
334 // Point 1 |
70842db72ee4
Include improved DA66Parser into importer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4681
diff
changeset
|
335 if(addPoint( |
70842db72ee4
Include improved DA66Parser into importer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4681
diff
changeset
|
336 m.group(FIELD.POINT_1_Y.getIdx()), |
70842db72ee4
Include improved DA66Parser into importer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4681
diff
changeset
|
337 m.group(FIELD.POINT_1_Z.getIdx()), |
70842db72ee4
Include improved DA66Parser into importer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4681
diff
changeset
|
338 m.group(FIELD.POINT_1_ID.getIdx()))) { |
70842db72ee4
Include improved DA66Parser into importer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4681
diff
changeset
|
339 // Point added. |
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 else { |
70842db72ee4
Include improved DA66Parser into importer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4681
diff
changeset
|
342 // Problematic point. |
70842db72ee4
Include improved DA66Parser into importer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4681
diff
changeset
|
343 logger.error("A point could not be added"); |
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 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
|
347 // Point 2 |
70842db72ee4
Include improved DA66Parser into importer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4681
diff
changeset
|
348 if(addPoint( |
70842db72ee4
Include improved DA66Parser into importer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4681
diff
changeset
|
349 m.group(FIELD.POINT_2_Y.getIdx()), |
70842db72ee4
Include improved DA66Parser into importer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4681
diff
changeset
|
350 m.group(FIELD.POINT_2_Z.getIdx()), |
70842db72ee4
Include improved DA66Parser into importer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4681
diff
changeset
|
351 m.group(FIELD.POINT_2_ID.getIdx()))) { |
70842db72ee4
Include improved DA66Parser into importer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4681
diff
changeset
|
352 // Point added. |
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 else { |
70842db72ee4
Include improved DA66Parser into importer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4681
diff
changeset
|
355 // Problematic point. |
70842db72ee4
Include improved DA66Parser into importer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4681
diff
changeset
|
356 logger.error("A point could not be added"); |
70842db72ee4
Include improved DA66Parser into importer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4681
diff
changeset
|
357 } |
70842db72ee4
Include improved DA66Parser into importer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4681
diff
changeset
|
358 } |
70842db72ee4
Include improved DA66Parser into importer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4681
diff
changeset
|
359 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
|
360 // Point 3 |
70842db72ee4
Include improved DA66Parser into importer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4681
diff
changeset
|
361 if(addPoint( |
70842db72ee4
Include improved DA66Parser into importer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4681
diff
changeset
|
362 m.group(FIELD.POINT_3_Y.getIdx()), |
70842db72ee4
Include improved DA66Parser into importer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4681
diff
changeset
|
363 m.group(FIELD.POINT_3_Z.getIdx()), |
70842db72ee4
Include improved DA66Parser into importer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4681
diff
changeset
|
364 m.group(FIELD.POINT_3_ID.getIdx()))) { |
70842db72ee4
Include improved DA66Parser into importer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4681
diff
changeset
|
365 // Point added. |
70842db72ee4
Include improved DA66Parser into importer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4681
diff
changeset
|
366 } |
70842db72ee4
Include improved DA66Parser into importer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4681
diff
changeset
|
367 else { |
70842db72ee4
Include improved DA66Parser into importer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4681
diff
changeset
|
368 // Problematic point. |
70842db72ee4
Include improved DA66Parser into importer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4681
diff
changeset
|
369 logger.error("A point could not be added"); |
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 } |
70842db72ee4
Include improved DA66Parser into importer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4681
diff
changeset
|
372 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
|
373 // Point 4 |
70842db72ee4
Include improved DA66Parser into importer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4681
diff
changeset
|
374 if(addPoint( |
70842db72ee4
Include improved DA66Parser into importer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4681
diff
changeset
|
375 m.group(FIELD.POINT_4_Y.getIdx()), |
70842db72ee4
Include improved DA66Parser into importer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4681
diff
changeset
|
376 m.group(FIELD.POINT_4_Z.getIdx()), |
70842db72ee4
Include improved DA66Parser into importer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4681
diff
changeset
|
377 m.group(FIELD.POINT_4_ID.getIdx()))) { |
70842db72ee4
Include improved DA66Parser into importer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4681
diff
changeset
|
378 // Point added. |
70842db72ee4
Include improved DA66Parser into importer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4681
diff
changeset
|
379 } |
70842db72ee4
Include improved DA66Parser into importer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4681
diff
changeset
|
380 else { |
70842db72ee4
Include improved DA66Parser into importer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4681
diff
changeset
|
381 // Problematic point. |
70842db72ee4
Include improved DA66Parser into importer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4681
diff
changeset
|
382 logger.error("A point could not be added"); |
70842db72ee4
Include improved DA66Parser into importer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4681
diff
changeset
|
383 } |
70842db72ee4
Include improved DA66Parser into importer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4681
diff
changeset
|
384 } |
70842db72ee4
Include improved DA66Parser into importer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4681
diff
changeset
|
385 } |
70842db72ee4
Include improved DA66Parser into importer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4681
diff
changeset
|
386 else { |
70842db72ee4
Include improved DA66Parser into importer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4681
diff
changeset
|
387 logger.warn("Line could not be parsed: "); |
70842db72ee4
Include improved DA66Parser into importer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4681
diff
changeset
|
388 logger.warn(line); |
70842db72ee4
Include improved DA66Parser into importer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4681
diff
changeset
|
389 } |
4681
aa718770308e
Less than sceleton for DA66-CrossSection parser added.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
390 } |
4712
70842db72ee4
Include improved DA66Parser into importer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4681
diff
changeset
|
391 else if (HEAD_GEOM.equals(head)) { |
70842db72ee4
Include improved DA66Parser into importer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4681
diff
changeset
|
392 logger.debug("Hit a 88"); |
70842db72ee4
Include improved DA66Parser into importer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4681
diff
changeset
|
393 } |
70842db72ee4
Include improved DA66Parser into importer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4681
diff
changeset
|
394 else { |
70842db72ee4
Include improved DA66Parser into importer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4681
diff
changeset
|
395 logger.error("Do not know how to treat da66 line:"); |
70842db72ee4
Include improved DA66Parser into importer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4681
diff
changeset
|
396 logger.error(line); |
70842db72ee4
Include improved DA66Parser into importer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4681
diff
changeset
|
397 } |
70842db72ee4
Include improved DA66Parser into importer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4681
diff
changeset
|
398 } |
70842db72ee4
Include improved DA66Parser into importer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4681
diff
changeset
|
399 |
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 /** Called when file is fully consumed. */ |
70842db72ee4
Include improved DA66Parser into importer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4681
diff
changeset
|
402 @Override |
70842db72ee4
Include improved DA66Parser into importer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4681
diff
changeset
|
403 protected void finish() { |
70842db72ee4
Include improved DA66Parser into importer.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4681
diff
changeset
|
404 logger.info("Parsed " + data.size() + " lines"); |
4681
aa718770308e
Less than sceleton for DA66-CrossSection parser added.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
405 } |
aa718770308e
Less than sceleton for DA66-CrossSection parser added.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
406 |
aa718770308e
Less than sceleton for DA66-CrossSection parser added.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
407 |
aa718770308e
Less than sceleton for DA66-CrossSection parser added.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
408 /** Parses files given as arguments. */ |
aa718770308e
Less than sceleton for DA66-CrossSection parser added.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
409 public static void main(String [] args) { |
aa718770308e
Less than sceleton for DA66-CrossSection parser added.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
410 |
aa718770308e
Less than sceleton for DA66-CrossSection parser added.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
411 DA66Parser parser = new DA66Parser(); |
aa718770308e
Less than sceleton for DA66-CrossSection parser added.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
412 |
4719
7a8d3ec7abbc
DA66Parser: Improved logging.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4718
diff
changeset
|
413 logger.warn("Start parsing files."); |
4681
aa718770308e
Less than sceleton for DA66-CrossSection parser added.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
414 for (String arg: args) { |
aa718770308e
Less than sceleton for DA66-CrossSection parser added.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
415 parser.parseDA66s(new File(arg), null); |
aa718770308e
Less than sceleton for DA66-CrossSection parser added.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
416 logger.warn("Parsing a file."); |
aa718770308e
Less than sceleton for DA66-CrossSection parser added.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
417 } |
4719
7a8d3ec7abbc
DA66Parser: Improved logging.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4718
diff
changeset
|
418 logger.error("Finished parsing files."); |
4681
aa718770308e
Less than sceleton for DA66-CrossSection parser added.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
419 } |
aa718770308e
Less than sceleton for DA66-CrossSection parser added.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
420 } |
aa718770308e
Less than sceleton for DA66-CrossSection parser added.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
421 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |