comparison flys-backend/src/main/java/de/intevation/flys/model/FastCrossSectionLine.java @ 2380:e237a08acf6e

Create fast cross section lines in the backend now. flys-backend/trunk@3696 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Sascha L. Teichmann <sascha.teichmann@intevation.de>
date Tue, 17 Jan 2012 16:56:38 +0000
parents
children 2f874d14ac68
comparison
equal deleted inserted replaced
2379:8be27b950dbe 2380:e237a08acf6e
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 :

http://dive4elements.wald.intevation.org