comparison flys-backend/src/main/java/de/intevation/flys/importer/parsers/DA66Parser.java @ 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.
author Sascha L. Teichmann <teichmann@intevation.de>
date Tue, 01 Jan 2013 13:54:08 +0100
parents 0df1cac6c4b5
children c10103dc202f
comparison
equal deleted inserted replaced
4734:0b4e1a493045 4735:94b39073f0f7
1 package de.intevation.flys.importer.parsers; 1 package de.intevation.flys.importer.parsers;
2
3 import de.intevation.artifacts.common.utils.FileTools;
4
5 import de.intevation.flys.importer.XY;
6
7 import de.intevation.flys.utils.EpsilonComparator;
8
9 import java.io.File;
10 import java.io.IOException;
2 11
3 import java.util.ArrayList; 12 import java.util.ArrayList;
4 import java.util.HashMap; 13 import java.util.HashMap;
14 import java.util.List;
5 import java.util.Map; 15 import java.util.Map;
6 import java.util.List;
7 import java.util.TreeMap; 16 import java.util.TreeMap;
8 17
18 import java.util.regex.Matcher;
9 import java.util.regex.Pattern; 19 import java.util.regex.Pattern;
10 import java.util.regex.Matcher;
11
12 import java.io.File;
13 import java.io.IOException;
14 20
15 import org.apache.log4j.Logger; 21 import org.apache.log4j.Logger;
16
17 import de.intevation.flys.importer.XY;
18
19 import de.intevation.artifacts.common.utils.FileTools;
20 22
21 23
22 /** 24 /**
23 * To create cross-sections, generate: Map<double,list<xy>> from files 25 * To create cross-sections, generate: Map<double,list<xy>> from files
24 * in da66 format. 26 * in da66 format.
76 POINT_3_Y (13), 78 POINT_3_Y (13),
77 POINT_3_Z (14), 79 POINT_3_Z (14),
78 POINT_4_ID(15), 80 POINT_4_ID(15),
79 POINT_4_Y (16), 81 POINT_4_Y (16),
80 POINT_4_Z (17); 82 POINT_4_Z (17);
81 83
82 private int idx; 84 private int idx;
83 FIELD(int idx) { 85 FIELD(int idx) {
84 this.idx = idx; 86 this.idx = idx;
85 } 87 }
86 int getIdx() { 88 int getIdx() {
170 protected Map<Double, List<XY>> data; 172 protected Map<Double, List<XY>> data;
171 173
172 174
173 /** Trivial constructor. */ 175 /** Trivial constructor. */
174 public DA66Parser() { 176 public DA66Parser() {
175 data = new TreeMap<Double, List<XY>>(); 177 data = new TreeMap<Double, List<XY>>(EpsilonComparator.CMP);
176 } 178 }
177 179
178 180
179 /** Get the description of the cross section parsed. */ 181 /** Get the description of the cross section parsed. */
180 @Override 182 @Override
264 if (z == null || y == null || idx == null) { 266 if (z == null || y == null || idx == null) {
265 logger.error("Incomplete point definition"); 267 logger.error("Incomplete point definition");
266 return false; 268 return false;
267 } 269 }
268 270
269 Double iy; 271 double iy;
270 Double iz; 272 double iz;
271 try { 273 try {
272 iy = Double.parseDouble(y) / 1000d; 274 iy = Double.parseDouble(y) / 1000d;
273 iz = Double.parseDouble(z) / 1000d; 275 iz = Double.parseDouble(z) / 1000d;
274 } 276 }
275 catch(java.lang.NumberFormatException nfe) { 277 catch(java.lang.NumberFormatException nfe) {
276 logger.error("Could not parse Number: " + nfe.getMessage()); 278 logger.error("Could not parse Number: " + nfe.getMessage());
277 return false; 279 return false;
278 } 280 }
279 281
280 // We ignore idx, and increment instead. 282 // We ignore idx, and increment instead.
281 Integer index; 283 int index;
282 int lastPointIdx = lastPointIdx(); 284 int lastPointIdx = lastPointIdx();
283 if (lastPointIdx <= 0) { 285 if (lastPointIdx <= 0) {
284 index = 1; 286 index = 1;
285 } else { 287 } else {
286 index = lastPointIdx + 1; 288 index = lastPointIdx + 1;

http://dive4elements.wald.intevation.org