Mercurial > dive4elements > gnv-client
comparison gnv-artifacts/src/main/java/de/intevation/gnv/math/L1Comparator.java @ 798:6cff63d0c434
Fixed vim modeline. Added some Javadoc.
gnv-artifacts/trunk@880 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Sascha L. Teichmann <sascha.teichmann@intevation.de> |
---|---|
date | Tue, 06 Apr 2010 11:05:00 +0000 |
parents | b1f5f2a8840f |
children | bb7afd783321 |
comparison
equal
deleted
inserted
replaced
797:9d2891068ba5 | 798:6cff63d0c434 |
---|---|
3 import com.vividsolutions.jts.geom.Coordinate; | 3 import com.vividsolutions.jts.geom.Coordinate; |
4 | 4 |
5 import java.util.Comparator; | 5 import java.util.Comparator; |
6 | 6 |
7 /** | 7 /** |
8 * @author Sascha L. Teichmann | 8 * @author <a href="mailto:sascha.teichmann@intevation.de">Sascha L. Teichmann</a> |
9 */ | 9 */ |
10 public class L1Comparator | 10 public class L1Comparator |
11 implements Comparator | 11 implements Comparator |
12 { | 12 { |
13 private Coordinate ref; | 13 private Coordinate ref; |
24 } | 24 } |
25 | 25 |
26 public int compare(Object a, Object b) { | 26 public int compare(Object a, Object b) { |
27 Coordinate pa = (Coordinate)a; | 27 Coordinate pa = (Coordinate)a; |
28 Coordinate pb = (Coordinate)b; | 28 Coordinate pb = (Coordinate)b; |
29 double da = Point2d.L1(ref, pa); | 29 double da = L1(ref, pa); |
30 double db = Point2d.L1(ref, pb); | 30 double db = L1(ref, pb); |
31 if (da < db) return -1; | 31 if (da < db) return -1; |
32 if (da > db) return +1; | 32 if (da > db) return +1; |
33 return 0; | 33 return 0; |
34 } | 34 } |
35 | |
36 public static double L1(Coordinate a, Coordinate b) { | |
37 return Math.abs(a.x - b.x) + Math.abs(a.y - b.y); | |
38 } | |
39 | |
35 } | 40 } |
36 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8: | 41 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |
37 |