annotate flys-backend/src/main/java/de/intevation/flys/model/FastCrossSectionLine.java @ 2803:cdc084071c14

Adapted the column type of relation 'dem' in oracle-spatial schema. flys-backend/trunk@4160 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Mon, 19 Mar 2012 06:11:38 +0000
parents e237a08acf6e
children 2f874d14ac68
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.math.BigDecimal;
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 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
11
e237a08acf6e Create fast cross section lines in the backend now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
12 public class FastCrossSectionLine
e237a08acf6e Create fast cross section lines in the backend now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
13 implements Serializable
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 double EPSILON = 1e-5;
e237a08acf6e Create fast cross section lines in the backend now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
16
e237a08acf6e Create fast cross section lines in the backend now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
17 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
18 new Comparator<FastCrossSectionLine>() {
e237a08acf6e Create fast cross section lines in the backend now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
19 public int compare(
e237a08acf6e Create fast cross section lines in the backend now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
20 FastCrossSectionLine a,
e237a08acf6e Create fast cross section lines in the backend now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
21 FastCrossSectionLine b
e237a08acf6e Create fast cross section lines in the backend now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
22 ) {
e237a08acf6e Create fast cross section lines in the backend now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
23 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
24 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
25 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
26 }
e237a08acf6e Create fast cross section lines in the backend now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
27 };
e237a08acf6e Create fast cross section lines in the backend now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
28
e237a08acf6e Create fast cross section lines in the backend now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
29 protected double km;
e237a08acf6e Create fast cross section lines in the backend now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
30 protected List<Point2D> points;
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 public FastCrossSectionLine() {
e237a08acf6e Create fast cross section lines in the backend now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
33 }
e237a08acf6e Create fast cross section lines in the backend now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
34
e237a08acf6e Create fast cross section lines in the backend now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
35 public FastCrossSectionLine(double km) {
e237a08acf6e Create fast cross section lines in the backend now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
36 this.km = km;
e237a08acf6e Create fast cross section lines in the backend now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
37 }
e237a08acf6e Create fast cross section lines in the backend now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
38
e237a08acf6e Create fast cross section lines in the backend now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
39 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
40 this(km);
e237a08acf6e Create fast cross section lines in the backend now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
41 this.points = points;
e237a08acf6e Create fast cross section lines in the backend now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
42 }
e237a08acf6e Create fast cross section lines in the backend now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
43
e237a08acf6e Create fast cross section lines in the backend now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
44 public FastCrossSectionLine(CrossSectionLine csl) {
e237a08acf6e Create fast cross section lines in the backend now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
45 BigDecimal kmBD = csl.getKm();
e237a08acf6e Create fast cross section lines in the backend now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
46 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
47 points = csl.fetchCrossSectionLinesPoints();
e237a08acf6e Create fast cross section lines in the backend now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
48 }
e237a08acf6e Create fast cross section lines in the backend now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
49
e237a08acf6e Create fast cross section lines in the backend now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
50 public double getKm() {
e237a08acf6e Create fast cross section lines in the backend now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
51 return km;
e237a08acf6e Create fast cross section lines in the backend now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
52 }
e237a08acf6e Create fast cross section lines in the backend now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
53
e237a08acf6e Create fast cross section lines in the backend now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
54 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
55 this.km = km;
e237a08acf6e Create fast cross section lines in the backend now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
56 }
e237a08acf6e Create fast cross section lines in the backend now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
57
e237a08acf6e Create fast cross section lines in the backend now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
58 public List<Point2D> getPoints() {
e237a08acf6e Create fast cross section lines in the backend now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
59 return points;
e237a08acf6e Create fast cross section lines in the backend now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
60 }
e237a08acf6e Create fast cross section lines in the backend now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
61
e237a08acf6e Create fast cross section lines in the backend now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
62 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
63 this.points = points;
e237a08acf6e Create fast cross section lines in the backend now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
64 }
e237a08acf6e Create fast cross section lines in the backend now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
65
e237a08acf6e Create fast cross section lines in the backend now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
66 public double [][] fetchCrossSectionProfile() {
e237a08acf6e Create fast cross section lines in the backend now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
67 return CrossSectionLine.fetchCrossSectionProfile(points);
e237a08acf6e Create fast cross section lines in the backend now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
68 }
e237a08acf6e Create fast cross section lines in the backend now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
69 }
e237a08acf6e Create fast cross section lines in the backend now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
70 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org