diff gnv-artifacts/src/main/java/de/intevation/gnv/math/L1Comparator.java @ 657:af3f56758f59

merged gnv-artifacts/0.5
author Thomas Arendsen Hein <thomas@intevation.de>
date Fri, 28 Sep 2012 12:13:53 +0200
parents ab29e4ff2fda
children b1f5f2a8840f
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/gnv-artifacts/src/main/java/de/intevation/gnv/math/L1Comparator.java	Fri Sep 28 12:13:53 2012 +0200
@@ -0,0 +1,37 @@
+package de.intevation.gnv.math;
+
+import java.util.Comparator;
+
+import com.vividsolutions.jts.geom.Coordinate;
+
+/**
+ *  @author Sascha L. Teichmann
+ */
+public  class L1Comparator
+implements    Comparator
+{
+    private Coordinate ref;
+
+    public L1Comparator() {
+    }
+
+    public L1Comparator(Coordinate ref) {
+        this.ref = ref;
+    }
+
+    public void setReference(Coordinate ref) {
+        this.ref = ref;
+    }
+
+    public int compare(Object a, Object b) {
+        Coordinate pa = (Coordinate)a;
+        Coordinate pb = (Coordinate)b;
+        double da = Point2d.L1(ref, pa);
+        double db = Point2d.L1(ref, pb);
+        if (da < db) return -1;
+        if (da > db) return +1;
+        return 0;
+    }
+}
+// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8:
+

http://dive4elements.wald.intevation.org