Mercurial > dive4elements > river
comparison flys-backend/src/main/java/de/intevation/flys/model/FastCrossSectionLine.java @ 2386:cb7ebcadb214 2.6
merged flys-backend/2.6
author | Thomas Arendsen Hein <thomas@intevation.de> |
---|---|
date | Fri, 28 Sep 2012 12:14:23 +0200 |
parents | e237a08acf6e |
children | 2f874d14ac68 |
comparison
equal
deleted
inserted
replaced
2333:66946e278e66 | 2386:cb7ebcadb214 |
---|---|
1 package de.intevation.flys.model; | |
2 | |
3 import java.util.List; | |
4 import java.util.Comparator; | |
5 | |
6 import java.io.Serializable; | |
7 | |
8 import java.math.BigDecimal; | |
9 | |
10 import java.awt.geom.Point2D; | |
11 | |
12 public class FastCrossSectionLine | |
13 implements Serializable | |
14 { | |
15 public static final double EPSILON = 1e-5; | |
16 | |
17 public static final Comparator<FastCrossSectionLine> KM_CMP = | |
18 new Comparator<FastCrossSectionLine>() { | |
19 public int compare( | |
20 FastCrossSectionLine a, | |
21 FastCrossSectionLine b | |
22 ) { | |
23 double diff = a.km - b.km; | |
24 if (diff < -EPSILON) return -1; | |
25 return diff > +EPSILON ? +1 : 0; | |
26 } | |
27 }; | |
28 | |
29 protected double km; | |
30 protected List<Point2D> points; | |
31 | |
32 public FastCrossSectionLine() { | |
33 } | |
34 | |
35 public FastCrossSectionLine(double km) { | |
36 this.km = km; | |
37 } | |
38 | |
39 public FastCrossSectionLine(double km, List<Point2D> points) { | |
40 this(km); | |
41 this.points = points; | |
42 } | |
43 | |
44 public FastCrossSectionLine(CrossSectionLine csl) { | |
45 BigDecimal kmBD = csl.getKm(); | |
46 km = kmBD != null ? kmBD.doubleValue() : 0d; | |
47 points = csl.fetchCrossSectionLinesPoints(); | |
48 } | |
49 | |
50 public double getKm() { | |
51 return km; | |
52 } | |
53 | |
54 public void setKm(double km) { | |
55 this.km = km; | |
56 } | |
57 | |
58 public List<Point2D> getPoints() { | |
59 return points; | |
60 } | |
61 | |
62 public void setPoints(List<Point2D> points) { | |
63 this.points = points; | |
64 } | |
65 | |
66 public double [][] fetchCrossSectionProfile() { | |
67 return CrossSectionLine.fetchCrossSectionProfile(points); | |
68 } | |
69 } | |
70 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |