comparison 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
comparison
equal deleted inserted replaced
590:5f5f273c8566 657:af3f56758f59
1 package de.intevation.gnv.math;
2
3 import java.util.Comparator;
4
5 import com.vividsolutions.jts.geom.Coordinate;
6
7 /**
8 * @author Sascha L. Teichmann
9 */
10 public class L1Comparator
11 implements Comparator
12 {
13 private Coordinate ref;
14
15 public L1Comparator() {
16 }
17
18 public L1Comparator(Coordinate ref) {
19 this.ref = ref;
20 }
21
22 public void setReference(Coordinate ref) {
23 this.ref = ref;
24 }
25
26 public int compare(Object a, Object b) {
27 Coordinate pa = (Coordinate)a;
28 Coordinate pb = (Coordinate)b;
29 double da = Point2d.L1(ref, pa);
30 double db = Point2d.L1(ref, pb);
31 if (da < db) return -1;
32 if (da > db) return +1;
33 return 0;
34 }
35 }
36 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8:
37

http://dive4elements.wald.intevation.org