Mercurial > dive4elements > river
annotate flys-backend/src/main/java/de/intevation/flys/model/FastCrossSectionLine.java @ 5477:ae60bb7b8085
Add proper handling of multiple river_axes for datacage and rivermapfile
author | Andre Heinecke <aheinecke@intevation.de> |
---|---|
date | Wed, 27 Mar 2013 18:31:31 +0100 |
parents | 2f874d14ac68 |
children |
rev | line source |
---|---|
2380
e237a08acf6e
Create fast cross section lines in the backend now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
1 package de.intevation.flys.model; |
e237a08acf6e
Create fast cross section lines in the backend now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
2 |
e237a08acf6e
Create fast cross section lines in the backend now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
3 import java.util.List; |
e237a08acf6e
Create fast cross section lines in the backend now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
4 import java.util.Comparator; |
e237a08acf6e
Create fast cross section lines in the backend now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
5 |
e237a08acf6e
Create fast cross section lines in the backend now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
6 import java.io.Serializable; |
e237a08acf6e
Create fast cross section lines in the backend now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
7 |
e237a08acf6e
Create fast cross section lines in the backend now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
8 import java.awt.geom.Point2D; |
e237a08acf6e
Create fast cross section lines in the backend now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
9 |
e237a08acf6e
Create fast cross section lines in the backend now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
10 public class FastCrossSectionLine |
e237a08acf6e
Create fast cross section lines in the backend now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
11 implements Serializable |
e237a08acf6e
Create fast cross section lines in the backend now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
12 { |
e237a08acf6e
Create fast cross section lines in the backend now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
13 public static final double EPSILON = 1e-5; |
e237a08acf6e
Create fast cross section lines in the backend now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
14 |
e237a08acf6e
Create fast cross section lines in the backend now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
15 public static final Comparator<FastCrossSectionLine> KM_CMP = |
e237a08acf6e
Create fast cross section lines in the backend now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
16 new Comparator<FastCrossSectionLine>() { |
e237a08acf6e
Create fast cross section lines in the backend now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
17 public int compare( |
e237a08acf6e
Create fast cross section lines in the backend now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
18 FastCrossSectionLine a, |
e237a08acf6e
Create fast cross section lines in the backend now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
19 FastCrossSectionLine b |
e237a08acf6e
Create fast cross section lines in the backend now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
20 ) { |
e237a08acf6e
Create fast cross section lines in the backend now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
21 double diff = a.km - b.km; |
e237a08acf6e
Create fast cross section lines in the backend now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
22 if (diff < -EPSILON) return -1; |
e237a08acf6e
Create fast cross section lines in the backend now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
23 return diff > +EPSILON ? +1 : 0; |
e237a08acf6e
Create fast cross section lines in the backend now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
24 } |
e237a08acf6e
Create fast cross section lines in the backend now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
25 }; |
e237a08acf6e
Create fast cross section lines in the backend now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
26 |
e237a08acf6e
Create fast cross section lines in the backend now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
27 protected double km; |
e237a08acf6e
Create fast cross section lines in the backend now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
28 protected List<Point2D> points; |
e237a08acf6e
Create fast cross section lines in the backend now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
29 |
e237a08acf6e
Create fast cross section lines in the backend now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
30 public FastCrossSectionLine() { |
e237a08acf6e
Create fast cross section lines in the backend now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
31 } |
e237a08acf6e
Create fast cross section lines in the backend now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
32 |
e237a08acf6e
Create fast cross section lines in the backend now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
33 public FastCrossSectionLine(double km) { |
e237a08acf6e
Create fast cross section lines in the backend now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
34 this.km = km; |
e237a08acf6e
Create fast cross section lines in the backend now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
35 } |
e237a08acf6e
Create fast cross section lines in the backend now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
36 |
e237a08acf6e
Create fast cross section lines in the backend now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
37 public FastCrossSectionLine(double km, List<Point2D> points) { |
e237a08acf6e
Create fast cross section lines in the backend now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
38 this(km); |
e237a08acf6e
Create fast cross section lines in the backend now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
39 this.points = points; |
e237a08acf6e
Create fast cross section lines in the backend now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
40 } |
e237a08acf6e
Create fast cross section lines in the backend now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
41 |
e237a08acf6e
Create fast cross section lines in the backend now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
42 public FastCrossSectionLine(CrossSectionLine csl) { |
2860
2f874d14ac68
Use Doubles to store meassure points of profiles.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2380
diff
changeset
|
43 Double kmBD = csl.getKm(); |
2380
e237a08acf6e
Create fast cross section lines in the backend now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
44 km = kmBD != null ? kmBD.doubleValue() : 0d; |
e237a08acf6e
Create fast cross section lines in the backend now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
45 points = csl.fetchCrossSectionLinesPoints(); |
e237a08acf6e
Create fast cross section lines in the backend now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
46 } |
e237a08acf6e
Create fast cross section lines in the backend now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
47 |
e237a08acf6e
Create fast cross section lines in the backend now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
48 public double getKm() { |
e237a08acf6e
Create fast cross section lines in the backend now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
49 return km; |
e237a08acf6e
Create fast cross section lines in the backend now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
50 } |
e237a08acf6e
Create fast cross section lines in the backend now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
51 |
e237a08acf6e
Create fast cross section lines in the backend now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
52 public void setKm(double km) { |
e237a08acf6e
Create fast cross section lines in the backend now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
53 this.km = km; |
e237a08acf6e
Create fast cross section lines in the backend now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
54 } |
e237a08acf6e
Create fast cross section lines in the backend now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
55 |
e237a08acf6e
Create fast cross section lines in the backend now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
56 public List<Point2D> getPoints() { |
e237a08acf6e
Create fast cross section lines in the backend now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
57 return points; |
e237a08acf6e
Create fast cross section lines in the backend now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
58 } |
e237a08acf6e
Create fast cross section lines in the backend now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
59 |
e237a08acf6e
Create fast cross section lines in the backend now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
60 public void setPoints(List<Point2D> points) { |
e237a08acf6e
Create fast cross section lines in the backend now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
61 this.points = points; |
e237a08acf6e
Create fast cross section lines in the backend now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
62 } |
e237a08acf6e
Create fast cross section lines in the backend now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
63 |
e237a08acf6e
Create fast cross section lines in the backend now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
64 public double [][] fetchCrossSectionProfile() { |
e237a08acf6e
Create fast cross section lines in the backend now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
65 return CrossSectionLine.fetchCrossSectionProfile(points); |
e237a08acf6e
Create fast cross section lines in the backend now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
66 } |
e237a08acf6e
Create fast cross section lines in the backend now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
67 } |
e237a08acf6e
Create fast cross section lines in the backend now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
68 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |