[Dive4elements-commits] [PATCH] Initial version of support files for TIMParser, comments and TODOs by Felix Wolfsteller, Code by Sascha Teichmann
Wald Commits
scm-commit at wald.intevation.org
Fri Dec 28 14:55:23 CET 2012
# HG changeset patch
# User Sascha Teichmann <sascha.teichmann at intevation.de>
# Date 1356703272 -3600
# Node ID 7fdddc6ba2964beee18c42cf3c627b7a0235dd39
# Parent 7d9fcd322c45c7487e42f2d2a68457b82bf4b6ad
Initial version of support files for TIMParser, comments and TODOs by Felix Wolfsteller, Code by Sascha Teichmann.
diff -r 7d9fcd322c45 -r 7fdddc6ba296 flys-backend/src/main/java/de/intevation/flys/importer/parsers/tim/Coordinate.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/flys-backend/src/main/java/de/intevation/flys/importer/parsers/tim/Coordinate.java Fri Dec 28 15:01:12 2012 +0100
@@ -0,0 +1,26 @@
+package de.intevation.flys.importer.parsers.tim;
+
+public class Coordinate
+{
+ public double x;
+ public double y;
+ public double z;
+
+ public Coordinate() {
+ }
+
+ public Coordinate(Coordinate c) {
+ this(c.x, c.y, c.z);
+ }
+
+ public Coordinate(double x, double y) {
+ this(x, y, 0d);
+ }
+
+ public Coordinate(double x, double y, double z) {
+ this.x = x;
+ this.y = y;
+ this.z = z;
+ }
+}
+// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
diff -r 7d9fcd322c45 -r 7fdddc6ba296 flys-backend/src/main/java/de/intevation/flys/importer/parsers/tim/EpsilonComparator.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/flys-backend/src/main/java/de/intevation/flys/importer/parsers/tim/EpsilonComparator.java Fri Dec 28 15:01:12 2012 +0100
@@ -0,0 +1,25 @@
+package de.intevation.flys.importer.parsers.tim;
+
+import java.util.Comparator;
+
+public class EpsilonComparator implements Comparator<Double>
+{
+ public static final double EPSILON = 1e-4;
+
+ public static final EpsilonComparator CMP = new EpsilonComparator(EPSILON);
+
+ private double epsilon;
+
+ public EpsilonComparator(double epsilon) {
+ this.epsilon = epsilon;
+ }
+
+ @Override
+ public int compare(Double a, Double b) {
+ double diff = a - b;
+ if (diff < -epsilon) return -1;
+ if (diff > epsilon) return +1;
+ return 0;
+ }
+}
+// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
diff -r 7d9fcd322c45 -r 7fdddc6ba296 flys-backend/src/main/java/de/intevation/flys/importer/parsers/tim/LexiComparator.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/flys-backend/src/main/java/de/intevation/flys/importer/parsers/tim/LexiComparator.java Fri Dec 28 15:01:12 2012 +0100
@@ -0,0 +1,18 @@
+package de.intevation.flys.importer.parsers.tim;
+
+import java.util.Comparator;
+
+public class LexiComparator implements Comparator<Coordinate> {
+
+ public static final LexiComparator CMP = new LexiComparator();
+
+ @Override
+ public int compare(Coordinate a, Coordinate b) {
+ if (a.x < b.x) return -1;
+ if (a.x > b.x) return +1;
+ if (a.y < b.y) return -1;
+ if (a.y > b.y) return +1;
+ return 0;
+ }
+}
+// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
diff -r 7d9fcd322c45 -r 7fdddc6ba296 flys-backend/src/main/java/de/intevation/flys/importer/parsers/tim/Line.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/flys-backend/src/main/java/de/intevation/flys/importer/parsers/tim/Line.java Fri Dec 28 15:01:12 2012 +0100
@@ -0,0 +1,33 @@
+package de.intevation.flys.importer.parsers.tim;
+
+public class Line {
+
+ public Coordinate a;
+ public Coordinate b;
+
+ public Line() {
+ }
+
+ public Line(Coordinate a, Coordinate b) {
+ this.a = a;
+ this.b = b;
+ }
+
+ /** Project coordinate to line. */
+ public double distanceToFirst(Coordinate c) {
+
+ double nx = b.x - a.x;
+ double ny = b.y - a.y;
+
+ double len = Math.sqrt(nx*nx + ny*ny);
+
+ nx /= len;
+ ny /= len;
+
+ double px = c.x - a.x;
+ double py = c.y - a.y;
+
+ return nx*px + ny*py;
+ }
+}
+// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
More information about the Dive4elements-commits
mailing list