Mercurial > dive4elements > river
diff flys-backend/src/main/java/de/intevation/flys/importer/PRFParser.java @ 1204:22858e7cca79
Integrated PRF parsing into importer. Needs testing!
flys-backend/trunk@2309 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Sascha L. Teichmann <sascha.teichmann@intevation.de> |
---|---|
date | Thu, 07 Jul 2011 22:25:38 +0000 |
parents | 7c88650ff548 |
children | c7370734b872 |
line wrap: on
line diff
--- a/flys-backend/src/main/java/de/intevation/flys/importer/PRFParser.java Thu Jul 07 15:59:24 2011 +0000 +++ b/flys-backend/src/main/java/de/intevation/flys/importer/PRFParser.java Thu Jul 07 22:25:38 2011 +0000 @@ -39,61 +39,9 @@ public static final int MIN_YEAR = 1800; public static final int MAX_YEAR = 2100; - public static final double X_EPSILON = 1e-4; - - public interface PRFCallback { - void found(PRFParser parser); - } // interface PRFParser - - public static final class XY - implements Comparable<XY> - { - protected double x; - protected double y; - protected int index; - - public XY() { - } - - public XY(double x, double y, int index) { - this.x = x; - this.y = y; - this.index = index; - } - - @Override - public int compareTo(XY other) { - if (x + X_EPSILON < other.x) return -1; - if (x > other.x + X_EPSILON) return +1; - if (index < other.index) return -1; - if (index > other.index) return +1; - return 0; - } - - public double getX() { - return x; - } - - public void setX(double x) { - this.x = x; - } - - public double getY() { - return y; - } - - public void setY(double y) { - this.y = y; - } - - public int getIndex() { - return index; - } - - public void setIndex(int index) { - this.index = index; - } - } // class XY + public interface Callback { + void prfParsed(PRFParser parser); + } // interface Parser public static class DataFormat { @@ -432,9 +380,7 @@ description = null; } - public static void parsePRFs(File root, PRFCallback callback) { - - PRFParser parser = new PRFParser(); + public void parsePRFs(File root, Callback callback) { Stack<File> stack = new Stack<File>(); stack.push(root); @@ -452,11 +398,11 @@ else if (file.isFile() && file.getName().toLowerCase().endsWith(".prf") ) { - parser.reset(); - boolean success = parser.parse(file); + reset(); + boolean success = parse(file); log.info("parsing " + (success ? "succeeded" : "failed")); if (success && callback != null) { - callback.found(parser); + callback.prfParsed(this); } } } @@ -464,8 +410,10 @@ public static void main(String [] args) { + PRFParser parser = new PRFParser(); + for (String arg: args) { - parsePRFs(new File(arg), null); + parser.parsePRFs(new File(arg), null); } } }